add window definitions and update all subroutine

This commit is contained in:
IntelOrca 2014-04-02 04:56:26 +01:00
parent 643db7ae01
commit bfd3ad8b28
6 changed files with 336 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<Project DefaultTargets="Build0;Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build0">
<Copy SourceFiles="..\openrct2.exe" DestinationFolder="$(OutDir)" />
<Copy SourceFiles="..\SDL2.dll" DestinationFolder="$(OutDir)" />
<Copy SourceFiles="..\SDL2.dll" DestinationFolder="$(OutDir)" />
</Target>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -21,6 +21,7 @@
<ClInclude Include="..\src\osinterface.h" />
<ClInclude Include="..\src\rct2.h" />
<ClInclude Include="..\src\title.h" />
<ClInclude Include="..\src\window.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\game.c" />
@ -28,6 +29,7 @@
<ClCompile Include="..\src\osinterface.c" />
<ClCompile Include="..\src\rct2.c" />
<ClCompile Include="..\src\title.c" />
<ClCompile Include="..\src\window.c" />
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe" />
@ -81,7 +83,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>winmm.lib;sdl2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>winmm.lib;sdl2.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

View File

@ -33,6 +33,9 @@
<ClInclude Include="..\src\title.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\window.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\game.c">
@ -50,6 +53,9 @@
<ClCompile Include="..\src\title.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\window.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@ -44,10 +44,24 @@
#define RCT2_ADDRESS_SCREEN_HEIGHT 0x009ABDDA
#define RCT2_ADDRESS_RUN_INTRO_TICK_PART 0x009AC319
#define RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS 0x009DE533
#define RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER 0x009DE534
#define RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX 0x009DE536
#define RCT2_ADDRESS_TOOLTIP_CURSOR_X 0x009DE538
#define RCT2_ADDRESS_TOOLTIP_CURSOR_Y 0x009DE53A
#define RCT2_ADDRESS_TOOLTIP_TIMEOUT 0x009DE53C
#define RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS 0x009DE53E
#define RCT2_ADDRESS_SCREEN_FLAGS 0x009DEA68
#define RCT2_ADDRESS_PLACE_OBJECT_MODIFIER 0x009DEA70
#define RCT2_ADDRESS_ON_TUTORIAL 0x009DEA71
#define RCT2_ADDRESS_WINDOW_LIST 0x01420078
#define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8
#define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC
#define RCT2_ADDRESS_NEW_VIEWPORT_PTR 0x01423570
#define RCT2_ADDRESS_OS_TOTALPHYS 0x01423B5C
static void RCT2_CALLPROC_EBPSAFE(int address)

View File

@ -21,6 +21,7 @@
#include "addresses.h"
#include "rct2.h"
#include "game.h"
#include "window.h"
void game_update()
{
@ -133,7 +134,7 @@ void game_logic_update()
RCT2_CALLPROC_EBPSAFE(0x0067009A);
// Update windows
RCT2_CALLPROC_EBPSAFE(0x006ED7B0); // window_update_all()
window_update_all();
if (RCT2_GLOBAL(0x009AC31B, uint8) != 0) {
_bx = 3010;

39
src/window.c Normal file
View File

@ -0,0 +1,39 @@
/*****************************************************************************
* 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 "window.h"
#define RCT2_FIRST_WINDOW (RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window))
#define RCT2_LAST_WINDOW (RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*) - 1)
// rct2: 0x006ED7B0
void window_update_all()
{
rct_window *w;
RCT2_GLOBAL(0x01423604, sint32)++;
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_NOT_SHOWN_TICKS, sint16)++;
for (w = RCT2_LAST_WINDOW; w >= RCT2_FIRST_WINDOW; w--) {
RCT2_CALLPROC_X(w->event_handlers[WE_UPDATE], 0, 0, 0, 0, w, 0, 0);
}
RCT2_CALLPROC_EBPSAFE(0x006EE411);
}

271
src/window.h Normal file
View File

@ -0,0 +1,271 @@
/*****************************************************************************
* 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 _WINDOW_H_
#define _WINDOW_H_
#include "rct2.h"
struct rct_window;
union rct_window_event;
typedef void wndproc(struct rct_window*, union rct_window_event*);
/**
* Widget structure
* size: 0x10
*/
typedef struct {
uint8 type; // 0x00
uint8 colour; // 0x01
sint16 left; // 0x02
sint16 right; // 0x04
sint16 top; // 0x06
sint16 bottom; // 0x08
uint32 image; // 0x0A
uint16 tooltip; // 0x0E
} rct_widget;
typedef sint8 rct_windowclass;
typedef sint16 rct_windownumber;
typedef struct {
rct_windowclass classification;
rct_windownumber number;
} window_identifier;
typedef struct {
window_identifier window;
int widget_index;
} widget_identifier;
/**
* Viewport structure
* size: 0x14
*/
typedef struct {
sint16 width; // 0x00
sint16 height; // 0x02
sint16 x; // 0x04
sint16 y; // 0x06
sint16 view_x; // 0x08
sint16 view_y; // 0x0A
sint16 view_width; // 0x0C
sint16 view_height; // 0x0E
uint8 zoom; // 0x10
uint8 var_11;
uint16 flags; // 0x12
} rct_viewport;
enum {
HSCROLLBAR_VISIBLE = (1 << 0),
HSCROLLBAR_LEFT_PRESSED = (1 << 1),
HSCROLLBAR_THUMB_PRESSED = (1 << 2),
HSCROLLBAR_RIGHT_PRESSED = (1 << 3),
VSCROLLBAR_VISIBLE = (1 << 4),
VSCROLLBAR_UP_PRESSED = (1 << 5),
VSCROLLBAR_THUMB_PRESSED = (1 << 6),
VSCROLLBAR_DOWN_PRESSED = (1 << 7),
};
#define SCROLLBAR_SIZE 16
enum {
SCROLL_PART_NONE = -1,
SCROLL_PART_VIEW = 0,
SCROLL_PART_HSCROLLBAR_LEFT = 1,
SCROLL_PART_HSCROLLBAR_RIGHT = 2,
SCROLL_PART_HSCROLLBAR_LEFT_TROUGH = 3,
SCROLL_PART_HSCROLLBAR_RIGHT_TROUGH = 4,
SCROLL_PART_HSCROLLBAR_THUMB = 5,
SCROLL_PART_VSCROLLBAR_TOP = 6,
SCROLL_PART_VSCROLLBAR_BOTTOM = 7,
SCROLL_PART_VSCROLLBAR_TOP_TROUGH = 8,
SCROLL_PART_VSCROLLBAR_BOTTOM_TROUGH = 9,
SCROLL_PART_VSCROLLBAR_THUMB = 10,
};
typedef struct {
uint16 flags; // 0x00
sint16 h_left; // 0x02
sint16 h_right; // 0x04
sint16 h_thumb_left; // 0x06
sint16 h_thumb_right; // 0x08
sint16 v_top; // 0x0A
sint16 v_bottom; // 0x0C
sint16 v_thumb_top; // 0x0E
sint16 v_thumb_bottom; // 0x10
} rct_scroll;
/**
* Window structure
* size: 0x4C0
*/
typedef struct rct_window {
uint32* event_handlers; // 0x000
rct_viewport* viewport; // 0x004
uint64 enabled_widgets; // 0x008
uint64 disabled_widgets; // 0x010
uint64 pressed_widgets; // 0x018
uint64 var_020;
rct_widget* widgets; // 0x028
sint16 x; // 0x02C
sint16 y; // 0x02E
sint16 width; // 0x030
sint16 height; // 0x032
sint16 min_width; // 0x034
sint16 max_width; // 0x036
sint16 min_height; // 0x038
sint16 max_height; // 0x03A
rct_windownumber number; // 0x03C
uint16 flags;
rct_scroll scrolls[3]; // 0x040
uint8 pad_076[0x40A];
sint16 var_480;
sint16 var_482;
sint16 var_484;
sint16 var_486;
sint16 var_488;
sint16 var_48A;
sint16 var_48C;
sint16 var_48E;
sint16 var_490;
sint16 var_492;
uint32 var_494;
uint8 var_498[0x14];
sint16 var_4AC;
sint16 var_4AE;
sint16 var_4B0;
sint16 var_4B2;
sint16 var_4B4;
rct_windowclass classification; // 0x4B6
uint8 pad_4B7;
uint8 var_4B8;
uint8 var_4B9;
uint8 colours[6]; // 0x4BA
} rct_window;
typedef enum {
WE_CLOSE = 0,
WE_MOUSE_UP = 1,
WE_UNKNOWN_02 = 2,
WE_MOUSE_DOWN = 3,
WE_DROPDOWN = 4,
WE_UNKNOWN_05 = 5,
WE_UPDATE = 6,
WE_UNKNOWN_07 = 7,
WE_UNKNOWN_08 = 8,
WE_UNKNOWN_09 = 9,
WE_UNKNOWN_0A = 10,
WE_UNKNOWN_0B = 11,
WE_UNKNOWN_0C = 12,
WE_UNKNOWN_0D = 13,
WE_UNKNOWN_0E = 14,
WE_SCROLL_GETSIZE = 15,
WE_SCROLL_MOUSEDOWN = 16,
WE_UNKNOWN_11 = 17,
WE_SCROLL_MOUSEOVER = 18,
WE_UNKNOWN_13 = 19,
WE_UNKNOWN_14 = 20,
WE_UNKNOWN_15 = 21,
WE_TOOLTIP = 22,
WE_UNKNOWN_17 = 23,
WE_UNKNOWN_18 = 24,
WE_INVALIDATE = 25,
WE_PAINT = 26,
WE_SCROLL_PAINT = 27,
WE_MOUSE_ENTER,
WE_MOUSE_LEAVE,
WE_MOUSE_OVER,
} WINDOW_EVENTS;
typedef enum {
/*
WF_TIMEOUT_SHL = 0,
WF_TIMEOUT_MASK = 7,
WF_DRAGGING = 1 << 3,
WF_SCROLLER_UP = 1 << 4,
WF_SCROLLER_DOWN = 1 << 5,
WF_SCROLLER_MIDDLE = 1 << 6,
WF_DISABLE_VP_SCROLL = 1 << 9,
*/
WF_TRANSPARENT = (1 << 4),
WF_WHITE_BORDER_ONE = (1 << 12),
WF_WHITE_BORDER_MASK = (1 << 12) | (1 << 13),
} WINDOW_FLAGS;
enum {
INPUT_STATE_RESET = 0,
INPUT_STATE_NORMAL = 1,
INPUT_STATE_WIDGET_PRESSED = 2,
INPUT_STATE_DRAGGING = 3,
INPUT_STATE_VIEWPORT_LEFT = 4,
INPUT_STATE_DROPDOWN_ACTIVE = 5,
INPUT_STATE_VIEWPORT_RIGHT = 6,
INPUT_STATE_SCROLL_LEFT = 7,
INPUT_STATE_RESIZING = 8,
};
enum {
WC_MAIN_WINDOW = 0,
WC_TOP_TOOLBAR = 1,
WC_BOTTOM_TOOLBAR = 2,
WC_TOOLTIP = 5,
WC_DROPDOWN = 6,
WC_ABOUT = 8,
WC_RIDE = 12,
WC_RIDE_CONSTRUCTION = 13,
WC_RIDE_LIST = 15,
WC_CONSTRUCT_RIDE = 16,
WC_SCENERY = 18,
WC_OPTIONS = 19,
WC_FOOTPATH = 20,
WC_LAND = 21,
WC_WATER = 22,
WC_PEEP = 23,
WC_GUEST_LIST = 24,
WC_STAFF_LIST = 25,
WC_PARK_INFORMATION = 27,
WC_FINANCES = 28,
WC_TITLE_MENU = 29,
WC_TITLE_EXIT = 30,
WC_RECENT_NEWS = 31,
WC_LEVEL_SELECT = 32,
WC_TRACK_DESIGN_LIST = 33,
WC_NEW_CAMPAIGN = 35,
WC_KEYBOARD_SHORTCUT_LIST = 36,
WC_CHANGE_KEYBOARD_SHORTCUT = 37,
WC_MAP = 38,
WC_TITLE_LOGO = 39,
WC_EDITOR_OBJECT_SELECTION = 42,
WC_EDITOR_INVENTION_LIST = 43,
WC_EDITOR_SCENARIO_OPTIONS = 45,
WC_EDTIOR_OBJECTIVE_OPTIONS = 46,
WC_CLEAR_SCENERY = 50,
WC_MANAGE_TRACK_DESIGN = 89,
WC_CHEATS = 110,
} WINDOW_CLASS;
void window_update_all();
#endif