Subversion Repositories Kolibri OS

Rev

Rev 8954 | Rev 9539 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #define MEMSIZE 4096*20
  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. proc_info Form;
  17. #define CONX 30 //content X pos
  18.  
  19. char default_dir[] = "/rd/1";
  20. od_filter filter2 = {"",0};
  21.  
  22. dword scr = FROM "scr.raw_8bit";
  23. dword scr_pal[] = {0xFFFFFF,0xBBDDFF,0x4166B5,0xE0E4E6,0xAFBEDD,0xC4D4E8,0x52ACDD,0x000000,
  24. 0xE9DAB2,0xC99811,0xFDF9D4,0xF8B93C,0xFDEEBE,0xFBEBA6,0xDFAF4F,0xF3D57C};
  25.  
  26. #define BTN_MANUAL_SEARCH 10
  27. #define BTN_OPEN_ANYWAY 11
  28.  
  29. #define APP_PLUS_INI_PATH "/sys/settings/app_plus.ini"
  30.  
  31. //===================================================//
  32. //                                                   //
  33. //                   TRANSLATIONS                    //
  34. //                                                   //
  35. //===================================================//
  36.  
  37. #ifdef LANG_RUS
  38. ?define WINDOW_TITLE_TEXT "‚­¨¬ ­¨¥! â® ¢ ¦­®."
  39. ?define CONTENT_HEADER_TEXT "€Š€ /KOLIBRIOS/ … €‰„…€"
  40. ?define DESCRIPTION_TEXT "®¯à®¡ã©â¥ ­ ©â¨ ¥¥ á ¬®áâ®ï⥫쭮.
  41. ‘®¤¥à¦¨¬®¥ ¨áª®¬®© ¯ ¯ª¨ ¯®ª § ­® ­ 
  42. ª à⨭ª¥ á¯à ¢ . ‚ á«ãç ¥ ­¥¢¥à­®
  43. ¢ë¡à ­­®© ¯ ¯ª¨ âॡã¥âáï ¢ë¯®«­¨âì
  44. ¯¥à¥§ £à㧪㠏Š ¨ ¯®¯à®¡®¢ âì á­®¢ ."
  45. ?define MANUALLY_BUTTON_TEXT " ©â¨ /kolibrios/..."
  46. ?define OPEN_ANYWAY_BUTTON_TEXT "‡ ¯ãáâ¨âì APP+ (­¥ª®â®àë¥ ¯à®£à ¬¬ë ¡ã¤ãâ ­¥¤®áâ㯭ë)"
  47. #else
  48. ?define WINDOW_TITLE_TEXT "Warning! It's important."
  49. ?define CONTENT_HEADER_TEXT "/KOLIBRIOS/ IS NOT MOUNTED"
  50. ?define DESCRIPTION_TEXT "Try to find it manually. It should look
  51. like image on the right.
  52. Note: this action can be done only once
  53. per 1 session of the OS running. If you
  54. will choose the wrong folder then you
  55. need to reboot system to try again."
  56. ?define MANUALLY_BUTTON_TEXT "Choose /kolibrios/ folder..."
  57. ?define OPEN_ANYWAY_BUTTON_TEXT "Open APP+ anyway (some apps will be unavailable)"
  58. #endif
  59.  
  60. //===================================================//
  61. //                                                   //
  62. //                       CODE                        //
  63. //                                                   //
  64. //===================================================//
  65.  
  66. void main()
  67. {
  68.         if (param) {
  69.                 SetAdditionalSystemDirectory("kolibrios", #param+1);
  70.                 ExitProcess();
  71.         }
  72.  
  73.         WaitAutosearch();
  74.         CheckKosMounted();
  75.  
  76.         o_dialog.type = 2;
  77.         #define NO_DLL_INIT
  78.         load_dll(Proc_lib, #OpenDialog_init,0);
  79.         OpenDialog_init stdcall (#o_dialog);
  80.         active_button_id = BTN_MANUAL_SEARCH;
  81.  
  82.         loop() switch(@WaitEvent())
  83.         {      
  84.                 case evButton:
  85.                         EventButton(GetButtonID());
  86.                         break;
  87.                 case evKey:
  88.                         @GetKeyScancode();
  89.                         if (AL == SCAN_CODE_ENTER) {
  90.                                 EventButton(active_button_id);
  91.                         } else if (AL == SCAN_CODE_TAB) {
  92.                                 active_button_id = active_button_id-10^1 + 10;
  93.                                 DrawButtons();
  94.                         }
  95.                         break;
  96.                  
  97.                 case evReDraw:
  98.                         draw_window();
  99.         }
  100. }
  101.  
  102. void draw_window()
  103. {
  104.         incn y;
  105.         sc.get();
  106.         DefineAndDrawWindow(screen.width-570/2, 100, 570, 300+skin_height, 0x34, sc.work, WINDOW_TITLE_TEXT,0);
  107.         GetProcessInfo(#Form, SelfInfo);
  108.         WriteTextB(CONX+2,y.set(20)+2,0x81,MixColors(sc.work, 0xB92234,220),CONTENT_HEADER_TEXT);
  109.         WriteTextB(CONX,y.n,0x81,0xB92234,CONTENT_HEADER_TEXT);
  110.        
  111.         PutPaletteImage(#scr,144,171,Form.cwidth-180,y.n,8,#scr_pal);
  112.         DrawRectangle(Form.cwidth-180-1,y.n-1, 144+1,171+1, sc.work_graph);
  113.  
  114.         WriteTextLines(CONX,y.inc(50),0x90,sc.work_text,DESCRIPTION_TEXT,20);
  115.  
  116.         DrawButtons(); 
  117. }
  118.  
  119. void DrawButtons()
  120. {
  121.         DrawStandartCaptButton(CONX, Form.cheight-80, BTN_MANUAL_SEARCH, MANUALLY_BUTTON_TEXT);
  122.         DrawStandartCaptButton(CONX, Form.cheight-42, BTN_OPEN_ANYWAY, OPEN_ANYWAY_BUTTON_TEXT);
  123. }
  124.  
  125. void CheckKosMounted()
  126. {
  127.         if (dir_exists("/kolibrios"))
  128.         {
  129.                 if (file_exists(APP_PLUS_INI_PATH))     EventOpenApp();
  130.                 ExitProcess();
  131.         }
  132. }
  133.  
  134. void WaitAutosearch()
  135. {
  136.         while (CheckProcessExists("SEARCHAP")) pause(2);
  137. }
  138.  
  139. //===================================================//
  140. //                                                   //
  141. //                      EVENTS                       //
  142. //                                                   //
  143. //===================================================//
  144.  
  145. void EventManualSearch()
  146. {
  147.         OpenDialog_start stdcall (#o_dialog);
  148.         if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1);
  149.         pause(3);
  150.         CheckKosMounted();     
  151. }
  152.  
  153. void EventOpenApp()
  154. {
  155.         if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
  156.                 notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
  157.         }
  158. }
  159.  
  160. void EventButton(dword id)
  161. {
  162.         if (id==CLOSE_BTN) ExitProcess();
  163.         else if (id==BTN_MANUAL_SEARCH) EventManualSearch();
  164.         else if (id==BTN_OPEN_ANYWAY) { EventOpenApp();  ExitProcess(); }
  165. }
  166.  
  167.  
  168. stop:
  169.