diff --git a/bin/data/misc/burninglogo.png b/bin/data/misc/burninglogo.png new file mode 100644 index 0000000..19cf8b3 Binary files /dev/null and b/bin/data/misc/burninglogo.png differ diff --git a/bin/data/misc/directxlogo.png b/bin/data/misc/directxlogo.png new file mode 100644 index 0000000..db5eff7 Binary files /dev/null and b/bin/data/misc/directxlogo.png differ diff --git a/bin/data/misc/irrlichtlogo.png b/bin/data/misc/irrlichtlogo.png new file mode 100644 index 0000000..9086b12 Binary files /dev/null and b/bin/data/misc/irrlichtlogo.png differ diff --git a/bin/data/misc/opengllogo.png b/bin/data/misc/opengllogo.png new file mode 100644 index 0000000..2e83726 Binary files /dev/null and b/bin/data/misc/opengllogo.png differ diff --git a/src/Client/DefScript/DefScript.cpp b/src/Client/DefScript/DefScript.cpp index 3006f03..f095d2d 100644 --- a/src/Client/DefScript/DefScript.cpp +++ b/src/Client/DefScript/DefScript.cpp @@ -89,7 +89,7 @@ void DefScriptPackage::_InitFunctions(void) AddFunc("shdn",&DefScriptPackage::func_shdn); AddFunc("loaddef",&DefScriptPackage::func_loaddef); AddFunc("reloaddef",&DefScriptPackage::func_reloaddef); - AddFunc("reloaddef",&DefScriptPackage::func_unloaddef); + AddFunc("unloaddef",&DefScriptPackage::func_unloaddef); AddFunc("setscriptpermission",&DefScriptPackage::func_setscriptpermission); AddFunc("toint",&DefScriptPackage::func_toint); AddFunc("add",&DefScriptPackage::func_add); diff --git a/src/Client/GUI/PseuGUI.cpp b/src/Client/GUI/PseuGUI.cpp index 0af09ce..c223182 100644 --- a/src/Client/GUI/PseuGUI.cpp +++ b/src/Client/GUI/PseuGUI.cpp @@ -3,25 +3,9 @@ #include "Object.h" #include "DrawObject.h" #include "PseuWoW.h" +#include "Scene.h" #include "PseuGUI.h" -using namespace irr; -using namespace core; -using namespace scene; -using namespace video; -using namespace io; -using namespace gui; - -enum DriverIDs -{ - NULLDEVICE = 0, - SOFTWARE = 1, - BURNINGSVIDEO = 2, - OPENGL = 3, - DIRECTX8 = 4, - DIRECTX9 = 5, -}; - PseuGUIRunnable::PseuGUIRunnable() { _gui = new PseuGUI(); @@ -53,6 +37,11 @@ PseuGUI::PseuGUI() _initialized = false; _mustdie = false; _driverType = video::EDT_BURNINGSVIDEO; // nulldevice makes not really a sense to display stuff + _scenestate = SCENESTATE_NULL; + _smgr = NULL; + _device = NULL; + _guienv = NULL; + _scene = NULL; } PseuGUI::~PseuGUI() @@ -108,6 +97,7 @@ void PseuGUI::_Init(void) _device->setWindowCaption(L"PseuWoW - Initializing"); _driver = _device->getVideoDriver(); _smgr = _device->getSceneManager(); + _guienv = _device->getGUIEnvironment(); //... _initialized = true; } @@ -115,12 +105,19 @@ void PseuGUI::_Init(void) void PseuGUI::Cancel(void) { DEBUG(logdebug("PseuGUI::Cancel()")); - _mustdie = true; + + if(_scene) + { + delete _scene; + _scene = NULL; + } if(_device) { _device->drop(); _device = NULL; + } + _mustdie = true; } void PseuGUI::Shutdown(void) @@ -149,9 +146,11 @@ void PseuGUI::Run(void) { _driver->beginScene(true, true, 0); - domgr.Update(); // iterate over DrawObjects, draw them and clean up + _UpdateSceneState(); + DrawCurrentScene(); _smgr->drawAll(); + _guienv->drawAll(); _driver->endScene(); } @@ -198,4 +197,39 @@ void PseuGUI::SetInstance(PseuInstance* in) _instance = in; } +void PseuGUI::SetSceneState(SceneState state) +{ + _scenestate_new = state; // will be applied at next cycle +} + +void PseuGUI::_UpdateSceneState(void) +{ + if(_scenestate != _scenestate_new && _smgr) + { + _smgr->clear(); + if(_scene) + delete _scene; + + _scenestate = _scenestate_new; + + logdebug("PseuGUI: switched to SceneState %u", _scenestate); + + switch (_scenestate) + { + case SCENESTATE_GUISTART: _scene = new SceneGuiStart(this); break; + case SCENESTATE_WORLD: _scene = new SceneWorld(this); break; + default: _scene = new Scene(this); // will draw nothing, just yield the gui + } + + logdebug("PseuGUI: scene created."); + } +} + +void PseuGUI::DrawCurrentScene() +{ + if(!_initialized) + return; + if(_scene) + _scene->Draw(); +} diff --git a/src/Client/GUI/PseuGUI.h b/src/Client/GUI/PseuGUI.h index 801d457..5ea49e2 100644 --- a/src/Client/GUI/PseuGUI.h +++ b/src/Client/GUI/PseuGUI.h @@ -7,6 +7,27 @@ class PseuGUI; class Object; class PseuInstance; +class Scene; + +enum SceneState +{ + SCENESTATE_NULL, + SCENESTATE_GUISTART, + SCENESTATE_LOGINSCREEN, + SCENESTATE_CHARACTERSELECTION, + SCENESTATE_LOADING, + SCENESTATE_WORLD +}; + +enum DriverIDs +{ + NULLDEVICE = 0, + SOFTWARE = 1, + BURNINGSVIDEO = 2, + OPENGL = 3, + DIRECTX8 = 4, + DIRECTX9 = 5, +}; class PseuGUIRunnable : public ZThread::Runnable { @@ -22,6 +43,12 @@ private: class PseuGUI { + // too bad friends are not inherited... + friend class Scene; + friend class SceneWorld; + friend class SceneGuiStart; + // ... + public: PseuGUI(); ~PseuGUI(); @@ -35,14 +62,21 @@ public: void UseShadows(bool); void Cancel(void); void Shutdown(void); + inline bool IsInitialized(void) { return _initialized; } + inline bool MustDie(void) { return _mustdie; } // interfaces to tell the gui what to draw void NotifyObjectDeletion(uint64 guid); void NotifyObjectCreation(Object *o); + // scenes + void DrawCurrentScene(void); + void SetSceneState(SceneState); + private: void _Init(void); + void _UpdateSceneState(void); uint16 _xres,_yres,_colordepth; bool _windowed,_vsync,_shadows; bool _initialized,_mustdie; @@ -53,6 +87,8 @@ private: irr::video::E_DRIVER_TYPE _driverType; DrawObjMgr domgr; PseuInstance *_instance; + SceneState _scenestate, _scenestate_new; + Scene *_scene; }; diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index c297096..e97be27 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -94,7 +94,8 @@ PseuInstance::~PseuInstance() bool PseuInstance::Init(void) { - log_prepare("logfile.txt",this); + log_prepare("logfile.txt","a"); + log_setloglevel(0); log(""); log("--- Initializing Instance ---"); @@ -185,10 +186,20 @@ bool PseuInstance::Init(void) void PseuInstance::Run(void) { - if(!_initialized) return; + logdetail("PseuInstance: Initialized and running!"); + + if(GetGUI()) + { + while(!GetGUI()->IsInitialized()) + Sleep(1); // wait until the gui is ready. it will crash otherwise + logdebug("GUI: switching to startup display..."); + GetGUI()->SetSceneState(SCENESTATE_GUISTART); + } + // TODO: as soon as username ans password can be inputted into the gui, wait until it was set by user. + if(GetConf()->realmlist.empty() || GetConf()->realmport==0) { logcritical("Realmlist address not set, can't connect."); @@ -404,6 +415,8 @@ void PseuInstanceConf::ApplyFromVarSet(VarSet &v) num+=opt.at(i); } } + + log_setloglevel(debug); } diff --git a/src/PseuWoW.vcproj b/src/PseuWoW.vcproj index e82068b..2af157a 100644 --- a/src/PseuWoW.vcproj +++ b/src/PseuWoW.vcproj @@ -177,12 +177,6 @@ - - - - @@ -426,6 +420,18 @@ + + + + + + + + + + + + diff --git a/src/shared/common.h b/src/shared/common.h index ff0efbb..e2707b0 100644 --- a/src/shared/common.h +++ b/src/shared/common.h @@ -26,6 +26,7 @@ #include "SysDefs.h" #include "DebugStuff.h" #include "tools.h" +#include "log.h" #include "ByteBuffer.h" diff --git a/src/Client/log.cpp b/src/shared/log.cpp similarity index 92% rename from src/Client/log.cpp rename to src/shared/log.cpp index 180e722..3851c80 100644 --- a/src/Client/log.cpp +++ b/src/shared/log.cpp @@ -1,16 +1,25 @@ #include #include "common.h" -#include "PseuWoW.h" #include "log.h" -PseuInstance *instance=NULL; +#if PLATFORM == PLATFORM_WIN32 +#include +#endif + FILE *logfile=NULL; +uint8 loglevel=0; -void log_prepare(char *fn, PseuInstance* p) +void log_prepare(char *fn, char *mode = NULL) { - logfile = fopen(fn,"a"); - instance = p; + if(!mode) + mode = "a"; + logfile = fopen(fn,mode); +} + +void log_setloglevel(uint8 lvl) +{ + loglevel = lvl; } void log(const char *str, ...) @@ -40,7 +49,7 @@ void log(const char *str, ...) void logdetail(const char *str, ...) { - if(!str || instance->GetConf()->debug < 1) + if(!str || loglevel < 1) return; va_list ap; _log_setcolor(true,LCYAN); @@ -65,7 +74,7 @@ void logdetail(const char *str, ...) void logdebug(const char *str, ...) { - if(!str || instance->GetConf()->debug < 2) + if(!str || loglevel < 2) return; va_list ap; _log_setcolor(true,LBLUE); @@ -91,7 +100,7 @@ void logdebug(const char *str, ...) void logdev(const char *str, ...) { - if(!str || instance->GetConf()->debug < 3) + if(!str || loglevel < 3) return; va_list ap; _log_setcolor(true,LMAGENTA); @@ -161,9 +170,9 @@ void logcritical(const char *str, ...) fflush(stdout); } -void logcustom(uint8 loglevel, Color color, const char *str, ...) +void logcustom(uint8 lvl, Color color, const char *str, ...) { - if(!str || instance->GetConf()->debug < loglevel) + if(!str || loglevel < lvl) return; va_list ap; _log_setcolor(true,color); diff --git a/src/Client/log.h b/src/shared/log.h similarity index 81% rename from src/Client/log.h rename to src/shared/log.h index e9e0925..d05d4e2 100644 --- a/src/Client/log.h +++ b/src/shared/log.h @@ -1,8 +1,6 @@ #ifndef _LOG_H #define _LOG_H -class PseuInstance; - enum Color { BLACK, @@ -22,7 +20,8 @@ enum Color WHITE }; -void log_prepare(char *fn, PseuInstance* p); // instance reference needed for log level determination +void log_prepare(char *fn, char *mode); +void log_setloglevel(uint8 lvl); void log(const char *str, ...); void logdetail(const char *str, ...); void logdebug(const char *str, ...);