mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
add title menu and dropdown
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
<ClInclude Include="..\src\climate.h" />
|
||||
<ClInclude Include="..\src\config.h" />
|
||||
<ClInclude Include="..\src\date.h" />
|
||||
<ClInclude Include="..\src\editor.h" />
|
||||
<ClInclude Include="..\src\game.h" />
|
||||
<ClInclude Include="..\src\gfx.h" />
|
||||
<ClInclude Include="..\src\intro.h" />
|
||||
@@ -35,9 +36,11 @@
|
||||
<ClInclude Include="..\src\sprites.h" />
|
||||
<ClInclude Include="..\src\strings.h" />
|
||||
<ClInclude Include="..\src\title.h" />
|
||||
<ClInclude Include="..\src\tutorial.h" />
|
||||
<ClInclude Include="..\src\viewport.h" />
|
||||
<ClInclude Include="..\src\widget.h" />
|
||||
<ClInclude Include="..\src\window.h" />
|
||||
<ClInclude Include="..\src\window_dropdown.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -45,6 +48,7 @@
|
||||
<ClCompile Include="..\src\climate.c" />
|
||||
<ClCompile Include="..\src\config.c" />
|
||||
<ClCompile Include="..\src\date.c" />
|
||||
<ClCompile Include="..\src\editor.c" />
|
||||
<ClCompile Include="..\src\game.c" />
|
||||
<ClCompile Include="..\src\gfx.c" />
|
||||
<ClCompile Include="..\src\intro.c" />
|
||||
@@ -58,9 +62,11 @@
|
||||
<ClCompile Include="..\src\scenario.c" />
|
||||
<ClCompile Include="..\src\strings.c" />
|
||||
<ClCompile Include="..\src\title.c" />
|
||||
<ClCompile Include="..\src\tutorial.c" />
|
||||
<ClCompile Include="..\src\viewport.c" />
|
||||
<ClCompile Include="..\src\widget.c" />
|
||||
<ClCompile Include="..\src\window.c" />
|
||||
<ClCompile Include="..\src\window_dropdown.c" />
|
||||
<ClCompile Include="..\src\window_title_exit.c" />
|
||||
<ClCompile Include="..\src\window_title_logo.c" />
|
||||
<ClCompile Include="..\src\window_main.c" />
|
||||
@@ -133,6 +139,9 @@
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StructMemberAlignment>1Byte</StructMemberAlignment>
|
||||
<TreatSpecificWarningsAsErrors>4013</TreatSpecificWarningsAsErrors>
|
||||
<OmitFramePointers>
|
||||
</OmitFramePointers>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
|
||||
@@ -90,6 +90,15 @@
|
||||
<ClInclude Include="..\src\climate.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\window_dropdown.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\tutorial.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\editor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\src\game.c">
|
||||
@@ -167,6 +176,15 @@
|
||||
<ClCompile Include="..\src\climate.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\window_dropdown.c">
|
||||
<Filter>Windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\tutorial.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\editor.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\openrct2.exe">
|
||||
|
||||
58
src/editor.c
Normal file
58
src/editor.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "editor.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066FFE1
|
||||
*/
|
||||
void editor_load()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x0066FFE1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00672781
|
||||
*/
|
||||
void editor_convert_save_to_scenario()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x00672781);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00672957
|
||||
*/
|
||||
void trackdesigner_load()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x00672957);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006729FD
|
||||
*/
|
||||
void trackmanager_load()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x006729FD);
|
||||
}
|
||||
29
src/editor.h
Normal file
29
src/editor.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EDITOR_H_
|
||||
#define _EDITOR_H_
|
||||
|
||||
void editor_load();
|
||||
void editor_convert_save_to_scenario();
|
||||
void trackdesigner_load();
|
||||
void trackmanager_load();
|
||||
|
||||
#endif
|
||||
40
src/gfx.c
40
src/gfx.c
@@ -271,4 +271,44 @@ void gfx_redraw_screen_rect(short left, short top, short right, short bottom)
|
||||
continue;
|
||||
window_draw(w, left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006C2321
|
||||
* buffer (esi)
|
||||
*/
|
||||
int gfx_get_string_width(char *buffer)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
|
||||
esi = buffer;
|
||||
RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
|
||||
return ecx & 0xFFFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws i formatted text string left aligned at i specified position but clips
|
||||
* the text with an elipsis if the text width exceeds the specified width.
|
||||
* rct2: 0x006C1B83
|
||||
* dpi (edi)
|
||||
* format (bx)
|
||||
* args (esi)
|
||||
* colour (al)
|
||||
* x (cx)
|
||||
* y (dx)
|
||||
* width (bp)
|
||||
*/
|
||||
void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y, int width)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, args, dpi, width);
|
||||
|
||||
//char* buffer;
|
||||
|
||||
//buffer = (char*)0x0141ED68;
|
||||
//format_string(buffer, format, args);
|
||||
//rctmem->current_font_sprite_base = 224;
|
||||
//clip_text(buffer, width);
|
||||
//gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
}
|
||||
31
src/tutorial.c
Normal file
31
src/tutorial.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "tutorial.h"
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0066ECC1
|
||||
*/
|
||||
void tutorial_start(int type)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x0066ECC1, type, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
26
src/tutorial.h
Normal file
26
src/tutorial.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _TUTORIAL_H_
|
||||
#define _TUTORIAL_H_
|
||||
|
||||
void tutorial_start(int type);
|
||||
|
||||
#endif
|
||||
60
src/window.c
60
src/window.c
@@ -109,7 +109,7 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han
|
||||
if (RCT2_NEW_WINDOW == &(RCT2_FIRST_WINDOW[12])) {
|
||||
// Close least recently used window
|
||||
for (w = RCT2_FIRST_WINDOW; w < RCT2_NEW_WINDOW; w++)
|
||||
if (!(w->flags & 0x203))
|
||||
if (!(w->flags & (0x01 | 0x02 | 0x200)))
|
||||
break;
|
||||
|
||||
window_close(w);
|
||||
@@ -119,14 +119,17 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han
|
||||
|
||||
// Flags
|
||||
if (flags & 0x01) {
|
||||
for (; w >= RCT2_FIRST_WINDOW + 1; w--)
|
||||
if (((w - 1)->flags & 0x01) && !((w - 1)->flags & 0x02))
|
||||
for (; w >= RCT2_FIRST_WINDOW + 1; w--) {
|
||||
if ((w - 1)->flags & 0x02)
|
||||
continue;
|
||||
if ((w - 1)->flags & 0x01)
|
||||
break;
|
||||
}
|
||||
else if (flags & 0x02) {
|
||||
for (; w >= RCT2_FIRST_WINDOW + 1; w--)
|
||||
}
|
||||
} else if (!(flags & 0x02)) {
|
||||
for (; w >= RCT2_FIRST_WINDOW + 1; w--) {
|
||||
if (!((w - 1)->flags & 0x02))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Move w to new window slot
|
||||
@@ -137,11 +140,10 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han
|
||||
w->classification = cls;
|
||||
w->var_4B8 = -1;
|
||||
w->var_4B9 = -1;
|
||||
w->flags = 0;
|
||||
w->flags |= flags;
|
||||
w->flags = flags;
|
||||
|
||||
// Play sound
|
||||
if (!(flags & 0x03))
|
||||
if (!(flags & (0x01 | 0x02)))
|
||||
sound_play_panned(40, x + (width / 2));
|
||||
|
||||
w->number = 0;
|
||||
@@ -169,6 +171,7 @@ rct_window *window_create(int x, int y, int width, int height, uint32 *event_han
|
||||
w->var_4AE = 0;
|
||||
RCT2_NEW_WINDOW++;
|
||||
|
||||
window_invalidate(w);
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -208,6 +211,33 @@ void window_close(rct_window* window)
|
||||
viewport_update_pointers();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006ECCF4
|
||||
* @param cls (cl)
|
||||
* @param number (dx)
|
||||
*/
|
||||
void window_close_by_id(rct_windowclass cls, rct_windownumber number)
|
||||
{
|
||||
rct_window* w;
|
||||
|
||||
if (cls & 0x80) {
|
||||
for (w = RCT2_FIRST_WINDOW; w < RCT2_NEW_WINDOW; w++) {
|
||||
if (w->classification == cls) {
|
||||
window_close(w);
|
||||
w = RCT2_FIRST_WINDOW - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (w = RCT2_FIRST_WINDOW; w < RCT2_NEW_WINDOW; w++) {
|
||||
if (w->classification == cls && w->number == number) {
|
||||
window_close(w);
|
||||
w = RCT2_FIRST_WINDOW - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EA8A0
|
||||
@@ -536,4 +566,16 @@ static int window_draw_split(rct_window *w, int left, int top, int right, int bo
|
||||
|
||||
// No windows overlap
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EB15C
|
||||
*
|
||||
* @param window (esi)
|
||||
* @param dpi (edi)
|
||||
*/
|
||||
void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006EB15C, 0, 0, 0, 0, w, dpi, 0);
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef _WINDOW_H_
|
||||
#define _WINDOW_H_
|
||||
|
||||
#include "gfx.h"
|
||||
#include "rct2.h"
|
||||
|
||||
struct rct_window;
|
||||
@@ -135,7 +136,7 @@ typedef struct rct_window {
|
||||
sint16 min_height; // 0x038
|
||||
sint16 max_height; // 0x03A
|
||||
rct_windownumber number; // 0x03C
|
||||
uint16 flags;
|
||||
uint16 flags; // 0x03E
|
||||
rct_scroll scrolls[3]; // 0x040
|
||||
uint8 pad_076[0x40A];
|
||||
sint16 var_480;
|
||||
@@ -270,6 +271,7 @@ void window_dispatch_update_all();
|
||||
void window_update_all();
|
||||
rct_window *window_create(int x, int y, int width, int height, uint32 *event_handlers, rct_windowclass cls, uint16 flags);
|
||||
void window_close(rct_window *window);
|
||||
void window_close_by_id(rct_windowclass cls, rct_windownumber number);
|
||||
rct_window *window_find_by_id(rct_windowclass cls, rct_windownumber number);
|
||||
void window_invalidate(rct_window *window);
|
||||
void window_invalidate_by_id(uint16 cls, rct_windownumber number);
|
||||
@@ -280,5 +282,6 @@ rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber nu
|
||||
rct_window *window_bring_to_front(rct_window *w);
|
||||
|
||||
void window_draw(rct_window *w, int left, int top, int right, int bottom);
|
||||
void window_draw_widgets(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
|
||||
#endif
|
||||
238
src/window_dropdown.c
Normal file
238
src/window_dropdown.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <memory.h>
|
||||
#include "addresses.h"
|
||||
#include "scenario.h"
|
||||
#include "strings.h"
|
||||
#include "sprites.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "window_dropdown.h"
|
||||
|
||||
enum {
|
||||
WIDX_BACKGROUND,
|
||||
};
|
||||
|
||||
static rct_widget window_dropdown_widgets[] = {
|
||||
{ WWT_IMGBTN, 0, 0, 0, 0, 0, -1, STR_NONE },
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
int _dropdown_num_items;
|
||||
int _dropdown_num_columns;
|
||||
int _dropdown_num_rows;
|
||||
int _dropdown_item_width;
|
||||
int _dropdown_item_height;
|
||||
int _dropdown_highlighted_index;
|
||||
|
||||
uint16 gDropdownItemsFormat[64];
|
||||
sint32 gDropdownItemsArgs[64];
|
||||
|
||||
static void window_dropdown_emptysub() { }
|
||||
static void window_dropdown_paint();
|
||||
|
||||
static uint32 window_dropdown_events[] = {
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_emptysub,
|
||||
window_dropdown_paint,
|
||||
window_dropdown_emptysub
|
||||
};
|
||||
|
||||
/**
|
||||
* Shows a text dropdown menu.
|
||||
* rct2: 0x006ECFB9
|
||||
*
|
||||
* @param x (cx)
|
||||
* @param y (dx)
|
||||
* @param extray (di)
|
||||
* @param flags (bh)
|
||||
* @param num_items (bx)
|
||||
* @param colour (al)
|
||||
*/
|
||||
void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 flags, int num_items)
|
||||
{
|
||||
rct_window* w;
|
||||
int i, string_width, max_string_width;
|
||||
char buffer[256];
|
||||
|
||||
// Copy the formats and arguments until all use of it is decompiled
|
||||
memcpy(0x009DEBA4, gDropdownItemsFormat, 37 * 2);
|
||||
memcpy(0x009DEBF4, gDropdownItemsArgs, 80 * 4);
|
||||
|
||||
RCT2_GLOBAL(0x009DE518, uint32) &= ~(0x04 | 0x02);
|
||||
if (flags & 0x80)
|
||||
RCT2_GLOBAL(0x009DE518, uint32) |= 0x02;
|
||||
|
||||
window_dropdown_close();
|
||||
_dropdown_num_columns = 1;
|
||||
_dropdown_item_width = 0;
|
||||
_dropdown_item_height = 10;
|
||||
if (flags & 0x40)
|
||||
_dropdown_item_height = flags & 0x3F;
|
||||
|
||||
// Calculate the longest string width
|
||||
max_string_width = 0;
|
||||
for (i = 0; i < num_items; i++) {
|
||||
format_string(buffer, gDropdownItemsFormat[i], (void*)(&gDropdownItemsArgs[i]));
|
||||
RCT2_GLOBAL(0x013CE950, sint16) = 224;
|
||||
string_width = gfx_get_string_width(buffer);
|
||||
max_string_width = max(string_width, max_string_width);
|
||||
}
|
||||
|
||||
// Set the widgets
|
||||
_dropdown_item_width = max_string_width + 3;
|
||||
_dropdown_num_items = num_items;
|
||||
_dropdown_num_rows = num_items;
|
||||
window_dropdown_widgets[WIDX_BACKGROUND].bottom = _dropdown_item_height * num_items + 3;
|
||||
window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;
|
||||
|
||||
// Create the window
|
||||
w = window_create(
|
||||
x, y + extray,
|
||||
window_dropdown_widgets[WIDX_BACKGROUND].right + 1,
|
||||
window_dropdown_widgets[WIDX_BACKGROUND].bottom + 1,
|
||||
window_dropdown_events,
|
||||
WC_DROPDOWN,
|
||||
0x02
|
||||
);
|
||||
w->widgets = window_dropdown_widgets;
|
||||
if (colour & 0x80)
|
||||
w->flags |= WF_TRANSPARENT;
|
||||
w->colours[0] = colour;
|
||||
|
||||
// Input state
|
||||
_dropdown_highlighted_index = -1;
|
||||
RCT2_GLOBAL(0x009DED34, sint32) = 0;
|
||||
RCT2_GLOBAL(0x009DED38, sint32) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = 5;
|
||||
|
||||
// Copy the following properties until all use of it is decompiled
|
||||
RCT2_GLOBAL(0x009DEBA0, sint16) = _dropdown_num_items;
|
||||
RCT2_GLOBAL(0x009DED44, sint32) = _dropdown_num_columns;
|
||||
RCT2_GLOBAL(0x009DED48, sint32) = _dropdown_num_rows;
|
||||
RCT2_GLOBAL(0x009DED40, sint32) = _dropdown_item_width;
|
||||
RCT2_GLOBAL(0x009DED3C, sint32) = _dropdown_item_height;
|
||||
RCT2_GLOBAL(0x009DEBA2, sint16) = _dropdown_highlighted_index;
|
||||
}
|
||||
|
||||
void window_dropdown_close()
|
||||
{
|
||||
window_close_by_id(WC_DROPDOWN, 0);
|
||||
}
|
||||
|
||||
static void window_dropdown_paint()
|
||||
{
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
|
||||
__asm mov w, esi
|
||||
__asm mov dpi, edi
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
|
||||
_dropdown_highlighted_index = RCT2_GLOBAL(0x009DEBA2, sint16);
|
||||
{
|
||||
int i, cell_x, cell_y, l, t, r, b, item, colour;
|
||||
for (i = 0; i < _dropdown_num_items; i++) {
|
||||
cell_x = i % _dropdown_num_columns;
|
||||
cell_y = i / _dropdown_num_columns;
|
||||
|
||||
if (gDropdownItemsFormat[i] == DROPDOWN_SEPARATOR) {
|
||||
l = w->x + 2 + (cell_x * _dropdown_item_width);
|
||||
t = w->y + 2 + (cell_y * _dropdown_item_height);
|
||||
r = l + _dropdown_item_width - 1;
|
||||
t += (_dropdown_item_height / 2);
|
||||
b = t;
|
||||
|
||||
if (w->colours[0] & 0x80) {
|
||||
gfx_fill_rect(dpi, l, t, r, b, (RCT2_ADDRESS(0x009DEDF4, uint8)[w->colours[0]] | 0x02000000) + 1);
|
||||
gfx_fill_rect(dpi, l, t + 1, r, b + 1, (RCT2_ADDRESS(0x009DEDF4, uint8)[w->colours[0]] | 0x02000000) + 2);
|
||||
} else {
|
||||
gfx_fill_rect(dpi, l, t, r, b,
|
||||
*((char*)(0x00141FC47 + (w->colours[0] * 8))));
|
||||
gfx_fill_rect(dpi, l, t + 1, r, b + 1,
|
||||
*((char*)(0x00141FC4B + (w->colours[0] * 8))));
|
||||
}
|
||||
} else {
|
||||
//
|
||||
if (i == _dropdown_highlighted_index) {
|
||||
l = w->x + 2 + (cell_x * _dropdown_item_width);
|
||||
t = w->y + 2 + (cell_y * _dropdown_item_height);
|
||||
r = l + _dropdown_item_width - 1;
|
||||
b = t + _dropdown_item_height - 1;
|
||||
gfx_fill_rect(dpi, l, t, r, b, 0x2000000 | 0x2F);
|
||||
}
|
||||
|
||||
item = gDropdownItemsFormat[i];
|
||||
if (item == -1 || item == -2) {
|
||||
// Image item
|
||||
} else {
|
||||
// Text item
|
||||
if (i < 32)
|
||||
if (RCT2_GLOBAL(0x009DED38, uint32) & (1 << i))
|
||||
item++;
|
||||
|
||||
// Calculate colour
|
||||
colour = w->colours[0] & 0x7F;
|
||||
if (i == _dropdown_highlighted_index)
|
||||
colour = 2;
|
||||
if (RCT2_GLOBAL(0x009DED34, uint32) & (1 << i))
|
||||
if (i < 32)
|
||||
colour = (w->colours[0] & 0x7F) | 0x40;
|
||||
|
||||
// Draw item string
|
||||
gfx_draw_string_left_clipped(
|
||||
dpi,
|
||||
item,
|
||||
(void*)(&gDropdownItemsArgs[i]), colour,
|
||||
w->x + 2 + (cell_x * _dropdown_item_width),
|
||||
w->y + 1 + (cell_y * _dropdown_item_height),
|
||||
w->width - 5
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/window_dropdown.h
Normal file
29
src/window_dropdown.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*****************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "rct2.h"
|
||||
|
||||
#define DROPDOWN_SEPARATOR 0
|
||||
|
||||
extern uint16 gDropdownItemsFormat[64];
|
||||
extern sint32 gDropdownItemsArgs[64];
|
||||
|
||||
void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 flags, int num_items);
|
||||
void window_dropdown_close();
|
||||
@@ -19,10 +19,13 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "editor.h"
|
||||
#include "strings.h"
|
||||
#include "sprites.h"
|
||||
#include "tutorial.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "window_dropdown.h"
|
||||
|
||||
void window_levelselect_open();
|
||||
|
||||
@@ -41,35 +44,42 @@ static rct_widget window_title_menu_widgets[] = {
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
static void window_title_menu_emptysub() { }
|
||||
static void window_title_menu_mouseup();
|
||||
static void window_title_menu_mousedown();
|
||||
static void window_title_menu_dropdown();
|
||||
static void window_title_menu_unknown17();
|
||||
static void window_title_menu_paint();
|
||||
|
||||
static uint32 window_title_menu_events[] = {
|
||||
0x0066B834,
|
||||
0x0066B6EC,
|
||||
0x0066B834,
|
||||
0x0066B70E,
|
||||
0x0066B71F,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B730,
|
||||
0x0066B834,
|
||||
0x0066B834,
|
||||
0x0066B6E6,
|
||||
0x0066B834
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_mouseup,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_mousedown,
|
||||
window_title_menu_dropdown,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_unknown17,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_emptysub,
|
||||
window_title_menu_paint,
|
||||
window_title_menu_emptysub
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -92,4 +102,97 @@ void window_title_menu_open()
|
||||
window->colours[0] = 140;
|
||||
window->colours[1] = 140;
|
||||
window->colours[2] = 140;
|
||||
}
|
||||
|
||||
static void window_title_menu_mouseup()
|
||||
{
|
||||
short widgetIndex;
|
||||
|
||||
__asm mov widgetIndex, dx
|
||||
if (widgetIndex == WIDX_START_NEW_GAME) {
|
||||
window_levelselect_open();
|
||||
} else if (widgetIndex == WIDX_CONTINUE_SAVED_GAME) {
|
||||
RCT2_CALLPROC_X(0x006677F2, 0, 1, 0, 0, 5, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_title_menu_mousedown()
|
||||
{
|
||||
short widgetIndex;
|
||||
rct_window *w;
|
||||
rct_widget *widget;
|
||||
|
||||
__asm mov widgetIndex, dx
|
||||
__asm mov w, esi
|
||||
__asm mov widget, edi
|
||||
|
||||
if (widgetIndex == WIDX_SHOW_TUTORIAL) {
|
||||
gDropdownItemsFormat[0] = STR_TUTORIAL_BEGINNERS;
|
||||
gDropdownItemsFormat[1] = STR_TUTORIAL_CUSTOM_RIDES;
|
||||
gDropdownItemsFormat[2] = STR_TUTORIAL_ROLLER_COASTER;
|
||||
window_dropdown_show_text(
|
||||
w->x + widget->left,
|
||||
w->y + widget->top,
|
||||
widget->bottom - widget->top + 1,
|
||||
w->colours[0] | 0x80,
|
||||
0x80,
|
||||
3
|
||||
);
|
||||
} else if (widgetIndex == WIDX_GAME_TOOLS) {
|
||||
gDropdownItemsFormat[0] = STR_SCENARIO_EDITOR;
|
||||
gDropdownItemsFormat[1] = STR_CONVERT_SAVED_GAME_TO_SCENARIO;
|
||||
gDropdownItemsFormat[2] = STR_ROLLER_COASTER_DESIGNER;
|
||||
gDropdownItemsFormat[3] = STR_TRACK_DESIGNS_MANAGER;
|
||||
window_dropdown_show_text(
|
||||
w->x + widget->left,
|
||||
w->y + widget->top,
|
||||
widget->bottom - widget->top + 1,
|
||||
w->colours[0] | 0x80,
|
||||
0x80,
|
||||
4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_title_menu_dropdown()
|
||||
{
|
||||
short widgetIndex, dropdownIndex;
|
||||
|
||||
__asm mov widgetIndex, dx
|
||||
__asm mov dropdownIndex, ax
|
||||
|
||||
if (widgetIndex == WIDX_SHOW_TUTORIAL) {
|
||||
tutorial_start(dropdownIndex);
|
||||
} else if (widgetIndex == WIDX_GAME_TOOLS) {
|
||||
switch (dropdownIndex) {
|
||||
case 0:
|
||||
editor_load();
|
||||
break;
|
||||
case 1:
|
||||
editor_convert_save_to_scenario();
|
||||
break;
|
||||
case 2:
|
||||
trackdesigner_load();
|
||||
break;
|
||||
case 3:
|
||||
trackmanager_load();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void window_title_menu_unknown17()
|
||||
{
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, sint16) = 2000;
|
||||
}
|
||||
|
||||
static void window_title_menu_paint()
|
||||
{
|
||||
rct_window *w;
|
||||
rct_drawpixelinfo *dpi;
|
||||
|
||||
__asm mov w, esi
|
||||
__asm mov dpi, edi
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "addresses.h"
|
||||
#include "scenario.h"
|
||||
#include "strings.h"
|
||||
#include "sprites.h"
|
||||
#include "widget.h"
|
||||
@@ -45,18 +46,22 @@ static rct_widget window_levelselect_widgets[] = {
|
||||
void window_levelselect_open()
|
||||
{
|
||||
rct_window* window;
|
||||
int y;
|
||||
|
||||
if (window_bring_to_front_by_id(WC_LEVEL_SELECT, 0) != NULL)
|
||||
return;
|
||||
|
||||
// Load scenario list
|
||||
RCT2_CALLPROC_EBPSAFE(0x006775A8); // scenario_load_list();
|
||||
scenario_load_list();
|
||||
|
||||
y = (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 167;
|
||||
if (y < 28)
|
||||
y = 28;
|
||||
window = window_create((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - 305, y, 610, 334, 0x0097FC4C, WC_LEVEL_SELECT, 0x0402);
|
||||
window = window_create(
|
||||
(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) / 2) - 305,
|
||||
max(28, (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) / 2) - 167),
|
||||
610,
|
||||
334,
|
||||
0x0097FC4C,
|
||||
WC_LEVEL_SELECT,
|
||||
0x400 | 0x02
|
||||
);
|
||||
window->widgets = window_levelselect_widgets;
|
||||
|
||||
window->enabled_widgets = 0x04 | 0x10 | 0x20 | 0x40 | 0x80 | 0x100;
|
||||
|
||||
Reference in New Issue
Block a user