C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/src/HumanView.cpp

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #include "HumanView.h"
00022 
00023 #include <CEGUI/elements/CEGUIPushButton.h>
00024 
00025 namespace GameEngine{
00026 
00027         HumanView::HumanView(GameApp* const application, BaseGame* const game)
00028                 : mApplication(application), mGame(game)
00029         {
00030 
00031         }
00032 
00033 
00034         HumanView::~HumanView()
00035         {
00036 
00037                 //if(mGuiSystem){
00038                         //delete mGuiSystem;
00039                 //}
00040 
00041                 //if(mGuiRenderer){
00042                         //delete mGuiRenderer;
00043                 //}
00044         }
00045 
00046 
00047         void HumanView::init(void)
00048         {
00049                 // Create the renderer and system objects
00050                 mGuiRenderer = new CEGUI::OgreCEGUIRenderer( mApplication->getRenderWindow() );
00051 
00052                 mGuiSystem = new CEGUI::System( mGuiRenderer );
00053 
00054 
00055                 // Set up logging
00056                 CEGUI::Logger::getSingletonPtr()->setLoggingLevel(CEGUI::Informative);
00057 
00058                 // Load the (for now default) scheme, and set a default mouse cursor look
00059                 CEGUI::SchemeManager::getSingletonPtr()->loadScheme("TaharezLookSkin.scheme");
00060                 CEGUI::System::getSingletonPtr()->setDefaultMouseCursor("TaharezLook", "MouseArrow");
00061 
00062 
00063                 // Register to listen for input events so we can update the GUI to respond to them
00064                 EventManager::getSingletonPtr()->addListener(this->shared_from_this(), EventType("KeyPressed"));
00065                 EventManager::getSingletonPtr()->addListener(this->shared_from_this(), EventType("KeyReleased"));
00066                 EventManager::getSingletonPtr()->addListener(this->shared_from_this(), EventType("MouseMoved"));
00067                 EventManager::getSingletonPtr()->addListener(this->shared_from_this(), EventType("MouseButtonPressed"));
00068                 EventManager::getSingletonPtr()->addListener(this->shared_from_this(), EventType("MouseButtonReleased"));
00069         }
00070 
00071 
00072         bool HumanView::handleEvent(const Event& event)
00073         {
00074                 if(event.getEventType() == EventType("KeyPressed")){
00075                         OIS::KeyEvent arg = event.getDataPtr<KeyboardEventData>()->mEvent;
00076 
00077                         mGuiSystem->injectKeyDown(arg.key);
00078                 }
00079                 else if(event.getEventType() == EventType("KeyReleased")){
00080                         OIS::KeyEvent arg = event.getDataPtr<KeyboardEventData>()->mEvent;
00081 
00082                         mGuiSystem->injectKeyUp(arg.key);
00083                 }
00084                 else if(event.getEventType() == EventType("MouseMoved")){
00085                         OIS::MouseEvent arg = event.getDataPtr<MouseMovedEventData>()->mEvent;
00086 
00087                         mGuiSystem->injectMousePosition(arg.state.abX, arg.state.abY);
00088                 }
00089                 else if(event.getEventType() == EventType("MouseButtonPressed")){
00090                         OIS::MouseButtonID id = event.getDataPtr<MouseButtonEventData>()->mButtonId;
00091 
00092                         mGuiSystem->injectMouseButtonDown(InputManager::getSingletonPtr()->convertOisButtonToCegui(id) );
00093                 }
00094                 else if(event.getEventType() == EventType("MouseButtonReleased")){
00095                         OIS::MouseButtonID id = event.getDataPtr<MouseButtonEventData>()->mButtonId;
00096 
00097                         mGuiSystem->injectMouseButtonUp( InputManager::getSingletonPtr()->convertOisButtonToCegui(id) );
00098                 }
00099 
00100                 return false;
00101         }
00102 
00103 
00104         void HumanView::onUpdate(const double dt)
00105         {
00106 
00107         }
00108 
00109 }

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2