start implementation of track list window

This commit is contained in:
IntelOrca 2014-09-27 00:41:24 +01:00
parent b65554e669
commit f026f92d1e
12 changed files with 395 additions and 14 deletions

View File

@ -143,6 +143,7 @@
<ClCompile Include="..\src\window_title_scenarioselect.c" />
<ClCompile Include="..\src\window_game_top_toolbar.c" />
<ClCompile Include="..\src\window_tooltip.c" />
<ClCompile Include="..\src\window_track_list.c" />
<ClCompile Include="..\src\window_water.c" />
<ClCompile Include="..\src\staff.c" />
<ClCompile Include="..\src\window_scenery.c" />

View File

@ -168,6 +168,12 @@
<ClInclude Include="..\src\window_scenery.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\hook.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\mixer.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\game.c">
@ -401,6 +407,18 @@
<ClCompile Include="..\src\window_publisher_credits.c">
<Filter>Windows</Filter>
</ClCompile>
<ClCompile Include="..\libspeex\resample.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\hook.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\mixer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\window_track_list.c">
<Filter>Windows</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\openrct2.exe">

View File

@ -161,7 +161,10 @@ void rct2_init()
// RCT2_CALLPROC_EBPSAFE(0x00674B81); // pointless expansion pack crap
object_list_load();
scenario_load_list();
track_load_list(253);
ride_list_item item = { 253, 0 };
track_load_list(item);
gfx_load_g1();
//RCT2_CALLPROC_EBPSAFE(0x006C19AC); //Load character widths
gfx_load_character_widths();

View File

@ -39,6 +39,14 @@ typedef struct {
ride_rating nausea;
} rating_tuple;
/**
* Couples a ride type and subtype together.
*/
typedef struct {
uint8 type;
uint8 entry_index;
} ride_list_item;
/**
* Ride type structure.
* size: unknown

View File

@ -183,7 +183,7 @@ void scenario_load_and_play(const rct_scenario_basic *scenario)
srand0 = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_0, uint32) ^ timeGetTime();
srand1 = RCT2_GLOBAL(RCT2_ADDRESS_SCENARIO_SRAND_1, uint32) ^ timeGetTime();
RCT2_CALLPROC_EBPSAFE(0x006CBCC3);
window_close_construction_windows();
subsitute_path(
RCT2_ADDRESS(0x0141EF68, char),

View File

@ -471,6 +471,10 @@ enum {
STR_MEASUREMENTS_AND_TEST_DATA_TIP = 1398,
STR_GRAPHS_TIP = 1399,
STR_ROTATE_90_TIP = 1404,
STR_MIRROR_IMAGE_TIP = 1405,
STR_TOGGLE_SCENERY_TIP = 1406,
STR_BUILD_THIS = 1407,
STR_COST_LABEL = 1408,
@ -823,6 +827,9 @@ enum {
STR_CHANGE_BASE_LAND_TIP = 2294,
STR_CHANGE_VERTICAL_LAND_TIP = 2295,
STR_SELECT_DESIGN = 2307,
STR_TRACK_DESIGNS = 2308,
STR_SOUND_QUALITY = 2317,
STR_SOUND_LOW = 2318,
STR_SOUND_MEDIUM = 2319,
@ -1160,6 +1167,9 @@ enum {
STR_OPEN_RIDE = 3109,
STR_BLOCK_SECTIONS = 3110,
STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP = 3111,
STR_CLICK_ON_DESIGN_TO_RENAME_OR_DELETE_IT = 3112,
STR_SAVE_TRACK_DESIGN = 3115,
STR_SAVE_TRACK_DESIGN_NOT_POSSIBLE = 3116,
@ -1226,6 +1236,9 @@ enum {
STR_ROLLER_COASTER_DESIGNER = 3344,
STR_TRACK_DESIGNS_MANAGER = 3345,
STR_WARNING = 3360,
STR_TOO_MANY_TRACK_DESIGNS_OF_THIS_TYPE = 3361,
STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING = 3362,
STR_SOUND_FORCED_SOFTWARE_BUFFER_MIXING_TIP = 3363,

View File

@ -19,6 +19,7 @@
*****************************************************************************/
#include "addresses.h"
#include "ride.h"
#include "track.h"
/**
@ -220,7 +221,7 @@ const rct_trackdefinition gTrackDefinitions[] = {
*
* rct2: 0x006CED50
*/
void track_load_list(int edx)
void track_load_list(ride_list_item item)
{
RCT2_CALLPROC_X(0x006CED50, 0, 0, 0, edx, 0, 0, 0);
RCT2_CALLPROC_X(0x006CED50, 0, 0, 0, *((uint16*)&item), 0, 0, 0);
}

View File

@ -90,6 +90,6 @@ enum {
TRACK_CORKSCREW_DOWN = 224
};
void track_load_list(int edx);
void track_load_list(ride_list_item item);
#endif

View File

@ -1688,3 +1688,14 @@ void window_align_tabs(rct_window *w, uint8 start_tab_id, uint8 end_tab_id)
}
}
/**
*
* rct2: 0x006CBCC3
*/
void window_close_construction_windows()
{
window_close_by_id(WC_RIDE_CONSTRUCTION, 0);
window_close_by_id(WC_FOOTPATH, 0);
window_close_by_id(WC_TRACK_DESIGN_LIST, 0);
window_close_by_id(WC_34, 0);
}

View File

@ -25,6 +25,7 @@
#include "park.h"
#include "peep.h"
#include "rct2.h"
#include "ride.h"
struct rct_window;
union rct_window_event;
@ -168,6 +169,12 @@ typedef struct {
sint16 hover_counter;
} scenery_variables;
typedef struct {
uint16 var_480;
uint16 var_482;
uint16 var_484;
} track_list_variables;
/**
* Window structure
* size: 0x4C0
@ -206,6 +213,7 @@ typedef struct rct_window {
map_variables map;
ride_variables ride;
scenery_variables scenery;
track_list_variables track_list;
};
sint16 page; // 0x48A
sint16 var_48C;
@ -361,6 +369,7 @@ enum {
WC_RECENT_NEWS = 31,
WC_SCENARIO_SELECT = 32,
WC_TRACK_DESIGN_LIST = 33,
WC_34 = 34,
WC_NEW_CAMPAIGN = 35,
WC_KEYBOARD_SHORTCUT_LIST = 36,
WC_CHANGE_KEYBOARD_SHORTCUT = 37,
@ -371,6 +380,8 @@ enum {
WC_EDITOR_INVENTION_LIST = 43,
WC_EDITOR_SCENARIO_OPTIONS = 45,
WC_EDTIOR_OBJECTIVE_OPTIONS = 46,
WC_47,
WC_48,
WC_CLEAR_SCENERY = 50,
WC_MANAGE_TRACK_DESIGN = 89,
WC_CHEATS = 110,
@ -433,6 +444,8 @@ void window_set_resize(rct_window *w, int minWidth, int minHeight, int maxWidth,
int tool_set(rct_window *w, int widgetIndex, int tool);
void tool_cancel();
void window_close_construction_windows();
// Open window functions
void window_main_open();
void window_resize_gui(int width, int height);
@ -447,6 +460,7 @@ void window_title_exit_open();
void window_title_logo_open();
void window_news_open();
void window_scenarioselect_open();
void window_track_list_open(ride_list_item item);
void window_clear_scenery_open();
void window_land_open();
void window_water_open();

View File

@ -32,11 +32,6 @@
#define _window_new_ride_current_tab RCT2_GLOBAL(RCT2_ADDRESS_WINDOW_RIDE_LIST_SELECTED_TAB, uint8)
typedef struct {
uint8 type;
uint8 entry_index;
} ride_list_item;
#pragma region Ride type view order
/**
@ -874,7 +869,7 @@ static ride_list_item window_new_ride_scroll_get_ride_list_item_at(rct_window *w
static int get_num_track_designs(ride_list_item item)
{
track_load_list(*((uint16*)&item));
track_load_list(item);
uint8 *trackDesignList = (uint8*)0x00F441EC;
int count = 0;
@ -964,12 +959,11 @@ static void window_new_ride_select(rct_window *w)
uint32 rideTypeFlags = RCT2_GLOBAL(RCT2_ADDRESS_RIDE_FLAGS + (item.type * 8), uint32);
if (rideTypeFlags & 0x10000000) {
track_load_list(*((sint16*)&item));
track_load_list(item);
uint8 *trackDesignList = (uint8*)0x00F441EC;
if (*trackDesignList != 0) {
// Show track design list
RCT2_CALLPROC_X(0x006CF1A2, *((sint16*)&item), 0, 0, 0, 0, 0, 0);
window_track_list_open(item);
return;
}
}

318
src/window_track_list.c Normal file
View File

@ -0,0 +1,318 @@
/*****************************************************************************
* 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 <windows.h>
#include <memory.h>
#include "addresses.h"
#include "editor.h"
#include "ride.h"
#include "string_ids.h"
#include "widget.h"
#include "window.h"
#include "window_error.h"
enum {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_TRACK_LIST,
WIDX_UNK,
WIDX_ROTATE,
WIDX_TOGGLE_SCENERY
};
static rct_widget window_track_list_widgets[] = {
{ WWT_FRAME, 0, 0, 599, 0, 399, 0xFFFFFFFF, STR_NONE },
{ WWT_CAPTION, 0, 1, 598, 1, 14, STR_SELECT_DESIGN, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
{ WWT_SCROLL, 0, 4, 221, 18, 395, 2, STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP },
{ WWT_FLATBTN, 0, 224, 595, 18, 236, 0xFFFFFFFF, STR_NONE },
{ WWT_FLATBTN, 0, 574, 597, 374, 397, 5169, STR_ROTATE_90_TIP },
{ WWT_FLATBTN, 0, 574, 597, 350, 373, 5171, STR_TOGGLE_SCENERY_TIP },
{ WIDGETS_END },
};
static void window_track_list_emptysub() { }
static void window_track_list_close();
static void window_track_list_mouseup();
static void window_track_list_scrollgetsize();
static void window_track_list_scrollmousedown();
static void window_track_list_scrollmouseover();
static void window_track_list_tooltip();
static void window_track_list_invalidate();
static void window_track_list_paint();
static void window_track_list_scrollpaint();
static void* window_track_list_events[] = {
(uint32*)window_track_list_close,
(uint32*)window_track_list_mouseup,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_scrollgetsize,
(uint32*)window_track_list_scrollmousedown,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_scrollmouseover,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_tooltip,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_emptysub,
(uint32*)window_track_list_invalidate,
(uint32*)window_track_list_paint,
(uint32*)window_track_list_scrollpaint
};
static ride_list_item _window_track_list_item;
/**
*
* rct2: 0x006CF1A2
*/
void window_track_list_open(ride_list_item item)
{
rct_window *w;
int x, y;
void *mem;
window_close_construction_windows();
_window_track_list_item = item;
if (RCT2_GLOBAL(0x00F635ED, uint8) & 1)
window_error_open(STR_WARNING, STR_TOO_MANY_TRACK_DESIGNS_OF_THIS_TYPE);
mem = malloc(1285292);
if (mem == NULL)
return;
RCT2_GLOBAL(0x00F44105, void*) = mem;
RCT2_CALLPROC_EBPSAFE(0x006D1DCE);
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
x = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16) / 2 - 300;
y = max(28, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) / 2 - 200);
} else {
x = 0;
y = 29;
}
w = window_create(0, 29, 600, 400, (uint32*)window_track_list_events, WC_TRACK_DESIGN_LIST, 0);
w->widgets = window_track_list_widgets;
w->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_ROTATE) | (1 << WIDX_TOGGLE_SCENERY);
window_init_scroll_widgets(w);
w->colours[0] = 26;
w->colours[1] = 26;
w->colours[2] = 26;
w->track_list.var_480 = 0xFFFF;
w->track_list.var_482 = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER ? 1 : 0;
w->track_list.var_484 = 0;
RCT2_GLOBAL(0x00F44152, uint8) = 0;
window_push_others_right(w);
RCT2_GLOBAL(0x00F440AE, uint8) = 2;
}
/**
*
* rct2: 0x006CFD76
*/
static void window_track_list_close()
{
free(RCT2_GLOBAL(0x00F44105, void*));
}
/**
*
* rct2: 0x006CFA31
*/
static void window_track_list_mouseup()
{
rct_window *w;
short widgetIndex;
window_widget_get_registers(w, widgetIndex);
switch (widgetIndex) {
case WIDX_CLOSE:
window_close(w);
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
window_close_by_id(WC_47, w->number);
window_close_by_id(WC_48, w->number);
trackmanager_load();
}
break;
case WIDX_ROTATE:
RCT2_GLOBAL(0x00F440AE, uint8)++;
RCT2_GLOBAL(0x00F440AE, uint8) %= 4;
window_invalidate(w);
break;
case WIDX_TOGGLE_SCENERY:
RCT2_GLOBAL(0x00F44152, uint8) ^= 1;
RCT2_CALLPROC_EBPSAFE(0x006D1DCE);
window_invalidate(w);
break;
}
}
/**
*
* rct2: 0x006CFAB0
*/
static void window_track_list_scrollgetsize()
{
rct_window *w;
int height;
uint8 *trackDesignItem, *trackDesignList = (uint8*)0x00F441EC;
window_get_register(w);
height = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER & 8 ? 0 : 10;
for (trackDesignItem = trackDesignList; *trackDesignItem != 0; trackDesignItem += 128)
height += 10;
#ifdef _MSC_VER
__asm mov ecx, 0
#else
__asm__ ( "mov ecx, 0 " );
#endif
#ifdef _MSC_VER
__asm mov edx, height
#else
__asm__ ( "mov edx, %[height] " : [height] "+m" (height) );
#endif
}
/**
*
* rct2: 0x006CFB39
*/
static void window_track_list_scrollmousedown()
{
rct_window *w;
short x, y;
window_scrollmouse_get_registers(w, x, y);
}
/**
*
* rct2: 0x006CFAD7
*/
static void window_track_list_scrollmouseover()
{
rct_window *w;
short x, y;
window_scrollmouse_get_registers(w, x, y);
}
/**
*
* rct2: 0x006CFD6C
*/
static void window_track_list_tooltip()
{
RCT2_GLOBAL(0x013CE952, uint16) = STR_LIST;
}
/**
*
* rct2: 0x006CF2D6
*/
static void window_track_list_invalidate()
{
rct_window *w;
rct_ride_type *entry;
rct_string_id stringId;
window_get_register(w);
entry = GET_RIDE_ENTRY(_window_track_list_item.entry_index);
stringId = entry->name;
if (!(entry->var_008 & 0x1000))
stringId = _window_track_list_item.type + 2;
RCT2_GLOBAL(0x013CE952, uint16) = stringId;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) {
window_track_list_widgets[WIDX_TITLE].image = STR_TRACK_DESIGNS;
window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_RENAME_OR_DELETE_IT;
} else {
window_track_list_widgets[WIDX_TITLE].image = STR_SELECT_DESIGN;
window_track_list_widgets[WIDX_TRACK_LIST].tooltip = STR_CLICK_ON_DESIGN_TO_BUILD_IT_TIP;
}
if ((RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TRACK_MANAGER) || w->track_list.var_482 != 0) {
w->pressed_widgets |= 1 << WIDX_UNK;
w->disabled_widgets &= ~(1 << WIDX_UNK);
window_track_list_widgets[WIDX_ROTATE].type = WWT_FLATBTN;
window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_FLATBTN;
if (RCT2_GLOBAL(0x00F44152, uint8) == 0)
w->pressed_widgets |= (1 << WIDX_TOGGLE_SCENERY);
else
w->pressed_widgets &= ~(1 << WIDX_TOGGLE_SCENERY);
} else {
w->pressed_widgets &= ~(1 << WIDX_UNK);
w->disabled_widgets |= (1 << WIDX_UNK);
window_track_list_widgets[WIDX_ROTATE].type = WWT_EMPTY;
window_track_list_widgets[WIDX_TOGGLE_SCENERY].type = WWT_EMPTY;
}
}
/**
*
* rct2: 0x006CF387
*/
static void window_track_list_paint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
window_paint_get_registers(w, dpi);
window_draw_widgets(w, dpi);
}
/**
*
* rct2: 0x006CF8CD
*/
static void window_track_list_scrollpaint()
{
rct_window *w;
rct_drawpixelinfo *dpi;
int colour;
window_paint_get_registers(w, dpi);
colour = RCT2_GLOBAL(0x00141FC48 + (w->colours[0] * 8), uint8);
colour = (colour << 24) | (colour << 16) | (colour << 8) | colour;
gfx_clear(dpi, colour);
}