Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
Loading...
Searching...
No Matches
scripts.h
Go to the documentation of this file.
1
/*
2
* Copyright 2019 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
18
#include <QObject>
19
#include <QJsonValue>
20
#include <QVector>
21
#include <QString>
22
#include <QHash>
23
#include <optional>
24
25
#include <
pse-common/types.h
>
26
#include "
./db_autoport.h
"
27
28
struct
MapDBEntry
;
29
class
QQmlEngine;
30
40
struct
DB_AUTOPORT
ScriptDBEntry
{
41
ScriptDBEntry
();
42
ScriptDBEntry
(QJsonValue& data);
43
void
deepLink
();
44
45
QString
name
;
46
var8
ind
= 0;
47
var8
size
= 0;
48
49
QVector<QString>
maps
;
50
std::optional<var8>
skip
;
51
52
QVector<MapDBEntry*>
toMaps
;
53
};
54
62
class
DB_AUTOPORT
ScriptsDB :
public
QObject
63
{
64
Q_OBJECT
65
Q_PROPERTY(
int
getStoreSize
READ
getStoreSize
CONSTANT)
66
67
public
:
68
static
ScriptsDB*
inst
();
69
70
[[nodiscard]]
const
QVector<ScriptDBEntry*>
getStore
()
const
;
71
[[nodiscard]]
const
QHash<QString, ScriptDBEntry*>
getInd
()
const
;
72
[[nodiscard]]
int
getStoreSize
()
const
;
73
74
Q_INVOKABLE
ScriptDBEntry
*
getStoreAt
(
int
idx)
const
;
75
Q_INVOKABLE
ScriptDBEntry
*
getIndAt
(
const
QString& key)
const
;
76
77
public
slots:
78
void
load
();
79
void
index
();
80
void
deepLink
();
81
void
qmlProtect
(
const
QQmlEngine*
const
engine)
const
;
82
83
private
slots:
84
void
qmlRegister()
const
;
85
86
private
:
87
ScriptsDB();
88
89
QVector<ScriptDBEntry*> store;
90
QHash<QString, ScriptDBEntry*> ind;
91
};
ScriptsDB::getStoreSize
int getStoreSize() const
Script count.
Definition
scripts.cpp:75
ScriptsDB::deepLink
void deepLink()
Resolve each script's map links.
Definition
scripts.cpp:109
ScriptsDB::getInd
const QHash< QString, ScriptDBEntry * > getInd() const
Name->entry index.
Definition
scripts.cpp:74
ScriptsDB::load
void load()
Load scripts from JSON.
Definition
scripts.cpp:88
ScriptsDB::qmlProtect
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition
scripts.cpp:118
ScriptsDB::inst
static ScriptsDB * inst()
< Number of scripts.
Definition
scripts.cpp:67
ScriptsDB::getIndAt
ScriptDBEntry * getIndAt(const QString &key) const
Script by name key (for QML).
Definition
scripts.cpp:83
ScriptsDB::getStore
const QVector< ScriptDBEntry * > getStore() const
All scripts.
Definition
scripts.cpp:73
ScriptsDB::index
void index()
Build the name->entry index.
Definition
scripts.cpp:98
ScriptsDB::getStoreAt
ScriptDBEntry * getStoreAt(int idx) const
Script by store index (for QML).
Definition
scripts.cpp:77
types.h
Project-wide fixed-width integer aliases (var8, var16, ...).
var8
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition
types.h:124
db_autoport.h
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
DB_AUTOPORT
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition
db_autoport.h:37
MapDBEntry
One map's complete static definition – the root of the MapDBEntry family.
Definition
mapdbentry.h:56
ScriptDBEntry
One map-script definition: its id/size and which maps use it.
Definition
scripts.h:40
ScriptDBEntry::size
var8 size
Script size.
Definition
scripts.h:47
ScriptDBEntry::toMaps
QVector< MapDBEntry * > toMaps
Resolved map entries (deepLink).
Definition
scripts.h:52
ScriptDBEntry::deepLink
void deepLink()
Resolve the maps names to entries.
Definition
scripts.cpp:53
ScriptDBEntry::skip
std::optional< var8 > skip
Optional skip value.
Definition
scripts.h:50
ScriptDBEntry::ind
var8 ind
Script index.
Definition
scripts.h:46
ScriptDBEntry::maps
QVector< QString > maps
Map names using this script.
Definition
scripts.h:49
ScriptDBEntry::ScriptDBEntry
ScriptDBEntry()
Empty entry.
Definition
scripts.cpp:35
ScriptDBEntry::name
QString name
Script name (key).
Definition
scripts.h:45
projects
db
src
pse-db
scripts.h
Generated by
1.17.0