"L. Spiro Engine"

F:/My Projects/LSEngine/Modules/LSEngine/Src/Game/LSEGame.h

00001 
00021 #ifndef __LSE_GAME_H__
00022 #define __LSE_GAME_H__
00023 
00024 #include "../LSEEngine.h"
00025 #include "../Input/LSEKeyboard.h"
00026 #include "../Input/LSEKeyboardBuffer.h"
00027 #include "../Input/LSEMouse.h"
00028 #include "../States/LSEStateFactory.h"
00029 #include "../States/LSEStateMachine.h"
00030 #include "Fnd/LSGFnd.h"
00031 #include "Rand/LSMRand.h"
00032 #include "SoundCore/LSSSoundManagerEx.h"
00033 #include "Time/LSSTDTime.h"
00034 
00035 namespace lse {
00036 
00048         class CGame {
00049                 friend class                                                            CStateMachine;
00050         public :
00051                 // == Various constructors.
00052                 LSE_CALL                                                                        CGame();
00053                 virtual LSE_CALL                                                        ~CGame();
00054                 
00055                 
00056                 // == Types.
00061                 typedef LSVOID (LSE_CALL *                                      PfPresentFunc)( LSVOID * _pvParm );
00062 
00063 
00064                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00065                 // GETS
00066                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00073                 const CTime & LSE_CALL                                          GetTime() const;
00074 
00080                 const CTime & LSE_CALL                                          GetRenderTime() const;
00081 
00085                 virtual LSBOOL LSE_CALL                                         IsPaused() const;
00086 
00092                 LSINT32 LSE_CALL                                                        GetWidth() const;
00093 
00099                 LSINT32 LSE_CALL                                                        GetHeight() const;
00100 
00106                 LSREAL LSE_CALL                                                         GetWidthF() const;
00107 
00113                 LSREAL LSE_CALL                                                         GetHeightF() const;
00114 
00120                 LSREAL LSE_CALL                                                         GetHalfWidthF() const;
00121 
00127                 LSREAL LSE_CALL                                                         GetHalfHeightF() const;
00128 
00134                 LSBOOL LSE_CALL                                                         IsFullScreen() const;
00135 
00139                 LSINT32 LSE_CALL                                                        GetCurStateId() const;
00140                 
00146                 CState * LSE_CALL                                                       GetCurState();
00147                 
00153                 const CState * LSE_CALL                                         GetCurState() const;
00154 
00158                 CSoundManagerEx & LSE_CALL                                      GetSoundMan();
00159 
00160 
00161 
00162                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00163                 // SETS
00164                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00171                 LSVOID LSE_CALL                                                         SetPresentFunc( PfPresentFunc _pfFunc, LSVOID * _pvUser );
00172 
00181                 virtual LSVOID LSE_CALL                                         SetNextState( LSUINT32 _ui32Id, LSUINTPTR _uptrUser, LSBOOL _bForce = false );
00182 
00186                 virtual LSVOID LSE_CALL                                         SetStateFactory( CStateFactory * _psfFactory );
00187 
00188 
00189 
00190                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00191                 // INPUT
00192                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00199                 virtual LSVOID LSE_CALL                                         SetInitialMousePosition( LSINT32 _ui32X, LSINT32 _ui32Y );
00200 
00206                 CMouse & LSE_CALL                                                       GetHiDefMouse();
00207 
00213                 const CMouse & LSE_CALL                                         GetHiDefMouse() const;
00214 
00220                 CMouse & LSE_CALL                                                       GetLoDefMouse();
00221 
00227                 const CMouse & LSE_CALL                                         GetLoDefMouse() const;
00228 
00232                 virtual LSBOOL LSE_CALL                                         SendInputToHiDefMouse() const;
00233 
00240                 virtual LSVOID LSE_CALL                                         SetSendInputToHiDefMouse( LSBOOL _bVal );
00241 
00247                 const CKeyboard & LSE_CALL                                      GetKeyboard() const;
00248 
00254                 LSVOID LSE_CALL                                                         SetKeyboardBuffer( CKeyboardBuffer * _pkbBuffer );
00255 
00256 
00257 
00258                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00259                 // OTHER
00260                 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00264                 virtual LSBOOL LSE_CALL                                         Tick();
00265 
00269                 virtual LSVOID LSE_CALL                                         UpdateTime();
00270                 
00277                 virtual LSVOID LSE_CALL                                         SetScreenDimensions( LSINT32 _i32Width, LSINT32 _i32Height );
00278 
00284                 virtual LSVOID LSE_CALL                                         SetActive( LSBOOL _bVal );
00285 
00289                 virtual LSBOOL LSE_CALL                                         GetActive() const;
00290 
00296                 virtual LSVOID LSE_CALL                                         SetFullScreen( LSBOOL _bVal );
00297 
00301                 virtual LSVOID LSE_CALL                                         Present();
00302 
00306                 virtual LSVOID LSE_CALL                                         Close();
00307 
00311                 LSBOOL LSE_CALL                                                         IsClosing() const;
00312 
00313 
00314         protected :
00315                 // == Members.
00319                 mutable CCriticalSection                                        m_csCriticalSection;
00320 
00324                 CTime                                                                           m_tTime;
00325 
00332                 CTime                                                                           m_tRenderTime;
00333 
00337                 PfPresentFunc                                                           m_pfPresent;
00338                 
00342                 LSVOID *                                                                        m_lpvPresentUser;
00343 
00347                 LSINT32                                                                         m_i32Width,
00348                                                                                                         m_i32Height;
00349 
00353                 LSBOOL                                                                          m_bActive                               : 1;
00354                 
00358                 LSBOOL                                                                          m_bFullScreen                   : 1;
00359 
00366                 LSBOOL                                                                          m_bHiDefInput                   : 1;
00367                 
00371                 LSBOOL                                                                          m_bTicked                               : 1;
00372 
00376                 LSBOOL                                                                          m_bPaused                               : 1;
00377 
00381                 LSBOOL                                                                          m_bClosing                              : 1;
00382 
00387                 LSBOOL                                                                          m_bCostantTimeTicked    : 1;
00388 
00392                 CKeyboard                                                                       m_kKeyboard;
00393 
00397                 CKeyboardBuffer *                                                       m_pkbKeyboardBuffer;
00398 
00399                 // Random numbers.
00400                 CRand                                                                           m_rRand;
00401 
00405                 CStateMachine                                                           m_smStateMachine;
00406 
00410                 CStateFactory *                                                         m_psfStateFactory;
00411 
00415                 struct {
00419                         LSBOOL                                                                  bSetNextState;
00420 
00424                         LSUINT32                                                                ui32Id;
00425 
00429                         LSUINTPTR                                                               uiptrUser;
00430 
00434                         LSBOOL                                                                  bForce;
00435                 }                                                                                       m_sNextState;
00436 
00440                 CMouse                                                                          m_mHiDefMouse;
00441 
00445                 CMouse                                                                          m_mLoDefMouse;
00446 
00450                 CSoundManagerEx *                                                       m_smeSoundMan;
00451 
00455                 CAllocator                                                                      m_aSoundManAllocator;
00456 
00457 
00458                 // == Functions.
00464                 LSBOOL LSE_CALL                                                         TickLogic();
00465 
00475                 LSBOOL LSE_CALL                                                         SetState( LSUINT32 _ui32Id, LSUINTPTR _uptrUser, LSBOOL _bForce = false );
00476 
00485                 static LSVOID LSE_CALL                                          SoundEventHandler( LSUINTPTR _uiptrUserPtr, CSoundSource * _pssSource,
00486                         LSUINT32 _ui32EventType, CSoundManager * _psmManager );
00487         };
00488 
00489 
00490         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00491         // DEFINITIONS
00492         // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00493         // == Functions.
00500         LSE_INLINE const CTime & LSE_CALL CGame::GetTime() const {
00501                 return m_tTime;
00502         }
00503 
00509         LSE_INLINE const CTime & LSE_CALL CGame::GetRenderTime() const {
00510                 return m_tRenderTime;
00511         }
00512 
00516         LSE_INLINE LSBOOL LSE_CALL CGame::IsPaused() const {
00517                 return m_bPaused || m_smStateMachine.GetTotalStates() > 1;
00518         }
00519 
00525         LSE_INLINE LSINT32 LSE_CALL CGame::GetWidth() const {
00526                 return static_cast<LSUINT32>(m_i32Width);
00527         }
00528 
00534         LSE_INLINE LSINT32 LSE_CALL CGame::GetHeight() const {
00535                 return static_cast<LSUINT32>(m_i32Height);
00536         }
00537 
00543         LSE_INLINE LSREAL LSE_CALL CGame::GetWidthF() const {
00544                 return static_cast<LSREAL>(m_i32Width);
00545         }
00546 
00552         LSE_INLINE LSREAL LSE_CALL CGame::GetHeightF() const {
00553                 return static_cast<LSREAL>(m_i32Height);
00554         }
00555 
00561         LSE_INLINE LSREAL LSE_CALL CGame::GetHalfWidthF() const {
00562                 return static_cast<LSREAL>(m_i32Width) * LSM_HALF;
00563         }
00564 
00570         LSE_INLINE LSREAL LSE_CALL CGame::GetHalfHeightF() const {
00571                 return static_cast<LSREAL>(m_i32Height) * LSM_HALF;
00572         }
00573 
00579         LSE_INLINE LSBOOL LSE_CALL CGame::IsFullScreen() const {
00580                 return m_bFullScreen;
00581         }
00582 
00586         LSE_INLINE LSINT32 LSE_CALL CGame::GetCurStateId() const {
00587                 CCriticalSection::CLocker lLockMe( m_csCriticalSection );
00588                 return m_smStateMachine.GetCurStateId();
00589         }
00590         
00596         LSE_INLINE CState * LSE_CALL CGame::GetCurState() {
00597                 CCriticalSection::CLocker lLockMe( m_csCriticalSection );
00598                 return m_smStateMachine.GetCurState();
00599         }
00600         
00606         LSE_INLINE const CState * LSE_CALL CGame::GetCurState() const {
00607                 CCriticalSection::CLocker lLockMe( m_csCriticalSection );
00608                 return m_smStateMachine.GetCurState();
00609         }
00610 
00614         LSE_INLINE CSoundManagerEx & LSE_CALL CGame::GetSoundMan() {
00615                 return (*m_smeSoundMan);
00616         }
00617 
00618 }       // namespace lse
00619 
00620 #endif  // #ifndef __LSE_GAME_H__
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator