Subversion Repositories Kolibri OS

Rev

Rev 5055 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2. GAME CENTER v1.5
  3. */
  4.  
  5. #define MEMSIZE 0x3E80
  6. #include "..\lib\kolibri.h"
  7. #include "..\lib\strings.h"
  8. #include "..\lib\mem.h"
  9. #include "..\lib\file_system.h"
  10. #include "..\lib\dll.h"
  11. #include "..\lib\figures.h"
  12.  
  13. #include "..\lib\lib.obj\libio_lib.h"
  14. #include "..\lib\lib.obj\libimg_lib.h"
  15. #include "..\lib\lib.obj\libini.h"
  16.  
  17. system_colors sc;
  18. proc_info Form;
  19. int run_id, enum_i;
  20.  
  21. struct struct_skin {
  22.         dword image, w, h;
  23.         int Load();
  24. } skin;
  25.  
  26. int struct_skin::Load()
  27. {
  28.         int i;
  29.         dword image_data;
  30.         skin.image = load_image("/sys/iconstrp.png");
  31.         if (!skin.image) notify("'iconstrp.png not found' -E");
  32.         skin.w = DSWORD[skin.image+4];
  33.         skin.h = DSWORD[skin.image+8];
  34.         image_data = DSDWORD[skin.image+24];
  35.         sc.get();
  36.  
  37.         for (i=0; i<w*h*4; i+=4)
  38.         {
  39.                 if (DSDWORD[image_data + i]==0) DSDWORD[image_data + i] = 0xF3F3F3;
  40.         }
  41. }
  42.  
  43.  
  44. void main()
  45. {  
  46.         int id, key;
  47.         mem_Init();
  48.         if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
  49.         if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
  50.         if (load_dll2(libini, #lib_init,1)!=0) notify("Error: library doesn't exists - libini");
  51.         skin.Load();
  52.        
  53.         loop()
  54.    {
  55.       switch(WaitEvent())
  56.       {
  57.          case evButton:
  58.             id=GetButtonID();              
  59.             if (id==1) ExitProcess();
  60.             if (id>=100)
  61.             {
  62.                 run_id = id - 100;
  63.                 enum_i = 0;
  64.                 ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #run_game);
  65.             }
  66.                         break;
  67.      
  68.         case evKey:
  69.                         key = GetKey();
  70.                         break;
  71.          
  72.          case evReDraw:
  73.                         sc.get();
  74.                         DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," ");
  75.                         GetProcessInfo(#Form, SelfInfo);
  76.                         if (Form.status_window>2) break;
  77.                         draw_window();
  78.                         break;
  79.       }
  80.    }
  81. }
  82.  
  83. byte run_game(dword key_value, key_name, sec_name, f_name)
  84. {
  85.         if (run_id==enum_i)
  86.         {
  87.                 ESBYTE[key_value + strchr(key_value, ',') - 1] = 0;
  88.                 RunProgram(key_value, '');
  89.                 return 0;
  90.         }
  91.         enum_i++;
  92.         return 1;
  93. }
  94.  
  95.  
  96. int col_max, col_w, col_h, y;
  97. int row, col;
  98.  
  99. byte key_process(dword key_value, key_name, sec_name, f_name)
  100. {
  101.         int tmp;
  102.         int icon_n;
  103.  
  104.  
  105.         if (col==col_max) {
  106.                 row++;
  107.                 col=0;
  108.         }
  109.         DefineButton(col*col_w+6,row*col_h+y,col_w,col_h-10,row*col_max+col+100+BT_HIDE,0);
  110.         tmp = col_w/2;
  111.         icon_n = atoi(key_value + strchr(key_value, ','));
  112.         img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, icon_n*32);
  113.         WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,key_name);
  114.         WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,key_name);
  115.         col++;
  116.         return 1;
  117. }
  118.  
  119. void draw_window()
  120. {
  121.         y = 25;
  122.         DrawBar(0,0,Form.cwidth, y-1, sc.work);
  123.         DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph);
  124.         DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3);
  125.         WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center");
  126.         y += 2;
  127.         col_max=8;
  128.         col_w=68;
  129.         col_h=70;
  130.         col = row = 0;
  131.  
  132.         ini_enum_keys stdcall ("/sys/settings/games.ini", "Games", #key_process);
  133. }
  134.  
  135.  
  136.  
  137. stop:
  138.