Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4870 leency 1
/*
2
GAME CENTER v1.0
3
*/
4
 
5
#define MEMSIZE 0x3E80
6
#include "..\lib\kolibri.h"
7
#include "..\lib\strings.h"
8
#include "..\lib\mem.h"
9
#include "..\lib\file_system.h"
10
#include "..\lib\dll.h"
11
#include "..\lib\figures.h"
12
 
13
#include "..\lib\lib.obj\libio_lib.h"
14
#include "..\lib\lib.obj\libimg_lib.h"
15
 
16
system_colors sc;
17
proc_info Form;
18
 
19
struct link {
20
	char *name;
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", 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
	"Pipes", "/sys/games/pipes", 26,
57
	"Pong", "/sys/games/pong", 12,
58
	"Pong3", "/sys/games/pong3", 12,
59
	"Reversi", "/sys/games/reversi", 35,
60
	"Rforces", "/sys/games/rforces", 35,
61
	"Rsquare", "/sys/games/rsquare", 35,
62
	"Snake", "/sys/games/snake", 32,
63
	"Sq game", "/sys/games/sq_game", 35,
64
	"Sudoku", "/sys/games/sudoku", 25,
65
	"Sea War", "/sys/games/SW", 35,
66
	"Tanks", "/sys/games/tanks", 35,
67
	"Tetris", "/sys/games/tetris", 35,
68
	"Whowtbam", "/sys/games/whowtbam", 35,
69
	"Xonix", "/sys/games/xonix", 21,
70
 
71
};
72
 
73
struct struct_skin {
74
	dword image, w, h;
75
	int Load();
76
} skin;
77
 
78
int struct_skin::Load()
79
{
80
	int i;
81
	dword image_data;
82
	skin.image = load_image("/sys/iconstrp.png");
83
	if (!skin.image) notify("'iconstrp.png not found' -E");
84
	skin.w = DSWORD[skin.image+4];
85
	skin.h = DSWORD[skin.image+8];
86
	image_data = DSDWORD[skin.image+24];
87
	sc.get();
88
 
89
	for (i=0; i
90
	{
91
		if (DSDWORD[image_data + i]==0) DSDWORD[image_data + i] = 0xF3F3F3;
92
	}
93
}
94
 
95
 
96
void main()
97
{
98
	int id, key;
99
	mem_Init();
100
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
101
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
102
	skin.Load();
103
 
104
	loop()
105
   {
106
      switch(WaitEvent())
107
      {
108
         case evButton:
109
            id=GetButtonID();
110
            if (id==1) ExitProcess();
111
            if (id>=100) RunProgram(games[id-100].path, "");
112
			break;
113
 
114
        case evKey:
115
			key = GetKey();
116
			break;
117
 
118
         case evReDraw:
119
			sc.get();
120
			DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," ");
121
			GetProcessInfo(#Form, SelfInfo);
122
			if (Form.status_window>2) break;
123
			draw_window();
124
			break;
125
      }
126
   }
127
}
128
 
129
 
130
void draw_window()
131
{
132
	int row, col, col_max=8;
133
	int col_w=68, col_h=70;
134
	int tmp,y=25;
135
	DrawBar(0,0,Form.cwidth, y-1, sc.work);
136
	DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph);
137
	DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3);
138
	WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center");
139
 
140
	y += 7;
141
	for (col=0, row=0; games[row*col_max+col].name!=0; col++)
142
	{
143
		if (col==col_max) {
144
			row++;
145
			col=0;
146
		}
147
		DefineButton(col*col_w+6,row*col_h+y,col_w,col_h,row*col_max+col+100+BT_HIDE,0);
148
		tmp = col_w/2;
149
		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);
150
		WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,games[row*col_max+col].name);
151
		WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,games[row*col_max+col].name);
152
	}
153
}
154
 
155
 
156
 
157
stop: