Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

LevelInput.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "LevelInput.h"
00010 
00011 #include "Level.h"
00012 #include "Keymap.h"
00013 
00014 #include "KeyStroke.h"
00015 #include "OptionAgent.h"
00016 #include "MenuOptions.h"
00017 #include "SubTitleAgent.h"
00018 
00019 //-----------------------------------------------------------------
00020 LevelInput::LevelInput(Level *level)
00021     : GameInput(level)
00022 {
00023     m_keymap->registerKey(KeyStroke(SDLK_SPACE, KMOD_NONE),
00024             KeyDesc(KEY_SWITCH, "switch"));
00025     m_keymap->registerKey(KeyStroke(SDLK_F2, KMOD_NONE),
00026             KeyDesc(KEY_SAVE, "save"));
00027     m_keymap->registerKey(KeyStroke(SDLK_F3, KMOD_NONE),
00028             KeyDesc(KEY_LOAD, "load"));
00029     m_keymap->registerKey(KeyStroke(SDLK_BACKSPACE, KMOD_NONE),
00030             KeyDesc(KEY_RESTART, "restart"));
00031     m_keymap->registerKey(KeyStroke(SDLK_F5, KMOD_NONE),
00032             KeyDesc(KEY_SHOW_STEPS, "show number of steps"));
00033 }
00034 //-----------------------------------------------------------------
00035 Level *
00036 LevelInput::getLevel()
00037 {
00038     return dynamic_cast<Level*>(m_state);
00039 }
00040 //-----------------------------------------------------------------
00041 void
00042 LevelInput::specKey(int keyIndex)
00043 {
00044     switch (keyIndex) {
00045         case KEY_SWITCH:
00046             if (!getLevel()->isShowing() && !getLevel()->isLoading()) {
00047                 getLevel()->switchFish();
00048             }
00049             break;
00050         case KEY_SAVE:
00051             if (!getLevel()->isShowing() && !getLevel()->isLoading()) {
00052                 getLevel()->action_save();
00053             }
00054             break;
00055         case KEY_LOAD:
00056             getLevel()->interruptShow();
00057             getLevel()->action_load();
00058             break;
00059         case KEY_RESTART:
00060             getLevel()->interruptShow();
00061             getLevel()->action_restart();
00062             break;
00063         case KEY_SHOW_STEPS:
00064             toggleParam("show_steps");
00065             break;
00066         default:
00067             GameInput::specKey(keyIndex);
00068     }
00069 }
00070 //-----------------------------------------------------------------
00071 void
00072 LevelInput::specStroke(const KeyStroke &stroke)
00073 {
00074     if (!getLevel()->isShowing() && !getLevel()->isLoading()) {
00075         getLevel()->controlEvent(stroke);
00076     }
00077 }
00078 //-----------------------------------------------------------------
00079 void
00080 LevelInput::mouseEvent(const MouseStroke &buttons)
00081 {
00082     getLevel()->controlMouse(buttons);
00083 }
00084 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2