summaryrefslogtreecommitdiffstats
path: root/knights/resource.h
blob: 2876af7367ce106ed7f194c412b404049b5229d6 (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 <tdelistview.h>
#include <tdecmdlineargs.h>
/* TQt */
#include <tqstylesheet.h>
#include <tqvaluelist.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqpixmap.h>
#include <tqimage.h>
/* Local */
#include "definitions.h"

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

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

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

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

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

													/* General Settings */
		TQString								Local_Player;
		TQString								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;
		TQString								PGN_Filename;
		TQString								Email_Command_Line;
		TQString								Email_Address;
		TQString								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 */
		TQString								PromptForSaving;
													/* Colors */
		TQColor								COLOR_White;
		TQColor								COLOR_Black;
		TQColor								COLOR_Background;
		TQColor								COLOR_Standard;
		TQColor								COLOR_PrivateTell;
		TQColor								COLOR_ChannelTell;
		TQColor								COLOR_Shout;
		TQColor								COLOR_Whisper;
		TQColor								COLOR_Notification;
		TQColor								COLOR_Notation;
		TQColor								COLOR_Notation_Shadow;
		TQColor								COLOR_GraphBackground;
		TQColor								COLOR_GraphForeground;
													/* Fonts */
		TQFont									FONT_Standard;
		TQFont									FONT_PrivateTell;
		TQFont									FONT_ChannelTell;
		TQFont									FONT_Shout;
		TQFont									FONT_Whisper;
		TQFont									FONT_Notification;
													/* Cursors */
		TQCursor								CURSOR_Standard;
		TQCursor								CURSOR_Thinking;
		TQCursor								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( TDECmdLineArgs *args );
													~resource();

		void									ConfigRead( void );
		void									ConfigWrite( void );
		
		void									readThemeDir( void );
		TQString								getBoard( int Index=-1 );
		TQString								getChessmen( int Index=-1 );
		TQString								getSounds( int Index=-1 );
		TQString								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 );
		TQPixmap								LoadIcon( TQString Name, int Group );
		TQPixmap								loadSCIDImage( const TQString &name );
		void									play( const char );

	private:

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

		TQString								GlobalDataDir;
		TQString								LocalDataDir;

		TQStringList						Boards;
		TQStringList						Chessmen;
		TQStringList						Sounds;
		TDEIconLoader						*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.
		*/
		TQString								encryptStr( const TQString& inStr ) const;
		TQString								decryptStr( const TQString& inStr ) const;
		TQString								themeURL( const TQString );
		void									loadThemeItem( const TQString& URL, TQImage& Image );
};

#endif