1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Rumors meta string

This commit is contained in:
nordsoft
2023-09-27 23:22:45 +02:00
parent ab373f08ab
commit 0ac893b80f
5 changed files with 15 additions and 14 deletions

View File

@@ -456,8 +456,7 @@ CTavernWindow::CTavernWindow(const CGObjectInstance * TavernObj)
heroDescription = std::make_shared<CTextBox>("", Rect(30, 373, 233, 35), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
heroesForHire = std::make_shared<CLabel>(145, 283, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, CGI->generaltexth->jktexts[38]);
auto rumorText = boost::str(boost::format(CGI->generaltexth->allTexts[216]) % LOCPLINT->cb->getTavernRumor(tavernObj));
rumor = std::make_shared<CTextBox>(rumorText, Rect(32, 188, 330, 66), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
rumor = std::make_shared<CTextBox>(LOCPLINT->cb->getTavernRumor(tavernObj), Rect(32, 188, 330, 66), 0, FONT_SMALL, ETextAlignment::CENTER, Colors::WHITE);
statusbar = CGStatusBar::create(std::make_shared<CPicture>(background->getSurface(), Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
cancel = std::make_shared<CButton>(Point(310, 428), AnimationPath::builtin("ICANCEL.DEF"), CButton::tooltip(CGI->generaltexth->tavernInfo[7]), std::bind(&CTavernWindow::close, this), EShortcut::GLOBAL_CANCEL);

View File

@@ -649,33 +649,34 @@ EPlayerStatus CGameInfoCallback::getPlayerStatus(PlayerColor player, bool verbos
std::string CGameInfoCallback::getTavernRumor(const CGObjectInstance * townOrTavern) const
{
std::string text;
MetaString text;
text.appendLocalString(EMetaText::GENERAL_TXT, 216);
std::string extraText;
if(gs->rumor.type == RumorState::TYPE_NONE)
return text;
return text.toString();
auto rumor = gs->rumor.last[gs->rumor.type];
switch(gs->rumor.type)
{
case RumorState::TYPE_SPECIAL:
text.replaceLocalString(EMetaText::GENERAL_TXT, rumor.first);
if(rumor.first == RumorState::RUMOR_GRAIL)
extraText = VLC->generaltexth->arraytxt[158 + rumor.second];
text.replaceTextID(TextIdentifier("core", "genrltxt", "arraytxt", 158 + rumor.second).get());
else
extraText = VLC->generaltexth->capColors[rumor.second];
text = boost::str(boost::format(VLC->generaltexth->allTexts[rumor.first]) % extraText);
text.replaceTextID(TextIdentifier("core", "genrltxt", "capitalColors", rumor.second).get());
break;
case RumorState::TYPE_MAP:
text = gs->map->rumors[rumor.first].text;
text.replaceRawString(gs->map->rumors[rumor.first].text.toString());
break;
case RumorState::TYPE_RAND:
text = VLC->generaltexth->tavernRumors[rumor.first];
text.replaceTextID(TextIdentifier("core", "genrltxt", "randtvrn", rumor.first).get());
break;
}
return text;
return text.toString();
}
PlayerRelations CGameInfoCallback::getPlayerRelations( PlayerColor color1, PlayerColor color2 ) const

View File

@@ -32,7 +32,7 @@ VCMI_LIB_NAMESPACE_BEGIN
void Rumor::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeString("name", name);
handler.serializeString("text", text);
handler.serializeStruct("text", text);
}
DisposedHero::DisposedHero() : heroId(0), portrait(255)

View File

@@ -11,6 +11,7 @@
#pragma once
#include "CMapHeader.h"
#include "../MetaString.h"
#include "../mapObjects/MiscObjects.h" // To serialize static props
#include "../mapObjects/CQuest.h" // To serialize static props
#include "../mapObjects/CGTownInstance.h" // To serialize static props
@@ -36,7 +37,7 @@ struct TeleportChannel;
struct DLL_LINKAGE Rumor
{
std::string name;
std::string text;
MetaString text;
Rumor() = default;
~Rumor() = default;

View File

@@ -807,7 +807,7 @@ void CMapLoaderH3M::readRumors()
{
Rumor ourRumor;
ourRumor.name = readBasicString();
ourRumor.text = readLocalizedString(TextIdentifier("header", "rumor", it, "text"));
ourRumor.text.appendTextID(readLocalizedString(TextIdentifier("header", "rumor", it, "text")));
map->rumors.push_back(ourRumor);
}
}