All pastes #964828 Raw Edit

Someone

public diff v1 · immutable
#964828 ·published 2008-03-31 16:13 UTC
rendered paste body
Index: PseuGUI.cpp===================================================================--- PseuGUI.cpp	(revision 263)+++ PseuGUI.cpp	(working copy)@@ -226,7 +226,7 @@ // called from ObjMgr::Add(Object*) void PseuGUI::NotifyObjectCreation(Object *o) {-    DrawObject *d = new DrawObject(_device,o);+    DrawObject *d = new DrawObject(_smgr,o,_guienv);     domgr.Add(o->GetGUID(),d); } Index: DrawObject.cpp===================================================================--- DrawObject.cpp	(revision 263)+++ DrawObject.cpp	(working copy)@@ -3,11 +3,13 @@ #include "DrawObject.h" #include "PseuWoW.h" -DrawObject::DrawObject(irr::scene::ISceneManager *smgr, Object *obj)+DrawObject::DrawObject(irr::scene::ISceneManager *smgr, Object *obj, irr::gui::IGUIEnvironment *gui) {     _smgr = smgr;     _obj = obj;-    DEBUG( logdebug("create DrawObject() this=%X obj=%X smgr=%X",this,_obj,_smgr) );+    _gui = gui;+    DEBUG( logdebug("create DrawObject() this=%X obj=%X smgr=%X type=%u guid="I64FMT,this,_obj,_smgr,_obj->GetTypeId(),_obj->GetGUID()) );+    _initialized=false; }  DrawObject::~DrawObject()@@ -15,7 +17,70 @@     DEBUG( logdebug("~DrawObject() this=%X obj=%X smgr=%X",this,_obj,_smgr) ); } +void DrawObject::Init()+{+    if(this->HasCoordinates()){+        cube = _smgr->addCubeSceneNode(5);+        logdebug ("Cube node created for object "I64FMT,_obj->GetGUID());+        if(_obj->GetName() != "")+        {+        iname=L"";+        iname +=_obj->GetName().c_str();+        }+        else{+        iname=L"null";}++        text=_smgr->addTextSceneNode(_gui->getBuiltInFont(), L"TestText" , irr::video::SColor(255,255,255,255),cube, irr::core::vector3df(0,5,0));+        text->setText(iname.c_str());+    //cube->setPosition(irr::core::vector3di(100,100,100));+    }+    _initialized=true;+}++bool DrawObject::HasCoordinates()+{+    if(_obj->IsUnit())+        return true;+    else+        return false;+}+ void DrawObject::Draw(void) {+    if(!_initialized)+    {+        Init();+        logdebug("Initializing object "I64FMT,_obj->GetGUID());+    }+    else+        {+    if(this->HasCoordinates())+    {+        //logdebug("Trying to get World Position for Object "I64FMT" Type %u",_obj->GetGUID(),_obj->GetTypeId());+        WorldPosition pos = ((WorldObject*)_obj)->GetPosition();+        //logdebug("Got position: x=%f y=%f z=%f",pos.x,pos.y,pos.z);+        float dx=pos.x * -5.0f - 26830.0f;+        float dy=-500;+        float dz=pos.y * -3.5f - 1066.0f;+        //logdebug("Setting position for cube %X",cube);+        cube->setPosition(irr::core::vector3df(dx,dy,dz));+        //logdebug("Position set");+        cube->getMaterial(0).DiffuseColor.set(255,255,0,0);+        if(iname==L"null")+        {+        logdebug("Trying to get Name for Object "I64FMT" Type %u",_obj->GetGUID(),_obj->GetTypeId());+        if(_obj->GetName() != "")+        {+        iname=L"";+        iname +=_obj->GetName().c_str();+        }+        else{+        iname=L"null";}+                text->setText(iname.c_str());+        } +    }+        }+ }+Index: DrawObject.h===================================================================--- DrawObject.h	(revision 263)+++ DrawObject.h	(working copy)@@ -1,6 +1,7 @@ #ifndef DRAWOBJECT_H #define DRAWOBJECT_H +#include "Object.h" #include "common.h" #include "irrlicht/irrlicht.h" @@ -9,15 +10,22 @@ class DrawObject { public:-    DrawObject(irr::scene::ISceneManager*, Object*);+    DrawObject(irr::scene::ISceneManager*, Object*, irr::gui::IGUIEnvironment*);     ~DrawObject();     void Draw(void); // call only in threadsafe environment!! (ensure the obj ptr is still valid!)     // additionally, we dont use a GetObject() func - that would fuck things up if the object was already deleted.+    bool HasCoordinates(); + private:+    void Init();+    bool _initialized;     Object *_obj;     irr::scene::ISceneManager *_smgr;-+    irr::gui::IGUIEnvironment *_gui;+    irr::scene::ISceneNode* cube;+    irr::scene::ITextSceneNode* text;+    irr::core::stringw iname; };  #endif