diff --git a/AI/Nullkiller/Goals/CompleteQuest.cpp b/AI/Nullkiller/Goals/CompleteQuest.cpp index f774a2295..aeceb9871 100644 --- a/AI/Nullkiller/Goals/CompleteQuest.cpp +++ b/AI/Nullkiller/Goals/CompleteQuest.cpp @@ -12,7 +12,7 @@ #include "../Behaviors/CaptureObjectsBehavior.h" #include "../AIGateway.h" #include "../../../lib/VCMI_Lib.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" namespace NKAI { diff --git a/CCallback.cpp b/CCallback.cpp index 423223a73..be99a628c 100644 --- a/CCallback.cpp +++ b/CCallback.cpp @@ -18,7 +18,7 @@ #include "lib/mapObjects/CGHeroInstance.h" #include "lib/mapObjects/CGTownInstance.h" #include "lib/CBuildingHandler.h" -#include "lib/CGeneralTextHandler.h" +#include "lib/texts/CGeneralTextHandler.h" #include "lib/CHeroHandler.h" #include "lib/CArtHandler.h" #include "lib/GameConstants.h" diff --git a/client/ArtifactsUIController.cpp b/client/ArtifactsUIController.cpp index 38083b4f8..73461a58a 100644 --- a/client/ArtifactsUIController.cpp +++ b/client/ArtifactsUIController.cpp @@ -15,7 +15,7 @@ #include "../CCallback.h" #include "../lib/ArtifactUtils.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/mapObjects/CGHeroInstance.h" #include "gui/CGuiHandler.h" diff --git a/client/CMT.cpp b/client/CMT.cpp index 8109081fa..3962a1821 100644 --- a/client/CMT.cpp +++ b/client/CMT.cpp @@ -32,7 +32,7 @@ #include "render/Graphics.h" #include "../lib/CConfigHandler.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CThreadHelper.h" #include "../lib/ExceptionsCommon.h" #include "../lib/VCMIDirs.h" diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index dab02d6dd..901e8236d 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -67,7 +67,7 @@ #include "../CCallback.h" #include "../lib/CConfigHandler.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CPlayerState.h" #include "../lib/CRandomGenerator.h" @@ -79,7 +79,6 @@ #include "../lib/RoadHandler.h" #include "../lib/StartInfo.h" #include "../lib/TerrainHandler.h" -#include "../lib/TextOperations.h" #include "../lib/UnlockGuard.h" #include "../lib/VCMIDirs.h" @@ -108,6 +107,8 @@ #include "../lib/spells/CSpellHandler.h" +#include "../lib/texts/TextOperations.h" + // The macro below is used to mark functions that are called by client when game state changes. // They all assume that interface mutex is locked. #define EVENT_HANDLER_CALLED_BY_CLIENT diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 55b52285f..ebdaec1be 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -28,7 +28,7 @@ #include "mainmenu/CHighScoreScreen.h" #include "../lib/CConfigHandler.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "ConditionalWait.h" #include "../lib/CThreadHelper.h" #include "../lib/StartInfo.h" diff --git a/client/ClientCommandManager.cpp b/client/ClientCommandManager.cpp index 96e150713..79ef59688 100644 --- a/client/ClientCommandManager.cpp +++ b/client/ClientCommandManager.cpp @@ -30,7 +30,7 @@ #include "../lib/mapObjects/CGHeroInstance.h" #include "render/CAnimation.h" #include "../CCallback.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/filesystem/Filesystem.h" #include "../lib/modding/CModHandler.h" #include "../lib/modding/ContentTypeHandler.h" diff --git a/client/GameChatHandler.cpp b/client/GameChatHandler.cpp index e93208bd9..ceb9be0aa 100644 --- a/client/GameChatHandler.cpp +++ b/client/GameChatHandler.cpp @@ -21,12 +21,11 @@ #include "../CCallback.h" #include "../lib/networkPacks/PacksForLobby.h" -#include "../lib/TextOperations.h" #include "../lib/mapObjects/CArmedInstance.h" #include "../lib/CConfigHandler.h" -#include "../lib/MetaString.h" #include "../lib/VCMI_Lib.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" +#include "../lib/texts/TextOperations.h" const std::vector & GameChatHandler::getChatHistory() const { diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index c7755dd82..6d16608a0 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -31,7 +31,7 @@ #include "../lib/filesystem/FileInfo.h" #include "../lib/serializer/BinarySerializer.h" #include "../lib/serializer/Connection.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/VCMI_Lib.h" #include "../lib/mapping/CMap.h" diff --git a/client/NetPacksLobbyClient.cpp b/client/NetPacksLobbyClient.cpp index d7dd519c9..72691458a 100644 --- a/client/NetPacksLobbyClient.cpp +++ b/client/NetPacksLobbyClient.cpp @@ -33,7 +33,7 @@ #include "widgets/TextControls.h" #include "../lib/CConfigHandler.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/serializer/Connection.h" void ApplyOnLobbyHandlerNetPackVisitor::visitLobbyClientConnected(LobbyClientConnected & pack) diff --git a/client/adventureMap/AdventureMapInterface.cpp b/client/adventureMap/AdventureMapInterface.cpp index 255dc2884..ef0a1be11 100644 --- a/client/adventureMap/AdventureMapInterface.cpp +++ b/client/adventureMap/AdventureMapInterface.cpp @@ -40,7 +40,7 @@ #include "../../CCallback.h" #include "../../lib/GameSettings.h" #include "../../lib/StartInfo.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGTownInstance.h" diff --git a/client/adventureMap/AdventureMapShortcuts.cpp b/client/adventureMap/AdventureMapShortcuts.cpp index 222553e78..d0e28ba19 100644 --- a/client/adventureMap/AdventureMapShortcuts.cpp +++ b/client/adventureMap/AdventureMapShortcuts.cpp @@ -31,7 +31,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapping/CMap.h" diff --git a/client/adventureMap/AdventureOptions.cpp b/client/adventureMap/AdventureOptions.cpp index 138aa59d3..a0acb6ead 100644 --- a/client/adventureMap/AdventureOptions.cpp +++ b/client/adventureMap/AdventureOptions.cpp @@ -23,7 +23,7 @@ #include "../../CCallback.h" #include "../../lib/StartInfo.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" AdventureOptions::AdventureOptions() : CWindowObject(PLAYER_COLORED, ImagePath::builtin("ADVOPTS")) diff --git a/client/adventureMap/CInGameConsole.cpp b/client/adventureMap/CInGameConsole.cpp index 02181d2ee..b28aa1ea0 100644 --- a/client/adventureMap/CInGameConsole.cpp +++ b/client/adventureMap/CInGameConsole.cpp @@ -30,9 +30,8 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" #include "../../lib/CThreadHelper.h" -#include "../../lib/TextOperations.h" #include "../../lib/mapObjects/CArmedInstance.h" -#include "../../lib/MetaString.h" +#include "../../lib/texts/TextOperations.h" CInGameConsole::CInGameConsole() : CIntObject(KEYBOARD | TIME | TEXTINPUT) diff --git a/client/adventureMap/CInfoBar.cpp b/client/adventureMap/CInfoBar.cpp index 70b6484bb..deadd6fc6 100644 --- a/client/adventureMap/CInfoBar.cpp +++ b/client/adventureMap/CInfoBar.cpp @@ -29,7 +29,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGTownInstance.h" diff --git a/client/adventureMap/CList.cpp b/client/adventureMap/CList.cpp index 976476365..8ed4b1fd3 100644 --- a/client/adventureMap/CList.cpp +++ b/client/adventureMap/CList.cpp @@ -26,7 +26,7 @@ #include "../render/Canvas.h" #include "../render/Colors.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/GameSettings.h" #include "../../lib/mapObjects/CGHeroInstance.h" diff --git a/client/adventureMap/CMinimap.cpp b/client/adventureMap/CMinimap.cpp index 91de1edda..50c89d884 100644 --- a/client/adventureMap/CMinimap.cpp +++ b/client/adventureMap/CMinimap.cpp @@ -26,7 +26,7 @@ #include "../windows/InfoWindows.h" #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/TerrainHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapping/CMapDefines.h" diff --git a/client/adventureMap/CResDataBar.cpp b/client/adventureMap/CResDataBar.cpp index d15fe230f..675aac23b 100644 --- a/client/adventureMap/CResDataBar.cpp +++ b/client/adventureMap/CResDataBar.cpp @@ -21,7 +21,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/ResourceSet.h" CResDataBar::CResDataBar(const ImagePath & imageName, const Point & position) diff --git a/client/battle/BattleActionsController.cpp b/client/battle/BattleActionsController.cpp index a4fe689a1..2a5fceb34 100644 --- a/client/battle/BattleActionsController.cpp +++ b/client/battle/BattleActionsController.cpp @@ -28,7 +28,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CRandomGenerator.h" #include "../../lib/CStack.h" #include "../../lib/battle/BattleAction.h" diff --git a/client/battle/BattleEffectsController.cpp b/client/battle/BattleEffectsController.cpp index 7a2d936b7..d390093d9 100644 --- a/client/battle/BattleEffectsController.cpp +++ b/client/battle/BattleEffectsController.cpp @@ -31,7 +31,7 @@ #include "../../lib/networkPacks/PacksForClientBattle.h" #include "../../lib/CStack.h" #include "../../lib/IGameEventsReceiver.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" BattleEffectsController::BattleEffectsController(BattleInterface & owner): owner(owner) diff --git a/client/battle/BattleInterface.cpp b/client/battle/BattleInterface.cpp index 8309add13..59fa364c4 100644 --- a/client/battle/BattleInterface.cpp +++ b/client/battle/BattleInterface.cpp @@ -38,7 +38,7 @@ #include "../../lib/BattleFieldHandler.h" #include "../../lib/CStack.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/gameState/InfoAboutArmy.h" #include "../../lib/mapObjects/CGTownInstance.h" diff --git a/client/battle/BattleInterfaceClasses.cpp b/client/battle/BattleInterfaceClasses.cpp index 3f4ab4838..baa2295f6 100644 --- a/client/battle/BattleInterfaceClasses.cpp +++ b/client/battle/BattleInterfaceClasses.cpp @@ -51,13 +51,13 @@ #include "../../lib/CConfigHandler.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/gameState/InfoAboutArmy.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/CTownHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/StartInfo.h" #include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/networkPacks/PacksForClientBattle.h" -#include "../../lib/TextOperations.h" #include "../../lib/json/JsonUtils.h" diff --git a/client/battle/BattleInterfaceClasses.h b/client/battle/BattleInterfaceClasses.h index 634c66567..5cf2a1f3b 100644 --- a/client/battle/BattleInterfaceClasses.h +++ b/client/battle/BattleInterfaceClasses.h @@ -13,8 +13,8 @@ #include "../gui/CIntObject.h" #include "../../lib/FunctionList.h" #include "../../lib/battle/BattleHex.h" +#include "../../lib/texts/MetaString.h" #include "../windows/CWindowObject.h" -#include "../../lib/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/client/battle/BattleStacksController.cpp b/client/battle/BattleStacksController.cpp index 4e67c9098..7fda941d3 100644 --- a/client/battle/BattleStacksController.cpp +++ b/client/battle/BattleStacksController.cpp @@ -37,9 +37,9 @@ #include "../../lib/spells/ISpellMechanics.h" #include "../../lib/battle/BattleAction.h" #include "../../lib/battle/BattleHex.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/CRandomGenerator.h" #include "../../lib/CStack.h" -#include "../../lib/TextOperations.h" static void onAnimationFinished(const CStack *stack, std::weak_ptr anim) { diff --git a/client/battle/BattleWindow.cpp b/client/battle/BattleWindow.cpp index 0f90f357b..15216c811 100644 --- a/client/battle/BattleWindow.cpp +++ b/client/battle/BattleWindow.cpp @@ -34,7 +34,7 @@ #include "../adventureMap/TurnTimerWidget.h" #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/gameState/InfoAboutArmy.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/CStack.h" diff --git a/client/globalLobby/GlobalLobbyClient.cpp b/client/globalLobby/GlobalLobbyClient.cpp index 018af2334..9a29ddae3 100644 --- a/client/globalLobby/GlobalLobbyClient.cpp +++ b/client/globalLobby/GlobalLobbyClient.cpp @@ -25,10 +25,10 @@ #include "../windows/InfoWindows.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/MetaString.h" #include "../../lib/json/JsonUtils.h" -#include "../../lib/TextOperations.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/MetaString.h" +#include "../../lib/texts/TextOperations.h" GlobalLobbyClient::GlobalLobbyClient() { diff --git a/client/globalLobby/GlobalLobbyInviteWindow.cpp b/client/globalLobby/GlobalLobbyInviteWindow.cpp index fb63d5b5f..f282f9902 100644 --- a/client/globalLobby/GlobalLobbyInviteWindow.cpp +++ b/client/globalLobby/GlobalLobbyInviteWindow.cpp @@ -22,8 +22,8 @@ #include "../widgets/ObjectLists.h" #include "../widgets/TextControls.h" -#include "../../lib/MetaString.h" #include "../../lib/json/JsonNode.h" +#include "../../lib/texts/MetaString.h" GlobalLobbyInviteAccountCard::GlobalLobbyInviteAccountCard(const GlobalLobbyAccount & accountDescription) : accountID(accountDescription.accountID) diff --git a/client/globalLobby/GlobalLobbyLoginWindow.cpp b/client/globalLobby/GlobalLobbyLoginWindow.cpp index 06718961e..6e866443c 100644 --- a/client/globalLobby/GlobalLobbyLoginWindow.cpp +++ b/client/globalLobby/GlobalLobbyLoginWindow.cpp @@ -25,8 +25,8 @@ #include "../widgets/TextControls.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/MetaString.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/MetaString.h" GlobalLobbyLoginWindow::GlobalLobbyLoginWindow() : CWindowObject(BORDERED) diff --git a/client/globalLobby/GlobalLobbyRoomWindow.cpp b/client/globalLobby/GlobalLobbyRoomWindow.cpp index b1803f0a4..08d4bb475 100644 --- a/client/globalLobby/GlobalLobbyRoomWindow.cpp +++ b/client/globalLobby/GlobalLobbyRoomWindow.cpp @@ -26,10 +26,10 @@ #include "../widgets/GraphicalPrimitiveCanvas.h" #include "../widgets/ObjectLists.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/MetaString.h" #include "../../lib/modding/CModHandler.h" #include "../../lib/modding/CModInfo.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/MetaString.h" GlobalLobbyRoomAccountCard::GlobalLobbyRoomAccountCard(const GlobalLobbyAccount & accountDescription) { diff --git a/client/globalLobby/GlobalLobbyServerSetup.cpp b/client/globalLobby/GlobalLobbyServerSetup.cpp index ad55222d5..084a1cfef 100644 --- a/client/globalLobby/GlobalLobbyServerSetup.cpp +++ b/client/globalLobby/GlobalLobbyServerSetup.cpp @@ -23,8 +23,8 @@ #include "../widgets/TextControls.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/MetaString.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/MetaString.h" GlobalLobbyServerSetup::GlobalLobbyServerSetup() : CWindowObject(BORDERED) diff --git a/client/globalLobby/GlobalLobbyWidget.cpp b/client/globalLobby/GlobalLobbyWidget.cpp index b3ee03288..a8a57ac7f 100644 --- a/client/globalLobby/GlobalLobbyWidget.cpp +++ b/client/globalLobby/GlobalLobbyWidget.cpp @@ -30,8 +30,8 @@ #include "../widgets/TextControls.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/Languages.h" -#include "../../lib/MetaString.h" +#include "../../lib/texts/Languages.h" +#include "../../lib/texts/MetaString.h" GlobalLobbyWidget::GlobalLobbyWidget(GlobalLobbyWindow * window) : window(window) diff --git a/client/globalLobby/GlobalLobbyWindow.cpp b/client/globalLobby/GlobalLobbyWindow.cpp index 70a195101..a3a2b8185 100644 --- a/client/globalLobby/GlobalLobbyWindow.cpp +++ b/client/globalLobby/GlobalLobbyWindow.cpp @@ -23,9 +23,9 @@ #include "../widgets/ObjectLists.h" #include "../widgets/TextControls.h" -#include "../../lib/Languages.h" -#include "../../lib/MetaString.h" -#include "../../lib/TextOperations.h" +#include "../../lib/texts/Languages.h" +#include "../../lib/texts/MetaString.h" +#include "../../lib/texts/TextOperations.h" GlobalLobbyWindow::GlobalLobbyWindow() : CWindowObject(BORDERED) diff --git a/client/gui/InterfaceObjectConfigurable.cpp b/client/gui/InterfaceObjectConfigurable.cpp index bf9736cde..7b1db756f 100644 --- a/client/gui/InterfaceObjectConfigurable.cpp +++ b/client/gui/InterfaceObjectConfigurable.cpp @@ -32,7 +32,7 @@ #include "../../lib/constants/StringConstants.h" #include "../../lib/json/JsonUtils.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/filesystem/ResourcePath.h" InterfaceObjectConfigurable::InterfaceObjectConfigurable(const JsonNode & config, int used, Point offset): diff --git a/client/lobby/CBonusSelection.cpp b/client/lobby/CBonusSelection.cpp index 61414c3ea..079f448f7 100644 --- a/client/lobby/CBonusSelection.cpp +++ b/client/lobby/CBonusSelection.cpp @@ -39,7 +39,7 @@ #include "../gui/WindowHandler.h" #include "../../lib/filesystem/Filesystem.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CConfigHandler.h" #include "../../lib/CBuildingHandler.h" #include "../../lib/CConfigHandler.h" diff --git a/client/lobby/CCampaignInfoScreen.cpp b/client/lobby/CCampaignInfoScreen.cpp index 56183b31c..4218b818f 100644 --- a/client/lobby/CCampaignInfoScreen.cpp +++ b/client/lobby/CCampaignInfoScreen.cpp @@ -12,7 +12,7 @@ #include "CCampaignInfoScreen.h" #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/StartInfo.h" #include "../../lib/mapping/CMapInfo.h" #include "../../lib/mapping/CMapHeader.h" diff --git a/client/lobby/CLobbyScreen.cpp b/client/lobby/CLobbyScreen.cpp index fac1bd173..b8ccb8871 100644 --- a/client/lobby/CLobbyScreen.cpp +++ b/client/lobby/CLobbyScreen.cpp @@ -28,7 +28,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/campaign/CampaignHandler.h" #include "../../lib/mapping/CMapInfo.h" #include "../../lib/networkPacks/PacksForLobby.h" diff --git a/client/lobby/CSavingScreen.cpp b/client/lobby/CSavingScreen.cpp index 1ec536aa7..a60ae033e 100644 --- a/client/lobby/CSavingScreen.cpp +++ b/client/lobby/CSavingScreen.cpp @@ -21,7 +21,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/StartInfo.h" #include "../../lib/filesystem/Filesystem.h" #include "../../lib/mapping/CMapInfo.h" diff --git a/client/lobby/CScenarioInfoScreen.cpp b/client/lobby/CScenarioInfoScreen.cpp index 51a6f242a..69463157a 100644 --- a/client/lobby/CScenarioInfoScreen.cpp +++ b/client/lobby/CScenarioInfoScreen.cpp @@ -20,7 +20,7 @@ #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/StartInfo.h" #include "../../lib/mapping/CMapInfo.h" #include "../../lib/mapping/CMapHeader.h" diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index 04a77fc7c..58a280b97 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -43,12 +43,11 @@ #include "../render/IFont.h" #include "../render/IRenderHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/CTownHandler.h" #include "../../lib/CRandomGenerator.h" #include "../../lib/CThreadHelper.h" -#include "../../lib/MetaString.h" #include "../../lib/filesystem/Filesystem.h" #include "../../lib/mapping/CMapHeader.h" #include "../../lib/mapping/CMapInfo.h" diff --git a/client/lobby/OptionsTab.cpp b/client/lobby/OptionsTab.cpp index d8cd1f273..a7e3611df 100644 --- a/client/lobby/OptionsTab.cpp +++ b/client/lobby/OptionsTab.cpp @@ -36,7 +36,7 @@ #include "../../lib/filesystem/Filesystem.h" #include "../../lib/networkPacks/PacksForLobby.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CArtHandler.h" #include "../../lib/CConfigHandler.h" #include "../../lib/CTownHandler.h" diff --git a/client/lobby/OptionsTabBase.cpp b/client/lobby/OptionsTabBase.cpp index c4d728d00..8b924f23c 100644 --- a/client/lobby/OptionsTabBase.cpp +++ b/client/lobby/OptionsTabBase.cpp @@ -20,9 +20,9 @@ #include "../CGameInfo.h" #include "../../lib/StartInfo.h" -#include "../../lib/Languages.h" -#include "../../lib/MetaString.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/Languages.h" +#include "../../lib/texts/MetaString.h" #include "../../lib/CConfigHandler.h" static std::string timeToString(int time) diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index 76ab489d6..f1674ce79 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -29,7 +29,7 @@ #include "../windows/GUIClasses.h" #include "../windows/InfoWindows.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapping/CMapInfo.h" #include "../../lib/mapping/CMapHeader.h" #include "../../lib/mapping/MapFormat.h" diff --git a/client/lobby/SelectionTab.cpp b/client/lobby/SelectionTab.cpp index c65944237..33276ea1b 100644 --- a/client/lobby/SelectionTab.cpp +++ b/client/lobby/SelectionTab.cpp @@ -35,7 +35,6 @@ #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" #include "../../lib/CConfigHandler.h" #include "../../lib/GameSettings.h" #include "../../lib/filesystem/Filesystem.h" @@ -43,8 +42,9 @@ #include "../../lib/mapping/CMapInfo.h" #include "../../lib/mapping/CMapHeader.h" #include "../../lib/mapping/MapFormat.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/TerrainHandler.h" -#include "../../lib/TextOperations.h" bool mapSorter::operator()(const std::shared_ptr aaa, const std::shared_ptr bbb) { diff --git a/client/mainmenu/CCampaignScreen.cpp b/client/mainmenu/CCampaignScreen.cpp index 16ae03a8a..6da71e9c7 100644 --- a/client/mainmenu/CCampaignScreen.cpp +++ b/client/mainmenu/CCampaignScreen.cpp @@ -31,7 +31,7 @@ #include "../windows/CWindowObject.h" #include "../../lib/filesystem/Filesystem.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CArtHandler.h" #include "../../lib/CBuildingHandler.h" diff --git a/client/mainmenu/CHighScoreScreen.cpp b/client/mainmenu/CHighScoreScreen.cpp index 6b572ae74..fb70d983c 100644 --- a/client/mainmenu/CHighScoreScreen.cpp +++ b/client/mainmenu/CHighScoreScreen.cpp @@ -27,12 +27,11 @@ #include "../render/IRenderHandler.h" #include "../CGameInfo.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/CConfigHandler.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/constants/EntityIdentifiers.h" -#include "../../lib/TextOperations.h" -#include "../../lib/Languages.h" auto HighScoreCalculation::calculate() { diff --git a/client/mainmenu/CMainMenu.cpp b/client/mainmenu/CMainMenu.cpp index b464f5dc4..556caba4d 100644 --- a/client/mainmenu/CMainMenu.cpp +++ b/client/mainmenu/CMainMenu.cpp @@ -45,7 +45,7 @@ #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/campaign/CampaignHandler.h" #include "../../lib/serializer/CTypeList.h" #include "../../lib/filesystem/Filesystem.h" diff --git a/client/mapView/mapHandler.cpp b/client/mapView/mapHandler.cpp index f535fa61d..bd19e421a 100644 --- a/client/mapView/mapHandler.cpp +++ b/client/mapView/mapHandler.cpp @@ -17,7 +17,7 @@ #include "../CPlayerInterface.h" #include "../gui/CGuiHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/TerrainHandler.h" #include "../../lib/mapObjectConstructors/CObjectClassesHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" diff --git a/client/media/CVideoHandler.cpp b/client/media/CVideoHandler.cpp index d32da36bd..6c104c7c8 100644 --- a/client/media/CVideoHandler.cpp +++ b/client/media/CVideoHandler.cpp @@ -23,8 +23,8 @@ #include "../../lib/filesystem/CInputStream.h" #include "../../lib/filesystem/Filesystem.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/Languages.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/Languages.h" #include diff --git a/client/render/Graphics.cpp b/client/render/Graphics.cpp index a42a90c5b..64c6e2b7f 100644 --- a/client/render/Graphics.cpp +++ b/client/render/Graphics.cpp @@ -35,7 +35,7 @@ #include "CGameInfo.h" #include "../lib/VCMI_Lib.h" #include "../CCallback.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/vcmi_endian.h" #include "../lib/CStopWatch.h" #include "../lib/CHeroHandler.h" diff --git a/client/render/IFont.cpp b/client/render/IFont.cpp index 5cc60928b..e01e8e80a 100644 --- a/client/render/IFont.cpp +++ b/client/render/IFont.cpp @@ -12,7 +12,7 @@ #include "IFont.h" #include "../../lib/Point.h" -#include "../../lib/TextOperations.h" +#include "../../lib/texts/TextOperations.h" size_t IFont::getStringWidth(const std::string & data) const { diff --git a/client/renderSDL/CBitmapFont.cpp b/client/renderSDL/CBitmapFont.cpp index 9b755680d..d3ed5bb55 100644 --- a/client/renderSDL/CBitmapFont.cpp +++ b/client/renderSDL/CBitmapFont.cpp @@ -14,11 +14,11 @@ #include "../CGameInfo.h" #include "../render/Colors.h" -#include "../../lib/Languages.h" #include "../../lib/Rect.h" -#include "../../lib/TextOperations.h" #include "../../lib/filesystem/Filesystem.h" #include "../../lib/modding/CModHandler.h" +#include "../../lib/texts/Languages.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/vcmi_endian.h" #include "../../lib/VCMI_Lib.h" diff --git a/client/renderSDL/CBitmapHanFont.cpp b/client/renderSDL/CBitmapHanFont.cpp index 5476d823f..d85d0ebcd 100644 --- a/client/renderSDL/CBitmapHanFont.cpp +++ b/client/renderSDL/CBitmapHanFont.cpp @@ -15,8 +15,8 @@ #include "../../lib/filesystem/Filesystem.h" #include "../../lib/json/JsonNode.h" -#include "../../lib/TextOperations.h" #include "../../lib/Rect.h" +#include "../../lib/texts/TextOperations.h" #include diff --git a/client/renderSDL/CTrueTypeFont.cpp b/client/renderSDL/CTrueTypeFont.cpp index e977a6c4c..0aa78d914 100644 --- a/client/renderSDL/CTrueTypeFont.cpp +++ b/client/renderSDL/CTrueTypeFont.cpp @@ -15,9 +15,9 @@ #include "../render/Colors.h" #include "../renderSDL/SDL_Extensions.h" -#include "../../lib/TextOperations.h" #include "../../lib/json/JsonNode.h" #include "../../lib/filesystem/Filesystem.h" +#include "../../lib/texts/TextOperations.h" #include diff --git a/client/widgets/Buttons.cpp b/client/widgets/Buttons.cpp index 2d786ac0a..d35a2b513 100644 --- a/client/widgets/Buttons.cpp +++ b/client/widgets/Buttons.cpp @@ -28,7 +28,7 @@ #include "../render/IRenderHandler.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/filesystem/Filesystem.h" void ButtonBase::update() diff --git a/client/widgets/CArtPlace.cpp b/client/widgets/CArtPlace.cpp index 520efd1be..d4d57d785 100644 --- a/client/widgets/CArtPlace.cpp +++ b/client/widgets/CArtPlace.cpp @@ -23,7 +23,7 @@ #include "../CGameInfo.h" #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/ArtifactUtils.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/networkPacks/ArtifactLocation.h" diff --git a/client/widgets/CComponent.cpp b/client/widgets/CComponent.cpp index 5d3497840..e1c28918b 100644 --- a/client/widgets/CComponent.cpp +++ b/client/widgets/CComponent.cpp @@ -34,7 +34,7 @@ #include "../../lib/spells/CSpellHandler.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/CSkillHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CArtHandler.h" #include "../../lib/CArtifactInstance.h" diff --git a/client/widgets/CGarrisonInt.cpp b/client/widgets/CGarrisonInt.cpp index 667cfdc22..deda14514 100644 --- a/client/widgets/CGarrisonInt.cpp +++ b/client/widgets/CGarrisonInt.cpp @@ -26,12 +26,12 @@ #include "../../CCallback.h" #include "../../lib/ArtifactUtils.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/CConfigHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/networkPacks/ArtifactLocation.h" -#include "../../lib/TextOperations.h" #include "../../lib/gameState/CGameState.h" void CGarrisonSlot::setHighlight(bool on) diff --git a/client/widgets/CTextInput.cpp b/client/widgets/CTextInput.cpp index 46d824665..4fa9c345e 100644 --- a/client/widgets/CTextInput.cpp +++ b/client/widgets/CTextInput.cpp @@ -18,7 +18,7 @@ #include "../render/Graphics.h" #include "../render/IFont.h" -#include "../../lib/TextOperations.h" +#include "../../lib/texts/TextOperations.h" std::list CFocusable::focusables; CFocusable * CFocusable::inputWithFocus; diff --git a/client/widgets/Images.cpp b/client/widgets/Images.cpp index 35218477e..cd75c6620 100644 --- a/client/widgets/Images.cpp +++ b/client/widgets/Images.cpp @@ -29,7 +29,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" //for Unicode related stuff +#include "../../lib/texts/CGeneralTextHandler.h" //for Unicode related stuff #include "../../lib/CRandomGenerator.h" CPicture::CPicture(std::shared_ptr image, const Point & position) diff --git a/client/widgets/MiscWidgets.cpp b/client/widgets/MiscWidgets.cpp index 81f1da476..6718059d8 100644 --- a/client/widgets/MiscWidgets.cpp +++ b/client/widgets/MiscWidgets.cpp @@ -33,12 +33,12 @@ #include "../../lib/CConfigHandler.h" #include "../../lib/gameState/InfoAboutArmy.h" -#include "../../lib/CGeneralTextHandler.h" #include "../../lib/GameSettings.h" -#include "../../lib/TextOperations.h" #include "../../lib/mapObjects/CGCreature.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGTownInstance.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" void CHoverableArea::hover (bool on) { diff --git a/client/widgets/RadialMenu.cpp b/client/widgets/RadialMenu.cpp index ea8743b91..b4242cbf7 100644 --- a/client/widgets/RadialMenu.cpp +++ b/client/widgets/RadialMenu.cpp @@ -19,7 +19,7 @@ #include "../render/IImage.h" #include "../CGameInfo.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" RadialMenuItem::RadialMenuItem(const std::string & imageName, const std::string & hoverText, const std::function & callback, bool alternativeLayout) : callback(callback) diff --git a/client/widgets/TextControls.cpp b/client/widgets/TextControls.cpp index c7864db13..82e022429 100644 --- a/client/widgets/TextControls.cpp +++ b/client/widgets/TextControls.cpp @@ -23,7 +23,7 @@ #include "../render/Graphics.h" #include "../render/IFont.h" -#include "../../lib/TextOperations.h" +#include "../../lib/texts/TextOperations.h" #ifdef VCMI_ANDROID #include "lib/CAndroidVMHelper.h" diff --git a/client/widgets/markets/CAltarArtifacts.cpp b/client/widgets/markets/CAltarArtifacts.cpp index cf3f9285c..5d169c2bc 100644 --- a/client/widgets/markets/CAltarArtifacts.cpp +++ b/client/widgets/markets/CAltarArtifacts.cpp @@ -22,7 +22,7 @@ #include "../../../CCallback.h" #include "../../../lib/networkPacks/ArtifactLocation.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" diff --git a/client/widgets/markets/CAltarCreatures.cpp b/client/widgets/markets/CAltarCreatures.cpp index 033f53a3f..a6d808937 100644 --- a/client/widgets/markets/CAltarCreatures.cpp +++ b/client/widgets/markets/CAltarCreatures.cpp @@ -21,10 +21,9 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" -#include "../../../lib/MetaString.h" CAltarCreatures::CAltarCreatures(const IMarket * market, const CGHeroInstance * hero) : CMarketBase(market, hero) diff --git a/client/widgets/markets/CArtifactsBuying.cpp b/client/widgets/markets/CArtifactsBuying.cpp index 4bb558ff5..bb967e374 100644 --- a/client/widgets/markets/CArtifactsBuying.cpp +++ b/client/widgets/markets/CArtifactsBuying.cpp @@ -21,7 +21,7 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" #include "../../../lib/mapObjects/CGTownInstance.h" diff --git a/client/widgets/markets/CArtifactsSelling.cpp b/client/widgets/markets/CArtifactsSelling.cpp index 3d2883d2b..3b1d64dd0 100644 --- a/client/widgets/markets/CArtifactsSelling.cpp +++ b/client/widgets/markets/CArtifactsSelling.cpp @@ -22,7 +22,7 @@ #include "../../../CCallback.h" #include "../../../lib/CArtifactInstance.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" #include "../../../lib/mapObjects/CGTownInstance.h" diff --git a/client/widgets/markets/CFreelancerGuild.cpp b/client/widgets/markets/CFreelancerGuild.cpp index 095a75dcd..e3544968b 100644 --- a/client/widgets/markets/CFreelancerGuild.cpp +++ b/client/widgets/markets/CFreelancerGuild.cpp @@ -21,8 +21,7 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" -#include "../../../lib/MetaString.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/mapObjects/CGMarket.h" diff --git a/client/widgets/markets/CMarketBase.cpp b/client/widgets/markets/CMarketBase.cpp index 888c42aac..d18021d61 100644 --- a/client/widgets/markets/CMarketBase.cpp +++ b/client/widgets/markets/CMarketBase.cpp @@ -23,7 +23,7 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../../../lib/CHeroHandler.h" #include "../../../lib/mapObjects/CGMarket.h" diff --git a/client/widgets/markets/CMarketResources.cpp b/client/widgets/markets/CMarketResources.cpp index b7b0a4eac..9b3696ca8 100644 --- a/client/widgets/markets/CMarketResources.cpp +++ b/client/widgets/markets/CMarketResources.cpp @@ -21,8 +21,7 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" -#include "../../../lib/MetaString.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGMarket.h" CMarketResources::CMarketResources(const IMarket * market, const CGHeroInstance * hero) diff --git a/client/widgets/markets/CTransferResources.cpp b/client/widgets/markets/CTransferResources.cpp index fc7b5f360..f8dbe8ae5 100644 --- a/client/widgets/markets/CTransferResources.cpp +++ b/client/widgets/markets/CTransferResources.cpp @@ -21,8 +21,8 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" -#include "../../../lib/MetaString.h" +#include "../../../lib/texts/CGeneralTextHandler.h" +#include "../../../lib/texts/MetaString.h" CTransferResources::CTransferResources(const IMarket * market, const CGHeroInstance * hero) : CMarketBase(market, hero) diff --git a/client/widgets/markets/TradePanels.cpp b/client/widgets/markets/TradePanels.cpp index 26c43941d..64ce3d172 100644 --- a/client/widgets/markets/TradePanels.cpp +++ b/client/widgets/markets/TradePanels.cpp @@ -20,7 +20,7 @@ #include "../../../CCallback.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/mapObjects/CGHeroInstance.h" CTradeableItem::CTradeableItem(const Rect & area, EType Type, int ID, int Serial) diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index bb2fe18c0..5d9585877 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -46,7 +46,7 @@ #include "../../lib/CConfigHandler.h" #include "../../lib/CSoundBase.h" #include "../../lib/CCreatureHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/GameSettings.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/CTownHandler.h" diff --git a/client/windows/CCreatureWindow.cpp b/client/windows/CCreatureWindow.cpp index 3dafa0e81..e33503ab3 100644 --- a/client/windows/CCreatureWindow.cpp +++ b/client/windows/CCreatureWindow.cpp @@ -30,12 +30,12 @@ #include "../../lib/ArtifactUtils.h" #include "../../lib/CStack.h" #include "../../lib/CBonusTypeHandler.h" -#include "../../lib/CGeneralTextHandler.h" #include "../../lib/GameSettings.h" #include "../../lib/CHeroHandler.h" #include "../../lib/gameState/CGameState.h" #include "../../lib/networkPacks/ArtifactLocation.h" -#include "../../lib/TextOperations.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" class CCreatureArtifactInstance; class CSelectableSkill; diff --git a/client/windows/CExchangeWindow.cpp b/client/windows/CExchangeWindow.cpp index 6d0fca66e..deb147983 100644 --- a/client/windows/CExchangeWindow.cpp +++ b/client/windows/CExchangeWindow.cpp @@ -29,12 +29,12 @@ #include "../../CCallback.h" -#include "../lib/mapObjects/CGHeroInstance.h" -#include "../lib/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" -#include "../lib/filesystem/Filesystem.h" #include "../lib/CSkillHandler.h" -#include "../lib/TextOperations.h" +#include "../lib/filesystem/Filesystem.h" +#include "../lib/mapObjects/CGHeroInstance.h" +#include "../lib/texts/CGeneralTextHandler.h" +#include "../lib/texts/TextOperations.h" static const std::string QUICK_EXCHANGE_BG = "quick-exchange/TRADEQE"; diff --git a/client/windows/CHeroOverview.cpp b/client/windows/CHeroOverview.cpp index 563bf9644..d76b3b926 100644 --- a/client/windows/CHeroOverview.cpp +++ b/client/windows/CHeroOverview.cpp @@ -22,7 +22,7 @@ #include "../widgets/GraphicalPrimitiveCanvas.h" #include "../../lib/GameSettings.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CCreatureHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/CSkillHandler.h" diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 36701a63a..16b08af5d 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -35,7 +35,7 @@ #include "../lib/ArtifactUtils.h" #include "../lib/CArtHandler.h" #include "../lib/CConfigHandler.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CSkillHandler.h" #include "../lib/mapObjects/CGHeroInstance.h" diff --git a/client/windows/CKingdomInterface.cpp b/client/windows/CKingdomInterface.cpp index 46feda7ef..3dc18c846 100644 --- a/client/windows/CKingdomInterface.cpp +++ b/client/windows/CKingdomInterface.cpp @@ -33,7 +33,7 @@ #include "../../lib/CConfigHandler.h" #include "../../lib/CCreatureHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CHeroHandler.h" #include "../../lib/GameSettings.h" #include "../../lib/CSkillHandler.h" diff --git a/client/windows/CMapOverview.cpp b/client/windows/CMapOverview.cpp index eb9a2c6f5..d205a7eab 100644 --- a/client/windows/CMapOverview.cpp +++ b/client/windows/CMapOverview.cpp @@ -25,8 +25,6 @@ #include "../render/IRenderHandler.h" #include "../render/Graphics.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/TextOperations.h" #include "../../lib/CConfigHandler.h" #include "../../lib/campaign/CampaignState.h" #include "../../lib/mapping/CMap.h" @@ -37,10 +35,11 @@ #include "../../lib/TerrainHandler.h" #include "../../lib/filesystem/Filesystem.h" -#include "../../lib/serializer/CLoadFile.h" #include "../../lib/StartInfo.h" #include "../../lib/rmg/CMapGenOptions.h" -#include "../../lib/Languages.h" +#include "../../lib/serializer/CLoadFile.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/TextOperations.h" CMapOverview::CMapOverview(std::string mapName, std::string fileName, std::string date, std::string author, std::string version, ResourcePath resource, ESelectionScreen tabType) : CWindowObject(BORDERED | RCLICK_POPUP), resource(resource), mapName(mapName), fileName(fileName), date(date), author(author), version(version), tabType(tabType) diff --git a/client/windows/CMarketWindow.cpp b/client/windows/CMarketWindow.cpp index 2789f3ca8..8568a0536 100644 --- a/client/windows/CMarketWindow.cpp +++ b/client/windows/CMarketWindow.cpp @@ -27,7 +27,7 @@ #include "../CGameInfo.h" #include "../CPlayerInterface.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapObjects/CGMarket.h" #include "../../lib/mapObjects/CGHeroInstance.h" diff --git a/client/windows/CMessage.cpp b/client/windows/CMessage.cpp index 5cf0dd3a7..140f00993 100644 --- a/client/windows/CMessage.cpp +++ b/client/windows/CMessage.cpp @@ -11,8 +11,6 @@ #include "StdInc.h" #include "CMessage.h" -#include "../../lib/TextOperations.h" - #include "../gui/CGuiHandler.h" #include "../render/CAnimation.h" #include "../render/Canvas.h" @@ -27,6 +25,8 @@ #include "../widgets/TextControls.h" #include "../windows/InfoWindows.h" +#include "../../lib/texts/TextOperations.h" + constexpr int RIGHT_CLICK_POPUP_MIN_SIZE = 100; constexpr int SIDE_MARGIN = 11; constexpr int TOP_MARGIN = 20; diff --git a/client/windows/CPuzzleWindow.cpp b/client/windows/CPuzzleWindow.cpp index d234e0e95..4a192065c 100644 --- a/client/windows/CPuzzleWindow.cpp +++ b/client/windows/CPuzzleWindow.cpp @@ -23,7 +23,7 @@ #include "../widgets/TextControls.h" #include "../../CCallback.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CTownHandler.h" #include "../../lib/StartInfo.h" diff --git a/client/windows/CQuestLog.cpp b/client/windows/CQuestLog.cpp index d0daf0a2b..ede1e71be 100644 --- a/client/windows/CQuestLog.cpp +++ b/client/windows/CQuestLog.cpp @@ -27,8 +27,7 @@ #include "../../lib/CArtHandler.h" #include "../../lib/CConfigHandler.h" #include "../../lib/gameState/QuestInfo.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/MetaString.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CQuest.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/client/windows/CSpellWindow.cpp b/client/windows/CSpellWindow.cpp index d3274c304..a14adcb60 100644 --- a/client/windows/CSpellWindow.cpp +++ b/client/windows/CSpellWindow.cpp @@ -38,7 +38,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/spells/CSpellHandler.h" #include "../../lib/spells/ISpellMechanics.h" #include "../../lib/spells/Problem.h" diff --git a/client/windows/CTutorialWindow.cpp b/client/windows/CTutorialWindow.cpp index a53cb7de4..43307e4da 100644 --- a/client/windows/CTutorialWindow.cpp +++ b/client/windows/CTutorialWindow.cpp @@ -13,7 +13,7 @@ #include "../eventsSDL/InputHandler.h" #include "../../lib/CConfigHandler.h" #include "../ConditionalWait.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../CPlayerInterface.h" #include "../CGameInfo.h" diff --git a/client/windows/CWindowObject.cpp b/client/windows/CWindowObject.cpp index 3909b0d45..9bd406df3 100644 --- a/client/windows/CWindowObject.cpp +++ b/client/windows/CWindowObject.cpp @@ -29,7 +29,7 @@ #include "../../CCallback.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" //for Unicode related stuff +#include "../../lib/texts/CGeneralTextHandler.h" //for Unicode related stuff #include diff --git a/client/windows/CWindowWithArtifacts.cpp b/client/windows/CWindowWithArtifacts.cpp index ec9949a5c..62f6ddcbd 100644 --- a/client/windows/CWindowWithArtifacts.cpp +++ b/client/windows/CWindowWithArtifacts.cpp @@ -29,7 +29,7 @@ #include "../CGameInfo.h" #include "../../lib/ArtifactUtils.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/networkPacks/ArtifactLocation.h" #include "../../lib/CConfigHandler.h" diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 17f73ef91..732068427 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -49,7 +49,7 @@ #include "../lib/gameState/CGameState.h" #include "../lib/gameState/SThievesGuildInfo.h" #include "../lib/gameState/TavernHeroesPool.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/GameSettings.h" #include "ConditionalWait.h" diff --git a/client/windows/settings/BattleOptionsTab.cpp b/client/windows/settings/BattleOptionsTab.cpp index 7c803614e..7d431f4cc 100644 --- a/client/windows/settings/BattleOptionsTab.cpp +++ b/client/windows/settings/BattleOptionsTab.cpp @@ -14,7 +14,7 @@ #include "../../gui/CGuiHandler.h" #include "../../../lib/CConfigHandler.h" #include "../../../lib/filesystem/ResourcePath.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../widgets/Buttons.h" #include "../../widgets/TextControls.h" diff --git a/client/windows/settings/GeneralOptionsTab.cpp b/client/windows/settings/GeneralOptionsTab.cpp index 46f409e1c..09bed3cf2 100644 --- a/client/windows/settings/GeneralOptionsTab.cpp +++ b/client/windows/settings/GeneralOptionsTab.cpp @@ -26,7 +26,7 @@ #include "../../widgets/Slider.h" #include "../../widgets/TextControls.h" -#include "../../../lib/CGeneralTextHandler.h" +#include "../../../lib/texts/CGeneralTextHandler.h" #include "../../../lib/filesystem/ResourcePath.h" static void setIntSetting(std::string group, std::string field, int value) diff --git a/client/windows/settings/SettingsMainWindow.cpp b/client/windows/settings/SettingsMainWindow.cpp index f5c3ab7ac..56339e9a6 100644 --- a/client/windows/settings/SettingsMainWindow.cpp +++ b/client/windows/settings/SettingsMainWindow.cpp @@ -18,7 +18,7 @@ #include "CMT.h" #include "CGameInfo.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "CPlayerInterface.h" #include "CServerHandler.h" #include "filesystem/ResourcePath.h" diff --git a/launcher/firstLaunch/firstlaunch_moc.cpp b/launcher/firstLaunch/firstlaunch_moc.cpp index 98671a681..8f70abae7 100644 --- a/launcher/firstLaunch/firstlaunch_moc.cpp +++ b/launcher/firstLaunch/firstlaunch_moc.cpp @@ -15,8 +15,8 @@ #include "modManager/cmodlistview_moc.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/CGeneralTextHandler.h" -#include "../../lib/Languages.h" +#include "../../lib/texts/CGeneralTextHandler.h" +#include "../../lib/texts/Languages.h" #include "../../lib/VCMIDirs.h" #include "../../lib/filesystem/Filesystem.h" #include "../helper.h" diff --git a/launcher/languages.cpp b/launcher/languages.cpp index d035c4fb1..174f0eb39 100644 --- a/launcher/languages.cpp +++ b/launcher/languages.cpp @@ -11,8 +11,8 @@ #include "languages.h" #include "../lib/CConfigHandler.h" -#include "../lib/Languages.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/Languages.h" +#include "../lib/texts/CGeneralTextHandler.h" #include #include diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index 88b86be46..488d6d73f 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -15,9 +15,9 @@ #include "../lib/CConfigHandler.h" #include "../lib/VCMIDirs.h" -#include "../lib/Languages.h" #include "../lib/filesystem/Filesystem.h" #include "../lib/logging/CBasicLogConfigurator.h" +#include "../lib/texts/Languages.h" #include "updatedialog_moc.h" #include "main.h" diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 0fa415c5e..5c351b366 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -27,7 +27,7 @@ #include "../../lib/VCMIDirs.h" #include "../../lib/CConfigHandler.h" -#include "../../lib/Languages.h" +#include "../../lib/texts/Languages.h" #include "../../lib/modding/CModVersion.h" static double mbToBytes(double mb) diff --git a/lib/CArtHandler.cpp b/lib/CArtHandler.cpp index a15ad071d..f4b2e74ab 100644 --- a/lib/CArtHandler.cpp +++ b/lib/CArtHandler.cpp @@ -11,7 +11,6 @@ #include "StdInc.h" #include "ArtifactUtils.h" -#include "CGeneralTextHandler.h" #include "ExceptionsCommon.h" #include "GameSettings.h" #include "mapObjects/MapObjects.h" @@ -20,6 +19,8 @@ #include "mapObjectConstructors/AObjectTypeHandler.h" #include "mapObjectConstructors/CObjectClassesHandler.h" #include "serializer/JsonSerializeFormat.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" // Note: list must match entries in ArtTraits.txt #define ART_POS_LIST \ diff --git a/lib/CBonusTypeHandler.cpp b/lib/CBonusTypeHandler.cpp index 9fc92572a..799bf2632 100644 --- a/lib/CBonusTypeHandler.cpp +++ b/lib/CBonusTypeHandler.cpp @@ -17,7 +17,7 @@ #include "GameConstants.h" #include "CCreatureHandler.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "json/JsonUtils.h" #include "spells/CSpellHandler.h" #include "VCMI_Lib.h" diff --git a/lib/CCreatureHandler.cpp b/lib/CCreatureHandler.cpp index 7b29e1f6f..35fddfeec 100644 --- a/lib/CCreatureHandler.cpp +++ b/lib/CCreatureHandler.cpp @@ -10,7 +10,6 @@ #include "StdInc.h" #include "CCreatureHandler.h" -#include "CGeneralTextHandler.h" #include "ResourceSet.h" #include "filesystem/Filesystem.h" #include "VCMI_Lib.h" @@ -22,6 +21,8 @@ #include "json/JsonBonus.h" #include "serializer/JsonDeserializer.h" #include "serializer/JsonUpdater.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" #include "mapObjectConstructors/AObjectTypeHandler.h" #include "mapObjectConstructors/CObjectClassesHandler.h" #include "modding/CModHandler.h" diff --git a/lib/CCreatureSet.cpp b/lib/CCreatureSet.cpp index 2a184b8e9..871505875 100644 --- a/lib/CCreatureSet.cpp +++ b/lib/CCreatureSet.cpp @@ -18,7 +18,7 @@ #include "mapObjects/CGHeroInstance.h" #include "modding/ModScope.h" #include "IGameCallback.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "spells/CSpellHandler.h" #include "CHeroHandler.h" #include "IBonusTypeHandler.h" diff --git a/lib/CGameInfoCallback.cpp b/lib/CGameInfoCallback.cpp index 379db73fd..7669da332 100644 --- a/lib/CGameInfoCallback.cpp +++ b/lib/CGameInfoCallback.cpp @@ -19,7 +19,7 @@ #include "mapObjects/CGTownInstance.h" #include "mapObjects/MiscObjects.h" #include "networkPacks/ArtifactLocation.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "StartInfo.h" // for StartInfo #include "battle/BattleInfo.h" // for BattleInfo #include "GameSettings.h" diff --git a/lib/CGeneralTextHandler.h b/lib/CGeneralTextHandler.h deleted file mode 100644 index 02602bdb1..000000000 --- a/lib/CGeneralTextHandler.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * CGeneralTextHandler.h, part of VCMI engine - * - * Authors: listed in file AUTHORS in main folder - * - * License: GNU General Public License v2.0 or later - * Full text of license available in license.txt file, in main folder - * - */ -#pragma once - -#include "filesystem/ResourcePath.h" - -VCMI_LIB_NAMESPACE_BEGIN - -class CInputStream; -class JsonNode; -class JsonSerializeFormat; - -/// Parser for any text files from H3 -class DLL_LINKAGE CLegacyConfigParser -{ - std::string fileEncoding; - - std::unique_ptr data; - char * curr; - char * end; - - /// extracts part of quoted string. - std::string extractQuotedPart(); - - /// extracts quoted string. Any end of lines are ignored, double-quote is considered as "escaping" - std::string extractQuotedString(); - - /// extracts non-quoted string - std::string extractNormalString(); - - /// reads "raw" string without encoding conversion - std::string readRawString(); - -public: - /// read one entry from current line. Return ""/0 if end of line reached - std::string readString(); - float readNumber(); - - template - std::vector readNumArray(size_t size) - { - std::vector ret; - ret.reserve(size); - while (size--) - ret.push_back((numeric)readNumber()); - return ret; - } - - /// returns true if next entry is empty - bool isNextEntryEmpty() const; - - /// end current line - bool endLine(); - - explicit CLegacyConfigParser(const TextPath & URI); -}; - -class CGeneralTextHandler; - -/// Small wrapper that provides text access API compatible with old code -class DLL_LINKAGE LegacyTextContainer -{ - CGeneralTextHandler & owner; - std::string basePath; - -public: - LegacyTextContainer(CGeneralTextHandler & owner, std::string basePath); - std::string operator [](size_t index) const; -}; - -/// Small wrapper that provides help text access API compatible with old code -class DLL_LINKAGE LegacyHelpContainer -{ - CGeneralTextHandler & owner; - std::string basePath; - -public: - LegacyHelpContainer(CGeneralTextHandler & owner, std::string basePath); - std::pair operator[](size_t index) const; -}; - -class TextIdentifier -{ - std::string identifier; -public: - const std::string & get() const - { - return identifier; - } - - TextIdentifier(const char * id): - identifier(id) - {} - - TextIdentifier(const std::string & id): - identifier(id) - {} - - template - TextIdentifier(const std::string & id, size_t index, T... rest): - TextIdentifier(id + '.' + std::to_string(index), rest...) - {} - - template - TextIdentifier(const std::string & id, const std::string & id2, T... rest): - TextIdentifier(id + '.' + id2, rest...) - {} -}; - -class DLL_LINKAGE TextLocalizationContainer -{ -protected: - static std::recursive_mutex globalTextMutex; - - struct StringState - { - /// Human-readable string that was added on registration - std::string baseValue; - - /// Language of base string - std::string baseLanguage; - - /// Translated human-readable string - std::string overrideValue; - - /// Language of the override string - std::string overrideLanguage; - - /// ID of mod that created this string - std::string modContext; - - template - void serialize(Handler & h) - { - h & baseValue; - h & baseLanguage; - h & modContext; - } - }; - - /// map identifier -> localization - std::unordered_map stringsLocalizations; - - std::vector subContainers; - - /// add selected string to internal storage as high-priority strings - void registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized); - - std::string getModLanguage(const std::string & modContext); - - // returns true if identifier with such name was registered, even if not translated to current language - bool identifierExists(const TextIdentifier & UID) const; - -public: - /// validates translation of specified language for specified mod - /// returns true if localization is valid and complete - /// any error messages will be written to log file - bool validateTranslation(const std::string & language, const std::string & modContext, JsonNode const & file) const; - - /// Loads translation from provided json - /// Any entries loaded by this will have priority over texts registered normally - void loadTranslationOverrides(const std::string & language, const std::string & modContext, JsonNode const & file); - - /// add selected string to internal storage - void registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized); - void registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized, const std::string & language); - - /// returns translated version of a string that can be displayed to user - template - std::string translate(std::string arg1, Args ... args) const - { - TextIdentifier id(arg1, args ...); - return deserialize(id); - } - - /// converts identifier into user-readable string - const std::string & deserialize(const TextIdentifier & identifier) const; - - /// Debug method, returns all currently stored texts - /// Format: [mod ID][string ID] -> human-readable text - void exportAllTexts(std::map> & storage) const; - - /// Add or override subcontainer which can store identifiers - void addSubContainer(const TextLocalizationContainer & container); - - /// Remove subcontainer with give name - void removeSubContainer(const TextLocalizationContainer & container); - - void jsonSerialize(JsonNode & dest) const; - - template - void serialize(Handler & h) - { - std::lock_guard globalLock(globalTextMutex); - - if (h.version >= Handler::Version::SIMPLE_TEXT_CONTAINER_SERIALIZATION) - { - h & stringsLocalizations; - } - else - { - std::string key; - int64_t sz = stringsLocalizations.size(); - - if (h.version >= Handler::Version::REMOVE_TEXT_CONTAINER_SIZE_T) - { - int64_t size = sz; - h & size; - sz = size; - } - else - { - h & sz; - } - - if(h.saving) - { - for(auto s : stringsLocalizations) - { - key = s.first; - h & key; - h & s.second; - } - } - else - { - for(size_t i = 0; i < sz; ++i) - { - h & key; - h & stringsLocalizations[key]; - } - } - } - } -}; - -class DLL_LINKAGE TextContainerRegistrable : public TextLocalizationContainer -{ -public: - TextContainerRegistrable(); - ~TextContainerRegistrable(); - - TextContainerRegistrable(const TextContainerRegistrable & other); - TextContainerRegistrable(TextContainerRegistrable && other) noexcept; - - TextContainerRegistrable& operator=(const TextContainerRegistrable & b) = default; -}; - -/// Handles all text-related data in game -class DLL_LINKAGE CGeneralTextHandler: public TextLocalizationContainer -{ - void readToVector(const std::string & sourceID, const std::string & sourceName); - - /// number of scenarios in specific campaign. TODO: move to a better location - std::vector scenariosCountPerCampaign; - -public: - LegacyTextContainer allTexts; - - LegacyTextContainer arraytxt; - LegacyTextContainer primarySkillNames; - LegacyTextContainer jktexts; - LegacyTextContainer heroscrn; - LegacyTextContainer overview;//text for Kingdom Overview window - LegacyTextContainer colors; //names of player colors ("red",...) - LegacyTextContainer capColors; //names of player colors with first letter capitalized ("Red",...) - LegacyTextContainer turnDurations; //turn durations for pregame (1 Minute ... Unlimited) - - //towns - LegacyTextContainer tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen - LegacyTextContainer tavernInfo; - LegacyTextContainer tavernRumors; - - LegacyTextContainer qeModCommands; - - LegacyHelpContainer zelp; - LegacyTextContainer lossConditions; - LegacyTextContainer victoryConditions; - - //objects - LegacyTextContainer advobtxt; - LegacyTextContainer restypes; //names of resources - LegacyTextContainer randsign; - LegacyTextContainer seerEmpty; - LegacyTextContainer seerNames; - LegacyTextContainer tentColors; - - //sec skills - LegacyTextContainer levels; - //commanders - LegacyTextContainer znpc00; //more or less useful content of that file - - std::vector findStringsWithPrefix(const std::string & prefix); - - int32_t pluralText(int32_t textIndex, int32_t count) const; - - size_t getCampaignLength(size_t campaignID) const; - - CGeneralTextHandler(); - CGeneralTextHandler(const CGeneralTextHandler&) = delete; - CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete; - - /// Attempts to detect encoding & language of H3 files - static void detectInstallParameters(); - - /// Returns name of language preferred by user - static std::string getPreferredLanguage(); - - /// Returns name of language of Heroes III text files - static std::string getInstalledLanguage(); - - /// Returns name of encoding of Heroes III text files - static std::string getInstalledEncoding(); -}; - -VCMI_LIB_NAMESPACE_END diff --git a/lib/CHeroHandler.cpp b/lib/CHeroHandler.cpp index b2bdc41b9..d76907852 100644 --- a/lib/CHeroHandler.cpp +++ b/lib/CHeroHandler.cpp @@ -10,7 +10,6 @@ #include "StdInc.h" #include "CHeroHandler.h" -#include "CGeneralTextHandler.h" #include "filesystem/Filesystem.h" #include "VCMI_Lib.h" #include "constants/StringConstants.h" @@ -27,6 +26,8 @@ #include "mapObjectConstructors/AObjectTypeHandler.h" #include "mapObjectConstructors/CObjectClassesHandler.h" #include "modding/IdentifierStorage.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" #include diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4b84c8411..fd6c1aa23 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -30,13 +30,14 @@ set(lib_SRCS network/NetworkHandler.cpp network/NetworkServer.cpp + texts/TextOperations.cpp + vstd/DateUtils.cpp vstd/StringUtils.cpp CConfigHandler.cpp CConsoleHandler.cpp CThreadHelper.cpp - TextOperations.cpp VCMIDirs.cpp ) @@ -241,6 +242,11 @@ set(lib_MAIN_SRCS spells/effects/RemoveObstacle.cpp spells/effects/Sacrifice.cpp + texts/CGeneralTextHandler.cpp + texts/CLegacyConfigParser.cpp + texts/MetaString.cpp + texts/TextLocalizationContainer.cpp + ArtifactUtils.cpp BasicTypes.cpp BattleFieldHandler.cpp @@ -253,7 +259,6 @@ set(lib_MAIN_SRCS CCreatureSet.cpp CGameInfoCallback.cpp CGameInterface.cpp - CGeneralTextHandler.cpp CHeroHandler.cpp CPlayerState.cpp CRandomGenerator.cpp @@ -266,7 +271,6 @@ set(lib_MAIN_SRCS IHandlerBase.cpp LoadProgress.cpp LogicalExpression.cpp - MetaString.cpp ObstacleHandler.cpp StartInfo.cpp ResourceSet.cpp @@ -335,10 +339,11 @@ set(lib_HEADERS network/NetworkInterface.h network/NetworkServer.h + texts/TextOperations.h + CConfigHandler.h CConsoleHandler.h CThreadHelper.h - TextOperations.h VCMIDirs.h ) @@ -639,6 +644,13 @@ set(lib_MAIN_HEADERS spells/effects/RemoveObstacle.h spells/effects/Sacrifice.h + texts/CGeneralTextHandler.h + texts/Languages.h + texts/CLegacyConfigParser.h + texts/MetaString.h + texts/TextIdentifier.h + texts/TextLocalizationContainer.h + AI_Base.h ArtifactUtils.h BattleFieldHandler.h @@ -651,7 +663,6 @@ set(lib_MAIN_HEADERS CCreatureSet.h CGameInfoCallback.h CGameInterface.h - CGeneralTextHandler.h CHeroHandler.h ConstTransitivePtr.h Color.h @@ -674,10 +685,8 @@ set(lib_MAIN_HEADERS IGameEventsReceiver.h IHandlerBase.h int3.h - Languages.h LoadProgress.h LogicalExpression.h - MetaString.h ObstacleHandler.h Point.h Rect.h diff --git a/lib/CPlayerState.cpp b/lib/CPlayerState.cpp index 2ac3e39db..82f0a0a89 100644 --- a/lib/CPlayerState.cpp +++ b/lib/CPlayerState.cpp @@ -11,7 +11,7 @@ #include "CPlayerState.h" #include "gameState/QuestInfo.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "VCMI_Lib.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/CSkillHandler.cpp b/lib/CSkillHandler.cpp index 4b041368f..d3e955f8c 100644 --- a/lib/CSkillHandler.cpp +++ b/lib/CSkillHandler.cpp @@ -14,14 +14,16 @@ #include "CSkillHandler.h" -#include "CGeneralTextHandler.h" +#include "constants/StringConstants.h" #include "filesystem/Filesystem.h" #include "json/JsonBonus.h" #include "json/JsonUtils.h" #include "modding/IdentifierStorage.h" #include "modding/ModUtility.h" #include "modding/ModScope.h" -#include "constants/StringConstants.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" +#include "texts/TextOperations.h" #include "VCMI_Lib.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/CStack.cpp b/lib/CStack.cpp index 21747bfd2..fde17490c 100644 --- a/lib/CStack.cpp +++ b/lib/CStack.cpp @@ -15,7 +15,7 @@ #include #include -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "battle/BattleInfo.h" #include "spells/CSpellHandler.h" #include "networkPacks/PacksForClientBattle.h" diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 2c118d1f2..f82b8717b 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -11,7 +11,6 @@ #include "CTownHandler.h" #include "VCMI_Lib.h" -#include "CGeneralTextHandler.h" #include "constants/StringConstants.h" #include "CCreatureHandler.h" #include "CHeroHandler.h" @@ -28,6 +27,8 @@ #include "mapObjectConstructors/CObjectClassesHandler.h" #include "modding/IdentifierStorage.h" #include "modding/ModScope.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/LogicalExpression.cpp b/lib/LogicalExpression.cpp index 2b1a8cb5a..1caacaef4 100644 --- a/lib/LogicalExpression.cpp +++ b/lib/LogicalExpression.cpp @@ -12,7 +12,7 @@ #include "LogicalExpression.h" #include "VCMI_Lib.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/RiverHandler.cpp b/lib/RiverHandler.cpp index b000e8427..d12dcf317 100644 --- a/lib/RiverHandler.cpp +++ b/lib/RiverHandler.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "RiverHandler.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "GameSettings.h" #include "json/JsonNode.h" #include "VCMI_Lib.h" diff --git a/lib/RoadHandler.cpp b/lib/RoadHandler.cpp index fbcee0653..a77c4d625 100644 --- a/lib/RoadHandler.cpp +++ b/lib/RoadHandler.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "RoadHandler.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "GameSettings.h" #include "json/JsonNode.h" #include "VCMI_Lib.h" diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index 6acb048f8..61f30d44e 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "StartInfo.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "CTownHandler.h" #include "CHeroHandler.h" #include "VCMI_Lib.h" diff --git a/lib/TerrainHandler.cpp b/lib/TerrainHandler.cpp index 13789cacf..3b9aa3897 100644 --- a/lib/TerrainHandler.cpp +++ b/lib/TerrainHandler.cpp @@ -10,10 +10,11 @@ #include "StdInc.h" #include "TerrainHandler.h" -#include "CGeneralTextHandler.h" #include "GameSettings.h" #include "json/JsonNode.h" #include "modding/IdentifierStorage.h" +#include "texts/CGeneralTextHandler.h" +#include "texts/CLegacyConfigParser.h" #include "VCMI_Lib.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/VCMI_Lib.cpp b/lib/VCMI_Lib.cpp index 6a1a84fd6..2c0c90120 100644 --- a/lib/VCMI_Lib.cpp +++ b/lib/VCMI_Lib.cpp @@ -24,7 +24,7 @@ #include "spells/CSpellHandler.h" #include "spells/effects/Registry.h" #include "CSkillHandler.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "modding/CModHandler.h" #include "modding/CModInfo.h" #include "modding/IdentifierStorage.h" diff --git a/lib/battle/BattleInfo.cpp b/lib/battle/BattleInfo.cpp index 3ecb0bb83..4f4a1b3cf 100644 --- a/lib/battle/BattleInfo.cpp +++ b/lib/battle/BattleInfo.cpp @@ -16,7 +16,7 @@ #include "../CHeroHandler.h" #include "../filesystem/Filesystem.h" #include "../mapObjects/CGTownInstance.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../BattleFieldHandler.h" #include "../ObstacleHandler.h" diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index a8cb3737f..c96dc721c 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -14,7 +14,6 @@ #include #include "../CCreatureHandler.h" -#include "../MetaString.h" #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" diff --git a/lib/battle/Unit.cpp b/lib/battle/Unit.cpp index c08713f43..3ad33e95b 100644 --- a/lib/battle/Unit.cpp +++ b/lib/battle/Unit.cpp @@ -12,8 +12,7 @@ #include "Unit.h" #include "../VCMI_Lib.h" -#include "../CGeneralTextHandler.h" -#include "../MetaString.h" +#include "../texts/CGeneralTextHandler.h" #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" diff --git a/lib/bonuses/Bonus.cpp b/lib/bonuses/Bonus.cpp index e82b6eb13..33fa26648 100644 --- a/lib/bonuses/Bonus.cpp +++ b/lib/bonuses/Bonus.cpp @@ -20,7 +20,7 @@ #include "../CCreatureSet.h" #include "../CHeroHandler.h" #include "../CTownHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CSkillHandler.h" #include "../CArtHandler.h" #include "../TerrainHandler.h" diff --git a/lib/bonuses/Bonus.h b/lib/bonuses/Bonus.h index a03e193b0..2812b53b8 100644 --- a/lib/bonuses/Bonus.h +++ b/lib/bonuses/Bonus.h @@ -14,7 +14,7 @@ #include "../constants/VariantIdentifier.h" #include "../constants/EntityIdentifiers.h" #include "../serializer/Serializeable.h" -#include "../MetaString.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/bonuses/Limiters.cpp b/lib/bonuses/Limiters.cpp index e17bf3965..5988f04e0 100644 --- a/lib/bonuses/Limiters.cpp +++ b/lib/bonuses/Limiters.cpp @@ -17,7 +17,7 @@ #include "../CCreatureSet.h" #include "../CHeroHandler.h" #include "../CTownHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CSkillHandler.h" #include "../CStack.h" #include "../CArtHandler.h" diff --git a/lib/campaign/CampaignHandler.cpp b/lib/campaign/CampaignHandler.cpp index 5de4f9c7b..c52555f23 100644 --- a/lib/campaign/CampaignHandler.cpp +++ b/lib/campaign/CampaignHandler.cpp @@ -16,16 +16,16 @@ #include "../filesystem/CCompressedStream.h" #include "../filesystem/CMemoryStream.h" #include "../filesystem/CBinaryReader.h" -#include "../modding/IdentifierStorage.h" #include "../VCMI_Lib.h" -#include "../CGeneralTextHandler.h" -#include "../TextOperations.h" -#include "../Languages.h" #include "../constants/StringConstants.h" #include "../mapping/CMapHeader.h" #include "../mapping/CMapService.h" #include "../modding/CModHandler.h" +#include "../modding/IdentifierStorage.h" #include "../modding/ModScope.h" +#include "../texts/CGeneralTextHandler.h" +#include "../texts/Languages.h" +#include "../texts/TextOperations.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/campaign/CampaignScenarioPrologEpilog.h b/lib/campaign/CampaignScenarioPrologEpilog.h index 8bf9a1aa5..17dc1c506 100644 --- a/lib/campaign/CampaignScenarioPrologEpilog.h +++ b/lib/campaign/CampaignScenarioPrologEpilog.h @@ -10,7 +10,7 @@ #pragma once #include "../filesystem/ResourcePath.h" -#include "../MetaString.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/campaign/CampaignState.cpp b/lib/campaign/CampaignState.cpp index aa1da37e2..e69679f3a 100644 --- a/lib/campaign/CampaignState.cpp +++ b/lib/campaign/CampaignState.cpp @@ -13,7 +13,7 @@ #include "../Point.h" #include "../filesystem/ResourcePath.h" #include "../VCMI_Lib.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../mapping/CMapService.h" #include "../mapping/CMapInfo.h" #include "../mapping/CMap.h" diff --git a/lib/campaign/CampaignState.h b/lib/campaign/CampaignState.h index 231fecef6..9d1a23ced 100644 --- a/lib/campaign/CampaignState.h +++ b/lib/campaign/CampaignState.h @@ -10,10 +10,9 @@ #pragma once #include "../GameConstants.h" -#include "../MetaString.h" #include "../filesystem/ResourcePath.h" #include "../serializer/Serializeable.h" -#include "../CGeneralTextHandler.h" +#include "../texts/TextLocalizationContainer.h" #include "CampaignConstants.h" #include "CampaignScenarioPrologEpilog.h" diff --git a/lib/constants/EntityIdentifiers.cpp b/lib/constants/EntityIdentifiers.cpp index 44ae4d0e3..c055cd0d8 100644 --- a/lib/constants/EntityIdentifiers.cpp +++ b/lib/constants/EntityIdentifiers.cpp @@ -36,7 +36,7 @@ #include "CSkillHandler.h"//todo: remove #include "mapObjectConstructors/AObjectTypeHandler.h" #include "constants/StringConstants.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "TerrainHandler.h" //TODO: remove #include "RiverHandler.h" #include "RoadHandler.h" diff --git a/lib/filesystem/CBinaryReader.cpp b/lib/filesystem/CBinaryReader.cpp index fda958e88..b196baa5f 100644 --- a/lib/filesystem/CBinaryReader.cpp +++ b/lib/filesystem/CBinaryReader.cpp @@ -11,7 +11,6 @@ #include "CBinaryReader.h" #include "CInputStream.h" -#include "../TextOperations.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/gameState/CGameState.cpp b/lib/gameState/CGameState.cpp index cc48de519..3f3207df5 100644 --- a/lib/gameState/CGameState.cpp +++ b/lib/gameState/CGameState.cpp @@ -18,7 +18,7 @@ #include "../ArtifactUtils.h" #include "../CBuildingHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "../CPlayerState.h" #include "../CStopWatch.h" diff --git a/lib/gameState/EVictoryLossCheckResult.h b/lib/gameState/EVictoryLossCheckResult.h index c6f056222..f7860d78d 100644 --- a/lib/gameState/EVictoryLossCheckResult.h +++ b/lib/gameState/EVictoryLossCheckResult.h @@ -9,8 +9,6 @@ */ #pragma once -#include "MetaString.h" - VCMI_LIB_NAMESPACE_BEGIN class DLL_LINKAGE EVictoryLossCheckResult diff --git a/lib/json/JsonBonus.cpp b/lib/json/JsonBonus.cpp index 82c5c485d..64d2c9331 100644 --- a/lib/json/JsonBonus.cpp +++ b/lib/json/JsonBonus.cpp @@ -13,7 +13,7 @@ #include "JsonValidator.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../VCMI_Lib.h" #include "../bonuses/BonusParams.h" #include "../bonuses/Limiters.h" diff --git a/lib/json/JsonParser.cpp b/lib/json/JsonParser.cpp index f3ad1ab9b..eb45d69d8 100644 --- a/lib/json/JsonParser.cpp +++ b/lib/json/JsonParser.cpp @@ -12,7 +12,7 @@ #include "JsonParser.h" #include "../ScopeGuard.h" -#include "../TextOperations.h" +#include "../texts/TextOperations.h" #include "JsonFormatException.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjectConstructors/AObjectTypeHandler.cpp b/lib/mapObjectConstructors/AObjectTypeHandler.cpp index 0871def27..85c2aaef6 100644 --- a/lib/mapObjectConstructors/AObjectTypeHandler.cpp +++ b/lib/mapObjectConstructors/AObjectTypeHandler.cpp @@ -12,7 +12,7 @@ #include "AObjectTypeHandler.h" #include "IObjectInfo.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../VCMI_Lib.h" #include "../json/JsonUtils.h" #include "../modding/IdentifierStorage.h" diff --git a/lib/mapObjectConstructors/CBankInstanceConstructor.cpp b/lib/mapObjectConstructors/CBankInstanceConstructor.cpp index 94e186058..c35a2cf28 100644 --- a/lib/mapObjectConstructors/CBankInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/CBankInstanceConstructor.cpp @@ -11,7 +11,7 @@ #include "CBankInstanceConstructor.h" #include "../json/JsonRandom.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include diff --git a/lib/mapObjectConstructors/CObjectClassesHandler.cpp b/lib/mapObjectConstructors/CObjectClassesHandler.cpp index 736f41d7f..62c429a09 100644 --- a/lib/mapObjectConstructors/CObjectClassesHandler.cpp +++ b/lib/mapObjectConstructors/CObjectClassesHandler.cpp @@ -16,7 +16,6 @@ #include "../VCMI_Lib.h" #include "../GameConstants.h" #include "../constants/StringConstants.h" -#include "../CGeneralTextHandler.h" #include "../GameSettings.h" #include "../CSoundBase.h" @@ -38,6 +37,8 @@ #include "../modding/IdentifierStorage.h" #include "../modding/CModHandler.h" #include "../modding/ModScope.h" +#include "../texts/CGeneralTextHandler.h" +#include "../texts/CLegacyConfigParser.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjectConstructors/CRewardableConstructor.cpp b/lib/mapObjectConstructors/CRewardableConstructor.cpp index 28d98d50a..abe1edb07 100644 --- a/lib/mapObjectConstructors/CRewardableConstructor.cpp +++ b/lib/mapObjectConstructors/CRewardableConstructor.cpp @@ -11,7 +11,7 @@ #include "CRewardableConstructor.h" #include "../mapObjects/CRewardableObject.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjectConstructors/CommonConstructors.cpp b/lib/mapObjectConstructors/CommonConstructors.cpp index 94aade233..85a9c570b 100644 --- a/lib/mapObjectConstructors/CommonConstructors.cpp +++ b/lib/mapObjectConstructors/CommonConstructors.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "CommonConstructors.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "../CTownHandler.h" #include "../IGameCallback.h" diff --git a/lib/mapObjectConstructors/DwellingInstanceConstructor.cpp b/lib/mapObjectConstructors/DwellingInstanceConstructor.cpp index 12c2a0d93..609a57efb 100644 --- a/lib/mapObjectConstructors/DwellingInstanceConstructor.cpp +++ b/lib/mapObjectConstructors/DwellingInstanceConstructor.cpp @@ -11,7 +11,7 @@ #include "DwellingInstanceConstructor.h" #include "../CCreatureHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../json/JsonRandom.h" #include "../VCMI_Lib.h" #include "../mapObjects/CGDwelling.h" diff --git a/lib/mapObjects/CArmedInstance.cpp b/lib/mapObjects/CArmedInstance.cpp index baa2eb56e..5be2d96b0 100644 --- a/lib/mapObjects/CArmedInstance.cpp +++ b/lib/mapObjects/CArmedInstance.cpp @@ -13,10 +13,9 @@ #include "../CTownHandler.h" #include "../CCreatureHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../gameState/CGameState.h" #include "../CPlayerState.h" -#include "../MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/CBank.cpp b/lib/mapObjects/CBank.cpp index cceca0a6f..8ac6fec76 100644 --- a/lib/mapObjects/CBank.cpp +++ b/lib/mapObjects/CBank.cpp @@ -14,7 +14,7 @@ #include #include -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CSoundBase.h" #include "../GameSettings.h" #include "../CPlayerState.h" @@ -24,7 +24,6 @@ #include "../networkPacks/Component.h" #include "../networkPacks/PacksForClient.h" #include "../networkPacks/PacksForClientBattle.h" -#include "../MetaString.h" #include "../IGameCallback.h" #include "../gameState/CGameState.h" diff --git a/lib/mapObjects/CGCreature.cpp b/lib/mapObjects/CGCreature.cpp index 12e6ef77c..94ad2ad84 100644 --- a/lib/mapObjects/CGCreature.cpp +++ b/lib/mapObjects/CGCreature.cpp @@ -12,7 +12,7 @@ #include "CGCreature.h" #include "CGHeroInstance.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CConfigHandler.h" #include "../GameSettings.h" #include "../IGameCallback.h" diff --git a/lib/mapObjects/CGCreature.h b/lib/mapObjects/CGCreature.h index 34374ff49..588e26d0f 100644 --- a/lib/mapObjects/CGCreature.h +++ b/lib/mapObjects/CGCreature.h @@ -11,7 +11,6 @@ #include "CArmedInstance.h" #include "../ResourceSet.h" -#include "../MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/CGHeroInstance.cpp b/lib/mapObjects/CGHeroInstance.cpp index 6d62dd31f..1161fdaa5 100644 --- a/lib/mapObjects/CGHeroInstance.cpp +++ b/lib/mapObjects/CGHeroInstance.cpp @@ -15,7 +15,7 @@ #include #include -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../ArtifactUtils.h" #include "../CHeroHandler.h" #include "../TerrainHandler.h" diff --git a/lib/mapObjects/CGMarket.cpp b/lib/mapObjects/CGMarket.cpp index 3bca00646..d30b210f2 100644 --- a/lib/mapObjects/CGMarket.cpp +++ b/lib/mapObjects/CGMarket.cpp @@ -11,7 +11,7 @@ #include "StdInc.h" #include "CGMarket.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include "../CCreatureHandler.h" #include "CGTownInstance.h" diff --git a/lib/mapObjects/CGObjectInstance.cpp b/lib/mapObjects/CGObjectInstance.cpp index b659c34d1..89c9a88c1 100644 --- a/lib/mapObjects/CGObjectInstance.cpp +++ b/lib/mapObjects/CGObjectInstance.cpp @@ -15,7 +15,7 @@ #include "ObjectTemplate.h" #include "../gameState/CGameState.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include "../constants/StringConstants.h" #include "../TerrainHandler.h" diff --git a/lib/mapObjects/CGTownBuilding.cpp b/lib/mapObjects/CGTownBuilding.cpp index 8e58f1a57..48c56c475 100644 --- a/lib/mapObjects/CGTownBuilding.cpp +++ b/lib/mapObjects/CGTownBuilding.cpp @@ -11,7 +11,7 @@ #include "StdInc.h" #include "CGTownBuilding.h" #include "CGTownInstance.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include "../gameState/CGameState.h" #include "../mapObjects/CGHeroInstance.h" diff --git a/lib/mapObjects/CGTownInstance.cpp b/lib/mapObjects/CGTownInstance.cpp index 35eeecd9f..6da70a328 100644 --- a/lib/mapObjects/CGTownInstance.cpp +++ b/lib/mapObjects/CGTownInstance.cpp @@ -15,7 +15,7 @@ #include "../bonuses/Bonus.h" #include "../battle/IBattleInfoCallback.h" #include "../CConfigHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include "../gameState/CGameState.h" #include "../mapping/CMap.h" diff --git a/lib/mapObjects/CQuest.cpp b/lib/mapObjects/CQuest.cpp index af7fc5bf3..98179cd05 100644 --- a/lib/mapObjects/CQuest.cpp +++ b/lib/mapObjects/CQuest.cpp @@ -15,7 +15,7 @@ #include "../ArtifactUtils.h" #include "../CSoundBase.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "CGCreature.h" #include "../IGameCallback.h" diff --git a/lib/mapObjects/CQuest.h b/lib/mapObjects/CQuest.h index caebee439..281a087ba 100644 --- a/lib/mapObjects/CQuest.h +++ b/lib/mapObjects/CQuest.h @@ -11,8 +11,8 @@ #include "CRewardableObject.h" #include "../ResourceSet.h" -#include "../MetaString.h" #include "../serializer/Serializeable.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/CRewardableObject.cpp b/lib/mapObjects/CRewardableObject.cpp index 80f852c08..416fe93fa 100644 --- a/lib/mapObjects/CRewardableObject.cpp +++ b/lib/mapObjects/CRewardableObject.cpp @@ -11,7 +11,7 @@ #include "StdInc.h" #include "CRewardableObject.h" #include "../gameState/CGameState.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CPlayerState.h" #include "../IGameCallback.h" #include "../mapObjectConstructors/AObjectTypeHandler.h" diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 03e2e1079..1740f9dc3 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -15,7 +15,7 @@ #include "../bonuses/Propagators.h" #include "../constants/StringConstants.h" #include "../CConfigHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CSoundBase.h" #include "../CSkillHandler.h" #include "../spells/CSpellHandler.h" diff --git a/lib/mapObjects/MiscObjects.h b/lib/mapObjects/MiscObjects.h index 0ab01cb18..bdf170b2f 100644 --- a/lib/mapObjects/MiscObjects.h +++ b/lib/mapObjects/MiscObjects.h @@ -10,7 +10,7 @@ #pragma once #include "CArmedInstance.h" -#include "../MetaString.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapObjects/ObjectTemplate.cpp b/lib/mapObjects/ObjectTemplate.cpp index 31d696592..9c32a7566 100644 --- a/lib/mapObjects/ObjectTemplate.cpp +++ b/lib/mapObjects/ObjectTemplate.cpp @@ -15,7 +15,7 @@ #include "../VCMI_Lib.h" #include "../GameConstants.h" #include "../constants/StringConstants.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CLegacyConfigParser.h" #include "../TerrainHandler.h" #include "../mapObjectConstructors/CRewardableConstructor.h" diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index b91e335d3..0b3dfbf6a 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -22,7 +22,7 @@ #include "../mapObjects/CGTownInstance.h" #include "../mapObjects/CQuest.h" #include "../mapObjects/ObjectTemplate.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../spells/CSpellHandler.h" #include "../CSkillHandler.h" #include "CMapEditManager.h" diff --git a/lib/mapping/CMap.h b/lib/mapping/CMap.h index 5a56e984d..772520192 100644 --- a/lib/mapping/CMap.h +++ b/lib/mapping/CMap.h @@ -15,7 +15,6 @@ #include "../ConstTransitivePtr.h" #include "../GameCallbackHolder.h" -#include "../MetaString.h" #include "../networkPacks/TradeItem.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/CMapDefines.h b/lib/mapping/CMapDefines.h index 9c881a0e9..aa3e767a9 100644 --- a/lib/mapping/CMapDefines.h +++ b/lib/mapping/CMapDefines.h @@ -11,7 +11,7 @@ #pragma once #include "../ResourceSet.h" -#include "../MetaString.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/CMapHeader.cpp b/lib/mapping/CMapHeader.cpp index 4041d441c..72b130ad2 100644 --- a/lib/mapping/CMapHeader.cpp +++ b/lib/mapping/CMapHeader.cpp @@ -14,11 +14,11 @@ #include "../VCMI_Lib.h" #include "../CTownHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../json/JsonUtils.h" #include "../modding/CModHandler.h" +#include "../texts/Languages.h" #include "../CHeroHandler.h" -#include "../Languages.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/CMapHeader.h b/lib/mapping/CMapHeader.h index 2f544b8cd..a197ef44d 100644 --- a/lib/mapping/CMapHeader.h +++ b/lib/mapping/CMapHeader.h @@ -17,8 +17,8 @@ #include "../serializer/Serializeable.h" #include "../LogicalExpression.h" #include "../int3.h" -#include "../MetaString.h" -#include "../CGeneralTextHandler.h" +#include "../texts/MetaString.h" +#include "../texts/TextLocalizationContainer.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/CMapInfo.cpp b/lib/mapping/CMapInfo.cpp index 459cc4120..2100bcca8 100644 --- a/lib/mapping/CMapInfo.cpp +++ b/lib/mapping/CMapInfo.cpp @@ -19,14 +19,13 @@ #include "../campaign/CampaignHandler.h" #include "../filesystem/Filesystem.h" -#include "../serializer/CLoadFile.h" -#include "../CGeneralTextHandler.h" -#include "../TextOperations.h" #include "../rmg/CMapGenOptions.h" +#include "../serializer/CLoadFile.h" +#include "../texts/CGeneralTextHandler.h" +#include "../texts/TextOperations.h" #include "../CCreatureHandler.h" #include "../GameSettings.h" #include "../CHeroHandler.h" -#include "../Languages.h" #include "../CConfigHandler.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/mapping/CMapService.cpp b/lib/mapping/CMapService.cpp index cf70f7b08..ec58cc174 100644 --- a/lib/mapping/CMapService.cpp +++ b/lib/mapping/CMapService.cpp @@ -19,7 +19,7 @@ #include "../modding/CModHandler.h" #include "../modding/ModScope.h" #include "../modding/CModInfo.h" -#include "../Languages.h" +#include "../texts/Languages.h" #include "../VCMI_Lib.h" #include "CMap.h" diff --git a/lib/mapping/MapFormatH3M.cpp b/lib/mapping/MapFormatH3M.cpp index 28947e167..2565084f6 100644 --- a/lib/mapping/MapFormatH3M.cpp +++ b/lib/mapping/MapFormatH3M.cpp @@ -17,7 +17,7 @@ #include "../ArtifactUtils.h" #include "../CCreatureHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "../CSkillHandler.h" #include "../CStopWatch.h" @@ -25,7 +25,6 @@ #include "../RiverHandler.h" #include "../RoadHandler.h" #include "../TerrainHandler.h" -#include "../TextOperations.h" #include "../VCMI_Lib.h" #include "../constants/StringConstants.h" #include "../filesystem/CBinaryReader.h" @@ -39,6 +38,7 @@ #include "../networkPacks/Component.h" #include "../networkPacks/ArtifactLocation.h" #include "../spells/CSpellHandler.h" +#include "../texts/TextOperations.h" #include diff --git a/lib/mapping/MapFormatJson.cpp b/lib/mapping/MapFormatJson.cpp index cc6ba42f5..925373e0d 100644 --- a/lib/mapping/MapFormatJson.cpp +++ b/lib/mapping/MapFormatJson.cpp @@ -36,7 +36,7 @@ #include "../constants/StringConstants.h" #include "../serializer/JsonDeserializer.h" #include "../serializer/JsonSerializer.h" -#include "../Languages.h" +#include "../texts/Languages.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/modding/CModHandler.cpp b/lib/modding/CModHandler.cpp index 3dc775352..977336122 100644 --- a/lib/modding/CModHandler.cpp +++ b/lib/modding/CModHandler.cpp @@ -17,16 +17,15 @@ #include "ModIncompatibility.h" #include "../CCreatureHandler.h" -#include "../CGeneralTextHandler.h" #include "../CStopWatch.h" #include "../GameSettings.h" -#include "../Languages.h" -#include "../MetaString.h" #include "../ScriptHandler.h" #include "../constants/StringConstants.h" #include "../filesystem/Filesystem.h" #include "../json/JsonUtils.h" #include "../spells/CSpellHandler.h" +#include "../texts/CGeneralTextHandler.h" +#include "../texts/Languages.h" #include "../VCMI_Lib.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/modding/CModInfo.cpp b/lib/modding/CModInfo.cpp index 8690c17d0..66e7421c7 100644 --- a/lib/modding/CModInfo.cpp +++ b/lib/modding/CModInfo.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "CModInfo.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../VCMI_Lib.h" #include "../filesystem/Filesystem.h" diff --git a/lib/modding/ContentTypeHandler.cpp b/lib/modding/ContentTypeHandler.cpp index a14b81d42..87f18cf44 100644 --- a/lib/modding/ContentTypeHandler.cpp +++ b/lib/modding/ContentTypeHandler.cpp @@ -17,14 +17,13 @@ #include "../BattleFieldHandler.h" #include "../CArtHandler.h" #include "../CCreatureHandler.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CHeroHandler.h" #include "../CSkillHandler.h" #include "../CStopWatch.h" #include "../CTownHandler.h" #include "../GameSettings.h" #include "../IHandlerBase.h" -#include "../Languages.h" #include "../ObstacleHandler.h" #include "../mapObjects/ObstacleSetHandler.h" #include "../RiverHandler.h" diff --git a/lib/networkPacks/NetPacksLib.cpp b/lib/networkPacks/NetPacksLib.cpp index 8fcc759d7..e40042c93 100644 --- a/lib/networkPacks/NetPacksLib.cpp +++ b/lib/networkPacks/NetPacksLib.cpp @@ -17,7 +17,7 @@ #include "PacksForLobby.h" #include "SetStackEffect.h" #include "NetPackVisitor.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "CArtHandler.h" #include "CHeroHandler.h" #include "VCMI_Lib.h" diff --git a/lib/networkPacks/PacksForClient.h b/lib/networkPacks/PacksForClient.h index 7ad75413b..8ef2de96e 100644 --- a/lib/networkPacks/PacksForClient.h +++ b/lib/networkPacks/PacksForClient.h @@ -18,7 +18,6 @@ #include "ObjProperty.h" #include "../CCreatureSet.h" -#include "../MetaString.h" #include "../ResourceSet.h" #include "../TurnTimerInfo.h" #include "../gameState/EVictoryLossCheckResult.h" diff --git a/lib/networkPacks/PacksForClientBattle.h b/lib/networkPacks/PacksForClientBattle.h index 239a248da..b9d498794 100644 --- a/lib/networkPacks/PacksForClientBattle.h +++ b/lib/networkPacks/PacksForClientBattle.h @@ -11,8 +11,8 @@ #include "NetPacksBase.h" #include "BattleChanges.h" -#include "../MetaString.h" #include "../battle/BattleAction.h" +#include "../texts/MetaString.h" class CClient; diff --git a/lib/networkPacks/PacksForLobby.h b/lib/networkPacks/PacksForLobby.h index 8791510d4..a0745fe7b 100644 --- a/lib/networkPacks/PacksForLobby.h +++ b/lib/networkPacks/PacksForLobby.h @@ -11,8 +11,8 @@ #include "StartInfo.h" #include "NetPacksBase.h" -#include "../MetaString.h" #include "../serializer/ESerializationVersion.h" +#include "../texts/MetaString.h" class CServerHandler; class CVCMIServer; diff --git a/lib/rewardable/Configuration.h b/lib/rewardable/Configuration.h index 45038b8a2..fd8f8230d 100644 --- a/lib/rewardable/Configuration.h +++ b/lib/rewardable/Configuration.h @@ -11,9 +11,9 @@ #pragma once #include "Limiter.h" -#include "MetaString.h" #include "Reward.h" #include "../networkPacks/EInfoWindowMode.h" +#include "../texts/MetaString.h" VCMI_LIB_NAMESPACE_BEGIN diff --git a/lib/rewardable/Info.cpp b/lib/rewardable/Info.cpp index 4e5a40d2a..4d579063e 100644 --- a/lib/rewardable/Info.cpp +++ b/lib/rewardable/Info.cpp @@ -15,7 +15,7 @@ #include "Limiter.h" #include "Reward.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../IGameCallback.h" #include "../json/JsonRandom.h" #include "../mapObjects/IObjectInterface.h" diff --git a/lib/rmg/CMapGenerator.cpp b/lib/rmg/CMapGenerator.cpp index 9807d60d6..361e3df73 100644 --- a/lib/rmg/CMapGenerator.cpp +++ b/lib/rmg/CMapGenerator.cpp @@ -13,7 +13,7 @@ #include "../mapping/CMap.h" #include "../mapping/MapFormat.h" #include "../VCMI_Lib.h" -#include "../CGeneralTextHandler.h" +#include "../texts/CGeneralTextHandler.h" #include "../CRandomGenerator.h" #include "../mapObjectConstructors/AObjectTypeHandler.h" #include "../mapObjectConstructors/CObjectClassesHandler.h" diff --git a/lib/spells/BonusCaster.cpp b/lib/spells/BonusCaster.cpp index 720082112..deb119a89 100644 --- a/lib/spells/BonusCaster.cpp +++ b/lib/spells/BonusCaster.cpp @@ -13,7 +13,6 @@ #include -#include "../MetaString.h" #include "../battle/Unit.h" #include "../bonuses/Bonus.h" #include "../VCMI_Lib.h" diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index db8244aeb..e6cb76f33 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -17,7 +17,6 @@ #include -#include "../CGeneralTextHandler.h" #include "../filesystem/Filesystem.h" #include "../constants/StringConstants.h" @@ -28,9 +27,11 @@ #include "../json/JsonBonus.h" #include "../json/JsonUtils.h" #include "../mapObjects/CGHeroInstance.h" //todo: remove -#include "../serializer/CSerializer.h" #include "../modding/IdentifierStorage.h" #include "../modding/ModUtility.h" +#include "../serializer/CSerializer.h" +#include "../texts/CLegacyConfigParser.h" +#include "../texts/CGeneralTextHandler.h" #include "ISpellMechanics.h" diff --git a/lib/spells/Problem.cpp b/lib/spells/Problem.cpp index ed93028cd..90dcc7fe8 100644 --- a/lib/spells/Problem.cpp +++ b/lib/spells/Problem.cpp @@ -10,6 +10,8 @@ #include "StdInc.h" #include "Problem.h" +#include "../texts/MetaString.h" + VCMI_LIB_NAMESPACE_BEGIN namespace spells diff --git a/lib/spells/Problem.h b/lib/spells/Problem.h index aca7062f6..c3d850cb3 100644 --- a/lib/spells/Problem.h +++ b/lib/spells/Problem.h @@ -12,8 +12,6 @@ #include -#include "../MetaString.h" - VCMI_LIB_NAMESPACE_BEGIN namespace spells diff --git a/lib/spells/effects/Damage.cpp b/lib/spells/effects/Damage.cpp index 425607008..59d19658f 100644 --- a/lib/spells/effects/Damage.cpp +++ b/lib/spells/effects/Damage.cpp @@ -14,13 +14,12 @@ #include "../CSpellHandler.h" #include "../ISpellMechanics.h" -#include "../../MetaString.h" #include "../../CStack.h" #include "../../battle/IBattleState.h" #include "../../battle/CBattleInfoCallback.h" #include "../../networkPacks/PacksForClientBattle.h" -#include "../../CGeneralTextHandler.h" -#include "../../Languages.h" +#include "../../texts/CGeneralTextHandler.h" +#include "../../texts/Languages.h" #include "../../serializer/JsonSerializeFormat.h" #include diff --git a/lib/spells/effects/Dispel.cpp b/lib/spells/effects/Dispel.cpp index c27d9b7d3..8ee66b75f 100644 --- a/lib/spells/effects/Dispel.cpp +++ b/lib/spells/effects/Dispel.cpp @@ -16,7 +16,6 @@ #include "../ISpellMechanics.h" -#include "../../MetaString.h" #include "../../battle/IBattleState.h" #include "../../battle/CBattleInfoCallback.h" #include "../../battle/Unit.h" diff --git a/lib/spells/effects/Heal.cpp b/lib/spells/effects/Heal.cpp index 815d6888c..c0aedb3a1 100644 --- a/lib/spells/effects/Heal.cpp +++ b/lib/spells/effects/Heal.cpp @@ -13,7 +13,6 @@ #include "Registry.h" #include "../ISpellMechanics.h" -#include "../../MetaString.h" #include "../../battle/IBattleState.h" #include "../../battle/CUnitState.h" #include "../../battle/CBattleInfoCallback.h" diff --git a/lib/spells/effects/Summon.cpp b/lib/spells/effects/Summon.cpp index eb7816a97..65eb5dafb 100644 --- a/lib/spells/effects/Summon.cpp +++ b/lib/spells/effects/Summon.cpp @@ -13,7 +13,6 @@ #include "Registry.h" #include "../ISpellMechanics.h" -#include "../../MetaString.h" #include "../../battle/CBattleInfoCallback.h" #include "../../battle/BattleInfo.h" #include "../../battle/Unit.h" diff --git a/lib/spells/effects/Timed.cpp b/lib/spells/effects/Timed.cpp index a90c903d7..545505f20 100644 --- a/lib/spells/effects/Timed.cpp +++ b/lib/spells/effects/Timed.cpp @@ -13,7 +13,6 @@ #include "Registry.h" #include "../ISpellMechanics.h" -#include "../../MetaString.h" #include "../../battle/IBattleState.h" #include "../../battle/CBattleInfoCallback.h" #include "../../battle/Unit.h" diff --git a/lib/CGeneralTextHandler.cpp b/lib/texts/CGeneralTextHandler.cpp similarity index 54% rename from lib/CGeneralTextHandler.cpp rename to lib/texts/CGeneralTextHandler.cpp index 2f93f783d..9218aa920 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/texts/CGeneralTextHandler.cpp @@ -8,23 +8,17 @@ * */ #include "StdInc.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" +#include "CLegacyConfigParser.h" #include "CConfigHandler.h" #include "GameSettings.h" #include "Languages.h" -#include "TextOperations.h" -#include "VCMIDirs.h" -#include "VCMI_Lib.h" -#include "filesystem/Filesystem.h" -#include "mapObjects/CQuest.h" -#include "modding/CModHandler.h" -#include "serializer/JsonSerializeFormat.h" +#include "../filesystem/Filesystem.h" +#include "../mapObjects/CQuest.h" VCMI_LIB_NAMESPACE_BEGIN -std::recursive_mutex TextLocalizationContainer::globalTextMutex; - /// Detects language and encoding of H3 text files based on matching against pregenerated footprints of H3 file void CGeneralTextHandler::detectInstallParameters() { @@ -113,361 +107,6 @@ void CGeneralTextHandler::detectInstallParameters() encoding->String() = Languages::getLanguageOptions(knownLanguages[bestIndex]).encoding; } -//Helper for string -> float conversion -class LocaleWithComma: public std::numpunct -{ -protected: - char do_decimal_point() const override - { - return ','; - } -}; - -CLegacyConfigParser::CLegacyConfigParser(const TextPath & resource) -{ - auto input = CResourceHandler::get()->load(resource); - std::string modName = VLC->modh->findResourceOrigin(resource); - std::string language = VLC->modh->getModLanguage(modName); - fileEncoding = Languages::getLanguageOptions(language).encoding; - - data.reset(new char[input->getSize()]); - input->read(reinterpret_cast(data.get()), input->getSize()); - - curr = data.get(); - end = curr + input->getSize(); -} - -std::string CLegacyConfigParser::extractQuotedPart() -{ - assert(*curr == '\"'); - - curr++; // skip quote - char * begin = curr; - - while (curr != end && *curr != '\"' && *curr != '\t') - curr++; - - return std::string(begin, curr++); //increment curr to close quote -} - -std::string CLegacyConfigParser::extractQuotedString() -{ - assert(*curr == '\"'); - - std::string ret; - while (true) - { - ret += extractQuotedPart(); - - // double quote - add it to string and continue quoted part - if (curr < end && *curr == '\"') - { - ret += '\"'; - } - //extract normal part - else if(curr < end && *curr != '\t' && *curr != '\r') - { - char * begin = curr; - - while (curr < end && *curr != '\t' && *curr != '\r' && *curr != '\"')//find end of string or next quoted part start - curr++; - - ret += std::string(begin, curr); - - if(curr>=end || *curr != '\"') - return ret; - } - else // end of string - return ret; - } -} - -std::string CLegacyConfigParser::extractNormalString() -{ - char * begin = curr; - - while (curr < end && *curr != '\t' && *curr != '\r')//find end of string - curr++; - - return std::string(begin, curr); -} - -std::string CLegacyConfigParser::readRawString() -{ - if (curr >= end || *curr == '\n') - return ""; - - std::string ret; - - if (*curr == '\"') - ret = extractQuotedString();// quoted text - find closing quote - else - ret = extractNormalString();//string without quotes - copy till \t or \r - - curr++; - return ret; -} - -std::string CLegacyConfigParser::readString() -{ - // do not convert strings that are already in ASCII - this will only slow down loading process - std::string str = readRawString(); - if (TextOperations::isValidASCII(str)) - return str; - return TextOperations::toUnicode(str, fileEncoding); -} - -float CLegacyConfigParser::readNumber() -{ - std::string input = readRawString(); - - std::istringstream stream(input); - - if(input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator - stream.imbue(std::locale(std::locale(), new LocaleWithComma())); - - float result; - if ( !(stream >> result) ) - return 0; - return result; -} - -bool CLegacyConfigParser::isNextEntryEmpty() const -{ - char * nextSymbol = curr; - while (nextSymbol < end && *nextSymbol == ' ') - nextSymbol++; //find next meaningful symbol - - return nextSymbol >= end || *nextSymbol == '\n' || *nextSymbol == '\r' || *nextSymbol == '\t'; -} - -bool CLegacyConfigParser::endLine() -{ - while (curr < end && *curr != '\n') - readString(); - - curr++; - - return curr < end; -} - -void TextLocalizationContainer::registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized) -{ - std::lock_guard globalLock(globalTextMutex); - - assert(!modContext.empty()); - assert(!language.empty()); - - // NOTE: implicitly creates entry, intended - strings added by maps, campaigns, vcmi and potentially - UI mods are not registered anywhere at the moment - auto & entry = stringsLocalizations[UID.get()]; - - entry.overrideLanguage = language; - entry.overrideValue = localized; - if (entry.modContext.empty()) - entry.modContext = modContext; -} - -void TextLocalizationContainer::addSubContainer(const TextLocalizationContainer & container) -{ - std::lock_guard globalLock(globalTextMutex); - - assert(!vstd::contains(subContainers, &container)); - subContainers.push_back(&container); -} - -void TextLocalizationContainer::removeSubContainer(const TextLocalizationContainer & container) -{ - std::lock_guard globalLock(globalTextMutex); - - assert(vstd::contains(subContainers, &container)); - - subContainers.erase(std::remove(subContainers.begin(), subContainers.end(), &container), subContainers.end()); -} - -const std::string & TextLocalizationContainer::deserialize(const TextIdentifier & identifier) const -{ - std::lock_guard globalLock(globalTextMutex); - - if(stringsLocalizations.count(identifier.get()) == 0) - { - for(auto containerIter = subContainers.rbegin(); containerIter != subContainers.rend(); ++containerIter) - if((*containerIter)->identifierExists(identifier)) - return (*containerIter)->deserialize(identifier); - - logGlobal->error("Unable to find localization for string '%s'", identifier.get()); - return identifier.get(); - } - - const auto & entry = stringsLocalizations.at(identifier.get()); - - if (!entry.overrideValue.empty()) - return entry.overrideValue; - return entry.baseValue; -} - -void TextLocalizationContainer::registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized, const std::string & language) -{ - std::lock_guard globalLock(globalTextMutex); - - assert(!modContext.empty()); - assert(!Languages::getLanguageOptions(language).identifier.empty()); - assert(UID.get().find("..") == std::string::npos); // invalid identifier - there is section that was evaluated to empty string - //assert(stringsLocalizations.count(UID.get()) == 0); // registering already registered string? - - if(stringsLocalizations.count(UID.get()) > 0) - { - auto & value = stringsLocalizations[UID.get()]; - value.baseLanguage = language; - value.baseValue = localized; - } - else - { - StringState value; - value.baseLanguage = language; - value.baseValue = localized; - value.modContext = modContext; - - stringsLocalizations[UID.get()] = value; - } -} - -void TextLocalizationContainer::registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized) -{ - assert(!getModLanguage(modContext).empty()); - registerString(modContext, UID, localized, getModLanguage(modContext)); -} - -bool TextLocalizationContainer::validateTranslation(const std::string & language, const std::string & modContext, const JsonNode & config) const -{ - std::lock_guard globalLock(globalTextMutex); - - bool allPresent = true; - - for(const auto & string : stringsLocalizations) - { - if (string.second.modContext != modContext) - continue; // Not our mod - - if (string.second.overrideLanguage == language) - continue; // Already translated - - if (string.second.baseLanguage == language && !string.second.baseValue.empty()) - continue; // Base string already uses our language - - if (string.second.baseLanguage.empty()) - continue; // String added in localization, not present in base language (e.g. maps/campaigns) - - if (config.Struct().count(string.first) > 0) - continue; - - if (allPresent) - logMod->warn("Translation into language '%s' in mod '%s' is incomplete! Missing lines:", language, modContext); - - std::string currentText; - if (string.second.overrideValue.empty()) - currentText = string.second.baseValue; - else - currentText = string.second.overrideValue; - - logMod->warn(R"( "%s" : "%s",)", string.first, TextOperations::escapeString(currentText)); - allPresent = false; - } - - bool allFound = true; - -// for(const auto & string : config.Struct()) -// { -// if (stringsLocalizations.count(string.first) > 0) -// continue; -// -// if (allFound) -// logMod->warn("Translation into language '%s' in mod '%s' has unused lines:", language, modContext); -// -// logMod->warn(R"( "%s" : "%s",)", string.first, TextOperations::escapeString(string.second.String())); -// allFound = false; -// } - - return allPresent && allFound; -} - -void TextLocalizationContainer::loadTranslationOverrides(const std::string & language, const std::string & modContext, const JsonNode & config) -{ - for(const auto & node : config.Struct()) - registerStringOverride(modContext, language, node.first, node.second.String()); -} - -bool TextLocalizationContainer::identifierExists(const TextIdentifier & UID) const -{ - std::lock_guard globalLock(globalTextMutex); - - return stringsLocalizations.count(UID.get()); -} - -void TextLocalizationContainer::exportAllTexts(std::map> & storage) const -{ - std::lock_guard globalLock(globalTextMutex); - - for (auto const & subContainer : subContainers) - subContainer->exportAllTexts(storage); - - for (auto const & entry : stringsLocalizations) - { - std::string textToWrite; - std::string modName = entry.second.modContext; - - if (modName.find('.') != std::string::npos) - modName = modName.substr(0, modName.find('.')); - - if (!entry.second.overrideValue.empty()) - textToWrite = entry.second.overrideValue; - else - textToWrite = entry.second.baseValue; - - storage[modName][entry.first] = textToWrite; - } -} - -std::string TextLocalizationContainer::getModLanguage(const std::string & modContext) -{ - if (modContext == "core") - return CGeneralTextHandler::getInstalledLanguage(); - return VLC->modh->getModLanguage(modContext); -} - -void TextLocalizationContainer::jsonSerialize(JsonNode & dest) const -{ - std::lock_guard globalLock(globalTextMutex); - - for(auto & s : stringsLocalizations) - { - dest.Struct()[s.first].String() = s.second.baseValue; - if(!s.second.overrideValue.empty()) - dest.Struct()[s.first].String() = s.second.overrideValue; - } -} - -TextContainerRegistrable::TextContainerRegistrable() -{ - VLC->generaltexth->addSubContainer(*this); -} - -TextContainerRegistrable::~TextContainerRegistrable() -{ - VLC->generaltexth->removeSubContainer(*this); -} - -TextContainerRegistrable::TextContainerRegistrable(const TextContainerRegistrable & other) - : TextLocalizationContainer(other) -{ - VLC->generaltexth->addSubContainer(*this); -} - -TextContainerRegistrable::TextContainerRegistrable(TextContainerRegistrable && other) noexcept - :TextLocalizationContainer(other) -{ - VLC->generaltexth->addSubContainer(*this); -} - void CGeneralTextHandler::readToVector(const std::string & sourceID, const std::string & sourceName) { CLegacyConfigParser parser(TextPath::builtin(sourceName)); diff --git a/lib/texts/CGeneralTextHandler.h b/lib/texts/CGeneralTextHandler.h new file mode 100644 index 000000000..0513085de --- /dev/null +++ b/lib/texts/CGeneralTextHandler.h @@ -0,0 +1,107 @@ +/* + * CGeneralTextHandler.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include "TextLocalizationContainer.h" + +VCMI_LIB_NAMESPACE_BEGIN + +class CGeneralTextHandler; + +/// Small wrapper that provides text access API compatible with old code +class DLL_LINKAGE LegacyTextContainer +{ + CGeneralTextHandler & owner; + std::string basePath; + +public: + LegacyTextContainer(CGeneralTextHandler & owner, std::string basePath); + std::string operator [](size_t index) const; +}; + +/// Small wrapper that provides help text access API compatible with old code +class DLL_LINKAGE LegacyHelpContainer +{ + CGeneralTextHandler & owner; + std::string basePath; + +public: + LegacyHelpContainer(CGeneralTextHandler & owner, std::string basePath); + std::pair operator[](size_t index) const; +}; + +/// Handles all text-related data in game +class DLL_LINKAGE CGeneralTextHandler: public TextLocalizationContainer +{ + void readToVector(const std::string & sourceID, const std::string & sourceName); + + /// number of scenarios in specific campaign. TODO: move to a better location + std::vector scenariosCountPerCampaign; + +public: + LegacyTextContainer allTexts; + + LegacyTextContainer arraytxt; + LegacyTextContainer primarySkillNames; + LegacyTextContainer jktexts; + LegacyTextContainer heroscrn; + LegacyTextContainer overview;//text for Kingdom Overview window + LegacyTextContainer colors; //names of player colors ("red",...) + LegacyTextContainer capColors; //names of player colors with first letter capitalized ("Red",...) + LegacyTextContainer turnDurations; //turn durations for pregame (1 Minute ... Unlimited) + + //towns + LegacyTextContainer tcommands, hcommands, fcommands; //texts for town screen, town hall screen and fort screen + LegacyTextContainer tavernInfo; + LegacyTextContainer tavernRumors; + + LegacyTextContainer qeModCommands; + + LegacyHelpContainer zelp; + LegacyTextContainer lossConditions; + LegacyTextContainer victoryConditions; + + //objects + LegacyTextContainer advobtxt; + LegacyTextContainer restypes; //names of resources + LegacyTextContainer randsign; + LegacyTextContainer seerEmpty; + LegacyTextContainer seerNames; + LegacyTextContainer tentColors; + + //sec skills + LegacyTextContainer levels; + //commanders + LegacyTextContainer znpc00; //more or less useful content of that file + + std::vector findStringsWithPrefix(const std::string & prefix); + + int32_t pluralText(int32_t textIndex, int32_t count) const; + + size_t getCampaignLength(size_t campaignID) const; + + CGeneralTextHandler(); + CGeneralTextHandler(const CGeneralTextHandler&) = delete; + CGeneralTextHandler operator=(const CGeneralTextHandler&) = delete; + + /// Attempts to detect encoding & language of H3 files + static void detectInstallParameters(); + + /// Returns name of language preferred by user + static std::string getPreferredLanguage(); + + /// Returns name of language of Heroes III text files + static std::string getInstalledLanguage(); + + /// Returns name of encoding of Heroes III text files + static std::string getInstalledEncoding(); +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/texts/CLegacyConfigParser.cpp b/lib/texts/CLegacyConfigParser.cpp new file mode 100644 index 000000000..753c8c863 --- /dev/null +++ b/lib/texts/CLegacyConfigParser.cpp @@ -0,0 +1,160 @@ +/* + * CLegacyConfigParser.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#include "StdInc.h" +#include "CLegacyConfigParser.h" + +#include "TextOperations.h" +#include "Languages.h" + +#include "../VCMI_Lib.h" +#include "filesystem/Filesystem.h" +#include "../modding/CModHandler.h" + +VCMI_LIB_NAMESPACE_BEGIN + +//Helper for string -> float conversion +class LocaleWithComma: public std::numpunct +{ +protected: + char do_decimal_point() const override + { + return ','; + } +}; + +CLegacyConfigParser::CLegacyConfigParser(const TextPath & resource) +{ + auto input = CResourceHandler::get()->load(resource); + std::string modName = VLC->modh->findResourceOrigin(resource); + std::string language = VLC->modh->getModLanguage(modName); + fileEncoding = Languages::getLanguageOptions(language).encoding; + + data.reset(new char[input->getSize()]); + input->read(reinterpret_cast(data.get()), input->getSize()); + + curr = data.get(); + end = curr + input->getSize(); +} + +std::string CLegacyConfigParser::extractQuotedPart() +{ + assert(*curr == '\"'); + + curr++; // skip quote + char * begin = curr; + + while (curr != end && *curr != '\"' && *curr != '\t') + curr++; + + return std::string(begin, curr++); //increment curr to close quote +} + +std::string CLegacyConfigParser::extractQuotedString() +{ + assert(*curr == '\"'); + + std::string ret; + while (true) + { + ret += extractQuotedPart(); + + // double quote - add it to string and continue quoted part + if (curr < end && *curr == '\"') + { + ret += '\"'; + } + //extract normal part + else if(curr < end && *curr != '\t' && *curr != '\r') + { + char * begin = curr; + + while (curr < end && *curr != '\t' && *curr != '\r' && *curr != '\"')//find end of string or next quoted part start + curr++; + + ret += std::string(begin, curr); + + if(curr>=end || *curr != '\"') + return ret; + } + else // end of string + return ret; + } +} + +std::string CLegacyConfigParser::extractNormalString() +{ + char * begin = curr; + + while (curr < end && *curr != '\t' && *curr != '\r')//find end of string + curr++; + + return std::string(begin, curr); +} + +std::string CLegacyConfigParser::readRawString() +{ + if (curr >= end || *curr == '\n') + return ""; + + std::string ret; + + if (*curr == '\"') + ret = extractQuotedString();// quoted text - find closing quote + else + ret = extractNormalString();//string without quotes - copy till \t or \r + + curr++; + return ret; +} + +std::string CLegacyConfigParser::readString() +{ + // do not convert strings that are already in ASCII - this will only slow down loading process + std::string str = readRawString(); + if (TextOperations::isValidASCII(str)) + return str; + return TextOperations::toUnicode(str, fileEncoding); +} + +float CLegacyConfigParser::readNumber() +{ + std::string input = readRawString(); + + std::istringstream stream(input); + + if(input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator + stream.imbue(std::locale(std::locale(), new LocaleWithComma())); + + float result; + if ( !(stream >> result) ) + return 0; + return result; +} + +bool CLegacyConfigParser::isNextEntryEmpty() const +{ + char * nextSymbol = curr; + while (nextSymbol < end && *nextSymbol == ' ') + nextSymbol++; //find next meaningful symbol + + return nextSymbol >= end || *nextSymbol == '\n' || *nextSymbol == '\r' || *nextSymbol == '\t'; +} + +bool CLegacyConfigParser::endLine() +{ + while (curr < end && *curr != '\n') + readString(); + + curr++; + + return curr < end; +} + +VCMI_LIB_NAMESPACE_END diff --git a/lib/texts/CLegacyConfigParser.h b/lib/texts/CLegacyConfigParser.h new file mode 100644 index 000000000..7918590e7 --- /dev/null +++ b/lib/texts/CLegacyConfigParser.h @@ -0,0 +1,65 @@ +/* + * CLegacyConfigParser.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include "filesystem/ResourcePath.h" + +VCMI_LIB_NAMESPACE_BEGIN + +//class CInputStream; +//class JsonNode; +//class JsonSerializeFormat; + +/// Parser for any text files from H3 +class DLL_LINKAGE CLegacyConfigParser +{ + std::string fileEncoding; + + std::unique_ptr data; + char * curr; + char * end; + + /// extracts part of quoted string. + std::string extractQuotedPart(); + + /// extracts quoted string. Any end of lines are ignored, double-quote is considered as "escaping" + std::string extractQuotedString(); + + /// extracts non-quoted string + std::string extractNormalString(); + + /// reads "raw" string without encoding conversion + std::string readRawString(); + +public: + /// read one entry from current line. Return ""/0 if end of line reached + std::string readString(); + float readNumber(); + + template + std::vector readNumArray(size_t size) + { + std::vector ret; + ret.reserve(size); + while (size--) + ret.push_back((numeric)readNumber()); + return ret; + } + + /// returns true if next entry is empty + bool isNextEntryEmpty() const; + + /// end current line + bool endLine(); + + explicit CLegacyConfigParser(const TextPath & URI); +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/Languages.h b/lib/texts/Languages.h similarity index 100% rename from lib/Languages.h rename to lib/texts/Languages.h diff --git a/lib/MetaString.cpp b/lib/texts/MetaString.cpp similarity index 99% rename from lib/MetaString.cpp rename to lib/texts/MetaString.cpp index 010122452..c627bcced 100644 --- a/lib/MetaString.cpp +++ b/lib/texts/MetaString.cpp @@ -13,7 +13,7 @@ #include "CArtHandler.h" #include "CCreatureHandler.h" #include "CCreatureSet.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "CSkillHandler.h" #include "GameConstants.h" #include "VCMI_Lib.h" diff --git a/lib/MetaString.h b/lib/texts/MetaString.h similarity index 100% rename from lib/MetaString.h rename to lib/texts/MetaString.h diff --git a/lib/texts/TextIdentifier.h b/lib/texts/TextIdentifier.h new file mode 100644 index 000000000..44ad2a21a --- /dev/null +++ b/lib/texts/TextIdentifier.h @@ -0,0 +1,42 @@ +/* + * TextIdentifier.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +VCMI_LIB_NAMESPACE_BEGIN + +class TextIdentifier +{ + std::string identifier; +public: + const std::string & get() const + { + return identifier; + } + + TextIdentifier(const char * id): + identifier(id) + {} + + TextIdentifier(const std::string & id): + identifier(id) + {} + + template + TextIdentifier(const std::string & id, size_t index, T... rest): + TextIdentifier(id + '.' + std::to_string(index), rest...) + {} + + template + TextIdentifier(const std::string & id, const std::string & id2, T... rest): + TextIdentifier(id + '.' + id2, rest...) + {} +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/texts/TextLocalizationContainer.cpp b/lib/texts/TextLocalizationContainer.cpp new file mode 100644 index 000000000..4a210ede3 --- /dev/null +++ b/lib/texts/TextLocalizationContainer.cpp @@ -0,0 +1,243 @@ +/* + * TextLocalizationContainer.cpp, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#include "StdInc.h" +#include "TextLocalizationContainer.h" + +#include "texts/CGeneralTextHandler.h" +#include "Languages.h" +#include "TextOperations.h" + +#include "../VCMI_Lib.h" +#include "../json/JsonNode.h" +#include "../modding/CModHandler.h" + +VCMI_LIB_NAMESPACE_BEGIN + +std::recursive_mutex TextLocalizationContainer::globalTextMutex; + +void TextLocalizationContainer::registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized) +{ + std::lock_guard globalLock(globalTextMutex); + + assert(!modContext.empty()); + assert(!language.empty()); + + // NOTE: implicitly creates entry, intended - strings added by maps, campaigns, vcmi and potentially - UI mods are not registered anywhere at the moment + auto & entry = stringsLocalizations[UID.get()]; + + entry.overrideLanguage = language; + entry.overrideValue = localized; + if (entry.modContext.empty()) + entry.modContext = modContext; +} + +void TextLocalizationContainer::addSubContainer(const TextLocalizationContainer & container) +{ + std::lock_guard globalLock(globalTextMutex); + + assert(!vstd::contains(subContainers, &container)); + subContainers.push_back(&container); +} + +void TextLocalizationContainer::removeSubContainer(const TextLocalizationContainer & container) +{ + std::lock_guard globalLock(globalTextMutex); + + assert(vstd::contains(subContainers, &container)); + + subContainers.erase(std::remove(subContainers.begin(), subContainers.end(), &container), subContainers.end()); +} + +const std::string & TextLocalizationContainer::deserialize(const TextIdentifier & identifier) const +{ + std::lock_guard globalLock(globalTextMutex); + + if(stringsLocalizations.count(identifier.get()) == 0) + { + for(auto containerIter = subContainers.rbegin(); containerIter != subContainers.rend(); ++containerIter) + if((*containerIter)->identifierExists(identifier)) + return (*containerIter)->deserialize(identifier); + + logGlobal->error("Unable to find localization for string '%s'", identifier.get()); + return identifier.get(); + } + + const auto & entry = stringsLocalizations.at(identifier.get()); + + if (!entry.overrideValue.empty()) + return entry.overrideValue; + return entry.baseValue; +} + +void TextLocalizationContainer::registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized, const std::string & language) +{ + std::lock_guard globalLock(globalTextMutex); + + assert(!modContext.empty()); + assert(!Languages::getLanguageOptions(language).identifier.empty()); + assert(UID.get().find("..") == std::string::npos); // invalid identifier - there is section that was evaluated to empty string + //assert(stringsLocalizations.count(UID.get()) == 0); // registering already registered string? + + if(stringsLocalizations.count(UID.get()) > 0) + { + auto & value = stringsLocalizations[UID.get()]; + value.baseLanguage = language; + value.baseValue = localized; + } + else + { + StringState value; + value.baseLanguage = language; + value.baseValue = localized; + value.modContext = modContext; + + stringsLocalizations[UID.get()] = value; + } +} + +void TextLocalizationContainer::registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized) +{ + assert(!getModLanguage(modContext).empty()); + registerString(modContext, UID, localized, getModLanguage(modContext)); +} + +bool TextLocalizationContainer::validateTranslation(const std::string & language, const std::string & modContext, const JsonNode & config) const +{ + std::lock_guard globalLock(globalTextMutex); + + bool allPresent = true; + + for(const auto & string : stringsLocalizations) + { + if (string.second.modContext != modContext) + continue; // Not our mod + + if (string.second.overrideLanguage == language) + continue; // Already translated + + if (string.second.baseLanguage == language && !string.second.baseValue.empty()) + continue; // Base string already uses our language + + if (string.second.baseLanguage.empty()) + continue; // String added in localization, not present in base language (e.g. maps/campaigns) + + if (config.Struct().count(string.first) > 0) + continue; + + if (allPresent) + logMod->warn("Translation into language '%s' in mod '%s' is incomplete! Missing lines:", language, modContext); + + std::string currentText; + if (string.second.overrideValue.empty()) + currentText = string.second.baseValue; + else + currentText = string.second.overrideValue; + + logMod->warn(R"( "%s" : "%s",)", string.first, TextOperations::escapeString(currentText)); + allPresent = false; + } + + bool allFound = true; + + // for(const auto & string : config.Struct()) + // { + // if (stringsLocalizations.count(string.first) > 0) + // continue; + // + // if (allFound) + // logMod->warn("Translation into language '%s' in mod '%s' has unused lines:", language, modContext); + // + // logMod->warn(R"( "%s" : "%s",)", string.first, TextOperations::escapeString(string.second.String())); + // allFound = false; + // } + + return allPresent && allFound; +} + +void TextLocalizationContainer::loadTranslationOverrides(const std::string & language, const std::string & modContext, const JsonNode & config) +{ + for(const auto & node : config.Struct()) + registerStringOverride(modContext, language, node.first, node.second.String()); +} + +bool TextLocalizationContainer::identifierExists(const TextIdentifier & UID) const +{ + std::lock_guard globalLock(globalTextMutex); + + return stringsLocalizations.count(UID.get()); +} + +void TextLocalizationContainer::exportAllTexts(std::map> & storage) const +{ + std::lock_guard globalLock(globalTextMutex); + + for (auto const & subContainer : subContainers) + subContainer->exportAllTexts(storage); + + for (auto const & entry : stringsLocalizations) + { + std::string textToWrite; + std::string modName = entry.second.modContext; + + if (modName.find('.') != std::string::npos) + modName = modName.substr(0, modName.find('.')); + + if (!entry.second.overrideValue.empty()) + textToWrite = entry.second.overrideValue; + else + textToWrite = entry.second.baseValue; + + storage[modName][entry.first] = textToWrite; + } +} + +std::string TextLocalizationContainer::getModLanguage(const std::string & modContext) +{ + if (modContext == "core") + return CGeneralTextHandler::getInstalledLanguage(); + return VLC->modh->getModLanguage(modContext); +} + +void TextLocalizationContainer::jsonSerialize(JsonNode & dest) const +{ + std::lock_guard globalLock(globalTextMutex); + + for(auto & s : stringsLocalizations) + { + dest.Struct()[s.first].String() = s.second.baseValue; + if(!s.second.overrideValue.empty()) + dest.Struct()[s.first].String() = s.second.overrideValue; + } +} + +TextContainerRegistrable::TextContainerRegistrable() +{ + VLC->generaltexth->addSubContainer(*this); +} + +TextContainerRegistrable::~TextContainerRegistrable() +{ + VLC->generaltexth->removeSubContainer(*this); +} + +TextContainerRegistrable::TextContainerRegistrable(const TextContainerRegistrable & other) + : TextLocalizationContainer(other) +{ + VLC->generaltexth->addSubContainer(*this); +} + +TextContainerRegistrable::TextContainerRegistrable(TextContainerRegistrable && other) noexcept + :TextLocalizationContainer(other) +{ + VLC->generaltexth->addSubContainer(*this); +} + + +VCMI_LIB_NAMESPACE_END diff --git a/lib/texts/TextLocalizationContainer.h b/lib/texts/TextLocalizationContainer.h new file mode 100644 index 000000000..0e9e3f05f --- /dev/null +++ b/lib/texts/TextLocalizationContainer.h @@ -0,0 +1,157 @@ +/* + * TextLocalizationContainer.h, part of VCMI engine + * + * Authors: listed in file AUTHORS in main folder + * + * License: GNU General Public License v2.0 or later + * Full text of license available in license.txt file, in main folder + * + */ +#pragma once + +#include "TextIdentifier.h" + +VCMI_LIB_NAMESPACE_BEGIN + +class JsonNode; + +class DLL_LINKAGE TextLocalizationContainer +{ +protected: + static std::recursive_mutex globalTextMutex; + + struct StringState + { + /// Human-readable string that was added on registration + std::string baseValue; + + /// Language of base string + std::string baseLanguage; + + /// Translated human-readable string + std::string overrideValue; + + /// Language of the override string + std::string overrideLanguage; + + /// ID of mod that created this string + std::string modContext; + + template + void serialize(Handler & h) + { + h & baseValue; + h & baseLanguage; + h & modContext; + } + }; + + /// map identifier -> localization + std::unordered_map stringsLocalizations; + + std::vector subContainers; + + /// add selected string to internal storage as high-priority strings + void registerStringOverride(const std::string & modContext, const std::string & language, const TextIdentifier & UID, const std::string & localized); + + std::string getModLanguage(const std::string & modContext); + + // returns true if identifier with such name was registered, even if not translated to current language + bool identifierExists(const TextIdentifier & UID) const; + +public: + /// validates translation of specified language for specified mod + /// returns true if localization is valid and complete + /// any error messages will be written to log file + bool validateTranslation(const std::string & language, const std::string & modContext, JsonNode const & file) const; + + /// Loads translation from provided json + /// Any entries loaded by this will have priority over texts registered normally + void loadTranslationOverrides(const std::string & language, const std::string & modContext, JsonNode const & file); + + /// add selected string to internal storage + void registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized); + void registerString(const std::string & modContext, const TextIdentifier & UID, const std::string & localized, const std::string & language); + + /// returns translated version of a string that can be displayed to user + template + std::string translate(std::string arg1, Args ... args) const + { + TextIdentifier id(arg1, args ...); + return deserialize(id); + } + + /// converts identifier into user-readable string + const std::string & deserialize(const TextIdentifier & identifier) const; + + /// Debug method, returns all currently stored texts + /// Format: [mod ID][string ID] -> human-readable text + void exportAllTexts(std::map> & storage) const; + + /// Add or override subcontainer which can store identifiers + void addSubContainer(const TextLocalizationContainer & container); + + /// Remove subcontainer with give name + void removeSubContainer(const TextLocalizationContainer & container); + + void jsonSerialize(JsonNode & dest) const; + + template + void serialize(Handler & h) + { + std::lock_guard globalLock(globalTextMutex); + + if (h.version >= Handler::Version::SIMPLE_TEXT_CONTAINER_SERIALIZATION) + { + h & stringsLocalizations; + } + else + { + std::string key; + int64_t sz = stringsLocalizations.size(); + + if (h.version >= Handler::Version::REMOVE_TEXT_CONTAINER_SIZE_T) + { + int64_t size = sz; + h & size; + sz = size; + } + else + { + h & sz; + } + + if(h.saving) + { + for(auto s : stringsLocalizations) + { + key = s.first; + h & key; + h & s.second; + } + } + else + { + for(size_t i = 0; i < sz; ++i) + { + h & key; + h & stringsLocalizations[key]; + } + } + } + } +}; + +class DLL_LINKAGE TextContainerRegistrable : public TextLocalizationContainer +{ +public: + TextContainerRegistrable(); + ~TextContainerRegistrable(); + + TextContainerRegistrable(const TextContainerRegistrable & other); + TextContainerRegistrable(TextContainerRegistrable && other) noexcept; + + TextContainerRegistrable& operator=(const TextContainerRegistrable & b) = default; +}; + +VCMI_LIB_NAMESPACE_END diff --git a/lib/TextOperations.cpp b/lib/texts/TextOperations.cpp similarity index 99% rename from lib/TextOperations.cpp rename to lib/texts/TextOperations.cpp index c152be4f1..ed46d9080 100644 --- a/lib/TextOperations.cpp +++ b/lib/texts/TextOperations.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "TextOperations.h" -#include "CGeneralTextHandler.h" +#include "texts/CGeneralTextHandler.h" #include "Languages.h" #include "CConfigHandler.h" diff --git a/lib/TextOperations.h b/lib/texts/TextOperations.h similarity index 99% rename from lib/TextOperations.h rename to lib/texts/TextOperations.h index 123efcac1..f549bc317 100644 --- a/lib/TextOperations.h +++ b/lib/texts/TextOperations.h @@ -72,8 +72,6 @@ namespace TextOperations DLL_LINKAGE std::string getCurrentFormattedTimeLocal(std::chrono::seconds timeOffset = {}); }; - - template inline std::string TextOperations::formatMetric(Arithmetic number, int maxDigits) { diff --git a/lobby/LobbyServer.cpp b/lobby/LobbyServer.cpp index 7f1a08635..692a2681b 100644 --- a/lobby/LobbyServer.cpp +++ b/lobby/LobbyServer.cpp @@ -12,11 +12,11 @@ #include "LobbyDatabase.h" -#include "../lib/Languages.h" -#include "../lib/TextOperations.h" #include "../lib/json/JsonFormatException.h" #include "../lib/json/JsonNode.h" #include "../lib/json/JsonUtils.h" +#include "../lib/texts/Languages.h" +#include "../lib/texts/TextOperations.h" #include #include diff --git a/mapeditor/graphics.cpp b/mapeditor/graphics.cpp index e41096556..ddf980b2a 100644 --- a/mapeditor/graphics.cpp +++ b/mapeditor/graphics.cpp @@ -26,7 +26,7 @@ #include "../lib/CThreadHelper.h" #include "../lib/VCMI_Lib.h" #include "../CCallback.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "BitmapHandler.h" #include "../lib/CStopWatch.h" #include "../lib/mapObjectConstructors/AObjectTypeHandler.h" diff --git a/mapeditor/inspector/inspector.h b/mapeditor/inspector/inspector.h index 1bb962555..50d631185 100644 --- a/mapeditor/inspector/inspector.h +++ b/mapeditor/inspector/inspector.h @@ -18,9 +18,8 @@ #include "../lib/mapObjects/CGCreature.h" #include "../lib/mapObjects/MapObjects.h" #include "../lib/mapObjects/CRewardableObject.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/ResourceSet.h" -#include "../lib/MetaString.h" #define DECLARE_OBJ_TYPE(x) void initialize(x*); #define DECLARE_OBJ_PROPERTY_METHODS(x) \ @@ -178,4 +177,4 @@ class OwnerDelegate : public InspectorDelegate Q_OBJECT public: OwnerDelegate(MapController & controller, bool addNeutral = true); -}; \ No newline at end of file +}; diff --git a/mapeditor/inspector/townbuildingswidget.cpp b/mapeditor/inspector/townbuildingswidget.cpp index ea3d0b403..cdf1582d1 100644 --- a/mapeditor/inspector/townbuildingswidget.cpp +++ b/mapeditor/inspector/townbuildingswidget.cpp @@ -10,7 +10,7 @@ #include "StdInc.h" #include "townbuildingswidget.h" #include "ui_townbuildingswidget.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" std::string defaultBuildingIdConversion(BuildingID bId) { diff --git a/mapeditor/mapsettings/loseconditions.cpp b/mapeditor/mapsettings/loseconditions.cpp index 79ffea12e..e7b559438 100644 --- a/mapeditor/mapsettings/loseconditions.cpp +++ b/mapeditor/mapsettings/loseconditions.cpp @@ -11,7 +11,7 @@ #include "loseconditions.h" #include "ui_loseconditions.h" #include "../mapcontroller.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" LoseConditions::LoseConditions(QWidget *parent) : AbstractSettings(parent), diff --git a/mapeditor/mapsettings/translations.cpp b/mapeditor/mapsettings/translations.cpp index dd3f6e234..8a3ba6490 100644 --- a/mapeditor/mapsettings/translations.cpp +++ b/mapeditor/mapsettings/translations.cpp @@ -11,8 +11,8 @@ #include "StdInc.h" #include "translations.h" #include "ui_translations.h" -#include "../../lib/Languages.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/Languages.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/mapObjects/CGObjectInstance.h" #include "../../lib/VCMI_Lib.h" diff --git a/mapeditor/mapsettings/victoryconditions.cpp b/mapeditor/mapsettings/victoryconditions.cpp index 2fa58afe2..ab7909347 100644 --- a/mapeditor/mapsettings/victoryconditions.cpp +++ b/mapeditor/mapsettings/victoryconditions.cpp @@ -11,7 +11,7 @@ #include "victoryconditions.h" #include "ui_victoryconditions.h" #include "../mapcontroller.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/constants/StringConstants.h" #include "../../lib/mapObjects/CGCreature.h" diff --git a/mapeditor/windownewmap.cpp b/mapeditor/windownewmap.cpp index 92e6a19fa..219a2da9c 100644 --- a/mapeditor/windownewmap.cpp +++ b/mapeditor/windownewmap.cpp @@ -16,7 +16,7 @@ #include "../lib/VCMI_Lib.h" #include "../lib/mapping/CMapEditManager.h" #include "../lib/mapping/MapFormat.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CRandomGenerator.h" #include "../lib/serializer/JsonSerializer.h" #include "../lib/serializer/JsonDeserializer.h" diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 05cc41ac3..616859971 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -27,7 +27,7 @@ #include "../lib/CConfigHandler.h" #include "../lib/CCreatureHandler.h" #include "../lib/CCreatureSet.h" -#include "../lib/CGeneralTextHandler.h" +#include "../lib/texts/CGeneralTextHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/CPlayerState.h" #include "../lib/CRandomGenerator.h" diff --git a/server/CVCMIServer.cpp b/server/CVCMIServer.cpp index 375568880..68480a0ce 100644 --- a/server/CVCMIServer.cpp +++ b/server/CVCMIServer.cpp @@ -17,10 +17,10 @@ #include "../lib/CHeroHandler.h" #include "../lib/CPlayerState.h" -#include "../lib/MetaString.h" #include "../lib/registerTypes/RegisterTypesLobbyPacks.h" #include "../lib/serializer/CMemorySerializer.h" #include "../lib/serializer/Connection.h" +#include "../lib/texts/CGeneralTextHandler.h" // UUID generation #include diff --git a/server/battles/BattleActionProcessor.cpp b/server/battles/BattleActionProcessor.cpp index 98d16493a..4a8e9b4f0 100644 --- a/server/battles/BattleActionProcessor.cpp +++ b/server/battles/BattleActionProcessor.cpp @@ -14,7 +14,7 @@ #include "../CGameHandler.h" -#include "../../lib/CGeneralTextHandler.h" +#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/CStack.h" #include "../../lib/GameSettings.h" #include "../../lib/battle/CBattleInfoCallback.h" diff --git a/test/mock/mock_spells_Problem.h b/test/mock/mock_spells_Problem.h index 82c8728f8..41de00cb4 100644 --- a/test/mock/mock_spells_Problem.h +++ b/test/mock/mock_spells_Problem.h @@ -12,7 +12,7 @@ #include -#include "../../lib/MetaString.h" +#include "../../lib/texts/MetaString.h" namespace spells {