Subversion Repositories Kolibri OS

Rev

Rev 9598 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9598 Rev 9602
1
#define MEMSIZE 1024*40
1
#define MEMSIZE 1024*40
2
#include "..\lib\strings.h" 
2
#include "..\lib\strings.h" 
3
#include "..\lib\mem.h" 
3
#include "..\lib\mem.h" 
4
#include "..\lib\gui.h"
4
#include "..\lib\gui.h"
5
#include "..\lib\obj\proc_lib.h"
5
#include "..\lib\obj\proc_lib.h"
6
#include "..\lib\patterns\simple_open_dialog.h"
6
#include "..\lib\patterns\simple_open_dialog.h"
7
#include "..\lib\patterns\restart_process.h"
7
#include "..\lib\patterns\restart_process.h"
8
#include "added_sysdir.c"
8
#include "added_sysdir.c"
9
 
9
 
10
//===================================================//
10
//===================================================//
11
//                                                   //
11
//                                                   //
12
//                       DATA                        //
12
//                       DATA                        //
13
//                                                   //
13
//                                                   //
14
//===================================================//
14
//===================================================//
15
 
15
 
16
#define WINW 570
16
#define WINW 570
17
#define WINH 300
17
#define WINH 300
18
#define CONX 30 //content X pos
18
#define CONX 30 //content X pos
19
#define SCRX WINW-180
19
#define SCRX WINW-180
20
#define SCRY 20
20
#define SCRY 20
21
 
21
 
22
char default_dir[] = "/sys";
22
char default_dir[] = "/sys";
23
od_filter filter2;
23
od_filter filter2;
24
 
24
 
25
#define BTN_MANUAL_SEARCH 10
25
#define BTN_MANUAL_SEARCH 10
26
#define BTN_OPEN_ANYWAY 11
26
#define BTN_OPEN_ANYWAY 11
27
 
27
 
28
#define APP_PLUS_INI_PATH "/sys/settings/app_plus.ini"
28
#define APP_PLUS_INI_PATH "/sys/settings/app_plus.ini"
29
 
29
 
30
//===================================================//
30
//===================================================//
31
//                                                   //
31
//                                                   //
32
//                   TRANSLATIONS                    //
32
//                   TRANSLATIONS                    //
33
//                                                   //
33
//                                                   //
34
//===================================================//
34
//===================================================//
35
 
35
 
36
#ifdef LANG_RUS
36
#ifdef LANG_RUS
37
?define WINDOW_TITLE_TEXT "‚­¨¬ ­¨¥! â® ¢ ¦­®."
37
?define WINDOW_TITLE_TEXT "‚­¨¬ ­¨¥! â® ¢ ¦­®."
38
?define CONTENT_HEADER_TEXT "€Š€ /KOLIBRIOS/ … €‰„…€"
38
?define CONTENT_HEADER_TEXT "€Š€ /KOLIBRIOS/ … €‰„…€"
39
?define DESCRIPTION_TEXT "®¯à®¡ã©â¥ ­ ©â¨ ¥¥ á ¬®áâ®ï⥫쭮.
39
?define DESCRIPTION_TEXT "®¯à®¡ã©â¥ ­ ©â¨ ¥¥ á ¬®áâ®ï⥫쭮.
40
‘®¤¥à¦¨¬®¥ ¨áª®¬®© ¯ ¯ª¨ ¯®ª § ­® ­  
40
‘®¤¥à¦¨¬®¥ ¨áª®¬®© ¯ ¯ª¨ ¯®ª § ­® ­  
41
ª à⨭ª¥ á¯à ¢ . ‚ á«ãç ¥ ­¥¢¥à­® 
41
ª à⨭ª¥ á¯à ¢ . ‚ á«ãç ¥ ­¥¢¥à­® 
42
¢ë¡à ­­®© ¯ ¯ª¨ âॡã¥âáï ¢ë¯®«­¨âì 
42
¢ë¡à ­­®© ¯ ¯ª¨ âॡã¥âáï ¢ë¯®«­¨âì 
43
¯¥à¥§ £à㧪㠏Š ¨ ¯®¯à®¡®¢ âì á­®¢ ."
43
¯¥à¥§ £à㧪㠏Š ¨ ¯®¯à®¡®¢ âì á­®¢ ."
44
?define MANUALLY_BUTTON_TEXT "“ª § âì ¯ ¯ªã /kolibrios/..."
44
?define MANUALLY_BUTTON_TEXT "“ª § âì ¯ ¯ªã /kolibrios/..."
45
?define OPEN_ANYWAY_BUTTON_TEXT "‡ ¯ãáâ¨âì APP+ (­¥ª®â®àë¥ ¯à®£à ¬¬ë ¡ã¤ãâ ­¥¤®áâ㯭ë)"
45
?define OPEN_ANYWAY_BUTTON_TEXT "‡ ¯ãáâ¨âì APP+ (­¥ª®â®àë¥ ¯à®£à ¬¬ë ¡ã¤ãâ ­¥¤®áâ㯭ë)"
46
#else
46
#else
47
?define WINDOW_TITLE_TEXT "Warning! It's important."
47
?define WINDOW_TITLE_TEXT "Warning! It's important."
48
?define CONTENT_HEADER_TEXT "/KOLIBRIOS/ IS NOT MOUNTED"
48
?define CONTENT_HEADER_TEXT "/KOLIBRIOS/ IS NOT MOUNTED"
49
?define DESCRIPTION_TEXT "Try to find it manually. It should look
49
?define DESCRIPTION_TEXT "Try to find it manually. It should look
50
like image on the right.
50
like image on the right.
51
Note: this action can be done only once 
51
Note: this action can be done only once 
52
per 1 session of the OS running. If you 
52
per 1 session of the OS running. If you 
53
will choose the wrong folder then you 
53
will choose the wrong folder then you 
54
need to reboot a system to try again."
54
need to reboot a system to try again."
55
?define MANUALLY_BUTTON_TEXT "Choose /kolibrios/ folder..."
55
?define MANUALLY_BUTTON_TEXT "Choose /kolibrios/ folder..."
56
?define OPEN_ANYWAY_BUTTON_TEXT "Open APP+ anyway (some programs won't be available)  "
56
?define OPEN_ANYWAY_BUTTON_TEXT "Open APP+ anyway (some programs won't be available)  "
57
#endif
57
#endif
58
 
58
 
59
char kolibrios_dirs[] = "..\0     3D     \0demos  \0develop\0drivers\0emul   \0games  \0grafx2";
59
char kolibrios_dirs[] = "..\0     3D     \0demos  \0develop\0drivers\0emul   \0games  \0grafx2";
60
 
60
 
61
//===================================================//
61
//===================================================//
62
//                                                   //
62
//                                                   //
63
//                       CODE                        //
63
//                       CODE                        //
64
//                                                   //
64
//                                                   //
65
//===================================================//
65
//===================================================//
66
 
66
 
67
void main()
67
void main()
68
{
68
{
69
	if (param) {
69
	if (param) {
70
		SetAdditionalSystemDirectory("kolibrios", #param+1);
70
		SetAdditionalSystemDirectory("kolibrios", #param+1);
71
		ExitProcess();
71
		ExitProcess();
72
	}
72
	}
73
 
73
 
74
	WaitAutosearch();
74
	WaitAutosearch();
75
	CheckKosMounted();
75
	CheckKosMounted();
76
 
76
 
77
	o_dialog.type = 2;
77
	o_dialog.type = 2;
78
	#define NO_DLL_INIT
78
	#define NO_DLL_INIT
79
	load_dll(Proc_lib, #OpenDialog_init,0);
79
	load_dll(Proc_lib, #OpenDialog_init,0);
80
	OpenDialog_init stdcall (#o_dialog);
80
	OpenDialog_init stdcall (#o_dialog);
81
	active_button_id = BTN_MANUAL_SEARCH;
81
	active_button_id = BTN_MANUAL_SEARCH;
82
 
82
 
83
	loop() switch(@WaitEvent())
83
	loop() switch(@WaitEvent())
84
	{	
84
	{	
85
		case evButton:
85
		case evButton:
86
			EventButton(GetButtonID());
86
			EventButton(GetButtonID());
87
			break;
87
			break;
88
		case evKey:
88
		case evKey:
89
			@GetKeyScancode();
89
			@GetKeyScancode();
90
			if (AL == SCAN_CODE_ENTER) {
90
			if (AL == SCAN_CODE_ENTER) {
91
				EventButton(active_button_id);
91
				EventButton(active_button_id);
92
			} else if (AL == SCAN_CODE_TAB) {
92
			} else if (AL == SCAN_CODE_TAB) {
93
				active_button_id = active_button_id-10^1 + 10;
93
				active_button_id = active_button_id-10^1 + 10;
94
				DrawButtons();
94
				DrawButtons();
95
			}
95
			}
96
			break;
96
			break;
97
		 
97
		 
98
		case evReDraw:
98
		case evReDraw:
99
			draw_window();
99
			draw_window();
100
	}
100
	}
101
}
101
}
102
 
102
 
103
void draw_window()
103
void draw_window()
104
{
104
{
105
	sc.get();
105
	sc.get();
106
	DefineAndDrawWindow(screen.w-WINW/2, 100, WINW, WINH+skin_h, 0x34, sc.work, WINDOW_TITLE_TEXT,0);
106
	DefineAndDrawWindow(screen.w-WINW/2, 100, WINW, WINH+skin_h, 0x34, sc.work, WINDOW_TITLE_TEXT,0);
107
	WriteTextB(CONX+2,SCRY+2,0x81,MixColors(sc.work, 0xB92234,220),CONTENT_HEADER_TEXT);
107
	WriteTextB(CONX+2,SCRY+2,0x81,MixColors(sc.work, 0xB92234,220),CONTENT_HEADER_TEXT);
108
	WriteTextB(CONX,SCRY,0x81,0xB92234,CONTENT_HEADER_TEXT);
108
	WriteTextB(CONX,SCRY,0x81,0xB92234,CONTENT_HEADER_TEXT);
109
	draw_screen();
109
	draw_screen();
110
	WriteTextLines(CONX,SCRY+50,0x90,sc.work_text,DESCRIPTION_TEXT,20);
110
	WriteTextLines(CONX,SCRY+50,0x90,sc.work_text,DESCRIPTION_TEXT,20);
111
	DrawButtons();	
111
	DrawButtons();	
112
}
112
}
113
 
113
 
114
void draw_screen()
114
void draw_screen()
115
{
115
{
116
	char i;
116
	char i;
117
	int icon_n=1;
117
	int icon_n=1;
118
	DrawRectangle(WINW-180-1,SCRY-1, 145+1,170+1, sc.work_graph);
118
	DrawRectangle(WINW-180-1,SCRY-1, 145+1,170+1, sc.line);
119
	DrawBar(SCRX,SCRY,145,170,0xFFFfff);
119
	DrawBar(SCRX,SCRY,145,170,0xFFFfff);
120
	DrawBar(SCRX+25,SCRY+5,144-25,20,0xBBDDFF);
120
	DrawBar(SCRX+25,SCRY+5,144-25,20,0xBBDDFF);
121
	for (i=0; i<8; i++) {
121
	for (i=0; i<8; i++) {
122
		draw_icon_16(SCRX+5, i*20+SCRY+5, icon_n);
122
		draw_icon_16(SCRX+5, i*20+SCRY+5, icon_n);
123
		WriteText(SCRX+27, i*20+SCRY+11, 0x80, 0, i*8 + #kolibrios_dirs);
123
		WriteText(SCRX+27, i*20+SCRY+11, 0x80, 0, i*8 + #kolibrios_dirs);
124
		icon_n = 0;
124
		icon_n = 0;
125
	}
125
	}
126
}
126
}
127
 
127
 
128
void DrawButtons()
128
void DrawButtons()
129
{
129
{
130
	DrawStandartCaptButton(CONX, WINH-80, BTN_MANUAL_SEARCH, MANUALLY_BUTTON_TEXT);
130
	DrawStandartCaptButton(CONX, WINH-80, BTN_MANUAL_SEARCH, MANUALLY_BUTTON_TEXT);
131
	DrawStandartCaptButton(CONX, WINH-42, BTN_OPEN_ANYWAY, OPEN_ANYWAY_BUTTON_TEXT);
131
	DrawStandartCaptButton(CONX, WINH-42, BTN_OPEN_ANYWAY, OPEN_ANYWAY_BUTTON_TEXT);
132
	//DrawCaptButton(CONX, WINH-80, 300, 25, BTN_MANUAL_SEARCH, sc.button, sc.button_text, MANUALLY_BUTTON_TEXT);
132
	//DrawCaptButton(CONX, WINH-80, 300, 25, BTN_MANUAL_SEARCH, sc.button, sc.button_text, MANUALLY_BUTTON_TEXT);
133
	//DrawCaptButton(CONX, WINH-42, 500, 25, BTN_OPEN_ANYWAY, sc.button, sc.button_text, OPEN_ANYWAY_BUTTON_TEXT);
133
	//DrawCaptButton(CONX, WINH-42, 500, 25, BTN_OPEN_ANYWAY, sc.button, sc.button_text, OPEN_ANYWAY_BUTTON_TEXT);
134
}
134
}
135
 
135
 
136
void CheckKosMounted()
136
void CheckKosMounted()
137
{
137
{
138
	if (dir_exists("/kolibrios")) 
138
	if (dir_exists("/kolibrios")) 
139
	{
139
	{
140
		if (file_exists(APP_PLUS_INI_PATH))	EventOpenApp();
140
		if (file_exists(APP_PLUS_INI_PATH))	EventOpenApp();
141
		ExitProcess();
141
		ExitProcess();
142
	}
142
	}
143
}
143
}
144
 
144
 
145
void WaitAutosearch()
145
void WaitAutosearch()
146
{
146
{
147
	while (CheckProcessExists("SEARCHAP")) pause(2);
147
	while (CheckProcessExists("SEARCHAP")) pause(2);
148
}
148
}
149
 
149
 
150
//===================================================//
150
//===================================================//
151
//                                                   //
151
//                                                   //
152
//                      EVENTS                       //
152
//                      EVENTS                       //
153
//                                                   //
153
//                                                   //
154
//===================================================//
154
//===================================================//
155
 
155
 
156
void EventManualSearch()
156
void EventManualSearch()
157
{
157
{
158
	OpenDialog_start stdcall (#o_dialog);
158
	OpenDialog_start stdcall (#o_dialog);
159
	if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1);
159
	if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1);
160
	pause(3);
160
	pause(3);
161
	CheckKosMounted();	
161
	CheckKosMounted();	
162
}
162
}
163
 
163
 
164
void EventOpenApp()
164
void EventOpenApp()
165
{
165
{
166
	if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
166
	if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
167
		notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
167
		notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
168
	}
168
	}
169
}
169
}
170
 
170
 
171
void EventButton(dword id)
171
void EventButton(dword id)
172
{
172
{
173
	if (id==CLOSE_BTN) ExitProcess();
173
	if (id==CLOSE_BTN) ExitProcess();
174
	else if (id==BTN_MANUAL_SEARCH) EventManualSearch();
174
	else if (id==BTN_MANUAL_SEARCH) EventManualSearch();
175
	else if (id==BTN_OPEN_ANYWAY) { EventOpenApp(); ExitProcess(); }
175
	else if (id==BTN_OPEN_ANYWAY) { EventOpenApp(); ExitProcess(); }
176
}
176
}
177
 
177
 
178
 
178
 
179
stop:
179
stop: