Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2. GAME CENTER v1.0
  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.  
  16. system_colors sc;
  17. proc_info Form;
  18.  
  19. struct link {
  20.         char *name;
  21.         char *path;
  22.         int icon;
  23. };
  24.  
  25. struct link games[] = {
  26.         "Bomber", "/kolibrios/games/bomber/bomber", 35,
  27.         "DOOM1", "/kolibrios/games/doom1/doom", 43,
  28.         "DOOM2", "/kolibrios/games/doom2/doom", 43,
  29.         "Fara", "/kolibrios/games/fara/fara", 42,
  30.         "JumpBump", "/kolibrios/games/jumpbump/jumpbump.kex", 35,
  31.         "Loderunner", "/kolibrios/games/LRL/LRL", 41,
  32.         "BabyPainter", "/kolibrios/games/baby painter", 35,
  33.         "Knight", "/kolibrios/games/knight", 35,
  34.         "Pinton", "/kolibrios/games/piton", 32,
  35.  
  36.         "15", "/sys/games/15", 34,
  37.         "Arcanii", "/sys/games/arcanii", 12,
  38.         "Ataka", "/sys/games/ataka", 35,
  39.         "C4", "/sys/games/c4", 35,
  40.         "Checkers", "/sys/games/checkers", 20,
  41.         "Clicks", "/sys/games/clicks", 18,
  42.         "FNumbers", "/sys/games/FindNumbers", 35,
  43.         "Flood-It", "/sys/games/flood-it", 27,
  44.         "Freecell", "/sys/games/freecell", 35,
  45.         "Gomoku", "/sys/games/gomoku", 24,
  46.         "Invaders", "/kolibrios/games/invaders", 35,
  47.         "Klavisha", "/sys/games/klavisha", 35,
  48.         "Kosilka", "/sys/games/kosilka", 23,
  49.         "Lines", "/sys/games/lines", 35,
  50.         "MBlocks", "/sys/games/mblocks", 11,
  51.         "Megamaze", "/sys/games/megamaze", 35,
  52.         "Mine", "/sys/games/mine", 14,
  53.         "Square", "/sys/games/msquare", 35,
  54.         "Padenie", "/sys/games/padenie", 35,
  55.         "Phenix", "/sys/games/phenix", 35,
  56.         "Pig", "/tmp0/1/games/pig/pig", 35,
  57.         "Pipes", "/sys/games/pipes", 26,
  58.         "Pong", "/sys/games/pong", 12,
  59.         "Pong3", "/sys/games/pong3", 12,
  60.         "Reversi", "/sys/games/reversi", 35,
  61.         "Rforces", "/sys/games/rforces", 35,
  62.         "Rsquare", "/sys/games/rsquare", 35,
  63.         "Snake", "/sys/games/snake", 32,
  64.         "Sq game", "/sys/games/sq_game", 35,
  65.         "Sudoku", "/sys/games/sudoku", 25,
  66.         "Sea War", "/sys/games/SW", 35,
  67.         "Tanks", "/sys/games/tanks", 35,
  68.         "Tetris", "/sys/games/tetris", 35,
  69.         "Whowtbam", "/sys/games/whowtbam", 35,
  70.         "Xonix", "/sys/games/xonix", 21,
  71.         0
  72. };
  73.  
  74. struct struct_skin {
  75.         dword image, w, h;
  76.         int Load();
  77. } skin;
  78.  
  79. int struct_skin::Load()
  80. {
  81.         int i;
  82.         dword image_data;
  83.         skin.image = load_image("/sys/iconstrp.png");
  84.         if (!skin.image) notify("'iconstrp.png not found' -E");
  85.         skin.w = DSWORD[skin.image+4];
  86.         skin.h = DSWORD[skin.image+8];
  87.         image_data = DSDWORD[skin.image+24];
  88.         sc.get();
  89.  
  90.         for (i=0; i<w*h*4; i+=4)
  91.         {
  92.                 if (DSDWORD[image_data + i]==0) DSDWORD[image_data + i] = 0xF3F3F3;
  93.         }
  94. }
  95.  
  96.  
  97. void main()
  98. {  
  99.         int id, key;
  100.         mem_Init();
  101.         if (load_dll2(libio, #libio_init,1)!=0) notify("Error: library doesn't exists - libio");
  102.         if (load_dll2(libimg, #libimg_init,1)!=0) notify("Error: library doesn't exists - libimg");
  103.         skin.Load();
  104.        
  105.         loop()
  106.    {
  107.       switch(WaitEvent())
  108.       {
  109.          case evButton:
  110.             id=GetButtonID();              
  111.             if (id==1) ExitProcess();
  112.             if (id>=100) RunProgram(games[id-100].path, "");
  113.                         break;
  114.      
  115.         case evKey:
  116.                         key = GetKey();
  117.                         break;
  118.          
  119.          case evReDraw:
  120.                         sc.get();
  121.                         DefineAndDrawWindow(215,100,568,390+60+GetSkinHeight(),0x74,sc.work," ");
  122.                         GetProcessInfo(#Form, SelfInfo);
  123.                         if (Form.status_window>2) break;
  124.                         draw_window();
  125.                         break;
  126.       }
  127.    }
  128. }
  129.  
  130.  
  131. void draw_window()
  132. {
  133.         int row, col, col_max=8;
  134.         int col_w=68, col_h=70;
  135.         int tmp,y=25;
  136.         DrawBar(0,0,Form.cwidth, y-1, sc.work);
  137.         DrawBar(0,y-1, Form.cwidth, 1, sc.work_graph);
  138.         DrawBar(0,y, Form.cwidth, Form.cheight-y, 0xF3F3F3);
  139.         WriteTextB(Form.cwidth/2-70, 9, 0x90, sc.work_text, "KolibriOS Game Center");
  140.  
  141.         y += 7;
  142.         for (col=0, row=0; games[row*col_max+col].name!=0; col++)
  143.         {
  144.                 if (col==col_max) {
  145.                         row++;
  146.                         col=0;
  147.                 }
  148.                 DefineButton(col*col_w+6,row*col_h+y,col_w,col_h,row*col_max+col+100+BT_HIDE,0);
  149.                 tmp = col_w/2;
  150.                 img_draw stdcall(skin.image, col*col_w+tmp-10, row*col_h+5+y, 32, 32, 0, games[row*col_max+col].icon*32);
  151.                 WriteTextCenter(col*col_w+7,row*col_h+47+y,col_w,0xD4D4d4,games[row*col_max+col].name);
  152.                 WriteTextCenter(col*col_w+6,row*col_h+46+y,col_w,0x000000,games[row*col_max+col].name);
  153.         }
  154. }
  155.  
  156.  
  157.  
  158. stop:
  159.