Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
savefile.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QtCore/QObject>
18#include <QtCore/qglobal.h>
19
20#include <pse-common/types.h>
21#include "savefile_autoport.h"
22
24
27class SaveFileToolset;
28
29constexpr var16 SAV_DATA_SIZE{0x8000};
30
45class SAVEFILE_AUTOPORT SaveFile : public QObject
46{
47 Q_OBJECT
48
51
52public:
54 SaveFile(QObject *parent = nullptr);
55 virtual ~SaveFile();
56
66
75 void setData(var8* data, bool silent = false);
76
77signals:
79 void dataChanged(var8* data);
80
84
85public slots:
89 void resetData(bool silent = false);
90
93 void flattenData();
94
96 void expandData();
97
100 void eraseExpansion();
101
107 void randomizeExpansion();
108
109public:
111 var8* data = nullptr;
112
115
118};
Root of the editable object tree – the friendly mirror of a raw save.
A moving cursor over a SaveFile, layering auto-advancing reads/writes on top of SaveFileToolset.
Low-level read/write primitives over a SaveFile's raw 32 KB buffer.
void randomizeExpansion()
Fully randomizes the expansion data, doesn't change save file data.
Definition savefile.cpp:104
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
Definition savefile.h:117
void setData(var8 *data, bool silent=false)
Change-out the save file.
Definition savefile.cpp:69
SaveFileIterator * iterator()
Returns a unique iterator that's setup to iterate over the raw sav file data.
Definition savefile.cpp:53
void expandData()
Replace expansion with new expansion of current sav file.
Definition savefile.cpp:94
void flattenData()
Flatten expansion back to the save file, overwriting it's current contents with only data that's stri...
Definition savefile.cpp:89
void resetData(bool silent=false)
Empty this save file to zero's.
Definition savefile.cpp:58
void dataExpandedChanged(SaveFileExpanded *expanded)
SAV file has changed but the old expansion has not been replaced with exxpansion of new data.
void eraseExpansion()
Erase expansion data, this makes expansion data act like a new file but save file contents are preser...
Definition savefile.cpp:99
var8 * data
Actual SAV Data, a raw internal binary copy of the file.
Definition savefile.h:111
SaveFile(QObject *parent=nullptr)
The expanded, editable object tree. QML traverses in from here.
Definition savefile.cpp:27
SaveFileExpanded * dataExpanded
Expanded SAV data to be readable and more usable.
Definition savefile.h:114
Project-wide fixed-width integer aliases (var8, var16, ...).
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
Definition types.h:125
constexpr var16 SAV_DATA_SIZE
Size of a Gen 1 save in bytes (32 KB).
Definition savefile.h:29
Import/export macro for the savefile library, plus the central list of QObject types kept deliberatel...
#define SAVEFILE_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.