Changeset 12377 for code/branches
- Timestamp:
- May 16, 2019, 2:27:40 PM (6 years ago)
- Location:
- code/branches/MouseAPI_FS19
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/MouseAPI_FS19/data/levels/MouseAPIExample.oxw
r12363 r12377 10 10 include("HUDTemplates3.oxo") 11 11 include("MouseCursor.oxo") 12 include("tetrisHUD.oxo")13 12 include("templates/lodInformation.oxt") 14 ?>15 16 <?lua17 include("templates/spaceshipEscort.oxt")18 13 ?> 19 14 … … 23 18 <Template link=lodtemplate_default /> 24 19 </templates> 20 <!--<?lua include("includes/notifications.oxi") ?>--> 25 21 26 22 <Scene … … 51 47 </MouseAPIExample> 52 48 53 <!--<MouseAPICursor></MouseAPICursor>54 <MouseCursor></MouseCursor>-->55 49 </Scene> 56 50 </Level> -
code/branches/MouseAPI_FS19/data/overlays/MouseCursor.oxo
r12363 r12377 1 1 <Template name="MouseCursor"> 2 2 <OverlayGroup name = "MouseCursorGroup" scale = "1, 1"> 3 <MouseAPICursor name="cursor" position = "0, 0" size="0.03, 0.03" cursorShape="cursor.png" ></MouseAPICursor>3 <MouseAPICursor name="cursor" position = "0, 0" size="0.03, 0.03" cursorShape="cursor.png" cursorColor="1,0,1"></MouseAPICursor> 4 4 </OverlayGroup> 5 5 </Template> -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.cc
r12363 r12377 1 1 #include "mouseapi.h" 2 3 #if OGRE_VERSION >= 0x0109004 # include <Overlay/OgreOverlayManager.h>5 # include <Overlay/OgrePanelOverlayElement.h>6 #else7 # include <OgreOverlayManager.h>8 # include <OgrePanelOverlayElement.h>9 #endif10 11 #include "util/StringUtils.h"12 2 13 3 namespace orxonox{ … … 27 17 if(InputManager::exists()) 28 18 { 29 //cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera();30 19 state = InputManager::getInstance().createInputState("MouseAPI",true,true,99); 31 20 state->setMouseExclusive(false);//does this work 32 21 state->setMouseHandler(this); 22 gameInputActivated = false; 33 23 state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 34 24 InputManager::getInstance().enterState("guiMouseOnly"); 35 25 InputManager::getInstance().enterState("MouseAPI"); 36 26 InputManager::getInstance().setMouseExclusive("game",false); 37 //InputManager::getInstance().setMouseExclusive("guiMouseOnly",false); 38 //InputManager::getInstance().getState("game")-> 39 } 40 //GUIManager::getInstance().showGUI("MouseAPICursor", true);//Display a mouse cursor by displaying a empty menu 41 /*cursor = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 42 .createOverlayElement("Panel", "MouseAPI_cursor_" + getUniqueNumberString())); 43 cursor->setMaterialName("Orxonox/RadarMarker");//todo: better material 44 cursor->setPosition(0,0); 45 cursor->setDimensions(0.1,0.1); 46 Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create( "MouseAPI_cursor_" + getUniqueNumberString() ); 47 overlay->show();*/ 48 //this->overlay_->add2D(this->cursor); 27 } 49 28 } 50 29 … … 55 34 if(active) 56 35 { 57 GUIManager::getInstance().showGUI("MouseAPICursor", true);58 36 active = false; 59 37 if(InputManager::exists()) … … 66 44 clickEvents.clear(); 67 45 scrollEvents.clear(); 46 gameInputActivated=false; 68 47 } 69 48 } … … 76 55 void MouseAPI::buttonPressed(MouseButtonCode::ByEnum button) 77 56 { 78 cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //todo: trycatch57 cam = CameraManager::getInstance().getActiveCamera()->getOgreCamera(); 79 58 Ogre::Viewport *vp = GraphicsManager::getInstance().getViewport(); 80 59 int mouseposX = InputManager::getInstance().getMousePosition().first; … … 94 73 void MouseAPI::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 95 74 { 96 //mousePos = abs;97 75 } 98 76 99 77 void MouseAPI::tick(float dt) 100 78 { 101 if(active) 102 { 103 InputManager::getInstance().leaveState("game");//hack: todo: crate 2nd input state with prioritz 98 for cegui(cursor) 104 //GUIManager::getInstance().showGUI("MouseAPICursor", false);//hack todo: only if gui not shown & evt better if not in mouse mooved 79 if(active && !gameInputActivated) 80 { 81 InputManager::getInstance().leaveState("game"); 105 82 } 106 83 … … 239 216 } 240 217 241 //returns relative Position of the Mouse242 218 Vector2 MouseAPI::getMousePosition() 243 219 { … … 246 222 } 247 223 248 } 224 void MouseAPI::activateGameInput() 225 { 226 gameInputActivated = true; 227 state->setKeyHandler(nullptr); 228 } 229 230 void MouseAPI::deactivateGameInput() 231 { 232 gameInputActivated = false; 233 state->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler()); 234 } 235 236 } -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapi.h
r12363 r12377 2 2 #define MOUSEAPI_H 3 3 4 #include "OrxonoxPrereqs.h"5 #include "util/OgreForwardRefs.h"6 #include "graphics/Camera.h"4 #include <OrxonoxPrereqs.h> 5 #include <util/OgreForwardRefs.h> 6 #include <graphics/Camera.h> 7 7 #include <util/Math.h> 8 8 #include <list> … … 13 13 #include <OgreCamera.h> 14 14 #include <OgreViewport.h> 15 #include "CameraManager.h"15 #include <CameraManager.h> 16 16 #include <functional> 17 #include "core/GUIManager.h"18 #include "core/input/KeyBinderManager.h"19 #include "tools/interfaces/Tickable.h"20 #include "core/singleton/ScopedSingletonIncludes.h"17 #include <core/GUIManager.h> 18 #include <core/input/KeyBinderManager.h> 19 #include <tools/interfaces/Tickable.h> 20 #include <core/singleton/ScopedSingletonIncludes.h> 21 21 22 22 /* this class implements a basic mouse-api … … 35 35 * to make it work, one has to add mouseapi in LINK_LIBRARIES in the file CMakeLists.txt of the level 36 36 * see CMakeLists.txt in MouseAPIExample 37 * 38 * MouseAPI: C++ API to access Mouse 39 * MouseGametype: Enable Mouse Cursor & Prevent that each click kills Player if no spaceship is used 40 * MouseAPICursor: Internal API which implements cursor. Usable from custom Gametype (not necessary if MouseGametype is used): 41 * add "this->setHUDTemplate("MouseCursor");" in constructor of Gametype. (Or by inheritance) 37 42 */ 38 43 … … 96 101 bool active = false; 97 102 98 Ogre::PanelOverlayElement* cursor; 103 //true => allow ship-controller to get mouse input; Default: false; Gets reset after each transition from deactivated to activated 104 bool gameInputActivated = false; 105 99 106 100 107 public: … … 240 247 */ 241 248 void deactivate(); 249 250 /* 251 * allow ship-controller to get mouse input 252 */ 253 void activateGameInput(); 254 255 /* 256 * do not allow ship-controller to get mouse input 257 * This is the default. This gets set after each transition from deactivated to activated 258 */ 259 void deactivateGameInput(); 242 260 }; 243 261 } -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.cc
r12363 r12377 10 10 cursor = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 11 11 .createOverlayElement("Panel", "MouseAPI_cursor_" + getUniqueNumberString())); 12 cursor->setMaterialName(TextureGenerator::getMaterialName( 13 cursorname, Ogre::ColourValue::White)); 14 12 updateCursor(); 15 13 overlay_->add2D(this->cursor); 16 14 scale(Vector2(0.03,0.03)); … … 22 20 if(running) 23 21 MouseAPI::getInstance().deactivate(); 22 if(this->isInitialized()) 23 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->cursor); 24 24 } 25 25 … … 30 30 SUPER(MouseAPICursor, XMLPort, xmlelement, mode); 31 31 XMLPortParam(MouseAPICursor, "cursorShape", setCursorName, getCursorName,xmlelement, mode); 32 //XMLPortParam(MouseAPICursor, "cursorColor", setCursorColor, getCursorColor,xmlelement, mode);//TODO: ColoValue::setAsARGB()32 XMLPortParam(MouseAPICursor, "cursorColor", setCursorColor, getCursorColor,xmlelement, mode); 33 33 } 34 34 -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mouseapicursor.h
r12363 r12377 2 2 #define MOUSEAPICURSOR_H 3 3 #include <overlays/OrxonoxOverlay.h> 4 #include "core/CoreIncludes.h" 5 #include "tools/interfaces/Tickable.h" 6 #include "overlays/OverlayGroup.h" 4 #include <core/CoreIncludes.h> 5 #include <tools/interfaces/Tickable.h> 7 6 #include "mouseapi.h" 8 #include "core/XMLPort.h" 9 7 #include <core/XMLPort.h> 10 8 11 9 #if OGRE_VERSION >= 0x010900 … … 17 15 #endif 18 16 19 #include "tools/TextureGenerator.h"20 #include "util/StringUtils.h"17 #include <tools/TextureGenerator.h> 18 #include <util/StringUtils.h> 21 19 22 20 namespace orxonox{ … … 25 23 { 26 24 private: 25 //Pointer to the cursor overlay 27 26 Ogre::PanelOverlayElement* cursor; 27 //Is Cursor activated? 28 28 bool running = false; 29 //Name of the image-file used as the cursor shape 29 30 std::string cursorname = "cursor.png"; 31 //Color of the cursor 32 Vector3 color = {1,1,1}; 30 33 public: 31 34 MouseAPICursor(Context* context); 32 35 ~MouseAPICursor(); 36 //Update cursor position 33 37 virtual void tick(float dt) override; 38 //XMLPort: ability to set cursor shape & color 34 39 virtual void XMLPort(ticpp::Element &xmlelement, XMLPort::Mode mode) override; 40 //Update cursol look (shape & color) 41 inline void updateCursor(){ 42 cursor->setMaterialName(TextureGenerator::getMaterialName( 43 cursorname, Ogre::ColourValue(color[0],color[1],color[2],1))); 44 } 35 45 inline void setCursorName(const std::string& name) 36 46 { 37 47 cursorname = name; 38 cursor->setMaterialName(TextureGenerator::getMaterialName( 39 cursorname, Ogre::ColourValue::White)); 48 updateCursor(); 40 49 } 41 50 inline std::string getCursorName(void) const 42 51 { 43 52 return cursorname; 53 } 54 inline void setCursorColor(const Vector3& cl) 55 { 56 color = cl; 57 updateCursor(); 58 } 59 inline Vector3 getCursorColor(void) const 60 { 61 return color; 44 62 } 45 63 -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mousegametype.cc
r12363 r12377 8 8 player_ =nullptr; 9 9 10 //Activate the Mouse Cursor 10 11 this->setHUDTemplate("MouseCursor"); 11 12 … … 14 15 void MouseGametype::start() 15 16 { 16 bool temp = this->bForceSpawn_;17 this->bForceSpawn_ = true;18 19 // Call start for the parent class.20 17 Gametype::start(); 21 22 // Reset the variable.23 this->bForceSpawn_ = temp;24 25 18 } 26 19 … … 37 30 { 38 31 assert(player); 39 32 //Only Spawn once 40 33 if(this->player_ == nullptr) 41 34 { -
code/branches/MouseAPI_FS19/src/modules/MouseAPI/mousegametype.h
r12309 r12377 1 1 #ifndef MOUSEGAMETYPE_H 2 2 #define MOUSEGAMETYPE_H 3 #include "gametypes/Gametype.h"4 #include "core/CoreIncludes.h"5 #include "infos/PlayerInfo.h"3 #include <gametypes/Gametype.h> 4 #include <core/CoreIncludes.h> 5 #include <infos/PlayerInfo.h> 6 6 #include <core/input/InputState.h> 7 #include "core/GUIManager.h"7 #include <core/GUIManager.h> 8 8 9 9 namespace orxonox -
code/branches/MouseAPI_FS19/src/modules/MouseAPIExample/mouseapiexample.h
r12352 r12377 2 2 #define MOUSEAPIEXAMPLE_H 3 3 4 #include "core/XMLPort.h"5 #include "MouseAPI/mouseapi.h"6 #include "core/CoreIncludes.h"7 #include "worldentities/ControllableEntity.h"4 #include <core/XMLPort.h> 5 #include <MouseAPI/mouseapi.h> 6 #include <core/CoreIncludes.h> 7 #include <worldentities/ControllableEntity.h> 8 8 #include <list> 9 9
Note: See TracChangeset
for help on using the changeset viewer.