Merge pull request #276 from hexdec/master

Window_resize_gui for scenario editor and window_zoom_in/out
This commit is contained in:
Ted John 2014-08-12 00:28:35 +01:00
commit 01974a0b9b
2 changed files with 76 additions and 4 deletions

View File

@ -909,7 +909,22 @@ void window_rotate_camera(rct_window *w)
*/
void window_zoom_in(rct_window *w)
{
RCT2_CALLPROC_X(0x006887A6, 0, 0, 0, 0, (int)w, 0, 0);
rct_viewport* v = w->viewport;
// Prevent zooming more than possible.
if (v->zoom <= 0) {
return;
}
v->zoom--;
v->view_width /= 2;
v->view_height /= 2;
w->saved_view_x += v->view_width >> 1;
w->saved_view_y += v->view_height >> 1;
RCT2_CALLPROC_X(0x006EB13A, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@ -918,7 +933,25 @@ void window_zoom_in(rct_window *w)
*/
void window_zoom_out(rct_window *w)
{
RCT2_CALLPROC_X(0x006887E0, 0, 0, 0, 0, (int)w, 0, 0);
rct_viewport* v = w->viewport;
// Prevent zooming more than possible.
if (v->zoom >= 3) {
return;
}
v->zoom++;
int width = v->view_width;
int height = v->view_height;
v->view_width *= 2;
v->view_height *= 2;
w->saved_view_x -= width / 2;
w->saved_view_y -= height >> 1;
RCT2_CALLPROC_X(0x006EB13A, 0, 0, 0, 0, (int)w, 0, 0);
}
/**
@ -1310,8 +1343,7 @@ void window_bubble_list_item(rct_window* w, int item_position){
void window_resize_gui(int width, int height)
{
if (RCT2_GLOBAL(0x9DEA68, uint8) & 0xE){
//Scenario editor version
RCT2_CALLPROC_EBPSAFE(0x66F0DD);
return window_resize_gui_scenario_editor(width, height);
}
rct_window* mainWind = window_get_main();
if (mainWind){
@ -1363,3 +1395,42 @@ void window_resize_gui(int width, int height)
exitWind->y = height - 64;
}
}
/**
* rct2: 0x0066F0DD
*/
void window_resize_gui_scenario_editor(int width, int height)
{
rct_window* mainWind = window_get_main();
if (mainWind) {
rct_viewport* viewport = mainWind->viewport;
mainWind->width = width;
mainWind->height = height;
RCT2_GLOBAL(0x9A9834, uint16) = width - 1;
RCT2_GLOBAL(0x9A9838, uint16) = height - 1;
viewport->width = width;
viewport->height = height;
viewport->view_width = width << viewport->zoom;
viewport->view_height = height << viewport->zoom;
if (mainWind->widgets != NULL && mainWind->widgets[0].type == WWT_VIEWPORT){
mainWind->widgets[0].right = width;
mainWind->widgets[0].bottom = height;
}
}
rct_window* topWind = window_find_by_id(WC_TOP_TOOLBAR, 0);
if (topWind){
topWind->width = max(640, width);
}
rct_window* bottomWind = window_find_by_id(WC_BOTTOM_TOOLBAR, 0);
if (bottomWind){
bottomWind->y = height - 32;
bottomWind->width = max(640, width);
RCT2_GLOBAL(0x9A997C, uint16) = bottomWind->width - 1;
RCT2_GLOBAL(0x9A997A, uint16) = bottomWind->width - 200;
RCT2_GLOBAL(0x9A998A, uint16) = bottomWind->width - 198;
RCT2_GLOBAL(0x9A998C, uint16) = bottomWind->width - 3;
}
}

View File

@ -346,6 +346,7 @@ void tool_cancel();
// Open window functions
void window_main_open();
void window_resize_gui(int width, int height);
void window_resize_gui_scenario_editor(int width, int height);
void window_game_top_toolbar_open();
void window_game_bottom_toolbar_open();
void window_about_open();