mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-04 10:34:01 +00:00
Implement setSceneDisplayNameInSave() Lua function.
This allows to specify pretty map names to be shown in save slots for mods.
This commit is contained in:
parent
abc35b4c9d
commit
65e2bd83b2
4 changed files with 35 additions and 26 deletions
|
@ -277,32 +277,8 @@ void AquariaSaveSlot::onUpdate(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc)
|
||||
static std::string getPrettySceneName_internal(const XMLElement *startData)
|
||||
{
|
||||
const XMLElement *startData = doc.FirstChildElement("StartData");
|
||||
if (!startData)
|
||||
return "";
|
||||
|
||||
int hours, minutes, seconds;
|
||||
hours = minutes = seconds = 0;
|
||||
|
||||
int time = 0;
|
||||
if (startData->Attribute("seconds"))
|
||||
{
|
||||
std::istringstream is(startData->Attribute("seconds"));
|
||||
is >> time;
|
||||
}
|
||||
|
||||
float s = dsq->continuity.seconds;
|
||||
dsq->continuity.seconds = time;
|
||||
dsq->continuity.getHoursMinutesSeconds(&hours, &minutes, &seconds);
|
||||
|
||||
/*
|
||||
std::ostringstream os;
|
||||
os << "Slot: " << slot << " - " << startData->Attribute("scene") << " - exp: " << exp << " - wealth: " << money;
|
||||
os << " Time: " << hours << ": " << minutes << ": " << seconds << " T: " << time;
|
||||
*/
|
||||
std::string location = startData->Attribute("scene");
|
||||
stringToLower(location);
|
||||
if (location.find("boilerroom")!=std::string::npos)
|
||||
|
@ -406,6 +382,31 @@ std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc)
|
|||
{
|
||||
location = dsq->continuity.stringBank.get(1029);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
std::string AquariaSaveSlot::getSaveDescription(const XMLDocument &doc)
|
||||
{
|
||||
const XMLElement *startData = doc.FirstChildElement("StartData");
|
||||
if (!startData)
|
||||
return "";
|
||||
|
||||
int hours, minutes, seconds;
|
||||
hours = minutes = seconds = 0;
|
||||
|
||||
int time = 0;
|
||||
if (startData->Attribute("seconds"))
|
||||
{
|
||||
std::istringstream is(startData->Attribute("seconds"));
|
||||
is >> time;
|
||||
}
|
||||
|
||||
float s = dsq->continuity.seconds;
|
||||
dsq->continuity.seconds = time;
|
||||
dsq->continuity.getHoursMinutesSeconds(&hours, &minutes, &seconds);
|
||||
|
||||
const char *loccstr = startData->Attribute("sceneDisplayName");
|
||||
std::string location = (loccstr && *loccstr) ? loccstr : getPrettySceneName_internal(startData);
|
||||
|
||||
std::string showLoc;
|
||||
if (dsq->isDeveloperKeys())
|
||||
|
|
|
@ -2552,6 +2552,7 @@ void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData,
|
|||
startData->SetAttribute("x", int(position.x));
|
||||
startData->SetAttribute("y", int(position.y));
|
||||
startData->SetAttribute("scene", dsq->game->sceneName.c_str());
|
||||
startData->SetAttribute("sceneDisplayName", dsq->game->sceneDisplayName.c_str());
|
||||
startData->SetAttribute("exp", dsq->continuity.exp);
|
||||
startData->SetAttribute("h", dsq->continuity.maxHealth);
|
||||
startData->SetAttribute("ch", dsq->continuity.health);
|
||||
|
|
|
@ -681,7 +681,7 @@ public:
|
|||
void handleShotCollisionsHair(Entity *e, int num = 0, float perc = 0);
|
||||
|
||||
std::vector<ElementTemplate> elementTemplates;
|
||||
std::string sceneName;
|
||||
std::string sceneName, sceneDisplayName;
|
||||
|
||||
ElementTemplate *getElementTemplateByIdx(int idx);
|
||||
|
||||
|
|
|
@ -4683,6 +4683,12 @@ luaFunc(saveMenu)
|
|||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(setSceneDisplayNameInSave)
|
||||
{
|
||||
dsq->game->sceneDisplayName = getString(L);
|
||||
luaReturnNil();
|
||||
}
|
||||
|
||||
luaFunc(pause)
|
||||
{
|
||||
dsq->game->togglePause(1);
|
||||
|
@ -9878,6 +9884,7 @@ static const struct {
|
|||
|
||||
luaRegister(savePoint),
|
||||
luaRegister(saveMenu),
|
||||
luaRegister(setSceneDisplayNameInSave),
|
||||
luaRegister(wait),
|
||||
luaRegister(watch),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue