Rev 3067 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3067 | leency | 1 | #include "..\lib\kolibri.h" |
2 | #include "..\lib\figures.h" |
||
3 | #include "..\lib\strings.h" |
||
4 | #include "..\lib\random.h" |
||
5 | #include "..\lib\mem.h" |
||
6 | #include "..\lib\file_system.h" |
||
7 | |||
8 | #ifndef ru |
||
9 | char *BUTTONS_CAPTIONS[]={ |
||
10 | "Перезагрузка [Enter]"w, 13, |
||
11 | "Выключение [End]"w, 181, |
||
12 | "Ядро [Home]"w, 180, |
||
13 | "Отмена [Esc]"w, 27, |
||
14 | 0}; |
||
15 | #else |
||
16 | char *BUTTONS_CAPTIONS[]={ |
||
17 | " Reboot [Enter]",13, |
||
18 | " Power off [End]",181, |
||
19 | " Kernel [Home]",180, |
||
20 | " Close [Esc]",27, |
||
21 | 0}; |
||
22 | #endif |
||
23 | |||
24 | system_colors sc; |
||
25 | |||
26 | unsigned char moon[6*6] = FROM "moon.raw"; |
||
27 | |||
28 | int WIN_SIZE_X, WIN_SIZE_Y; |
||
29 | int PANEL_X, PANEL_Y; |
||
30 | |||
31 | #define NIGHT_PALEL_HEIGHT 45 |
||
32 | #define STARS_COUNT 30 |
||
33 | |||
34 | #define PANEL_SIZE_X 260 |
||
35 | #define PANEL_SIZE_Y 165 |
||
36 | |||
37 | dword stars_col[4]={0xD2CF19, 0x716900, 0x002041}; //0x005BFF - голубой, редко |
||
38 | |||
39 | |||
40 | |||
41 | |||
42 | void main() |
||
43 | { |
||
44 | int key; |
||
45 | |||
3107 | leency | 46 | pause(10); |
3067 | leency | 47 | |
48 | WIN_SIZE_X=GetScreenWidth()+1; |
||
49 | WIN_SIZE_Y=GetScreenHeight()+1; |
||
50 | |||
51 | PANEL_X=WIN_SIZE_X-PANEL_SIZE_X/2; |
||
52 | PANEL_Y=WIN_SIZE_Y-PANEL_SIZE_Y/2; |
||
53 | |||
54 | loop() |
||
55 | { |
||
56 | WaitEventTimeout(130); |
||
57 | switch(EAX & 0xFF) |
||
58 | { |
||
59 | case evButton: |
||
60 | key=GetButtonID(); |
||
61 | if (key==1) ExitProcess(); |
||
62 | GOTO _BUTTON_MARK; |
||
63 | |||
64 | case evKey: |
||
65 | key = GetKey(); |
||
66 | _BUTTON_MARK: |
||
67 | if (key== 13) ExitSystem(REBOOT); //ENTER |
||
68 | if (key==180) ExitSystem(KERNEL); //HOME |
||
69 | if (key==181) ExitSystem(TURN_OFF); //END |
||
70 | if (key== 27) ExitProcess(); //ESC |
||
71 | if (key== 19) //CTRL+S |
||
72 | { |
||
73 | RunProgram("rdsave",0); |
||
74 | ExitProcess(); |
||
75 | } |
||
76 | break; |
||
77 | |||
78 | case evReDraw: |
||
79 | draw_window(); |
||
80 | break; |
||
81 | default: |
||
82 | draw_stars(); |
||
83 | } |
||
84 | } |
||
85 | } |
||
86 | |||
87 | |||
88 | |||
89 | void draw_window() |
||
90 | { |
||
91 | int x, y; |
||
92 | sc.get(); |
||
93 | |||
94 | DefineAndDrawWindow(0,0,WIN_SIZE_X, WIN_SIZE_Y, 0x01, 0, 0, 0x01fffFFF); |
||
95 | |||
96 | draw_main_area(PANEL_X, PANEL_Y, PANEL_SIZE_X, PANEL_SIZE_Y); |
||
97 | |||
98 | //draw grid |
||
99 | for (y=0; y |
||
100 | { |
||
101 | for (x=0; x |
||
102 | { |
||
103 | if (y>PANEL_Y) && (y |
||
104 | if (! y&1) && (! x&1) {PutPixel(x, y, 0); continue;} |
||
105 | if ( y&1) && ( x&1) PutPixel(x, y, 0); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | |||
110 | |||
111 | |||
112 | void draw_main_area() |
||
113 | { |
||
114 | int i=0; |
||
115 | |||
116 | DrawRectangle(PANEL_X, PANEL_Y, PANEL_SIZE_X, PANEL_SIZE_Y, 0); |
||
117 | DrawBar(PANEL_X+1, PANEL_Y+NIGHT_PALEL_HEIGHT+1, PANEL_SIZE_X-1, PANEL_SIZE_Y-NIGHT_PALEL_HEIGHT-1, sc.work); |
||
118 | |||
119 | for (i=0; i<4; i++) |
||
120 | { |
||
121 | DefineButton(PANEL_X+33, i*23 + PANEL_Y+NIGHT_PALEL_HEIGHT+16, 190,19, BUTTONS_CAPTIONS[i*2+1],sc.work_button); |
||
3107 | leency | 122 | WriteText(PANEL_X+59, i*23 + PANEL_Y+NIGHT_PALEL_HEIGHT+22, 0x80,sc.work_button_text, BUTTONS_CAPTIONS[i*2]); |
3067 | leency | 123 | } |
124 | |||
125 | draw_stars(); |
||
126 | } |
||
127 | |||
128 | void draw_stars() |
||
129 | { |
||
130 | |||
131 | int i, x_pic, y_pic, col; |
||
132 | |||
133 | DrawBar(PANEL_X+1, PANEL_Y+1, PANEL_SIZE_X-1, NIGHT_PALEL_HEIGHT, 0x002041); |
||
134 | |||
135 | for (i=0; i |
||
136 | { |
||
137 | x_pic = random(PANEL_SIZE_X-1); |
||
138 | y_pic = random(NIGHT_PALEL_HEIGHT-1); |
||
139 | col = random(3); |
||
140 | PutPixel(PANEL_X+1 +x_pic, PANEL_Y+1 +y_pic, stars_col[col]); |
||
141 | } |
||
142 | /*for (i=0; i<3; i++) |
||
143 | { |
||
144 | x_pic = random(PANEL_SIZE_X-8)+4; |
||
145 | y_pic = random(NIGHT_PALEL_HEIGHT-8)+4; |
||
146 | |||
147 | PutPixel(PANEL_X +x_pic, PANEL_Y +y_pic, stars_col[0]); |
||
148 | PutPixel(PANEL_X+1 +x_pic, PANEL_Y +y_pic, stars_col[1]); |
||
149 | PutPixel(PANEL_X-1 +x_pic, PANEL_Y +y_pic, stars_col[1]); |
||
150 | PutPixel(PANEL_X +x_pic, PANEL_Y +y_pic+1, stars_col[1]); |
||
151 | PutPixel(PANEL_X +x_pic, PANEL_Y +y_pic-1, stars_col[1]); |
||
152 | }*/ |
||
153 | |||
154 | PutImage(#moon,6,6, PANEL_X+PANEL_SIZE_X-60,PANEL_Y+10); |
||
155 | } |
||
156 | |||
157 | |||
158 | |||
159 | |||
160 | |||
161 | stop:3;>4;> |