Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
SaveFile Class Reference

One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between them. More...

#include <savefile.h>

Inheritance diagram for SaveFile:
Collaboration diagram for SaveFile:

Public Member Functions

 SaveFile (QObject *parent=nullptr)
 The expanded, editable object tree. QML traverses in from here.
virtual ~SaveFile ()
SaveFileIteratoriterator ()
 Returns a unique iterator that's setup to iterate over the raw sav file data.
void setData (var8 *data, bool silent=false)
 Change-out the save file.
void resetData (bool silent=false)
 Empty this save file to zero's.
void flattenData ()
 Flatten expansion back to the save file, overwriting it's current contents with only data that's strictly nesesary.
void expandData ()
 Replace expansion with new expansion of current sav file.
void eraseExpansion ()
 Erase expansion data, this makes expansion data act like a new file but save file contents are preserved.
void randomizeExpansion ()
 Fully randomizes the expansion data, doesn't change save file data.

Public Attributes

var8data = nullptr
 Actual SAV Data, a raw internal binary copy of the file.
SaveFileExpandeddataExpanded = nullptr
 Expanded SAV data to be readable and more usable.
SaveFileToolsettoolset = nullptr
 Tools to operate directly on the raw sav file data.

Protected Member Functions

void dataExpandedChanged (SaveFileExpanded *expanded)
 SAV file has changed but the old expansion has not been replaced with exxpansion of new data.

Protected Attributes

 : void dataChanged(var8* data)

Detailed Description

One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between them.

SaveFile is the hinge of the whole app. It holds three things: the raw byte buffer data (the on-disk source of truth), the dataExpanded object tree that the QML UI actually edits, and a toolset for byte-level access. Its verbs move data between the two representations – expandData() parses raw -> objects, flattenData() writes objects -> raw (only the strictly-necessary bytes). It is exposed to QML through FileManagement as brg.file.data.

See also
SaveFileExpanded (the object tree), SaveFileToolset / SaveFileIterator (byte access), and the system map.

Definition at line 45 of file savefile.h.

Constructor & Destructor Documentation

◆ SaveFile()

SaveFile::SaveFile ( QObject * parent = nullptr)

The expanded, editable object tree. QML traverses in from here.

Create a blank save file and a blank expanded save file.

Definition at line 27 of file savefile.cpp.

References data, dataExpanded, resetData(), SAV_DATA_SIZE, and toolset.

◆ ~SaveFile()

SaveFile::~SaveFile ( )
virtual

Definition at line 45 of file savefile.cpp.

References data, dataExpanded, and toolset.

Member Function Documentation

◆ dataExpandedChanged()

void SaveFile::dataExpandedChanged ( SaveFileExpanded * expanded)
protected

SAV file has changed but the old expansion has not been replaced with exxpansion of new data.

References eraseExpansion(), expandData(), flattenData(), randomizeExpansion(), and resetData().

Referenced by ItemMarketModel::ItemMarketModel(), resetData(), setData(), and Settings::Settings().

◆ eraseExpansion()

void SaveFile::eraseExpansion ( )

Erase expansion data, this makes expansion data act like a new file but save file contents are preserved.

Definition at line 99 of file savefile.cpp.

References dataExpanded.

Referenced by dataExpandedChanged().

◆ expandData()

void SaveFile::expandData ( )

Replace expansion with new expansion of current sav file.

Definition at line 94 of file savefile.cpp.

References dataExpanded.

Referenced by dataExpandedChanged(), resetData(), and setData().

◆ flattenData()

void SaveFile::flattenData ( )

Flatten expansion back to the save file, overwriting it's current contents with only data that's strictly nesesary.

A critical rule.

Definition at line 89 of file savefile.cpp.

References dataExpanded.

Referenced by dataExpandedChanged().

◆ iterator()

◆ randomizeExpansion()

void SaveFile::randomizeExpansion ( )

Fully randomizes the expansion data, doesn't change save file data.

This tries to give fun and playable randomization. Due to the complexity of Gen 1 Games there are limits on randomization. The idea is to randomize everything we can and still allow you to jump in and play right away with Your Psychic Traded Pikachu named Bob that uses Ice Beam and Splash.

Definition at line 104 of file savefile.cpp.

References dataExpanded.

Referenced by dataExpandedChanged(), and pse::shortcutActions().

◆ resetData()

void SaveFile::resetData ( bool silent = false)

Empty this save file to zero's.

Re-Expand the empty save file, overwriting prior expansion, unless marked silent.

Definition at line 58 of file savefile.cpp.

References data, dataExpanded, dataExpandedChanged(), expandData(), and SAV_DATA_SIZE.

Referenced by dataExpandedChanged(), and SaveFile().

◆ setData()

void SaveFile::setData ( var8 * data,
bool silent = false )

Change-out the save file.

Re-Expand the new save file, overwriting prior expansion, unless marked silent.

Parameters
dataNew raw save bytes to adopt.
silentWhen true, skip re-expanding the new data.

Definition at line 69 of file savefile.cpp.

References data, dataExpanded, dataExpandedChanged(), expandData(), and SAV_DATA_SIZE.

Member Data Documentation

◆ __pad0__

SaveFile::__pad0__
protected

Definition at line 75 of file savefile.h.

◆ data

var8* SaveFile::data = nullptr

Actual SAV Data, a raw internal binary copy of the file.

Definition at line 111 of file savefile.h.

Referenced by resetData(), SaveFile(), setData(), and ~SaveFile().

◆ dataExpanded

SaveFileExpanded* SaveFile::dataExpanded = nullptr

Expanded SAV data to be readable and more usable.

Definition at line 114 of file savefile.h.

Referenced by eraseExpansion(), expandData(), flattenData(), randomizeExpansion(), resetData(), SaveFile(), setData(), and ~SaveFile().

◆ toolset


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