Subversion Repositories Kolibri OS

Rev

Rev 5055 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4870 leency 1
/*
5151 leency 2
GAME CENTER v1.5
4870 leency 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"
5151 leency 15
#include "..\lib\lib.obj\libini.h"
4870 leency 16
 
17
system_colors sc;
18
proc_info Form;
5151 leency 19
int run_id, enum_i;
4870 leency 20
 
21
struct struct_skin {
22
	dword image, w, h;
23
	int Load();
24
} skin;
25
 
26
int struct_skin::Load()
27
{
28
	int i;
29
	dword image_data;
30
	skin.image = load_image("/sys/iconstrp.png");
31
	if (!skin.image) notify("'iconstrp.png not found' -E");
32
	skin.w = DSWORD[skin.image+4];
33
	skin.h = DSWORD[skin.image+8];
34
	image_data = DSDWORD[skin.image+24];
35
	sc.get();
36
 
37
	for (i=0; i
38
	{
39
		if (DSDWORD[image_data + i]==0) DSDWORD[image_data + i] = 0xF3F3F3;
40
	}
41
}
42
 
43
 
44
void main()
45
{
46
	int id, key;
47
	mem_Init();
48
	if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
49
	if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
5151 leency 50
	if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
4870 leency 51
	skin.Load();
52
 
53
	loop()
54
   {
55
      switch(WaitEvent())
56
      {
57
         case evButton:
58
            id=GetButtonID();
59
            if (id==1) ExitProcess();
5151 leency 60
            if (id>=100)
61
            {
62
            	run_id = id - 100;
63
            	enum_i = 0;
64
            	ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #run_game);
65
            }
4870 leency 66
			break;
67
 
68
        case evKey:
69
			key = GetKey();
70
			break;
71
 
72
         case evReDraw:
73
			sc.get();
74
			DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," ");
75
			GetProcessInfo(#Form, SelfInfo);
76
			if (Form.status_window>2) break;
77
			draw_window();
78
			break;
79
      }
80
   }
81
}
82
 
5151 leency 83
byte run_game(dword key_value, key_name, sec_name, f_name)
84
{
85
	if (run_id==enum_i)
86
	{
87
		ESBYTE[key_value + strchr(key_value, ',') - 1] = 0;
88
		RunProgram(key_value, '');
89
		return 0;
90
	}
91
	enum_i++;
92
	return 1;
93
}
4870 leency 94
 
5151 leency 95
 
96
int col_max, col_w, col_h, y;
97
int row, col;
98
 
99
byte key_process(dword key_value, key_name, sec_name, f_name)
100
{
101
	int tmp;
102
	int icon_n;
103
 
104
 
105
	if (col==col_max) {
106
		row++;
107
		col=0;
108
	}
109
	DefineButton(col*col_w+6,row*col_h+y,col_w,col_h-10,row*col_max+col+100+BT_HIDE,0);
110
	tmp = col_w/2;
111
	icon_n = atoi(key_value + strchr(key_value, ','));
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);
115
	col++;
116
	return 1;
117
}
118
 
4870 leency 119
void draw_window()
120
{
5151 leency 121
	y = 25;
4870 leency 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");
5151 leency 126
	y += 2;
127
	col_max=8;
128
	col_w=68;
129
	col_h=70;
130
	col = row = 0;
4870 leency 131
 
5151 leency 132
	ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #key_process);
4870 leency 133
}
134
 
135
 
136
 
137
stop: