CHANGED: #1471 Don't execute action handlers and/or Lua scripts in editor mode. Warning log message when trying to look up non-existent action handlers.
This commit is contained in:
parent
2dc85e1136
commit
c2b902250f
5 changed files with 29 additions and 1 deletions
|
@ -72,7 +72,13 @@ namespace NLGUI
|
||||||
IActionHandler *getActionHandler(const std::string &name) const
|
IActionHandler *getActionHandler(const std::string &name) const
|
||||||
{
|
{
|
||||||
TFactoryMap::const_iterator it = FactoryMap.find(name);
|
TFactoryMap::const_iterator it = FactoryMap.find(name);
|
||||||
return it != FactoryMap.end() ? it->second : NULL;
|
if( it == FactoryMap.end() )
|
||||||
|
{
|
||||||
|
nlwarning( "Couldn't find action handler %s", name.c_str() );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the name of the action handler given its pointer
|
/// Return the name of the action handler given its pointer
|
||||||
|
@ -110,10 +116,12 @@ namespace NLGUI
|
||||||
|
|
||||||
// Submit a generic event
|
// Submit a generic event
|
||||||
void submitEvent( const std::string &evt );
|
void submitEvent( const std::string &evt );
|
||||||
|
static void setEditorMode( bool b ){ editorMode = b; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CAHManager(){}
|
CAHManager(){}
|
||||||
static CAHManager *_GlobalInstance;
|
static CAHManager *_GlobalInstance;
|
||||||
|
static bool editorMode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,14 @@ namespace NLGUI
|
||||||
/// Forces the Garbage Collector to run.
|
/// Forces the Garbage Collector to run.
|
||||||
void forceGarbageCollect();
|
void forceGarbageCollect();
|
||||||
|
|
||||||
|
static void setEditorMode( bool b ){ editorMode = b; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CLuaManager();
|
CLuaManager();
|
||||||
|
|
||||||
static CLuaManager *instance;
|
static CLuaManager *instance;
|
||||||
static bool debugLua;
|
static bool debugLua;
|
||||||
|
static bool editorMode;
|
||||||
|
|
||||||
NLGUI::CLuaState *luaState;
|
NLGUI::CLuaState *luaState;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace NLGUI
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CAHManager *CAHManager::_GlobalInstance = NULL;
|
CAHManager *CAHManager::_GlobalInstance = NULL;
|
||||||
|
bool CAHManager::editorMode = false;
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -210,6 +211,9 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
if (ahCmdLine.empty()) return;
|
if (ahCmdLine.empty()) return;
|
||||||
|
|
||||||
|
if( editorMode )
|
||||||
|
return;
|
||||||
|
|
||||||
// Special AH form ("ah:params") ?
|
// Special AH form ("ah:params") ?
|
||||||
string::size_type i = ahCmdLine.find(':');
|
string::size_type i = ahCmdLine.find(':');
|
||||||
string ahName;
|
string ahName;
|
||||||
|
@ -259,6 +263,10 @@ namespace NLGUI
|
||||||
nlwarning ("no action handler");
|
nlwarning ("no action handler");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( editorMode )
|
||||||
|
return;
|
||||||
|
|
||||||
pAH->execute (pCaller, Params);
|
pAH->execute (pCaller, Params);
|
||||||
string AHName = CAHManager::getInstance()->getAHName(pAH);
|
string AHName = CAHManager::getInstance()->getAHName(pAH);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ namespace NLGUI
|
||||||
{
|
{
|
||||||
|
|
||||||
bool CLuaManager::debugLua = false;
|
bool CLuaManager::debugLua = false;
|
||||||
|
bool CLuaManager::editorMode = false;
|
||||||
CLuaManager* CLuaManager::instance = NULL;
|
CLuaManager* CLuaManager::instance = NULL;
|
||||||
|
|
||||||
CLuaManager::CLuaManager()
|
CLuaManager::CLuaManager()
|
||||||
|
@ -37,6 +38,9 @@ namespace NLGUI
|
||||||
|
|
||||||
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
|
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
|
||||||
{
|
{
|
||||||
|
if( editorMode )
|
||||||
|
return true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( smallScript )
|
if( smallScript )
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "nel/gui/view_renderer.h"
|
#include "nel/gui/view_renderer.h"
|
||||||
#include "nel/gui/interface_group.h"
|
#include "nel/gui/interface_group.h"
|
||||||
#include "nel/gui/widget_manager.h"
|
#include "nel/gui/widget_manager.h"
|
||||||
|
#include "nel/gui/action_handler.h"
|
||||||
|
#include "nel/gui/lua_manager.h"
|
||||||
#include "nel/misc/path.h"
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/i18n.h"
|
#include "nel/misc/i18n.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -58,6 +60,9 @@ namespace GUIEditor
|
||||||
Nel3DWidget::init();
|
Nel3DWidget::init();
|
||||||
createTextContext( "Ryzom.ttf" );
|
createTextContext( "Ryzom.ttf" );
|
||||||
|
|
||||||
|
NLGUI::CAHManager::setEditorMode( true );
|
||||||
|
NLGUI::CLuaManager::setEditorMode( true );
|
||||||
|
|
||||||
NLGUI::CViewRenderer::setDriver( getDriver() );
|
NLGUI::CViewRenderer::setDriver( getDriver() );
|
||||||
NLGUI::CViewRenderer::setTextContext( getTextContext() );
|
NLGUI::CViewRenderer::setTextContext( getTextContext() );
|
||||||
NLGUI::CViewRenderer::hwCursors = &hwCursors;
|
NLGUI::CViewRenderer::hwCursors = &hwCursors;
|
||||||
|
|
Loading…
Reference in a new issue