Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
mapsearch.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 <QString>
19#include <QVector>
20
21#include "../db_autoport.h"
22
23class MapDBEntry;
24class QQmlEngine;
25
41class DB_AUTOPORT MapSearch : public QObject
42{
43 Q_OBJECT
44 Q_PROPERTY(int mapCount READ getMapCount NOTIFY mapCountChanged STORED false)
45 Q_PROPERTY(MapDBEntry* pickRandom READ pickRandom STORED false)
46 Q_PROPERTY(MapSearch* startOver READ startOver STORED false)
47 Q_PROPERTY(MapSearch* hasConnections READ hasConnections STORED false)
48 Q_PROPERTY(MapSearch* noConnections READ noConnections STORED false)
49 Q_PROPERTY(MapSearch* hasWarpsOut READ hasWarpsOut STORED false)
50 Q_PROPERTY(MapSearch* noWarpsOut READ noWarpsOut STORED false)
51 Q_PROPERTY(MapSearch* hasWarpsIn READ hasWarpsIn STORED false)
52 Q_PROPERTY(MapSearch* noWarpsIn READ noWarpsIn STORED false)
53 Q_PROPERTY(MapSearch* hasSigns READ hasSigns STORED false)
54 Q_PROPERTY(MapSearch* noSigns READ noSigns STORED false)
55 Q_PROPERTY(MapSearch* hasSprites READ hasSprites STORED false)
56 Q_PROPERTY(MapSearch* noSprites READ noSprites STORED false)
57 Q_PROPERTY(MapSearch* hasSpriteSet READ hasSpriteSet STORED false)
58 Q_PROPERTY(MapSearch* noSpriteSet READ noSpriteSet STORED false)
59 Q_PROPERTY(MapSearch* hasDynamicSpriteSet READ hasDynamicSpriteSet STORED false)
60 Q_PROPERTY(MapSearch* noDynamicSpriteSet READ noDynamicSpriteSet STORED false)
61 Q_PROPERTY(MapSearch* hasMons READ hasMons STORED false)
62 Q_PROPERTY(MapSearch* noMons READ noMons STORED false)
63 Q_PROPERTY(MapSearch* isIncomplete READ isIncomplete STORED false)
64 Q_PROPERTY(MapSearch* notIncomplete READ notIncomplete STORED false)
65 Q_PROPERTY(MapSearch* isGlitch READ isGlitch STORED false)
66 Q_PROPERTY(MapSearch* notGlitch READ notGlitch STORED false)
67 Q_PROPERTY(MapSearch* isSpsecial READ isSpsecial STORED false)
68 Q_PROPERTY(MapSearch* notSpecial READ notSpecial STORED false)
69 Q_PROPERTY(MapSearch* isGood READ isGood STORED false)
70 Q_PROPERTY(MapSearch* isCity READ isCity STORED false)
71 Q_PROPERTY(MapSearch* notCity READ notCity STORED false)
72
73signals:
74 void mapCountChanged();
75
76public:
77 MapSearch();
78
81
82 Q_INVOKABLE MapSearch* notNamed(QString val);
83 Q_INVOKABLE MapSearch* indexLt(int val);
84 Q_INVOKABLE MapSearch* indexGt(int val);
85 Q_INVOKABLE MapSearch* widthGt(int val);
86 Q_INVOKABLE MapSearch* widthLt(int val);
87 Q_INVOKABLE MapSearch* heightGt(int val);
88 Q_INVOKABLE MapSearch* heightLt(int val);
89 Q_INVOKABLE MapSearch* areaGt(int val);
90 Q_INVOKABLE MapSearch* areaLt(int val);
91 Q_INVOKABLE MapSearch* hasTileset(QString val);
92 Q_INVOKABLE MapSearch* notTileset(QString val);
93 Q_INVOKABLE MapSearch* isType(QString val);
94 Q_INVOKABLE MapSearch* notType(QString val);
102 MapSearch* noSigns();
109 MapSearch* hasMons();
110 MapSearch* noMons();
117
118 // * A normal non-special or glitch map
119 // * A map that's complete (Not an incomplete map)
120 // * Has at least one warp in and out (You have to be able to enter and leave)
121 // * Is not the strange elevator that has an invalid warp
122 MapSearch* isGood();
124 MapSearch* isCity();
125 MapSearch* notCity();
126
127 // QML Interface
128 const QVector<MapDBEntry*> getMaps() const;
129 int getMapCount() const;
130 Q_INVOKABLE const MapDBEntry* mapAt(const int ind) const;
131
132public slots:
133 void qmlProtect(const QQmlEngine* const engine) const;
134
135private slots:
136 void qmlRegister() const;
137
138private:
139 QVector<MapDBEntry*> results;
140};
MapSearch * indexGt(int val)
Keep maps with index > val.
Definition mapsearch.cpp:81
MapSearch * startOver()
Reset to all maps. Returns this.
Definition mapsearch.cpp:49
MapSearch * isGood()
Keep only "good" maps (criteria listed above).
MapSearch * noWarpsIn()
MapSearch * hasMons()
MapSearch * hasConnections()
MapDBEntry * pickRandom()
A random map from the current results (backs pickRandom).
Definition mapsearch.cpp:41
MapSearch * noSprites()
MapSearch * widthGt(int val)
Keep maps wider than val.
Definition mapsearch.cpp:90
MapSearch * areaLt(int val)
Keep maps with area < val.
MapSearch * hasSpriteSet()
MapSearch * hasTileset(QString val)
Keep maps using tileset val.
MapSearch * hasWarpsIn()
MapSearch * heightLt(int val)
Keep maps shorter than val.
MapSearch * noSpriteSet()
MapSearch * heightGt(int val)
Keep maps taller than val.
const QVector< MapDBEntry * > getMaps() const
The current result set.
MapSearch * widthLt(int val)
Keep maps narrower than val.
Definition mapsearch.cpp:99
MapSearch()
Start with all maps in the result set.
Definition mapsearch.cpp:35
MapSearch * notType(QString val)
Drop maps of tileset-type val.
MapSearch * hasSprites()
MapSearch * noMons()
int getMapCount() const
Result count (backs mapCount).
MapSearch * hasDynamicSpriteSet()
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
MapSearch * hasWarpsOut()
MapSearch * isIncomplete()
MapSearch * areaGt(int val)
Keep maps with area > val.
MapSearch * isType(QString val)
Keep maps of tileset-type val.
MapSearch * isGlitch()
MapSearch * noDynamicSpriteSet()
MapSearch * noWarpsOut()
MapSearch * notTileset(QString val)
Drop maps using tileset val.
MapSearch * notCity()
MapSearch * isNotBad()
The complement helper used by isGood().
MapSearch * notIncomplete()
MapSearch * notGlitch()
MapSearch * notNamed(QString val)
Drop the map named val.
Definition mapsearch.cpp:62
MapSearch * noConnections()
MapSearch * hasSigns()
MapSearch * noSigns()
MapSearch * indexLt(int val)
Keep maps with index < val.
Definition mapsearch.cpp:72
MapSearch * notSpecial()
const MapDBEntry * mapAt(const int ind) const
Result ind (for QML).
MapSearch * isSpsecial()
MapSearch * isCity()
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 map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56