2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2016-11-21 01:16:47 +01: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
|
|
|
|
|
2016-12-24 01:53:33 +01:00
|
|
|
#include "../core/Console.hpp"
|
2017-03-26 22:42:07 +02:00
|
|
|
#include "../Context.h"
|
2016-11-21 01:16:47 +01:00
|
|
|
#include "../network/network.h"
|
2016-12-16 00:16:02 +01:00
|
|
|
#include "../OpenRCT2.h"
|
2017-01-22 23:04:07 +01:00
|
|
|
#include "../scenario/ScenarioRepository.h"
|
2016-11-21 01:16:47 +01:00
|
|
|
#include "TitleScreen.h"
|
|
|
|
#include "TitleSequence.h"
|
|
|
|
#include "TitleSequenceManager.h"
|
|
|
|
#include "TitleSequencePlayer.h"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include "../audio/audio.h"
|
2017-02-18 16:45:10 +01:00
|
|
|
#include "../config/Config.h"
|
2016-11-21 01:16:47 +01:00
|
|
|
#include "../drawing/drawing.h"
|
|
|
|
#include "../game.h"
|
|
|
|
#include "../input.h"
|
|
|
|
#include "../interface/screenshot.h"
|
|
|
|
#include "../interface/viewport.h"
|
|
|
|
#include "../interface/window.h"
|
|
|
|
#include "../localisation/localisation.h"
|
2017-01-17 13:51:02 +01:00
|
|
|
#include "../management/news_item.h"
|
2016-11-21 01:16:47 +01:00
|
|
|
#include "../peep/staff.h"
|
2017-03-11 12:24:18 +01:00
|
|
|
#include "../world/Climate.h"
|
2016-11-21 01:16:47 +01:00
|
|
|
#include "../world/scenery.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
bool gTitleHideVersionInfo = false;
|
2016-12-07 03:53:58 +01:00
|
|
|
uint16 gTitleCurrentSequence;
|
2016-11-21 01:16:47 +01:00
|
|
|
}
|
|
|
|
|
2016-12-24 01:53:33 +01:00
|
|
|
static uint16 _loadedTitleSequenceId = UINT16_MAX;
|
2016-11-21 01:16:47 +01:00
|
|
|
static ITitleSequencePlayer * _sequencePlayer = nullptr;
|
|
|
|
|
|
|
|
static void TitleInitialise();
|
|
|
|
static void TryLoadSequence();
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x00678680
|
|
|
|
*/
|
|
|
|
static void TitleInitialise()
|
|
|
|
{
|
|
|
|
if (_sequencePlayer == nullptr)
|
|
|
|
{
|
2017-01-22 23:04:07 +01:00
|
|
|
IScenarioRepository * scenarioRepository = GetScenarioRepository();
|
|
|
|
_sequencePlayer = CreateTitleSequencePlayer(scenarioRepository);
|
2016-11-21 01:16:47 +01:00
|
|
|
}
|
|
|
|
size_t seqId = title_sequence_manager_get_index_for_config_id(gConfigInterface.current_title_sequence_preset);
|
|
|
|
if (seqId == SIZE_MAX)
|
|
|
|
{
|
|
|
|
seqId = title_sequence_manager_get_index_for_config_id("*OPENRCT2");
|
|
|
|
if (seqId == SIZE_MAX)
|
|
|
|
{
|
|
|
|
seqId = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-01-04 22:17:08 +01:00
|
|
|
title_sequence_change_preset((sint32)seqId);
|
2016-11-21 01:16:47 +01:00
|
|
|
TryLoadSequence();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TryLoadSequence()
|
|
|
|
{
|
2016-12-07 03:53:58 +01:00
|
|
|
if (_loadedTitleSequenceId != gTitleCurrentSequence)
|
2016-11-21 01:16:47 +01:00
|
|
|
{
|
2016-12-24 01:53:33 +01:00
|
|
|
uint16 numSequences = (uint16)TitleSequenceManager::GetCount();
|
|
|
|
if (numSequences > 0)
|
2016-11-21 01:16:47 +01:00
|
|
|
{
|
2016-12-24 01:53:33 +01:00
|
|
|
uint16 targetSequence = gTitleCurrentSequence;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_sequencePlayer->Begin(targetSequence) && _sequencePlayer->Update())
|
|
|
|
{
|
|
|
|
_loadedTitleSequenceId = targetSequence;
|
|
|
|
gTitleCurrentSequence = targetSequence;
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
targetSequence = (targetSequence + 1) % numSequences;
|
|
|
|
}
|
|
|
|
while (targetSequence != gTitleCurrentSequence);
|
2016-11-21 01:16:47 +01:00
|
|
|
}
|
2016-12-24 01:53:33 +01:00
|
|
|
Console::Error::WriteLine("Unable to play any title sequences.");
|
|
|
|
_sequencePlayer->Eject();
|
|
|
|
gTitleCurrentSequence = UINT16_MAX;
|
|
|
|
_loadedTitleSequenceId = UINT16_MAX;
|
2016-11-21 01:16:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* rct2: 0x0068E8DA
|
|
|
|
*/
|
|
|
|
void title_load()
|
|
|
|
{
|
|
|
|
log_verbose("loading title");
|
|
|
|
|
|
|
|
if (gGamePaused & GAME_PAUSED_NORMAL)
|
|
|
|
pause_toggle();
|
|
|
|
|
|
|
|
gScreenFlags = SCREEN_FLAGS_TITLE_DEMO;
|
|
|
|
|
|
|
|
#ifndef DISABLE_NETWORK
|
|
|
|
network_close();
|
|
|
|
#endif
|
|
|
|
audio_stop_all_music_and_sounds();
|
2017-01-23 13:44:27 +01:00
|
|
|
game_init_all(150);
|
2016-11-21 01:16:47 +01:00
|
|
|
viewport_init_all();
|
|
|
|
window_main_open();
|
|
|
|
title_create_windows();
|
|
|
|
TitleInitialise();
|
|
|
|
gfx_invalidate_screen();
|
|
|
|
audio_start_title_music();
|
|
|
|
gScreenAge = 0;
|
|
|
|
|
|
|
|
if (gOpenRCT2ShowChangelog) {
|
|
|
|
gOpenRCT2ShowChangelog = false;
|
|
|
|
window_changelog_open();
|
|
|
|
}
|
|
|
|
|
2016-11-28 03:47:39 +01:00
|
|
|
if (_sequencePlayer != nullptr)
|
|
|
|
{
|
|
|
|
_sequencePlayer->Reset();
|
2017-01-02 00:49:06 +01:00
|
|
|
|
|
|
|
// Force the title sequence to load / update so we
|
|
|
|
// don't see a blank screen for a split second.
|
|
|
|
TryLoadSequence();
|
|
|
|
_sequencePlayer->Update();
|
2016-11-28 03:47:39 +01:00
|
|
|
}
|
|
|
|
|
2016-11-21 01:16:47 +01:00
|
|
|
log_verbose("loading title finished");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the windows shown on the title screen; New game, load game,
|
|
|
|
* tutorial, toolbox and exit.
|
|
|
|
* rct2: 0x0066B5C0 (part of 0x0066B3E8)
|
|
|
|
*/
|
|
|
|
void title_create_windows()
|
|
|
|
{
|
|
|
|
window_title_menu_open();
|
|
|
|
window_title_exit_open();
|
|
|
|
window_title_options_open();
|
|
|
|
window_title_logo_open();
|
2017-03-26 22:42:07 +02:00
|
|
|
window_resize_gui(context_get_width(), context_get_height());
|
2016-11-21 01:16:47 +01:00
|
|
|
gTitleHideVersionInfo = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void title_update()
|
|
|
|
{
|
|
|
|
screenshot_check();
|
|
|
|
title_handle_keyboard_input();
|
|
|
|
|
|
|
|
if (game_is_not_paused())
|
|
|
|
{
|
|
|
|
TryLoadSequence();
|
2016-12-24 18:15:30 +01:00
|
|
|
_sequencePlayer->Update();
|
2016-11-21 01:16:47 +01:00
|
|
|
|
|
|
|
sint32 numUpdates = 1;
|
|
|
|
if (gGameSpeed > 1) {
|
|
|
|
numUpdates = 1 << (gGameSpeed - 1);
|
|
|
|
}
|
|
|
|
for (sint32 i = 0; i < numUpdates; i++)
|
|
|
|
{
|
|
|
|
game_logic_update();
|
|
|
|
}
|
|
|
|
update_palette_effects();
|
|
|
|
// update_rain_animation();
|
|
|
|
}
|
|
|
|
|
2017-02-27 20:20:41 +01:00
|
|
|
input_set_flag(INPUT_FLAG_VIEWPORT_SCROLLING, false);
|
2016-11-21 01:16:47 +01:00
|
|
|
|
|
|
|
window_map_tooltip_update_visibility();
|
|
|
|
window_dispatch_update_all();
|
|
|
|
|
|
|
|
gSavedAge++;
|
|
|
|
|
|
|
|
game_handle_input();
|
|
|
|
}
|
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
void DrawOpenRCT2(rct_drawpixelinfo * dpi, sint32 x, sint32 y)
|
2016-11-21 01:16:47 +01:00
|
|
|
{
|
|
|
|
utf8 buffer[256];
|
|
|
|
|
|
|
|
// Write format codes
|
|
|
|
utf8 *ch = buffer;
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_MEDIUMFONT);
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_OUTLINE);
|
|
|
|
ch = utf8_write_codepoint(ch, FORMAT_WHITE);
|
|
|
|
|
|
|
|
// Write name and version information
|
|
|
|
openrct2_write_full_version_info(ch, sizeof(buffer) - (ch - buffer));
|
|
|
|
gfx_draw_string(dpi, buffer, COLOUR_BLACK, x + 5, y + 5 - 13);
|
|
|
|
|
|
|
|
// Write platform information
|
|
|
|
snprintf(ch, 256 - (ch - buffer), "%s (%s)", OPENRCT2_PLATFORM, OPENRCT2_ARCHITECTURE);
|
|
|
|
gfx_draw_string(dpi, buffer, COLOUR_BLACK, x + 5, y + 5);
|
|
|
|
}
|
2016-11-26 16:32:49 +01:00
|
|
|
|
|
|
|
void * title_get_sequence_player()
|
|
|
|
{
|
|
|
|
return _sequencePlayer;
|
|
|
|
}
|
2016-12-07 03:53:58 +01:00
|
|
|
|
2017-01-04 22:17:08 +01:00
|
|
|
void title_sequence_change_preset(sint32 preset)
|
2016-12-07 03:53:58 +01:00
|
|
|
{
|
2017-01-04 22:17:08 +01:00
|
|
|
sint32 count = (sint32)title_sequence_manager_get_count();
|
2016-12-07 03:53:58 +01:00
|
|
|
if (preset < 0 || preset >= count) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const utf8 * configId = title_sequence_manager_get_config_id(preset);
|
|
|
|
SafeFree(gConfigInterface.current_title_sequence_preset);
|
|
|
|
gConfigInterface.current_title_sequence_preset = _strdup(configId);
|
|
|
|
|
|
|
|
gTitleCurrentSequence = preset;
|
|
|
|
window_invalidate_all();
|
|
|
|
}
|
2016-11-21 01:16:47 +01:00
|
|
|
}
|