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 "xmas.h"
  20.  
  21. #include "font.h"
  22. #include "keyboard.h"
  23. #include "palette.h"
  24. #include "setup.h"
  25. #include "sprite.h"
  26. #include "video.h"
  27.  
  28. #include <stdio.h>
  29. #include <time.h>
  30.  
  31. bool xmas = false;
  32.  
  33. bool xmas_time( void )
  34. {
  35.         time_t now = time(NULL);
  36.         return localtime(&now)->tm_mon == 11;
  37. }
  38.  
  39. bool xmas_prompt( void )
  40. {
  41.         const char *prompt[] =
  42.         {
  43.                 "Christmas has been detected.",
  44.                 "Activate Christmas?",
  45.         };
  46.         const char *choice[] =
  47.         {
  48.                 "Yes",
  49.                 "No",
  50.         };
  51.        
  52.         set_palette(palettes[0], 0, 255);
  53.        
  54.         for (uint i = 0; i < COUNTOF(prompt); ++i)
  55.                 draw_font_hv(VGAScreen, 320 / 2, 85 + 15 * i, prompt[i], normal_font, centered, (i % 2) ? 2 : 4, -2);
  56.        
  57.         uint selection = 0;
  58.        
  59.         bool decided = false, quit = false;
  60.         while (!decided)
  61.         {
  62.                 for (uint i = 0; i < COUNTOF(choice); ++i)
  63.                         draw_font_hv(VGAScreen, 320 / 2 - 20 + 40 * i, 120, choice[i], normal_font, centered, 15, (selection == i) ? -2 : -4);
  64.                
  65.                 JE_showVGA();
  66.                
  67.                 JE_word temp = 0;
  68.                 JE_textMenuWait(&temp, false);
  69.                
  70.                 if (newkey)
  71.                 {
  72.                         switch (lastkey_sym)
  73.                         {
  74.                                 case SDLK_LEFT:
  75.                                         if (selection == 0)
  76.                                                 selection = 2;
  77.                                         selection--;
  78.                                         break;
  79.                                 case SDLK_RIGHT:
  80.                                         selection++;
  81.                                         selection %= 2;
  82.                                         break;
  83.                                        
  84.                                 case SDLK_RETURN:
  85.                                         decided = true;
  86.                                         break;
  87.                                 case SDLK_ESCAPE:
  88.                                         decided = true;
  89.                                         quit = true;
  90.                                         break;
  91.                                 default:
  92.                                         break;
  93.                         }
  94.                 }
  95.         }
  96.        
  97.         fade_black(10);
  98.        
  99.         return (selection == 0 && quit == false);
  100. }
  101.