CHANGED: #1471 Moved CProcedure code to it's own files, and also moved the procedure handling code from CInterfaceManager to CWidgetManager.
This commit is contained in:
parent
e24b0b1125
commit
cdbcadcbaa
14 changed files with 349 additions and 286 deletions
|
@ -25,6 +25,7 @@
|
|||
#include "nel/gui/interface_link.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/gui/lua_helper.h"
|
||||
#include "nel/gui/proc.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
|
||||
namespace NLGUI
|
||||
|
@ -230,6 +231,8 @@ namespace NLGUI
|
|||
|
||||
CInterfaceAnim* getAnim( const std::string &name ) const;
|
||||
|
||||
CProcedure* getProc( const std::string &name );
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -260,49 +263,6 @@ namespace NLGUI
|
|||
|
||||
bool validDefineChar(char c) const;
|
||||
|
||||
/// Procedure def
|
||||
class CParamBlock
|
||||
{
|
||||
public:
|
||||
// -1 if not a param id, but a string
|
||||
sint32 NumParam;
|
||||
std::string String;
|
||||
|
||||
CParamBlock()
|
||||
{
|
||||
NumParam= -1;
|
||||
}
|
||||
};
|
||||
class CAction
|
||||
{
|
||||
public:
|
||||
// a condition to launch this action handler (is an expression)
|
||||
std::vector<CParamBlock> CondBlocks;
|
||||
|
||||
// the action handler (may be proc!!)
|
||||
std::string Action;
|
||||
// A list of string/or param number => to build the final params at execution
|
||||
std::vector<CParamBlock> ParamBlocks;
|
||||
|
||||
// build a paramBlock from a string
|
||||
void buildParamBlock (const std::string ¶ms);
|
||||
// from ParamBlock, and a paramList (skip the 0th), build params.
|
||||
void buildParams (const std::vector<std::string> ¶mList, std::string ¶ms) const;
|
||||
|
||||
void buildCondBlock (const std::string ¶ms);
|
||||
|
||||
void buildCond (const std::vector<std::string> ¶mList, std::string &cond) const;
|
||||
|
||||
static void buildBlocks (const std::string &in, std::vector<CParamBlock> &out);
|
||||
static void eval (const std::vector<std::string> &inArgs, const std::vector<CParamBlock> &inBlocks, std::string &out);
|
||||
|
||||
};
|
||||
class CProcedure
|
||||
{
|
||||
public:
|
||||
// List of the actions
|
||||
std::vector<CAction> Actions;
|
||||
};
|
||||
class CStyleProperty
|
||||
{
|
||||
public:
|
||||
|
|
77
code/nel/include/nel/gui/proc.h
Normal file
77
code/nel/include/nel/gui/proc.h
Normal file
|
@ -0,0 +1,77 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef PROC_H
|
||||
#define PROC_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CParamBlock
|
||||
{
|
||||
public:
|
||||
// -1 if not a param id, but a string
|
||||
sint32 NumParam;
|
||||
std::string String;
|
||||
|
||||
CParamBlock()
|
||||
{
|
||||
NumParam = -1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CProcAction
|
||||
{
|
||||
public:
|
||||
// a condition to launch this action handler (is an expression)
|
||||
std::vector< CParamBlock > CondBlocks;
|
||||
|
||||
// the action handler (may be proc!!)
|
||||
std::string Action;
|
||||
// A list of string/or param number => to build the final params at execution
|
||||
std::vector< CParamBlock > ParamBlocks;
|
||||
|
||||
// build a paramBlock from a string
|
||||
void buildParamBlock( const std::string ¶ms );
|
||||
// from ParamBlock, and a paramList (skip the 0th), build params.
|
||||
void buildParams( const std::vector< std::string > ¶mList, std::string ¶ms ) const;
|
||||
|
||||
void buildCondBlock( const std::string ¶ms );
|
||||
|
||||
void buildCond( const std::vector< std::string > ¶mList, std::string &cond ) const;
|
||||
|
||||
static void buildBlocks( const std::string &in, std::vector< CParamBlock > &out );
|
||||
|
||||
static void eval( const std::vector< std::string > &inArgs, const std::vector< CParamBlock > &inBlocks, std::string &out );
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CProcedure
|
||||
{
|
||||
public:
|
||||
// List of the actions
|
||||
std::vector< CProcAction > Actions;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -44,6 +44,7 @@ namespace NLGUI
|
|||
class CViewPointerBase;
|
||||
class CInterfaceOptions;
|
||||
class CInterfaceAnim;
|
||||
class CProcedure;
|
||||
|
||||
class IParser
|
||||
{
|
||||
|
@ -59,6 +60,7 @@ namespace NLGUI
|
|||
virtual bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const = 0;
|
||||
virtual const std::string& getDefine(const std::string &id) const = 0;
|
||||
virtual CInterfaceAnim* getAnim( const std::string &name ) const = 0;
|
||||
virtual CProcedure* getProc( const std::string &name ) = 0;
|
||||
};
|
||||
|
||||
/// Manages the GUI widgets
|
||||
|
@ -332,7 +334,7 @@ namespace NLGUI
|
|||
|
||||
void drawViews( NL3D::UCamera camera );
|
||||
|
||||
bool handleEvent( const CEventDescriptor &eventDesc );
|
||||
bool handleEvent( const CEventDescriptor &evnt );
|
||||
|
||||
bool handleMouseMoveEvent( const CEventDescriptor &eventDesc );
|
||||
|
||||
|
@ -475,6 +477,13 @@ namespace NLGUI
|
|||
void updateAnims();
|
||||
void removeFinishedAnims();
|
||||
|
||||
// execute a procedure. give a list of parameters. NB: the first param is the name of the proc (skipped)...
|
||||
void runProcedure( const std::string &procName, CCtrlBase *pCaller, const std::vector< std::string > ¶mList );
|
||||
// replace an action in a procedure (if possible)
|
||||
void setProcedureAction( const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms );
|
||||
|
||||
const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; }
|
||||
|
||||
static IParser *parser;
|
||||
|
||||
private:
|
||||
|
@ -542,6 +551,8 @@ namespace NLGUI
|
|||
|
||||
bool _MouseOverWindow;
|
||||
|
||||
CEventDescriptorKey lastKeyEvent;
|
||||
|
||||
uint32 screenH;
|
||||
uint32 screenW;
|
||||
|
||||
|
|
|
@ -1772,7 +1772,7 @@ namespace NLGUI
|
|||
CXMLAutoPtr name((const char*) xmlGetProp (cur, (xmlChar*)"handler"));
|
||||
CXMLAutoPtr params((const char*) xmlGetProp (cur, (xmlChar*)"params"));
|
||||
CXMLAutoPtr cond((const char*) xmlGetProp (cur, (xmlChar*)"cond"));
|
||||
CAction action;
|
||||
CProcAction action;
|
||||
if(!name)
|
||||
{
|
||||
// todo hulud interface syntax error
|
||||
|
@ -2086,153 +2086,6 @@ namespace NLGUI
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// CInterfaceParser::CAction
|
||||
// ***************************************************************************
|
||||
|
||||
#define PROC_PARAM_IDENT '@'
|
||||
|
||||
// ***************************************************************************
|
||||
void CInterfaceParser::CAction::buildParamBlock(const std::string ¶ms)
|
||||
{
|
||||
buildBlocks (params, ParamBlocks);
|
||||
}
|
||||
|
||||
void CInterfaceParser::CAction::buildParams(const std::vector<string> ¶mList, std::string ¶ms) const
|
||||
{
|
||||
eval (paramList, ParamBlocks, params);
|
||||
}
|
||||
|
||||
void CInterfaceParser::CAction::buildCondBlock(const std::string ¶ms)
|
||||
{
|
||||
buildBlocks (params, CondBlocks);
|
||||
}
|
||||
|
||||
void CInterfaceParser::CAction::buildCond(const std::vector<string> ¶mList, std::string ¶ms) const
|
||||
{
|
||||
eval (paramList, CondBlocks, params);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CInterfaceParser::CAction::buildBlocks (const std::string &in, std::vector<CParamBlock> &out)
|
||||
{
|
||||
out.clear();
|
||||
|
||||
if(in.empty())
|
||||
return;
|
||||
|
||||
string lastString;
|
||||
string::size_type curPos= 0;
|
||||
string::size_type lastPos= 0;
|
||||
|
||||
//if it has some @ then solve proc value
|
||||
while( (curPos=in.find(PROC_PARAM_IDENT, curPos)) != string::npos)
|
||||
{
|
||||
// If it is end of line
|
||||
if(curPos==in.size()-1)
|
||||
{
|
||||
// then skip
|
||||
curPos= in.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip all @
|
||||
uint countNbIdent = 0;
|
||||
while (curPos<in.size() && in[curPos]==PROC_PARAM_IDENT)
|
||||
{
|
||||
curPos++;
|
||||
countNbIdent++;
|
||||
}
|
||||
|
||||
// get the id pos
|
||||
uint countNbDigit = 0;
|
||||
uint startIdPos= (uint)curPos;
|
||||
while (curPos<in.size() && in[curPos]>='0' && in[curPos]<='9')
|
||||
{
|
||||
curPos++;
|
||||
countNbDigit++;
|
||||
}
|
||||
|
||||
if (curPos == startIdPos)
|
||||
{
|
||||
// No digit so it is a normal db entry
|
||||
lastString+= in.substr (lastPos, curPos-(countNbIdent-1)-lastPos);
|
||||
// all @ are skipped
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is some digit it is an argument
|
||||
|
||||
// copy the last not param sub string.
|
||||
sint nbToCopy = (sint)(curPos-countNbIdent-countNbDigit-lastPos);
|
||||
if (nbToCopy > 0)
|
||||
lastString += in.substr(lastPos, nbToCopy);
|
||||
|
||||
// if not empty, add to the param block
|
||||
if (!lastString.empty())
|
||||
{
|
||||
CParamBlock pb;
|
||||
pb.String = lastString;
|
||||
out.push_back(pb);
|
||||
// clear it
|
||||
lastString.clear();
|
||||
}
|
||||
|
||||
// get the param id
|
||||
sint paramId;
|
||||
fromString(in.substr(startIdPos, curPos-startIdPos), paramId);
|
||||
// Add it to the param block
|
||||
CParamBlock pb;
|
||||
pb.NumParam = paramId;
|
||||
out.push_back(pb);
|
||||
}
|
||||
|
||||
// valid pos is current pos
|
||||
lastPos= curPos;
|
||||
}
|
||||
}
|
||||
// concat last part
|
||||
lastString+= in.substr(lastPos, in.size()-lastPos);
|
||||
if(!lastString.empty())
|
||||
{
|
||||
CParamBlock pb;
|
||||
pb.String = lastString;
|
||||
out.push_back(pb);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
//void CInterfaceParser::CAction::buildParams(const std::vector<string> ¶mList, std::string ¶ms) const
|
||||
void CInterfaceParser::CAction::eval (const std::vector<string> &inArgs, const std::vector<CParamBlock> &inBlocks, std::string &out)
|
||||
{
|
||||
// clear the ret string
|
||||
out.clear();
|
||||
|
||||
// for all block
|
||||
for (uint i=0; i < inBlocks.size(); i++)
|
||||
{
|
||||
const CParamBlock &pb = inBlocks[i];
|
||||
// if the block is a raw string
|
||||
if (pb.NumParam < 0)
|
||||
{
|
||||
// concat with the block
|
||||
out += pb.String;
|
||||
}
|
||||
// else get from paramList
|
||||
else
|
||||
{
|
||||
// add 1, because paramList[0] is the name of the procedure
|
||||
sint idInList = pb.NumParam+1;
|
||||
// if param exist
|
||||
if (idInList < (sint)inArgs.size())
|
||||
// concat with the params
|
||||
out += inArgs[idInList];
|
||||
// else skip (should fail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CInterfaceParser::parseSheetSelection(xmlNodePtr cur)
|
||||
{
|
||||
|
@ -2638,7 +2491,7 @@ namespace NLGUI
|
|||
const CProcedure &proc= it->second;
|
||||
if(actionIndex<proc.Actions.size())
|
||||
{
|
||||
const CAction &action= proc.Actions[actionIndex];
|
||||
const CProcAction &action= proc.Actions[actionIndex];
|
||||
// if not a variable parametrized Params
|
||||
if(action.ParamBlocks.size()==1 && action.ParamBlocks[0].NumParam==-1)
|
||||
{
|
||||
|
@ -2664,6 +2517,15 @@ namespace NLGUI
|
|||
return it->second;
|
||||
}
|
||||
|
||||
CProcedure* CInterfaceParser::getProc( const std::string &name )
|
||||
{
|
||||
TProcedureMap::iterator itr = _ProcedureMap.find( name );
|
||||
if( itr == _ProcedureMap.end() )
|
||||
return NULL;
|
||||
|
||||
return &itr->second;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CInterfaceParser::parseStyle(xmlNodePtr cur)
|
||||
{
|
||||
|
|
167
code/nel/src/gui/proc.cpp
Normal file
167
code/nel/src/gui/proc.cpp
Normal file
|
@ -0,0 +1,167 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "nel/gui/proc.h"
|
||||
#include "nel/misc/algo.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
#define PROC_PARAM_IDENT '@'
|
||||
|
||||
// ***************************************************************************
|
||||
void CProcAction::buildParamBlock( const std::string ¶ms )
|
||||
{
|
||||
buildBlocks( params, ParamBlocks );
|
||||
}
|
||||
|
||||
void CProcAction::buildParams( const std::vector< std::string > ¶mList, std::string ¶ms ) const
|
||||
{
|
||||
eval( paramList, ParamBlocks, params );
|
||||
}
|
||||
|
||||
void CProcAction::buildCondBlock( const std::string ¶ms )
|
||||
{
|
||||
buildBlocks( params, CondBlocks );
|
||||
}
|
||||
|
||||
void CProcAction::buildCond( const std::vector< std::string > ¶mList, std::string ¶ms ) const
|
||||
{
|
||||
eval( paramList, CondBlocks, params );
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CProcAction::buildBlocks( const std::string &in, std::vector< CParamBlock > &out )
|
||||
{
|
||||
out.clear();
|
||||
|
||||
if(in.empty())
|
||||
return;
|
||||
|
||||
std::string lastString;
|
||||
std::string::size_type curPos= 0;
|
||||
std::string::size_type lastPos= 0;
|
||||
|
||||
//if it has some @ then solve proc value
|
||||
while( (curPos=in.find(PROC_PARAM_IDENT, curPos)) != std::string::npos)
|
||||
{
|
||||
// If it is end of line
|
||||
if(curPos==in.size()-1)
|
||||
{
|
||||
// then skip
|
||||
curPos= in.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip all @
|
||||
uint countNbIdent = 0;
|
||||
while (curPos<in.size() && in[curPos]==PROC_PARAM_IDENT)
|
||||
{
|
||||
curPos++;
|
||||
countNbIdent++;
|
||||
}
|
||||
|
||||
// get the id pos
|
||||
uint countNbDigit = 0;
|
||||
uint startIdPos= (uint)curPos;
|
||||
while (curPos<in.size() && in[curPos]>='0' && in[curPos]<='9')
|
||||
{
|
||||
curPos++;
|
||||
countNbDigit++;
|
||||
}
|
||||
|
||||
if (curPos == startIdPos)
|
||||
{
|
||||
// No digit so it is a normal db entry
|
||||
lastString+= in.substr (lastPos, curPos-(countNbIdent-1)-lastPos);
|
||||
// all @ are skipped
|
||||
}
|
||||
else
|
||||
{
|
||||
// There is some digit it is an argument
|
||||
|
||||
// copy the last not param sub string.
|
||||
sint nbToCopy = (sint)(curPos-countNbIdent-countNbDigit-lastPos);
|
||||
if (nbToCopy > 0)
|
||||
lastString += in.substr(lastPos, nbToCopy);
|
||||
|
||||
// if not empty, add to the param block
|
||||
if (!lastString.empty())
|
||||
{
|
||||
CParamBlock pb;
|
||||
pb.String = lastString;
|
||||
out.push_back(pb);
|
||||
// clear it
|
||||
lastString.clear();
|
||||
}
|
||||
|
||||
// get the param id
|
||||
sint paramId;
|
||||
fromString(in.substr(startIdPos, curPos-startIdPos), paramId);
|
||||
// Add it to the param block
|
||||
CParamBlock pb;
|
||||
pb.NumParam = paramId;
|
||||
out.push_back(pb);
|
||||
}
|
||||
|
||||
// valid pos is current pos
|
||||
lastPos= curPos;
|
||||
}
|
||||
}
|
||||
// concat last part
|
||||
lastString+= in.substr(lastPos, in.size()-lastPos);
|
||||
if(!lastString.empty())
|
||||
{
|
||||
CParamBlock pb;
|
||||
pb.String = lastString;
|
||||
out.push_back(pb);
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CProcAction::eval( const std::vector<std::string> &inArgs, const std::vector< CParamBlock > &inBlocks, std::string &out )
|
||||
{
|
||||
// clear the ret string
|
||||
out.clear();
|
||||
|
||||
// for all block
|
||||
for (uint i=0; i < inBlocks.size(); i++)
|
||||
{
|
||||
const CParamBlock &pb = inBlocks[i];
|
||||
// if the block is a raw string
|
||||
if (pb.NumParam < 0)
|
||||
{
|
||||
// concat with the block
|
||||
out += pb.String;
|
||||
}
|
||||
// else get from paramList
|
||||
else
|
||||
{
|
||||
// add 1, because paramList[0] is the name of the procedure
|
||||
sint idInList = pb.NumParam+1;
|
||||
// if param exist
|
||||
if (idInList < (sint)inArgs.size())
|
||||
// concat with the params
|
||||
out += inArgs[idInList];
|
||||
// else skip (should fail)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,8 @@
|
|||
#include "nel/gui/view_bitmap.h"
|
||||
#include "nel/gui/group_container.h"
|
||||
#include "nel/gui/interface_anim.h"
|
||||
#include "nel/gui/proc.h"
|
||||
#include "nel/gui/interface_expr.h"
|
||||
#include "nel/misc/events.h"
|
||||
|
||||
namespace NLGUI
|
||||
|
@ -2211,6 +2213,8 @@ namespace NLGUI
|
|||
CDBManager::getInstance()->flushObserverCalls();
|
||||
return result;
|
||||
}
|
||||
|
||||
lastKeyEvent = eventDesc;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////// Keyboard handling ends here ////////////////////////////////////
|
||||
|
@ -3028,6 +3032,66 @@ namespace NLGUI
|
|||
(*itr)->update();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CWidgetManager::runProcedure( const std::string &procName, CCtrlBase *pCaller,
|
||||
const std::vector< std::string> ¶mList )
|
||||
{
|
||||
CProcedure *procp = parser->getProc( procName );
|
||||
if( procp == NULL )
|
||||
return;
|
||||
|
||||
CProcedure &proc = *procp;
|
||||
|
||||
// Run all actions
|
||||
for( uint i = 0; i < proc.Actions.size(); i++ )
|
||||
{
|
||||
const CProcAction &action = proc.Actions[i];
|
||||
// test if the condition for the action is valid
|
||||
if( action.CondBlocks.size() > 0 )
|
||||
{
|
||||
CInterfaceExprValue result;
|
||||
result.setBool( false );
|
||||
std::string cond;
|
||||
action.buildCond( paramList, cond );
|
||||
CInterfaceExpr::eval( cond, result, NULL );
|
||||
|
||||
if( result.toBool() )
|
||||
if( !result.getBool() )
|
||||
continue;
|
||||
}
|
||||
// build the params sting
|
||||
std::string params;
|
||||
action.buildParams( paramList, params );
|
||||
// run
|
||||
//nlwarning("step %d : %s, %s", (int) i, action.Action.c_str(), params.c_str());
|
||||
CAHManager::getInstance()->runActionHandler( action.Action, pCaller, params );
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CWidgetManager::setProcedureAction( const std::string &procName, uint actionIndex,
|
||||
const std::string &ah, const std::string ¶ms )
|
||||
{
|
||||
CProcedure *procp = parser->getProc( procName );
|
||||
if( procp == NULL )
|
||||
return;
|
||||
|
||||
CProcedure &proc = *procp;
|
||||
|
||||
// set wanted action
|
||||
if( actionIndex<proc.Actions.size() )
|
||||
{
|
||||
CProcAction &action = proc.Actions[ actionIndex ];
|
||||
action.Action = ah;
|
||||
action.ParamBlocks.clear();
|
||||
action.ParamBlocks.resize( 1 );
|
||||
action.ParamBlocks[ 0 ].String = params;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
CWidgetManager::CWidgetManager()
|
||||
{
|
||||
_Pointer = NULL;
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
///////////
|
||||
// CLASS //
|
||||
class CCombo;
|
||||
class CAction;
|
||||
class CActionsManager;
|
||||
class CAction;
|
||||
|
||||
/**
|
||||
* The goal of CCombo is to gather together Inputs that will validate an Action.
|
||||
|
|
|
@ -2059,7 +2059,7 @@ public:
|
|||
{
|
||||
vector<string> p;
|
||||
p.push_back(sProc);
|
||||
pIM->runProcedure(sProc, pCaller, p);
|
||||
CWidgetManager::getInstance()->runProcedure(sProc, pCaller, p);
|
||||
|
||||
CInterfaceExprValue result;
|
||||
if (CInterfaceExpr::eval(sCond, result))
|
||||
|
|
|
@ -315,11 +315,10 @@ class CAHMilkoMenuDoResetInterface : public IActionHandler
|
|||
|
||||
// run procedure
|
||||
vector<string> v;
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
if (mode == "R2TestMode")
|
||||
pIM->runProcedure ("proc_reset_r2ed_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure ("proc_reset_r2ed_interface", NULL, v);
|
||||
else
|
||||
pIM->runProcedure("proc_reset_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure("proc_reset_interface", NULL, v);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER(CAHMilkoMenuDoResetInterface, "milko_menu_do_reset_interface");
|
||||
|
|
|
@ -1857,7 +1857,7 @@ public:
|
|||
if (ClientCfg.Light)
|
||||
{
|
||||
vector<string> v;
|
||||
CInterfaceManager::getInstance()->runProcedure ("proc_reset_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure ("proc_reset_interface", NULL, v);
|
||||
|
||||
//CInterfaceManager::getInstance()->launchContextMenuInGame("ui:interface:game_context_menu");
|
||||
}
|
||||
|
@ -2747,7 +2747,7 @@ public:
|
|||
vector<string> vecStr;
|
||||
vecStr.push_back(procNames[desktop]);
|
||||
vecStr.push_back(sValue);
|
||||
pIM->runProcedure(procNames[desktop], NULL, vecStr);
|
||||
CWidgetManager::getInstance()->runProcedure(procNames[desktop], NULL, vecStr);
|
||||
}*/
|
||||
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
|
@ -2773,11 +2773,10 @@ public:
|
|||
{
|
||||
_FirstTime = false;
|
||||
|
||||
CInterfaceManager *pIM= CInterfaceManager::getInstance();
|
||||
vector<string> vecStr;
|
||||
vecStr.push_back("tb_setdesktop");
|
||||
vecStr.push_back(Params);
|
||||
pIM->runProcedure("tb_setdesktop", NULL, vecStr);
|
||||
CWidgetManager::getInstance()->runProcedure("tb_setdesktop", NULL, vecStr);
|
||||
}
|
||||
else // Not the first time
|
||||
{
|
||||
|
|
|
@ -288,8 +288,6 @@ class CActionHandlerProc : public IActionHandler
|
|||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string ¶ms)
|
||||
{
|
||||
CInterfaceManager *mngr= CInterfaceManager::getInstance();
|
||||
|
||||
// split the parameters
|
||||
vector<string> paramList;
|
||||
splitString(params, "|", paramList);
|
||||
|
@ -297,7 +295,7 @@ public:
|
|||
return;
|
||||
|
||||
// execute the procedure
|
||||
mngr->runProcedure(paramList[0], pCaller, paramList);
|
||||
CWidgetManager::getInstance()->runProcedure(paramList[0], pCaller, paramList);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CActionHandlerProc, "proc");
|
||||
|
|
|
@ -2249,7 +2249,7 @@ class CAHConfirmTrade : public IActionHandler
|
|||
case 1: enableResale = true; break;
|
||||
default: // 2: comes only from Enter of Shift+Enter key from an edit box or in the modal window
|
||||
{
|
||||
const NLGUI::CEventDescriptorKey& keyEvent = CInterfaceManager::getInstance()->getLastEventKeyDesc();
|
||||
const NLGUI::CEventDescriptorKey& keyEvent = CWidgetManager::getInstance()->getLastKeyEvent();
|
||||
enableResale = ! keyEvent.getKeyShift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1422,7 +1422,6 @@ void CInterfaceManager::updateFrameEvents()
|
|||
|
||||
// Handle anims done in 2 times because some AH can add or remove anims
|
||||
// First ensure we are working on a safe vector and update all anims
|
||||
sint i;
|
||||
CWidgetManager::getInstance()->updateAnims();
|
||||
|
||||
IngameDbMngr.flushObserverCalls();
|
||||
|
@ -1599,11 +1598,11 @@ bool CInterfaceManager::loadConfig (const string &filename)
|
|||
vector<string> v;
|
||||
if (ClientCfg.R2EDEnabled)
|
||||
{
|
||||
runProcedure ("proc_reset_r2ed_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure ("proc_reset_r2ed_interface", NULL, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
runProcedure ("proc_reset_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure ("proc_reset_interface", NULL, v);
|
||||
}
|
||||
|
||||
// By default, consider the reset interface has been set with the current resolution
|
||||
|
@ -1754,7 +1753,7 @@ bool CInterfaceManager::loadConfig (const string &filename)
|
|||
vector<string> v;
|
||||
if (!ClientCfg.R2EDEnabled)
|
||||
{
|
||||
runProcedure ("proc_reset_interface", NULL, v);
|
||||
CWidgetManager::getInstance()->runProcedure ("proc_reset_interface", NULL, v);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2123,68 +2122,6 @@ void CInterfaceManager::processServerIDString()
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CInterfaceManager::runProcedure (const string &procName, CCtrlBase *pCaller,
|
||||
const vector<string> ¶mList)
|
||||
{
|
||||
CstItProcedureMap it= _ProcedureMap.find(procName);
|
||||
if(it!=_ProcedureMap.end())
|
||||
{
|
||||
// TMP TMP
|
||||
/*std::string params;
|
||||
for(uint k = 0; k < paramList.size(); ++k)
|
||||
{
|
||||
params += paramList[k] + " ";
|
||||
}
|
||||
|
||||
nlinfo("runProcedure : %s : %s",procName.c_str(), params.c_str());*/
|
||||
const CProcedure &proc= it->second;
|
||||
// Run all actions
|
||||
for(uint i=0;i<proc.Actions.size();i++)
|
||||
{
|
||||
const CAction &action= proc.Actions[i];
|
||||
// test if the condition for the action is valid
|
||||
if (action.CondBlocks.size() > 0)
|
||||
{
|
||||
CInterfaceExprValue result;
|
||||
result.setBool(false);
|
||||
string cond;
|
||||
action.buildCond(paramList, cond);
|
||||
CInterfaceExpr::eval(cond, result, NULL);
|
||||
if (result.toBool())
|
||||
{
|
||||
if (!result.getBool()) continue;
|
||||
}
|
||||
}
|
||||
// build the params sting
|
||||
string params;
|
||||
action.buildParams(paramList, params);
|
||||
// run
|
||||
//nlwarning("step %d : %s, %s", (int) i, action.Action.c_str(), params.c_str());
|
||||
CAHManager::getInstance()->runActionHandler(action.Action, pCaller, params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CInterfaceManager::setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms)
|
||||
{
|
||||
ItProcedureMap it= _ProcedureMap.find(procName);
|
||||
if(it!=_ProcedureMap.end())
|
||||
{
|
||||
CProcedure &proc= it->second;
|
||||
// set wanted action
|
||||
if(actionIndex<proc.Actions.size())
|
||||
{
|
||||
CAction &action= proc.Actions[actionIndex];
|
||||
action.Action= ah;
|
||||
action.ParamBlocks.clear();
|
||||
action.ParamBlocks.resize(1);
|
||||
action.ParamBlocks[0].String= params;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CInterfaceManager::messageBoxInternal(const string &msgBoxGroup, const ucstring &text, const string &masterGroup, TCaseMode caseMode)
|
||||
{
|
||||
|
@ -2215,7 +2152,7 @@ void CInterfaceManager::messageBoxWithHelp(const ucstring &text, const std::stri
|
|||
TCaseMode caseMode)
|
||||
{
|
||||
// replace the procedure "proc_valid_message_box_ok" action
|
||||
setProcedureAction("proc_message_box_with_help_ok", 1, ahOnOk, paramsOnOk);
|
||||
CWidgetManager::getInstance()->setProcedureAction("proc_message_box_with_help_ok", 1, ahOnOk, paramsOnOk);
|
||||
const char *mbName = "message_box_with_help";
|
||||
// if no action handler is wanted, then assume that
|
||||
// clicking 'ok' do not have any consequence, so allow exiting the message box by clicking
|
||||
|
@ -2242,9 +2179,9 @@ void CInterfaceManager::validMessageBox(TValidMessageIcon icon, const ucstring &
|
|||
if (group && viewText)
|
||||
{
|
||||
// replace the procedure "proc_valid_message_box_ok" action
|
||||
setProcedureAction("proc_valid_message_box_ok", 1, ahOnOk, paramsOnOk);
|
||||
CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_ok", 1, ahOnOk, paramsOnOk);
|
||||
// replace the procedure "proc_valid_message_box_cancel" action
|
||||
setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel);
|
||||
CWidgetManager::getInstance()->setProcedureAction("proc_valid_message_box_cancel", 1, ahOnCancel, paramsOnCancel);
|
||||
|
||||
// set text and icon
|
||||
viewText->setText(text);
|
||||
|
|
|
@ -261,11 +261,6 @@ public:
|
|||
/// Handle The Event. return true if the interfaceManager catch it and if must not send to the Game Action Manager
|
||||
bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
// execute a procedure. give a list of parameters. NB: the first param is the name of the proc (skipped)...
|
||||
void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector<std::string> ¶mList);
|
||||
// replace an action in a procedure (if possible)
|
||||
void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms);
|
||||
|
||||
// InGame ContextMenu
|
||||
void launchContextMenuInGame (const std::string &nameOfCM);
|
||||
|
||||
|
@ -426,9 +421,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Description of the last key event that called an action handler
|
||||
const NLGUI::CEventDescriptorKey& getLastEventKeyDesc() const { return _LastEventKeyDesc; }
|
||||
|
||||
void notifyMailAvailable();
|
||||
void notifyForumUpdated();
|
||||
|
||||
|
@ -657,9 +649,6 @@ private:
|
|||
// Item Carac requirement
|
||||
sint32 _CurrentPlayerCharac[CHARACTERISTICS::NUM_CHARACTERISTICS];
|
||||
|
||||
// Description of the last key event that called an action handler
|
||||
NLGUI::CEventDescriptorKey _LastEventKeyDesc;
|
||||
|
||||
// observers for copying database branch changes
|
||||
CServerToLocalAutoCopy ServerToLocalAutoCopyInventory;
|
||||
CServerToLocalAutoCopy ServerToLocalAutoCopyExchange;
|
||||
|
|
Loading…
Reference in a new issue