2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2014-04-03 20:49:00 +02:00
|
|
|
/*****************************************************************************
|
2016-05-04 19:24:41 +02:00
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
|
|
|
*
|
|
|
|
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
|
|
|
* For more information, visit https://github.com/OpenRCT2/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.
|
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
|
|
|
*****************************************************************************/
|
|
|
|
#pragma endregion
|
2014-04-03 20:49:00 +02:00
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <openrct2/audio/audio.h>
|
2017-09-10 11:02:16 +02:00
|
|
|
#include <openrct2/config/Config.h>
|
2018-01-06 18:32:25 +01:00
|
|
|
#include <openrct2/localisation/Date.h>
|
|
|
|
#include <openrct2/localisation/Localisation.h>
|
2018-04-27 00:03:02 +02:00
|
|
|
#include <openrct2/localisation/LocalisationService.h>
|
2018-01-19 14:05:34 +01:00
|
|
|
#include <openrct2/scenario/ScenarioRepository.h>
|
|
|
|
#include <openrct2/scenario/ScenarioSources.h>
|
2017-09-10 11:02:16 +02:00
|
|
|
#include <openrct2/sprites.h>
|
2017-12-13 13:02:24 +01:00
|
|
|
#include <openrct2/util/Util.h>
|
2018-01-19 14:05:34 +01:00
|
|
|
#include <openrct2-ui/interface/Widget.h>
|
|
|
|
#include <openrct2-ui/windows/Window.h>
|
2018-03-19 23:28:40 +01:00
|
|
|
#include <openrct2/drawing/Drawing.h>
|
|
|
|
#include <openrct2/scenario/Scenario.h>
|
2018-06-02 12:31:14 +02:00
|
|
|
#include "../interface/Theme.h"
|
2014-04-03 20:49:00 +02:00
|
|
|
|
2015-12-31 19:26:25 +01:00
|
|
|
#define INITIAL_NUM_UNLOCKED_SCENARIOS 5
|
|
|
|
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format off
|
2018-01-19 14:05:34 +01:00
|
|
|
enum class LIST_ITEM_TYPE : uint8
|
|
|
|
{
|
|
|
|
HEADING,
|
|
|
|
SCENARIO,
|
2015-12-31 19:26:25 +01:00
|
|
|
};
|
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
struct sc_list_item
|
|
|
|
{
|
|
|
|
LIST_ITEM_TYPE type;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_string_id string_id;
|
|
|
|
} heading;
|
2018-01-19 14:05:34 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
const scenario_index_entry * scenario;
|
2017-06-06 23:24:18 +02:00
|
|
|
bool is_locked;
|
|
|
|
} scenario;
|
|
|
|
};
|
2018-01-19 14:05:34 +01:00
|
|
|
};
|
2015-12-31 19:26:25 +01:00
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
static std::vector<sc_list_item> _listItems;
|
2015-12-31 19:26:25 +01:00
|
|
|
|
2014-04-09 19:38:04 +02:00
|
|
|
enum {
|
2017-06-06 23:24:18 +02:00
|
|
|
WIDX_BACKGROUND,
|
|
|
|
WIDX_TITLEBAR,
|
|
|
|
WIDX_CLOSE,
|
|
|
|
WIDX_TABCONTENT,
|
|
|
|
WIDX_TAB1,
|
|
|
|
WIDX_TAB2,
|
|
|
|
WIDX_TAB3,
|
|
|
|
WIDX_TAB4,
|
|
|
|
WIDX_TAB5,
|
|
|
|
WIDX_TAB6,
|
|
|
|
WIDX_TAB7,
|
|
|
|
WIDX_TAB8,
|
|
|
|
WIDX_SCENARIOLIST
|
2014-04-09 19:38:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static rct_widget window_scenarioselect_widgets[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_FRAME, 0, 0, 733, 0, 333, 0xFFFFFFFF, STR_NONE }, // panel / background
|
|
|
|
{ WWT_CAPTION, 0, 1, 732, 1, 14, STR_SELECT_SCENARIO, STR_WINDOW_TITLE_TIP }, // title bar
|
|
|
|
{ WWT_CLOSEBOX, 0, 721, 731, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, // close x button
|
|
|
|
{ WWT_IMGBTN, 1, 0, 733, 50, 333, 0xFFFFFFFF, STR_NONE }, // tab content panel
|
2017-07-20 20:56:29 +02:00
|
|
|
{ WWT_TAB, 1, 3, 93, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 1
|
|
|
|
{ WWT_TAB, 1, 94, 184, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 2
|
|
|
|
{ WWT_TAB, 1, 185, 275, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 3
|
|
|
|
{ WWT_TAB, 1, 276, 366, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 4
|
|
|
|
{ WWT_TAB, 1, 367, 457, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 5
|
|
|
|
{ WWT_TAB, 1, 458, 593, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 6
|
|
|
|
{ WWT_TAB, 1, 594, 684, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 7
|
|
|
|
{ WWT_TAB, 1, 685, 775, 17, 50, IMAGE_TYPE_REMAP | SPR_TAB_LARGE, STR_NONE }, // tab 8
|
2017-06-06 23:24:18 +02:00
|
|
|
{ WWT_SCROLL, 1, 3, 555, 54, 329, SCROLL_VERTICAL, STR_NONE }, // level list
|
|
|
|
{ WIDGETS_END },
|
2014-04-03 20:49:00 +02:00
|
|
|
};
|
|
|
|
|
2018-01-11 14:50:31 +01:00
|
|
|
static constexpr const rct_string_id ScenarioOriginStringIds[] = {
|
2017-06-06 23:24:18 +02:00
|
|
|
STR_SCENARIO_CATEGORY_RCT1,
|
|
|
|
STR_SCENARIO_CATEGORY_RCT1_AA,
|
|
|
|
STR_SCENARIO_CATEGORY_RCT1_LL,
|
|
|
|
STR_SCENARIO_CATEGORY_RCT2,
|
|
|
|
STR_SCENARIO_CATEGORY_RCT2_WW,
|
|
|
|
STR_SCENARIO_CATEGORY_RCT2_TT,
|
|
|
|
STR_SCENARIO_CATEGORY_REAL_PARKS,
|
|
|
|
STR_SCENARIO_CATEGORY_OTHER_PARKS,
|
2016-07-14 14:07:49 +02:00
|
|
|
};
|
|
|
|
|
2016-01-01 23:43:57 +01:00
|
|
|
static void window_scenarioselect_init_tabs(rct_window *w);
|
2014-04-09 19:38:04 +02:00
|
|
|
|
2015-12-31 19:26:25 +01:00
|
|
|
static void window_scenarioselect_close(rct_window *w);
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_scenarioselect_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_scenarioselect_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
|
|
|
|
static void window_scenarioselect_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
|
|
|
static void window_scenarioselect_scrollmouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_scenarioselect_invalidate(rct_window *w);
|
|
|
|
static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
2015-07-10 02:39:16 +02:00
|
|
|
|
|
|
|
static rct_window_event_list window_scenarioselect_events = {
|
2017-06-06 23:24:18 +02:00
|
|
|
window_scenarioselect_close,
|
|
|
|
window_scenarioselect_mouseup,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_scenarioselect_mousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_scenarioselect_scrollgetsize,
|
|
|
|
window_scenarioselect_scrollmousedown,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_scenarioselect_scrollmouseover,
|
2017-08-15 10:07:44 +02:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2017-06-06 23:24:18 +02:00
|
|
|
window_scenarioselect_invalidate,
|
|
|
|
window_scenarioselect_paint,
|
|
|
|
window_scenarioselect_scrollpaint
|
2014-04-09 19:38:04 +02:00
|
|
|
};
|
2018-05-16 20:41:29 +02:00
|
|
|
// clang-format on
|
2014-04-09 19:38:04 +02:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void draw_category_heading(rct_window *w, rct_drawpixelinfo *dpi, sint32 left, sint32 right, sint32 y, rct_string_id stringId);
|
2015-12-31 19:26:25 +01:00
|
|
|
static void initialise_list_items(rct_window *w);
|
2016-10-12 13:36:30 +02:00
|
|
|
static bool is_scenario_visible(rct_window *w, const scenario_index_entry *scenario);
|
2015-12-31 19:26:25 +01:00
|
|
|
static bool is_locking_enabled(rct_window *w);
|
|
|
|
|
2016-02-10 19:44:00 +01:00
|
|
|
static scenarioselect_callback _callback;
|
2016-02-29 22:28:01 +01:00
|
|
|
static bool _showLockedInformation = false;
|
2017-12-31 12:42:40 +01:00
|
|
|
static bool _titleEditor = false;
|
2016-02-10 19:44:00 +01:00
|
|
|
|
2014-04-03 20:49:00 +02:00
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-03 20:49:00 +02:00
|
|
|
* rct2: 0x006781B5
|
|
|
|
*/
|
2017-12-31 12:42:40 +01:00
|
|
|
rct_window * window_scenarioselect_open(scenarioselect_callback callback, bool titleEditor)
|
2014-04-03 20:49:00 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct_window* window;
|
|
|
|
sint32 windowWidth;
|
|
|
|
sint32 windowHeight = 334;
|
|
|
|
|
|
|
|
_callback = callback;
|
|
|
|
|
2017-12-31 12:42:40 +01:00
|
|
|
if (_titleEditor != titleEditor)
|
|
|
|
{
|
|
|
|
_titleEditor = titleEditor;
|
|
|
|
window_close_by_class(WC_SCENARIO_SELECT);
|
|
|
|
}
|
|
|
|
|
2017-09-12 00:04:03 +02:00
|
|
|
window = window_bring_to_front_by_class(WC_SCENARIO_SELECT);
|
|
|
|
if (window != nullptr)
|
|
|
|
return window;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Load scenario list
|
|
|
|
scenario_repository_scan();
|
|
|
|
|
|
|
|
// Shrink the window if we're showing scenarios by difficulty level.
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_DIFFICULTY && !_titleEditor)
|
2017-06-06 23:24:18 +02:00
|
|
|
windowWidth = 610;
|
2017-12-31 12:42:40 +01:00
|
|
|
else
|
2017-06-06 23:24:18 +02:00
|
|
|
windowWidth = 733;
|
|
|
|
|
|
|
|
window = window_create_centred(
|
|
|
|
windowWidth,
|
|
|
|
windowHeight,
|
|
|
|
&window_scenarioselect_events,
|
|
|
|
WC_SCENARIO_SELECT,
|
2017-12-31 12:42:40 +01:00
|
|
|
WF_10 | (titleEditor ? WF_STICK_TO_FRONT : 0)
|
2017-06-06 23:24:18 +02:00
|
|
|
);
|
|
|
|
window->widgets = window_scenarioselect_widgets;
|
|
|
|
window->enabled_widgets = (1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2)
|
|
|
|
| (1 << WIDX_TAB3) | (1 << WIDX_TAB4) | (1 << WIDX_TAB5)
|
|
|
|
| (1 << WIDX_TAB6) | (1 << WIDX_TAB7) | (1 << WIDX_TAB8);
|
|
|
|
|
|
|
|
window_scenarioselect_init_tabs(window);
|
|
|
|
initialise_list_items(window);
|
|
|
|
|
|
|
|
window_init_scroll_widgets(window);
|
|
|
|
window->viewport_focus_coordinates.var_480 = -1;
|
2017-08-15 10:07:44 +02:00
|
|
|
window->highlighted_scenario = nullptr;
|
2017-09-12 00:04:03 +02:00
|
|
|
|
|
|
|
return window;
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-10-20 20:16:30 +02:00
|
|
|
*
|
2014-04-09 19:38:04 +02:00
|
|
|
* rct2: 0x00677C8A
|
|
|
|
*/
|
2016-01-01 23:43:57 +01:00
|
|
|
static void window_scenarioselect_init_tabs(rct_window *w)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 showPages = 0;
|
|
|
|
size_t numScenarios = scenario_repository_get_count();
|
2017-12-31 12:42:40 +01:00
|
|
|
for (size_t i = 0; i < numScenarios; i++)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
const scenario_index_entry *scenario = scenario_repository_get_by_index(i);
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor)
|
|
|
|
{
|
|
|
|
if (_titleEditor && scenario->source_game == SCENARIO_SOURCE_OTHER)
|
|
|
|
continue;
|
2017-06-06 23:24:18 +02:00
|
|
|
showPages |= 1 << scenario->source_game;
|
2017-12-31 12:42:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 category = scenario->category;
|
2017-12-31 12:42:40 +01:00
|
|
|
if (category > SCENARIO_CATEGORY_OTHER)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
category = SCENARIO_CATEGORY_OTHER;
|
|
|
|
}
|
|
|
|
showPages |= 1 << category;
|
|
|
|
}
|
2017-12-31 12:42:40 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
sint32 firstPage = bitscanforward(showPages);
|
|
|
|
if (firstPage != -1) {
|
|
|
|
w->selected_tab = firstPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
sint32 x = 3;
|
|
|
|
for (sint32 i = 0; i < 8; i++) {
|
|
|
|
rct_widget* widget = &w->widgets[i + WIDX_TAB1];
|
|
|
|
if (!(showPages & (1 << i))) {
|
|
|
|
widget->type = WWT_EMPTY;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
widget->type = WWT_TAB;
|
|
|
|
widget->left = x;
|
|
|
|
widget->right = x + 90;
|
|
|
|
x += 91;
|
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2015-12-31 19:26:25 +01:00
|
|
|
static void window_scenarioselect_close(rct_window *w)
|
|
|
|
{
|
2018-01-19 14:05:34 +01:00
|
|
|
_listItems.clear();
|
|
|
|
_listItems.shrink_to_fit();
|
2015-12-31 19:26:25 +01:00
|
|
|
}
|
|
|
|
|
2017-05-01 15:41:45 +02:00
|
|
|
static void window_scenarioselect_mouseup(rct_window *w, rct_widgetindex widgetIndex)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (widgetIndex == WIDX_CLOSE) {
|
|
|
|
window_close(w);
|
|
|
|
}
|
2015-12-31 19:26:25 +01:00
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
|
2017-07-03 23:09:46 +02:00
|
|
|
static void window_scenarioselect_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (widgetIndex >= WIDX_TAB1 && widgetIndex <= WIDX_TAB8) {
|
|
|
|
w->selected_tab = widgetIndex - 4;
|
2017-08-15 10:07:44 +02:00
|
|
|
w->highlighted_scenario = nullptr;
|
2017-06-06 23:24:18 +02:00
|
|
|
initialise_list_items(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
window_event_resize_call(w);
|
|
|
|
window_event_invalidate_call(w);
|
|
|
|
window_init_scroll_widgets(w);
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 13:58:46 +02:00
|
|
|
static sint32 get_scenario_list_item_size()
|
|
|
|
{
|
2018-04-27 00:03:02 +02:00
|
|
|
if (!LocalisationService_UseTrueTypeFont())
|
2018-05-01 13:58:46 +02:00
|
|
|
return 24;
|
|
|
|
|
|
|
|
// Scenario title
|
|
|
|
sint32 lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
|
|
|
|
|
|
|
|
// 'Completed by' line
|
|
|
|
lineHeight += font_get_line_height(FONT_SPRITE_BASE_SMALL);
|
|
|
|
|
|
|
|
return lineHeight;
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2018-05-01 13:58:46 +02:00
|
|
|
const sint32 scenarioItemHeight = get_scenario_list_item_size();
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 y = 0;
|
2018-01-19 14:05:34 +01:00
|
|
|
for (const auto &listItem : _listItems)
|
|
|
|
{
|
|
|
|
switch (listItem.type)
|
|
|
|
{
|
|
|
|
case LIST_ITEM_TYPE::HEADING:
|
2017-06-06 23:24:18 +02:00
|
|
|
y += 18;
|
|
|
|
break;
|
2018-01-19 14:05:34 +01:00
|
|
|
case LIST_ITEM_TYPE::SCENARIO:
|
2018-05-01 13:58:46 +02:00
|
|
|
y += scenarioItemHeight;
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*height = y;
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x6780FE
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2018-05-01 13:58:46 +02:00
|
|
|
const sint32 scenarioItemHeight = get_scenario_list_item_size();
|
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
for (const auto &listItem : _listItems)
|
|
|
|
{
|
|
|
|
switch (listItem.type)
|
|
|
|
{
|
|
|
|
case LIST_ITEM_TYPE::HEADING:
|
2017-06-06 23:24:18 +02:00
|
|
|
y -= 18;
|
|
|
|
break;
|
2018-01-19 14:05:34 +01:00
|
|
|
case LIST_ITEM_TYPE::SCENARIO:
|
2018-05-01 13:58:46 +02:00
|
|
|
y -= scenarioItemHeight;
|
2018-01-19 14:05:34 +01:00
|
|
|
if (y < 0 && !listItem.scenario.is_locked) {
|
2017-06-06 23:24:18 +02:00
|
|
|
audio_play_sound(SOUND_CLICK_1, 0, w->x + (w->width / 2));
|
2017-10-15 21:38:46 +02:00
|
|
|
gFirstTimeSaving = true;
|
2018-01-19 14:05:34 +01:00
|
|
|
_callback(listItem.scenario.scenario->path);
|
2017-12-31 12:42:40 +01:00
|
|
|
if (_titleEditor)
|
|
|
|
{
|
|
|
|
window_close(w);
|
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (y < 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2015-12-11 16:38:37 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x678162
|
|
|
|
*/
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollmouseover(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2018-05-01 13:58:46 +02:00
|
|
|
const sint32 scenarioItemHeight = get_scenario_list_item_size();
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
bool originalShowLockedInformation = _showLockedInformation;
|
|
|
|
_showLockedInformation = false;
|
2017-08-15 10:07:44 +02:00
|
|
|
const scenario_index_entry *selected = nullptr;
|
2018-01-19 14:05:34 +01:00
|
|
|
for (const auto &listItem : _listItems)
|
|
|
|
{
|
|
|
|
switch (listItem.type)
|
|
|
|
{
|
|
|
|
case LIST_ITEM_TYPE::HEADING:
|
2017-06-06 23:24:18 +02:00
|
|
|
y -= 18;
|
|
|
|
break;
|
2018-01-19 14:05:34 +01:00
|
|
|
case LIST_ITEM_TYPE::SCENARIO:
|
2018-05-01 13:58:46 +02:00
|
|
|
y -= scenarioItemHeight;
|
2017-06-06 23:24:18 +02:00
|
|
|
if (y < 0) {
|
2018-01-19 14:05:34 +01:00
|
|
|
if (listItem.scenario.is_locked) {
|
2017-06-06 23:24:18 +02:00
|
|
|
_showLockedInformation = true;
|
|
|
|
} else {
|
2018-01-19 14:05:34 +01:00
|
|
|
selected = listItem.scenario.scenario;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (y < 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (w->highlighted_scenario != selected) {
|
|
|
|
w->highlighted_scenario = selected;
|
|
|
|
window_invalidate(w);
|
|
|
|
} else if (_showLockedInformation != originalShowLockedInformation) {
|
|
|
|
window_invalidate(w);
|
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_scenarioselect_invalidate(rct_window *w)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
w->pressed_widgets &= ~( (1 << WIDX_CLOSE) | (1 << WIDX_TAB1) | (1 << WIDX_TAB2)
|
|
|
|
| (1 << WIDX_TAB3) | (1 << WIDX_TAB4) | (1 << WIDX_TAB5)
|
|
|
|
| (1 << WIDX_TAB6) | (1 << WIDX_TAB7) | (1 << WIDX_TAB8) );
|
|
|
|
|
|
|
|
w->pressed_widgets |= 1LL << (w->selected_tab + WIDX_TAB1);
|
|
|
|
|
|
|
|
sint32 windowWidth = w->width;
|
|
|
|
window_scenarioselect_widgets[WIDX_BACKGROUND].right = windowWidth - 1;
|
|
|
|
window_scenarioselect_widgets[WIDX_TITLEBAR].right = windowWidth - 2;
|
|
|
|
window_scenarioselect_widgets[WIDX_CLOSE].left = windowWidth - 13;
|
|
|
|
window_scenarioselect_widgets[WIDX_CLOSE].right = windowWidth - 3;
|
|
|
|
window_scenarioselect_widgets[WIDX_TABCONTENT].right = windowWidth - 1;
|
|
|
|
window_scenarioselect_widgets[WIDX_SCENARIOLIST].right = windowWidth - 179;
|
|
|
|
|
|
|
|
sint32 windowHeight = w->height;
|
|
|
|
window_scenarioselect_widgets[WIDX_BACKGROUND].bottom = windowHeight - 1;
|
|
|
|
window_scenarioselect_widgets[WIDX_TABCONTENT].bottom = windowHeight - 1;
|
|
|
|
|
|
|
|
const sint32 bottomMargin = gConfigGeneral.debugging_tools ? 17 : 5;
|
|
|
|
window_scenarioselect_widgets[WIDX_SCENARIOLIST].bottom = windowHeight - bottomMargin;
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2015-07-10 02:39:16 +02:00
|
|
|
static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 format;
|
|
|
|
const scenario_index_entry *scenario;
|
|
|
|
|
|
|
|
window_draw_widgets(w, dpi);
|
|
|
|
|
|
|
|
format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_SMALL_WINDOW_COLOUR_2_STRINGID : STR_WINDOW_COLOUR_2_STRINGID;
|
|
|
|
|
|
|
|
// Text for each tab
|
|
|
|
for (sint32 i = 0; i < 8; i++) {
|
|
|
|
rct_widget *widget = &window_scenarioselect_widgets[WIDX_TAB1 + i];
|
|
|
|
if (widget->type == WWT_EMPTY)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sint32 x = (widget->left + widget->right) / 2 + w->x;
|
|
|
|
sint32 y = (widget->top + widget->bottom) / 2 + w->y - 3;
|
|
|
|
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor) {
|
2017-06-06 23:24:18 +02:00
|
|
|
set_format_arg(0, rct_string_id, ScenarioOriginStringIds[i]);
|
|
|
|
} else { // old-style
|
|
|
|
set_format_arg(0, rct_string_id, ScenarioCategoryStringIds[i]);
|
|
|
|
}
|
|
|
|
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, 87, format, COLOUR_AQUAMARINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return if no scenario highlighted
|
|
|
|
scenario = w->highlighted_scenario;
|
2017-08-15 10:07:44 +02:00
|
|
|
if (scenario == nullptr) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (_showLockedInformation) {
|
|
|
|
// Show locked information
|
|
|
|
sint32 x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4;
|
|
|
|
sint32 y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5;
|
2017-08-15 10:07:44 +02:00
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_SCENARIO_LOCKED, nullptr, COLOUR_BLACK, x + 85, y, 170);
|
2017-06-06 23:24:18 +02:00
|
|
|
y += 15;
|
2017-08-15 10:07:44 +02:00
|
|
|
y += gfx_draw_string_left_wrapped(dpi, nullptr, x, y, 170, STR_SCENARIO_LOCKED_DESC, COLOUR_BLACK) + 5;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scenario path
|
|
|
|
if (gConfigGeneral.debugging_tools) {
|
|
|
|
utf8 path[MAX_PATH];
|
|
|
|
|
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
|
|
|
shorten_path(path, sizeof(path), scenario->path, w->width - 6);
|
|
|
|
|
|
|
|
const utf8 *pathPtr = path;
|
|
|
|
gfx_draw_string_left(dpi, STR_STRING, (void*)&pathPtr, w->colours[1], w->x + 3, w->y + w->height - 3 - 11);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scenario name
|
|
|
|
sint32 x = w->x + window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4;
|
|
|
|
sint32 y = w->y + window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5;
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, scenario->name);
|
|
|
|
gfx_draw_string_centred_clipped(dpi, STR_WINDOW_COLOUR_2_STRINGID, gCommonFormatArgs, COLOUR_BLACK, x + 85, y, 170);
|
|
|
|
y += 15;
|
|
|
|
|
|
|
|
// Scenario details
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, scenario->details);
|
|
|
|
y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_BLACK_STRING, COLOUR_BLACK) + 5;
|
|
|
|
|
|
|
|
// Scenario objective
|
|
|
|
set_format_arg(0, rct_string_id, ObjectiveNames[scenario->objective_type]);
|
|
|
|
set_format_arg(2, sint16, scenario->objective_arg_3);
|
|
|
|
set_format_arg(4, sint16, date_get_total_months(MONTH_OCTOBER, scenario->objective_arg_1));
|
|
|
|
set_format_arg(6, sint32, scenario->objective_arg_2);
|
|
|
|
y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_OBJECTIVE, COLOUR_BLACK) + 5;
|
|
|
|
|
|
|
|
// Scenario score
|
2017-08-15 10:07:44 +02:00
|
|
|
if (scenario->highscore != nullptr) {
|
2017-06-06 23:24:18 +02:00
|
|
|
// TODO: Should probably be translatable
|
|
|
|
const utf8 *completedByName = "???";
|
|
|
|
if (!str_is_null_or_empty(scenario->highscore->name)) {
|
|
|
|
completedByName = scenario->highscore->name;
|
|
|
|
}
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, const char *, completedByName);
|
|
|
|
set_format_arg(2 + sizeof(const char *), money32, scenario->highscore->company_value);
|
|
|
|
y += gfx_draw_string_left_wrapped(dpi, gCommonFormatArgs, x, y, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, COLOUR_BLACK);
|
|
|
|
}
|
2014-04-09 19:38:04 +02:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
|
2014-04-09 19:38:04 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 colour;
|
|
|
|
|
|
|
|
uint8 paletteIndex = ColourMapA[w->colours[1]].mid_light;
|
|
|
|
gfx_clear(dpi, paletteIndex);
|
|
|
|
|
|
|
|
rct_string_id highlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_WINDOW_COLOUR_2_STRINGID;
|
|
|
|
rct_string_id unhighlighted_format = (theme_get_flags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_WHITE_STRING : STR_BLACK_STRING;
|
|
|
|
|
2017-12-31 12:42:40 +01:00
|
|
|
bool wide = gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
rct_widget *listWidget = &w->widgets[WIDX_SCENARIOLIST];
|
|
|
|
sint32 listWidth = listWidget->right - listWidget->left - 12;
|
|
|
|
|
2018-05-01 13:58:46 +02:00
|
|
|
const sint32 scenarioItemHeight = get_scenario_list_item_size();
|
|
|
|
|
|
|
|
// Scenario title
|
|
|
|
sint32 scenarioTitleHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
|
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 y = 0;
|
2018-01-19 14:05:34 +01:00
|
|
|
for (const auto &listItem : _listItems)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
if (y > dpi->y + dpi->height) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
switch (listItem.type)
|
|
|
|
{
|
|
|
|
case LIST_ITEM_TYPE::HEADING:
|
2017-08-02 00:20:32 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
const sint32 horizontalRuleMargin = 4;
|
2018-01-19 14:05:34 +01:00
|
|
|
draw_category_heading(w, dpi, horizontalRuleMargin, listWidth - horizontalRuleMargin, y + 2, listItem.heading.string_id);
|
2017-06-06 23:24:18 +02:00
|
|
|
y += 18;
|
|
|
|
break;
|
2017-08-02 00:20:32 +02:00
|
|
|
}
|
2018-01-19 14:05:34 +01:00
|
|
|
case LIST_ITEM_TYPE::SCENARIO:
|
2017-08-02 00:20:32 +02:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Draw hover highlight
|
2018-01-19 14:05:34 +01:00
|
|
|
const scenario_index_entry *scenario = listItem.scenario.scenario;
|
2017-06-06 23:24:18 +02:00
|
|
|
bool isHighlighted = w->highlighted_scenario == scenario;
|
|
|
|
if (isHighlighted) {
|
2018-05-01 13:58:46 +02:00
|
|
|
gfx_filter_rect(dpi, 0, y, w->width, y + scenarioItemHeight - 1, PALETTE_DARKEN_1);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2017-08-15 10:07:44 +02:00
|
|
|
bool isCompleted = scenario->highscore != nullptr;
|
2018-01-19 14:05:34 +01:00
|
|
|
bool isDisabled = listItem.scenario.is_locked;
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Draw scenario name
|
|
|
|
char buffer[64];
|
|
|
|
safe_strcpy(buffer, scenario->name, sizeof(buffer));
|
|
|
|
rct_string_id format = isDisabled ? STR_STRINGID : (isHighlighted ? highlighted_format : unhighlighted_format);
|
|
|
|
set_format_arg(0, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(2, char *, buffer);
|
|
|
|
colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK;
|
|
|
|
if (isDisabled) {
|
|
|
|
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
|
|
|
}
|
|
|
|
gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 1, colour, gCommonFormatArgs);
|
|
|
|
|
|
|
|
// Check if scenario is completed
|
2018-05-01 13:58:46 +02:00
|
|
|
if (isCompleted)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Draw completion tick
|
|
|
|
gfx_draw_sprite(dpi, SPR_MENU_CHECKMARK, wide ? 500 : 395, y + 1, 0);
|
|
|
|
|
|
|
|
// Draw completion score
|
|
|
|
const utf8 *completedByName = "???";
|
2018-05-01 13:58:46 +02:00
|
|
|
if (!str_is_null_or_empty(scenario->highscore->name))
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
completedByName = scenario->highscore->name;
|
|
|
|
}
|
|
|
|
safe_strcpy(buffer, completedByName, 64);
|
|
|
|
set_format_arg(0, rct_string_id, STR_COMPLETED_BY);
|
|
|
|
set_format_arg(2, rct_string_id, STR_STRING);
|
|
|
|
set_format_arg(4, char *, buffer);
|
2018-05-01 13:58:46 +02:00
|
|
|
gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + scenarioTitleHeight + 1, COLOUR_BLACK, gCommonFormatArgs);
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 13:58:46 +02:00
|
|
|
y += scenarioItemHeight;
|
2017-06-06 23:24:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-08-02 00:20:32 +02:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
2015-12-31 19:26:25 +01:00
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
static void draw_category_heading(rct_window *w, rct_drawpixelinfo *dpi, sint32 left, sint32 right, sint32 y, rct_string_id stringId)
|
2015-12-31 19:26:25 +01:00
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
uint8 baseColour = w->colours[1];
|
|
|
|
uint8 lightColour = ColourMapA[baseColour].lighter;
|
|
|
|
uint8 darkColour = ColourMapA[baseColour].mid_dark;
|
|
|
|
|
|
|
|
// Draw string
|
|
|
|
sint32 centreX = (left + right) / 2;
|
2017-08-15 10:07:44 +02:00
|
|
|
gfx_draw_string_centred(dpi, stringId, centreX, y, baseColour, nullptr);
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Get string dimensions
|
|
|
|
utf8 *buffer = gCommonStringFormatBuffer;
|
2017-08-15 10:07:44 +02:00
|
|
|
format_string(buffer, 256, stringId, nullptr);
|
2017-06-06 23:24:18 +02:00
|
|
|
sint32 categoryStringHalfWidth = (gfx_get_string_width(buffer) / 2) + 4;
|
|
|
|
sint32 strLeft = centreX - categoryStringHalfWidth;
|
|
|
|
sint32 strRight = centreX + categoryStringHalfWidth;
|
|
|
|
|
|
|
|
// Draw light horizontal rule
|
|
|
|
sint32 lineY = y + 4;
|
|
|
|
gfx_draw_line(dpi, left, lineY, strLeft, lineY, lightColour);
|
|
|
|
gfx_draw_line(dpi, strRight, lineY, right, lineY, lightColour);
|
|
|
|
|
|
|
|
// Draw dark horizontal rule
|
|
|
|
lineY++;
|
|
|
|
gfx_draw_line(dpi, left, lineY, strLeft, lineY, darkColour);
|
|
|
|
gfx_draw_line(dpi, strRight, lineY, right, lineY, darkColour);
|
2015-12-31 22:13:49 +01:00
|
|
|
}
|
2015-12-31 19:26:25 +01:00
|
|
|
|
|
|
|
static void initialise_list_items(rct_window *w)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
size_t numScenarios = scenario_repository_get_count();
|
2018-01-19 14:05:34 +01:00
|
|
|
_listItems.clear();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Mega park unlock
|
|
|
|
const uint32 rct1RequiredCompletedScenarios = (1 << SC_MEGA_PARK) - 1;
|
|
|
|
uint32 rct1CompletedScenarios = 0;
|
|
|
|
size_t megaParkListItemIndex = SIZE_MAX;
|
|
|
|
|
|
|
|
sint32 numUnlocks = INITIAL_NUM_UNLOCKED_SCENARIOS;
|
|
|
|
uint8 currentHeading = UINT8_MAX;
|
|
|
|
for (size_t i = 0; i < numScenarios; i++) {
|
|
|
|
const scenario_index_entry *scenario = scenario_repository_get_by_index(i);
|
2017-12-31 12:42:40 +01:00
|
|
|
|
|
|
|
if (!is_scenario_visible(w, scenario))
|
|
|
|
continue;
|
|
|
|
if (_titleEditor && scenario->source_game == SCENARIO_SOURCE_OTHER)
|
2017-06-06 23:24:18 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Category heading
|
|
|
|
rct_string_id headingStringId = STR_NONE;
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (w->selected_tab != SCENARIO_SOURCE_REAL && currentHeading != scenario->category) {
|
|
|
|
currentHeading = scenario->category;
|
|
|
|
headingStringId = ScenarioCategoryStringIds[currentHeading];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (w->selected_tab <= SCENARIO_CATEGORY_EXPERT) {
|
|
|
|
if (currentHeading != scenario->source_game) {
|
|
|
|
currentHeading = scenario->source_game;
|
|
|
|
headingStringId = ScenarioOriginStringIds[currentHeading];
|
|
|
|
}
|
|
|
|
} else if (w->selected_tab == SCENARIO_CATEGORY_OTHER) {
|
|
|
|
sint32 category = scenario->category;
|
|
|
|
if (category <= SCENARIO_CATEGORY_REAL) {
|
|
|
|
category = SCENARIO_CATEGORY_OTHER;
|
|
|
|
}
|
|
|
|
if (currentHeading != category) {
|
|
|
|
currentHeading = category;
|
|
|
|
headingStringId = ScenarioCategoryStringIds[category];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-19 14:05:34 +01:00
|
|
|
if (headingStringId != STR_NONE)
|
|
|
|
{
|
|
|
|
sc_list_item headerItem;
|
|
|
|
headerItem.type = LIST_ITEM_TYPE::HEADING;
|
|
|
|
headerItem.heading.string_id = headingStringId;
|
|
|
|
_listItems.push_back(std::move(headerItem));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Scenario
|
2018-01-19 14:05:34 +01:00
|
|
|
sc_list_item scenarioItem;
|
|
|
|
scenarioItem.type = LIST_ITEM_TYPE::SCENARIO;
|
|
|
|
scenarioItem.scenario.scenario = scenario;
|
|
|
|
if (is_locking_enabled(w))
|
|
|
|
{
|
|
|
|
scenarioItem.scenario.is_locked = numUnlocks <= 0;
|
|
|
|
if (scenario->highscore == nullptr)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
numUnlocks--;
|
2018-01-19 14:05:34 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Mark RCT1 scenario as completed
|
2018-01-19 14:05:34 +01:00
|
|
|
if (scenario->sc_id < SC_MEGA_PARK)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
rct1CompletedScenarios |= 1 << scenario->sc_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If scenario is Mega Park, keep a reference to it
|
2018-01-19 14:05:34 +01:00
|
|
|
if (scenario->sc_id == SC_MEGA_PARK)
|
|
|
|
{
|
|
|
|
megaParkListItemIndex = _listItems.size() - 1;
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
2018-01-19 14:05:34 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
scenarioItem.scenario.is_locked = false;
|
|
|
|
}
|
|
|
|
_listItems.push_back(std::move(scenarioItem));
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mega park handling
|
2018-01-19 14:05:34 +01:00
|
|
|
if (megaParkListItemIndex != SIZE_MAX)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
bool megaParkLocked = (rct1CompletedScenarios & rct1RequiredCompletedScenarios) != rct1RequiredCompletedScenarios;
|
|
|
|
_listItems[megaParkListItemIndex].scenario.is_locked = megaParkLocked;
|
2018-01-19 14:05:34 +01:00
|
|
|
if (megaParkLocked && gConfigGeneral.scenario_hide_mega_park)
|
|
|
|
{
|
2017-06-06 23:24:18 +02:00
|
|
|
// Remove mega park
|
2018-01-19 14:05:34 +01:00
|
|
|
_listItems.pop_back();
|
2017-06-06 23:24:18 +02:00
|
|
|
|
|
|
|
// Remove empty headings
|
2018-03-10 14:58:49 +01:00
|
|
|
for (auto it = _listItems.begin(); it != _listItems.end(); it++)
|
2018-01-19 14:05:34 +01:00
|
|
|
{
|
2018-03-10 14:58:49 +01:00
|
|
|
const auto &listItem = *it;
|
2018-01-19 14:05:34 +01:00
|
|
|
if (listItem.type == LIST_ITEM_TYPE::HEADING)
|
|
|
|
{
|
2018-03-10 14:58:49 +01:00
|
|
|
if ((it + 1) == _listItems.end() ||
|
|
|
|
(it + 1)->type == LIST_ITEM_TYPE::HEADING)
|
2018-01-19 14:05:34 +01:00
|
|
|
{
|
2018-03-10 14:58:49 +01:00
|
|
|
it = _listItems.erase(it);
|
|
|
|
it--;
|
2018-01-19 14:05:34 +01:00
|
|
|
}
|
2017-06-06 23:24:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-31 19:26:25 +01:00
|
|
|
}
|
|
|
|
|
2016-10-12 13:36:30 +02:00
|
|
|
static bool is_scenario_visible(rct_window *w, const scenario_index_entry *scenario)
|
2015-12-31 19:26:25 +01:00
|
|
|
{
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor) {
|
2017-06-06 23:24:18 +02:00
|
|
|
if (scenario->source_game != w->selected_tab) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
sint32 category = scenario->category;
|
|
|
|
if (category > SCENARIO_CATEGORY_OTHER) {
|
|
|
|
category = SCENARIO_CATEGORY_OTHER;
|
|
|
|
}
|
|
|
|
if (category != w->selected_tab) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-31 19:26:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool is_locking_enabled(rct_window *w)
|
|
|
|
{
|
2017-12-31 12:42:40 +01:00
|
|
|
if (gConfigGeneral.scenario_select_mode != SCENARIO_SELECT_MODE_ORIGIN)
|
2017-06-06 23:24:18 +02:00
|
|
|
return false;
|
2017-12-31 12:42:40 +01:00
|
|
|
if (!gConfigGeneral.scenario_unlocking_enabled)
|
2017-06-06 23:24:18 +02:00
|
|
|
return false;
|
2017-12-31 12:42:40 +01:00
|
|
|
if (w->selected_tab >= 6)
|
2017-06-06 23:24:18 +02:00
|
|
|
return false;
|
2017-12-31 12:42:40 +01:00
|
|
|
if (_titleEditor)
|
|
|
|
return false;
|
2018-01-11 14:50:31 +01:00
|
|
|
|
2017-06-06 23:24:18 +02:00
|
|
|
return true;
|
2014-04-21 11:27:48 +02:00
|
|
|
}
|