Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 14, 2009, 11:50:47 AM (15 years ago)
Author:
rgrieder
Message:

Added window size as static variable to the WindowEventListener interface.
This resolves several hacks and inconveniences in Mouse, InputManager, InGameConsole, GSGraphics and OrxonoxOverlay.

Location:
code/branches/core4/src/orxonox
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/orxonox/GraphicsManager.cc

    r3290 r3291  
    7575    class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener
    7676    {
    77         void windowResized     (Ogre::RenderWindow* rw);
    78         void windowFocusChange (Ogre::RenderWindow* rw);
    79         void windowClosed      (Ogre::RenderWindow* rw);
    80         //void windowMoved       (Ogre::RenderWindow* rw);
     77        void windowResized     (Ogre::RenderWindow* rw)
     78            { orxonox::WindowEventListener::resizeWindow(rw->getWidth(), rw->getHeight()); }
     79        void windowFocusChange (Ogre::RenderWindow* rw)
     80            { orxonox::WindowEventListener::changeWindowFocus(); }
     81        void windowClosed      (Ogre::RenderWindow* rw)
     82            { orxonox::Game::getInstance().stop(); }
     83        void windowMoved       (Ogre::RenderWindow* rw)
     84            { orxonox::WindowEventListener::moveWindow(); }
    8185    };
    8286
     
    418422        this->renderWindow_->writeContentsToTimestampedFile(Core::getLogPathString() + "screenShot_", ".jpg");
    419423    }
    420 
    421 
    422     /****** OgreWindowEventListener ******/
    423 
    424     void OgreWindowEventListener::windowResized(Ogre::RenderWindow* rw)
    425     {
    426         for (ObjectList<orxonox::WindowEventListener>::iterator it
    427             = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    428             it->windowResized(rw->getWidth(), rw->getHeight());
    429     }
    430     void OgreWindowEventListener::windowFocusChange(Ogre::RenderWindow* rw)
    431     {
    432         for (ObjectList<orxonox::WindowEventListener>::iterator it
    433             = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    434             it->windowFocusChanged();
    435     }
    436     void OgreWindowEventListener::windowClosed(Ogre::RenderWindow* rw)
    437     {
    438         Game::getInstance().stop();
    439     }
    440424}
  • code/branches/core4/src/orxonox/OrxonoxPrereqs.h

    r3261 r3291  
    9292    class Level;
    9393    class Scene;
     94    class Tickable;
    9495
    9596    class AddQuest;
  • code/branches/core4/src/orxonox/gamestates/GSGraphics.cc

    r3279 r3291  
    3939
    4040#include "util/Convert.h"
    41 #include "core/ConfigValueIncludes.h"
    4241#include "core/Clock.h"
    4342#include "core/CommandExecutor.h"
    4443#include "core/ConsoleCommand.h"
    4544#include "core/Core.h"
    46 #include "core/CoreIncludes.h"
    4745#include "core/Game.h"
    4846#include "core/GameMode.h"
     
    7270        , debugOverlay_(0)
    7371    {
    74         RegisterRootObject(GSGraphics);
    7572    }
    7673
    7774    GSGraphics::~GSGraphics()
    78     {
    79     }
    80 
    81     /**
    82     @brief
    83         this function does nothing
    84 
    85         Indeed. Here goes nothing.
    86     */
    87     void GSGraphics::setConfigValues()
    8875    {
    8976    }
     
    10895        GameMode::setShowsGraphics(true);
    10996
    110         setConfigValues();
    111 
    11297        // Load OGRE including the render window
    11398        this->graphicsManager_ = new GraphicsManager();
     
    124109
    125110        // Calls the InputManager which sets up the input devices.
    126         inputManager_ = new InputManager(windowHnd, renderWindow->getWidth(), renderWindow->getHeight());
     111        inputManager_ = new InputManager(windowHnd);
    127112
    128113        // load master key bindings
     
    137122        // Load the InGameConsole
    138123        console_ = new InGameConsole();
    139         console_->initialise(renderWindow->getWidth(), renderWindow->getHeight());
     124        console_->initialise();
    140125
    141126        // load the CEGUI interface
     
    233218        this->graphicsManager_->update(time);
    234219    }
    235 
    236     /**
    237     @brief
    238         Window has resized.
    239     @param rw
    240         The render window it occured in
    241     @note
    242         GraphicsManager has a render window stored itself. This is the same
    243         as rw. But we have to be careful when using multiple render windows!
    244     */
    245     void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight)
    246     {
    247         // OIS needs this under linux even if we only use relative input measurement.
    248         // HACK:
    249         CommandExecutor::execute("setWindowExtents_s " + multi_cast<std::string>(newWidth) + " " + multi_cast<std::string>(newHeight));
    250     }
    251 
    252     /**
    253     @brief
    254         Window focus has changed.
    255     @param rw
    256         The render window it occured in
    257     */
    258     void GSGraphics::windowFocusChanged()
    259     {
    260         // instruct InputManager to clear the buffers (core library so we cannot use the interface)
    261         if (this->inputManager_)
    262             this->inputManager_->clearBuffers();
    263     }
    264 
    265220}
  • code/branches/core4/src/orxonox/gamestates/GSGraphics.h

    r3290 r3291  
    3737
    3838#include "OrxonoxPrereqs.h"
    39 
    4039#include "core/GameState.h"
    41 #include "core/WindowEventListener.h"
    4240
    4341namespace orxonox
     
    4947        This game state is only left out if we start a dedicated server where no graphics are present.
    5048    */
    51     class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
     49    class _OrxonoxExport GSGraphics : public GameState
    5250    {
    5351    public:
    5452        GSGraphics(const GameStateConstrParams& params);
    5553        ~GSGraphics();
    56         void setConfigValues();
    5754
    5855        void activate();
     
    6360
    6461    private:
    65         // Window events from WindowEventListener
    66         void windowResized(unsigned int newWidth, unsigned int newHeight);
    67         void windowFocusChanged();
    68 
    6962        // managed singletons
    7063        InputManager*         inputManager_;        //!< Reference to input management
  • code/branches/core4/src/orxonox/overlays/OrxonoxOverlay.cc

    r3265 r3291  
    4747#include "core/XMLPort.h"
    4848#include "core/ConsoleCommand.h"
    49 #include "GraphicsManager.h"
    5049
    5150namespace orxonox
     
    8180
    8281        // Get aspect ratio from the render window. Later on, we get informed automatically
    83         Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
    84         this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
     82        this->windowAspectRatio_ = (float)this->getWindowWidth() / this->getWindowHeight();
    8583        this->sizeCorrectionChanged();
    8684
  • code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc

    r3279 r3291  
    172172        @brief Initializes the InGameConsole.
    173173    */
    174     void InGameConsole::initialise(int windowWidth, int windowHeight)
     174    void InGameConsole::initialise()
    175175    {
    176176        // create the corresponding input state
     
    248248        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    249249
    250         this->windowResized(windowWidth, windowHeight);
     250        this->windowResized(this->getWindowWidth(), this->getWindowWidth());
    251251
    252252        // move overlay "above" the top edge of the screen
  • code/branches/core4/src/orxonox/overlays/console/InGameConsole.h

    r3290 r3291  
    4646        ~InGameConsole();
    4747
    48         void initialise(int windowWidth, int windowHeight);
     48        void initialise();
    4949        void destroy();
    5050        void setConfigValues();
Note: See TracChangeset for help on using the changeset viewer.