Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * OpenTyrian: A modern cross-platform port of Tyrian
  3.  * Copyright (C) 2007-2009  The OpenTyrian Development Team
  4.  *
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License
  7.  * as published by the Free Software Foundation; either version 2
  8.  * of the License, or (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  18.  */
  19. #include "menus.h"
  20.  
  21. #include "config.h"
  22. #include "episodes.h"
  23. #include "fonthand.h"
  24. #include "keyboard.h"
  25. #include "nortsong.h"
  26. #include "opentyr.h"
  27. #include "palette.h"
  28. #include "picload.h"
  29. #include "setup.h"
  30. #include "sprite.h"
  31. #include "video.h"
  32.  
  33. char episode_name[6][31], difficulty_name[7][21], gameplay_name[GAMEPLAY_NAME_COUNT][26];
  34.  
  35. bool select_gameplay( void )
  36. {
  37.         JE_loadPic(VGAScreen, 2, false);
  38.         JE_dString(VGAScreen, JE_fontCenter(gameplay_name[0], FONT_SHAPES), 20, gameplay_name[0], FONT_SHAPES);
  39.  
  40.         int gameplay = 1,
  41.             gameplay_max = GAMEPLAY_NAME_COUNT - 1;
  42.  
  43.         bool fade_in = true;
  44.         for (; ; )
  45.         {
  46.                 for (int i = 1; i <= gameplay_max; i++)
  47.                 {
  48.                         JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * 24 + 30, gameplay_name[i], 15, -4 + (i == gameplay ? 2 : 0) - (i == (GAMEPLAY_NAME_COUNT - 1) ? 4 : 0), SMALL_FONT_SHAPES, true);
  49.                 }
  50.                 JE_showVGA();
  51.  
  52.                 if (fade_in)
  53.                 {
  54.                         fade_palette(colors, 10, 0, 255);
  55.                         fade_in = false;
  56.                 }
  57.  
  58.                 JE_word temp = 0;
  59.                 JE_textMenuWait(&temp, false);
  60.  
  61.                 if (newkey)
  62.                 {
  63.                         switch (lastkey_sym)
  64.                         {
  65.                         case SDLK_UP:
  66.                                 if (--gameplay < 1)
  67.                                         gameplay = gameplay_max;
  68.                                 JE_playSampleNum(S_CURSOR);
  69.                                 break;
  70.                         case SDLK_DOWN:
  71.                                 if (++gameplay > gameplay_max)
  72.                                         gameplay = 1;
  73.                                 JE_playSampleNum(S_CURSOR);
  74.                                 break;
  75.  
  76.                         case SDLK_RETURN:
  77.                                 if (gameplay == GAMEPLAY_NAME_COUNT - 1)
  78.                                 {
  79.                                         JE_playSampleNum(S_SPRING);
  80.                                         /* TODO: NETWORK */
  81.                                         fprintf(stderr, "error: networking via menu not implemented\n");
  82.                                         break;
  83.                                 }
  84.                                 JE_playSampleNum(S_SELECT);
  85.                                 fade_black(10);
  86.  
  87.                                 onePlayerAction = (gameplay == 2);
  88.                                 twoPlayerMode = (gameplay == GAMEPLAY_NAME_COUNT - 2);
  89.                                 return true;
  90.  
  91.                         case SDLK_ESCAPE:
  92.                                 JE_playSampleNum(S_SPRING);
  93.                                 /* fading handled elsewhere
  94.                                 fade_black(10); */
  95.  
  96.                                 return false;
  97.  
  98.                         default:
  99.                                 break;
  100.                         }
  101.                 }
  102.         }
  103. }
  104.  
  105. bool select_episode( void )
  106. {
  107.         JE_loadPic(VGAScreen, 2, false);
  108.         JE_dString(VGAScreen, JE_fontCenter(episode_name[0], FONT_SHAPES), 20, episode_name[0], FONT_SHAPES);
  109.  
  110.         int episode = 1, episode_max = EPISODE_AVAILABLE;
  111.  
  112.         bool fade_in = true;
  113.         for (; ; )
  114.         {
  115.                 for (int i = 1; i <= episode_max; i++)
  116.                 {
  117.                         JE_outTextAdjust(VGAScreen, 20, i * 30 + 20, episode_name[i], 15, -4 + (i == episode ? 2 : 0) - (!episodeAvail[i - 1] ? 4 : 0), SMALL_FONT_SHAPES, true);
  118.                 }
  119.                 JE_showVGA();
  120.  
  121.                 if (fade_in)
  122.                 {
  123.                         fade_palette(colors, 10, 0, 255);
  124.                         fade_in = false;
  125.                 }
  126.  
  127.                 JE_word temp = 0;
  128.                 JE_textMenuWait(&temp, false);
  129.  
  130.                 if (newkey)
  131.                 {
  132.                         switch (lastkey_sym)
  133.                         {
  134.                         case SDLK_UP:
  135.                                 episode--;
  136.                                 if (episode < 1)
  137.                                 {
  138.                                         episode = episode_max;
  139.                                 }
  140.                                 JE_playSampleNum(S_CURSOR);
  141.                                 break;
  142.                         case SDLK_DOWN:
  143.                                 episode++;
  144.                                 if (episode > episode_max)
  145.                                 {
  146.                                         episode = 1;
  147.                                 }
  148.                                 JE_playSampleNum(S_CURSOR);
  149.                                 break;
  150.  
  151.                         case SDLK_RETURN:
  152.                                 if (!episodeAvail[episode - 1])
  153.                                 {
  154.                                         JE_playSampleNum(S_SPRING);
  155.                                         break;
  156.                                 }
  157.                                 JE_playSampleNum(S_SELECT);
  158.                                 fade_black(10);
  159.  
  160.                                 JE_initEpisode(episode);
  161.                                 initial_episode_num = episodeNum;
  162.                                 return true;
  163.  
  164.                         case SDLK_ESCAPE:
  165.                                 JE_playSampleNum(S_SPRING);
  166.                                 /* fading handled elsewhere
  167.                                 fade_black(10); */
  168.  
  169.                                 return false;
  170.  
  171.                         default:
  172.                                 break;
  173.                         }
  174.                 }
  175.         }
  176. }
  177.  
  178. bool select_difficulty( void )
  179. {
  180.         JE_loadPic(VGAScreen, 2, false);
  181.         JE_dString(VGAScreen, JE_fontCenter(difficulty_name[0], FONT_SHAPES), 20, difficulty_name[0], FONT_SHAPES);
  182.  
  183.         difficultyLevel = 2;
  184.         int difficulty_max = 3;
  185.  
  186.         bool fade_in = true;
  187.         for (; ; )
  188.         {
  189.                 for (int i = 1; i <= difficulty_max; i++)
  190.                 {
  191.                         JE_outTextAdjust(VGAScreen, JE_fontCenter(difficulty_name[i], SMALL_FONT_SHAPES), i * 24 + 30, difficulty_name[i], 15, -4 + (i == difficultyLevel ? 2 : 0), SMALL_FONT_SHAPES, true);
  192.                 }
  193.                 JE_showVGA();
  194.  
  195.                 if (fade_in)
  196.                 {
  197.                         fade_palette(colors, 10, 0, 255);
  198.                         fade_in = false;
  199.                 }
  200.  
  201.                 JE_word temp = 0;
  202.                 JE_textMenuWait(&temp, false);
  203.  
  204.                 if (SDL_GetModState() & KMOD_SHIFT)
  205.                 {
  206.                         if ((difficulty_max < 4 && keysactive[SDLK_g]) ||
  207.                             (difficulty_max == 4 && keysactive[SDLK_RIGHTBRACKET]))
  208.                         {
  209.                                 difficulty_max++;
  210.                         }
  211.                 } else if (difficulty_max == 5 && keysactive[SDLK_l] && keysactive[SDLK_o] && keysactive[SDLK_r] && keysactive[SDLK_d]) {
  212.                         difficulty_max++;
  213.                 }
  214.  
  215.                 if (newkey)
  216.                 {
  217.                         switch (lastkey_sym)
  218.                         {
  219.                         case SDLK_UP:
  220.                                 difficultyLevel--;
  221.                                 if (difficultyLevel < 1)
  222.                                 {
  223.                                         difficultyLevel = difficulty_max;
  224.                                 }
  225.                                 JE_playSampleNum(S_CURSOR);
  226.                                 break;
  227.                         case SDLK_DOWN:
  228.                                 difficultyLevel++;
  229.                                 if (difficultyLevel > difficulty_max)
  230.                                 {
  231.                                         difficultyLevel = 1;
  232.                                 }
  233.                                 JE_playSampleNum(S_CURSOR);
  234.                                 break;
  235.  
  236.                         case SDLK_RETURN:
  237.                                 JE_playSampleNum(S_SELECT);
  238.                                 /* fading handled elsewhere
  239.                                 fade_black(10); */
  240.  
  241.                                 if (difficultyLevel == 6)
  242.                                 {
  243.                                         difficultyLevel = 8;
  244.                                 } else if (difficultyLevel == 5) {
  245.                                         difficultyLevel = 6;
  246.                                 }
  247.                                 return true;
  248.  
  249.                         case SDLK_ESCAPE:
  250.                                 JE_playSampleNum(S_SPRING);
  251.                                 /* fading handled elsewhere
  252.                                 fade_black(10); */
  253.  
  254.                                 return false;
  255.  
  256.                         default:
  257.                                 break;
  258.                         }
  259.                 }
  260.         }
  261. }
  262.  
  263.