mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
add cancel and set tool along with path refactor
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
|
||||
#define RCT2_ADDRESS_TOOL_WINDOWNUMBER 0x009DE542
|
||||
#define RCT2_ADDRESS_TOOL_WINDOWCLASS 0x009DE544
|
||||
#define RCT2_ADDRESS_CURRENT_TOOL 0x009DE545
|
||||
#define RCT2_ADDRESS_TOOL_WIDGETINDEX 0x009DE546
|
||||
|
||||
#define RCT2_ADDRESS_CURSOR_OVER_WINDOWCLASS 0x009DE55C
|
||||
|
||||
67
src/window.c
67
src/window.c
@@ -1105,3 +1105,70 @@ void window_set_resize(rct_window *w, int minWidth, int minHeight, int maxWidth,
|
||||
window_invalidate(w);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EE212
|
||||
*
|
||||
* @param tool (al)
|
||||
* @param widgetIndex (dx)
|
||||
* @param w (esi)
|
||||
*/
|
||||
int tool_set(rct_window *w, int widgetIndex, int tool)
|
||||
{
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) {
|
||||
if (
|
||||
w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) &&
|
||||
w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) &&
|
||||
widgetIndex == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16)
|
||||
) {
|
||||
tool_cancel();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 3);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) &= ~(1 << 6);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TOOL, uint8) = tool;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) = w->classification;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) = w->number;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) = widgetIndex;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EE281
|
||||
*/
|
||||
void tool_cancel()
|
||||
{
|
||||
rct_window *w;
|
||||
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) {
|
||||
RCT2_GLOBAL(0x009DE518, uint32) &= ~(1 << 3);
|
||||
|
||||
//
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068AAE1);
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068AB1B);
|
||||
|
||||
// Reset map selection
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) = 0;
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, sint16) >= 0) {
|
||||
// Invalidate tool widget
|
||||
widget_invalidate(
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass),
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber),
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16)
|
||||
);
|
||||
|
||||
// Abort tool event
|
||||
w = window_find_by_id(
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass),
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber)
|
||||
);
|
||||
if (w != NULL)
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_ABORT], 0, 0, 0, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), w, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,6 +319,9 @@ void window_move_position(rct_window *w, int dx, int dy);
|
||||
void window_resize(rct_window *w, int dw, int dh);
|
||||
void window_set_resize(rct_window *w, int minWidth, int minHeight, int maxWidth, int maxHeight);
|
||||
|
||||
int tool_set(rct_window *w, int widgetIndex, int tool);
|
||||
void tool_cancel();
|
||||
|
||||
// Open window functions
|
||||
void window_main_open();
|
||||
void window_game_top_toolbar_open();
|
||||
|
||||
@@ -116,7 +116,7 @@ static void window_clear_scenery_close()
|
||||
{
|
||||
// If the tool wasn't changed, turn tool off
|
||||
if (!window_clear_scenery_should_close())
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
#include "window.h"
|
||||
#include "window_dropdown.h"
|
||||
|
||||
enum {
|
||||
PATH_CONSTRUCTION_MODE_LAND,
|
||||
PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL,
|
||||
PATH_CONSTRUCTION_MODE_2
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint16 pad_00;
|
||||
uint32 image; // 0x02
|
||||
@@ -193,9 +199,9 @@ void window_footpath_open()
|
||||
window->colours[1] = 24;
|
||||
window->colours[2] = 24;
|
||||
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
RCT2_GLOBAL(0x00F3EF99, uint8) = 0;
|
||||
RCT2_CALLPROC_X(0x006EE212, 17, 0, 0, 18, window, 0, 0);
|
||||
tool_cancel();
|
||||
RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_LAND;
|
||||
tool_set(window, WIDX_CONSTRUCT_ON_LAND, 17);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(0x00F3EF9F, uint8) = 0;
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A855C);
|
||||
@@ -242,10 +248,36 @@ static void window_footpath_mouseup()
|
||||
RCT2_CALLPROC_X(0x006A7863, 0, 0, 0, 0, w, 0, 0);
|
||||
break;
|
||||
case WIDX_CONSTRUCT_ON_LAND:
|
||||
RCT2_CALLPROC_X(0x006A8072, 0, 0, 0, widgetIndex, w, 0, 0);
|
||||
// RCT2_CALLPROC_X(0x006A8072, 0, 0, 0, widgetIndex, w, 0, 0);
|
||||
|
||||
if (RCT2_GLOBAL(0x00F3EF99, uint8) == PATH_CONSTRUCTION_MODE_LAND)
|
||||
break;
|
||||
_window_footpath_cost = 0x80000000;
|
||||
tool_cancel();
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A7831);
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068AB1B);
|
||||
RCT2_GLOBAL(0x009DE58A, uint16) &= ~2;
|
||||
RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_LAND;
|
||||
tool_set(w, WIDX_CONSTRUCT_ON_LAND, 17);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(0x00F3EF9F, uint8) = 0;
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A855C);
|
||||
break;
|
||||
case WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL:
|
||||
RCT2_CALLPROC_X(0x006A80C5, 0, 0, 0, widgetIndex, w, 0, 0);
|
||||
// RCT2_CALLPROC_X(0x006A80C5, 0, 0, 0, widgetIndex, w, 0, 0);
|
||||
|
||||
if (RCT2_GLOBAL(0x00F3EF99, uint8) == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL)
|
||||
break;
|
||||
_window_footpath_cost = 0x80000000;
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A7831);
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068AB1B);
|
||||
RCT2_GLOBAL(0x009DE58A, uint16) &= ~2;
|
||||
RCT2_GLOBAL(0x00F3EF99, uint8) = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
|
||||
tool_set(w, WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL, 12);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(0x00F3EF9F, uint8) = 0;
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A855C);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -451,14 +483,14 @@ static void window_footpath_update()
|
||||
RCT2_CALLPROC_EBPSAFE(0x006A7760);
|
||||
|
||||
// Check tool
|
||||
if (RCT2_GLOBAL(0x00F3EF99, uint8) == 0) {
|
||||
if (RCT2_GLOBAL(0x00F3EF99, uint8) == PATH_CONSTRUCTION_MODE_LAND) {
|
||||
if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)))
|
||||
window_close(w);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_FOOTPATH)
|
||||
window_close(w);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != WIDX_CONSTRUCT_ON_LAND)
|
||||
window_close(w);
|
||||
} else if (RCT2_GLOBAL(0x00F3EF99, uint8) == 1) {
|
||||
} else if (RCT2_GLOBAL(0x00F3EF99, uint8) == PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL) {
|
||||
if (!(RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)))
|
||||
window_close(w);
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_FOOTPATH)
|
||||
@@ -488,7 +520,7 @@ static void window_footpath_invalidate()
|
||||
(1 << WIDX_QUEUELINE_TYPE);
|
||||
|
||||
// Enable / disable construct button
|
||||
window_footpath_widgets[WIDX_CONSTRUCT].type = RCT2_GLOBAL(0x00F3EF99, uint8) == 0 ? WWT_EMPTY : WWT_IMGBTN;
|
||||
window_footpath_widgets[WIDX_CONSTRUCT].type = RCT2_GLOBAL(0x00F3EF99, uint8) == PATH_CONSTRUCTION_MODE_LAND ? WWT_EMPTY : WWT_IMGBTN;
|
||||
|
||||
// Set footpath and queue type button images
|
||||
selectedPath = RCT2_GLOBAL(0x00F3EFA0, uint16);
|
||||
|
||||
@@ -175,10 +175,10 @@ static void window_game_top_toolbar_mouseup()
|
||||
|
||||
case WIDX_CLEAR_SCENERY:
|
||||
if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 16) {
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
} else {
|
||||
show_gridlines();
|
||||
RCT2_CALLPROC_X(0x006EE212, 12, 0, 0, WIDX_CLEAR_SCENERY, w, 0, 0);
|
||||
tool_set(w, WIDX_CLEAR_SCENERY, 12);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 2;
|
||||
window_clear_scenery_open();
|
||||
@@ -186,10 +186,10 @@ static void window_game_top_toolbar_mouseup()
|
||||
break;
|
||||
case WIDX_LAND:
|
||||
if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 7) {
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
} else {
|
||||
show_gridlines();
|
||||
RCT2_CALLPROC_X(0x006EE212, 18, 0, 0, WIDX_LAND, w, 0, 0);
|
||||
tool_set(w, WIDX_LAND, 18);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1;
|
||||
window_land_open();
|
||||
@@ -197,17 +197,17 @@ static void window_game_top_toolbar_mouseup()
|
||||
break;
|
||||
case WIDX_WATER:
|
||||
if ((RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3)) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 8) {
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
} else {
|
||||
show_gridlines();
|
||||
RCT2_CALLPROC_X(0x006EE212, 19, 0, 0, WIDX_WATER, w, 0, 0);
|
||||
tool_set(w, WIDX_WATER, 19);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1;
|
||||
window_water_open();
|
||||
}
|
||||
break;
|
||||
case WIDX_SCENERY:
|
||||
RCT2_CALLPROC_X(0x006EE212, 0, 0, 0, WIDX_SCENERY, w, 0, 0);
|
||||
tool_set(w, WIDX_SCENERY, 0);
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= (1 << 6);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006E0FEF);
|
||||
break;
|
||||
@@ -215,7 +215,7 @@ static void window_game_top_toolbar_mouseup()
|
||||
if (window_find_by_id(WC_FOOTPATH, 0) == NULL) {
|
||||
window_footpath_open();
|
||||
} else {
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
window_close_by_id(0x80 | WC_FOOTPATH, 0);
|
||||
}
|
||||
break;
|
||||
@@ -345,7 +345,7 @@ static void window_game_top_toolbar_dropdown()
|
||||
RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, 0, 5, 0, 0);
|
||||
break;
|
||||
case 1: // save game
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
RCT2_CALLFUNC_X(0x006750E9, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
|
||||
@@ -152,7 +152,7 @@ static void window_land_close()
|
||||
{
|
||||
// If the tool wasn't changed, turn tool off
|
||||
if (!window_land_should_close())
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -645,7 +645,7 @@ static void window_park_entrance_close()
|
||||
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))
|
||||
if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber))
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1618,7 +1618,7 @@ void window_park_objective_open()
|
||||
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))
|
||||
if (window->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && window->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber))
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
|
||||
window->viewport = NULL;
|
||||
window->page = WINDOW_PARK_PAGE_OBJECTIVE;
|
||||
@@ -1895,7 +1895,7 @@ static void window_park_set_page(rct_window *w, int page)
|
||||
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 3))
|
||||
if (w->classification == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) && w->number == RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber))
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
|
||||
// Set listen only to viewport
|
||||
listen = 0;
|
||||
|
||||
@@ -117,7 +117,7 @@ static void window_water_close()
|
||||
{
|
||||
// If the tool wasn't changed, turn tool off
|
||||
if (!window_water_should_close())
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE281);
|
||||
tool_cancel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user