Crossfire Server, Trunk
CRESettings.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "CRESettings.h"
14 #include "CRESettingsDialog.h"
15 
16 #include <QFileInfo>
17 #include <QDir>
18 
20 {
21 }
22 
24 {
25  bool need = false;
26  if (mapCacheDirectory().isEmpty())
27  need = true;
28  else
29  {
30  QFileInfo info(mapCacheDirectory());
31  if (!info.exists())
32  {
33  QDir dir(mapCacheDirectory());
34  dir.mkpath(".");
35  info.refresh();
36  }
37 
38  if (!info.exists())
39  need = true;
40  }
41 
42  if (need)
43  {
44  CRESettingsDialog dlg(this);
45  if (dlg.exec() == QDialog::Rejected)
46  return false;
47 
48  setValue("mapCacheDirectory", dlg.mapCache());
49  return ensureOptions();
50  }
51 
52  return true;
53 }
54 
56 {
57  return value("mapCacheDirectory").toString();
58 }
59 
61 {
62  filters.copy(value("filters").value<CREFilterDefinitionManager>());
63 }
64 
66 {
67  QVariant val;
68  val.setValue(filters);
69  setValue("filters", val);
70 }
71 
73 {
74  reports.copy(value("reports").value<CREReportDefinitionManager>());
75 }
76 
78 {
79  QVariant val;
80  val.setValue(reports);
81  setValue("reports", val);
82 }
83 
85 {
86  return value("facesetToDisplay", "base").toString();
87 }
88 
89 void CRESettings::setFacesetToDisplay(const QString& faceset)
90 {
91  setValue("facesetToDisplay", faceset);
92 }
93 
95 {
96  return value("facesetUseFallback").toBool();
97 }
98 
100 {
101  setValue("facesetUseFallback", use);
102 }
103 
105  return value("showChanges", true).toBool();
106 }
107 
109  setValue("showChanges", show);
110 }
111 
113  return value("changesLength").toInt();
114 }
115 
117  setValue("changesLength", length);
118 }
119 
121  return value("storeWindowsState").toBool();
122 }
123 
125  setValue("storeWindowsState", store);
126 }
127 
129  return value("mainWindowGeometry").toByteArray();
130 }
131 
132 void CRESettings::setMainWindowGeometry(const QByteArray &data) {
133  setValue("mainWindowGeometry", data);
134  sync();
135 }
136 
138  return value("subWindows/count").toInt();
139 }
140 
142  remove("subWindows");
143  setValue("subWindows/count", count);
144 }
145 
146 int CRESettings::subWindowType(int subWindow) const {
147  return value(QString("subWindows/win_%1/type").arg(subWindow)).toInt();
148 }
149 
150 void CRESettings::setSubWindowType(int subWindow, int type) {
151  setValue(QString("subWindows/win_%1/type").arg(subWindow), type);
152 }
153 
154 QByteArray CRESettings::subWindowPosition(int subWindow) const {
155  return value(QString("subWindows/win_%1/position").arg(subWindow)).toByteArray();
156 }
157 
158 void CRESettings::setSubWindowPosition(int subWindow, const QByteArray &data) {
159  setValue(QString("subWindows/win_%1/position").arg(subWindow), data);
160 }
161 
163 {
164  return value("soundsDirectory").toString();
165 }
166 
167 void CRESettings::setSoundsDirectory(const QString &dir)
168 {
169  setValue("soundsDirectory", dir);
170 }
ship.setValue
def setValue(key, value)
Definition: ship.py:23
CREReportDefinitionManager
Definition: CREReportDefinitionManager.h:21
CRESettings::setShowChanges
void setShowChanges(bool show)
Definition: CRESettings.cpp:108
CRESettings::loadReports
void loadReports(CREReportDefinitionManager &reports)
Definition: CRESettings.cpp:72
CREFilterDefinitionManager
Definition: CREFilterDefinitionManager.h:21
CRESettings::loadFilters
void loadFilters(CREFilterDefinitionManager &filters)
Definition: CRESettings.cpp:60
CRESettingsDialog::mapCache
QString mapCache() const
Definition: CRESettingsDialog.cpp:45
CRESettings::setSubWindowPosition
void setSubWindowPosition(int subWindow, const QByteArray &data)
Definition: CRESettings.cpp:158
CRESettings::storeWindowsState
bool storeWindowsState() const
Definition: CRESettings.cpp:120
CRESettings::subWindowCount
int subWindowCount() const
Definition: CRESettings.cpp:137
CRESettings::saveFilters
void saveFilters(const CREFilterDefinitionManager &filters)
Definition: CRESettings.cpp:65
CRESettings::subWindowPosition
QByteArray subWindowPosition(int subWindow) const
Definition: CRESettings.cpp:154
CRESettings::setSoundsDirectory
void setSoundsDirectory(const QString &dir)
Definition: CRESettings.cpp:167
CRESettings::setChangesLength
void setChangesLength(int length)
Definition: CRESettings.cpp:116
CRESettings.h
CRESettings::CRESettings
CRESettings()
Definition: CRESettings.cpp:19
CRESettings::subWindowType
int subWindowType(int subWindow) const
Definition: CRESettings.cpp:146
navar-midane_time.data
data
Definition: navar-midane_time.py:11
disinfect.count
int count
Definition: disinfect.py:7
CRESettings::mapCacheDirectory
QString mapCacheDirectory() const
Definition: CRESettings.cpp:55
CRESettings::changesLength
int changesLength() const
Definition: CRESettings.cpp:112
CRESettings::setSubWindowType
void setSubWindowType(int subWindow, int type)
Definition: CRESettings.cpp:150
CRESettings::setFacesetUseFallback
void setFacesetUseFallback(bool use)
Definition: CRESettings.cpp:99
CRESettingsDialog
Definition: CRESettingsDialog.h:21
CRESettings::setFacesetToDisplay
void setFacesetToDisplay(const QString &faceset)
Definition: CRESettings.cpp:89
CRESettings::mainWindowGeometry
QByteArray mainWindowGeometry()
Definition: CRESettings.cpp:128
autojail.value
value
Definition: autojail.py:6
CRESettings::setSubWindowCount
void setSubWindowCount(int count)
Definition: CRESettings.cpp:141
CRESettingsDialog.h
CRESettings::ensureOptions
bool ensureOptions()
Definition: CRESettings.cpp:23
CRESettings::facesetToDisplay
QString facesetToDisplay() const
Definition: CRESettings.cpp:84
CRESettings::facesetUseFallback
bool facesetUseFallback() const
Definition: CRESettings.cpp:94
CRESettings::saveReports
void saveReports(const CREReportDefinitionManager &reports)
Definition: CRESettings.cpp:77
CREFilterDefinitionManager::copy
void copy(const CREFilterDefinitionManager &other)
Definition: CREFilterDefinitionManager.cpp:31
CRESettings::setStoreWindowState
void setStoreWindowState(bool store)
Definition: CRESettings.cpp:124
CRESettings::showChanges
bool showChanges() const
Definition: CRESettings.cpp:104
CREReportDefinitionManager::copy
void copy(const CREReportDefinitionManager &other)
Definition: CREReportDefinitionManager.cpp:31
CRESettings::setMainWindowGeometry
void setMainWindowGeometry(const QByteArray &data)
Definition: CRESettings.cpp:132
is_valid_types_gen.type
list type
Definition: is_valid_types_gen.py:25
CRESettings::soundsDirectory
QString soundsDirectory() const
Definition: CRESettings.cpp:162