Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
gamecornerdb.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 "./db_autoport.h"
20
22class QQmlEngine;
23
34class DB_AUTOPORT GameCornerDB : public QObject
35{
36 Q_OBJECT
37 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
38 Q_PROPERTY(int getBuyPrice READ getBuyPrice CONSTANT)
39 Q_PROPERTY(int getSellPrice READ getSellPrice CONSTANT)
40
41public:
42 // Get Instance
43 static GameCornerDB* inst();
44
45 // Get Properties, includes QML array helpers
46 const QVector<GameCornerDBEntry*> getStore() const;
47 int getStoreSize() const;
48
49 // QML Methods that can't be a property or slot because they take an argument
50 Q_INVOKABLE GameCornerDBEntry* getStoreAt(const int ind) const;
51 int getBuyPrice() const;
52 int getSellPrice() const;
53
54public slots:
55 void load();
56 void deepLink();
57 void qmlProtect(const QQmlEngine* const engine) const;
58
59private slots:
60 void qmlRegister() const;
61
62private:
63 GameCornerDB();
64
65 QVector<GameCornerDBEntry*> store;
66
67 // Buy and Sell Price
68 // Pokedollars <=> Game Coins
69 // Regular Casinos give you an even exchange, you get the exact amount back
70 // But in the Poke-World I want to follow the global sell-back mechanics
71 // whereby you get half back
72 int buyPrice = 0;
73
74 friend class GameCornerDBEntry;
75};
void deepLink()
Resolve each prize's item/Pokemon links.
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
GameCornerDBEntry * getStoreAt(const int ind) const
Prize by store index (for QML).
int getStoreSize() const
Prize count.
friend class GameCornerDBEntry
Lets entries populate the store/price during load.
const QVector< GameCornerDBEntry * > getStore() const
All prize entries.
void load()
Load prizes from JSON.
int getBuyPrice() const
The buy rate (backs getBuyPrice).
static GameCornerDB * inst()
< Number of prize entries.
int getSellPrice() const
The sell rate (half the buy rate).
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 Game Corner prize: a Pokemon or item, its coin price, and level.