Skip to content

Commit

Permalink
Merge branch 'develop-rando' into potsanity
Browse files Browse the repository at this point in the history
  • Loading branch information
aMannus committed Jan 6, 2024
2 parents 039ddff + 1669393 commit ba9577c
Show file tree
Hide file tree
Showing 15 changed files with 620 additions and 880 deletions.
4 changes: 3 additions & 1 deletion soh/soh/Enhancements/randomizer/3drando/playthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ int Playthrough_Init(uint32_t seed, std::set<RandomizerCheck> excludedLocations,

for (Rando::Option* option : optionGroup.GetOptions()) {
if (option->IsCategory(Rando::OptionCategory::Setting)) {
settingsStr += option->GetSelectedOptionText();
if (option->GetOptionCount() > 0) {
settingsStr += option->GetSelectedOptionText();
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "utils.hpp"
#include "shops.hpp"
#include "hints.hpp"
#include "../randomizer_tricks.h"
#include "pool_functions.hpp"
#include "soh/Enhancements/randomizer/randomizer_check_objects.h"
#include <nlohmann/json.hpp>
Expand All @@ -31,6 +30,8 @@

#include <Context.h>

#include "consolevariablebridge.h"

using json = nlohmann::ordered_json;
using namespace Rando;

Expand Down
8 changes: 6 additions & 2 deletions soh/soh/Enhancements/randomizer/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <fstream>
#include <spdlog/spdlog.h>

#include "luslog.h"

namespace Rando {
std::weak_ptr<Context> Context::mContext;

Expand Down Expand Up @@ -247,7 +249,9 @@ void Context::LocationReset() {
GetItemLocation(il)->RemoveFromPool();
}

GetItemLocation(RC_GANONDORF_HINT)->RemoveFromPool();
for (const RandomizerCheck il : StaticData::otherHintLocations) {
GetItemLocation(il)->RemoveFromPool();
}
}

void Context::HintReset() {
Expand Down Expand Up @@ -604,7 +608,7 @@ Option& Context::GetOption(const RandomizerSettingKey key) const {
return mSettings->GetOption(key);
}

Option& Context::GetTrickOption(const RandomizerTrick key) const {
TrickOption& Context::GetTrickOption(const RandomizerTrick key) const {
return mSettings->GetTrickOption(key);
}
} // namespace Rando
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Context {
TrialInfo* GetTrial(size_t key) const;
static Sprite* GetSeedTexture(uint8_t index);
Option& GetOption(RandomizerSettingKey key) const;
Option& GetTrickOption(RandomizerTrick key) const;
TrickOption& GetTrickOption(RandomizerTrick key) const;
GetItemEntry GetFinalGIEntry(RandomizerCheck rc, bool checkObtainability = true, GetItemID ogItemId = GI_NONE);
void ParseSpoiler(const char* spoilerFileName, bool plandoMode);
void ParseHashIconIndexesJson(nlohmann::json spoilerFileJson);
Expand Down
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/item_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void Rando::StaticData::InitItemTable() {
itemTable[RG_KOKIRI_SWORD] = Item(RG_KOKIRI_SWORD, Text{ "Kokiri Sword", "Épée Kokiri", "Kokiri-Schwert" }, ITEMTYPE_ITEM, GI_SWORD_KOKIRI, true, &Logic::KokiriSword, RHT_KOKIRI_SWORD, ITEM_SWORD_KOKIRI, OBJECT_GI_SWORD_1, GID_SWORD_KOKIRI, 0xA4, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE);
itemTable[RG_MASTER_SWORD] = Item(RG_MASTER_SWORD, Text{ "Master Sword", "Épée de Legende", "Espada Master"}, ITEMTYPE_ITEM, 0xE0, true, &Logic::MasterSword, RHT_MASTER_SWORD, ITEM_SWORD_MASTER, OBJECT_TOKI_OBJECTS, GID_SWORD_BGS, TEXT_RANDOMIZER_CUSTOM_ITEM, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_RANDOMIZER);
itemTable[RG_MASTER_SWORD].SetCustomDrawFunc(Randomizer_DrawMasterSword);
itemTable[RG_GIANTS_KNIFE] = Item(RG_GIANTS_KNIFE, Text{ "Giant's Knife", "Lame des Géants", "Messer des Riesen" }, ITEMTYPE_ITEM, GI_SWORD_KNIFE, true, &Logic::KokiriSword, RHT_GIANTS_KNIFE, ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x4B, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE);
itemTable[RG_GIANTS_KNIFE] = Item(RG_GIANTS_KNIFE, Text{ "Giant's Knife", "Lame des Géants", "Messer des Riesen" }, ITEMTYPE_ITEM, GI_SWORD_KNIFE, true, &Logic::noVariable, RHT_GIANTS_KNIFE, ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x4B, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE);
itemTable[RG_BIGGORON_SWORD] = Item(RG_BIGGORON_SWORD, Text{ "Biggoron's Sword", "Épée de Biggoron", "Biggoron-Schwert" }, ITEMTYPE_ITEM, GI_SWORD_BGS, true, &Logic::BiggoronSword, RHT_BIGGORON_SWORD, ITEM_SWORD_BGS, OBJECT_GI_LONGSWORD, GID_SWORD_BGS, 0x0C, 0x80, CHEST_ANIM_LONG, ITEM_CATEGORY_MAJOR, MOD_NONE);
itemTable[RG_DEKU_SHIELD] = Item(RG_DEKU_SHIELD, Text{ "Deku Shield", "Bouclier Mojo", "Deku-Schild" }, ITEMTYPE_ITEM, GI_SHIELD_DEKU, false, &Logic::noVariable, RHT_DEKU_SHIELD, ITEM_SHIELD_DEKU, OBJECT_GI_SHIELD_1, GID_SHIELD_DEKU, 0x4C, 0xA0, CHEST_ANIM_SHORT, ITEM_CATEGORY_LESSER, MOD_NONE);
itemTable[RG_HYLIAN_SHIELD] = Item(RG_HYLIAN_SHIELD, Text{ "Hylian Shield", "Bouclier Hylien", "Hylia-Schild" }, ITEMTYPE_ITEM, GI_SHIELD_HYLIAN, false, &Logic::noVariable, RHT_HYLIAN_SHIELD, ITEM_SHIELD_HYLIAN, OBJECT_GI_SHIELD_2, GID_SHIELD_HYLIAN, 0x4D, 0xA0, CHEST_ANIM_SHORT, ITEM_CATEGORY_LESSER, MOD_NONE);
Expand Down
33 changes: 33 additions & 0 deletions soh/soh/Enhancements/randomizer/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const std::string& Option::GetName() const {
return name;
}

const std::string& Option::GetDescription() const {
return description;
}

uint8_t Option::GetSelectedOptionIndex() const {
return selectedOption;
}
Expand Down Expand Up @@ -297,6 +301,35 @@ bool Option::RenderSlider() const {
return changed;
}

TrickOption::TrickOption(const RandomizerCheckQuest quest_, const RandomizerArea area_, std::set<Tricks::Tag> tags_, const bool glitch_, const std::string& name_, std::string description_) :
Option(false, name_, {"Disabled", "Enabled"}, OptionCategory::Setting, "",
std::move(description_), WidgetType::Checkbox, 0, false, IMFLAG_NONE),
mQuest(quest_), mArea(area_), mTags(std::move(tags_)), mGlitch(glitch_) {}

TrickOption TrickOption::LogicTrick(RandomizerCheckQuest quest_, RandomizerArea area_, std::set<Tricks::Tag> tags_, bool glitch_, const std::string& name_, std::string description_) {
return {quest_, area_, std::move(tags_), glitch_, name_, std::move(description_)};
}

RandomizerCheckQuest TrickOption::GetQuest() const {
return mQuest;
}

RandomizerArea TrickOption::GetArea() const {
return mArea;
}

bool TrickOption::IsGlitch() const {
return mGlitch;
}

bool TrickOption::HasTag(const Tricks::Tag tag) const {
return mTags.contains(tag);
}

const std::set<Tricks::Tag>& TrickOption::GetTags() const {
return mTags;
}

OptionGroup::OptionGroup(std::string name, std::vector<Option*> options, const OptionGroupType groupType,
const bool printInSpoiler, const WidgetContainerType containerType, std::string description)
: mName(std::move(name)), mOptions(std::move(options)), mGroupType(groupType), mPrintInSpoiler(printInSpoiler),
Expand Down
64 changes: 63 additions & 1 deletion soh/soh/Enhancements/randomizer/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
#include "soh/UIWidgets.hpp"

#include <cstdint>
#include <set>
#include <string>
#include <vector>
#include <variant>
#include <type_traits>

#include "randomizerTypes.h"
#include "tricks.h"

namespace Rando {
enum ImGuiMenuFlags {
IMFLAG_NONE = 0,
Expand Down Expand Up @@ -181,6 +185,7 @@ class Option {
* @return const std::string&
*/
const std::string& GetName() const;
const std::string& GetDescription() const;

/**
* @brief Get the value name corresponding to the selected index.
Expand Down Expand Up @@ -302,13 +307,15 @@ class Option {
void SetFlag(int imFlag_);
void RemoveFlag(int imFlag_);

private:
protected:
Option(uint8_t var_, std::string name_, std::vector<std::string> options_, OptionCategory category_,
std::string cvarName_, std::string description_, WidgetType widgetType_, uint8_t defaultOption_,
bool defaultHidden_, int imFlags_);
Option(bool var_, std::string name_, std::vector<std::string> options_, OptionCategory category_,
std::string cvarName_, std::string description_, WidgetType widgetType_, uint8_t defaultOption_,
bool defaultHidden_, int imFlags_);

private:
bool RenderCheckbox() const;
bool RenderCombobox() const;
bool RenderSlider() const;
Expand All @@ -330,6 +337,61 @@ class Option {
std::string disabledText;
};

class TrickOption : public Option {
public:
TrickOption() = default;
/**
* @brief A convenience function for constructing the Option for a trick.
*
* @param quest_ MQ, Vanilla, or Both.
* @param area_ The area the trick is relevant for.
* @param tags_ The set of RandomizerTrickTags for this trick.
* @param glitch_ Whether or not this trick is a glitch.
* @param name_ The name of the trick. Appears in the spoiler/patch file.
* @param description_ A brief description of the trick.
* @return Option
*/
static TrickOption LogicTrick(RandomizerCheckQuest quest_, RandomizerArea area_, std::set<Tricks::Tag> tags_, bool glitch_, const std::string& name_, std::string description_);

/**
* @brief Retrieve the quest type this trick is relevant for.
*
* @return RandomizerCheckQuest
*/
RandomizerCheckQuest GetQuest() const;

/**
* @brief Get the Area this trick is used in
*
* @return RandomizerArea
*/
RandomizerArea GetArea() const;

/**
* @brief Get whether or not this Trick is considered a glitch.
*
* @return true or false
*/
bool IsGlitch() const;

/**
* @brief Check if this Trick has the given tag
*
* @param tag the RandomizerTrickTag to check for
* @return true or false
*/
bool HasTag(Tricks::Tag tag) const;

const std::set<Tricks::Tag>& GetTags() const;

private:
TrickOption(RandomizerCheckQuest quest_, RandomizerArea area_, std::set<Tricks::Tag> tags_, bool glitch_, const std::string& name_, std::string description_);
RandomizerCheckQuest mQuest;
RandomizerArea mArea;
std::set<Tricks::Tag> mTags;
bool mGlitch;
};

enum class OptionGroupType {
DEFAULT,
SUBGROUP,
Expand Down
Loading

0 comments on commit ba9577c

Please sign in to comment.