Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
>
24
#include <
pse-db/entries/mapdbentry.h
>
25
#include <
pse-db/tileset.h
>
26
#include <
pse-savefile/savefile.h
>
27
#include <
pse-savefile/expanded/savefileexpanded.h
>
28
#include <
pse-savefile/expanded/area/area.h
>
29
#include <
pse-savefile/expanded/area/areamap.h
>
30
31
QString
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
58
Settings::Settings
(
SaveFile
*
file
)
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
64
connect(
file
, &
SaveFile::dataExpandedChanged
,
this
, &
Settings::dataChanged
);
65
}
66
67
void
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
76
int
Settings::getPreviewTilesetIndex
()
77
{
78
int
ret = -1;
79
80
for
(
int
i = 0; i < 24; i++) {
81
if
(
tilesetOrder
[i] ==
previewTileset
) {
82
ret = i;
83
break
;
84
}
85
}
86
87
return
ret;
88
}
89
90
void
Settings::dataChanged
()
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
}
area.h
areamap.h
MapsDB::inst
static MapsDB * inst()
< Number of maps.
Definition
mapsdb.cpp:35
MapsDB::getIndAt
MapDBEntry * getIndAt(const QString val) const
Map by name key (for QML).
Definition
mapsdb.cpp:155
SaveFile
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition
savefile.h:46
SaveFile::dataExpandedChanged
void dataExpandedChanged(SaveFileExpanded *expanded)
SAV file has changed but the old expansion has not been replaced with exxpansion of new data.
Settings::primaryColorDark
QColor primaryColorDark
Definition
settings.h:112
Settings::primaryColorLight
QColor primaryColorLight
Definition
settings.h:111
Settings::accentColor
QColor accentColor
Definition
settings.h:121
Settings::getPreviewTilesetIndex
int getPreviewTilesetIndex()
Index of previewTileset (backs the property).
Definition
settings.cpp:76
Settings::Settings
Settings(SaveFile *file)
Definition
settings.cpp:58
Settings::previewOutdoor
bool previewOutdoor
Definition
settings.h:102
Settings::file
SaveFile * file
The live save (held for data-reactive settings).
Definition
settings.h:134
Settings::dataChanged
void dataChanged()
React to the save's data changing.
Definition
settings.cpp:90
Settings::primaryColor
QColor primaryColor
Definition
settings.h:110
Settings::setColorScheme
void setColorScheme(QColor primary, QColor secondary)
Recolour the palette at runtime.
Definition
settings.cpp:67
Settings::previewTileset
QString previewTileset
Definition
settings.h:101
mapdbentry.h
mapsdb.h
savefile.h
savefileexpanded.h
tilesetOrder
QString tilesetOrder[24]
Definition
settings.cpp:31
settings.h
tileset.h
TilesetType::OUTDOOR
@ OUTDOOR
Definition
tileset.h:31
projects
app
src
bridge
settings.cpp
Generated by
1.17.0