Subversion Repositories Kolibri OS

Rev

Rev 8509 | Rev 9453 | 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\io.h"
  5. #include "..\lib\gui.h"
  6. #include "..\lib\obj\proc_lib.h"
  7. #include "..\lib\patterns\simple_open_dialog.h"
  8. #include "..\lib\patterns\restart_process.h"
  9. #include "added_sysdir.c"
  10.  
  11. //===================================================//
  12. //                                                   //
  13. //                       DATA                        //
  14. //                                                   //
  15. //===================================================//
  16.  
  17. proc_info Form;
  18. #define CONX 30 //content X pos
  19.  
  20. char default_dir[] = "/rd/1";
  21. od_filter filter2 = {"",0};
  22.  
  23. dword scr = FROM "scr.raw_8bit";
  24. dword scr_pal[] = {0xFFFFFF,0xBBDDFF,0x4166B5,0xE0E4E6,0xAFBEDD,0xC4D4E8,0x52ACDD,0x000000,
  25. 0xE9DAB2,0xC99811,0xFDF9D4,0xF8B93C,0xFDEEBE,0xFBEBA6,0xDFAF4F,0xF3D57C};
  26.  
  27. #define BTN_MANUAL_SEARCH 10
  28. #define BTN_OPEN_ANYWAY 11
  29.  
  30. #define APP_PLUS_INI_PATH "/sys/settings/app_plus.ini"
  31.  
  32. //===================================================//
  33. //                                                   //
  34. //                   TRANSLATIONS                    //
  35. //                                                   //
  36. //===================================================//
  37.  
  38. #ifdef LANG_RUS
  39. ?define WINDOW_TITLE_TEXT "‚­¨¬ ­¨¥! â® ¢ ¦­®."
  40. ?define CONTENT_HEADER_TEXT "€Š€ /KOLIBRIOS/ … €‰„…€"
  41. ?define DESCRIPTION_TEXT "®¯à®¡ã©â¥ ­ ©â¨ ¥¥ á ¬®áâ®ï⥫쭮.
  42. ‘®¤¥à¦¨¬®¥ ¨áª®¬®© ¯ ¯ª¨ ¯®ª § ­® ­ 
  43. ª à⨭ª¥ á¯à ¢ . ‚ á«ãç ¥ ­¥¢¥à­®
  44. ¢ë¡à ­­®© ¯ ¯ª¨ âॡã¥âáï ¢ë¯®«­¨âì
  45. ¯¥à¥§ £à㧪㠏Š ¨ ¯®¯à®¡®¢ âì á­®¢ ."
  46. ?define MANUALLY_BUTTON_TEXT " ©â¨ /kolibrios/..."
  47. ?define OPEN_ANYWAY_BUTTON_TEXT "‡ ¯ãáâ¨âì APP+ (­¥ª®â®àë¥ ¯à®£à ¬¬ë ¡ã¤ãâ ­¥¤®áâ㯭ë)"
  48. #else
  49. ?define WINDOW_TITLE_TEXT "Warning! It's important."
  50. ?define CONTENT_HEADER_TEXT "/KOLIBRIOS/ IS NOT MOUNTED"
  51. ?define DESCRIPTION_TEXT "Try to find it manually. It should look
  52. like image on the right.
  53. Note: this action can be done only once
  54. per 1 session of the OS running. If you
  55. will choose the wrong folder then you
  56. need to reboot system to try again."
  57. ?define MANUALLY_BUTTON_TEXT "Choose /kolibrios/ folder..."
  58. ?define OPEN_ANYWAY_BUTTON_TEXT "Open APP+ anyway (some apps will be unavailable)"
  59. #endif
  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.         incn y;
  106.         sc.get();
  107.         DefineAndDrawWindow(screen.width-570/2, 100, 570, 300+skin_height, 0x34, sc.work, WINDOW_TITLE_TEXT,0);
  108.         GetProcessInfo(#Form, SelfInfo);
  109.         WriteTextB(CONX+2,y.set(20)+2,0x81,MixColors(sc.work, 0xB92234,220),CONTENT_HEADER_TEXT);
  110.         WriteTextB(CONX,y.n,0x81,0xB92234,CONTENT_HEADER_TEXT);
  111.        
  112.         PutPaletteImage(#scr,144,171,Form.cwidth-180,y.n,8,#scr_pal);
  113.         DrawRectangle(Form.cwidth-180-1,y.n-1, 144+1,171+1, sc.work_graph);
  114.  
  115.         WriteTextLines(CONX,y.inc(50),0x90,sc.work_text,DESCRIPTION_TEXT,20);
  116.  
  117.         DrawButtons(); 
  118. }
  119.  
  120. void DrawButtons()
  121. {
  122.         DrawStandartCaptButton(CONX, Form.cheight-80, BTN_MANUAL_SEARCH, MANUALLY_BUTTON_TEXT);
  123.         DrawStandartCaptButton(CONX, Form.cheight-42, BTN_OPEN_ANYWAY, OPEN_ANYWAY_BUTTON_TEXT);
  124. }
  125.  
  126. void CheckKosMounted()
  127. {
  128.         if (dir_exists("/kolibrios"))
  129.         {
  130.                 if (file_exists(APP_PLUS_INI_PATH))     EventOpenApp();
  131.                 ExitProcess();
  132.         }
  133. }
  134.  
  135. void WaitAutosearch()
  136. {
  137.         while (CheckProcessExists("SEARCHAP")) pause(2);
  138. }
  139.  
  140. //===================================================//
  141. //                                                   //
  142. //                      EVENTS                       //
  143. //                                                   //
  144. //===================================================//
  145.  
  146. void EventManualSearch()
  147. {
  148.         OpenDialog_start stdcall (#o_dialog);
  149.         if (o_dialog.status) SetAdditionalSystemDirectory("kolibrios", #openfile_path+1);
  150.         pause(3);
  151.         CheckKosMounted();     
  152. }
  153.  
  154. void EventOpenApp()
  155. {
  156.         if (RunProgram("/sys/syspanel", APP_PLUS_INI_PATH) < 0) {
  157.                 notify("'App+ can not be started because\n/sys/syspanel does not exists' -E");
  158.         }
  159. }
  160.  
  161. void EventButton(dword id)
  162. {
  163.         if (id==CLOSE_BTN) ExitProcess();
  164.         else if (id==BTN_MANUAL_SEARCH) EventManualSearch();
  165.         else if (id==BTN_OPEN_ANYWAY) { EventOpenApp();  ExitProcess(); }
  166. }
  167.  
  168.  
  169. stop:
  170.