Rev 9455 | Rev 9601 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 9455 | Rev 9594 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #define MEMSIZE 1024*20 |
1 | #define MEMSIZE 1024*20 |
2 | #define ENTRY_POINT #main |
2 | #define ENTRY_POINT #main |
Line -... | Line 3... | ||
- | 3 | ||
- | 4 | //===================================================// |
|
- | 5 | // // |
|
- | 6 | // LIB // |
|
- | 7 | // // |
|
- | 8 | //===================================================// |
|
3 | 9 | ||
4 | #include "../lib/fs.h" |
10 | #include "../lib/fs.h" |
5 | #include "../lib/mem.h" |
11 | #include "../lib/mem.h" |
6 | #include "../lib/obj/libimg.h" |
12 | #include "../lib/obj/libimg.h" |
- | 13 | #include "../lib/patterns/rgb.h" |
|
- | 14 | #include "../lib/patterns/restart_process.h" |
|
- | 15 | #include "../lib/patterns/toolbar_button.h" |
|
- | 16 | ||
- | 17 | //===================================================// |
|
- | 18 | // // |
|
- | 19 | // GLOBAL VARS // |
|
- | 20 | // // |
|
- | 21 | //===================================================// |
|
- | 22 | ||
- | 23 | libimg_image icons32; |
|
- | 24 | libimg_image icons16; |
|
- | 25 | libimg_image icons16w; |
|
- | 26 | unsigned int size32; |
|
- | 27 | unsigned int size16; |
|
- | 28 | ||
- | 29 | //===================================================// |
|
- | 30 | // // |
|
- | 31 | // MAIN // |
|
- | 32 | // // |
|
- | 33 | //===================================================// |
|
- | 34 | ||
- | 35 | void main() |
|
- | 36 | { |
|
- | 37 | mem_init(); |
|
- | 38 | load_dll(libimg, #libimg_init, 1); |
|
- | 39 | ||
- | 40 | icons32.load("/SYS/ICONS32.PNG"); size32 = icons32.h * 32 * 4; |
|
- | 41 | icons16.load("/SYS/ICONS16.PNG"); size16 = icons16.h * 18 * 4; |
|
- | 42 | ||
- | 43 | if (GetProcessesCount("@RESHARE")>1) { |
|
- | 44 | start_ui(); |
|
- | 45 | } else { |
|
- | 46 | start_daemon(); |
|
- | 47 | } |
|
- | 48 | } |
|
- | 49 | ||
- | 50 | //===================================================// |
|
- | 51 | // // |
|
- | 52 | // DAEMON // |
|
- | 53 | // // |
|
- | 54 | //===================================================// |
|
- | 55 | ||
- | 56 | void start_daemon() |
|
- | 57 | { |
|
- | 58 | char* shared_i32; |
|
- | 59 | char* shared_i16; |
|
- | 60 | char* shared_i16w; |
|
- | 61 | char* shared_chbox; |
|
- | 62 | ||
- | 63 | shared_chbox = memopen("CHECKBOX", 507, SHM_CREATE+SHM_WRITE); |
|
- | 64 | memmov(shared_chbox, #checkbox_flag, 507); |
|
- | 65 | ||
- | 66 | shared_i32 = memopen("ICONS32", size32, SHM_CREATE+SHM_WRITE); |
|
- | 67 | memmov(shared_i32, icons32.imgsrc, size32); |
|
- | 68 | img_destroy stdcall(icons32.image); |
|
- | 69 | ||
- | 70 | shared_i16 = memopen("ICONS18", size16, SHM_CREATE + SHM_WRITE); |
|
- | 71 | memmov(shared_i16, icons16.imgsrc, size16); |
|
- | 72 | //img_destroy stdcall(icons16.image); |
|
- | 73 | ||
- | 74 | shared_i16w = memopen("ICONS18W", size16, SHM_CREATE + SHM_WRITE); |
|
- | 75 | ||
- | 76 | @SetEventMask(EVM_DESKTOPBG); |
|
- | 77 | do { |
|
- | 78 | $push sc.work |
|
- | 79 | sc.get(); |
|
- | 80 | $pop eax |
|
- | 81 | if (sc.work != EAX) { |
|
- | 82 | memmov(shared_i16w, icons16.imgsrc, size16); |
|
- | 83 | replace_2cols(shared_i16w, size16, 0xffFFFfff, sc.work, 0xffCACBD6, sc.work_dark); |
|
- | 84 | } |
|
- | 85 | } while(WaitEvent()==evDesktop); |
|
- | 86 | } |
|
- | 87 | ||
- | 88 | //===================================================// |
|
- | 89 | // // |
|
- | 90 | // UI // |
|
- | 91 | // // |
|
- | 92 | //===================================================// |
|
- | 93 | ||
- | 94 | #define WINW 775 |
|
- | 95 | #define WINH 660 |
|
- | 96 | #define PAD 10 |
|
- | 97 | #define BTNW 100 |
|
- | 98 | #define BTNH 24 |
|
- | 99 | #define RESY PAD+30+BTNH+BTNH |
|
- | 100 | ||
- | 101 | enum { ACTIVE_ICONS32=1, ACTIVE_ICONS16=2, ACTIVE_ICONS16W=4, ACTIVE_CHECKBOX=8 }; |
|
- | 102 | int active_tab = ACTIVE_ICONS32; |
|
- | 103 | ||
- | 104 | void start_ui() |
|
- | 105 | { |
|
- | 106 | loop() switch(WaitEvent()) |
|
- | 107 | { |
|
- | 108 | case evKey: |
|
- | 109 | @GetKeyScancode(); |
|
- | 110 | if (AL == SCAN_CODE_ESC) ExitProcess(); |
|
- | 111 | if (AL == SCAN_CODE_TAB) { |
|
- | 112 | active_tab <<= 1; |
|
- | 113 | if (active_tab > ACTIVE_CHECKBOX) active_tab = 1; |
|
- | 114 | draw_tabs(); |
|
- | 115 | } |
|
- | 116 | break; |
|
- | 117 | ||
- | 118 | case evButton: |
|
- | 119 | GetButtonID(); |
|
- | 120 | if (1==EAX) { |
|
- | 121 | ExitProcess(); |
|
- | 122 | } else { |
|
- | 123 | active_tab = EAX - 10; |
|
- | 124 | draw_tabs(); |
|
- | 125 | } |
|
- | 126 | break; |
|
- | 127 | ||
- | 128 | case evReDraw: |
|
- | 129 | sc.get(); |
|
- | 130 | DefineAndDrawWindow(80, 50, WINW+9, WINH+4+GetSkinHeight(), 0x74, 0, "@RESHARE - A service that provides shared resorces", 0); |
|
- | 131 | DrawBar(0, 0, WINW, RESY-PAD-1, sc.work); //top bg |
|
- | 132 | DrawBar(0, RESY-PAD-1, WINW, 1, sc.work_graph); |
|
- | 133 | WriteText(PAD, PAD, 0x90, sc.work_text, "Each tab name corresponds to memory name that can be accessed by sysfunc 68.22. Now availabe:"); |
|
- | 134 | draw_tabs(); |
|
- | 135 | } |
|
- | 136 | } |
|
- | 137 | ||
- | 138 | void DrawFlatButton(dword _x, _y, _text, _id, _active) |
|
- | 139 | { |
|
- | 140 | if (_active) EDX = sc.button; else EDX = sc.work_light; |
|
- | 141 | DrawBar(_x, _y, BTNW, BTNH+1, EDX); |
|
- | 142 | ||
- | 143 | if (_active) EDX = sc.button_text; else EDX = sc.work_text; |
|
- | 144 | WriteText(-strlen(_text)*8+BTNW/2+_x, _y+6, 0x90, EDX, _text); |
|
- | 145 | ||
- | 146 | PutPixel(_x,_y,sc.work); |
|
- | 147 | PutPixel(_x,_y+BTNH,EDX); |
|
- | 148 | PutPixel(_x+BTNW-1,_y,EDX); |
|
- | 149 | PutPixel(_x+BTNW-1,_y+BTNH,EDX); |
|
- | 150 | ||
- | 151 | DefineHiddenButton(_x, _y, BTNW-1, BTNH, _id); |
|
- | 152 | } |
|
- | 153 | ||
- | 154 | void draw_tabs() |
|
- | 155 | { |
|
- | 156 | #define TABX WINW-BTNW-PAD-BTNW-PAD-BTNW-PAD-BTNW/2 |
|
- | 157 | DrawFlatButton( TABX, PAD+30, "ICONS32", 10+ACTIVE_ICONS32, active_tab & ACTIVE_ICONS32); |
|
- | 158 | DrawFlatButton(PAD+BTNW*1+TABX, PAD+30, "ICONS16", 10+ACTIVE_ICONS16, active_tab & ACTIVE_ICONS16); |
|
- | 159 | DrawFlatButton(PAD+BTNW*2+TABX, PAD+30, "ICONS16W", 10+ACTIVE_ICONS16W, active_tab & ACTIVE_ICONS16W); |
|
- | 160 | DrawFlatButton(PAD+BTNW*3+TABX, PAD+30, "CHECKBOX", 10+ACTIVE_CHECKBOX, active_tab & ACTIVE_CHECKBOX); |
|
- | 161 | draw_tab_icons32(); |
|
- | 162 | } |
|
- | 163 | ||
- | 164 | void draw_tab_icons32() |
|
- | 165 | { |
|
- | 166 | int i; |
|
- | 167 | int x=PAD, y; |
|
- | 168 | int iconimg; |
|
- | 169 | int iconh; |
|
- | 170 | int iconw; |
|
- | 171 | ||
- | 172 | DrawBar(0, RESY-PAD, WINW, WINH-RESY+PAD, sc.work); |
|
- | 173 | if (active_tab & ACTIVE_ICONS32) { |
|
- | 174 | iconimg = icons32.imgsrc; |
|
- | 175 | iconw = 32; |
|
- | 176 | iconh = icons32.h; |
|
- | 177 | } else if (active_tab & ACTIVE_ICONS16) { |
|
- | 178 | iconimg = icons16.imgsrc; |
|
- | 179 | iconw = 18; |
|
- | 180 | iconh = icons16.h; |
|
- | 181 | } else if (active_tab & ACTIVE_ICONS16W) { |
|
- | 182 | iconimg = memopen("ICONS18W", NULL, SHM_READ); |
|
- | 183 | iconw = 18; |
|
- | 184 | iconh = icons16.h; |
|
- | 185 | } else { |
|
- | 186 | _PutImage(WINW-13/2, WINH-RESY-13/2+RESY, 13, 13, #checkbox_flag); |
|
- | 187 | return; |
|
- | 188 | } |
|
- | 189 | ||
- | 190 | for (i = 0; i < iconh/iconw; i++) |
|
- | 191 | { |
|
- | 192 | PutPaletteImage(iconw*iconw*4*i + iconimg, iconw, iconw, 50-iconw/2+x, y+RESY, 32, 0); |
|
- | 193 | WriteText(-strlen(itoa(i))*8+50/2+x, y+RESY+iconw+5, 0x90, sc.work_graph, itoa(i)); |
|
- | 194 | x += 50; |
|
- | 195 | if (x + 50 > WINW) { |
|
- | 196 | x = PAD; |
|
- | 197 | y += iconw + 30; |
|
- | 198 | } |
|
- | 199 | } |
|
- | 200 | } |
|
- | 201 | ||
- | 202 | //===================================================// |
|
- | 203 | // // |
|
- | 204 | // DATA // |
|
- | 205 | // // |
|
Line 7... | Line 206... | ||
7 | #include "../lib/patterns/rgb.h" |
206 | //===================================================// |
8 | 207 | ||
9 | :unsigned char checkbox_flag[507] = { |
208 | :unsigned char checkbox_flag[507] = { |
10 | 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, |
209 | 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, |
Line 38... | Line 237... | ||
38 | 0x9F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, |
237 | 0x9F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, |
39 | 0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, |
238 | 0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, |
40 | 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, |
239 | 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, |
41 | 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04 |
240 | 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04 |
42 | }; |
241 | };>=><=> |
43 | - | ||
44 | void main() |
- | |
45 | { |
- | |
46 | libimg_image icons32; |
- | |
47 | libimg_image icons16; |
- | |
48 | libimg_image icons16w; |
- | |
49 | unsigned int size32; |
- | |
50 | unsigned int size16; |
- | |
51 | char* shared_i32; |
- | |
52 | char* shared_i16; |
- | |
53 | char* shared_i16w; |
- | |
54 | char* shared_chbox; |
- | |
55 | - | ||
56 | mem_init(); |
- | |
57 | load_dll(libimg, #libimg_init, 1); |
- | |
58 | @SetEventMask(EVM_DESKTOPBG); |
- | |
59 | - | ||
60 | shared_chbox = memopen("CHECKBOX", sizeof(checkbox_flag), SHM_CREATE+SHM_WRITE); |
- | |
61 | memmov(shared_chbox, #checkbox_flag, sizeof(checkbox_flag)); |
- | |
62 | - | ||
63 | icons32.load("/sys/icons32.png"); size32 = icons32.h * 32 * 4; |
- | |
64 | icons16.load("/sys/icons16.png"); size16 = icons16.h * 18 * 4; |
- | |
65 | - | ||
66 | shared_i32 = memopen("ICONS32", size32, SHM_CREATE+SHM_WRITE); |
- | |
67 | memmov(shared_i32, icons32.imgsrc, size32); |
- | |
68 | img_destroy stdcall(icons32.image); |
- | |
69 | - | ||
70 | shared_i16 = memopen("ICONS18", size16, SHM_CREATE + SHM_WRITE); |
- | |
71 | memmov(shared_i16, icons16.imgsrc, size16); |
- | |
72 | img_destroy stdcall(icons16.image); |
- | |
73 | - | ||
74 | shared_i16w = memopen("ICONS18W", size16, SHM_CREATE + SHM_WRITE); |
- | |
75 | - | ||
76 | UPDATE_ICONS18WORK: |
- | |
77 | $push sc.work |
- | |
78 | sc.get(); |
- | |
79 | $pop eax |
- | |
80 | if (sc.work != EAX) { |
- | |
81 | icons16w.load("/sys/icons16.png"); |
- | |
82 | icons16w.replace_2colors(0xffFFFfff, sc.work, 0xffCACBD6, MixColors(sc.work, 0, 200)); |
- | |
83 | memmov(shared_i16w, icons16w.imgsrc, size16); |
- | |
84 | img_destroy stdcall(icons16w.image); |
- | |
85 | icons16w.image = NULL; |
- | |
86 | } |
- | |
87 | - | ||
88 | loop() IF(WaitEvent()==evDesktop) GOTO UPDATE_ICONS18WORK; |
- | |
89 | } |
- | |
90 | - |