mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #539 from duncanspumpkin/window_banner_s
Window banner complete
This commit is contained in:
commit
55085d60af
|
@ -347,8 +347,8 @@ static int editor_read_s4(char *src)
|
|||
|
||||
for (i = 0; i < MAX_BANNERS; i++) {
|
||||
banner = &gBanners[i];
|
||||
if (banner->var_00 != 255 && banner->var_02 != 3458)
|
||||
banner->var_02 = 778;
|
||||
if (banner->var_00 != 255 && banner->string_idx != 3458)
|
||||
banner->string_idx = 778;
|
||||
}
|
||||
|
||||
read((void*)0x0135A8F4, &src, 0x2F51C);
|
||||
|
@ -394,4 +394,4 @@ static int editor_read_s6(const char *path)
|
|||
strcpy((char *)0x0141EF68, path);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006758FE);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ void sub_0x0069E9A7();
|
|||
void update_palette_effects();
|
||||
|
||||
int game_do_command(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
|
||||
int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *edi, int *esi, int *ebp);
|
||||
int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *esi, int *edi, int *ebp);
|
||||
|
||||
void game_increase_game_speed();
|
||||
void game_reduce_game_speed();
|
||||
|
|
|
@ -503,7 +503,7 @@ void window_ride_construct(rct_window *w);
|
|||
void window_ride_list_open();
|
||||
void window_track_place_open();
|
||||
void window_new_ride_open();
|
||||
void window_banner_open();
|
||||
void window_banner_open(rct_windownumber number);
|
||||
void window_cheats_open();
|
||||
void window_research_open();
|
||||
void window_scenery_open();
|
||||
|
|
|
@ -20,11 +20,21 @@
|
|||
|
||||
#include <string.h>
|
||||
#include "../addresses.h"
|
||||
#include "../game.h"
|
||||
#include "../config.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../interface/viewport.h"
|
||||
#include "../interface/widget.h"
|
||||
#include "../interface/window.h"
|
||||
#include "../world/map.h"
|
||||
#include "../world/banner.h"
|
||||
#include "../world/scenery.h"
|
||||
#include "error.h"
|
||||
#include "dropdown.h"
|
||||
#include "../drawing/drawing.h"
|
||||
|
||||
#define WW 113
|
||||
#define WH 96
|
||||
|
||||
enum WINDOW_BANNER_WIDGET_IDX {
|
||||
WIDX_BACKGROUND,
|
||||
|
@ -40,16 +50,16 @@ enum WINDOW_BANNER_WIDGET_IDX {
|
|||
};
|
||||
|
||||
rct_widget window_banner_widgets[] = {
|
||||
{ WWT_FRAME, 0, 0, 112, 0, 95, 0x0FFFFFFFF, 65535}, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, 111, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar
|
||||
{ WWT_CLOSEBOX, 0, 100, 110, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button
|
||||
{ WWT_VIEWPORT, 1, 3, 87, 17, 76, 0x0FFFFFFFE, 65535}, // tab content panel
|
||||
{ WWT_FLATBTN, 1, 88, 111, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button
|
||||
{ WWT_FLATBTN, 1, 88, 111, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button
|
||||
{ WWT_FLATBTN, 1, 88, 111, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button
|
||||
{ WWT_COLORBTN, 1, 5, 16, 80, 91, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money
|
||||
{ WWT_DROPDOWN, 1, 43, 81, 80, 91, 0x0FFFFFFFF, 65535}, // high money
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 70, 80, 81, 90, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money
|
||||
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, 0x0FFFFFFFF, 65535}, // panel / background
|
||||
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, 0xBA9, STR_WINDOW_TITLE_TIP}, // title bar
|
||||
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, 0x338, STR_CLOSE_WINDOW_TIP}, // close x button
|
||||
{ WWT_VIEWPORT, 1, 3, WW - 26,17, WH - 20, 0x0FFFFFFFE, 65535}, // tab content panel
|
||||
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 19, 42, 0x1430, STR_CHANGE_BANNER_TEXT_TIP}, // change banner button
|
||||
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 43, 66, 0x143A, STR_SET_AS_NO_ENTRY_BANNER_TIP}, // no entry button
|
||||
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 67, 90, 0x142D, STR_DEMOLISH_BANNER_TIP}, // demolish button
|
||||
{ WWT_COLORBTN, 1, 5, 16, WH - 16,WH - 5, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP}, // high money
|
||||
{ WWT_DROPDOWN, 1, 43, 81, WH - 16,WH - 5, 0x0FFFFFFFF, 65535}, // high money
|
||||
{ WWT_DROPDOWN_BUTTON, 1, 70, 80, WH - 15,WH - 6, 0x36C, STR_SELECT_TEXT_COLOR_TIP}, // high money
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
|
@ -60,13 +70,14 @@ static void window_banner_dropdown();
|
|||
static void window_banner_textinput();
|
||||
static void window_banner_invalidate();
|
||||
static void window_banner_paint();
|
||||
static void window_banner_unknown_14();
|
||||
|
||||
static void* window_banner_events[] = {
|
||||
window_banner_emptysub,
|
||||
window_banner_mouseup,
|
||||
window_banner_emptysub,
|
||||
window_banner_mousedown,
|
||||
window_banner_dropdown,
|
||||
window_banner_mousedown,
|
||||
window_banner_dropdown,
|
||||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
|
@ -82,13 +93,13 @@ static void* window_banner_events[] = {
|
|||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
window_banner_textinput,
|
||||
(void*)0x006BA7B5,
|
||||
window_banner_unknown_14,
|
||||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
window_banner_emptysub,
|
||||
window_banner_invalidate,
|
||||
window_banner_paint,
|
||||
window_banner_paint,
|
||||
window_banner_emptysub
|
||||
};
|
||||
|
||||
|
@ -96,21 +107,18 @@ static void* window_banner_events[] = {
|
|||
*
|
||||
* rct2: 0x006BA305
|
||||
*/
|
||||
void window_banner_open()
|
||||
void window_banner_open(rct_windownumber number)
|
||||
{
|
||||
rct_windownumber windownumber;
|
||||
rct_window* w;
|
||||
rct_widget *viewportWidget;
|
||||
|
||||
//__asm mov windownumber, ax // not quite right I think
|
||||
windownumber = 0;
|
||||
|
||||
// Check if window is already open
|
||||
w = window_bring_to_front_by_number(WC_BANNER, windownumber);
|
||||
w = window_bring_to_front_by_number(WC_BANNER, number);
|
||||
if (w != NULL)
|
||||
return;
|
||||
|
||||
w = window_create_auto_pos(113, 96, (uint32*)window_banner_events, WC_BANNER, 0);
|
||||
w = window_create_auto_pos(WW, WH, (uint32*)window_banner_events, WC_BANNER, 0);
|
||||
w->widgets = window_banner_widgets;
|
||||
w->enabled_widgets =
|
||||
(1 << WIDX_CLOSE) |
|
||||
|
@ -121,15 +129,30 @@ void window_banner_open()
|
|||
(1 << WIDX_TEXT_COLOR_DROPDOWN) |
|
||||
(1 << WIDX_TEXT_COLOR_DROPDOWN_BUTTON);
|
||||
|
||||
w->number = windownumber;
|
||||
w->number = number;
|
||||
window_init_scroll_widgets(w);
|
||||
w->colours[0] = 24;
|
||||
w->colours[1] = 24;
|
||||
w->colours[2] = 24;
|
||||
|
||||
/*
|
||||
TODO: MISSING CODE 006BA377 -> 006BA3F6, need the banner map element
|
||||
*/
|
||||
int view_x = gBanners[w->number].x << 5;
|
||||
int view_y = gBanners[w->number].y << 5;
|
||||
int ebp = ((view_y << 8) | view_x) >> 5;
|
||||
|
||||
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER(ebp);
|
||||
|
||||
while(1){
|
||||
if (((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_BANNER) &&
|
||||
(map_element->properties.banner.index == w->number)) break;
|
||||
|
||||
map_element++;
|
||||
}
|
||||
|
||||
int view_z = map_element->base_height<<3;
|
||||
w->frame_no = view_z;
|
||||
|
||||
view_x += 16;
|
||||
view_y += 16;
|
||||
|
||||
// Create viewport
|
||||
viewportWidget = &window_banner_widgets[WIDX_VIEWPORT];
|
||||
|
@ -140,18 +163,19 @@ void window_banner_open()
|
|||
(viewportWidget->right - viewportWidget->left) - 2,
|
||||
(viewportWidget->bottom - viewportWidget->top) - 2,
|
||||
0,
|
||||
100, // TODO: needs banner map position
|
||||
100, // TODO: needs banner map position
|
||||
100,
|
||||
view_x,
|
||||
view_y,
|
||||
view_z,
|
||||
0,
|
||||
-1
|
||||
);
|
||||
|
||||
w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0;
|
||||
w->flags |= WF_2 | WF_TRANSPARENT;
|
||||
w->flags |= WF_2;
|
||||
window_invalidate(w);
|
||||
}
|
||||
|
||||
/* rct2: 0x6ba4d6*/
|
||||
static void window_banner_mouseup()
|
||||
{
|
||||
short widgetIndex;
|
||||
|
@ -159,77 +183,200 @@ static void window_banner_mouseup()
|
|||
|
||||
window_widget_get_registers(w, widgetIndex);
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
int x = banner->x << 5;
|
||||
int y = banner->y << 5;
|
||||
|
||||
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER(((y << 8) | x) >> 5);
|
||||
|
||||
while (1){
|
||||
if (((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_BANNER) &&
|
||||
(map_element->properties.banner.index == w->number)) break;
|
||||
map_element++;
|
||||
}
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
break;
|
||||
case WIDX_BANNER_DEMOLISH:
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA739);
|
||||
game_do_command(x, 1, y, map_element->base_height | (map_element->properties.banner.position << 8), GAME_COMMAND_51, 0, 0);
|
||||
break;
|
||||
case WIDX_BANNER_TEXT:
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA6BC);
|
||||
window_text_input_open(w, WIDX_BANNER_TEXT, 2982, 2983, gBanners[w->number].string_idx, 0);
|
||||
break;
|
||||
case WIDX_BANNER_NO_ENTRY:
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA64D);
|
||||
RCT2_CALLPROC_EBPSAFE(0x006EE3C3);
|
||||
banner->flags ^= BANNER_FLAG_NO_ENTRY;
|
||||
window_invalidate(w);
|
||||
|
||||
map_element->properties.banner.flags = 0xFF;
|
||||
if (banner->flags & BANNER_FLAG_NO_ENTRY){
|
||||
map_element->properties.banner.flags &= ~(1 << map_element->properties.banner.position);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x6ba4ff */
|
||||
static void window_banner_mousedown(int widgetIndex, rct_window*w, rct_widget* widget)
|
||||
{
|
||||
//short widgetIndex;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
//__asm mov widgetIndex, dx
|
||||
#else
|
||||
// __asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
|
||||
switch (widgetIndex) {
|
||||
case WIDX_MAIN_COLOR:
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA528);
|
||||
window_dropdown_show_colour(w, widget, w->colours[1] | 0x80, banner->colour);
|
||||
break;
|
||||
case WIDX_TEXT_COLOR_DROPDOWN_BUTTON:
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA563);
|
||||
|
||||
for( int i = 0; i < 13; ++i){
|
||||
gDropdownItemsFormat[i] = 1142;
|
||||
gDropdownItemsArgs[i] = 2997 + i;
|
||||
|
||||
}
|
||||
|
||||
//Switch to the dropdown box widget.
|
||||
widget--;
|
||||
|
||||
window_dropdown_show_text_custom_width(
|
||||
widget->left + w->x,
|
||||
widget->top + w->y,
|
||||
widget->bottom - widget->top + 1,
|
||||
w->colours[1],
|
||||
0x80,
|
||||
13,
|
||||
widget->right - widget->left - 3);
|
||||
|
||||
gDropdownItemsChecked = 1 << (banner->text_colour - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x6ba517 */
|
||||
static void window_banner_dropdown()
|
||||
{
|
||||
short widgetIndex, dropdownIndex;
|
||||
rct_window* w;
|
||||
|
||||
window_dropdown_get_registers(w, widgetIndex, dropdownIndex);
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
|
||||
if (widgetIndex == WIDX_MAIN_COLOR)
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA548);
|
||||
else if (widgetIndex == WIDX_TEXT_COLOR_DROPDOWN_BUTTON)
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA5D0);
|
||||
}
|
||||
switch(widgetIndex){
|
||||
case WIDX_MAIN_COLOR:
|
||||
if ( dropdownIndex == 0xFFFF) return;
|
||||
banner->colour = (uint8)dropdownIndex;
|
||||
window_invalidate(w);
|
||||
break;
|
||||
case WIDX_TEXT_COLOR_DROPDOWN_BUTTON:
|
||||
if ( dropdownIndex == 0xFFFF) return;
|
||||
banner->text_colour = dropdownIndex + 1;
|
||||
|
||||
static void window_banner_textinput()
|
||||
{
|
||||
short widgetIndex;
|
||||
//Can be replaced with a buffer 34 chars wide ( 32 character + 1 colour_format + 1 '\0')
|
||||
uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8);
|
||||
|
||||
format_string(text_buffer, banner->string_idx, 0);
|
||||
|
||||
if (text_buffer[0] < FORMAT_COLOUR_CODE_START
|
||||
|| text_buffer[0] > FORMAT_COLOUR_CODE_END){
|
||||
int end_point = strlen(text_buffer) + 1;
|
||||
strncpy(text_buffer + 1, text_buffer, 32);
|
||||
text_buffer[end_point] = '\0';
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov widgetIndex, dx;
|
||||
#else
|
||||
__asm__ ( "mov %[widgetIndex], dx; " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START;
|
||||
|
||||
int string_id = 0, ebx = 0, ecx = 128, edx = 0, ebp = 0, esi = 0;
|
||||
// Allocate text_buffer to a new string_id?
|
||||
RCT2_CALLFUNC_X(0x6C421D, &string_id, &ebx, &ecx, &edx, &esi, (int*)&text_buffer, &ebp);
|
||||
|
||||
if (widgetIndex == WIDX_BANNER_TEXT) {
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA6D8);
|
||||
if (string_id){
|
||||
rct_string_id prev_string_id = banner->string_idx;
|
||||
banner->string_idx = string_id;
|
||||
// De-allocate previous string id?
|
||||
RCT2_CALLPROC_X(0x6C42AC, prev_string_id, 0, 0, 0, 0, 0, 0);
|
||||
window_invalidate(w);
|
||||
}
|
||||
else{
|
||||
window_error_open(2984, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_banner_invalidate()
|
||||
/* rct2: 0x6ba50c */
|
||||
static void window_banner_textinput()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BA44D);
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
uint8 result;
|
||||
uint8* text;
|
||||
|
||||
window_text_input_get_registers(w, widgetIndex, result, text);
|
||||
|
||||
|
||||
if (widgetIndex == WIDX_BANNER_TEXT && result) {
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
|
||||
uint8* text_buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, uint8);
|
||||
|
||||
text_buffer[0] = banner->text_colour + FORMAT_COLOUR_CODE_START;
|
||||
strncpy(text_buffer + 1, text, 32);
|
||||
|
||||
int string_id = 0, ebx = 0, ecx = 128, edx = 0, ebp = 0, esi = 0;
|
||||
RCT2_CALLFUNC_X(0x6C421D, &string_id, &ebx, &ecx, &edx, &esi, (int*)&text_buffer, &ebp);
|
||||
|
||||
if (string_id){
|
||||
rct_string_id prev_string_id = banner->string_idx;
|
||||
banner->string_idx = string_id;
|
||||
// De-allocate previous string id?
|
||||
RCT2_CALLPROC_X(0x6C42AC, prev_string_id, 0, 0, 0, 0, 0, 0);
|
||||
window_invalidate(w);
|
||||
}
|
||||
else{
|
||||
window_error_open(2984, RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x006BA44D */
|
||||
static void window_banner_invalidate()
|
||||
{
|
||||
rct_window* w;
|
||||
|
||||
window_get_register(w);
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
rct_widget* colour_btn = &window_banner_widgets[WIDX_MAIN_COLOR];
|
||||
colour_btn->type = WWT_EMPTY;
|
||||
|
||||
//sceneray item not sure why we use this instead of banner?
|
||||
rct_scenery_entry* sceneryEntry = g_bannerSceneryEntries[banner->var_00];
|
||||
|
||||
if (sceneryEntry->banner.flags & 1) colour_btn->type = WWT_COLORBTN;
|
||||
|
||||
w->pressed_widgets &= ~(1ULL<<WIDX_BANNER_NO_ENTRY);
|
||||
w->disabled_widgets &= ~(
|
||||
(1ULL<<WIDX_BANNER_TEXT)|
|
||||
(1ULL<<WIDX_TEXT_COLOR_DROPDOWN)|
|
||||
(1ULL<<WIDX_TEXT_COLOR_DROPDOWN_BUTTON));
|
||||
|
||||
if (banner->flags & BANNER_FLAG_NO_ENTRY){
|
||||
w->pressed_widgets |= (1ULL<<WIDX_BANNER_NO_ENTRY);
|
||||
w->disabled_widgets |=
|
||||
(1ULL<<WIDX_BANNER_TEXT)|
|
||||
(1ULL<<WIDX_TEXT_COLOR_DROPDOWN)|
|
||||
(1ULL<<WIDX_TEXT_COLOR_DROPDOWN_BUTTON);
|
||||
}
|
||||
|
||||
colour_btn->image = (banner->colour << 19) + 0x600013C3;
|
||||
|
||||
rct_widget* drop_down_widget = &window_banner_widgets[WIDX_TEXT_COLOR_DROPDOWN];
|
||||
drop_down_widget->image = banner->text_colour + 2996;
|
||||
}
|
||||
|
||||
/* rct2:0x006BA4C5 */
|
||||
static void window_banner_paint()
|
||||
{
|
||||
rct_window *w;
|
||||
|
@ -244,3 +391,41 @@ static void window_banner_paint()
|
|||
window_draw_viewport(dpi, w);
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x6BA7B5 */
|
||||
static void window_banner_unknown_14()
|
||||
{
|
||||
rct_window* w;
|
||||
window_get_register(w);
|
||||
|
||||
rct_viewport* view = w->viewport;
|
||||
w->viewport = 0;
|
||||
|
||||
view->width = 0;
|
||||
viewport_update_pointers();
|
||||
|
||||
rct_banner* banner = &gBanners[w->number];
|
||||
|
||||
int view_x = (banner->x << 5) + 16;
|
||||
int view_y = (banner->y << 5) + 16;
|
||||
int view_z = w->frame_no;
|
||||
|
||||
// Create viewport
|
||||
rct_widget* viewportWidget = &window_banner_widgets[WIDX_VIEWPORT];
|
||||
viewport_create(
|
||||
w,
|
||||
w->x + viewportWidget->left + 1,
|
||||
w->y + viewportWidget->top + 1,
|
||||
(viewportWidget->right - viewportWidget->left) - 1,
|
||||
(viewportWidget->bottom - viewportWidget->top) - 1,
|
||||
0,
|
||||
view_x,
|
||||
view_y,
|
||||
view_z,
|
||||
0,
|
||||
-1
|
||||
);
|
||||
|
||||
w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0;
|
||||
window_invalidate(w);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#include "../interface/window.h"
|
||||
#include "dropdown.h"
|
||||
#include "../interface/viewport.h"
|
||||
#include "scenery.h"
|
||||
#include "../audio/audio.h"
|
||||
|
||||
enum {
|
||||
WIDX_PAUSE,
|
||||
|
@ -106,6 +108,7 @@ static void window_game_top_toolbar_mousedown(int widgetIndex, rct_window*w, rct
|
|||
static void window_game_top_toolbar_dropdown();
|
||||
static void window_game_top_toolbar_invalidate();
|
||||
static void window_game_top_toolbar_paint();
|
||||
static void window_game_top_toolbar_tool_down();
|
||||
|
||||
static void* window_game_top_toolbar_events[] = {
|
||||
window_game_top_toolbar_emptysub,
|
||||
|
@ -117,8 +120,8 @@ static void* window_game_top_toolbar_events[] = {
|
|||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
(void*)0x0066CB25,
|
||||
(void*)0x0066CB73,
|
||||
(void*)0x0066CB25, //Update
|
||||
window_game_top_toolbar_tool_down,
|
||||
(void*)0x0066CB4E,
|
||||
(void*)0x0066CC5B,
|
||||
(void*)0x0066CA58,
|
||||
|
@ -596,3 +599,108 @@ static void window_game_top_toolbar_paint()
|
|||
imgId = SPR_TAB_FINANCES_RESEARCH_0;
|
||||
gfx_draw_sprite(dpi, imgId, x, y, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x6e2cc6
|
||||
*/
|
||||
static void window_game_top_toolbar_scenery_tool_down(short x, short y, rct_window* w, short widgetIndex){
|
||||
RCT2_CALLPROC_EBPSAFE(0x006E2712);
|
||||
if (window_scenery_is_repaint_scenery_tool_on & 1){
|
||||
//6e3158
|
||||
RCT2_CALLPROC_X(0x6E2CC6, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
}
|
||||
|
||||
int selected_tab = window_scenery_selected_scenery_by_tab[window_scenery_active_tab_index];
|
||||
if (selected_tab == -1) return;
|
||||
|
||||
sint16 grid_x, grid_y, grid_z;
|
||||
uint8 item_colour;
|
||||
int ebp = selected_tab;
|
||||
|
||||
{
|
||||
int eax = x, ebx = y, ecx = 0, edx = 0, esi = 0, edi = 0, ebp = selected_tab;
|
||||
RCT2_CALLFUNC_X(0x6E1F34, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
item_colour = edi;
|
||||
grid_x = eax;
|
||||
grid_y = ecx;
|
||||
grid_z = edx;
|
||||
}
|
||||
|
||||
if (grid_x == 0x8000)return;
|
||||
|
||||
if (ebp >= 1024){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = 1161;
|
||||
|
||||
// The return value will be banner id but the input is colour
|
||||
int banner_id = item_colour;
|
||||
|
||||
int ebx = 1;
|
||||
|
||||
{
|
||||
int esi = 0, eax = grid_x, ecx = grid_y, edx = grid_z;
|
||||
game_do_command_p(GAME_COMMAND_50, &eax, &ebx, &ecx, &edx, &esi, &banner_id, &ebp);
|
||||
}
|
||||
|
||||
if (ebx == 0x80000000)return;
|
||||
|
||||
sound_play_panned(SOUND_PLACE_ITEM, 0x8001, RCT2_GLOBAL(0x009DEA5E, uint16), RCT2_GLOBAL(0x009DEA60, uint16), RCT2_GLOBAL(0x009DEA62, uint16));
|
||||
|
||||
window_banner_open(banner_id);
|
||||
}
|
||||
else if (ebp >= 768){
|
||||
//6e301c
|
||||
RCT2_CALLPROC_X(0x6E2CC6, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
}
|
||||
else if (ebp >= 512){
|
||||
//6e2f2e
|
||||
RCT2_CALLPROC_X(0x6E2CC6, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
}
|
||||
else if (ebp >= 256){
|
||||
//6e2eda
|
||||
RCT2_CALLPROC_X(0x6E2CC6, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
}
|
||||
else{
|
||||
//6e2d2d
|
||||
RCT2_CALLPROC_X(0x6E2CC6, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x0066CB73
|
||||
*/
|
||||
static void window_game_top_toolbar_tool_down(){
|
||||
short widgetIndex;
|
||||
rct_window* w;
|
||||
short x, y;
|
||||
|
||||
window_tool_get_registers(w, widgetIndex, x, y);
|
||||
|
||||
switch (widgetIndex){
|
||||
case WIDX_CLEAR_SCENERY:
|
||||
if (!RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16)&(1 << 0)){
|
||||
return;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = 3438;
|
||||
|
||||
game_do_command(
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16),
|
||||
1,
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16),
|
||||
0,
|
||||
GAME_COMMAND_57,
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16),
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16)
|
||||
);
|
||||
break;
|
||||
case WIDX_LAND:
|
||||
RCT2_CALLPROC_X(0x66CBF3, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
break;
|
||||
case WIDX_WATER:
|
||||
RCT2_CALLPROC_X(0x66CC48, x, y, 0, widgetIndex, (int)w, 0, 0);
|
||||
break;
|
||||
case WIDX_SCENERY:
|
||||
window_game_top_toolbar_scenery_tool_down(x, y, w, widgetIndex);
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -27,11 +27,18 @@
|
|||
|
||||
typedef struct {
|
||||
uint8 var_00;
|
||||
uint8 pad_01;
|
||||
uint16 var_02;
|
||||
uint8 pad_04[4];
|
||||
uint8 flags; //bit 0 is no entry
|
||||
rct_string_id string_idx; //0x02
|
||||
uint8 colour; //0x04
|
||||
uint8 text_colour; //0x05
|
||||
uint8 x; //0x06
|
||||
uint8 y; //0x07
|
||||
} rct_banner;
|
||||
|
||||
enum{
|
||||
BANNER_FLAG_NO_ENTRY = (1<<0)
|
||||
} BANNER_FLAGS;
|
||||
|
||||
extern rct_banner *gBanners;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -70,10 +70,10 @@ typedef struct {
|
|||
} rct_map_element_scenerymultiple_properties;
|
||||
|
||||
typedef struct {
|
||||
uint8 index;
|
||||
uint8 position;
|
||||
uint8 flags;
|
||||
uint8 unused;
|
||||
uint8 index; //4
|
||||
uint8 position; //5
|
||||
uint8 flags; //6
|
||||
uint8 unused; //7
|
||||
} rct_map_element_banner_properties;
|
||||
|
||||
typedef union {
|
||||
|
|
Loading…
Reference in New Issue