From f2ec0a4bb76c21ecf31af3cd44c60adfb2603ac3 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Tue, 7 Oct 2014 17:57:38 +0100 Subject: [PATCH] Moved mini window into seperate file. Fixed all bugs --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/window.h | 1 + src/window_shortcut_key_change.c | 127 ++++++++++++++++++++++++++++++ src/window_shortcut_keys.c | 110 ++------------------------ 5 files changed, 140 insertions(+), 102 deletions(-) create mode 100644 src/window_shortcut_key_change.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 7d2141ddcc..2ec0e1cadd 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -137,6 +137,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index cfc27fe39c..de03c0bbde 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -434,6 +434,9 @@ Windows + + Windows + diff --git a/src/window.h b/src/window.h index 6e59bc1cd0..e097a1a237 100644 --- a/src/window.h +++ b/src/window.h @@ -477,6 +477,7 @@ void window_guest_list_open(); void window_map_open(); void window_options_open(); void window_shortcut_keys_open(); +void window_shortcut_change_open(int selected_key); void window_peep_open(rct_peep* peep); void window_staff_peep_open(rct_peep* peep); void window_park_awards_open(); diff --git a/src/window_shortcut_key_change.c b/src/window_shortcut_key_change.c new file mode 100644 index 0000000000..a6f070bf2e --- /dev/null +++ b/src/window_shortcut_key_change.c @@ -0,0 +1,127 @@ +/***************************************************************************** +* Copyright (c) 2014 Ted John, Duncan Frost +* 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 "config.h" +#include "window.h" +#include "widget.h" + +#define WW 250 +#define WH 60 + +enum WINDOW_SHORTCUT_CHANGE_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, +}; + +// 0x9DE4E0 +static rct_widget window_shortcut_change_widgets[] = { + { WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, + { WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, WW-13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WIDGETS_END } +}; + +static void window_shortcut_change_emptysub(){} +static void window_shortcut_change_mouseup(); +static void window_shortcut_change_paint(); + +//0x9A3F7C +static void* window_shortcut_change_events[] = { + window_shortcut_change_emptysub, + window_shortcut_change_mouseup, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_emptysub, + window_shortcut_change_paint, + window_shortcut_change_emptysub +}; + +void window_shortcut_change_open(int selected_key){ + // Move this to window_shortcut_change_open + window_close_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); + // Save the item we are selecting for new window + RCT2_GLOBAL(0x9DE511, uint8) = selected_key; + rct_window* w = window_create_auto_pos(WW, WH, (uint32*)window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); + + w->widgets = window_shortcut_change_widgets; + w->enabled_widgets = (1 << 2); + window_init_scroll_widgets(w); + w->colours[0] = 7; + w->colours[1] = 7; + w->colours[2] = 7; +} + +/** +* +* rct2: 0x006E3AE0 +*/ +static void window_shortcut_change_mouseup(){ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + switch (widgetIndex){ + case WIDX_CLOSE: + window_close(w); + } +} + +/** +* +* rct2: 0x006E3A9F +*/ +static void window_shortcut_change_paint(){ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); + + int x = w->x + 125; + int y = w->y + 30; + + RCT2_GLOBAL(0x13CE952, uint16) = 2493 + RCT2_GLOBAL(0x9DE511, uint8); + gfx_draw_string_centred_wrapped(dpi, (void*)0x13CE952, x, y, 242, 2785, RCT2_GLOBAL(0x9DEB8D, uint8)); +} \ No newline at end of file diff --git a/src/window_shortcut_keys.c b/src/window_shortcut_keys.c index 80a978ce19..54e2710781 100644 --- a/src/window_shortcut_keys.c +++ b/src/window_shortcut_keys.c @@ -26,9 +26,6 @@ #define WW 340 #define WH 240 -#define WW_C 250 -#define WH_C 60 - enum WINDOW_SHORTCUT_WIDGET_IDX { WIDX_BACKGROUND, WIDX_TITLE, @@ -37,12 +34,6 @@ enum WINDOW_SHORTCUT_WIDGET_IDX { WIDX_RESET }; -enum WINDOW_SHORTCUT_CHANGE_WIDGET_IDX { - WIDX_CHANGE_BACKGROUND, - WIDX_CHANGE_TITLE, - WIDX_CHANGE_CLOSE, -}; - // 0x9DE48C static rct_widget window_shortcut_widgets[] = { { WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, @@ -53,14 +44,6 @@ static rct_widget window_shortcut_widgets[] = { { WIDGETS_END } }; -// 0x9DE4E0 -static rct_widget window_shortcut_change_widgets[] = { - { WWT_FRAME, 0, 0, WW_C - 1, 0, WH_C - 1, STR_NONE, STR_NONE }, - { WWT_CAPTION, 0, 1, WW_C - 2, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, - { WWT_CLOSEBOX, 0, WW_C-13, WW_C - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, - { WIDGETS_END } -}; - void window_shortcut_emptysub() { } static void window_shortcut_mouseup(); static void window_shortcut_paint(); @@ -101,42 +84,6 @@ static void* window_shortcut_events[] = { window_shortcut_scrollpaint }; -static void window_shortcut_change_mouseup(); -static void window_shortcut_change_paint(); - -//0x9A3F7C -static void* window_shortcut_change_events[] = { - window_shortcut_emptysub, - window_shortcut_change_mouseup, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_emptysub, - window_shortcut_change_paint, - window_shortcut_emptysub -}; - - /** * * rct2: 0x006E3884 @@ -242,19 +189,7 @@ static void window_shortcut_scrollmousedown() if (selected_item >= w->no_list_items)return; - // Move this to window_shortcut_change_open - window_close_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); - // Save the item we are selecting for new window - RCT2_GLOBAL(0x9DE511, uint8) = selected_item; - rct_window* change_w = window_create_auto_pos(WW_C, WH_C, (uint32*)window_shortcut_change_events, WC_CHANGE_KEYBOARD_SHORTCUT, 0); - - w->widgets = window_shortcut_change_widgets; - w->enabled_widgets = (1 << 2); - window_init_scroll_widgets(w); - w->colours[0] = 7; - w->colours[1] = 7; - w->colours[2] = 7; - + window_shortcut_change_open(selected_item); } /** @@ -273,6 +208,8 @@ static void window_shortcut_scrollmouseover() if (selected_item >= w->no_list_items)return; w->selected_list_item = selected_item; + + window_invalidate(w); } /** @@ -287,9 +224,13 @@ static void window_shortcut_scrollpaint() window_paint_get_registers(w, dpi); gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width - 1, dpi->y + dpi->height - 1, RCT2_ADDRESS(0x0141FC48,uint8)[w->colours[1] * 8]); - + for (int i = 0; i < w->no_list_items; ++i){ int y = i * 10; + if (y > dpi->y + dpi->height) { + break; + } + if (y + 10 < dpi->y)continue; int format = STR_BLACK_STRING; if (i == w->selected_list_item){ format = STR_WINDOW_COLOUR_2_STRING; @@ -316,39 +257,4 @@ static void window_shortcut_scrollpaint() gfx_draw_string_left(dpi, format, (void*)0x13CE952, 0, 0, y - 1); } -} - -/** - * - * rct2: 0x006E3AE0 - */ -static void window_shortcut_change_mouseup(){ - short widgetIndex; - rct_window *w; - - window_widget_get_registers(w, widgetIndex); - - switch (widgetIndex){ - case WIDX_CHANGE_CLOSE: - window_close(w); - } -} - -/** - * - * rct2: 0x006E3A9F - */ -static void window_shortcut_change_paint(){ - rct_window *w; - rct_drawpixelinfo *dpi; - - window_paint_get_registers(w, dpi); - - window_draw_widgets(w, dpi); - - int x = w->x + 125; - int y = w->y + 30; - - RCT2_GLOBAL(0x13CE952, uint16) = 2493 + RCT2_GLOBAL(0x9DE511, uint8); - gfx_draw_string_centred_wrapped(dpi, (void*)0x13CE952, x, y, 242, 2785, RCT2_GLOBAL(0x9DEB8D, uint8)); } \ No newline at end of file