Debian Codegraph @

code/controls/ModList.h

raw
1 /*
2 Copyright (C) 2009-2010 wxLauncher Team
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19 #ifndef MODLIST_H
20 #define MODLIST_H
21
22 #include <wx/wx.h>
23 #include <wx/vlbox.h>
24 #include <wx/fileconf.h>
25 #include <wx/arrstr.h>
26
27 #include "apis/SkinManager.h"
28
29 #include "controls/LightingPresets.h"
30
31 class ConfigPair {
32 public:
33 ConfigPair(const wxString &shortname, wxFileConfig* config);
34 ~ConfigPair();
35 wxString shortname;
36 wxFileConfig* config;
37 };
38 WX_DECLARE_OBJARRAY(ConfigPair, ConfigArray);
39
40
41 class FlagSetItem {
42 public:
43 FlagSetItem();
44 ~FlagSetItem();
45 wxString name;
46 wxString flagset;
47 wxString notes;
48 };
49
50 WX_DECLARE_OBJARRAY(FlagSetItem, FlagSets);
51
52 #ifdef MOD_TEXT_LOCALIZATION // mod text localization is not supported for now
53 extern wxSortedArrayString SupportedLanguages;
54
55 class I18nItem {
56 public:
57 I18nItem();
58 ~I18nItem();
59 wxString* modname;
60 wxString* infotext;
61 };
62
63 WX_DECLARE_STRING_HASH_MAP(I18nItem*, I18nData);
64 #endif
65
66
67 class ModItem{
68 public:
69 ModItem();
70 ~ModItem();
71 wxString name;
72 wxString shortname;
73 wxBitmap image255x112;
74 wxBitmap image182x80;
75 wxString infotext;
76 wxString author;
77 wxString notes;
78 bool warn;
79 wxString website;
80 wxString forum;
81 wxString bugs;
82 wxString support;
83
84 long minhorizontalres;
85 long minverticalres;
86
87 wxString forcedon;
88 wxString forcedoff;
89
90 wxString primarylist;
91 wxString secondarylist;
92
93 wxString recommendedlightingname;
94 wxString recommendedlightingflagset;
95
96 FlagSets* flagsets; // set 0 is the ideal set.
97
98 #ifdef MOD_TEXT_LOCALIZATION // mod text localization is not supported for now
99 I18nData* i18n;
100 #endif
101
102 void Draw(wxDC &dc, const wxRect &rect, bool selected, wxSizer *mainSizer, wxSizer *buttons, wxStaticBitmap* warn);
103
104 private:
105 class InfoText{
106 public:
107 InfoText(ModItem *myData);
108
109 void Draw(wxDC &dc, const wxRect &rect);
110 private:
111 ModItem *myData;
112 };
113
114 InfoText *infoTextPanel;
115
116 class ModImage{
117 public:
118 ModImage(ModItem *myData);
119
120 void Draw(wxDC &dc, const wxRect &rect);
121 private:
122 ModItem *myData;
123 };
124
125 ModImage *modImagePanel;
126
127 class ModName{
128 public:
129 ModName(ModItem *myData);
130
131 void Draw(wxDC &dc, const wxRect &rect);
132 private:
133 ModItem *myData;
134 };
135
136 ModName* modNamePanel;
137 };
138
139 WX_DECLARE_OBJARRAY(ModItem, ModItemArray);
140
141
142 class ModList: public wxVListBox {
143 public:
144 ModList(wxWindow *parent, wxSize& size, wxString tcPath);
145 ~ModList();
146
147 // overrides for wxVListBox
148 virtual void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const;
149 virtual void OnDrawSeparator(wxDC &dc, wxRect& rect, size_t n) const;
150 virtual void OnDrawBackground(wxDC &dc, const wxRect &rect, size_t n) const;
151 virtual wxCoord OnMeasureItem(size_t n) const;
152
153 void OnSelectionChange(wxCommandEvent &event);
154 void OnActivateMod(wxCommandEvent &event);
155 void OnInfoMod(wxCommandEvent &event);
156 void OnTCSkinChanged(wxCommandEvent &event);
157
158 static const ModItem* GetActiveMod() { return ModList::activeMod; }
159
160 private:
161 /** A hash map of the wxFileConfigs that represent the mod.ini files for
162 each mod. The key is the the mod's folder name which is used as the mod's
163 internal name. */
164 ConfigArray* configFiles;
165
166 ModItemArray* tableData;
167
168 Skin* TCSkin;
169
170 wxButton *infoButton, *activateButton;
171 wxStaticBitmap *warnBitmap;
172 wxBoxSizer *buttonSizer, *sizer;
173
174 static const ModItem* activeMod;
175
176 /** Sets a bitmap of the ModList's TCSkin. */
177 void SetSkinBitmap(
178 const wxFileConfig& config,
179 const wxString& modIniKey,
180 const wxString& tcPath,
181 const wxString& bitmapName,
182 bool (Skin::* setFnPtr)(const wxBitmap&));
183
184 void readIniFileString(const wxFileConfig* config,
185 const wxString& key, wxString& location);
186 void readFlagSet(const wxFileConfig* config,
187 const wxString& keyprefix, FlagSetItem& set);
188 #ifdef MOD_TEXT_LOCALIZATION // mod text localization is not supported for now
189 void readTranslation(wxFileConfig* config,
190 wxString langaugename, I18nItem ** trans);
191 #endif
192 wxString escapeSpecials(const wxString& toEscape);
193
194 bool ParseModIni(const wxString& modIniPath, const wxString& tcPath, bool isNoMod = false);
195 void SetSelectedMod();
196 static wxString GetShortName(const wxString& modIniPath, const wxString& tcPath);
197
198 /** The active mod's prepend mods and append mods. */
199 wxString prependmods, appendmods;
200
201 /** Tests whether a mod is a prepend/append mod of the active mod. */
202 bool isAPrependMod(const wxString& mod) const;
203 bool isAnAppendMod(const wxString& mod) const;
204
205 /** Tests whether a mod appears in the specified mod list. */
206 static bool isADependency(const wxString& mod, const wxString& modlist);
207
208 /** Tests whether a mod is a prepend/append mod of the selected mod. */
209 bool isCurrentSelectionAPrependMod(const wxString &mod) const;
210 bool isCurrentSelectionAnAppendMod(const wxString &mod) const;
211
212 DECLARE_EVENT_TABLE();
213 };
214
215 #endif