Moved mini window into seperate file. Fixed all bugs

This commit is contained in:
Duncan Frost 2014-10-07 17:57:38 +01:00
parent 75f71de53a
commit f2ec0a4bb7
5 changed files with 140 additions and 102 deletions

View File

@ -137,6 +137,7 @@
<ClCompile Include="..\src\window_ride_list.c" />
<ClCompile Include="..\src\window_save_prompt.c" />
<ClCompile Include="..\src\window_shortcut_keys.c" />
<ClCompile Include="..\src\window_shortcut_key_change.c" />
<ClCompile Include="..\src\window_staff.c" />
<ClCompile Include="..\src\window_staff_peep.c" />
<ClCompile Include="..\src\window_title_exit.c" />

View File

@ -434,6 +434,9 @@
<ClCompile Include="..\src\window_shortcut_keys.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\src\window_shortcut_key_change.c">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@ -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();

View File

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#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));
}

View File

@ -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));
}