From 09e9288eb8ba58968155d867f943a979f2af4740 Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Fri, 20 Feb 2015 01:35:29 +0100 Subject: [PATCH] Added options button to title screen --- projects/openrct2.vcxproj | 1 + projects/openrct2.vcxproj.filters | 3 + src/interface/window.h | 4 +- src/title.c | 1 + src/windows/title_options.c | 112 ++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/windows/title_options.c diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index ea978e0d9a..a83cc21a07 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -123,6 +123,7 @@ + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index e139763e95..d409975888 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -425,6 +425,9 @@ Source + + Source\Windows + diff --git a/src/interface/window.h b/src/interface/window.h index 744c6f9618..7c8c3c07fa 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -400,7 +400,8 @@ enum { WC_TEXTINPUT = 113, WC_MAPGEN = 114, WC_LOADSAVE = 115, - WC_LOADSAVE_OVERWRITE_PROMPT = 116 + WC_LOADSAVE_OVERWRITE_PROMPT = 116, + WC_TITLE_OPTIONS = 117 } WINDOW_CLASS; enum PROMPT_MODE { @@ -504,6 +505,7 @@ void window_footpath_open(); void window_save_prompt_open(); void window_title_menu_open(); void window_title_exit_open(); +void window_title_options_open(); void window_title_logo_open(); void window_news_open(); void window_scenarioselect_open(); diff --git a/src/title.c b/src/title.c index d1daa1eb9a..bbfa0e7375 100644 --- a/src/title.c +++ b/src/title.c @@ -135,6 +135,7 @@ static void title_create_windows() window_main_open(); window_title_menu_open(); window_title_exit_open(); + window_title_options_open(); window_title_logo_open(); RCT2_CALLPROC_EBPSAFE(0x0066B905); } diff --git a/src/windows/title_options.c b/src/windows/title_options.c new file mode 100644 index 0000000000..7b7715c103 --- /dev/null +++ b/src/windows/title_options.c @@ -0,0 +1,112 @@ +/***************************************************************************** + * Copyright (c) 2014 Ted John, Timmy Weerwag + * 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 "../game.h" +#include "../localisation/localisation.h" +#include "../interface/widget.h" +#include "../interface/window.h" + +static rct_widget window_title_options_widgets[] = { + { WWT_DROPDOWN_BUTTON, 2, 0, 79, 0, 11, STR_OPTIONS, STR_NONE }, + { WIDGETS_END }, +}; + +static void window_title_options_emptysub() {} +static void window_title_options_paint(); +static void window_title_options_mouseup(); + +static void* window_title_options_events[] = { + window_title_options_emptysub, + window_title_options_mouseup, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_emptysub, + window_title_options_paint, + window_title_options_emptysub +}; + +/** + * Creates the window containing the options button on the title screen. + */ +void window_title_options_open() +{ + rct_window* window; + + window = window_create( + RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - 80, 0, + 80, 12, + (uint32*)window_title_options_events, + WC_TITLE_OPTIONS, + WF_STICK_TO_FRONT + ); + window->widgets = window_title_options_widgets; + window->enabled_widgets |= 1; + window_init_scroll_widgets(window); + window->flags |= 16; + window->colours[0] = 140; + window->colours[1] = 140; + window->colours[2] = 140; +} + +static void window_title_options_mouseup() +{ + short widgetIndex; + rct_window *w; + + window_widget_get_registers(w, widgetIndex); + + if (RCT2_GLOBAL(RCT2_ADDRESS_RUN_INTRO_TICK_PART, uint8) != 0) + return; + + if (widgetIndex == 0) + window_options_open(); +} + +static void window_title_options_paint() +{ + rct_window *w; + rct_drawpixelinfo *dpi; + + window_paint_get_registers(w, dpi); + + window_draw_widgets(w, dpi); +} \ No newline at end of file