From 1bd487445a8ca17ba9375f02c93d8714e6d1e7da Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Sat, 8 Dec 2007 14:26:56 +0000 Subject: [PATCH] * added new var in ScriptConfig.conf: OnGUIClose=0 -> set to 1 to close PseuWoW when the GUI is closed --- bin/conf/ScriptConfig.conf.default | 3 +++ bin/scripts/__core_internal.def | 11 +++++++++++ src/Client/PseuWoW.cpp | 3 +++ 3 files changed, 17 insertions(+) diff --git a/bin/conf/ScriptConfig.conf.default b/bin/conf/ScriptConfig.conf.default index b438b5e..0dc7f7a 100644 --- a/bin/conf/ScriptConfig.conf.default +++ b/bin/conf/ScriptConfig.conf.default @@ -15,6 +15,9 @@ cmdchar=. // MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command! other_cmd_chars=.! +// Set to 1 if PseuWoW should exit after the GUI is closed (if there is a GUI) +ExitOnGUIClose=0 + [#normal] diff --git a/bin/scripts/__core_internal.def b/bin/scripts/__core_internal.def index 8149060..8e49cfb 100644 --- a/bin/scripts/__core_internal.def +++ b/bin/scripts/__core_internal.def @@ -103,6 +103,16 @@ LOG * Assigning permissions for internal functions... setscriptpermission,emote 0 // ... set more permissions here ... +//------------------------------------------------- +#script=register_onguiclose_exit +//------------------------------------------------- +if ?{not ?{ScriptHasLine,_onguiclose #tag:hook:${@myname}}} + appenddef,_onguiclose #tag:hook:${@myname} + appenddef,_onguiclose if ?\{GetVar #EXITONGUICLOSE\} + appenddef,_onguiclose exit + appenddef,_onguiclose endif +endif + // this dummy script does nothing actually but since its loaded last in this file it causes the config // script to be run before all .def files are loaded @@ -114,5 +124,6 @@ setscriptpermission,emote 0 if ?{not ${#config::DONE}} config endif +register_onguiclose_exit #/onload diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index ca7429b..d9e0a56 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -371,7 +371,10 @@ void PseuInstance::Sleep(uint32 msecs) void PseuInstance::DeleteGUI(void) { _gui = NULL; + delete _guithread; // since it was allocated with new _guithread = NULL; + if(GetScripts()->ScriptExists("_onguiclose")) + AddCliCommand("_onguiclose"); // since this func is called from another thread, use threadsafe variant via CLI } PseuInstanceConf::PseuInstanceConf()