Subversion Repositories Kolibri OS

Rev

Rev 4652 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4652 Rev 5123
Line 1... Line -...
1
#ifndef AUTOBUILD
-
 
2
#include "lang.h"
-
 
3
#endif
-
 
4
//#define BUILD_RUS
-
 
5
#ifndef __MENUET__
1
//#define LANG_RUS
6
#include 
2
#define NDEBUG
7
#include 
3
#include 
8
#include 
4
#include 
9
#include 
5
#include 
10
#include 
6
#include 
11
#else
7
#include 
12
#include 
-
 
13
#include 
-
 
14
using namespace Menuet;
-
 
15
#define strlen StrLen
-
 
16
#define strcpy StrCopy
-
 
17
#define memcpy MemCopy
-
 
18
#include 
-
 
19
const unsigned dectab[] = { 1000000000, 100000000, 10000000, 1000000, 100000,
-
 
20
                   10000, 1000, 100, 10, 0 };
-
 
21
int sprintf( char *Str, char* Format, ... )
-
 
22
{
-
 
23
        int i, fmtlinesize, j, k, flag;
-
 
24
        unsigned head, tail;
-
 
25
        char c;
-
 
26
        va_list arglist;
-
 
27
        //
-
 
28
        va_start(arglist, Format);
-
 
29
 
-
 
30
        //
-
 
31
        fmtlinesize = strlen( Format );
-
 
32
        //
-
 
33
        if( fmtlinesize == 0 ) return 0;
-
 
34
  
-
 
35
        //
-
 
36
        for( i = 0, j = 0; i < fmtlinesize; i++ )
-
 
37
        {
-
 
38
                //
-
 
39
                c = Format[i];
-
 
40
                //
-
 
41
                if( c != '%' )
-
 
42
                {
-
 
43
                        Str[j++] = c;
-
 
44
                        continue;
-
 
45
                }
-
 
46
                //
-
 
47
                i++;
-
 
48
                //
-
 
49
                if( i >= fmtlinesize ) break;
-
 
50
 
-
 
51
                //
-
 
52
                flag = 0;
-
 
53
                //
-
 
54
                c = Format[i];
-
 
55
                if (c == 'l') c = Format[++i];
-
 
56
                //
-
 
57
                switch( c )
-
 
58
                {
-
 
59
                //
-
 
60
                case '%':
-
 
61
                        Str[j++] = c;
-
 
62
                        break;
-
 
63
                // ˜„ Ÿ‰•
-
 
64
                case 's':
-
 
65
                        char* str;
-
 
66
                        str = va_arg(arglist, char*);
-
 
67
                        for( k = 0; ( c = str[k] ) != 0; k++ )
-
 
68
                        {
-
 
69
                                Str[j++] = c;
-
 
70
                        }
-
 
71
                        break;
-
 
72
                // ˜„ Ÿ•‹Šž
-
 
73
                case 'c':
-
 
74
                        Str[j++] = va_arg(arglist, int) & 0xFF;
-
 
75
                        break;
-
 
76
                // ˜„ „ˆŒ– ŸŠž  „…Ÿš•‚Œ‹ •„…
-
 
77
                case 'u':
-
 
78
                case 'd':
-
 
79
                        head = va_arg(arglist, unsigned);
-
 
80
                        for( k = 0; dectab[k] != 0; k++ )
-
 
81
                        {
-
 
82
                                tail = head % dectab[k];
-
 
83
                                head /= dectab[k];
-
 
84
                                c = head + '0';
-
 
85
                                if( c == '0' )
-
 
86
                                {
-
 
87
                                        if( flag ) Str[j++] = c;
-
 
88
                                }
-
 
89
                                else
-
 
90
                                {
-
 
91
                                        flag++;
-
 
92
                                        Str[j++] = c;
-
 
93
                                }
-
 
94
                                //
-
 
95
                                head = tail;
-
 
96
                        }
-
 
97
                        //
-
 
98
                        c = head + '0';
-
 
99
                        Str[j++] = c;
-
 
100
                        break;
-
 
101
                default:
-
 
102
                        break;
-
 
103
                }
-
 
104
        }
-
 
105
        //
-
 
106
        Str[j] = 0;
-
 
107
        return j;
-
 
108
}
-
 
109
int isdigit(int c)
-
 
110
{
-
 
111
	return (c>='0' && c<='9');
-
 
112
}
-
 
113
int atoi(const char* string)
-
 
114
{
-
 
115
	int res=0;
-
 
116
	int sign=0;
-
 
117
	const char* ptr;
-
 
118
	for (ptr=string; *ptr && *ptr<=' ';ptr++);
-
 
119
	if (*ptr=='-') {sign=1;++ptr;}
-
 
120
	while (*ptr >= '0' && *ptr <= '9')
-
 
121
	{
-
 
122
		res = res*10 + *ptr++ - '0';
-
 
123
	}
-
 
124
	if (sign) res = -res;
-
 
125
	return res;
-
 
126
}
-
 
127
int islower(int c)
-
 
128
{
-
 
129
	return (c>='a' && c<='z');
-
 
130
}
-
 
131
int abs(int n)
-
 
132
{
-
 
133
	return (n<0)?-n:n;
-
 
134
}
-
 
135
int memcmp(const void* buf1, const void* buf2, unsigned count)
-
 
136
{
-
 
137
	const char* ptr1 = (const char*)buf1;
-
 
138
	const char* ptr2 = (const char*)buf2;
-
 
139
	unsigned i=0;
-
 
140
	while (i
-
 
141
	if (i==count)
-
 
142
		return 0;
-
 
143
	else if (*ptr1<*ptr2)
-
 
144
		return -1;
-
 
145
	else
-
 
146
		return 1;
-
 
147
}
-
 
148
void strncpy(char* dest, const char* source, unsigned len)
-
 
149
{
-
 
150
	char* ptr1 = dest;
-
 
151
	const char *ptr2 = source;
-
 
152
	for (;len-- && *ptr2; *ptr1++=*ptr2++) ;
-
 
153
}
-
 
154
unsigned int rand_data[4];
-
 
155
 
-
 
156
void randomize()
-
 
157
{
-
 
158
	rand_data[0] = (unsigned int)Clock();
-
 
159
	rand_data[1] = (unsigned int)GetPackedTime();
-
 
160
	rand_data[2] = (unsigned int)GetPackedDate();
-
 
161
	rand_data[3] = (unsigned int)0xA3901BD2 ^ GetPid();
-
 
162
}
-
 
163
 
-
 
Line 164... Line 8...
164
unsigned int rand()
8
 
-
 
9
// sprintf is too heavy
165
{
10
int itoa(char* dst, int number)
-
 
11
{
-
 
12
	int result = 0;
-
 
13
	if (number < 0) {
-
 
14
		result++;
-
 
15
		*dst++ = '-';
-
 
16
		number = -number;
-
 
17
	}
-
 
18
	char digits[16];
-
 
19
	int ndigits = 0;
166
	rand_data[0] ^= _HashDword(rand_data[3] + 0x2835C013U);
20
	do {
-
 
21
		digits[ndigits++] = number % 10;
-
 
22
		number /= 10;
167
	rand_data[1] += _HashDword(rand_data[0]);
23
	} while (number);
168
	rand_data[2] -= _HashDword(rand_data[1]);
24
	result += ndigits;
169
	rand_data[3] ^= _HashDword(rand_data[2]);
25
	for (; ndigits--; )
170
	return rand_data[3];
26
		*dst++ = digits[ndigits] + '0';
171
}
27
	return result;
Line 172... Line -...
172
 
-
 
173
#define random(k)  (rand() % (k))
-
 
174
#define floor Floor
-
 
175
double fabs(double x)
-
 
176
{
-
 
177
	__asm	fld	x
-
 
178
	__asm	fabs
-
 
179
}
-
 
180
#define M_PI       3.14159265358979323846
-
 
181
double cos(double x)
-
 
182
{
-
 
183
	__asm	fld	x
-
 
184
	__asm	fcos
-
 
185
}
-
 
186
double sin(double x)
-
 
187
{
-
 
188
	__asm	fld	x
-
 
189
	__asm	fsin
-
 
190
}
-
 
191
/*inline void printf(const char* format, ...)
-
 
192
{}*/
-
 
193
#define printf /* nothing */
-
 
194
inline void strcat(char* str1, const char* str2)
-
 
195
{strcpy(str1+strlen(str1),str2);}
-
 
196
int strncmp(const char* str1, const char* str2, unsigned len)
-
 
197
{
-
 
198
	for (;len--;)
-
 
199
	{
-
 
200
		if (*str1 != *str2) break;
-
 
201
		if (*str1 == 0)
-
 
202
			return 0;
-
 
203
		++str1;++str2;
-
 
204
	}
-
 
205
	if (len==(unsigned)-1)
-
 
206
		return 0;
-
 
207
	if (*str1 < *str2)
-
 
208
		return -1;
-
 
209
	return 1;
-
 
210
}
-
 
211
#define clock Clock
-
 
212
typedef unsigned int clock_t;
-
 
213
#define CLOCKS_PER_SEC 100
-
 
214
#define XK_Left		0xB0
-
 
215
#define XK_Right	0xB3
-
 
216
#define XK_Up		0xB2
-
 
217
#define XK_Down		0xB1
-
 
218
#define XK_Return	0x0D
-
 
219
#define XK_space	0x20
-
 
220
#define XK_Escape	0x1B
-
 
221
#define XK_less		'<'
-
 
222
#define XK_comma	','
-
 
223
#define XK_period	'.'
-
 
224
#define XK_greater	'>'
-
 
225
#define XK_minus	'-'
-
 
226
#define XK_equal	'='
-
 
227
#define XK_underscore	'_'
-
 
228
#define XK_plus		'+'
-
 
229
#define XK_Delete	0xB6
-
 
230
#define XK_F8		0x39
-
 
231
#define XK_l		'l'
-
 
232
#define XK_L		'L'
-
 
233
#define XK_F2		0x33
-
 
234
#define XK_s		's'
-
 
235
#define XK_S		'S'
-
 
236
#define XK_slash	'/'
-
 
237
#define XK_question	'?'
-
 
238
#define XK_n		'n'
-
 
239
#define XK_N		'N'
-
 
240
#define XK_t		't'
-
 
241
#define XK_T		'T'
-
 
242
#define XK_r		'r'
-
 
243
#define XK_R		'R'
-
 
244
#define XK_b		'b'
-
 
245
#define XK_B		'B'
-
 
246
#define XK_f		'f'
-
 
247
#define XK_F		'F'
-
 
248
#define assert(a) /* nothing */
-
 
249
#include "qsort.c"
-
 
250
#endif
28
}
251
#include "gr-draw.h"
29
 
252
#include "board.h"
30
#include "gr-draw.h"
253
#include "player.h"
31
#include "board.h"
254
#include "buttons.h"
32
#include "player.h"
Line 270... Line 48...
270
  void Clear();
48
 
271
  void Add(const PlayWrite &pl);
49
  void Clear();
272
  PlayWrite &operator[](int i) {return play[i];}
50
  void Add(const PlayWrite &pl);
273
  int GetNPlay() const {return nplay;}
51
  PlayWrite &operator[](int i) {return play[i];}
274
#ifndef __MENUET__
52
  int GetNPlay() const {return nplay;}
275
  int OpenFile(const char *name, int kind);
53
#ifndef NO_FILES
276
  int MsgOpenFile(const char *name, int kind);
54
  int OpenFile(const char *name, int kind);
277
  int SaveFile(const char *name, int num, int kind);
55
  int MsgOpenFile(const char *name, int kind);
278
  int MsgSaveFile(const char *name, int num, int kind);
56
  int SaveFile(const char *name, int num, int kind);
279
#endif
57
  int MsgSaveFile(const char *name, int num, int kind);
Line 283... Line 61...
283
 
61
  void Extend(int n = -1);
Line 284... Line 62...
284
  PlayWrite *play;
62
 
285
  int nplay, mplay;
63
  PlayWrite *play;
286
protected:
64
  int nplay, mplay;
287
#ifndef __MENUET__
65
protected:
288
  static const char *const search[];
66
#ifndef NO_FILES
289
  static int AnalizeKind(FILE *f, const int w[], const char *smb = 0);
67
  static const char *const search[];
290
  static int ReadFileTo(FILE *f, char c);
68
  static int AnalizeKind(FILE *f, const int w[], const char *smb = 0);
291
  static int ReadFileTo(FILE *f, const char *c);
69
  static int ReadFileTo(FILE *f, char c);
292
  static int ReadTheText(FILE *f, const char *s);
70
  static int ReadFileTo(FILE *f, const char *c);
293
#endif
71
  static int ReadTheText(FILE *f, const char *s);
294
};
72
#endif
Line 295... Line -...
295
 
-
 
296
#ifndef __MENUET__
73
};
297
#if LANG_RUS //Pending Russian Translations
74
 
298
    #define CHECKERS_CANT_OPEN_STR "\n˜ èª¨: ¥ ¬®£ã ®âªàëâì ä ©« \"%s\".\n"
75
#ifdef LANG_RUS //Pending Russian Translations
299
    #define CHECKERS_FILE_EMPTY_STR "\n˜ èª¨: ” ©« \"%s\" ¯ãáâ.\n"
76
    #define CHECKERS_CANT_OPEN_STR "\n˜ èª¨: ¥ ¬®£ã ®âªàëâì ä ©« \"%s\".\n"
300
    #define CHECKERS_INVALID_FILE_STR "\n˜ èª¨: ” ©« \"%s\" ®è¨¡®ç­ë©.\n"
77
    #define CHECKERS_FILE_EMPTY_STR "\n˜ èª¨: ” ©« \"%s\" ¯ãáâ.\n"
301
    #define FILE_WRONG_TYPE_STR "\n˜ èª¨: ” ©« \"%s\" ¨¬¥¥â ­¥¢¥à­ë© ⨯.\n"
78
    #define CHECKERS_INVALID_FILE_STR "\n˜ èª¨: ” ©« \"%s\" ®è¨¡®ç­ë©.\n"
Line 323... Line 100...
323
    #define ROTATE_BOARD_STR "rotate board"
100
    #define SAVE_STR "save"
324
    #define EXIT_STR "exit"
101
    #define ROTATE_BOARD_STR "rotate board"
325
    #define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
102
    #define EXIT_STR "exit"
326
 
103
    #define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
Line -... Line 104...
-
 
104
 
327
const char *const TPlayArray::search[] =
105
#ifndef NO_FILES
328
  {"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
106
const char *const TPlayArray::search[] =
-
 
107
  {"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
Line 329... Line 108...
329
 
108
#endif
330
#else /*For all other languages except RUS*/
109
 
331
    #define CHECKERS_CANT_OPEN_STR "\nCheckers: Can't open the file \"%s\".\n"
110
#else /*For all other languages except RUS*/
332
    #define CHECKERS_FILE_EMPTY_STR "\nCheckers: The file \"%s\" is empty.\n"
111
    #define CHECKERS_CANT_OPEN_STR "\nCheckers: Can't open the file \"%s\".\n"
Line 355... Line 134...
355
    #define SAVE_STR "save"
134
    #define CLEAR_STR "clear"
356
    #define ROTATE_BOARD_STR "rotate board"
135
    #define SAVE_STR "save"
357
    #define EXIT_STR "exit"
136
    #define ROTATE_BOARD_STR "rotate board"
358
    #define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
137
    #define EXIT_STR "exit"
359
const char *const TPlayArray::search[] =
138
    #define CHECKERS_INVALID_STR "Checkers: Invalid key %s\n"
-
 
139
 
-
 
140
#ifndef NO_FILES
360
     {"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
141
const char *const TPlayArray::search[] =
361
 
142
     {"checkers-", "play:", "text", "bin_1.0\n", "history_", "1.0", "1.1"};
362
#endif
-
 
363
#endif
143
#endif
-
 
144
 
364
void TPlayArray::Clear()
145
#endif
365
{
146
void TPlayArray::Clear()
366
  if (play) delete[] play;
147
{
367
  play = 0; nplay = 0; mplay = 0;
148
  if (play) delete[] play;
368
}
149
  play = 0; nplay = 0; mplay = 0;
Line 390... Line 171...
390
  play[nplay] = pl;
171
  Extend();
391
  nplay++;
172
  play[nplay] = pl;
392
}
173
  nplay++;
393
 
174
}
Line 394... Line 175...
394
#ifndef __MENUET__
175
 
395
int TPlayArray::AnalizeKind(FILE *f, const int w[], const char *smb)
176
#ifndef NO_FILES
396
{
177
int TPlayArray::AnalizeKind(FILE *f, const int w[], const char *smb)
397
  int i, L, was1 = 1;
178
{
398
  unsigned char ch;
179
  int i, L, was1 = 1;
399
  int fnd[NELEM(search)];
180
  unsigned char ch;
Line 878... Line 659...
878
};
659
  int ur_type;
879
 
660
};
Line 880... Line 661...
880
void TMainDraw::InitButton()
661
 
881
{
662
void TMainDraw::InitButton()
882
  char newgame_literal[] = NEW_GAME_STR;
663
{
883
  char list_literal[] = LIST_STR;
664
  static char newgame_literal[] = NEW_GAME_STR;
884
  char delete_literal[] = DELETE_STR;
665
  static char list_literal[] = LIST_STR;
885
  char clear_literal[] = CLEAR_STR;
666
  static char delete_literal[] = DELETE_STR;
886
  char save_literal[] = SAVE_STR;
667
  static char clear_literal[] = CLEAR_STR;
887
  char rotateboard_literal[] = ROTATE_BOARD_STR;
668
  static char save_literal[] = SAVE_STR;
888
  char exit_literal[] = EXIT_STR;
669
  static char rotateboard_literal[] = ROTATE_BOARD_STR;
889
 
670
  static char exit_literal[] = EXIT_STR;
890
  char one_literal[] = "1";
671
 
891
  char dash_literal[] = "-";
672
  static char one_literal[] = "1";
892
  char plus_literal[] = "+";
673
  static char dash_literal[] = "-";
893
  char leftshift_literal[] = "<<";
674
  static char plus_literal[] = "+";
894
  char rightshift_literal[] = ">>";
675
  static char leftshift_literal[] = "<<";
895
  char lessthan_literal[] = "<";
676
  static char rightshift_literal[] = ">>";
896
  char greaterthan_literal[] = ">";
677
  static char lessthan_literal[] = "<";
897
  char xor_literal[] = "^";
678
  static char greaterthan_literal[] = ">";
Line 898... Line 679...
898
 
679
  static char xor_literal[] = "^";
899
  button.Add(1, 80, 22, newgame_literal);
680
 
900
  button.Add(6, 60, 22, list_literal);
681
  button.Add(1, 80, 22, newgame_literal);
901
  button.Add(7, 60, 22, delete_literal);
682
  button.Add(6, 60, 22, list_literal);
Line 907... Line 688...
907
  play_list->a.Add(27, 37, 22, play_num[1]);
688
  play_list->a.Add(22, 20, 22, plus_literal);
908
  play_list->SetDefW();
689
  play_list->a.Add(27, 37, 22, play_num[1]);
909
  button.Add(play_list);
690
  play_list->SetDefW();
910
  button.Add(24, 50, 22, clear_literal);
691
  button.Add(play_list);
911
#ifndef __MENUET__
692
  button.Add(24, 50, 22, clear_literal);
912
  button.Add(25, 50, 22, save_literal);
693
#ifndef NO_FILES
913
#endif
694
  button.Add(25, 50, 22, save_literal);
914
  button.Add(2, 120, 22, player_str[0]);
695
#endif
915
  button.Add(3, 120, 22, player_str[1]);
696
  button.Add(2, 120, 22, player_str[0]);
916
  button.Add(4, 110, 22, rotateboard_literal);
697
  button.Add(3, 120, 22, player_str[1]);
917
  undo_redo = new TMultiButton(10);
698
  button.Add(4, 110, 22, rotateboard_literal);
Line 968... Line 749...
968
  bt1 = button.GetButton(6);
749
  if (play.GetNPlay() == 0) is_drw = 1;
969
  if (bt1) bt1->drw = is_drw;
750
  bt1 = button.GetButton(6);
970
  bt1 = button.GetButton(7);
751
  if (bt1) bt1->drw = is_drw;
971
  if (bt1) bt1->drw = !is_drw;
752
  bt1 = button.GetButton(7);
972
#ifndef __MENUET__
753
  if (bt1) bt1->drw = !is_drw;
973
  bt1 = button.GetButton(25);
754
#ifndef NO_FILES
974
  if (bt1) bt1->drw = !is_drw;
755
  bt1 = button.GetButton(25);
975
#endif
756
  if (bt1) bt1->drw = !is_drw;
976
  is_drw = board.GetPViewStatus() && play.GetNPlay() > 1;
757
#endif
977
  bt1 = button.GetButton(20);
758
  is_drw = board.GetPViewStatus() && play.GetNPlay() > 1;
978
  if (bt1) bt1->drw = is_drw;
759
  bt1 = button.GetButton(20);
Line 980... Line 761...
980
  if (bt1) bt1->drw = is_drw;
761
  bt1 = button.GetButton(24);
981
  if (is_drw)
762
  if (bt1) bt1->drw = is_drw;
982
  {
763
  if (is_drw)
983
    play_num[0][0] = 0; play_num[1][0] = 0;
764
  {
984
    if (cur_play >= 0) sprintf(play_num[0], "%d", cur_play + 1);
765
    play_num[0][0] = 0; play_num[1][0] = 0;
985
    sprintf(play_num[1], "%d", play.GetNPlay());
766
    if (cur_play >= 0) itoa(play_num[0], cur_play + 1);
986
    thick = (cur_play <= 0) ? 0 : 3;
767
    itoa(play_num[1], play.GetNPlay());
987
#define dynamic_cast static_cast
768
    thick = (cur_play <= 0) ? 0 : 3;
988
    txb = dynamic_cast(play_list->a.GetButton(21));
-
 
989
    if (txb) txb->thick = thick;
769
    txb = static_cast(play_list->a.GetButton(21));
990
    txb = dynamic_cast(play_list->a.GetButton(26));
770
    if (txb) txb->thick = thick;
991
    if (txb) txb->thick = thick;
771
    txb = static_cast(play_list->a.GetButton(26));
992
    thick = (cur_play >= play.GetNPlay() - 1) ? 0 : 3;
772
    if (txb) txb->thick = thick;
993
    txb = dynamic_cast(play_list->a.GetButton(22));
773
    thick = (cur_play >= play.GetNPlay() - 1) ? 0 : 3;
994
    if (txb) txb->thick = thick;
774
    txb = static_cast(play_list->a.GetButton(22));
995
    txb = dynamic_cast(play_list->a.GetButton(27));
775
    if (txb) txb->thick = thick;
996
    if (txb) txb->thick = thick;
776
    txb = static_cast(play_list->a.GetButton(27));
997
#undef dynamic_cast
777
    if (txb) txb->thick = thick;
998
  }
-
 
999
}
778
  }
1000
 
779
}
Line 1001... Line 780...
1001
void TMainDraw::PressUR(int n, TChBoard &board, TGraphDraw *drw)
780
 
1002
{
781
void TMainDraw::PressUR(int n, TChBoard &board, TGraphDraw *drw)
Line 1071... Line 850...
1071
      board.SetPlay(play[cur_play]); need_redraw = 1;
850
      cur_play = play.GetNPlay() - 1;
1072
    }
851
      board.SetPlay(play[cur_play]); need_redraw = 1;
1073
  }
852
    }
1074
  else if (n == 24) {play.Clear(); cur_play = 0; need_redraw = 1;}
853
  }
1075
#ifndef __MENUET__
854
  else if (n == 24) {play.Clear(); cur_play = 0; need_redraw = 1;}
1076
  else if (n == 25)
855
#ifndef NO_FILES
1077
  {
856
  else if (n == 25)
1078
    if (play.GetNPlay() > 0) play.MsgSaveFile(def_savefile, -1, def_savekind);
857
  {
1079
  }
858
    if (play.GetNPlay() > 0) play.MsgSaveFile(def_savefile, -1, def_savekind);
1080
  else if (n == 28)
859
  }
1081
  {
860
  else if (n == 28)
Line 1311... Line 1090...
1311
    else if (ev.key.k == XK_plus) data.main_draw.PressLS(27, data.board, ev.button.drw);
1090
    else if (ev.key.k == XK_underscore) data.main_draw.PressLS(26, data.board, ev.button.drw);
1312
    else if (ev.key.k == XK_Delete) data.main_draw.PressLS(7, data.board, ev.button.drw);
1091
    else if (ev.key.k == XK_plus) data.main_draw.PressLS(27, data.board, ev.button.drw);
1313
    else if (ev.key.k == XK_F8) data.main_draw.PressLS(24, data.board, ev.button.drw);
1092
    else if (ev.key.k == XK_Delete) data.main_draw.PressLS(7, data.board, ev.button.drw);
1314
    else if (ev.key.k == XK_l || ev.key.k == XK_L) data.main_draw.PressLS(6, data.board, ev.button.drw);
1093
    else if (ev.key.k == XK_F8) data.main_draw.PressLS(24, data.board, ev.button.drw);
1315
#ifndef __MENUET__
1094
    else if (ev.key.k == XK_l || ev.key.k == XK_L) data.main_draw.PressLS(6, data.board, ev.button.drw);
1316
    else if (ev.key.k == XK_F2) data.main_draw.PressLS(25, data.board, ev.button.drw);
1095
#ifndef NO_FILES
1317
#endif
1096
    else if (ev.key.k == XK_F2) data.main_draw.PressLS(25, data.board, ev.button.drw);
1318
    else if (ev.key.k == XK_s || ev.key.k == XK_S) data.main_draw.PressLS(28, data.board, ev.button.drw);
1097
#endif
1319
    else if (ev.key.k == XK_slash || ev.key.k == XK_question) data.GoToCurMove(ev.button.drw);
1098
    else if (ev.key.k == XK_s || ev.key.k == XK_S) data.main_draw.PressLS(28, data.board, ev.button.drw);
1320
    else if (ev.key.k == XK_n || ev.key.k == XK_N) data.NewGame(ev.button.drw);
1099
    else if (ev.key.k == XK_slash || ev.key.k == XK_question) data.GoToCurMove(ev.button.drw);
1321
    else if (ev.key.k == XK_t || ev.key.k == XK_T) data.RotateBoard(ev.button.drw);
1100
    else if (ev.key.k == XK_n || ev.key.k == XK_N) data.NewGame(ev.button.drw);
Line 1340... Line 1119...
1340
  }
1119
    break;
1341
  return ret;
1120
  }
1342
}
1121
  return ret;
1343
 
1122
}
Line 1344... Line -...
1344
#ifndef __MENUET__
-
 
1345
int main(int argc, char **argv)
1123
 
1346
{
1124
int main(int argc, char **argv)
1347
  randomize();
1125
{
-
 
1126
  randomize();
1348
  THistory::InitHFile(argv[0]);
1127
#ifndef NO_FILES
-
 
1128
  THistory::InitHFile(argv[0]);
1349
  TMainData data(-1);
1129
#endif
1350
  if (argv && argc >= 2)
1130
  TMainData data(-1);
1351
  {
1131
  if (argv && argc >= 2)
1352
    int i, kx = 1;
1132
  {
1353
    for (i = 1; i < argc; i++)
1133
    int i, kx = 1;
Line 1374... Line 1154...
1374
        else printf(CHECKERS_INVALID_STR, argv[i]);
1154
 
1375
      }
1155
        else printf(CHECKERS_INVALID_STR, argv[i]);
1376
      else if (kx == 0 || kx == 1)
1156
      }
1377
      {
1157
      else if (kx == 0 || kx == 1)
-
 
1158
      {
1378
        data.main_draw.play.MsgOpenFile(argv[i], -1);
1159
#ifndef NO_FILES
-
 
1160
        data.main_draw.play.MsgOpenFile(argv[i], -1);
1379
      }
1161
#endif
1380
    }
1162
      }
1381
  }
1163
    }
1382
  data.InitDef();
1164
  }
1383
  TMainGraphDraw graph(CHECKERS_STR);
1165
  data.InitDef();
Line 1389... Line 1171...
1389
            TGraphDraw::key_down_mask | TGraphDraw::mouse_drag_mask,
1171
  graph.Run(TGraphDraw::button_down_mask | TGraphDraw::button_up_mask |
1390
            450 + 100 * ssf, 528);
1172
            TGraphDraw::key_down_mask | TGraphDraw::mouse_drag_mask,
1391
  return 0;
1173
            450 + 100 * ssf, 528);
1392
}
1174
  return 0;
1393
#else
1175
}
1394
 
-
 
1395
TMainData* mdata;
-
 
1396
TMainGraphDraw* graph;
-
 
1397
 
-
 
1398
bool MenuetOnStart(TStartData &me_start, TThreadData)
-
 
1399
{
-
 
1400
	mdata = new TMainData(-1);
-
 
1401
	graph = new TMainGraphDraw;
-
 
1402
	randomize();
-
 
1403
	mdata->InitDef();
-
 
1404
	static TTimerDraw timer_draw(&mdata->board, graph);
-
 
1405
	mdata->player.draw = TTimerDraw::draw; mdata->player.data = &timer_draw;
-
 
1406
	graph->data = mdata;
-
 
1407
	me_start.WinData.Title = CHECKERS_STR;
-
 
1408
	me_start.Width = 450 + 100*ssf;
-
 
1409
	me_start.Height = 528;
-
 
1410
	return true;
-
 
1411
}
-
 
1412
bool MenuetOnClose(TThreadData)
-
 
1413
{
-
 
1414
	delete mdata;
-
 
1415
	delete graph;
-
 
1416
	return true;
-
 
1417
}
-
 
1418
int MenuetOnIdle(TThreadData)
-
 
1419
{return -1;}
-
 
1420
void MenuetOnSize(int window_rect[], TThreadData)
-
 
1421
{mdata->board.Resize(window_rect[2]-window_rect[0], window_rect[3]-window_rect[1]);}
-
 
1422
void MenuetOnKeyPress(TThreadData)
-
 
1423
{
-
 
1424
	TGraphDraw::event ev;
-
 
1425
	ev.type = TGraphDraw::event::key_down;
-
 
1426
	ev.any.drw = graph;
-
 
1427
	ev.key.k = GetKey();
-
 
1428
	mdata->EventFunction(ev);
-
 
1429
}
-
 
1430
void MenuetOnDraw(void)
-
 
1431
{
-
 
1432
	TGraphDraw::event ev;
-
 
1433
	ev.type = TGraphDraw::event::draw;
-
 
1434
	ev.any.drw = graph;
-
 
1435
	mdata->EventFunction(ev);
-
 
1436
}
-
 
1437
void MenuetOnMouse(TThreadData)
-
 
1438
{
-
 
1439
	short x,y;
-
 
1440
	GetMousePosition(x,y);
-
 
1441
	int m = GetMouseButton() & 1;
-
 
1442
	static int mprev = 0;
-
 
1443
	if (m == mprev)
-
 
1444
		return;
-
 
1445
	mprev = m;
-
 
1446
	TGraphDraw::event ev;
-
 
1447
	ev.type = m ? TGraphDraw::event::button_down : TGraphDraw::event::button_up;
-
 
1448
	ev.any.drw = graph;
-
 
1449
	ev.button.n = 1;
-
 
1450
	ev.button.x = x;
-
 
1451
	ev.button.y = y;
-
 
1452
	mdata->EventFunction(ev);
-
 
1453
}
-
 
1454
#endif
-
 
1455
>
-