From: <sv...@ww...> - 2004-12-18 11:32:36
|
Author: mkrose Date: 2004-12-18 03:32:30 -0800 (Sat, 18 Dec 2004) New Revision: 1408 Modified: trunk/CSP/CSPSim/CHANGES.current trunk/CSP/CSPSim/Include/GameScreen.h trunk/CSP/CSPSim/Source/GameScreen.cpp Log: Add hooks in GameScreen to catch player join/quit events and display a message on the screen. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1408 Modified: trunk/CSP/CSPSim/CHANGES.current =================================================================== --- trunk/CSP/CSPSim/CHANGES.current 2004-12-18 11:28:17 UTC (rev 1407) +++ trunk/CSP/CSPSim/CHANGES.current 2004-12-18 11:32:30 UTC (rev 1408) @@ -1,15 +1,19 @@ Version 0.4.0 (in progress) -=========================== - -2004-12-18: delta -* Until we make a more accurate FCS, we'll use the animation binding to - provide a better visual approximation of the animations of the "ailerons" - and "elevators". - -* Deflection limits are set to -16 deg and +25 deg. - -==> ALL USERS: run RebuildData.py. - +=========================== + +2004-12-18: onsight + * Add hooks in GameScreen to catch player join/quit events and display + a message on the screen. + +2004-12-18: delta + * Until we make a more accurate FCS, we'll use the animation binding to + provide a better visual approximation of the animations of the "ailerons" + and "elevators". + + * Deflection limits are set to -16 deg and +25 deg. + +==> ALL USERS: run RebuildData.py. + 2004-12-17: onsight * Add a message box to the onscreen display that displays/scrolls several lines of text, and fades out when unchanged for several seconds. @@ -30,10 +34,10 @@ * Updated FlightModel and m2k xml related files. ==> ALL USERS: run RebuildData.py. - + 2004-12-17: Lologramme * Add hangar - + 2004-12-16: Lologramme * add control tower @@ -62,17 +66,17 @@ 2004-12-15: delta * Moved the aircraft at start up to be at the bottom of the runway. - + 2004-12-14: onsight * Minor fix for the engine cutoff function under linux. 2004-12-13: Lologramme * Replace Runway by New runway with taxi and roads - + 2004-12-14: delta * Minor anti-warnings changes in SimCore/Battlefield/LocalBattlefield.cpp. - * Slighty flatten the joystick inputs. + * Slighty flatten the joystick inputs. * Other minor changes. Modified: trunk/CSP/CSPSim/Include/GameScreen.h =================================================================== --- trunk/CSP/CSPSim/Include/GameScreen.h 2004-12-18 11:28:17 UTC (rev 1407) +++ trunk/CSP/CSPSim/Include/GameScreen.h 2004-12-18 11:32:30 UTC (rev 1408) @@ -28,6 +28,7 @@ #include <osg/ref_ptr> #include <SimData/Ref.h> #include <SimData/ScopedPointer.h> +#include <SimCore/Util/CallbackDecl.h> #include "BaseScreen.h" class PyConsole; @@ -149,7 +150,7 @@ virtual void initInterface(); -protected: +private: size_t m_ViewMode; void setCamera(double dt); @@ -170,15 +171,11 @@ simdata::ScopedPointer<CameraAgent> m_CameraAgent; simdata::ScopedPointer<CameraCommands> m_CameraCommands; CameraCommand* m_CurrentCameraCommand; - /* - CameraCommand *m_PanLeft,*m_PanRight,*m_PanLeftRightStop; - CameraCommand *m_PanUp,*m_PanDown,*m_PanUpDownStop; - CameraCommand *m_ZoomIn,*m_ZoomOut,*m_ZoomStop,*m_ZoomStepIn,*m_ZoomStepOut; - MouseCommand* m_Mouse; - CameraCommand* m_CurrentCameraCommand; - void createCameraCommand(); - void deleteCameraCommands(); - */ + + void onPlayerJoin(int, const std::string&); + void onPlayerQuit(int, const std::string&); + simcore::ScopedCallback2<int, const std::string&> m_OnPlayerJoin; + simcore::ScopedCallback2<int, const std::string&> m_OnPlayerQuit; }; #endif // __GAMESCREEN_H__ Modified: trunk/CSP/CSPSim/Source/GameScreen.cpp =================================================================== --- trunk/CSP/CSPSim/Source/GameScreen.cpp 2004-12-18 11:28:17 UTC (rev 1407) +++ trunk/CSP/CSPSim/Source/GameScreen.cpp 2004-12-18 11:32:30 UTC (rev 1408) @@ -48,6 +48,7 @@ #include "VirtualScene.h" #include <SimCore/Battlefield/LocalBattlefield.h> +#include <SimCore/Util/Callback.h> #include <SimCore/Util/Log.h> /* @@ -182,13 +183,14 @@ m_ActiveObject(0), m_CameraAgent(new CameraAgent(ViewFactory())), m_CameraCommands(new CameraCommands), - m_CurrentCameraCommand(0) { + m_CurrentCameraCommand(0), + m_OnPlayerJoin(this, &GameScreen::onPlayerJoin), + m_OnPlayerQuit(this, &GameScreen::onPlayerQuit) +{ initInterface(); - //createCameraCommand(); } GameScreen::~GameScreen() { - //deleteCameraCommands(); m_CurrentCameraCommand = 0; } @@ -219,10 +221,26 @@ m_InfoView->setSceneData(m_InfoGroup.get()); simdata::Ref<DynamicObject> ao = CSPSim::theSim->getActiveObject(); - if (ao.valid()) + if (ao.valid()) { setActiveObject(ao); + } + + LocalBattlefield *bf = CSPSim::theSim->getBattlefield(); + if (bf) { + bf->registerPlayerJoinCallback(*m_OnPlayerJoin); + bf->registerPlayerQuitCallback(*m_OnPlayerQuit); + } } +void GameScreen::onPlayerJoin(int, const std::string& name) { + m_ScreenInfoManager->addMessage(name + " has joined the game"); +} + +void GameScreen::onPlayerQuit(int, const std::string& name) { + m_ScreenInfoManager->addMessage(name + " has left the game"); +} + + void GameScreen::onExit() { } |