Subversion Repositories Kolibri OS

Rev

Rev 5055 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5055 Rev 5151
Line 1... Line 1...
1
/*
1
/*
2
GAME CENTER v1.0
2
GAME CENTER v1.5
3
*/
3
*/
Line 4... Line 4...
4
 
4
 
5
#define MEMSIZE 0x3E80
5
#define MEMSIZE 0x3E80
6
#include "..\lib\kolibri.h" 
6
#include "..\lib\kolibri.h" 
Line 10... Line 10...
10
#include "..\lib\dll.h"
10
#include "..\lib\dll.h"
11
#include "..\lib\figures.h"
11
#include "..\lib\figures.h"
Line 12... Line 12...
12
 
12
 
13
#include "..\lib\lib.obj\libio_lib.h"
13
#include "..\lib\lib.obj\libio_lib.h"
-
 
14
#include "..\lib\lib.obj\libimg_lib.h"
Line 14... Line 15...
14
#include "..\lib\lib.obj\libimg_lib.h"
15
#include "..\lib\lib.obj\libini.h"
15
 
16
 
16
system_colors sc;
-
 
17
proc_info Form;
-
 
18
 
-
 
19
struct link {
-
 
20
	char *name;
17
system_colors sc;
21
	char *path;
-
 
22
	int icon;
-
 
23
};
-
 
24
 
-
 
25
struct link games[] = {
-
 
26
	"Bomber", "/kolibrios/games/bomber/bomber", 35,
-
 
27
	"DOOM1", "/kolibrios/games/doom1/doom", 43,
-
 
28
	"DOOM2", "/kolibrios/games/doom2/doom", 43,
-
 
29
	"Fara", "/kolibrios/games/fara/fara", 42,
-
 
30
	"JumpBump", "/kolibrios/games/jumpbump/jumpbump.kex", 35,
-
 
31
	"Loderunner", "/kolibrios/games/LRL/LRL", 41,
-
 
32
	"BabyPainter", "/kolibrios/games/baby painter", 35,
-
 
33
	"Knight", "/kolibrios/games/knight", 35,
-
 
34
	"Pinton", "/kolibrios/games/piton", 32,
-
 
35
 
-
 
36
	"15", "/sys/games/15", 34,
-
 
37
	"Arcanii", "/sys/games/arcanii", 12,
-
 
38
	"Ataka", "/sys/games/ataka", 35,
-
 
39
	"C4", "/sys/games/c4", 35,
-
 
40
	"Checkers", "/sys/games/checkers", 20,
-
 
41
	"Clicks", "/sys/games/clicks", 18,
-
 
42
	"FNumbers", "/sys/games/FindNumbers", 35,
-
 
43
	"Flood-It", "/sys/games/flood-it", 27,
-
 
44
	"Freecell", "/sys/games/freecell", 35,
-
 
45
	"Gomoku", "/sys/games/gomoku", 24,
-
 
46
	"Invaders", "/kolibrios/games/invaders", 35,
-
 
47
	"Klavisha", "/sys/games/klavisha", 35,
-
 
48
	"Kosilka", "/sys/games/kosilka", 23,
-
 
49
	"Lines", "/sys/games/lines", 35,
-
 
50
	"MBlocks", "/sys/games/mblocks", 11,
-
 
51
	"Megamaze", "/sys/games/megamaze", 35,
-
 
52
	"Mine", "/sys/games/mine", 14,
-
 
53
	"Square", "/sys/games/msquare", 35,
-
 
54
	"Padenie", "/sys/games/padenie", 35,
-
 
55
	"Phenix", "/sys/games/phenix", 35,
-
 
56
	"Pig", "/tmp0/1/games/pig/pig", 35,
-
 
57
	"Pipes", "/sys/games/pipes", 26,
-
 
58
	"Pong", "/sys/games/pong", 12,
-
 
59
	"Pong3", "/sys/games/pong3", 12,
-
 
60
	"Reversi", "/sys/games/reversi", 35,
-
 
61
	"Rforces", "/sys/games/rforces", 35,
-
 
62
	"Rsquare", "/sys/games/rsquare", 35,
-
 
63
	"Snake", "/sys/games/snake", 32,
-
 
64
	"Sq game", "/sys/games/sq_game", 35,
-
 
65
	"Sudoku", "/sys/games/sudoku", 25,
-
 
66
	"Sea War", "/sys/games/SW", 35,
-
 
67
	"Tanks", "/sys/games/tanks", 35,
-
 
68
	"Tetris", "/sys/games/tetris", 35,
-
 
69
	"Whowtbam", "/sys/games/whowtbam", 35,
-
 
70
	"Xonix", "/sys/games/xonix", 21,
-
 
Line 71... Line 18...
71
	0
18
proc_info Form;
72
};
19
int run_id, enum_i;
73
 
20
 
74
struct struct_skin {
21
struct struct_skin {
Line 98... Line 45...
98
{   
45
{   
99
	int id, key;
46
	int id, key;
100
	mem_Init();
47
	mem_Init();
101
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
48
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
102
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
49
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
-
 
50
	if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
103
	skin.Load();
51
	skin.Load();
Line 104... Line 52...
104
	
52
	
105
	loop()
53
	loop()
106
   {
54
   {
107
      switch(WaitEvent())
55
      switch(WaitEvent())
108
      {
56
      {
109
         case evButton:
57
         case evButton:
110
            id=GetButtonID();               
58
            id=GetButtonID();               
-
 
59
            if (id==1) ExitProcess();
-
 
60
            if (id>=100)
-
 
61
            {
-
 
62
            	run_id = id - 100;
111
            if (id==1) ExitProcess();
63
            	enum_i = 0;
-
 
64
            	ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #run_game);
112
            if (id>=100) RunProgram(games[id-100].path, "");
65
            }
Line 113... Line 66...
113
			break;
66
			break;
114
      
67
      
115
        case evKey:
68
        case evKey:
Line 125... Line 78...
125
			break;
78
			break;
126
      }
79
      }
127
   }
80
   }
128
}
81
}
Line 129... Line -...
129
 
-
 
130
 
82
 
131
void draw_window()
83
byte run_game(dword key_value, key_name, sec_name, f_name)
132
{
84
{
-
 
85
	if (run_id==enum_i)
-
 
86
	{
133
	int row, col, col_max=8;
87
		ESBYTE[key_value + strchr(key_value, ',') - 1] = 0;
134
	int col_w=68, col_h=70;
88
		RunProgram(key_value, '');
-
 
89
		return 0;
135
	int tmp,y=25;
90
	}
136
	DrawBar(0,0,Form.cwidth, y-1, sc.work);
91
	enum_i++;
137
	DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph);
-
 
138
	DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3);
-
 
-
 
92
	return 1;
Line -... Line 93...
-
 
93
}
-
 
94
 
139
	WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center");
95
 
-
 
96
int col_max, col_w, col_h, y;
140
 
97
int row, col;
141
	y += 7;
98
 
-
 
99
byte key_process(dword key_value, key_name, sec_name, f_name)
-
 
100
{
-
 
101
	int tmp;
-
 
102
	int icon_n;
142
	for (col=0, row=0; games[row*col_max+col].name!=0; col++)
103
 
143
	{
104
 
144
		if (col==col_max) {
105
	if (col==col_max) {
145
			row++;
106
		row++;
146
			col=0;
107
		col=0;
147
		}
108
	}
-
 
109
	DefineButton(col*col_w+6,row*col_h+y,col_w,col_h-10,row*col_max+col+100+BT_HIDE,0);
148
		DefineButton(col*col_w+6,row*col_h+y,col_w,col_h,row*col_max+col+100+BT_HIDE,0);
110
	tmp = col_w/2;
149
		tmp = col_w/2;
111
	icon_n = atoi(key_value + strchr(key_value, ','));
150
		img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, games[row*col_max+col].icon*32);
112
	img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, icon_n*32);
-
 
113
	WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,key_name);
-
 
114
	WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,key_name);
151
		WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,games[row*col_max+col].name);
115
	col++;
-
 
116
	return 1;
-
 
117
}
-
 
118
 
-
 
119
void draw_window()
-
 
120
{
-
 
121
	y = 25;
-
 
122
	DrawBar(0,0,Form.cwidth, y-1, sc.work);
-
 
123
	DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph);
-
 
124
	DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3);
-
 
125
	WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center");
-
 
126
	y += 2;
-
 
127
	col_max=8;
-
 
128
	col_w=68;
-
 
129
	col_h=70;
-
 
130
	col = row = 0;
152
		WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,games[row*col_max+col].name);
131
 
Line 153... Line 132...
153
	}
132
	ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #key_process);