1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Fix top toolbar tool switching

Moved tool active checks to top toolbar so that it can use constants.
This commit is contained in:
Ted John
2017-04-30 22:33:19 +01:00
parent 75e0c94082
commit ae8aa2d466
6 changed files with 71 additions and 74 deletions

View File

@@ -792,6 +792,10 @@ void window_update_textbox();
bool window_is_visible(rct_window* w);
bool land_tool_is_active();
bool water_tool_is_active();
bool clear_scenery_tool_is_active();
bool land_rights_tool_is_active();
bool scenery_tool_is_active();
//Cheat: in-game land ownership editor
void toggle_ingame_land_ownership_editor();

View File

@@ -52,8 +52,6 @@ rct_widget window_clear_scenery_widgets[] = {
{ WIDGETS_END },
};
static sint32 window_clear_scenery_should_close();
static void window_clear_scenery_close(rct_window *w);
static void window_clear_scenery_mouseup(rct_window *w, sint32 widgetIndex);
static void window_clear_scenery_update(rct_window *w);
@@ -126,7 +124,7 @@ void window_clear_scenery_open()
static void window_clear_scenery_close(rct_window *w)
{
// If the tool wasn't changed, turn tool off
if (!window_clear_scenery_should_close())
if (clear_scenery_tool_is_active())
tool_cancel();
}
@@ -203,7 +201,7 @@ static void window_clear_scenery_inputsize(rct_window *w)
static void window_clear_scenery_update(rct_window *w)
{
// Close window if another tool is open
if (window_clear_scenery_should_close())
if (!clear_scenery_tool_is_active())
window_close(w);
}
@@ -252,18 +250,3 @@ static void window_clear_scenery_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, COLOUR_BLACK, &gClearSceneryCost);
}
}
/**
*
* rct2: 0x0066D125
*/
static sint32 window_clear_scenery_should_close()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return 1;
if (gCurrentToolWidget.window_classification != WC_TOP_TOOLBAR)
return 1;
if (gCurrentToolWidget.widget_index != 16)
return 1;
return 0;
}

View File

@@ -51,8 +51,6 @@ static rct_widget window_land_rights_widgets[] = {
{ WIDGETS_END },
};
static sint32 window_land_rights_should_close();
static void window_land_rights_close(rct_window *w);
static void window_land_rights_mouseup(rct_window *w, sint32 widgetIndex);
static void window_land_rights_update(rct_window *w);
@@ -119,7 +117,7 @@ void window_land_rights_open()
static void window_land_rights_close(rct_window *w)
{
// If the tool wasn't changed, turn tool off
if (!window_land_rights_should_close())
if (land_rights_tool_is_active())
tool_cancel();
}
@@ -192,7 +190,7 @@ static void window_land_rights_inputsize(rct_window *w)
static void window_land_rights_update(rct_window *w)
{
// Close window if another tool is open
if (window_land_rights_should_close())
if (!land_rights_tool_is_active())
window_close(w);
}
@@ -250,14 +248,3 @@ static void window_land_rights_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, COLOUR_BLACK, &gLandRightsCost);
}
}
static sint32 window_land_rights_should_close()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return 1;
if (gCurrentToolWidget.window_classification != WC_PARK_INFORMATION)
return 1;
if (gCurrentToolWidget.widget_index != 14)
return 1;
return 0;
}

View File

@@ -483,22 +483,6 @@ void window_scenery_open()
window->max_height = WINDOW_SCENERY_HEIGHT;
}
/**
*
* rct2: 0x0066DB3D
*/
static bool window_scenery_is_scenery_tool_active() {
sint32 toolWindowClassification = gCurrentToolWidget.window_classification;
sint32 toolWidgetIndex = gCurrentToolWidget.widget_index;
if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
if (toolWindowClassification == WC_TOP_TOOLBAR && toolWidgetIndex == 9) // 9 is WIDX_SCENERY
return true;
return false;
}
/**
*
* rct2: 0x006E1A73
@@ -509,7 +493,7 @@ void window_scenery_close(rct_window *w)
hide_gridlines();
viewport_set_visibility(0);
if (window_scenery_is_scenery_tool_active())
if (scenery_tool_is_active())
tool_cancel();
}
@@ -783,7 +767,7 @@ static void window_scenery_update(rct_window *w)
window_invalidate(w);
if (!window_scenery_is_scenery_tool_active()){
if (!scenery_tool_is_active()){
window_close(w);
return;
}

View File

@@ -3291,7 +3291,7 @@ void toggle_footpath_window()
*/
void toggle_land_window(rct_window *topToolbar, sint32 widgetIndex)
{
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == 7) {
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == WIDX_LAND) {
tool_cancel();
} else {
show_gridlines();
@@ -3308,7 +3308,7 @@ void toggle_land_window(rct_window *topToolbar, sint32 widgetIndex)
*/
void toggle_clear_scenery_window(rct_window *topToolbar, sint32 widgetIndex)
{
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == 16)) {
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == WIDX_CLEAR_SCENERY)) {
tool_cancel();
} else {
show_gridlines();
@@ -3325,7 +3325,7 @@ void toggle_clear_scenery_window(rct_window *topToolbar, sint32 widgetIndex)
*/
void toggle_water_window(rct_window *topToolbar, sint32 widgetIndex)
{
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == 8) {
if ((input_test_flag(INPUT_FLAG_TOOL_ACTIVE)) && gCurrentToolWidget.window_classification == WC_TOP_TOOLBAR && gCurrentToolWidget.widget_index == WIDX_WATER) {
tool_cancel();
} else {
show_gridlines();
@@ -3350,3 +3350,59 @@ bool land_tool_is_active()
return false;
return true;
}
/**
*
* rct2: 0x0066D125
*/
bool clear_scenery_tool_is_active()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != WC_TOP_TOOLBAR)
return false;
if (gCurrentToolWidget.widget_index != WIDX_CLEAR_SCENERY)
return false;
return true;
}
bool land_rights_tool_is_active()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != WC_PARK_INFORMATION)
return false;
if (gCurrentToolWidget.widget_index != WIDX_PARK)
return false;
return true;
}
/**
*
* rct2: 0x0066DB3D
*/
bool scenery_tool_is_active()
{
sint32 toolWindowClassification = gCurrentToolWidget.window_classification;
sint32 toolWidgetIndex = gCurrentToolWidget.widget_index;
if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
if (toolWindowClassification == WC_TOP_TOOLBAR && toolWidgetIndex == WIDX_SCENERY)
return true;
return false;
}
/**
*
* rct2: 0x0066D125
*/
bool water_tool_is_active()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return false;
if (gCurrentToolWidget.window_classification != WC_TOP_TOOLBAR)
return false;
if (gCurrentToolWidget.widget_index != WIDX_WATER)
return false;
return true;
}

View File

@@ -45,8 +45,6 @@ static rct_widget window_water_widgets[] = {
{ WIDGETS_END },
};
static sint32 window_water_should_close();
static void window_water_close(rct_window *w);
static void window_water_mouseup(rct_window *w, sint32 widgetIndex);
static void window_water_update(rct_window *w);
@@ -123,7 +121,7 @@ void window_water_open()
static void window_water_close(rct_window *w)
{
// If the tool wasn't changed, turn tool off
if (!window_water_should_close())
if (water_tool_is_active())
tool_cancel();
}
@@ -189,7 +187,7 @@ static void window_water_inputsize(rct_window *w)
static void window_water_update(rct_window *w)
{
// Close window if another tool is open
if (window_water_should_close())
if (!water_tool_is_active())
window_close(w);
}
@@ -243,18 +241,3 @@ static void window_water_paint(rct_window *w, rct_drawpixelinfo *dpi)
}
/**
*
* rct2: 0x0066D125
*/
static sint32 window_water_should_close()
{
if (!(input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
return 1;
if (gCurrentToolWidget.window_classification != WC_TOP_TOOLBAR)
return 1;
if (gCurrentToolWidget.widget_index != 8)
return 1;
return 0;
}