Subversion Repositories Kolibri OS

Rev

Rev 9598 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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