summaryrefslogtreecommitdiffstats
path: root/knights/resource.h
blob: 0892988efaabda60edf2ee3d377a0572a40bc771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
/***************************************************************************
                          resource.h  -  description
                             -------------------
    begin                : Tue Jul 17 2001
    copyright            : (C) 2003 by Troy Corbin Jr.
    email                : tcorbin@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef RESOURCE_H
#define RESOURCE_H


/**
  *@author Troy Corbin Jr.
  */

/* KDE */
#include <kapp.h>
#include <klocale.h>
#include <kcursor.h>
#include <klistview.h>
#include <kcmdlineargs.h>
/* Qt */
#include <qstylesheet.h>
#include <qvaluelist.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qpixmap.h>
#include <qimage.h>
/* Local */
#include "definitions.h"

class audio;
class KnightsPixCache;
class TabManager;
class Accel;

typedef struct engineResource
{
		QListViewItem	*Item;
		QString				Name;
		QString				Filename;
		QString				Arguments;
		QString				LogFile;
		int						Protocol;
		int						Wins;
		int						Losses;
		int						Draws;
		int						CurrentRef;
};

typedef struct serverResource
{
		QListViewItem *Item;
		QString				Name;
		QString				URL;
		QString				UserName;
		QString				Password;
		QString				LogFile;
		QString				Timeseal;
		bool					StorePass;
		int						Port;
		int						CurrentRef;
};

typedef QValueList<engineResource> engineList;
typedef QValueList<serverResource> serverList;

class resource
{
	public:
													/* The current Theme */
		int										ThemeSize;
		bool									ThemeBorder;
		QStyleSheet						*ConsoleStyle;
		QString								CurrentBoard;
		QString								CurrentChessmen;
		QString								CurrentAudio;
		ThemeHeader						boardHeader;
		ThemeHeader						chessmenHeader;
		ThemeHeader						audioHeader;
		KnightsPixCache				*pixCache;
		TabManager						*tabManager;
		Accel									*myAccel;

													/* General Settings */
		QString								Local_Player;
		QString								Local_Email_Address;
		int										Config_Version;
		bool									Accepted_License;
		int										OPTION_On_Init;
		int										Audio_Volume;
		bool 									OPTION_Audio;
		bool									OPTION_Audio_Current_Only;
		bool 									OPTION_Auto_Queen;
		bool 									OPTION_Auto_Preview;
		bool 									OPTION_Auto_Call_Flag;
		bool									OPTION_Auto_Close_Last_ICS;
		bool									OPTION_Animate_Moves;
		bool									OPTION_Book_White;
		bool									OPTION_Book_Black;
		bool									OPTION_Board_Orientation;
		bool									OPTION_Ponder;
		bool									OPTION_Show_Coord;
		bool									OPTION_Show_Last_Move;
		bool									OPTION_Show_Splash;
		bool									OPTION_Show_Extended_PGN;
		bool									OPTION_Pause_On_Minimize;
		bool									OPTION_Reuse_PGN;
		bool									OPTION_3DBoard;
		QString								PGN_Filename;
		QString								Email_Command_Line;
		QString								Email_Address;
		QString								SCID_Image_Path;
		int										Widget_Height;
													/* ICS Options */
		int										Seek_Timer;
		int										OPTION_Profanity;
		bool									OPTION_Premove;
		bool									OPTION_Kibitz;
		bool									OPTION_Private;
		bool									OPTION_Shout;
		bool									OPTION_Tell;
		bool									OPTION_Seek;
													/* Notification Prompts */
		QString								PromptForSaving;
													/* Colors */
		QColor								COLOR_White;
		QColor								COLOR_Black;
		QColor								COLOR_Background;
		QColor								COLOR_Standard;
		QColor								COLOR_PrivateTell;
		QColor								COLOR_ChannelTell;
		QColor								COLOR_Shout;
		QColor								COLOR_Whisper;
		QColor								COLOR_Notification;
		QColor								COLOR_Notation;
		QColor								COLOR_Notation_Shadow;
		QColor								COLOR_GraphBackground;
		QColor								COLOR_GraphForeground;
													/* Fonts */
		QFont									FONT_Standard;
		QFont									FONT_PrivateTell;
		QFont									FONT_ChannelTell;
		QFont									FONT_Shout;
		QFont									FONT_Whisper;
		QFont									FONT_Notification;
													/* Cursors */
		QCursor								CURSOR_Standard;
		QCursor								CURSOR_Thinking;
		QCursor								CURSOR_Text;
													/* Chess Engines */
		engineList						engines;
		engineList::Iterator	enginesIT;
													/* Chess Servers */
		serverList						servers;
		serverList::Iterator	serversIT;
													/* New Match Presets */
		TCPList								TCPWhite;
		TCPList								TCPBlack;
		char									MatchRules;
		char									Type[4];
		char									Strength[4];

													resource( KCmdLineArgs *args );
													~resource();

		void									ConfigRead( void );
		void									ConfigWrite( void );
		
		void									readThemeDir( void );
		QString								getBoard( int Index=-1 );
		QString								getChessmen( int Index=-1 );
		QString								getSounds( int Index=-1 );
		QString								themeDir( void );
		void									setTheme( int BoardIndex=-1, int ChessmenIndex=-1 );
		void									setAudio( int AudioIndex=-1 );
		void									resizeTheme( const int &size );

													/**
													Call buildStyle whenever you need to reparse the Resource configuration */
		void									buildStyle( void );
		QPixmap								LoadIcon( QString Name, int Group );
		QPixmap								loadSCIDImage( const QString &name );
		void									play( const char );

	private:

		QStyleSheetItem				*SSI_Default;
		QStyleSheetItem				*SSI_PrivateTell;
		QStyleSheetItem				*SSI_ChannelTell;
		QStyleSheetItem				*SSI_Shout;
		QStyleSheetItem				*SSI_Whisper;
		QStyleSheetItem				*SSI_Notification;

		QString								GlobalDataDir;
		QString								LocalDataDir;

		QStringList						Boards;
		QStringList						Chessmen;
		QStringList						Sounds;
		KIconLoader						*Icons;
		audio									*Audio;

		void									ReadEngines( void );
		void									WriteEngines( void );

		void									ReadServers( void );
		void									WriteServers( void );
		
		void									ReadMatchParam( void );
		void									WriteMatchParam( void );
		
		void									ReadColors( void );
		void									WriteColors( void );

		void									ReadFonts( void );
		void									WriteFonts( void );

		/**
			Borrowed from KMail
			Very primitive en/de-cryption so that the password is not
			readable in the config file. But still very easy breakable.
		*/
		QString								encryptStr( const QString& inStr ) const;
		QString								decryptStr( const QString& inStr ) const;
		QString								themeURL( const QString );
		void									loadThemeItem( const QString& URL, QImage& Image );
};

#endif