Added window_sign_small

This commit is contained in:
Duncan Frost 2014-11-02 14:09:04 +00:00
parent 49ccea7f26
commit c87e373ced
4 changed files with 259 additions and 13 deletions

View File

@ -845,7 +845,7 @@ static void game_handle_input_mouse(int x, int y, int state)
//0x006e57a9
scenery_entry = g_wallSceneryEntries[map_element->properties.fence.slope];
if (scenery_entry->wall.var_0D != 0xFF){
RCT2_CALLPROC_X(0x6E5F52, map_element->properties.fence.item[0], 0, 0, 0, 0, 0, 0);
window_sign_small_open(map_element->properties.fence.item[0]);
}
else{
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = 1158;

View File

@ -506,6 +506,7 @@ void window_track_place_open();
void window_new_ride_open();
void window_banner_open(rct_windownumber number);
void window_sign_open(rct_windownumber number);
void window_sign_small_open(rct_windownumber number);
void window_cheats_open();
void window_research_open();
void window_scenery_open();

View File

@ -998,6 +998,10 @@ enum {
STR_DEMOLISH_BANNER_TIP = 2988,
STR_SELECT_MAIN_COLOR_TIP = 2989,
STR_SELECT_TEXT_COLOR_TIP = 2990,
STR_SIGN = 2991,
STR_CHANGE_SIGN_TEXT_TIP = 2994,
STR_DEMOLISH_SIGN_TIP = 2995,
STR_LICENCE_AGREEMENT_NOTICE_1 = 2969,
STR_LICENCE_AGREEMENT_NOTICE_2 = 2970,

View File

@ -50,14 +50,14 @@ enum WINDOW_SIGN_WIDGET_IDX {
// 0x9AEE00
rct_widget window_sign_widgets[] = {
{ WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, 0x0FFFFFFFF, 65535 }, // panel / background
{ WWT_CAPTION, 0, 1, WW - 2, 1, 14, 2991, STR_WINDOW_TITLE_TIP }, // title bar
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, 824, 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, 5168, STR_CHANGE_BANNER_TEXT_TIP }, // change banner button
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 67, 90, 5165, STR_DEMOLISH_BANNER_TIP }, // demolish button
{ WWT_COLORBTN, 1, 5, 16, WH - 16, WH - 5, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP }, // high money
{ WWT_COLORBTN, 1, 17, 28, WH - 16, WH - 5, 0x0FFFFFFFF, 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, STR_SIGN, STR_WINDOW_TITLE_TIP }, // title bar
{ WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
{ WWT_VIEWPORT, 1, 3, WW - 26, 17, WH - 20, 0x0FFFFFFFE, 65535 }, // Viewport
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 19, 42, 5168, STR_CHANGE_SIGN_TEXT_TIP }, // change sign button
{ WWT_FLATBTN, 1, WW - 25, WW - 2, 67, 90, 5165, STR_DEMOLISH_SIGN_TIP }, // demolish button
{ WWT_COLORBTN, 1, 5, 16, WH - 16, WH - 5, 0x0FFFFFFFF, STR_SELECT_MAIN_COLOR_TIP },// Main colour
{ WWT_COLORBTN, 1, 17, 28, WH - 16, WH - 5, 0x0FFFFFFFF, STR_SELECT_TEXT_COLOR_TIP },// Text colour
{ WIDGETS_END },
};
@ -102,6 +102,42 @@ static void* window_sign_events[] = {
window_sign_emptysub
};
static void window_sign_small_mouseup();
static void window_sign_small_dropdown();
static void window_sign_small_invalidate();
// 0x9A410C
static void* window_sign_small_events[] = {
window_sign_emptysub,
window_sign_small_mouseup,
window_sign_emptysub,
window_sign_mousedown,
window_sign_small_dropdown,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_textinput,
window_sign_unknown_14,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_emptysub,
window_sign_small_invalidate,
window_sign_paint,
window_sign_emptysub
};
/**
*
* rct2: 0x006BA305
@ -245,7 +281,7 @@ static void window_sign_mouseup()
}
}
/* rct2: 0x6B9784 */
/* rct2: 0x6B9784 & 0x6E6164 */
static void window_sign_mousedown(int widgetIndex, rct_window*w, rct_widget* widget)
{
rct_banner* banner = &gBanners[w->number];
@ -310,7 +346,7 @@ static void window_sign_dropdown()
window_invalidate(w);
}
/* rct2: 0x6B9791 */
/* rct2: 0x6B9791 & 0x6E6171*/
static void window_sign_textinput()
{
short widgetIndex;
@ -382,7 +418,7 @@ static void window_sign_invalidate()
text_colour_btn->image = (w->var_492 << 19) | 0x600013C3;
}
/* rct2: 0x006B9754 */
/* rct2: 0x006B9754 & 0x006E6134 */
static void window_sign_paint()
{
rct_window *w;
@ -398,7 +434,7 @@ static void window_sign_paint()
}
}
/* rct2: 0x6B9A6C */
/* rct2: 0x6B9A6C & 0x6E6424 */
static void window_sign_unknown_14()
{
rct_window* w;
@ -435,3 +471,208 @@ static void window_sign_unknown_14()
w->viewport->flags = (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FLAGS, uint8) & CONFIG_FLAG_ALWAYS_SHOW_GRIDLINES) ? VIEWPORT_FLAG_GRIDLINES : 0;
window_invalidate(w);
}
/* rct2: 0x6E5F52 */
void window_sign_small_open(rct_windownumber number){
rct_window* w;
rct_widget *viewportWidget;
// Check if window is already open
w = window_bring_to_front_by_number(WC_BANNER, number);
if (w != NULL)
return;
w = window_create_auto_pos(WW, WH, (uint32*)window_sign_small_events, WC_BANNER, 0);
w->widgets = window_sign_widgets;
w->enabled_widgets =
(1 << WIDX_CLOSE) |
(1 << WIDX_SIGN_TEXT) |
(1 << WIDX_SIGN_DEMOLISH) |
(1 << WIDX_MAIN_COLOR) |
(1 << WIDX_TEXT_COLOR);
w->number = number;
window_init_scroll_widgets(w);
w->colours[0] = 24;
w->colours[1] = 24;
w->colours[2] = 24;
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_FENCE){
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[map_element->properties.fence.slope];
if (scenery_entry->wall.var_0D != 0xFF){
if (map_element->properties.fence.item[0] == w->number)
break;
}
}
map_element++;
}
int view_z = map_element->base_height << 3;
w->frame_no = view_z;
w->list_information_type = map_element->properties.fence.item[1] & 0x1F;
w->var_492 = (map_element->properties.fence.item[1] >> 5) | ((map_element->flags&0x60) >> 2);
w->var_48C = map_element->properties.fence.slope;
view_x += 16;
view_y += 16;
// Create viewport
viewportWidget = &window_sign_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;
w->flags |= WF_2;
window_invalidate(w);
}
/* rct2: 0x6E6145 */
static void window_sign_small_mouseup()
{
short widgetIndex;
rct_window *w;
window_widget_get_registers(w, widgetIndex);
rct_banner* banner = &gBanners[w->number];
int x = banner->x << 5;
int y = banner->y << 5;
rct_string_id string_id;
rct_map_element* map_element = TILE_MAP_ELEMENT_POINTER(((y << 8) | x) >> 5);
switch (widgetIndex) {
case WIDX_CLOSE:
window_close(w);
break;
case WIDX_SIGN_DEMOLISH:
while (1){
if ((map_element->type & MAP_ELEMENT_TYPE_MASK) == MAP_ELEMENT_TYPE_FENCE){
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[map_element->properties.fence.slope];
if (scenery_entry->wall.var_0D != 0xFF){
if (map_element->properties.fence.item[0] == w->number)
break;
}
}
map_element++;
}
RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID, rct_string_id) = 1158;
game_do_command(
x,
1 | ((map_element->type & 0x3) << 8),
y,
(map_element->base_height << 8) | (map_element->type & 0x3),
GAME_COMMAND_42,
0,
0);
break;
case WIDX_SIGN_TEXT:
if (banner->flags&BANNER_FLAG_2){
rct_ride* ride = GET_RIDE(banner->colour);
RCT2_GLOBAL(0x13CE962, uint32) = ride->name_arguments;
string_id = ride->name;
}
else
{
string_id = gBanners[w->number].string_idx;
}
window_text_input_open(w, WIDX_SIGN_TEXT, 2992, 2993, string_id, 0);
break;
}
}
/* rct2: 0x6E617C */
static void window_sign_small_dropdown()
{
short widgetIndex, dropdownIndex;
rct_window* w;
window_dropdown_get_registers(w, widgetIndex, dropdownIndex);
switch (widgetIndex){
case WIDX_MAIN_COLOR:
if (dropdownIndex == -1) return;
w->list_information_type = dropdownIndex;
break;
case WIDX_TEXT_COLOR:
if (dropdownIndex == -1) return;
w->var_492 = dropdownIndex;
break;
default:
return;
}
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_FENCE){
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[map_element->properties.fence.slope];
if (scenery_entry->wall.var_0D != 0xFF){
if (map_element->properties.fence.item[0] == w->number)
break;
}
}
map_element++;
}
map_element->flags &= 0x9F;
map_element->properties.fence.item[1] =
w->list_information_type |
((w->var_492 & 0x7) << 5);
map_element->flags |= ((w->var_492 & 0x18) << 2);
RCT2_CALLPROC_X(0x6EC847, x, 0, y, 0, map_element->clearance_height << 3, map_element->base_height << 3, 0);
window_invalidate(w);
}
/* rct2: 0x006E60D5 */
static void window_sign_small_invalidate()
{
rct_window* w;
window_get_register(w);
rct_widget* main_colour_btn = &window_sign_widgets[WIDX_MAIN_COLOR];
rct_widget* text_colour_btn = &window_sign_widgets[WIDX_TEXT_COLOR];
rct_scenery_entry* scenery_entry = g_wallSceneryEntries[w->var_48C];
main_colour_btn->type = WWT_EMPTY;
text_colour_btn->type = WWT_EMPTY;
if (scenery_entry->wall.flags&(1 << 0)){
main_colour_btn->type = WWT_COLORBTN;
}
if (scenery_entry->wall.flags&(1 << 6)) {
text_colour_btn->type = WWT_COLORBTN;
}
main_colour_btn->image = (w->list_information_type << 19) | 0x600013C3;
text_colour_btn->image = (w->var_492 << 19) | 0x600013C3;
}