1 /*****************************************************************************
2  * PokerTH - The open source texas holdem engine                             *
3  * Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May          *
4  *                                                                           *
5  * This program is free software: you can redistribute it and/or modify      *
6  * it under the terms of the GNU Affero General Public License as            *
7  * published by the Free Software Foundation, either version 3 of the        *
8  * License, or (at your option) any later version.                           *
9  *                                                                           *
10  * This program is distributed in the hope that it will be useful,           *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
13  * GNU Affero General Public License for more details.                       *
14  *                                                                           *
15  * You should have received a copy of the GNU Affero General Public License  *
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.     *
17  *                                                                           *
18  *                                                                           *
19  * Additional permission under GNU AGPL version 3 section 7                  *
20  *                                                                           *
21  * If you modify this program, or any covered work, by linking or            *
22  * combining it with the OpenSSL project's OpenSSL library (or a             *
23  * modified version of that library), containing parts covered by the        *
24  * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH           *
25  * (Felix Hammer, Florian Thauer, Lothar May) grant you additional           *
26  * permission to convey the resulting work.                                  *
27  * Corresponding Source for a non-source form of such a combination          *
28  * shall include the source code for the parts of OpenSSL used as well       *
29  * as that of the covered work.                                              *
30  *****************************************************************************/
31 #ifndef GAMETABLESTYLEREADER_H
32 #define GAMETABLESTYLEREADER_H
33 
34 #include <tinyxml.h>
35 #include "configfile.h"
36 #include "gametableimpl.h"
37 #include "mymessagedialogimpl.h"
38 #include "game_defs.h"
39 #include <string>
40 #include <QtCore>
41 #include <QtGui>
42 
43 #define POKERTH_GT_STYLE_FILE_VERSION	3
44 
45 enum GtStyleState {
46 	GT_STYLE_OK = 0,
47 	GT_STYLE_OUTDATED,
48 	GT_STYLE_FIELDS_EMPTY,
49 	GT_STYLE_PICTURES_MISSING,
50 	GT_STYLE_UNDEFINED
51 };
52 
53 class gameTableImpl;
54 
55 class GameTableStyleReader : public QObject
56 {
57 	Q_OBJECT
58 public:
59 	GameTableStyleReader(ConfigFile *c, QWidget *w);
60 	~GameTableStyleReader();
61 
62 	void readStyleFile(QString);
63 
64 	void showErrorMessage();
65 	void showLeftItemsErrorMessage();
66 	void showItemPicsLeftErrorMessage();
67 	void showOutdatedErrorMessage();
68 
getStyleDescription()69 	QString getStyleDescription() const
70 	{
71 		return StyleDescription;
72 	}
getStyleMaintainerName()73 	QString getStyleMaintainerName() const
74 	{
75 		return StyleMaintainerName;
76 	}
getStyleMaintainerEMail()77 	QString getStyleMaintainerEMail() const
78 	{
79 		return StyleMaintainerEMail;
80 	}
getStyleCreateDate()81 	QString getStyleCreateDate() const
82 	{
83 		return StyleCreateDate;
84 	}
85 
getCurrentFileName()86 	QString getCurrentFileName() const
87 	{
88 		return currentFileName;
89 	}
getPreview()90 	QString getPreview() const
91 	{
92 		return Preview;
93 	}
getDefaultAvatar()94 	QString getDefaultAvatar() const
95 	{
96 		return DefaultAvatar;
97 	}
getDealerPuck()98 	QString getDealerPuck() const
99 	{
100 		return DealerPuck;
101 	}
getSmallBlindPuck()102 	QString getSmallBlindPuck() const
103 	{
104 		return SmallBlindPuck;
105 	}
getBigBlindPuck()106 	QString getBigBlindPuck() const
107 	{
108 		return BigBlindPuck;
109 	}
getHandRanking()110 	QString getHandRanking() const
111 	{
112 		return HandRanking;
113 	}
getTable()114 	QString getTable() const
115 	{
116 		return Table;
117 	}
118 
119 	QString getActionPic(int);
120 
getFKeyIndicatorColor()121 	QString getFKeyIndicatorColor() const
122 	{
123 		return FKeyIndicatorColor;
124 	}
getChanceLabelImpossibleColor()125 	QString getChanceLabelImpossibleColor() const
126 	{
127 		return ChanceLabelImpossibleColor;
128 	}
getChanceLabelPossibleColor()129 	QString getChanceLabelPossibleColor() const
130 	{
131 		return ChanceLabelPossibleColor;
132 	}
getChatLogTextColor()133 	QString getChatLogTextColor() const
134 	{
135 		return ChatLogTextColor;
136 	}
getChatTextNickNotifyColor()137 	QString getChatTextNickNotifyColor() const
138 	{
139 		return ChatTextNickNotifyColor;
140 	}
getLogWinnerMainPotColor()141 	QString getLogWinnerMainPotColor() const
142 	{
143 		return LogWinnerMainPotColor;
144 	}
getLogWinnerSidePotColor()145 	QString getLogWinnerSidePotColor() const
146 	{
147 		return LogWinnerSidePotColor;
148 	}
getLogPlayerSitsOutColor()149 	QString getLogPlayerSitsOutColor() const
150 	{
151 		return LogPlayerSitsOutColor;
152 	}
getLogNewGameAdminColor()153 	QString getLogNewGameAdminColor() const
154 	{
155 		return LogNewGameAdminColor;
156 	}
getBreakLobbyButtonBgColor()157 	QString getBreakLobbyButtonBgColor() const
158 	{
159 		return BreakLobbyButtonBgColor;
160 	}
getRatingStarsColor()161 	QString getRatingStarsColor() const
162 	{
163 		return RatingStarsColor;
164 	}
getPlayerInfoHintTextColor()165 	QString getPlayerInfoHintTextColor() const
166 	{
167 		return PlayerInfoHintTextColor;
168 	}
169 
getPlayerNickTextColor()170 	QString getPlayerNickTextColor() const
171 	{
172 		return PlayerNickTextColor;
173 	}
174 
getPlayerCashTextColor()175 	QString getPlayerCashTextColor() const
176 	{
177 		return PlayerCashTextColor;
178 	}
179 
getPlayerNameLabelFontSize()180 	QString getPlayerNameLabelFontSize() const
181 	{
182 		return playerNameLabelFontSize;
183 	}
184 
getPlayerCashLabelFontSize()185 	QString getPlayerCashLabelFontSize() const
186 	{
187 		return cashFontSize;
188 	}
189 
getFont2String()190 	QString getFont2String() const
191 	{
192 		return font2String;
193 	}
194 
getFont1String()195 	QString getFont1String() const
196 	{
197 		return font1String;
198 	}
199 
getMinimumWindowWidth()200 	QString getMinimumWindowWidth() const
201 	{
202 		return MinimumWindowWidth;
203 	}
getMinimumWindowHeight()204 	QString getMinimumWindowHeight() const
205 	{
206 		return MinimumWindowHeight;
207 	}
getMaximumWindowWidth()208 	QString getMaximumWindowWidth() const
209 	{
210 		return MaximumWindowWidth;
211 	}
getMaximumWindowHeight()212 	QString getMaximumWindowHeight() const
213 	{
214 		return MaximumWindowHeight;
215 	}
getFixedWindowWidth()216 	QString getFixedWindowWidth() const
217 	{
218 		return FixedWindowWidth;
219 	}
getFixedWindowHeight()220 	QString getFixedWindowHeight() const
221 	{
222 		return FixedWindowHeight;
223 	}
getIfFixedWindowSize()224 	QString getIfFixedWindowSize() const
225 	{
226 		return IfFixedWindowSize;
227 	}
228 
getFallBack()229 	bool getFallBack() const
230 	{
231 		return fallBack;
232 	}
getLoadedSuccessfull()233 	bool getLoadedSuccessfull() const
234 	{
235 		return loadedSuccessfull;
236 	}
getState()237 	GtStyleState getState() const
238 	{
239 		return myState;
240 	}
241 
242 	//set pictures
243 	void setTableBackground(gameTableImpl*);
244 	void setCardHolderStyle(QLabel*, int /*bero*/);
245 	void setPlayerSeatActiveStyle(QGroupBox*);
246 	void setPlayerSeatInactiveStyle(QGroupBox*);
247 	void setToolBoxBackground(QGroupBox*);
248 
249 	//set fonts + colors
250 	void setChatLogStyle(QTextBrowser*);
251 	void setChatLogStyle(QPlainTextEdit*);
252 	void setChatInputStyle(QLineEdit*);
253 	void setCashLabelStyle(QLabel*);
254 	void setSetLabelStyle(QLabel*);
255 	void setPlayerNameLabelStyle(QLabel*);
256 	void setSmallFontBoardStyle(QLabel*);
257 	void setBigFontBoardStyle(QLabel*);
258 	void setMenuBarStyle(QMenuBar*);
259 	void setBreakButtonStyle(QPushButton*, int);
260 	void setSpeedStringStyle(QLabel*);
261 	void setVoteButtonStyle(QPushButton*);
262 	void setVoteStringsStyle(QLabel*);
263 	void setBetValueInputStyle(QSpinBox*);
264 	void setSliderStyle(QSlider*);
265 	void setTabWidgetStyle(QTabWidget*, QTabBar*);
266 	void setWindowsGeometry(gameTableImpl*);
267 	void setSpectatorNumberLabelStyle(QLabel*);
268 
269 	//set pics and fonts and colors
270 	void setButtonsStyle(MyActionButton*, MyActionButton*, MyActionButton*, MyActionButton*, int);
271 	void setShowMyCardsButtonStyle( MyActionButton *sc);
272 	void setAwayRadioButtonsStyle(QRadioButton*);
273 
getActionAllInI18NString()274 	QString getActionAllInI18NString() const
275 	{
276 		return ActionAllInI18NString;
277 	}
getActionRaiseI18NString()278 	QString getActionRaiseI18NString() const
279 	{
280 		return ActionRaiseI18NString;
281 	}
getActionBetI18NString()282 	QString getActionBetI18NString() const
283 	{
284 		return ActionBetI18NString;
285 	}
getActionCallI18NString()286 	QString getActionCallI18NString() const
287 	{
288 		return ActionCallI18NString;
289 	}
getActionCheckI18NString()290 	QString getActionCheckI18NString() const
291 	{
292 		return ActionCheckI18NString;
293 	}
getActionFoldI18NString()294 	QString getActionFoldI18NString() const
295 	{
296 		return ActionFoldI18NString;
297 	}
getRiverI18NString()298 	QString getRiverI18NString() const
299 	{
300 		return RiverI18NString;
301 	}
getTurnI18NString()302 	QString getTurnI18NString() const
303 	{
304 		return TurnI18NString;
305 	}
getFlopI18NString()306 	QString getFlopI18NString() const
307 	{
308 		return FlopI18NString;
309 	}
getPreflopI18NString()310 	QString getPreflopI18NString() const
311 	{
312 		return PreflopI18NString;
313 	}
getHandI18NString()314 	QString getHandI18NString() const
315 	{
316 		return HandI18NString;
317 	}
getGameI18NString()318 	QString getGameI18NString() const
319 	{
320 		return GameI18NString;
321 	}
getBetsI18NString()322 	QString getBetsI18NString() const
323 	{
324 		return BetsI18NString;
325 	}
getTotalI18NString()326 	QString getTotalI18NString() const
327 	{
328 		return TotalI18NString;
329 	}
getPotI18NString()330 	QString getPotI18NString() const
331 	{
332 		return PotI18NString;
333 	}
334 
335 	QString getFallBackFieldContent(QString field, int type); // type: 0 = string, 1= picture
336 	QString getMyStateToolTipInfo();
337 
338 private:
339 	//style values
340 	// 	INFOS
341 	QString StyleDescription;
342 	QString StyleMaintainerName;
343 	QString StyleMaintainerEMail;
344 	QString StyleCreateDate;
345 	QString PokerTHStyleFileVersion;
346 	// 	WINDOWS SETTINGS
347 	QString IfFixedWindowSize;
348 	QString FixedWindowWidth;
349 	QString FixedWindowHeight;
350 	QString MinimumWindowWidth;
351 	QString MinimumWindowHeight;
352 	QString MaximumWindowWidth;
353 	QString MaximumWindowHeight;
354 	// 	PICS
355 	QString Preview;
356 	QString ActionAllInI18NPic;
357 	QString ActionRaiseI18NPic;
358 	QString ActionBetI18NPic;
359 	QString ActionCallI18NPic;
360 	QString ActionCheckI18NPic;
361 	QString ActionFoldI18NPic;
362 	QString ActionWinnerI18NPic;
363 	QString BigBlindPuck;
364 	QString SmallBlindPuck;
365 	QString DealerPuck;
366 	QString DefaultAvatar;
367 	QString CardHolderFlop;
368 	QString CardHolderTurn;
369 	QString CardHolderRiver;
370 	QString FoldButtonDefault;
371 	QString FoldButtonHover;
372 	QString FoldButtonChecked;
373 	QString FoldButtonCheckedHover;
374 	QString CheckCallButtonDefault;
375 	QString CheckCallButtonHover;
376 	QString CheckCallButtonChecked;
377 	QString CheckCallButtonCheckedHover;
378 	QString BetRaiseButtonDefault;
379 	QString BetRaiseButtonHover;
380 	QString BetRaiseButtonChecked;
381 	QString BetRaiseButtonCheckedHover;
382 	QString AllInButtonDefault;
383 	QString AllInButtonHover;
384 	QString AllInButtonChecked;
385 	QString AllInButtonCheckedHover;
386 	QString RadioButtonPressed;
387 	QString RadioButtonChecked;
388 	QString RadioButtonCheckedHover;
389 	QString RadioButtonUnchecked;
390 	QString RadioButtonUncheckedHover;
391 	QString PlayerTopSeatInactive;
392 	QString PlayerTopSeatActive;
393 	QString PlayerBottomSeatInactive;
394 	QString PlayerBottomSeatActive;
395 	QString Table;
396 	QString HandRanking;
397 	QString ToolBoxBackground;
398 	QString ShowMyCardsButtonDefault;
399 	QString ShowMyCardsButtonHover;
400 
401 	//	I18N ACTION STRINGS
402 	QString ActionAllInI18NString;
403 	QString ActionRaiseI18NString;
404 	QString ActionBetI18NString;
405 	QString ActionCallI18NString;
406 	QString ActionCheckI18NString;
407 	QString ActionFoldI18NString;
408 	QString PotI18NString;
409 	QString TotalI18NString;
410 	QString BetsI18NString;
411 	QString GameI18NString;
412 	QString HandI18NString;
413 	QString PreflopI18NString;
414 	QString FlopI18NString;
415 	QString TurnI18NString;
416 	QString RiverI18NString;
417 
418 	// 	COLORS
419 	QString FKeyIndicatorColor;
420 	QString ChanceLabelPossibleColor;
421 	QString ChanceLabelImpossibleColor;
422 	QString ChatTextNickNotifyColor;
423 	QString ChatLogTextColor;
424 	QString ChatLogBgColor;
425 	QString ChatLogScrollBarBorderColor;
426 	QString ChatLogScrollBarBgColor;
427 	QString ChatLogScrollBarHandleBorderColor;
428 	QString ChatLogScrollBarHandleBgColor;
429 	QString ChatLogScrollBarArrowBorderColor;
430 	QString ChatLogScrollBarArrowBgColor;
431 	QString LogWinnerMainPotColor;
432 	QString LogWinnerSidePotColor;
433 	QString LogPlayerSitsOutColor;
434 	QString LogNewGameAdminColor;
435 	QString TabWidgetBorderColor;
436 	QString TabWidgetBgColor;
437 	QString TabWidgetTextColor;
438 	QString MenuBgColor;
439 	QString MenuTextColor;
440 	QString BreakLobbyButtonBgColor;
441 	QString BreakLobbyButtonTextColor;
442 	QString BreakLobbyButtonBgDisabledColor;
443 	QString BreakLobbyButtonTextDisabledColor;
444 	QString BreakLobbyButtonBgBlinkColor;
445 	QString BreakLobbyButtonTextBlinkColor;
446 	QString PlayerCashTextColor;
447 	QString PlayerBetTextColor;
448 	QString PlayerNickTextColor;
449 	QString BoardBigTextColor;
450 	QString BoardSmallTextColor;
451 	QString SpeedTextColor;
452 	QString VoteButtonBgColor;
453 	QString VoteButtonTextColor;
454 	QString BetInputTextColor;
455 	QString BetInputBgColor;
456 	QString BetInputDisabledTextColor;
457 	QString BetInputDisabledBgColor;
458 	QString FoldButtonTextColor;
459 	QString FoldButtonCheckableTextColor;
460 	QString CheckCallButtonTextColor;
461 	QString CheckCallButtonCheckableTextColor;
462 	QString BetRaiseButtonTextColor;
463 	QString BetRaiseButtonCheckableTextColor;
464 	QString AllInButtonTextColor;
465 	QString AllInButtonCheckableTextColor;
466 	QString BetSpeedSliderGrooveBgColor;
467 	QString BetSpeedSliderGrooveBorderColor;
468 	QString BetSpeedSliderHandleBgColor;
469 	QString BetSpeedSliderHandleBorderColor;
470 	QString ShowMyCardsButtonTextColor;
471 	QString RatingStarsColor;
472 	QString PlayerInfoHintTextColor;
473 
474 	// 	SIZES
475 	QString ChatLogTextSize;
476 
477 	//internal
478 	QString font2String;
479 	QString font1String;
480 	QString textBrowserFontsize;
481 	QString cashFontSize;
482 	QString setLabelFontSize;
483 	QString playerNameLabelFontSize;
484 	QString smallBoardFontSize;
485 	QString bigBoardFontSize;
486 	QString humanPlayerButtonFontSize;
487 	QString betValueFontSize;
488 
489 	QString tabBarPaddingTop;
490 	QString tabBarPaddingSide;
491 
492 	QByteArray fileContent;
493 	QString currentFileName;
494 	QString currentDir;
495 
496 	QStringList leftItems;
497 	QStringList itemPicsLeft;
498 
499 	ConfigFile *myConfig;
500 	QWidget *myW;
501 
502 	bool fallBack;
503 	bool loadedSuccessfull;
504 	GtStyleState myState;
505 
506 };
507 
508 #endif
509