Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ add_library(${PROJECT_NAME} OBJECT
src/scene_import.h
src/scene_item.cpp
src/scene_item.h
src/scene_language.cpp
src/scene_language.h
src/scene_load.cpp
src/scene_load.h
src/scene_logo.cpp
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ libeasyrpg_player_a_SOURCES = \
src/scene_gameover.h \
src/scene_item.cpp \
src/scene_item.h \
src/scene_language.cpp \
src/scene_language.h \
src/scene_load.cpp \
src/scene_load.h \
src/scene_logo.cpp \
Expand Down
6 changes: 4 additions & 2 deletions src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,8 @@ void Game_Config::LoadFromStream(Filesystem_Stream::InputStream& is) {
player.settings_autosave.FromIni(ini);
player.settings_in_title.FromIni(ini);
player.settings_in_menu.FromIni(ini);
player.lang_select_on_start.FromIni(ini);
player.lang_select_in_title.FromIni(ini);
player.show_startup_logos.FromIni(ini);
player.font1.FromIni(ini);
player.font1_size.FromIni(ini);
Expand Down Expand Up @@ -751,13 +753,13 @@ void Game_Config::WriteToStream(Filesystem_Stream::OutputStream& os) const {
player.settings_autosave.ToIni(os);
player.settings_in_title.ToIni(os);
player.settings_in_menu.ToIni(os);
player.lang_select_on_start.ToIni(os);
player.lang_select_in_title.ToIni(os);
player.show_startup_logos.ToIni(os);
player.font1.ToIni(os);
player.font1_size.ToIni(os);
player.font2.ToIni(os);
player.font2_size.ToIni(os);
player.log_enabled.ToIni(os);
player.screenshot_scale.ToIni(os);

os << "\n";
}
14 changes: 14 additions & 0 deletions src/game_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ namespace ConfigEnum {
All
};

enum class StartupLangSelect {
Never,
/* Shows language screen when no saves are found */
FirstStartup,
/* Always show the language screen before the title */
Always
};

enum class ShowFps {
/** Do not show */
OFF,
Expand Down Expand Up @@ -89,6 +97,12 @@ struct Game_ConfigPlayer {
RangeConfigParam<int> font1_size { "Font 1 Size", "", "Player", "Font1Size", 12, 6, 16};
PathConfigParam font2 { "Font 2", "The game chooses whether it wants font 1 or 2", "Player", "Font2", "" };
RangeConfigParam<int> font2_size { "Font 2 Size", "", "Player", "Font2Size", 12, 6, 16};
EnumConfigParam<ConfigEnum::StartupLangSelect, 3> lang_select_on_start {
"Startup Language Menu", "Show language menu before booting up a game", "Player", "StartupLangSelect", ConfigEnum::StartupLangSelect::FirstStartup,
Utils::MakeSvArray("Never", "First Start", "Always"),
Utils::MakeSvArray("never", "FirstStartup", "always"),
Utils::MakeSvArray("Never show language menu on start", "Show on first start (when no save files are found)", "Always show language menu prior to the title screen") };
BoolConfigParam lang_select_in_title{ "Show language menu on title screen", "Display language menu item on the title screen", "Player", "LanguageInTitle", true };
BoolConfigParam log_enabled{ "Logging", "Write diagnostic messages into a logfile", "Player", "Logging", true };
RangeConfigParam<int> screenshot_scale { "Screenshot scaling factor", "Scale screenshots by the given factor", "Player", "ScreenshotScale", 1, 1, 24};

Expand Down
11 changes: 5 additions & 6 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
#include "scene_shop.h"
#include "scene_debug.h"
#include "scene_gameover.h"
#include "scene_settings.h"
#include "scene_language.h"
#include "scene.h"
#include "graphics.h"
#include "input.h"
Expand Down Expand Up @@ -161,17 +163,14 @@ bool Game_Interpreter_Map::RequestMainMenuScene(int subscreen_id, int actor_inde
Scene::instance->SetRequestedScene(std::make_shared<Scene_Order>());
return true;
}
/*
case 6: // Settings
Scene::instance->SetRequestedScene(std::make_shared<Scene_Settings>());
return true;
case 7: // Language
Scene::instance->SetRequestedScene(std::make_shared<Scene_Language>());
return true;
case 8: // Debug
Scene::instance->SetRequestedScene(std::make_shared<Scene_Debug>());
if (Player::translation.HasTranslations()) {
Scene::instance->SetRequestedScene(std::make_shared<Scene_Language>());
}
return true;
*/
}

Scene::instance->SetRequestedScene(std::make_shared<Scene_Menu>());
Expand Down
34 changes: 24 additions & 10 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ namespace Player {
std::string escape_symbol;
uint32_t escape_char;
std::string game_title;
std::string game_title_original;
std::shared_ptr<Meta> meta;
FileExtGuesser::RPG2KFileExtRemap fileext_map;
std::string startup_language;
Expand Down Expand Up @@ -737,16 +738,7 @@ void Player::CreateGameObjects() {
}
}

std::stringstream title;
if (!game_title.empty()) {
Output::Debug("Loading game {}", game_title);
title << game_title << " - ";
Input::AddRecordingData(Input::RecordingData::GameTitle, game_title);
} else {
Output::Debug("Could not read game title.");
}
title << GAME_TITLE;
DisplayUi->SetTitle(title.str());
UpdateTitle(game_title);

if (no_rtp_warning_flag) {
Output::Debug("Game does not need RTP (FullPackageFlag=1)");
Expand Down Expand Up @@ -852,6 +844,28 @@ void Player::CreateGameObjects() {
}
}

void Player::UpdateTitle(std::string new_game_title) {
if (!game_title.empty() && game_title != new_game_title) {
if (game_title_original == new_game_title) {
game_title_original = "";
} else {
game_title_original = game_title;
}
game_title = new_game_title;
}

std::stringstream title;
if (!game_title.empty()) {
Output::Debug("Loading game {}", game_title);
title << new_game_title << " - ";
Input::AddRecordingData(Input::RecordingData::GameTitle, game_title);
} else {
Output::Debug("Could not read game title.");
}
title << GAME_TITLE;
DisplayUi->SetTitle(title.str());
}

bool Player::ChangeResolution(int width, int height) {
if (!DisplayUi->ChangeDisplaySurfaceResolution(width, height)) {
Output::Warning("Resolution change to {}x{} failed", width, height);
Expand Down
8 changes: 8 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ namespace Player {
*/
bool HasEasyRpgExtensions();

/**
* Update the game title displayed in the Player's UI
*/
void UpdateTitle(std::string new_game_title);

/**
* @return Running engine version. 2000 for RPG2k and 2003 for RPG2k3
*/
Expand Down Expand Up @@ -395,6 +400,9 @@ namespace Player {
/** Game title. */
extern std::string game_title;

/** Original game title, in case it was overriden by a translation. */
extern std::string game_title_original;

/** Meta class containing additional external data for this game. */
extern std::shared_ptr<Meta> meta;

Expand Down
33 changes: 32 additions & 1 deletion src/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@
#include "player.h"
#include "output.h"
#include "audio.h"
#include "filefinder.h"
#include "transition.h"
#include "game_actors.h"
#include "game_interpreter.h"
#include "game_system.h"
#include "main_data.h"
#include "scene_language.h"
#include "scene_settings.h"
#include "scene_title.h"
#include "game_map.h"

#ifndef NDEBUG
Expand Down Expand Up @@ -64,7 +67,9 @@ const char Scene::scene_names[SceneMax][12] =
"Logo",
"Order",
"GameBrowser",
"Teleport"
"Teleport",
"Settings",
"Language"
};

enum PushPopOperation {
Expand Down Expand Up @@ -95,6 +100,7 @@ lcf::rpg::SaveSystem::Scene Scene::rpgRtSceneFromSceneType(SceneType t) {
case Order:
case End:
case Settings:
case LanguageMenu:
return lcf::rpg::SaveSystem::Scene_menu;
case File:
case Save:
Expand Down Expand Up @@ -265,6 +271,12 @@ void Scene::Push(std::shared_ptr<Scene> const& new_scene, bool pop_stack_top) {
DEBUG_VALIDATE("Push");
}

std::shared_ptr<Scene> Scene::Peek() {
if (instances.size() == 1)
return nullptr;
return instances[instances.size() - 2];
}

void Scene::Pop() {
old_instances.push_back(instances.back());
instances.pop_back();
Expand Down Expand Up @@ -355,6 +367,25 @@ inline void Scene::DebugValidate(const char* caller) {
}
}

void Scene::PushTitleScene(bool pop_stack_top) {
auto title_scene = Scene::Find(Scene::Title);
if (title_scene) {
return;
}

if (!Player::startup_language.empty()) {
Player::translation.SelectLanguage(Player::startup_language);
} else if (Player::translation.HasTranslations()) {
if (Player::player_config.lang_select_on_start.Get() == ConfigEnum::StartupLangSelect::Always
|| (!FileFinder::HasSavegame() && Player::player_config.lang_select_on_start.Get() == ConfigEnum::StartupLangSelect::FirstStartup)) {
Scene::Push(std::make_shared<Scene_Language>(), pop_stack_top);
return;
}
}

Scene::Push(std::make_shared<Scene_Title>(), pop_stack_top);
}

bool Scene::ReturnToTitleScene() {
if (Scene::instance && Scene::instance->type == Scene::Title) {
return false;
Expand Down
15 changes: 15 additions & 0 deletions src/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Scene {
GameBrowser,
Teleport,
Settings,
LanguageMenu,
SceneMax
};

Expand Down Expand Up @@ -160,6 +161,14 @@ class Scene {
*/
static void Push(std::shared_ptr<Scene> const& new_scene, bool pop_stack_top = false);

/**
* Finds the the scene previous to the current, top-most one and
* returns it without popping it from the stack.
*
* @return the scene found, or NULL if the current scene is already the top.
*/
static std::shared_ptr<Scene> Peek();

/**
* Removes the scene that is on the top of the stack.
*/
Expand Down Expand Up @@ -247,6 +256,12 @@ class Scene {
/** Decrement delay frames by 1 if we're waiting */
void UpdateDelayFrames();

/**
* Pushes the title screen onto the stack to boot up the game.
* If there already is a title scene �n the stack, this function exits without doing anything.
*/
static void PushTitleScene(bool pop_stack_top = false);

/**
* Pops the stack until the title screen and sets proper delay.
*
Expand Down
7 changes: 2 additions & 5 deletions src/scene_gamebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "input.h"
#include "player.h"
#include "scene_logo.h"
#include "scene_title.h"
#include "bitmap.h"
#include "audio.h"
#include "output.h"
Expand Down Expand Up @@ -59,6 +58,7 @@ void Scene_GameBrowser::Continue(SceneType /* prev_scene */) {
Player::RestoreBaseResolution();

Player::game_title = "";
Player::game_title_original = "";

Font::ResetDefault();

Expand Down Expand Up @@ -242,8 +242,5 @@ void Scene_GameBrowser::BootGame() {
return;
}

if (!Player::startup_language.empty()) {
Player::translation.SelectLanguage(Player::startup_language);
}
Scene::Push(std::make_shared<Scene_Title>());
Scene::PushTitleScene();
}
Loading