Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
eventsdb.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#include <QObject>
18#include <QVector>
19#include <QString>
20#include <QHash>
21#include <QJsonValue>
22
23#include "./db_autoport.h"
24
25// With amazing help of Quicktype!!!
26// https://app.quicktype.io
27
28class EventDBEntry;
29class QQmlEngine;
30
40class DB_AUTOPORT EventsDB : public QObject
41{
42 Q_OBJECT
43 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
44
45public:
46 // Get Instance
47 static EventsDB* inst();
48
49 // Get Properties, includes QML array helpers
50 const QVector<EventDBEntry*> getStore() const;
51 const QHash<QString, EventDBEntry*> getInd() const;
52 int getStoreSize() const;
53
54 // QML Methods that can't be a property or slot because they take an argument
55 Q_INVOKABLE EventDBEntry* getStoreAt(const int ind) const;
56 Q_INVOKABLE EventDBEntry* getIndAt(const QString val) const;
57
58public slots:
59 void load();
60 void index();
61 void deepLink();
62 void qmlProtect(const QQmlEngine* const engine) const;
63
64private slots:
65 void qmlRegister() const;
66
67private:
68 // Singleton Constructor
69 EventsDB();
70
71 QVector<EventDBEntry*> store;
72 QHash<QString, EventDBEntry*> ind;
73};
void deepLink()
Resolve each event's cross-DB links.
Definition eventsdb.cpp:107
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition eventsdb.cpp:121
int getStoreSize() const
Event count.
Definition eventsdb.cpp:51
const QHash< QString, EventDBEntry * > getInd() const
Name->entry index.
Definition eventsdb.cpp:46
EventDBEntry * getIndAt(const QString val) const
Event by name key (for QML).
Definition eventsdb.cpp:64
void load()
Load events from JSON.
Definition eventsdb.cpp:69
EventDBEntry * getStoreAt(const int ind) const
Event by store index (for QML).
Definition eventsdb.cpp:56
void index()
Build the name->entry index.
Definition eventsdb.cpp:91
const QVector< EventDBEntry * > getStore() const
All event definitions.
Definition eventsdb.cpp:41
static EventsDB * inst()
< Number of event definitions.
Definition eventsdb.cpp:35
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One story-event definition: its name and where its flag lives in the save.