Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
areapokemon.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 <QObject>
18#include <QVector>
19#include <pse-common/types.h>
21
22class SaveFile;
24class MapDBEntry;
25
26constexpr var8 wildMonsCount = 10;
27
37class SAVEFILE_AUTOPORT AreaPokemonWild : public QObject {
38
39 Q_OBJECT
40
41 Q_PROPERTY(int index MEMBER index NOTIFY indexChanged)
42 Q_PROPERTY(int level MEMBER level NOTIFY levelChanged)
43
44public:
45 AreaPokemonWild(int index = 0, int level = 0);
46 AreaPokemonWild(bool random);
47
48 void load(SaveFileIterator* it);
49 void save(SaveFileIterator* it);
50
51 bool operator<(const AreaPokemonWild& a);
52 bool operator>(const AreaPokemonWild& a);
53
54signals:
57
58public slots:
60 void randomize();
61 void reset();
62 void load(int index, int level);
63
64public:
65 // Pokemon index number and level
66 int index;
67 int level;
68};
69
96class SAVEFILE_AUTOPORT AreaPokemon : public QObject
97{
98 Q_OBJECT
99
100 Q_PROPERTY(int grassRate MEMBER grassRate NOTIFY grassRateChanged)
101 Q_PROPERTY(int waterRate MEMBER waterRate NOTIFY waterRateChanged)
102 Q_PROPERTY(bool pauseMons3Steps MEMBER pauseMons3Steps NOTIFY pauseMons3StepsChanged)
103
104 // C++ Arrays can't be Q_PROPERTY and don't need a signal because they are
105 // pre-created with only their contents changing and have no properties of
106 // their own
107
108public:
109 AreaPokemon(SaveFile* saveFile = nullptr);
110 virtual ~AreaPokemon();
111
112 void load(SaveFile* saveFile = nullptr);
113 void save(SaveFile* saveFile);
114
115 Q_INVOKABLE int grassMonsCount();
116 Q_INVOKABLE AreaPokemonWild* grassMonsAt(int ind);
117 Q_INVOKABLE void grassMonsSwap(int from, int to);
118
119 Q_INVOKABLE int waterMonsCount();
120 Q_INVOKABLE AreaPokemonWild* waterMonsAt(int ind);
121 Q_INVOKABLE void waterMonsSwap(int from, int to);
122
123signals:
129
130public slots:
131 void reset();
132 void randomize();
133 void setTo(MapDBEntry* map);
134
135public:
136 // There are exactly 10 wild Pokemon in areas that have wild Pokemon
137 // Create 10 entries each, no more or less
140
143
145};
constexpr var8 wildMonsCount
Wild-encounter slots per list (grass or water).
Definition areapokemon.h:26
One wild-encounter slot: a species index and a level.
Definition areapokemon.h:37
void reset()
Blank this slot.
int index
Species index (backs property).
Definition areapokemon.h:66
bool operator>(const AreaPokemonWild &a)
Order by encounter value.
void save(SaveFileIterator *it)
Write one entry at the cursor.
bool operator<(const AreaPokemonWild &a)
Order by encounter value.
AreaPokemonWild(int index=0, int level=0)
< Species index.
protected::void indexChanged()
int level
Encounter level (backs property).
Definition areapokemon.h:67
void load(SaveFileIterator *it)
Read one entry at the cursor.
void randomize()
Generates a random Pokemon from any dex entry and level.
void waterMonsSwap(int from, int to)
Reorder water slots.
int waterMonsCount()
Water-slot count (wildMonsCount).
void grassMonsChanged()
void load(SaveFile *saveFile=nullptr)
Expand both encounter tables from the save.
AreaPokemonWild * grassMons[wildMonsCount]
The 10 grass-encounter slots.
void grassMonsSwap(int from, int to)
Reorder grass slots.
void waterRateChanged()
bool pauseMons3Steps
void randomize()
Randomize the encounter tables.
void waterMonsChanged()
AreaPokemonWild * waterMons[wildMonsCount]
The 10 water-encounter slots.
void setTo(MapDBEntry *map)
Set encounters from map.
void pauseMons3StepsChanged()
int grassMonsCount()
Grass-slot count (wildMonsCount).
AreaPokemonWild * grassMonsAt(int ind)
Grass slot ind (GC-protected return).
AreaPokemonWild * waterMonsAt(int ind)
Water slot ind (GC-protected return).
void reset()
Blank both encounter tables.
protected::void grassRateChanged()
AreaPokemon(SaveFile *saveFile=nullptr)
< Grass encounter rate (0 = none).
void save(SaveFile *saveFile)
Flatten both encounter tables to the save.
A moving cursor over a SaveFile, layering auto-advancing reads/writes on top of SaveFileToolset.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
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
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.
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56