Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
playerpokedex.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;
23
24constexpr var8 maxPokedex = 151;
25
36class SAVEFILE_AUTOPORT PlayerPokedex : public QObject
37{
38 Q_OBJECT
39 Q_PROPERTY(int ownedCount READ ownedCount NOTIFY dexChanged STORED false)
40 Q_PROPERTY(int seenCount READ seenCount NOTIFY dexChanged STORED false)
41
42public:
45 DexNone = 0,
46 DexSeen = 1,
48 };
49
50 PlayerPokedex(SaveFile* saveFile = nullptr);
51 virtual ~PlayerPokedex();
52
53 void load(SaveFile* saveFile = nullptr);
54 void save(SaveFile* saveFile);
55
57 void loadPokedex(SaveFile* saveFile, QVector<bool>* toArr, var16 fromOffset);
59 void savePokedex(SaveFile* saveFile, QVector<bool>* fromArr, var16 toOffset);
60
61 int ownedCount();
62 int seenCount();
63
64 Q_INVOKABLE int ownedMax();
65 Q_INVOKABLE bool ownedAt(int ind);
66 Q_INVOKABLE void ownedSet(int ind, bool val);
67
68 Q_INVOKABLE int seenMax();
69 Q_INVOKABLE bool seenAt(int ind);
70 Q_INVOKABLE void seenSet(int ind, bool val);
71
72 Q_INVOKABLE int getState(int ind);
73
74signals:
75 void dexChanged();
76 void dexItemChanged(int ind);
77
78public slots:
79 void reset();
80 void randomize();
81 void toggleAll();
82 void toggleOne(int val);
83 void markAll(int val);
84
85public:
88};
The player's Pokedex: a seen flag and an owned flag per species.
void markAll(int val)
Mark every entry to a state (e.g. all owned/seen/none).
void reset()
Blank the whole dex.
PlayerPokedex(SaveFile *saveFile=nullptr)
void randomize()
Randomize the dex (constrained).
DexEntryState
< Live count of owned species.
@ DexNone
Neither seen nor owned.
@ DexOwned
Owned (implies seen).
@ DexSeen
Seen but not owned.
protected::void dexChanged()
Any dex change (refreshes counts).
bool seen[maxPokedex]
Seen flag per species (0-based).
int seenCount()
Count of set seen flags (backs the property).
int ownedCount()
Count of set owned flags (backs the property).
void toggleOne(int val)
Flip a single entry val.
void toggleAll()
Flip every entry.
void dexItemChanged(int ind)
A single entry ind changed.
bool owned[maxPokedex]
Owned flag per species (0-based).
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
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
Definition types.h:125
constexpr var8 maxPokedex
Number of Gen 1 species (dex slots).
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.