Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
settings.cpp
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
21
22#include "./settings.h"
23#include <pse-db/mapsdb.h>
25#include <pse-db/tileset.h>
30
31QString tilesetOrder[24] = {
32 "Cavern",
33 "Cemetery",
34 "Club",
35 "Dojo",
36 "Facility",
37 "Forest",
38 "Forest Gate",
39 "Gate",
40 "Gym",
41 "House",
42 "Interior",
43 "Lab",
44 "Lobby",
45 "Mansion",
46 "Mart",
47 "Museum",
48 "Overworld",
49 "Plateau",
50 "Pokecenter",
51 "Reds House 1",
52 "Reds House 2",
53 "Ship",
54 "Ship Port",
55 "Underground"
56};
57
59 : file(file)
60{
61 // Only when all of the expanded data changes at once
62 // the preview settings are kept seperate from the rest of the file so
63 // we only want to update them when all the file data has been changed out
65}
66
67void Settings::setColorScheme(QColor primary, QColor secondary)
68{
69 primaryColor = primary;
70 primaryColorLight = primary.lighter(133);
71 primaryColorDark = primary.darker(142);
72
73 accentColor = secondary;
74}
75
77{
78 int ret = -1;
79
80 for(int i = 0; i < 24; i++) {
82 ret = i;
83 break;
84 }
85 }
86
87 return ret;
88}
89
91{
92 // Get the current map
93 // Even if no map data is laoded yet, the curMap will be 0 which is
94 // Palette Town and works just fine as defaults
95 auto mapInd = file->dataExpanded->area->map->curMap;
96
97 // Get all the data for the current map
98 auto mapData = MapsDB::inst()->getIndAt(QString::number(mapInd));
99
100 // Really shouldn't be any kind of error but stop here if there is one
101 if(mapData == nullptr || mapData->getToTileset() == nullptr)
102 return;
103
104 // Load in the 2 settings
105 previewTileset = mapData->getToTileset()->name;
106 previewOutdoor = (mapData->getToTileset()->typeAsEnum() == TilesetType::OUTDOOR);
107}
static MapsDB * inst()
< Number of maps.
Definition mapsdb.cpp:35
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition mapsdb.cpp:155
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
void dataExpandedChanged(SaveFileExpanded *expanded)
SAV file has changed but the old expansion has not been replaced with exxpansion of new data.
QColor primaryColorDark
Definition settings.h:112
QColor primaryColorLight
Definition settings.h:111
QColor accentColor
Definition settings.h:121
int getPreviewTilesetIndex()
Index of previewTileset (backs the property).
Definition settings.cpp:76
Settings(SaveFile *file)
Definition settings.cpp:58
bool previewOutdoor
Definition settings.h:102
SaveFile * file
The live save (held for data-reactive settings).
Definition settings.h:134
void dataChanged()
React to the save's data changing.
Definition settings.cpp:90
QColor primaryColor
Definition settings.h:110
void setColorScheme(QColor primary, QColor secondary)
Recolour the palette at runtime.
Definition settings.cpp:67
QString previewTileset
Definition settings.h:101
QString tilesetOrder[24]
Definition settings.cpp:31