diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index a443141ad2..498b457a32 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -70,14 +70,14 @@ - + - + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index 5b3bcff5b9..c26549df6e 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -197,10 +197,10 @@ Source Files - + Windows - + Windows diff --git a/src/addresses.h b/src/addresses.h index 341c17b1ef..01c72b73dd 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -146,7 +146,6 @@ #define RCT2_ADDRESS_OS_TIME_YEAR 0x01424320 #define RCT2_ADDRESS_OS_TIME_DAYOFWEEK 0x01423B20 - static void RCT2_CALLPROC_EBPSAFE(int address) { __asm push ebp diff --git a/src/climate.c b/src/climate.c index e4fe9896bb..8879160272 100644 --- a/src/climate.c +++ b/src/climate.c @@ -22,6 +22,11 @@ #include "date.h" #include "rct2.h" +int climate_celcius_to_fahrenheit(int celcius) +{ + return (celcius * 29) / 16 + 32; +} + /** * * rct2: 0x006C45ED diff --git a/src/climate.h b/src/climate.h index 8d00c71f40..dce3765ea0 100644 --- a/src/climate.h +++ b/src/climate.h @@ -28,6 +28,7 @@ enum { CLIMATE_COLD }; +int climate_celcius_to_fahrenheit(int celcius); void climate_reset(int climate); #endif \ No newline at end of file diff --git a/src/game.c b/src/game.c index c87155c3cb..d1c60b04bc 100644 --- a/src/game.c +++ b/src/game.c @@ -26,8 +26,8 @@ #include "window.h" void window_main_open(); -void window_top_toolbar_open(); -void window_bottom_toolbar_open(); +void window_game_top_toolbar_open(); +void window_game_bottom_toolbar_open(); /** * @@ -36,8 +36,8 @@ void window_bottom_toolbar_open(); void game_create_windows() { window_main_open(); - window_top_toolbar_open(); - window_bottom_toolbar_open(); + window_game_top_toolbar_open(); + window_game_bottom_toolbar_open(); RCT2_CALLPROC_EBPSAFE(0x0066B905); } diff --git a/src/gfx.c b/src/gfx.c index 0e42b2f86a..24fd13f6a5 100644 --- a/src/gfx.c +++ b/src/gfx.c @@ -24,6 +24,7 @@ #include "addresses.h" #include "gfx.h" #include "rct2.h" +#include "strings.h" #include "window.h" uint8 _screenDirtyBlocks[5120]; @@ -434,6 +435,25 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *format, int x, in return (sint16)(edx & 0xFFFF) - y; } +/** + * Draws i formatted text string. + * rct2: 0x006C1B2F + * dpi (edi) + * format (bx) + * args (esi) + * colour (al) + * x (cx) + * y (dx) + */ +void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y) +{ + char* buffer; + + buffer = (char*)0x0141ED68; + format_string(buffer, format, args); + gfx_draw_string(dpi, buffer, colour, x, y); +} + /** * * rct2: 0x00682702 diff --git a/src/news_item.c b/src/news_item.c index 2d40180b94..6821f18e28 100644 --- a/src/news_item.c +++ b/src/news_item.c @@ -24,6 +24,7 @@ #include "rct2.h" #include "window.h" +void window_game_bottom_toolbar_invalidate_news_item(); static int news_item_get_new_history_slot(); /** @@ -40,7 +41,7 @@ void news_item_init_queue() for (i = 0; i < 16; i++) RCT2_ADDRESS(0x01358750, uint8)[i] = 0; - RCT2_CALLPROC_EBPSAFE(0x0066BB79); // window_game_bottom_toolbar_invalidate_news_item(); + window_game_bottom_toolbar_invalidate_news_item(); } /** @@ -85,7 +86,7 @@ void news_item_update_current() if (newsItems[0].type == 0) return; - RCT2_CALLPROC_EBPSAFE(0x0066BB79); // window_game_bottom_toolbar_invalidate_news_item(); + window_game_bottom_toolbar_invalidate_news_item(); // Update the current news item newsItems[0].ticks++; @@ -138,7 +139,7 @@ void news_item_close_current() newsItems[10].type = NEWS_ITEM_NULL; // Invalidate current news item bar - RCT2_CALLPROC_EBPSAFE(0x0066BB79); // window_game_bottom_toolbar_invalidate_news_item(); + window_game_bottom_toolbar_invalidate_news_item(); } /** diff --git a/src/ride.h b/src/ride.h index fdbb5ee6e6..47bab3e86f 100644 --- a/src/ride.h +++ b/src/ride.h @@ -74,11 +74,9 @@ enum { RIDE_TYPE_MONORAIL, RIDE_TYPE_MINI_SUSPENDED_COASTER, RIDE_TYPE_BUMPER_BOATS, - RIDE_TYPE_WOODEN_WILD_MINE_RIDE, + RIDE_TYPE_WOODEN_WILD_MOUSE, RIDE_TYPE_STEEPLECHASE, - RIDE_TYPE_MOTORBIKE_RACES, RIDE_TYPE_CAR_RIDE, - RIDE_TYPE_VINTAGE_CARS, RIDE_TYPE_LAUNCHED_FREEFALL, RIDE_TYPE_BOBSLEIGH_COASTER, RIDE_TYPE_OBSERVATION_TOWER, @@ -119,12 +117,9 @@ enum { RIDE_TYPE_CIRCUS_SHOW, RIDE_TYPE_GHOST_TRAIN, RIDE_TYPE_TWISTER_ROLLER_COASTER, - RIDE_TYPE_FLOORLESS_ROLLER_COASTER, - RIDE_TYPE_WOODEN_ROLLER_COASTER, RIDE_TYPE_WOODEN_ROLLER_COASTER, RIDE_TYPE_SIDE_FRICTION_ROLLER_COASTER, RIDE_TYPE_WILD_MOUSE, - RIDE_TYPE_SPINNING_WILD_MOUSE, RIDE_TYPE_MULTI_DIMENSION_ROLLER_COASTER, RIDE_TYPE_38, RIDE_TYPE_FLYING_ROLLER_COASTER, diff --git a/src/window_bottom_toolbar.c b/src/window_bottom_toolbar.c deleted file mode 100644 index 27e34acd60..0000000000 --- a/src/window_bottom_toolbar.c +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 Ted John - * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. - * - * This file is part of OpenRCT2. - * - * OpenRCT2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - *****************************************************************************/ - -#include "addresses.h" -#include "sprites.h" -#include "strings.h" -#include "widget.h" -#include "window.h" - -static enum WINDOW_GAME_BOTTOM_TOOLBAR_WIDGET_IDX { - WIDX_LEFT_OUTSET, - WIDX_LEFT_INSET, - WIDX_MONEY, - WIDX_GUESTS, - WIDX_PARK_RATING, - WIDX_MIDDLE_OUTSET, - WIDX_MIDDLE_INSET, - WIDX_NEWS_SUBJECT, - WIDX_NEWS_LOCATE, - WIDX_RIGHT_OUTSET, - WIDX_RIGHT_INSET, - WIDX_DATE, -}; - -rct_widget window_game_bottom_toolbar_widgets[] = { - { WWT_IMGBTN, 0, 0x0000, 0x0077, 0, 33, 0xFFFFFFFF, STR_NONE }, // Left outset panel - { WWT_IMGBTN, 0, 0x0002, 0x0075, 2, 31, 0xFFFFFFFF, STR_NONE }, // Left inset panel - { WWT_FLATBTN, 0, 0x0002, 0x0075, 1, 12, 0xFFFFFFFF, STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP }, // Money window - { WWT_FLATBTN, 0, 0x0002, 0x0075, 11, 22, 0xFFFFFFFF, STR_NONE }, // Guests window - { WWT_FLATBTN, 0, 0x0002, 0x0075, 21, 31, 0xFFFFFFFF, STR_PARK_rating_TIP }, // Park rating window - - { WWT_IMGBTN, 2, 0x0078, 0x0207, 0, 33, 0xFFFFFFFF, STR_NONE }, // Middle outset panel - { WWT_25, 2, 0x007A, 0x0205, 2, 31, 0xFFFFFFFF, STR_NONE }, // Middle inset panel - { WWT_FLATBTN, 2, 0x007D, 0x0094, 5, 28, 0xFFFFFFFF, STR_SHOW_SUBJECT_TIP }, // Associated news item window - { WWT_FLATBTN, 2, 0x01EB, 0x0202, 5, 28, SPR_LOCATE, STR_LOCATE_SUBJECT_TIP }, // Scroll to news item target - - { WWT_IMGBTN, 0, 0x0208, 0x027F, 0, 33, 0xFFFFFFFF, STR_NONE }, // Right outset panel - { WWT_IMGBTN, 0, 0x020A, 0x027D, 2, 31, 0xFFFFFFFF, STR_NONE }, // Right inset panel - { WWT_FLATBTN, 0, 0x020A, 0x027D, 2, 13, 0xFFFFFFFF, 2290 }, // Date - { WIDGETS_END }, -}; - -/** - * Creates the main game bottom toolbar window. - * rct2: 0x0066B52F (part of 0x0066B3E8) - */ -void window_bottom_toolbar_open() -{ - rct_window* window; - - window = window_create(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, 0x0097BFDC, WC_BOTTOM_TOOLBAR, 0x32); - window->widgets = 0x009A953C; - window->enabled_widgets |= - (1 << WIDX_LEFT_OUTSET) | - (1 << WIDX_MONEY) | - (1 << WIDX_GUESTS) | - (1 << WIDX_PARK_RATING) | - (1 << WIDX_MIDDLE_OUTSET) | - (1 << WIDX_MIDDLE_INSET) | - (1 << WIDX_NEWS_SUBJECT) | - (1 << WIDX_NEWS_LOCATE) | - (1 << WIDX_RIGHT_OUTSET) | - (1 << WIDX_DATE); - - window->var_48E = 0; - window_init_scroll_widgets(window); - window->colours[0] = 140; - window->colours[1] = 140; - window->colours[2] = 0; -} \ No newline at end of file diff --git a/src/window_game_bottom_toolbar.c b/src/window_game_bottom_toolbar.c new file mode 100644 index 0000000000..7cca518355 --- /dev/null +++ b/src/window_game_bottom_toolbar.c @@ -0,0 +1,402 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * This file is part of OpenRCT2. + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + *****************************************************************************/ + +#include "addresses.h" +#include "climate.h" +#include "news_item.h" +#include "park.h" +#include "sprites.h" +#include "strings.h" +#include "widget.h" +#include "window.h" + +static enum WINDOW_GAME_BOTTOM_TOOLBAR_WIDGET_IDX { + WIDX_LEFT_OUTSET, + WIDX_LEFT_INSET, + WIDX_MONEY, + WIDX_GUESTS, + WIDX_PARK_RATING, + WIDX_MIDDLE_OUTSET, + WIDX_MIDDLE_INSET, + WIDX_NEWS_SUBJECT, + WIDX_NEWS_LOCATE, + WIDX_RIGHT_OUTSET, + WIDX_RIGHT_INSET, + WIDX_DATE +}; + +rct_widget window_game_bottom_toolbar_widgets[] = { + { WWT_IMGBTN, 0, 0x0000, 0x0077, 0, 33, 0xFFFFFFFF, STR_NONE }, // Left outset panel + { WWT_IMGBTN, 0, 0x0002, 0x0075, 2, 31, 0xFFFFFFFF, STR_NONE }, // Left inset panel + { WWT_FLATBTN, 0, 0x0002, 0x0075, 1, 12, 0xFFFFFFFF, STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP }, // Money window + { WWT_FLATBTN, 0, 0x0002, 0x0075, 11, 22, 0xFFFFFFFF, STR_NONE }, // Guests window + { WWT_FLATBTN, 0, 0x0002, 0x0075, 21, 31, 0xFFFFFFFF, STR_PARK_rating_TIP }, // Park rating window + + { WWT_IMGBTN, 2, 0x0078, 0x0207, 0, 33, 0xFFFFFFFF, STR_NONE }, // Middle outset panel + { WWT_25, 2, 0x007A, 0x0205, 2, 31, 0xFFFFFFFF, STR_NONE }, // Middle inset panel + { WWT_FLATBTN, 2, 0x007D, 0x0094, 5, 28, 0xFFFFFFFF, STR_SHOW_SUBJECT_TIP }, // Associated news item window + { WWT_FLATBTN, 2, 0x01EB, 0x0202, 5, 28, SPR_LOCATE, STR_LOCATE_SUBJECT_TIP }, // Scroll to news item target + + { WWT_IMGBTN, 0, 0x0208, 0x027F, 0, 33, 0xFFFFFFFF, STR_NONE }, // Right outset panel + { WWT_IMGBTN, 0, 0x020A, 0x027D, 2, 31, 0xFFFFFFFF, STR_NONE }, // Right inset panel + { WWT_FLATBTN, 0, 0x020A, 0x027D, 2, 13, 0xFFFFFFFF, 2290 }, // Date + { WIDGETS_END }, +}; + +static void window_game_bottom_toolbar_emptysub() { } +static void window_game_bottom_toolbar_mouseup(); +static void window_game_bottom_toolbar_mousedown(); +static void window_game_bottom_toolbar_dropdown(); +static void window_game_bottom_toolbar_invalidate(); +static void window_game_bottom_toolbar_paint(); + +static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, rct_window *w); +static void window_game_bottom_toolbar_draw_park_rating(rct_drawpixelinfo *dpi, rct_window *w, int colour, int x, int y, uint8 factor); +static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, rct_window *w); +static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w); +static void window_game_bottom_toolbar_draw_tutorial_text(rct_drawpixelinfo *dpi, rct_window *w); + +static uint32 window_game_bottom_toolbar_events[] = { + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_mouseup, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_mousedown, + window_game_bottom_toolbar_dropdown, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_emptysub, + window_game_bottom_toolbar_invalidate, + window_game_bottom_toolbar_paint, + window_game_bottom_toolbar_emptysub +}; + +/** + * Creates the main game bottom toolbar window. + * rct2: 0x0066B52F (part of 0x0066B3E8) + */ +void window_game_bottom_toolbar_open() +{ + rct_window* window; + + window = window_create(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - 32, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 32, window_game_bottom_toolbar_events, WC_BOTTOM_TOOLBAR, 0x32); + window->widgets = window_game_bottom_toolbar_widgets; + window->enabled_widgets |= + (1 << WIDX_LEFT_OUTSET) | + (1 << WIDX_MONEY) | + (1 << WIDX_GUESTS) | + (1 << WIDX_PARK_RATING) | + (1 << WIDX_MIDDLE_OUTSET) | + (1 << WIDX_MIDDLE_INSET) | + (1 << WIDX_NEWS_SUBJECT) | + (1 << WIDX_NEWS_LOCATE) | + (1 << WIDX_RIGHT_OUTSET) | + (1 << WIDX_DATE); + + window->var_48E = 0; + window_init_scroll_widgets(window); + window->colours[0] = 140; + window->colours[1] = 140; + window->colours[2] = 0; +} + +static void window_game_bottom_toolbar_mouseup() +{ + +} + +static void window_game_bottom_toolbar_mousedown() +{ + +} + +static void window_game_bottom_toolbar_dropdown() +{ + +} + +/** + * + * rct2: 0x0066BBA0 + */ +static void window_game_bottom_toolbar_invalidate() +{ + rct_window *w; + rct_news_item *newsItem; + + __asm mov w, esi + + window_game_bottom_toolbar_widgets[WIDX_LEFT_INSET].type = WWT_EMPTY; + window_game_bottom_toolbar_widgets[WIDX_RIGHT_INSET].type = WWT_EMPTY; + + newsItem = &(RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0]); + if (newsItem->type == 0) { + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_INSET].type = WWT_EMPTY; + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_EMPTY; + window_game_bottom_toolbar_widgets[WIDX_NEWS_LOCATE].type = WWT_EMPTY; + } else { + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_INSET].type = WWT_25; + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_FLATBTN; + window_game_bottom_toolbar_widgets[WIDX_NEWS_LOCATE].type = WWT_FLATBTN; + w->disabled_widgets &= ~(1 << WIDX_NEWS_SUBJECT); + w->disabled_widgets &= ~(1 << WIDX_NEWS_LOCATE); + + int eax, ebx, ecx, edx, esi, edi, ebp; + ecx = newsItem->assoc; + edx = newsItem->type; + RCT2_CALLFUNC_X(0x0066BA74, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); + + if ((eax & 0xFFFF) == 0x8000) + w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE); + + if (!(((char*)0x0097BE7C)[newsItem->type] & 2)) { + w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT); + window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_EMPTY; + } + + if (newsItem->flags & 1) { + w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT); + w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE); + } + } + + // Hide money if there is no money + if (RCT2_GLOBAL(0x013573E4, uint32) & 0x800) { + window_game_bottom_toolbar_widgets[WIDX_MONEY].type = WWT_EMPTY; + window_game_bottom_toolbar_widgets[WIDX_GUESTS].top = 1; + window_game_bottom_toolbar_widgets[WIDX_GUESTS].bottom = 17; + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].top = 17; + } else { + window_game_bottom_toolbar_widgets[WIDX_MONEY].type = WWT_FLATBTN; + window_game_bottom_toolbar_widgets[WIDX_GUESTS].top = 11; + window_game_bottom_toolbar_widgets[WIDX_GUESTS].bottom = 22; + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].top = 21; + } +} + +/** + * + * rct2: 0x0066BB79 + */ +void window_game_bottom_toolbar_invalidate_news_item() +{ + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].type = + RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0].type == NEWS_ITEM_NULL ? WWT_EMPTY : WWT_IMGBTN; + window_invalidate_by_id((WIDX_MIDDLE_OUTSET << 8) | 0x80 | WC_BOTTOM_TOOLBAR, 0); +} + +/** + * + * rct2: 0x0066BC87 + */ +static void window_game_bottom_toolbar_paint() +{ + int x, y, imgId; + rct_window *w; + rct_drawpixelinfo *dpi; + + __asm mov w, esi + __asm mov dpi, edi + + // Draw panel grey backgrounds + gfx_fill_rect( + dpi, + w->x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].left, + w->y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top, + w->x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].right, + w->y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].bottom, + 0x02000033 + ); + gfx_fill_rect( + dpi, + w->x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left, + w->y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top, + w->x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].right, + w->y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].bottom, + 0x02000033 + ); + + window_draw_widgets(w, dpi); + + window_game_bottom_toolbar_draw_left_panel(dpi, w); + window_game_bottom_toolbar_draw_right_panel(dpi, w); + + if (RCT2_ADDRESS(RCT2_ADDRESS_NEWS_ITEM_LIST, rct_news_item)[0].type != 0) + window_game_bottom_toolbar_draw_news_item(dpi, w); + else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8)) + window_game_bottom_toolbar_draw_tutorial_text(dpi, w); +} + +static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, rct_window *w) +{ + int x, y; + + // Draw green inset rectangle on panel + gfx_fill_rect_inset( + dpi, + w->x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].left + 1, + w->y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top + 1, + w->x + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].right - 1, + w->y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].bottom - 1, + w->colours[1], + 48 + ); + + x = (window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].left + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].right) / 2 + w->x; + y = window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].top + w->y + 4; + + // Draw money + if (!(RCT2_GLOBAL(0x0013573E4, uint32) & 0x800)) { + *((int*)0x013CE952) = DECRYPT_MONEY(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, sint32)); + gfx_draw_string_centred( + dpi, + (*((int*)0x013CE952) < 0 ? 1391 : 1390), + x, y - 3, + (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_MONEY ? 2 : w->colours[0] & 0x7F), + (void*)0x013CE952 + ); + y += 7; + } + + // Draw guests + gfx_draw_string_centred( + dpi, + STR_NUM_GUESTS + RCT2_GLOBAL(0x013573FE, uint8), + x, y, + (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_GUESTS ? 2 : w->colours[0] & 0x7F), + (void*)0x01357844 + ); + + // Draw park rating + window_game_bottom_toolbar_draw_park_rating( + dpi, + w, + 14, + w->x + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].left + 11, + w->y + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].top, + max(10, ((RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_PARK_RATING, sint16) / 4) * 263) / 256) + ); +} + +/** + * + * rct2: 0x0066C76C + */ +static void window_game_bottom_toolbar_draw_park_rating(rct_drawpixelinfo *dpi, rct_window *w, int colour, int x, int y, uint8 factor) +{ + short bar_width; + + bar_width = (factor * 90) / 256; + gfx_fill_rect_inset(dpi, x, y + 1, x + 93, y + 9, w->colours[1], 48); + if (!(colour & 0x80000000) || RCT2_GLOBAL(0x009DEA6E, uint8) != 0 || (RCT2_GLOBAL(0x013628F4, uint8) & 8)) { + if (bar_width > 2) + gfx_fill_rect_inset(dpi, x + 2, y + 2, x + bar_width - 1, y + 8, colour & 0x7FFFFFFF, 0); + } + + // Draw thumbs on the sides + gfx_draw_sprite(dpi, SPR_RATING_LOW, x - 14, y); + gfx_draw_sprite(dpi, SPR_RATING_HIGH, x + 92, y); +} + +static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo *dpi, rct_window *w) +{ + int x, y, temperature, format; + + // Draw green inset rectangle on panel + gfx_fill_rect_inset( + dpi, + w->x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left + 1, + w->y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top + 1, + w->x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].right - 1, + w->y + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].bottom - 1, + w->colours[1], + 48 + ); + + x = (window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].right) / 2 + w->x; + y = window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].top + w->y + 2; + + // Date + *((short*)0x013CE952) = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, sint16); + gfx_draw_string_centred( + dpi, + 1845, + x, + y, + (RCT2_GLOBAL(0x009DE55C, rct_windowclass) == 2 && RCT2_GLOBAL(0x009DE560, sint32) == WIDX_DATE ? 2 : w->colours[0] & 0x7F), + (void*)0x013CE952 + ); + + // Temperature + x = w->x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left + 15; + y += 11; + + temperature = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_TEMPERATURE, sint8); + format = STR_CELCIUS_VALUE; + if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_FAHRENHEIT, uint8)) { + temperature = climate_celcius_to_fahrenheit(temperature); + format = STR_FAHRENHEIT_VALUE; + } + *((short*)0x013CE952) = temperature; + gfx_draw_string_left(dpi, format, (void*)0x013CE952, 0, x, y + 6); + x += 30; + + // Current weather + gfx_draw_sprite(dpi, ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) * 2], x, y); + + // Next weather + if (((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, sint8) * 2] != ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8) * 2]) { + if (RCT2_GLOBAL(0x013CA748, sint16) < 960) { + gfx_draw_sprite(dpi, SPR_NEXT_WEATHER, x + 27, y + 5); + gfx_draw_sprite(dpi, ((int*)0x00993C98)[RCT2_GLOBAL(RCT2_ADDRESS_NEXT_WEATHER, sint8) * 2], x + 40, y); + } + } +} + +static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rct_window *w) +{ + +} + +static void window_game_bottom_toolbar_draw_tutorial_text(rct_drawpixelinfo *dpi, rct_window *w) +{ + int x, y; + + x = (window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].left + window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].right) / 2 + w->x; + y = window_game_bottom_toolbar_widgets[WIDX_MIDDLE_OUTSET].top + w->y + 2; + gfx_draw_string_centred(dpi, STR_TUTORIAL, x, y, 32, 0); + gfx_draw_string_centred(dpi, STR_PRESS_KEY_OR_MOUSE_BUTTON_FOR_CONTROL, x, y + 10, 32, 0); +} \ No newline at end of file diff --git a/src/window_top_toolbar.c b/src/window_game_top_toolbar.c similarity index 79% rename from src/window_top_toolbar.c rename to src/window_game_top_toolbar.c index 57077cf2d8..e13bd86e7f 100644 --- a/src/window_top_toolbar.c +++ b/src/window_game_top_toolbar.c @@ -49,7 +49,7 @@ enum { WIDX_FASTFORWARD }; -static rct_widget window_top_toolbar_widgets[] = { +static rct_widget window_game_top_toolbar_widgets[] = { { WWT_TRNBTN, 0, 0x0000, 0x001D, 0, 27, 0x20000000 | SPR_TOOLBAR_PAUSE, STR_PAUSE_GAME_TIP }, // Pause { WWT_TRNBTN, 0, 0x001E + 30, 0x003B + 30, 0, 27, 0x20000000 | SPR_TOOLBAR_FILE, STR_DISC_AND_GAME_OPTIONS_TIP }, // File menu { WWT_TRNBTN, 1, 0x0046 + 30, 0x0063 + 30, 0, 27, 0x20000000 | SPR_TOOLBAR_ZOOM_OUT, STR_ZOOM_OUT_TIP }, // Zoom out @@ -74,54 +74,54 @@ static rct_widget window_top_toolbar_widgets[] = { { WIDGETS_END }, }; -static void window_top_toolbar_emptysub() { } -static void window_top_toolbar_mouseup(); -static void window_top_toolbar_mousedown(); -static void window_top_toolbar_dropdown(); -static void window_top_toolbar_invalidate(); -static void window_top_toolbar_paint(); +static void window_game_top_toolbar_emptysub() { } +static void window_game_top_toolbar_mouseup(); +static void window_game_top_toolbar_mousedown(); +static void window_game_top_toolbar_dropdown(); +static void window_game_top_toolbar_invalidate(); +static void window_game_top_toolbar_paint(); -static uint32 window_top_toolbar_events[] = { - window_top_toolbar_emptysub, - window_top_toolbar_mouseup, - window_top_toolbar_emptysub, - window_top_toolbar_mousedown, - window_top_toolbar_dropdown, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_emptysub, - window_top_toolbar_invalidate, - window_top_toolbar_paint, - window_top_toolbar_emptysub +static uint32 window_game_top_toolbar_events[] = { + window_game_top_toolbar_emptysub, + window_game_top_toolbar_mouseup, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_mousedown, + window_game_top_toolbar_dropdown, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_emptysub, + window_game_top_toolbar_invalidate, + window_game_top_toolbar_paint, + window_game_top_toolbar_emptysub }; /** * Creates the main game top toolbar window. * rct2: 0x0066B485 (part of 0x0066B3E8) */ -void window_top_toolbar_open() +void window_game_top_toolbar_open() { rct_window* window; - window = window_create(0, 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, window_top_toolbar_events, WC_TOP_TOOLBAR, 0x32); - window->widgets = window_top_toolbar_widgets; + window = window_create(0, 0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16), 28, window_game_top_toolbar_events, WC_TOP_TOOLBAR, 0x32); + window->widgets = window_game_top_toolbar_widgets; window->enabled_widgets |= (1 | 2 | 4 | 8 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100 | 0x200 | 0x400 | 0x800 | 0x1000 | 0x2000 | 0x4000 | 0x8000 | 0x10000 | 0x20000); window_init_scroll_widgets(window); @@ -135,7 +135,7 @@ void window_top_toolbar_open() * * rct2: 0x0066C957 */ -static void window_top_toolbar_mouseup() +static void window_game_top_toolbar_mouseup() { short widgetIndex; rct_window *w, *mainWindow; @@ -234,7 +234,7 @@ static void window_top_toolbar_mouseup() * * rct2: 0x0066CA3B */ -static void window_top_toolbar_mousedown() +static void window_game_top_toolbar_mousedown() { short widgetIndex; rct_window *w; @@ -325,7 +325,7 @@ static void window_top_toolbar_mousedown() * * rct2: 0x0066C9EA */ -static void window_top_toolbar_dropdown() +static void window_game_top_toolbar_dropdown() { short widgetIndex, dropdownIndex; @@ -386,7 +386,7 @@ static void window_top_toolbar_dropdown() * * rct2: 0x0066C810 */ -static void window_top_toolbar_invalidate() +static void window_game_top_toolbar_invalidate() { int x; rct_window *w; @@ -398,45 +398,45 @@ static void window_top_toolbar_invalidate() if (x < 640) x = 640; x--; - window_top_toolbar_widgets[WIDX_GUESTS].right = x; + window_game_top_toolbar_widgets[WIDX_GUESTS].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_GUESTS].left = x; + window_game_top_toolbar_widgets[WIDX_GUESTS].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_STAFF].right = x; + window_game_top_toolbar_widgets[WIDX_STAFF].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_STAFF].left = x; + window_game_top_toolbar_widgets[WIDX_STAFF].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_PARK].right = x; + window_game_top_toolbar_widgets[WIDX_PARK].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_PARK].left = x; + window_game_top_toolbar_widgets[WIDX_PARK].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_RIDES].right = x; + window_game_top_toolbar_widgets[WIDX_RIDES].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_RIDES].left = x; + window_game_top_toolbar_widgets[WIDX_RIDES].left = x; x -= 11; - window_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].right = x; + window_game_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].left = x; + window_game_top_toolbar_widgets[WIDX_CONSTRUCT_RIDE].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_PATH].right = x; + window_game_top_toolbar_widgets[WIDX_PATH].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_PATH].left = x; + window_game_top_toolbar_widgets[WIDX_PATH].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_SCENERY].right = x; + window_game_top_toolbar_widgets[WIDX_SCENERY].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_SCENERY].left = x; + window_game_top_toolbar_widgets[WIDX_SCENERY].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_WATER].right = x; + window_game_top_toolbar_widgets[WIDX_WATER].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_WATER].left = x; + window_game_top_toolbar_widgets[WIDX_WATER].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_LAND].right = x; + window_game_top_toolbar_widgets[WIDX_LAND].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_LAND].left = x; + window_game_top_toolbar_widgets[WIDX_LAND].left = x; x -= 1; - window_top_toolbar_widgets[WIDX_CLEAR_SCENERY].right = x; + window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].right = x; x -= 29; - window_top_toolbar_widgets[WIDX_CLEAR_SCENERY].left = x; + window_game_top_toolbar_widgets[WIDX_CLEAR_SCENERY].left = x; // Footpath button pressed down if (window_find_by_id(0x80 | 0x20, 0) == NULL) @@ -455,7 +455,7 @@ static void window_top_toolbar_invalidate() * * rct2: 0x0066C8EC */ -static void window_top_toolbar_paint() +static void window_game_top_toolbar_paint() { int x, y, imgId; rct_window *w; @@ -467,8 +467,8 @@ static void window_top_toolbar_paint() window_draw_widgets(w, dpi); // Draw staff button image (setting masks to the staff colours) - x = w->x + window_top_toolbar_widgets[WIDX_STAFF].left; - y = w->y + window_top_toolbar_widgets[WIDX_STAFF].top; + x = w->x + window_game_top_toolbar_widgets[WIDX_STAFF].left; + y = w->y + window_game_top_toolbar_widgets[WIDX_STAFF].top; imgId = 5627; if (widget_is_pressed(w, WIDX_STAFF)) imgId++;