From: Brad A. <br...@us...> - 2012-08-11 16:54:21
|
gemrb: Infinity Engine emulator The branch master has been updated via 394b67bd6036c0db62bf36afaaae61c538018b62 (commit) via ce3ffe068cbfc3b831c62e7a762d49267fc643b8 (commit) via 89cb7468709596185e28d302acbfca2151be727d (commit) via 7467ec5a6daafc8b0c615e72a940c12c8a5df92b (commit) via 997134a482a6665c1eb39e1585334a19489f6633 (commit) via 49ebbee131f294e2554ca777db841ad78b249e16 (commit) Summary of changes: apple/GemRB.xcodeproj/project.pbxproj | 8 ++ gemrb/GUIScripts/include.py | 3 + gemrb/core/CMakeLists.txt | 1 + gemrb/core/DialogHandler.cpp | 1 + gemrb/core/DisplayMessage.cpp | 2 +- gemrb/core/GUI/TextArea.cpp | 16 ++- gemrb/core/System/Logger/MessageWindowLogger.cpp | 114 ++++++++++++++++++++ .../System/Logger/MessageWindowLogger.h} | 42 +++----- gemrb/core/System/Logging.cpp | 16 +++ gemrb/core/System/Logging.h | 1 + gemrb/plugins/GUIScript/GUIScript.cpp | 22 ++++ 11 files changed, 192 insertions(+), 34 deletions(-) create mode 100644 gemrb/core/System/Logger/MessageWindowLogger.cpp copy gemrb/{plugins/VLCPlayer/VideoContext.h => core/System/Logger/MessageWindowLogger.h} (62%) from 5c80b7e4e5ce64ca690ae0a0c34833e273e11d6b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=394b67bd6036c0db62bf36afaaae61c538018b62 commit 394b67bd6036c0db62bf36afaaae61c538018b62 Merge: 5c80b7e ce3ffe0 Author: Brad Allred <bra...@me...> Date: Sat Aug 11 10:54:02 2012 -0600 Merge branch 'MessageWindowLogger' http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=ce3ffe068cbfc3b831c62e7a762d49267fc643b8 commit ce3ffe068cbfc3b831c62e7a762d49267fc643b8 Author: Brad Allred <bra...@me...> Date: Fri Aug 10 19:20:48 2012 -0600 TextArea: prevent recursion when using a MessageWindowLogger diff --git a/gemrb/core/DialogHandler.cpp b/gemrb/core/DialogHandler.cpp index 3c29697..0dd5889 100644 --- a/gemrb/core/DialogHandler.cpp +++ b/gemrb/core/DialogHandler.cpp @@ -118,6 +118,7 @@ bool DialogHandler::InitDialog(Scriptable* spk, Scriptable* tgt, const char* dlg //no exploring while in dialogue gc->SetScreenFlags(/*SF_GUIENABLED|*/SF_DISABLEMOUSE|SF_LOCKSCROLL, BM_OR); + Log(WARNING, "DialogHandler", "Errors occuring while in dialog mode cannot be logged in the MessageWindow."); gc->SetDialogueFlags(DF_IN_DIALOG, BM_OR); if (tgt->Type==ST_ACTOR) { diff --git a/gemrb/core/GUI/TextArea.cpp b/gemrb/core/GUI/TextArea.cpp index afc8cfd..96d9c72 100644 --- a/gemrb/core/GUI/TextArea.cpp +++ b/gemrb/core/GUI/TextArea.cpp @@ -451,11 +451,17 @@ void TextArea::UpdateControls() SetRow(pos); } } - // This hack is to refresh the mouse cursor so that reply below cursor gets - // highlighted during a dialog - int x,y; - core->GetVideoDriver()->GetMousePos(x,y); - core->GetEventMgr()->MouseMove(x,y); + + GameControl* gc = core->GetGameControl(); + if (gc && gc->GetDialogueFlags()&DF_IN_DIALOG) { + // This hack is to refresh the mouse cursor so that reply below cursor gets + // highlighted during a dialog + // FIXME: we check DF_IN_DIALOG here to avoid recurssion in the MessageWindowLogger, but what happens when an error happens during dialog? + // I'm not super sure about how to avoid that. for now the logger will not log anything in dialog mode. + int x,y; + core->GetVideoDriver()->GetMousePos(x,y); + core->GetEventMgr()->MouseMove(x,y); + } core->RedrawAll(); } http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=89cb7468709596185e28d302acbfca2151be727d commit 89cb7468709596185e28d302acbfca2151be727d Author: Brad Allred <bra...@me...> Date: Fri Aug 10 19:20:13 2012 -0600 Add a GUIScript command to add/remove a MessageWindowLogger diff --git a/gemrb/GUIScripts/include.py b/gemrb/GUIScripts/include.py index 230f490..09b71db 100644 --- a/gemrb/GUIScripts/include.py +++ b/gemrb/GUIScripts/include.py @@ -11,6 +11,9 @@ def sps(stat, value, pcf=1): def mta(area): GemRB.MoveToArea(area) +def debug(toggle): + GemRB.MessageWindowDebug(toggle) + def cc(cre, px=-1, py=-1): GemRB.CreateCreature(GemRB.GameGetFirstSelectedPC(), cre, px, py) diff --git a/gemrb/core/DisplayMessage.cpp b/gemrb/core/DisplayMessage.cpp index fde11a7..7e7fef6 100644 --- a/gemrb/core/DisplayMessage.cpp +++ b/gemrb/core/DisplayMessage.cpp @@ -30,7 +30,7 @@ namespace GemRB { -GEM_EXPORT DisplayMessage * displaymsg; +GEM_EXPORT DisplayMessage * displaymsg = NULL; static int strref_table[STRREF_COUNT]; diff --git a/gemrb/plugins/GUIScript/GUIScript.cpp b/gemrb/plugins/GUIScript/GUIScript.cpp index 7e1a37c..6cca25d 100644 --- a/gemrb/plugins/GUIScript/GUIScript.cpp +++ b/gemrb/plugins/GUIScript/GUIScript.cpp @@ -59,6 +59,7 @@ #include "Scriptable/Door.h" #include "Scriptable/InfoPoint.h" #include "System/FileStream.h" +#include "System/Logger/MessageWindowLogger.h" #include "System/VFS.h" #include <cstdio> @@ -6530,6 +6531,26 @@ static PyObject* GemRB_UpdateAmbientsVolume(PyObject * /*self*/, PyObject* /*arg return Py_None; } +PyDoc_STRVAR( GemRB_MessageWindowDebug__doc, + "MessageWindowDebug(1/0)\n\n" + "Enable/Disable debug messages in the MessageWindow." ); + +static PyObject* GemRB_MessageWindowDebug(PyObject * /*self*/, PyObject* args) +{ + int enable; + if (!PyArg_ParseTuple( args, "i", &enable )) { + return AttributeError( GemRB_MessageWindowDebug__doc ); + } + if (enable && getMessageWindowLogger() == NULL) { + AddLogger(createMessageWindowLogger()); + } else if (!enable && getMessageWindowLogger() != NULL) { + RemoveLogger(getMessageWindowLogger()); + } + + Py_INCREF( Py_None ); + return Py_None; +} + PyDoc_STRVAR( GemRB_GetCurrentArea__doc, "GetCurrentArea()=>resref\n\n" "Returns current area's ResRef." ); @@ -10244,6 +10265,7 @@ static PyMethodDef GemRBMethods[] = { METHOD(GetMemorizableSpellsCount, METH_VARARGS), METHOD(GetMemorizedSpell, METH_VARARGS), METHOD(GetMemorizedSpellsCount, METH_VARARGS), + METHOD(MessageWindowDebug, METH_VARARGS), METHOD(GetMessageWindowSize, METH_NOARGS), METHOD(GetPartySize, METH_NOARGS), METHOD(GetPCStats, METH_VARARGS), http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=7467ec5a6daafc8b0c615e72a940c12c8a5df92b commit 7467ec5a6daafc8b0c615e72a940c12c8a5df92b Author: Brad Allred <bra...@me...> Date: Fri Aug 10 19:17:16 2012 -0600 Add a MessageWindowLogger class diff --git a/gemrb/core/System/Logger/MessageWindowLogger.cpp b/gemrb/core/System/Logger/MessageWindowLogger.cpp index de224ca..4327e4c 100644 --- a/gemrb/core/System/Logger/MessageWindowLogger.cpp +++ b/gemrb/core/System/Logger/MessageWindowLogger.cpp @@ -27,10 +27,13 @@ namespace GemRB { MessageWindowLogger* mwl = NULL; MessageWindowLogger::MessageWindowLogger() -{} +{ + PrintStatus(true); +} MessageWindowLogger::~MessageWindowLogger() { + PrintStatus(false); assert(mwl == this); mwl = NULL; } @@ -58,7 +61,7 @@ void MessageWindowLogger::log(log_level level, const char* owner, const char* me "[color=BFEFFF]", // LIGHT_BLUE "[color=FF00FF]", // LIGHT_MAGENTA "[color=B4CDCD]", // LIGHT_CYAN - "[color=CDCDCD]" // LIGHT_WHITE / GREY + "[color=CDCDCD]" // LIGHT_WHITE }; static log_color log_level_color[] = { RED, @@ -69,6 +72,10 @@ void MessageWindowLogger::log(log_level level, const char* owner, const char* me BLUE }; + if (level < 0) { + // re-assign our internal message level to the real one + level = MESSAGE; + } const char* fmt = "%s%s: [/color]%s%s[/color]"; char* msg = (char*)malloc(strlen(message) + strlen(owner) + 45); sprintf(msg, fmt, colors[color], owner, colors[log_level_color[level]], message); @@ -78,6 +85,17 @@ void MessageWindowLogger::log(log_level level, const char* owner, const char* me } } +void MessageWindowLogger::PrintStatus(bool toggle) +{ + // log_level -1 is a special internal level. + // this way we can print messages sine we have to ignore standard logged messages + if (toggle) { + log( (log_level)-1, "Logger", "MessageWindow logging active.", LIGHT_GREEN); + } else { + log( (log_level)-1, "Logger", "MessageWindow logging disabled.", LIGHT_RED); + } +} + // this MUST be a singleton. we only have one message window and multiple messages to that window are useless // additionally GUIScript doesnt check its existance and simply calls this function whenever the command is given Logger* createMessageWindowLogger() diff --git a/gemrb/core/System/Logger/MessageWindowLogger.h b/gemrb/core/System/Logger/MessageWindowLogger.h index 6cebabf..28c6484 100644 --- a/gemrb/core/System/Logger/MessageWindowLogger.h +++ b/gemrb/core/System/Logger/MessageWindowLogger.h @@ -28,10 +28,8 @@ namespace GemRB { virtual ~MessageWindowLogger(); void log(log_level level, const char* owner, const char* message, log_color color); - protected: - void print(const char*); private: - void printStatus(const char* status, log_color color); + void PrintStatus(bool); }; Logger* createMessageWindowLogger(); http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=997134a482a6665c1eb39e1585334a19489f6633 commit 997134a482a6665c1eb39e1585334a19489f6633 Author: Brad Allred <bra...@me...> Date: Fri Aug 10 19:17:34 2012 -0600 Logging: add a method to remove loggers diff --git a/gemrb/core/System/Logging.cpp b/gemrb/core/System/Logging.cpp index 8b80ec6..bdaf08b 100644 --- a/gemrb/core/System/Logging.cpp +++ b/gemrb/core/System/Logging.cpp @@ -47,6 +47,22 @@ void AddLogger(Logger* logger) theLogger.push_back(logger); } +void RemoveLogger(Logger* logger) +{ + if (logger) { + std::vector<Logger*>::iterator itr = theLogger.begin(); + while (itr != theLogger.end()) { + if (*itr == logger) { + itr = theLogger.erase(itr); + } else { + itr++; + } + } + logger->destroy(); + logger = NULL; + } +} + static void vLog(log_level level, const char* owner, const char* message, log_color color, va_list ap) { if (theLogger.empty()) diff --git a/gemrb/core/System/Logging.h b/gemrb/core/System/Logging.h index 740066e..9005172 100644 --- a/gemrb/core/System/Logging.h +++ b/gemrb/core/System/Logging.h @@ -49,6 +49,7 @@ class StringBuffer; GEM_EXPORT void InitializeLogging(); GEM_EXPORT void AddLogger(Logger*); +GEM_EXPORT void RemoveLogger(Logger*); GEM_EXPORT void ShutdownLogging(); #if defined(__GNUC__) http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=49ebbee131f294e2554ca777db841ad78b249e16 commit 49ebbee131f294e2554ca777db841ad78b249e16 Author: Brad Allred <bra...@me...> Date: Fri Aug 10 19:17:16 2012 -0600 Add a MessageWindowLogger class diff --git a/apple/GemRB.xcodeproj/project.pbxproj b/apple/GemRB.xcodeproj/project.pbxproj index ea29f50..6fcda1f 100644 --- a/apple/GemRB.xcodeproj/project.pbxproj +++ b/apple/GemRB.xcodeproj/project.pbxproj @@ -97,6 +97,8 @@ A22DCCE114A8FE120067D6D1 /* ios/Ic...@2x...g in Resources */ = {isa = PBXBuildFile; fileRef = A22DCCE014A8FE120067D6D1 /* ios/Ic...@2x...g */; }; A22DCCE314A8FE870067D6D1 /* ios/Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = A22DCCE214A8FE870067D6D1 /* ios/Icon-72.png */; }; A22EBDCE14FF18030029C9C1 /* AppleLogger.mm in Sources */ = {isa = PBXBuildFile; fileRef = A22EBDCD14FF18030029C9C1 /* AppleLogger.mm */; }; + A230584915D5BBCC00BDF69C /* MessageWindowLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A230584715D5BBCC00BDF69C /* MessageWindowLogger.cpp */; }; + A230584A15D5BBCC00BDF69C /* MessageWindowLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = A230584815D5BBCC00BDF69C /* MessageWindowLogger.h */; }; A238174B14B781F00058BFF4 /* GemRB.cfg.newinstall in Resources */ = {isa = PBXBuildFile; fileRef = A238174914B781CC0058BFF4 /* GemRB.cfg.newinstall */; }; A239390B145F8677007895B3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A239390A145F8677007895B3 /* UIKit.framework */; }; A23EBFFA141979D500CC049E /* KeyMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A265ECDA13A8661600C6DF12 /* KeyMap.cpp */; }; @@ -1142,6 +1144,8 @@ A22DCCE214A8FE870067D6D1 /* ios/Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ios/Icon-72.png"; sourceTree = "<group>"; }; A22EBDCC14FF18030029C9C1 /* AppleLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppleLogger.h; sourceTree = "<group>"; }; A22EBDCD14FF18030029C9C1 /* AppleLogger.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppleLogger.mm; sourceTree = "<group>"; }; + A230584715D5BBCC00BDF69C /* MessageWindowLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MessageWindowLogger.cpp; sourceTree = "<group>"; }; + A230584815D5BBCC00BDF69C /* MessageWindowLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageWindowLogger.h; sourceTree = "<group>"; }; A238174914B781CC0058BFF4 /* GemRB.cfg.newinstall */ = {isa = PBXFileReference; lastKnownFileType = text; name = GemRB.cfg.newinstall; path = ios/GemRB.cfg.newinstall; sourceTree = "<group>"; }; A239390A145F8677007895B3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; A2462F1113A036B1002D1F02 /* AREImporter.so */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = AREImporter.so; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -3037,6 +3041,8 @@ A2CB5AC215000A0D00B5C154 /* File.h */, A298DD2114EB61D300F59F56 /* Stdio.cpp */, A298DD1B14EB61C100F59F56 /* Stdio.h */, + A230584715D5BBCC00BDF69C /* MessageWindowLogger.cpp */, + A230584815D5BBCC00BDF69C /* MessageWindowLogger.h */, ); path = Logger; sourceTree = "<group>"; @@ -3192,6 +3198,7 @@ A298DD1D14EB61C100F59F56 /* Stdio.h in Headers */, A2C76D2C14F196E900961680 /* StringBuffer.h in Headers */, A2CB5AC515000A0D00B5C154 /* File.h in Headers */, + A230584A15D5BBCC00BDF69C /* MessageWindowLogger.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4904,6 +4911,7 @@ A298DD2214EB61D300F59F56 /* Stdio.cpp in Sources */, A2C76D2A14F196E900961680 /* StringBuffer.cpp in Sources */, A2CB5AC315000A0D00B5C154 /* File.cpp in Sources */, + A230584915D5BBCC00BDF69C /* MessageWindowLogger.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/gemrb/core/CMakeLists.txt b/gemrb/core/CMakeLists.txt index c542248..279ac86 100644 --- a/gemrb/core/CMakeLists.txt +++ b/gemrb/core/CMakeLists.txt @@ -128,6 +128,7 @@ FILE(GLOB gemrb_core_LIB_SRCS System/StringBuffer.cpp System/Logger.cpp System/Logger/File.cpp + System/Logger/MessageWindowLogger.cpp System/Logger/Stdio.cpp System/Logging.cpp System/SlicedStream.cpp diff --git a/gemrb/core/System/Logger/MessageWindowLogger.cpp b/gemrb/core/System/Logger/MessageWindowLogger.cpp new file mode 100644 index 0000000..de224ca --- /dev/null +++ b/gemrb/core/System/Logger/MessageWindowLogger.cpp @@ -0,0 +1,96 @@ +/* GemRB - Infinity Engine Emulator + * Copyright (C) 2012 The GemRB Project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "MessageWindowLogger.h" + +#include "DisplayMessage.h" +#include "GUI/GameControl.h" +#include "Interface.h" + +namespace GemRB { + +MessageWindowLogger* mwl = NULL; + +MessageWindowLogger::MessageWindowLogger() +{} + +MessageWindowLogger::~MessageWindowLogger() +{ + assert(mwl == this); + mwl = NULL; +} + +void MessageWindowLogger::log(log_level level, const char* owner, const char* message, log_color color) +{ + if (displaymsg) { + GameControl* gc = core->GetGameControl(); + if (level < MESSAGE && gc && !(gc->GetDialogueFlags()&DF_IN_DIALOG)) { + // FIXME: we check DF_IN_DIALOG here to avoid recurssion in the MessageWindowLogger, but what happens when an error happens during dialog? + // I'm not super sure about how to avoid that. for now the logger will not log anything in dialog mode. + static const char* colors[] = { + "[color=FFFFFF]", // DEFAULT + "[color=000000]", // BLACK + "[color=FF0000]", // RED + "[color=00FF00]", // GREEN + "[color=603311]", // BROWN + "[color=0000FF]", // BLUE + "[color=8B008B]", // MAGENTA + "[color=00CDCD]", // CYAN + "[color=FFFFFF]", // WHITE + "[color=CD5555]", // LIGHT_RED + "[color=90EE90]", // LIGHT_GREEN + "[color=FFFF00]", // YELLOW + "[color=BFEFFF]", // LIGHT_BLUE + "[color=FF00FF]", // LIGHT_MAGENTA + "[color=B4CDCD]", // LIGHT_CYAN + "[color=CDCDCD]" // LIGHT_WHITE / GREY + }; + static log_color log_level_color[] = { + RED, + RED, + YELLOW, + LIGHT_WHITE, + GREEN, + BLUE + }; + + const char* fmt = "%s%s: [/color]%s%s[/color]"; + char* msg = (char*)malloc(strlen(message) + strlen(owner) + 45); + sprintf(msg, fmt, colors[color], owner, colors[log_level_color[level]], message); + displaymsg->DisplayString(msg); + free(msg); + } + } +} + +// this MUST be a singleton. we only have one message window and multiple messages to that window are useless +// additionally GUIScript doesnt check its existance and simply calls this function whenever the command is given +Logger* createMessageWindowLogger() +{ + if (!mwl) { + mwl = new MessageWindowLogger(); + } + return mwl; +} + +Logger* getMessageWindowLogger() +{ + return mwl; +} + +} diff --git a/gemrb/core/System/Logger/MessageWindowLogger.h b/gemrb/core/System/Logger/MessageWindowLogger.h new file mode 100644 index 0000000..6cebabf --- /dev/null +++ b/gemrb/core/System/Logger/MessageWindowLogger.h @@ -0,0 +1,41 @@ +/* GemRB - Infinity Engine Emulator + * Copyright (C) 2012 The GemRB Project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef __GemRB__MessageWindowLogger__ +#define __GemRB__MessageWindowLogger__ + +#include "System/Logger.h" // for log_color + +namespace GemRB { + + class GEM_EXPORT MessageWindowLogger : public Logger { + public: + MessageWindowLogger(); + virtual ~MessageWindowLogger(); + + void log(log_level level, const char* owner, const char* message, log_color color); + protected: + void print(const char*); + private: + void printStatus(const char* status, log_color color); + }; + + Logger* createMessageWindowLogger(); + Logger* getMessageWindowLogger(); +} + +#endif /* defined(__GemRB__MessageWindowLogger__) */ ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |