-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce an in-game string to support multiple languages (#9330)
- Loading branch information
Showing
7 changed files
with
123 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2019 - 2024 * | ||
* Copyright (C) 2019 - 2025 * | ||
* * | ||
* Free Heroes2 Engine: http://sourceforge.net/projects/fheroes2 * | ||
* Copyright (C) 2009 by Andrey Afletdinov <[email protected]> * | ||
|
@@ -29,6 +29,7 @@ | |
#include "castle.h" // IWYU pragma: associated | ||
#include "dialog.h" | ||
#include "game_delays.h" | ||
#include "game_string.h" | ||
#include "icn.h" | ||
#include "translations.h" | ||
#include "ui_dialog.h" | ||
|
@@ -37,14 +38,14 @@ | |
|
||
void Castle::_openTavern() const | ||
{ | ||
auto [rumor, language] = world.getCurrentRumor(); | ||
auto rumor = world.getCurrentRumor(); | ||
|
||
std::string body( _( "A generous tip for the barkeep yields the following rumor:" ) ); | ||
body += "\n\n"; | ||
|
||
auto text = std::make_shared<fheroes2::MultiFontText>(); | ||
text->add( fheroes2::Text{ std::move( body ), fheroes2::FontType::normalWhite() } ); | ||
text->add( fheroes2::Text{ std::move( rumor ), fheroes2::FontType::normalWhite(), language } ); | ||
text->add( fheroes2::Text{ std::move( rumor.text ), fheroes2::FontType::normalWhite(), rumor.language } ); | ||
|
||
const fheroes2::AnimationDialogElement imageUI( ICN::TAVWIN, { 0, 1 }, 0, Game::getAnimationDelayValue( Game::CASTLE_TAVERN_DELAY ) ); | ||
const fheroes2::TextDialogElement textBodyUI( text ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2025 * | ||
* * | ||
* This program 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 2 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, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | ||
***************************************************************************/ | ||
|
||
#include "game_string.h" | ||
|
||
#include "serialize.h" | ||
|
||
OStreamBase & operator<<( OStreamBase & stream, const fheroes2::LocalizedString & string ) | ||
{ | ||
return stream << string.text << string.language; | ||
} | ||
|
||
IStreamBase & operator>>( IStreamBase & stream, fheroes2::LocalizedString & string ) | ||
{ | ||
return stream >> string.text >> string.language; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
* fheroes2: https://github.com/ihhub/fheroes2 * | ||
* Copyright (C) 2025 * | ||
* * | ||
* This program 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 2 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, write to the * | ||
* Free Software Foundation, Inc., * | ||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | ||
***************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <optional> | ||
#include <string> | ||
|
||
class IStreamBase; | ||
class OStreamBase; | ||
|
||
namespace fheroes2 | ||
{ | ||
|
||
enum class SupportedLanguage : uint8_t; | ||
|
||
struct LocalizedString | ||
{ | ||
std::string text; | ||
|
||
std::optional<SupportedLanguage> language; | ||
}; | ||
} | ||
|
||
OStreamBase & operator<<( OStreamBase & stream, const fheroes2::LocalizedString & string ); | ||
IStreamBase & operator>>( IStreamBase & stream, fheroes2::LocalizedString & string ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters