add entrance aliases

This commit is contained in:
gymnast86
2026-04-08 16:11:11 -07:00
parent 1efb6c4a80
commit 554a461c95
5 changed files with 211 additions and 11 deletions
File diff suppressed because it is too large Load Diff
+24 -1
View File
@@ -121,9 +121,32 @@ namespace randomizer::logic::entrance
return this->_originalName;
}
void Entrance::GeneralizeOriginalName()
void Entrance::SetAlias(const std::string& alias)
{
this->_alias = alias;
// If there's no alias, just use the original name
if (this->_alias.empty())
{
this->_alias = this->_originalName;
}
}
std::string Entrance::GetAlias() const
{
return this->_alias;
}
std::string Entrance::GetAliasFrom()
{
std::string parentAreaAlias = this->_alias.substr(0, this->_alias.find(" -> "));
std::string connectedAreaAlias = this->_alias.substr(this->_alias.find(" -> ") + 4);
return connectedAreaAlias + " from " + parentAreaAlias;
}
void Entrance::GeneralizeName()
{
randomizer::utility::str::Erase(this->_originalName, " North", " South", " East", " West", " Right", " Left");
randomizer::utility::str::Erase(this->_alias, " North", " South", " East", " West", " Right", " Left");
}
randomizer::logic::area::Area* Entrance::GetParentArea() const
+9 -2
View File
@@ -76,10 +76,16 @@ namespace randomizer::logic::entrance
int GetID() const;
std::string GetCurrentName() const;
std::string GetOriginalName() const;
void SetAlias(const std::string& alias);
std::string GetAlias() const;
/*
* @brief Gets the alias in the "connected area from parent area" format
*/
std::string GetAliasFrom();
/**
* @brief Removes cardinal/direction specifiers from the entrance's name (North, South, East, West, Left, Right)
* @brief Removes cardinal/direction specifiers from the entrance's name/alias (North, South, East, West, Left, Right)
*/
void GeneralizeOriginalName();
void GeneralizeName();
randomizer::logic::area::Area* GetParentArea() const;
randomizer::logic::area::Area* GetConnectedArea() const;
randomizer::logic::area::Area* GetOriginalConnectedArea() const;
@@ -150,6 +156,7 @@ namespace randomizer::logic::entrance
Type _type = Type::INVALID;
Type _originalType = Type::INVALID;
std::string _originalName = "";
std::string _alias = "";
randomizer::logic::world::World* _world = nullptr;
/**
@@ -66,6 +66,8 @@ namespace randomizer::logic::entrance_shuffle
// TODO: Set actual entrance data
forwardEntrance->SetID(world->GetNewEntranceID());
forwardEntrance->SetPrimary(true);
forwardEntrance->SetAlias(
forwardEntry["Alias"] ? forwardEntry["Alias"].as<std::string>() : "");
if (entranceDataNode["Return"])
{
@@ -76,6 +78,8 @@ namespace randomizer::logic::entrance_shuffle
returnEntrance->SetType(type);
// TODO: Set actual entrance data
returnEntrance->SetID(world->GetNewEntranceID());
returnEntrance->SetAlias(
returnEntry["Alias"] ? returnEntry["Alias"].as<std::string>() : "");
forwardEntrance->BindTwoWay(returnEntrance);
// Add double door entrances to their respective tag group
@@ -117,7 +121,7 @@ namespace randomizer::logic::entrance_shuffle
coupledDoor->GetParentArea()->RemoveExit(coupledDoor);
// Change the main door's name to be more general
mainDoor->GeneralizeOriginalName();
mainDoor->GeneralizeName();
}
}
}
+5 -7
View File
@@ -21,18 +21,16 @@ namespace randomizer::logic::spoiler_log
std::string SpoilerFormatEntrance(randomizer::logic::entrance::Entrance* entrance, const size_t& longestNameLength)
{
auto numSpaces = longestNameLength - entrance->GetOriginalName().length();
auto numSpaces = longestNameLength - entrance->GetAlias().length();
std::string spaces(numSpaces, ' ');
auto replacement = entrance->GetReplaces();
auto parent = replacement->GetParentArea()->GetName();
auto connected = replacement->GetOriginalConnectedArea()->GetName();
return entrance->GetOriginalName() + ": " + spaces + connected + " from " + parent;
return entrance->GetAlias() + ": " + spaces + replacement->GetAliasFrom();
}
void LogBasicInfo(std::ofstream& log, randomizer::seedgen::config::Config& config, randomizer::logic::world::WorldPool& worlds)
{
log << "Twilight Princess HD Randomizer Version: " << "1.0.0" << std::endl;
log << "Dusk Randomizer Version: " << "1.0.0" << std::endl;
log << "Seed: " << config.GetSeed() << std::endl;
// TODO: Setting string
@@ -117,7 +115,7 @@ namespace randomizer::logic::spoiler_log
{
for (const auto& entrance : sphere)
{
longestNameLength = std::max(entrance->GetOriginalName().length(), longestNameLength);
longestNameLength = std::max(entrance->GetAlias().length(), longestNameLength);
}
}
@@ -169,7 +167,7 @@ namespace randomizer::logic::spoiler_log
{
for (const auto& entrance : world->GetShuffledEntrances())
{
longestNameLength = std::max(entrance->GetOriginalName().length(), longestNameLength);
longestNameLength = std::max(entrance->GetAlias().length(), longestNameLength);
}
}
// Print all randomized entrances