yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::RomLoadOptionsDialog Class Reference

ROM load options dialog. More...

#include <rom_load_options_dialog.h>

Collaboration diagram for yaze::editor::RomLoadOptionsDialog:

Classes

struct  LoadOptions
 
struct  RememberedChoice
 

Public Member Functions

 RomLoadOptionsDialog ()
 
 ~RomLoadOptionsDialog ()=default
 
void Open (Rom *rom, const std::string &rom_filename)
 Open the dialog after ROM detection.
 
void Open (Rom *rom, const std::string &rom_filename, bool suggest_project_creation)
 
void Open (Rom *rom)
 Open the dialog with just ROM pointer (filename from ROM)
 
void Open (Rom *rom, bool suggest_project_creation)
 
void OpenForReview (Rom *rom, const core::FeatureFlags::Flags &active, const std::string &preset_name, bool remembered)
 Reopen the dialog for a ROM that is already loaded.
 
bool Show (bool *p_open)
 Show the dialog.
 
void Draw (bool *p_open)
 Draw the dialog (wrapper around Show)
 
const LoadOptions & GetOptions () const
 Get the selected load options.
 
bool WasConfirmed () const
 Check if dialog resulted in confirmation.
 
void ResetConfirmation ()
 Reset confirmation state.
 
void SetConfirmCallback (std::function< void(const LoadOptions &)> callback)
 Set callback for when options are confirmed.
 
void SetCancelCallback (std::function< void()> callback)
 Set callback for Cancel or the title-bar close button.
 
void SetApplyGuard (std::function< bool()> guard)
 
void Close ()
 
zelda3::OverworldVersion GetDetectedVersion () const
 Get detected ROM version.
 
const std::string & rom_filename () const
 
int zso_version_byte () const
 
bool reviewing () const
 
bool OverworldLoadOptionsChanged () const
 

Static Public Member Functions

static std::string EncodeRememberedChoice (const LoadOptions &options, int zso_version_byte)
 
static std::optional< RememberedChoice > DecodeRememberedChoice (std::string_view encoded)
 
static std::string RomChoiceKey (const std::string &rom_path)
 
static void ApplyToFeatureFlags (const LoadOptions &options, core::FeatureFlags::Flags &flags)
 
static LoadOptions OptionsFromFeatureFlags (const core::FeatureFlags::Flags &flags)
 

Private Member Functions

void DrawVersionInfo ()
 
void DrawOverworldOptions ()
 
void DrawFeatureFlagPresets ()
 
void DrawFeatureFlagDetails ()
 
void DrawProjectOptions ()
 
void DrawActionButtons ()
 
void ApplyPreset (const std::string &preset_name)
 
void ApplyOptionsToFeatureFlags ()
 

Private Attributes

Rom * rom_ = nullptr
 
std::string rom_filename_
 
zelda3::OverworldVersion detected_version_
 
bool is_open_ = false
 
bool confirmed_ = false
 
bool show_advanced_ = false
 
bool reviewing_ = false
 
int zso_version_byte_ = -1
 
bool loaded_custom_overworld_ = false
 
bool loaded_tail_expansion_ = false
 
LoadOptions options_
 
int selected_preset_index_ = 0
 
std::function< void(const LoadOptions &) confirm_callback_ )
 
std::function< void()> cancel_callback_
 
std::function< bool()> apply_guard_
 
char project_name_buffer_ [256] = {}
 
char project_path_buffer_ [512] = {}
 

Static Private Attributes

static constexpr int kNumPresets = 4
 
static const char * kPresetNames [kNumPresets]
 
static const char * kPresetDescriptions [kNumPresets]
 

Detailed Description

ROM load options dialog.

Shown after an interactive raw ROM open, and from the command palette to review the options a session uses now. It offers:

  • Overworld load options (custom overworld fields, special world tail)
  • Save flag presets based on the detected version
  • Project creation integration

It never changes the ROM. ZSCustomOverworld ASM is applied from the Overworld toolbar's Upgrade button.

Definition at line 33 of file rom_load_options_dialog.h.

Constructor & Destructor Documentation

◆ RomLoadOptionsDialog()

◆ ~RomLoadOptionsDialog()

yaze::editor::RomLoadOptionsDialog::~RomLoadOptionsDialog ( )
default

Member Function Documentation

◆ Open() [1/4]

void yaze::editor::RomLoadOptionsDialog::Open ( Rom * rom,
const std::string & rom_filename )

Open the dialog after ROM detection.

Parameters
romPointer to loaded ROM for version detection
rom_filenameFilename for display and project naming

Definition at line 92 of file rom_load_options_dialog.cc.

References Open(), and rom_filename().

Referenced by yaze::editor::EditorManager::FinishRawRomOpen(), Open(), Open(), Open(), and OpenForReview().

Here is the call graph for this function:

◆ Open() [2/4]

◆ Open() [3/4]

void yaze::editor::RomLoadOptionsDialog::Open ( Rom * rom)

Open the dialog with just ROM pointer (filename from ROM)

Parameters
romPointer to loaded ROM

Definition at line 76 of file rom_load_options_dialog.cc.

References yaze::Rom::filename(), and Open().

Here is the call graph for this function:

◆ Open() [4/4]

void yaze::editor::RomLoadOptionsDialog::Open ( Rom * rom,
bool suggest_project_creation )

Definition at line 82 of file rom_load_options_dialog.cc.

References yaze::Rom::filename(), and Open().

Here is the call graph for this function:

◆ OpenForReview()

void yaze::editor::RomLoadOptionsDialog::OpenForReview ( Rom * rom,
const core::FeatureFlags::Flags & active,
const std::string & preset_name,
bool remembered )

Reopen the dialog for a ROM that is already loaded.

Parameters
activeFeature flags the session uses now (what Save writes)
preset_nameRemembered preset to select; empty keeps the default
rememberedWhether this ROM file has a remembered choice

Definition at line 164 of file rom_load_options_dialog.cc.

References yaze::editor::RomLoadOptionsDialog::LoadOptions::create_project, yaze::Rom::filename(), yaze::core::FeatureFlags::Flags::Overworld::kEnableSpecialWorldExpansion, yaze::core::FeatureFlags::Flags::Overworld::kLoadCustomOverworld, kNumPresets, kPresetNames, loaded_custom_overworld_, loaded_tail_expansion_, Open(), options_, OptionsFromFeatureFlags(), yaze::core::FeatureFlags::Flags::overworld, yaze::editor::RomLoadOptionsDialog::LoadOptions::remember_for_rom, reviewing_, selected_preset_index_, and show_advanced_.

Referenced by yaze::editor::EditorManager::ShowRomLoadOptions().

Here is the call graph for this function:

◆ Show()

bool yaze::editor::RomLoadOptionsDialog::Show ( bool * p_open)

Show the dialog.

Parameters
p_openPointer to open state
Returns
True if user confirmed options

Definition at line 192 of file rom_load_options_dialog.cc.

References cancel_callback_, confirmed_, DrawActionButtons(), DrawFeatureFlagDetails(), DrawFeatureFlagPresets(), DrawOverworldOptions(), DrawProjectOptions(), DrawVersionInfo(), yaze::gui::GetInfoColor(), ICON_MD_SETTINGS, is_open_, reviewing_, and show_advanced_.

Referenced by Draw().

◆ Draw()

void yaze::editor::RomLoadOptionsDialog::Draw ( bool * p_open)

Draw the dialog (wrapper around Show)

Parameters
p_openPointer to open state

Definition at line 88 of file rom_load_options_dialog.cc.

References Show().

Referenced by yaze::editor::EditorManager::DrawInterface().

Here is the call graph for this function:

◆ GetOptions()

const LoadOptions & yaze::editor::RomLoadOptionsDialog::GetOptions ( ) const
inline

Get the selected load options.

Definition at line 114 of file rom_load_options_dialog.h.

References options_.

◆ WasConfirmed()

bool yaze::editor::RomLoadOptionsDialog::WasConfirmed ( ) const
inline

Check if dialog resulted in confirmation.

Definition at line 119 of file rom_load_options_dialog.h.

References confirmed_.

◆ ResetConfirmation()

void yaze::editor::RomLoadOptionsDialog::ResetConfirmation ( )
inline

Reset confirmation state.

Definition at line 124 of file rom_load_options_dialog.h.

References confirmed_.

◆ SetConfirmCallback()

void yaze::editor::RomLoadOptionsDialog::SetConfirmCallback ( std::function< void(const LoadOptions &)> callback)
inline

Set callback for when options are confirmed.

Definition at line 129 of file rom_load_options_dialog.h.

References confirm_callback_.

Referenced by yaze::editor::EditorManager::SetupDialogCallbacks().

◆ SetCancelCallback()

void yaze::editor::RomLoadOptionsDialog::SetCancelCallback ( std::function< void()> callback)
inline

Set callback for Cancel or the title-bar close button.

Definition at line 136 of file rom_load_options_dialog.h.

References cancel_callback_.

Referenced by yaze::editor::EditorManager::SetupDialogCallbacks().

◆ SetApplyGuard()

void yaze::editor::RomLoadOptionsDialog::SetApplyGuard ( std::function< bool()> guard)
inline

◆ Close()

void yaze::editor::RomLoadOptionsDialog::Close ( )
inline

◆ GetDetectedVersion()

zelda3::OverworldVersion yaze::editor::RomLoadOptionsDialog::GetDetectedVersion ( ) const
inline

Get detected ROM version.

Definition at line 152 of file rom_load_options_dialog.h.

References detected_version_.

◆ rom_filename()

const std::string & yaze::editor::RomLoadOptionsDialog::rom_filename ( ) const
inline

◆ zso_version_byte()

int yaze::editor::RomLoadOptionsDialog::zso_version_byte ( ) const
inline

◆ reviewing()

bool yaze::editor::RomLoadOptionsDialog::reviewing ( ) const
inline

◆ OverworldLoadOptionsChanged()

◆ EncodeRememberedChoice()

std::string yaze::editor::RomLoadOptionsDialog::EncodeRememberedChoice ( const LoadOptions & options,
int zso_version_byte )
static

Definition at line 563 of file rom_load_options_dialog.cc.

References yaze::editor::RomLoadOptionsDialog::LoadOptions::selected_preset, and zso_version_byte().

Referenced by yaze::editor::EditorManager::SetupDialogCallbacks().

Here is the call graph for this function:

◆ DecodeRememberedChoice()

◆ RomChoiceKey()

◆ ApplyToFeatureFlags()

void yaze::editor::RomLoadOptionsDialog::ApplyToFeatureFlags ( const LoadOptions & options,
core::FeatureFlags::Flags & flags )
static

Definition at line 533 of file rom_load_options_dialog.cc.

References yaze::editor::RomLoadOptionsDialog::LoadOptions::enable_custom_overworld, yaze::editor::RomLoadOptionsDialog::LoadOptions::enable_tail_expansion, yaze::core::FeatureFlags::Flags::Overworld::kEnableSpecialWorldExpansion, yaze::core::FeatureFlags::Flags::Overworld::kLoadCustomOverworld, yaze::core::FeatureFlags::Flags::kSaveAllPalettes, yaze::core::FeatureFlags::Flags::kSaveDungeonMaps, yaze::core::FeatureFlags::Flags::kSaveGfxGroups, yaze::core::FeatureFlags::Flags::Overworld::kSaveOverworldEntrances, yaze::core::FeatureFlags::Flags::Overworld::kSaveOverworldExits, yaze::core::FeatureFlags::Flags::Overworld::kSaveOverworldItems, yaze::core::FeatureFlags::Flags::Overworld::kSaveOverworldMaps, yaze::core::FeatureFlags::Flags::Overworld::kSaveOverworldSprites, yaze::core::FeatureFlags::Flags::overworld, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_all_palettes, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_dungeon_maps, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_gfx_groups, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_overworld_entrances, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_overworld_exits, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_overworld_items, yaze::editor::RomLoadOptionsDialog::LoadOptions::save_overworld_maps, and yaze::editor::RomLoadOptionsDialog::LoadOptions::save_overworld_sprites.

Referenced by ApplyOptionsToFeatureFlags(), yaze::editor::EditorManager::ApplyRememberedRomLoadChoice(), and yaze::editor::EditorManager::SetupDialogCallbacks().

◆ OptionsFromFeatureFlags()

RomLoadOptionsDialog::LoadOptions yaze::editor::RomLoadOptionsDialog::OptionsFromFeatureFlags ( const core::FeatureFlags::Flags & flags)
static

◆ DrawVersionInfo()

◆ DrawOverworldOptions()

◆ DrawFeatureFlagPresets()

void yaze::editor::RomLoadOptionsDialog::DrawFeatureFlagPresets ( )
private

Definition at line 333 of file rom_load_options_dialog.cc.

References ApplyPreset(), yaze::gui::GetTextSecondaryVec4(), ICON_MD_TUNE, kNumPresets, kPresetDescriptions, kPresetNames, selected_preset_index_, and show_advanced_.

Referenced by Show().

Here is the call graph for this function:

◆ DrawFeatureFlagDetails()

◆ DrawProjectOptions()

void yaze::editor::RomLoadOptionsDialog::DrawProjectOptions ( )
private

◆ DrawActionButtons()

◆ ApplyPreset()

◆ ApplyOptionsToFeatureFlags()

void yaze::editor::RomLoadOptionsDialog::ApplyOptionsToFeatureFlags ( )
private

Definition at line 529 of file rom_load_options_dialog.cc.

References ApplyToFeatureFlags(), yaze::core::FeatureFlags::get(), and options_.

Referenced by DrawActionButtons().

Here is the call graph for this function:

Member Data Documentation

◆ rom_

Rom* yaze::editor::RomLoadOptionsDialog::rom_ = nullptr
private

Definition at line 194 of file rom_load_options_dialog.h.

Referenced by Open().

◆ rom_filename_

std::string yaze::editor::RomLoadOptionsDialog::rom_filename_
private

Definition at line 195 of file rom_load_options_dialog.h.

Referenced by DrawVersionInfo(), Open(), and rom_filename().

◆ detected_version_

zelda3::OverworldVersion yaze::editor::RomLoadOptionsDialog::detected_version_
private
Initial value:

Definition at line 196 of file rom_load_options_dialog.h.

Referenced by DrawVersionInfo(), GetDetectedVersion(), and Open().

◆ is_open_

bool yaze::editor::RomLoadOptionsDialog::is_open_ = false
private

Definition at line 198 of file rom_load_options_dialog.h.

Referenced by Close(), DrawActionButtons(), Open(), and Show().

◆ confirmed_

bool yaze::editor::RomLoadOptionsDialog::confirmed_ = false
private

◆ show_advanced_

bool yaze::editor::RomLoadOptionsDialog::show_advanced_ = false
private

Definition at line 200 of file rom_load_options_dialog.h.

Referenced by DrawFeatureFlagPresets(), Open(), OpenForReview(), and Show().

◆ reviewing_

bool yaze::editor::RomLoadOptionsDialog::reviewing_ = false
private

Definition at line 201 of file rom_load_options_dialog.h.

Referenced by DrawActionButtons(), Open(), OpenForReview(), reviewing(), and Show().

◆ zso_version_byte_

int yaze::editor::RomLoadOptionsDialog::zso_version_byte_ = -1
private

Definition at line 202 of file rom_load_options_dialog.h.

Referenced by Open(), and zso_version_byte().

◆ loaded_custom_overworld_

bool yaze::editor::RomLoadOptionsDialog::loaded_custom_overworld_ = false
private

Definition at line 204 of file rom_load_options_dialog.h.

Referenced by Open(), OpenForReview(), and OverworldLoadOptionsChanged().

◆ loaded_tail_expansion_

bool yaze::editor::RomLoadOptionsDialog::loaded_tail_expansion_ = false
private

Definition at line 205 of file rom_load_options_dialog.h.

Referenced by Open(), OpenForReview(), and OverworldLoadOptionsChanged().

◆ options_

◆ kNumPresets

constexpr int yaze::editor::RomLoadOptionsDialog::kNumPresets = 4
staticconstexprprivate

Definition at line 211 of file rom_load_options_dialog.h.

Referenced by DrawFeatureFlagPresets(), and OpenForReview().

◆ kPresetNames

const char * yaze::editor::RomLoadOptionsDialog::kPresetNames
staticprivate
Initial value:
= {
"Vanilla ROM Hack", "ZSCustomOverworld v2",
"ZSCustomOverworld v3 (Recommended)", "Randomizer Compatible"}

Definition at line 212 of file rom_load_options_dialog.h.

Referenced by DrawActionButtons(), DrawFeatureFlagPresets(), Open(), and OpenForReview().

◆ kPresetDescriptions

const char * yaze::editor::RomLoadOptionsDialog::kPresetDescriptions
staticprivate
Initial value:
= {
"Standard ROM editing without custom ASM. Limited to vanilla features.",
"Basic overworld expansion: custom BG colors, main palettes, parent "
"system.",
"Full overworld expansion: wide/tall areas, animated GFX, overlays, all "
"features.",
"Compatible with ALttP Randomizer. Minimal custom features."}

Definition at line 213 of file rom_load_options_dialog.h.

Referenced by DrawFeatureFlagPresets().

◆ selected_preset_index_

int yaze::editor::RomLoadOptionsDialog::selected_preset_index_ = 0
private

◆ confirm_callback_

std::function<void(const LoadOptions&) yaze::editor::RomLoadOptionsDialog::confirm_callback_)
private

Definition at line 217 of file rom_load_options_dialog.h.

Referenced by DrawActionButtons(), and SetConfirmCallback().

◆ cancel_callback_

std::function<void()> yaze::editor::RomLoadOptionsDialog::cancel_callback_
private

Definition at line 218 of file rom_load_options_dialog.h.

Referenced by SetCancelCallback(), and Show().

◆ apply_guard_

std::function<bool()> yaze::editor::RomLoadOptionsDialog::apply_guard_
private

Definition at line 219 of file rom_load_options_dialog.h.

Referenced by DrawActionButtons(), and SetApplyGuard().

◆ project_name_buffer_

char yaze::editor::RomLoadOptionsDialog::project_name_buffer_[256] = {}
private

Definition at line 222 of file rom_load_options_dialog.h.

Referenced by DrawProjectOptions(), and Open().

◆ project_path_buffer_

char yaze::editor::RomLoadOptionsDialog::project_path_buffer_[512] = {}
private

Definition at line 223 of file rom_load_options_dialog.h.


The documentation for this class was generated from the following files: