mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-05 14:59:01 +00:00
Merged mainline default branch changes.
This commit is contained in:
commit
543488b490
653 changed files with 291288 additions and 270554 deletions
|
@ -293,6 +293,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
|
|||
###
|
||||
OPTION(WITH_NET "Build NLNET" ON )
|
||||
OPTION(WITH_3D "Build NL3D" ON )
|
||||
OPTION(WITH_GUI "Build GUI" ON )
|
||||
OPTION(WITH_PACS "Build NLPACS" ON )
|
||||
OPTION(WITH_GEORGES "Build NLGEORGES" ON )
|
||||
OPTION(WITH_LIGO "Build NLLIGO" ON )
|
||||
|
|
|
@ -1,33 +1,37 @@
|
|||
SUBDIRS(misc)
|
||||
|
||||
IF(WITH_3D)
|
||||
SUBDIRS(3d)
|
||||
ENDIF(WITH_3D)
|
||||
|
||||
IF(WITH_GEORGES)
|
||||
SUBDIRS(georges)
|
||||
ENDIF(WITH_GEORGES)
|
||||
|
||||
IF(WITH_LIGO)
|
||||
SUBDIRS(ligo)
|
||||
ENDIF(WITH_LIGO)
|
||||
|
||||
IF(WITH_LOGIC)
|
||||
SUBDIRS(logic)
|
||||
ENDIF(WITH_LOGIC)
|
||||
|
||||
IF(WITH_NET)
|
||||
SUBDIRS(net)
|
||||
ENDIF(WITH_NET)
|
||||
|
||||
IF(WITH_SOUND)
|
||||
SUBDIRS(sound)
|
||||
ENDIF(WITH_SOUND)
|
||||
|
||||
IF(WITH_PACS)
|
||||
SUBDIRS(pacs)
|
||||
ENDIF(WITH_PACS)
|
||||
|
||||
IF(WITH_NEL_CEGUI)
|
||||
SUBDIRS(cegui)
|
||||
ENDIF(WITH_NEL_CEGUI)
|
||||
SUBDIRS(misc)
|
||||
|
||||
IF(WITH_3D)
|
||||
SUBDIRS(3d)
|
||||
ENDIF(WITH_3D)
|
||||
|
||||
IF(WITH_GUI)
|
||||
ADD_SUBDIRECTORY(gui)
|
||||
ENDIF(WITH_GUI)
|
||||
|
||||
IF(WITH_GEORGES)
|
||||
SUBDIRS(georges)
|
||||
ENDIF(WITH_GEORGES)
|
||||
|
||||
IF(WITH_LIGO)
|
||||
SUBDIRS(ligo)
|
||||
ENDIF(WITH_LIGO)
|
||||
|
||||
IF(WITH_LOGIC)
|
||||
SUBDIRS(logic)
|
||||
ENDIF(WITH_LOGIC)
|
||||
|
||||
IF(WITH_NET)
|
||||
SUBDIRS(net)
|
||||
ENDIF(WITH_NET)
|
||||
|
||||
IF(WITH_SOUND)
|
||||
SUBDIRS(sound)
|
||||
ENDIF(WITH_SOUND)
|
||||
|
||||
IF(WITH_PACS)
|
||||
SUBDIRS(pacs)
|
||||
ENDIF(WITH_PACS)
|
||||
|
||||
IF(WITH_NEL_CEGUI)
|
||||
SUBDIRS(cegui)
|
||||
ENDIF(WITH_NEL_CEGUI)
|
||||
|
|
3
code/nel/include/nel/gui/CMakeLists.txt
Normal file
3
code/nel/include/nel/gui/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
FILE(GLOB HEADERS *.h)
|
||||
|
||||
INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers)
|
153
code/nel/include/nel/gui/action_handler.h
Normal file
153
code/nel/include/nel/gui/action_handler.h
Normal file
|
@ -0,0 +1,153 @@
|
|||
// 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 NL_ACTION_HANDLER_H
|
||||
#define NL_ACTION_HANDLER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <libxml/parser.h>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include <map>
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CCtrlBase;
|
||||
|
||||
|
||||
/**
|
||||
* interface for action handlers
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class IActionHandler
|
||||
{
|
||||
public:
|
||||
// Execute the answer to the action
|
||||
// Params has the following form : paramName=theParam|paramName2=theParam2|...
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { }
|
||||
|
||||
virtual ~IActionHandler() {}
|
||||
|
||||
static std::string getParam (const std::string &Params, const std::string &ParamName);
|
||||
|
||||
static void getAllParams (const std::string &Params, std::vector< std::pair<std::string,std::string> > &AllParams);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
interface for action handlers factory
|
||||
no release in this factory : a handler must be destroyed by the control that created it
|
||||
*/
|
||||
class CAHManager
|
||||
{
|
||||
public:
|
||||
typedef std::map< std::string, IActionHandler* > TFactoryMap;
|
||||
typedef std::map< IActionHandler*, std::string > TNameMap;
|
||||
|
||||
static CAHManager* getInstance()
|
||||
{
|
||||
if (_GlobalInstance == NULL)
|
||||
_GlobalInstance = new CAHManager;
|
||||
return _GlobalInstance;
|
||||
}
|
||||
|
||||
/// return pointer to action handler or null if it doesn't exist
|
||||
IActionHandler *getActionHandler(const std::string &name) const
|
||||
{
|
||||
TFactoryMap::const_iterator it = FactoryMap.find(name);
|
||||
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
|
||||
const std::string &getActionHandlerName(IActionHandler *pAH) const
|
||||
{
|
||||
TNameMap::const_iterator it = NameMap.find(pAH);
|
||||
return it != NameMap.end() ? it->second : EmptyName;
|
||||
}
|
||||
|
||||
/// map of action handler factories
|
||||
TFactoryMap FactoryMap;
|
||||
TNameMap NameMap;
|
||||
std::string EmptyName;
|
||||
|
||||
/// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed)
|
||||
IActionHandler *getAH(const std::string &name, std::string ¶ms);
|
||||
IActionHandler *getAH(const std::string &name, class CStringShared ¶ms);
|
||||
|
||||
/** common method to parse Action Handler from a xml node
|
||||
* \param ahId eg: "onclick_l"
|
||||
* \param paramId eg: "params_l".
|
||||
* \param params returned parameters.
|
||||
* NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book")
|
||||
* is taken
|
||||
* NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed
|
||||
*/
|
||||
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶ms);
|
||||
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms);
|
||||
|
||||
/// Get the AH name from ptr
|
||||
const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); }
|
||||
|
||||
void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") );
|
||||
void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") );
|
||||
|
||||
// Submit a generic event
|
||||
void submitEvent( const std::string &evt );
|
||||
static void setEditorMode( bool b ){ editorMode = b; }
|
||||
|
||||
private:
|
||||
CAHManager(){}
|
||||
static CAHManager *_GlobalInstance;
|
||||
static bool editorMode;
|
||||
|
||||
};
|
||||
|
||||
/// Ah name must all be lower case
|
||||
#define REGISTER_ACTION_HANDLER(handler ,name) \
|
||||
class handler##Factory : public handler \
|
||||
{ \
|
||||
public: \
|
||||
handler##Factory () \
|
||||
{ \
|
||||
nlassert(name!=NULL); \
|
||||
const char *c= name; \
|
||||
while(*c!='\0') \
|
||||
{ \
|
||||
nlassert(islower(*c) || !isalpha(*c)); \
|
||||
c++; \
|
||||
} \
|
||||
CAHManager *pAHFM = CAHManager::getInstance(); \
|
||||
pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \
|
||||
pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \
|
||||
}; \
|
||||
}; \
|
||||
handler##Factory handler##FactoryInstance ; \
|
||||
\
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif //NL_ACTION_HANDLER_H
|
190
code/nel/include/nel/gui/ctrl_base.h
Normal file
190
code/nel/include/nel/gui/ctrl_base.h
Normal file
|
@ -0,0 +1,190 @@
|
|||
// 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 RZ_CTRL_BASE_H
|
||||
#define RZ_CTRL_BASE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/gui/event_descriptor.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBase : public CViewBase
|
||||
{
|
||||
public:
|
||||
|
||||
// Tooltip mode
|
||||
enum TToolTipParentType
|
||||
{
|
||||
TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears
|
||||
TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears
|
||||
TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies.
|
||||
TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window
|
||||
|
||||
NumToolTipParentRef
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CCtrlBase(const TCtorParam ¶m) : CViewBase(param)
|
||||
{
|
||||
_ToolTipInstant= true;
|
||||
_ToolTipParent= TTCtrl;
|
||||
// see interface.txt for meaning of auto
|
||||
_ToolTipParentPosRef= Hotspot_TTAuto;
|
||||
_ToolTipPosRef= Hotspot_TTAuto;
|
||||
resizer = false;
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~CCtrlBase();
|
||||
|
||||
static std::string tooltipParentToString( TToolTipParentType type );
|
||||
static TToolTipParentType stringToToolTipParent( const std::string &str );
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// special parse
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
|
||||
/// Handle all events (implemented by derived classes) (return true to signal event handled)
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
|
||||
|
||||
/// Debug
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
|
||||
/// Get the ContextHelp for this control. Default is to return _ContextHelp
|
||||
virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;}
|
||||
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
|
||||
virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); }
|
||||
// Get the name of the context help window. Default to "context_help"
|
||||
virtual std::string getContextHelpWindowName() const;
|
||||
/// Get the ContextHelp ActionHandler. If "", noop
|
||||
const std::string &getContextHelpActionHandler() const {return _OnContextHelp;}
|
||||
/// Get the ContextHelp ActionHandler Params
|
||||
const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;}
|
||||
/// true if both are empty
|
||||
bool emptyContextHelp() const;
|
||||
// Should return true if the context help should be displayed instantly
|
||||
bool wantInstantContextHelp() const { return _ToolTipInstant; }
|
||||
/// Set true if ToolTip should be displayed instantly
|
||||
void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;}
|
||||
|
||||
/** If ctrl has a non rectangle shape, perform further test to know
|
||||
* if control should be taken in account for context help
|
||||
*/
|
||||
virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; }
|
||||
|
||||
|
||||
/// return the type of anchor for the tooltip of this control
|
||||
TToolTipParentType getToolTipParent() const { return _ToolTipParent;}
|
||||
const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();}
|
||||
/// Set the type of anchor for the tooltip of this control
|
||||
void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; }
|
||||
void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; }
|
||||
/// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
|
||||
THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;}
|
||||
THotSpot getToolTipPosRef() const { return _ToolTipPosRef;}
|
||||
THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;}
|
||||
THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;}
|
||||
/// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
|
||||
void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;}
|
||||
void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;}
|
||||
|
||||
/// replace the default contextHelp
|
||||
ucstring getDefaultContextHelp() const {return _ContextHelp;}
|
||||
void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;}
|
||||
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
|
||||
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
|
||||
|
||||
|
||||
|
||||
// called when this element or a son has been captured
|
||||
virtual void elementCaptured(CCtrlBase * /* capturedElement */) {}
|
||||
|
||||
virtual bool isCtrl() const { return true; }
|
||||
|
||||
// Made for CtrlResizer to take the precedence over son controls.
|
||||
virtual uint getDeltaDepth() const { return 0; }
|
||||
|
||||
// true if this ctrl is capturable (true by default, false for tooltip)
|
||||
virtual bool isCapturable() const {return true;}
|
||||
|
||||
bool isResizer() const{ return resizer; }
|
||||
|
||||
// from CInterfaceElement
|
||||
virtual void visit(CInterfaceElementVisitor *visitor);
|
||||
|
||||
/** test if virtual desktop change is possible while this element is captured by the mouse
|
||||
* Useful for resizers
|
||||
*/
|
||||
virtual bool canChangeVirtualDesktop() const { return true; }
|
||||
|
||||
// called when keyboard capture has been lost
|
||||
virtual void onKeyboardCaptureLost() {}
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
|
||||
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
// special for mouse over : return true and fill the name of the cursor to display
|
||||
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
uint32 getDepth( CInterfaceGroup *group );
|
||||
|
||||
protected:
|
||||
// This is the ContextHelp filled by default in parse()
|
||||
ucstring _ContextHelp;
|
||||
CStringShared _OnContextHelp;
|
||||
CStringShared _OnContextHelpParams;
|
||||
CStringShared _ToolTipSpecialParent;
|
||||
TToolTipParentType _ToolTipParent;
|
||||
bool _ToolTipInstant : 1;
|
||||
THotSpot _ToolTipParentPosRef : 6;
|
||||
THotSpot _ToolTipPosRef : 6;
|
||||
THotSpot _ToolTipParentPosRefAlt : 6;
|
||||
THotSpot _ToolTipPosRefAlt : 6;
|
||||
protected:
|
||||
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
|
||||
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
|
||||
|
||||
void mapAHString( const std::string &key, const std::string &value );
|
||||
std::string getAHString( const std::string &key ) const;
|
||||
|
||||
static std::map< std::string, std::map< std::string, std::string > > AHCache;
|
||||
|
||||
bool resizer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_VIEW_BASE_H
|
||||
|
||||
/* End of ctrl_base.h */
|
270
code/nel/include/nel/gui/ctrl_base_button.h
Normal file
270
code/nel/include/nel/gui/ctrl_base_button.h
Normal file
|
@ -0,0 +1,270 @@
|
|||
// 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 NL_CTRL_BASE_BUTTON_H
|
||||
#define NL_CTRL_BASE_BUTTON_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/gui/action_handler.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Base Class For Buttons.
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlBaseButton : public CCtrlBase
|
||||
{
|
||||
|
||||
public:
|
||||
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
|
||||
|
||||
/// Constructor
|
||||
CCtrlBaseButton(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& event);
|
||||
|
||||
/// \name Misc
|
||||
// @{
|
||||
void setType (EType t) { _Type = t; }
|
||||
EType getType() { return _Type; }
|
||||
std::string getTypeString() const;
|
||||
void setTypeFromString( const std::string &type );
|
||||
|
||||
void setClickWhenPushed(bool click) { _ClickWhenPushed = click; }
|
||||
bool getClickWhenPushed() const { return _ClickWhenPushed; }
|
||||
|
||||
void setPushed (bool state);
|
||||
bool getPushed () const { return _Pushed; }
|
||||
|
||||
void setFrozen (bool state);
|
||||
bool getFrozen () const { return _Frozen; }
|
||||
|
||||
// Set half tone mode for the display of frozen buttons. Default is true.
|
||||
void setFrozenHalfTone(bool enabled);
|
||||
bool getFrozenHalfTone() const { return _FrozenHalfTone; }
|
||||
|
||||
// if the radio is a radio button, then all radio button are unselected
|
||||
void unselect();
|
||||
// @}
|
||||
|
||||
|
||||
/// \name Colors
|
||||
// @{
|
||||
void setColor(NLMISC::CRGBA col) { _ColorNormal = col; }
|
||||
void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; }
|
||||
void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; }
|
||||
|
||||
NLMISC::CRGBA getColor() const { return _ColorNormal; }
|
||||
NLMISC::CRGBA getColorPushed() const { return _ColorPushed; }
|
||||
NLMISC::CRGBA getColorOver() const { return _ColorOver; }
|
||||
|
||||
// Override because mustupdate 3 states
|
||||
void setModulateGlobalColorAll(bool state);
|
||||
void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;}
|
||||
void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;}
|
||||
void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;}
|
||||
|
||||
virtual sint32 getAlpha() const { return _ColorNormal.A; }
|
||||
virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; }
|
||||
|
||||
std::string getColorAsString() const
|
||||
{ return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " +
|
||||
NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); }
|
||||
std::string getColorOverAsString() const
|
||||
{ return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " +
|
||||
NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); }
|
||||
std::string getColorPushedAsString() const
|
||||
{ return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " +
|
||||
NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); }
|
||||
|
||||
void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); }
|
||||
void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); }
|
||||
void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); }
|
||||
// @}
|
||||
|
||||
///\name radio button specific
|
||||
//@{
|
||||
/** Initialize radio button reference
|
||||
* Advanced:
|
||||
* NB: must call initRBRef() for radio button if button is created without parse().
|
||||
* NB: setParent() must be called before (else assert)
|
||||
*/
|
||||
void initRBRef();
|
||||
//@}
|
||||
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
|
||||
|
||||
|
||||
/// \name Handlers
|
||||
// @{
|
||||
// Event part
|
||||
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
|
||||
void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; }
|
||||
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
|
||||
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
|
||||
void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; }
|
||||
void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; }
|
||||
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
|
||||
|
||||
// get Event part
|
||||
std::string _getActionOnOver() const{ return CAHManager::getInstance()->getAHName( _AHOnOver ); }
|
||||
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftClick ); }
|
||||
std::string _getActionOnLeftLongClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftLongClick ); }
|
||||
std::string _getActionOnDblLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftDblClick ); }
|
||||
std::string _getActionOnRightClick() const { return CAHManager::getInstance()->getAHName( _AHOnRightClick ); }
|
||||
std::string _getActionOnClockTick() const { return CAHManager::getInstance()->getAHName( _AHOnClockTick ); }
|
||||
|
||||
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
|
||||
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
|
||||
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
|
||||
std::string _getParamsOnOver() const{ return _AHOverParams.toString(); }
|
||||
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
|
||||
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
|
||||
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
|
||||
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
|
||||
|
||||
// run action on left click
|
||||
void runLeftClickAction();
|
||||
|
||||
// Context menu accessor/ One for each button
|
||||
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
|
||||
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
|
||||
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
|
||||
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
|
||||
std::string getListMenuRight () { return _ListMenuRight.toString(); }
|
||||
// @}
|
||||
|
||||
|
||||
|
||||
int luaRunLeftClickAction(CLuaState &ls);
|
||||
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
|
||||
REFLECT_BOOL("pushed", getPushed, setPushed);
|
||||
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
|
||||
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
|
||||
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
|
||||
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
|
||||
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
|
||||
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
|
||||
REFLECT_BOOL("frozen", getFrozen, setFrozen);
|
||||
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
|
||||
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
|
||||
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
|
||||
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
EType _Type;
|
||||
|
||||
// State
|
||||
bool _Pushed : 1;
|
||||
bool _Over : 1;
|
||||
bool _OverWhenPushed : 1;
|
||||
bool _Frozen : 1;
|
||||
bool _FrozenHalfTone : 1;
|
||||
bool _ClickWhenPushed : 1;
|
||||
bool _ModulateGlobalColorNormal : 1;
|
||||
bool _ModulateGlobalColorPushed : 1;
|
||||
bool _ModulateGlobalColorOver : 1;
|
||||
bool _LeftLongClickHandled : 1; // Is it already handled ?
|
||||
bool _LeftDblClickHandled : 1;
|
||||
|
||||
|
||||
///\name radio button specific
|
||||
//@{
|
||||
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
|
||||
// There is only one radio button per group that own the reference (the first one)
|
||||
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
|
||||
//@}
|
||||
|
||||
|
||||
// Colors
|
||||
NLMISC::CRGBA _ColorNormal;
|
||||
NLMISC::CRGBA _ColorPushed;
|
||||
NLMISC::CRGBA _ColorOver;
|
||||
|
||||
///\name Long click specific
|
||||
//@{
|
||||
sint64 _LeftLongClickDate; // Time we left click down
|
||||
//@}
|
||||
|
||||
// for double click : last date at which last left click occurred
|
||||
static sint64 _LastLeftClickDate;
|
||||
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
|
||||
|
||||
///\name Action Handler
|
||||
//@{
|
||||
IActionHandler *_AHOnOver;
|
||||
CStringShared _AHOverParams;
|
||||
std::string _AHOnLeftClickString;
|
||||
std::string _AHOnLeftClickStringParams;
|
||||
IActionHandler *_AHOnLeftClick;
|
||||
CStringShared _AHLeftClickParams;
|
||||
IActionHandler *_AHOnLeftDblClick;
|
||||
CStringShared _AHLeftDblClickParams;
|
||||
IActionHandler *_AHOnRightClick;
|
||||
CStringShared _AHRightClickParams;
|
||||
IActionHandler *_AHOnClockTick;
|
||||
CStringShared _AHClockTickParams;
|
||||
IActionHandler *_AHOnLeftLongClick;
|
||||
CStringShared _AHLeftLongClickParams;
|
||||
//@}
|
||||
CStringShared _ListMenuLeft;
|
||||
CStringShared _ListMenuRight;
|
||||
|
||||
// get the colors modulated on request
|
||||
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
|
||||
{
|
||||
NLMISC::CRGBA rgba = _ColorNormal;
|
||||
if(_ModulateGlobalColorNormal)
|
||||
rgba.modulateFromColor(rgba, globalColor);
|
||||
return rgba;
|
||||
}
|
||||
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
|
||||
{
|
||||
NLMISC::CRGBA rgba = _ColorPushed;
|
||||
if(_ModulateGlobalColorPushed)
|
||||
rgba.modulateFromColor(rgba, globalColor);
|
||||
return rgba;
|
||||
}
|
||||
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
|
||||
{
|
||||
NLMISC::CRGBA rgba = _ColorOver;
|
||||
if(_ModulateGlobalColorOver)
|
||||
rgba.modulateFromColor(rgba, globalColor);
|
||||
return rgba;
|
||||
}
|
||||
|
||||
// call it at draw
|
||||
void updateOver(bool &lastOver);
|
||||
virtual void elementCaptured(CCtrlBase *capturedElement);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_CTRL_BASE_BUTTON_H
|
||||
|
||||
/* End of ctrl_base_button.h */
|
108
code/nel/include/nel/gui/ctrl_button.h
Normal file
108
code/nel/include/nel/gui/ctrl_button.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
// 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 RZ_CTRL_BUTTON_H
|
||||
#define RZ_CTRL_BUTTON_H
|
||||
|
||||
#include "nel/gui/ctrl_base_button.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptor;
|
||||
|
||||
/**
|
||||
* <Class description>
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCtrlButton : public CCtrlBaseButton
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CCtrlButton(const TCtorParam ¶m) : CCtrlBaseButton(param)
|
||||
{
|
||||
_Scale = false;
|
||||
_Align = 0;
|
||||
}
|
||||
|
||||
void setAlignFromString( const std::string &s );
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// Init part
|
||||
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */);
|
||||
|
||||
// Display part
|
||||
virtual void draw();
|
||||
|
||||
void setTexture (const std::string&name);
|
||||
void setTexturePushed (const std::string&name);
|
||||
void setTextureOver (const std::string&name);
|
||||
|
||||
void fitTexture();
|
||||
|
||||
std::string getTexture () const;
|
||||
std::string getTexturePushed () const;
|
||||
std::string getTextureOver() const;
|
||||
|
||||
bool isTextureValid() const { return _TextureIdNormal != -1; }
|
||||
|
||||
// test if the texture must scale
|
||||
bool getScale() const { return _Scale; }
|
||||
void setScale(bool scale) { _Scale = scale; }
|
||||
|
||||
|
||||
/// \from CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton)
|
||||
REFLECT_STRING("texture", getTexture, setTexture);
|
||||
REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed);
|
||||
REFLECT_STRING("texture_over", getTextureOver, setTextureOver);
|
||||
REFLECT_BOOL("scale", getScale, setScale);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
CViewRenderer::CTextureId _TextureIdNormal;
|
||||
CViewRenderer::CTextureId _TextureIdPushed;
|
||||
CViewRenderer::CTextureId _TextureIdOver;
|
||||
|
||||
private:
|
||||
|
||||
bool _Scale;
|
||||
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_CTRL_BUTTON_H
|
||||
|
||||
/* End of ctrl_button.h */
|
110
code/nel/include/nel/gui/ctrl_col_pick.h
Normal file
110
code/nel/include/nel/gui/ctrl_col_pick.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
// 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 RZ_CTRL_COL_PICK_H
|
||||
#define RZ_CTRL_COL_PICK_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* Class handling a Color Picker
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlColPick : public CCtrlBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CCtrlColPick(const TCtorParam ¶m);
|
||||
~CCtrlColPick();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
sint32 getColorR () const { return _ColorSelect.R; }
|
||||
sint32 getColorG () const { return _ColorSelect.G; }
|
||||
sint32 getColorB () const { return _ColorSelect.B; }
|
||||
sint32 getColorA () const { return _ColorSelect.A; }
|
||||
|
||||
void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; }
|
||||
void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; }
|
||||
void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; }
|
||||
void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; }
|
||||
|
||||
|
||||
std::string getColor () const; // Get Color Selected
|
||||
void setColor (const std::string &col); // Set Color Selected
|
||||
|
||||
std::string getColorOver () const; // Get Color Over
|
||||
void setColorOver (const std::string &col); // Set Color Over
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase)
|
||||
REFLECT_SINT32("r", getColorR, setColorR);
|
||||
REFLECT_SINT32("g", getColorG, setColorG);
|
||||
REFLECT_SINT32("b", getColorB, setColorB);
|
||||
REFLECT_SINT32("a", getColorA, setColorA);
|
||||
REFLECT_STRING("color", getColor, setColor);
|
||||
REFLECT_STRING("color_over", getColorOver, setColorOver);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
void selectColor (sint32 x, sint32 y);
|
||||
NLMISC::CRGBA getColor (sint32 x, sint32 y);
|
||||
|
||||
protected:
|
||||
|
||||
bool _MouseDown;
|
||||
|
||||
sint32 _Texture;
|
||||
|
||||
NLMISC::CRGBA _ColorSelect; // Last Color selected
|
||||
NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer
|
||||
|
||||
std::string _AHOnChange;
|
||||
std::string _AHOnChangeParams;
|
||||
|
||||
CInterfaceProperty _ColSelR;
|
||||
CInterfaceProperty _ColSelG;
|
||||
CInterfaceProperty _ColSelB;
|
||||
CInterfaceProperty _ColSelA;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // RZ_CTRL_COL_PICK_H
|
||||
|
||||
/* End of ctrl_col_pick.h */
|
||||
|
||||
|
64
code/nel/include/nel/gui/ctrl_draggable.h
Normal file
64
code/nel/include/nel/gui/ctrl_draggable.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
// 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 CTRL_DRAGGABLE_H
|
||||
#define CTRL_DRAGGABLE_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CCtrlDraggable : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CCtrlDraggable )
|
||||
|
||||
CCtrlDraggable( const TCtorParam ¶m );
|
||||
virtual ~CCtrlDraggable(){};
|
||||
|
||||
static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; }
|
||||
bool isDragged() const{ return dragged; }
|
||||
void setDragged( bool dragged ){ this->dragged = dragged; }
|
||||
bool isDraggable() const{ return draggable; }
|
||||
void setDraggable( bool draggable ){ this->draggable = draggable; }
|
||||
|
||||
void abortDragging()
|
||||
{
|
||||
dragged = false;
|
||||
_LastDraggedSheet = NULL;
|
||||
}
|
||||
|
||||
// Necessary because of reflection, no other purpose
|
||||
void draw(){}
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase)
|
||||
REFLECT_BOOL("dragable", isDraggable, setDraggable);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
|
||||
|
||||
private:
|
||||
static CCtrlDraggable *_LastDraggedSheet;
|
||||
bool dragged;
|
||||
bool draggable;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
94
code/nel/include/nel/gui/ctrl_polygon.h
Normal file
94
code/nel/include/nel/gui/ctrl_polygon.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
// 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 RZ_CTRL_POLYGON_H
|
||||
#define RZ_CTRL_POLYGON_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
#include "nel/misc/geom_ext.h"
|
||||
#include "nel/misc/polygon.h"
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CVector2f;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Display of an arbitrary polygon in the ui.
|
||||
* polygons are clipped & batched.
|
||||
*
|
||||
* Derives from CCtrlBase in order to provide button / tooltip capability
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 1/2006
|
||||
*/
|
||||
class CCtrlPolygon : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
CCtrlPolygon();
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
/** Change the vertices. This is costly because concav / complex polys are split in a list of triangles
|
||||
*/
|
||||
void setVertices(const std::vector<NLMISC::CVector> &vertices);
|
||||
const std::vector<NLMISC::CVector> &getVertices() const { return _Poly.Vertices; }
|
||||
// test if current position in inside the current (transformed) poly (in window space)
|
||||
bool contains(const NLMISC::CVector2f &pos) const;
|
||||
// color
|
||||
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
|
||||
NLMISC::CRGBA getColorRGBA() const { return _Color; }
|
||||
// from CViewBase
|
||||
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
|
||||
virtual void setAlpha(sint32 a);
|
||||
/** Change the matrix for this poly. Changing the matrix is usually cheaper than changing
|
||||
* The vertices because complex poly do not have to be split again
|
||||
*/
|
||||
//void setMatrix(const NLMISC::CMatrix &mat);
|
||||
//const NLMISC::CMatrix &getMatrix() const { return _Matrix; }
|
||||
// test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself)
|
||||
bool isValid() const { return _Valid; }
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
// no capturable by default (just tooltip capability wanted)
|
||||
virtual bool isCapturable() const { return false; }
|
||||
private:
|
||||
NLMISC::CPolygon _Poly;
|
||||
NLMISC::CPolygon2D _XFormPoly;
|
||||
//NLMISC::CMatrix _Matrix;
|
||||
bool _Valid;
|
||||
bool _Touched;
|
||||
NLMISC::CRGBA _Color;
|
||||
std::vector<NLMISC::CTriangle> _Tris;
|
||||
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
|
||||
private:
|
||||
void updateBoudingRect();
|
||||
protected:
|
||||
// TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ...
|
||||
virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src);
|
||||
public:
|
||||
void touch();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
116
code/nel/include/nel/gui/ctrl_quad.h
Normal file
116
code/nel/include/nel/gui/ctrl_quad.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
// 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 RZ_CTRL_QUAD_H
|
||||
#define RZ_CTRL_QUAD_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
#include "nel/misc/geom_ext.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
|
||||
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
|
||||
* are driven by the quad vertices coordinates (see setQuad).
|
||||
*
|
||||
* Derives from CCtrlBase for tooltipping support
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 12/2005
|
||||
*/
|
||||
class CCtrlQuad : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount };
|
||||
|
||||
|
||||
CCtrlQuad();
|
||||
|
||||
// from CInterfaceElement
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
// from CViewBase
|
||||
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
|
||||
virtual void setAlpha (sint32 a);
|
||||
|
||||
// texture
|
||||
void setTexture(const std::string &texName);
|
||||
std::string getTexture () const;
|
||||
|
||||
// color
|
||||
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
|
||||
NLMISC::CRGBA getColorRGBA() const { return _Color; }
|
||||
|
||||
/** Set a new quad relative to parent pos
|
||||
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
|
||||
*/
|
||||
void setQuad(const NLMISC::CQuad &quad);
|
||||
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
|
||||
/** Fit the given texture size (no hotspot for now, always centered)
|
||||
* NB : current texture is not modified.
|
||||
*/
|
||||
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
|
||||
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
|
||||
const NLMISC::CQuad &getQuad() const { return _Quad; }
|
||||
|
||||
void setAdditif(bool additif);
|
||||
bool getAdditif() const { return _Additif; }
|
||||
|
||||
void setFiltered(bool filtered);
|
||||
bool getFiltered() const { return _Filtered; }
|
||||
|
||||
void setPattern(float umin, float umax, TWrapMode wrapMode);
|
||||
|
||||
/** Set uvs for each corners -> this will change the wrap mode to CustomUVs
|
||||
* Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior
|
||||
*/
|
||||
void setCustomUVs(const NLMISC::CUV uvs[4]);
|
||||
|
||||
|
||||
// from CCtrlBase, no op by default
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
// see if this control contains the given point (in parent coords)
|
||||
bool contains(const NLMISC::CVector2f &pos) const;
|
||||
|
||||
// no capturable by default (just tooltip capability wanted)
|
||||
virtual bool isCapturable() const { return false; }
|
||||
|
||||
|
||||
private:
|
||||
NLMISC::CRGBA _Color;
|
||||
NLMISC::CQuad _Quad;
|
||||
NLMISC::CQuadUV _RealQuad; // absolute coords
|
||||
float _ClampedUCorrection;
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
bool _Additif;
|
||||
bool _Filtered;
|
||||
float _UMin;
|
||||
float _UMax;
|
||||
TWrapMode _WrapMode;
|
||||
NLMISC::CUV _CustomUVs[4];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
206
code/nel/include/nel/gui/ctrl_scroll.h
Normal file
206
code/nel/include/nel/gui/ctrl_scroll.h
Normal file
|
@ -0,0 +1,206 @@
|
|||
// 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 RZ_CTRL_SCROLL_H
|
||||
#define RZ_CTRL_SCROLL_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/ctrl_scroll_base.h"
|
||||
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* Class handling scollbar function
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
|
||||
{
|
||||
|
||||
public:
|
||||
DECLARE_UI_CLASS( CCtrlScroll )
|
||||
CCtrlScroll(const TCtorParam ¶m);
|
||||
~CCtrlScroll();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
void setTarget (CInterfaceGroup *pIG);
|
||||
// Return the delta value the track has moved
|
||||
sint32 moveTrackX (sint32 dx);
|
||||
sint32 moveTrackY (sint32 dy);
|
||||
|
||||
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
|
||||
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
|
||||
*/
|
||||
void moveTargetX (sint32 dx);
|
||||
void moveTargetY (sint32 dy);
|
||||
|
||||
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
|
||||
// invert the factor for target
|
||||
void setInverted(bool invert) { _Inverted = invert; }
|
||||
|
||||
void setTextureBottomOrLeft (const std::string &txName);
|
||||
void setTextureMiddle (const std::string &txName);
|
||||
void setTextureTopOrRight (const std::string &txName);
|
||||
std::string getTextureBottomOrLeft() const;
|
||||
std::string getTextureMiddle() const;
|
||||
std::string getTextureTopOrRight() const;
|
||||
|
||||
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
|
||||
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
|
||||
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
|
||||
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
|
||||
|
||||
// number scroller
|
||||
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
|
||||
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
|
||||
void setValue(sint32 value);
|
||||
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
|
||||
void setStepValue(uint32 step) { _StepValue= step; }
|
||||
|
||||
void setTrackPos(sint32 pos);
|
||||
sint32 getTrackPos() const { return _TrackPos; }
|
||||
sint32 getTrackSize() const { return _TrackSize; }
|
||||
// dummy set for track size (forlua export)
|
||||
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
|
||||
|
||||
|
||||
void setFrozen (bool state);
|
||||
bool getFrozen () const { return _Frozen; }
|
||||
|
||||
int luaSetTarget(CLuaState &ls);
|
||||
int luaEnsureVisible(CLuaState &ls);
|
||||
|
||||
// name
|
||||
void setName(const std::string & val) {_Name = val;}
|
||||
std::string getName() const {return _Name;}
|
||||
|
||||
// max
|
||||
void setMax(sint32 max) {_Max = max;}
|
||||
sint32 getMax() const {return _Max;}
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
|
||||
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
|
||||
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
|
||||
REFLECT_SINT32("value", getValue, setValue);
|
||||
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
|
||||
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
|
||||
REFLECT_STRING("name", getName, setName);
|
||||
REFLECT_SINT32("max", getMax, setMax);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
/** Ensure that a child element be visible into the frame through which
|
||||
* its parent group is displayed.
|
||||
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
|
||||
* matching the middle of the list, we would do :
|
||||
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
|
||||
*
|
||||
* The scrollbar will be moved accordingly.
|
||||
*/
|
||||
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
|
||||
sint32 _Value; // Or we can use a normal value
|
||||
sint32 _InitialValue;
|
||||
|
||||
sint32 _Min, _Max;
|
||||
std::string _AHOnScroll;
|
||||
std::string _AHOnScrollParams;
|
||||
//
|
||||
std::string _AHOnScrollEnd;
|
||||
std::string _AHOnScrollEndParams;
|
||||
//
|
||||
//
|
||||
std::string _AHOnScrollCancel;
|
||||
std::string _AHOnScrollCancelParams;
|
||||
|
||||
|
||||
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
|
||||
|
||||
sint32 _TrackDispPos;
|
||||
sint32 _TrackPos;
|
||||
sint32 _TrackSize;
|
||||
sint32 _TrackSizeMin;
|
||||
|
||||
sint32 _MouseDownOffsetX;
|
||||
sint32 _MouseDownOffsetY;
|
||||
|
||||
sint32 _TxIdB; // Same as Left if Horizontal sb
|
||||
sint32 _TxIdM;
|
||||
sint32 _TxIdT; // Same as Right if Horizontal sb
|
||||
|
||||
uint8 _TileM;
|
||||
|
||||
sint32 _LastTargetHReal;
|
||||
sint32 _LastTargetMaxHReal;
|
||||
sint32 _LastTargetOfsY;
|
||||
sint32 _LastTargetWReal;
|
||||
sint32 _LastTargetMaxWReal;
|
||||
sint32 _LastTargetOfsX;
|
||||
|
||||
bool _Vertical : 1; // true if vertical track bar
|
||||
bool _IsDBLink : 1;
|
||||
bool _ObserverOn : 1;
|
||||
bool _Inverted : 1;
|
||||
bool _MouseDown : 1;
|
||||
bool _CallingAH : 1;
|
||||
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
|
||||
bool _Frozen : 1;
|
||||
|
||||
// For Target Scroller only: the target offset step in pixel.
|
||||
sint32 _TargetStepX;
|
||||
sint32 _TargetStepY;
|
||||
|
||||
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
|
||||
uint32 _StepValue;
|
||||
|
||||
// Slider's name
|
||||
std::string _Name;
|
||||
|
||||
void computeTargetOfsFromPos();
|
||||
|
||||
// from IPropertyObserver
|
||||
virtual void update(NLMISC::ICDBNode *node);
|
||||
|
||||
// step the value, and clamp it
|
||||
void normalizeValue(sint32 &value);
|
||||
|
||||
void runAH(const std::string &name, const std::string ¶ms);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // RZ_CTRL_SCROLL_H
|
||||
|
||||
/* End of ctrl_scroll.h */
|
||||
|
||||
|
60
code/nel/include/nel/gui/ctrl_scroll_base.h
Normal file
60
code/nel/include/nel/gui/ctrl_scroll_base.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
// 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 CTRL_SCROLL_BASE_H
|
||||
#define CTRL_SCROLL_BASE_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CInterfaceGroup;
|
||||
|
||||
class CCtrlScrollBase : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CCtrlScrollBase )
|
||||
|
||||
CCtrlScrollBase( const TCtorParam ¶m );
|
||||
virtual ~CCtrlScrollBase();
|
||||
|
||||
virtual void setTarget( CInterfaceGroup *pIG );
|
||||
CInterfaceGroup* getTarget(){ return _Target; }
|
||||
virtual sint32 moveTrackX( sint32 dx );
|
||||
virtual sint32 moveTrackY( sint32 dy );
|
||||
|
||||
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
|
||||
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
|
||||
*/
|
||||
virtual void moveTargetX( sint32 dx );
|
||||
virtual void moveTargetY( sint32 dy );
|
||||
|
||||
|
||||
// Necessary because of reflection, no other purpose
|
||||
void draw(){}
|
||||
|
||||
protected:
|
||||
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
83
code/nel/include/nel/gui/ctrl_sheet_selection.h
Normal file
83
code/nel/include/nel/gui/ctrl_sheet_selection.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
// 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 CL_SHEET_CTRL_SELECTION_H
|
||||
#define CL_SHEET_CTRL_SELECTION_H
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class IActionHandler;
|
||||
|
||||
/** Infos about a selection group
|
||||
*/
|
||||
class CSheetSelectionGroup
|
||||
{
|
||||
public:
|
||||
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
|
||||
void setTexture(const std::string &texName);
|
||||
sint32 getTextureIndex() const { return _TextureIndex; }
|
||||
sint32 getTextureWidth() const { return _TextureWidth; }
|
||||
sint32 getTextureHeight() const { return _TextureHeight; }
|
||||
void setColor(NLMISC::CRGBA color) { _Color = color; }
|
||||
NLMISC::CRGBA getColor() const { return _Color; }
|
||||
void setActive(bool active) { _Active = active; }
|
||||
bool isActive() const { return _Active; }
|
||||
const std::string &getName() const { return _Name; }
|
||||
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
|
||||
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
|
||||
private:
|
||||
std::string _Name;
|
||||
bool _Active;
|
||||
sint32 _TextureIndex; // index for the selection texture
|
||||
sint32 _TextureWidth;
|
||||
sint32 _TextureHeight;
|
||||
NLMISC::CRGBA _Color; // color that modulate the texture of selection
|
||||
bool _GlobalColorEnabled;
|
||||
};
|
||||
|
||||
/** Class to manage selection of sheet.
|
||||
* Sheet are managed by groups, identified by their ID.
|
||||
*/
|
||||
class CCtrlSheetSelection
|
||||
{
|
||||
public:
|
||||
// Add a group, and returns its index, or -1 if already created.
|
||||
sint addGroup(const std::string &name);
|
||||
// Get a group by its name (must exist)
|
||||
CSheetSelectionGroup *getGroup(const std::string &name);
|
||||
const CSheetSelectionGroup *getGroup(const std::string &name) const;
|
||||
// Get a group by its index
|
||||
CSheetSelectionGroup *getGroup(uint index);
|
||||
const CSheetSelectionGroup *getGroup(uint index) const;
|
||||
// Get the index of a group from its name, return -1 if not a group
|
||||
sint getGroupIndex(const std::string &name) const;
|
||||
// Deactivate all groups
|
||||
void deactivateAll();
|
||||
// delete all groups
|
||||
void deleteGroups();
|
||||
private:
|
||||
//
|
||||
typedef std::vector<CSheetSelectionGroup> TGroupVect;
|
||||
typedef std::map<std::string, uint> TGroupNameToIndex;
|
||||
private:
|
||||
TGroupVect _Groups;
|
||||
TGroupNameToIndex _GroupNameToIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
170
code/nel/include/nel/gui/ctrl_text_button.h
Normal file
170
code/nel/include/nel/gui/ctrl_text_button.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
// 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 NL_CTRL_TEXT_BUTTON_H
|
||||
#define NL_CTRL_TEXT_BUTTON_H
|
||||
|
||||
#include "nel/gui/ctrl_base_button.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptor;
|
||||
class CViewText;
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Text Button that can be either Push or Toggle button. Localized, auto-resize
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCtrlTextButton : public CCtrlBaseButton
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CCtrlTextButton(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// Init part
|
||||
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
// Display part
|
||||
virtual void draw();
|
||||
|
||||
// Hide/Show the text also.
|
||||
virtual void setActive(bool state);
|
||||
|
||||
// Add also our ViewText
|
||||
virtual void onAddToGroup();
|
||||
|
||||
|
||||
/// \from CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
// Special Text Colors accessors
|
||||
// Colors
|
||||
NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;}
|
||||
void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;}
|
||||
NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;}
|
||||
void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;}
|
||||
NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;}
|
||||
void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;}
|
||||
// Shadow Colors
|
||||
NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;}
|
||||
void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;}
|
||||
NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;}
|
||||
void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;}
|
||||
NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;}
|
||||
void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;}
|
||||
// Global Modulate Colors
|
||||
bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;}
|
||||
void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;}
|
||||
bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;}
|
||||
void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;}
|
||||
bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;}
|
||||
void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;}
|
||||
// Set text (noop if text id)
|
||||
void setText (const ucstring &text);
|
||||
ucstring getText () const;
|
||||
|
||||
void setHardText (const std::string &text);
|
||||
std::string getHardText () const;
|
||||
|
||||
CViewText* getViewText();
|
||||
void setViewText(CViewText* text) {_ViewText=text;}
|
||||
|
||||
void setTextX(sint32 x);
|
||||
sint32 getTextX() const { return _TextX; }
|
||||
|
||||
void setWMargin(sint32 w) { _WMargin = w; }
|
||||
sint32 getWMargin() const { return _WMargin; }
|
||||
|
||||
sint32 getWMin() const { return _WMin; }
|
||||
void setWMin( sint32 wmin ) { _WMin = wmin; }
|
||||
|
||||
// Compute Size according to bitmap and Text (Ensure as big as possible button)
|
||||
sint32 getWMax() const;
|
||||
|
||||
int luaGetViewText(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
|
||||
REFLECT_UCSTRING("uc_hardtext", getText, setText);
|
||||
REFLECT_STRING("hardtext", getHardText, setHardText);
|
||||
REFLECT_SINT32("text_x", getTextX, setTextX)
|
||||
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
|
||||
REFLECT_SINT32("wmin", getWMin, setWMin)
|
||||
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
enum {NumTexture= 3};
|
||||
|
||||
CViewRenderer::CTextureId _TextureIdNormal[NumTexture];
|
||||
CViewRenderer::CTextureId _TextureIdPushed[NumTexture];
|
||||
CViewRenderer::CTextureId _TextureIdOver[NumTexture];
|
||||
|
||||
// setup
|
||||
void setup();
|
||||
|
||||
private:
|
||||
|
||||
CViewText *_ViewText;
|
||||
|
||||
bool _Setuped;
|
||||
bool _IsViewTextId;
|
||||
bool _ForceTextOver; // text is displayed over the "over" texture
|
||||
// Size of Bitmaps
|
||||
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
|
||||
// Value to add to TextW to get button W.
|
||||
sint32 _WMargin;
|
||||
// Min W Value
|
||||
sint32 _WMin;
|
||||
sint32 _TextY;
|
||||
sint32 _TextX;
|
||||
THotSpot _TextPosRef;
|
||||
THotSpot _TextParentPosRef;
|
||||
// Special Colors for text
|
||||
NLMISC::CRGBA _TextColorNormal;
|
||||
NLMISC::CRGBA _TextColorPushed;
|
||||
NLMISC::CRGBA _TextColorOver;
|
||||
NLMISC::CRGBA _TextShadowColorNormal;
|
||||
NLMISC::CRGBA _TextShadowColorPushed;
|
||||
NLMISC::CRGBA _TextShadowColorOver;
|
||||
bool _TextModulateGlobalColorNormal;
|
||||
bool _TextModulateGlobalColorPushed;
|
||||
bool _TextModulateGlobalColorOver;
|
||||
bool _TextHeaderColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_CTRL_TEXT_BUTTON_H
|
||||
|
||||
/* End of ctrl_text_button.h */
|
|
@ -1,53 +1,59 @@
|
|||
// 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 RZ_CTRL_TOOLTIP_H
|
||||
#define RZ_CTRL_TOOLTIP_H
|
||||
|
||||
#include "ctrl_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
|
||||
class CEventDescriptor;
|
||||
class CInterfaceManager;
|
||||
|
||||
/**
|
||||
* \author Matthieu 'Mr TRAP' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlToolTip : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CCtrlToolTip)
|
||||
/// Constructor
|
||||
CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {}
|
||||
|
||||
virtual bool handleEvent (const CEventDescriptor& eventDesc);
|
||||
virtual void draw();
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
// Can do nothing with tooltip (but display it :) )
|
||||
virtual bool isCapturable() const {return false;}
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // RZ_CTRL_TOOLTIP_H
|
||||
|
||||
/* End of ctrl_tooltip.h */
|
||||
// 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 RZ_CTRL_TOOLTIP_H
|
||||
#define RZ_CTRL_TOOLTIP_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptor;
|
||||
|
||||
|
||||
/**
|
||||
* \author Matthieu 'Mr TRAP' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlToolTip : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CCtrlToolTip)
|
||||
/// Constructor
|
||||
CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {}
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
virtual void draw();
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
// Can do nothing with tooltip (but display it :) )
|
||||
virtual bool isCapturable() const {return false;}
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_CTRL_TOOLTIP_H
|
||||
|
||||
/* End of ctrl_tooltip.h */
|
||||
|
71
code/nel/include/nel/gui/db_manager.h
Normal file
71
code/nel/include/nel/gui/db_manager.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
// 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 DBMANAGER_H
|
||||
#define DBMANAGER_H
|
||||
|
||||
#include "nel/misc/cdb_manager.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
Database Manager
|
||||
|
||||
Provides access to a simple CDB based tree hierarchical data store
|
||||
*/
|
||||
class CDBManager : public NLMISC::CCDBManager
|
||||
{
|
||||
public:
|
||||
static CDBManager* getInstance();
|
||||
static void release();
|
||||
|
||||
/**
|
||||
Retrieves a leaf node from the database.
|
||||
@param name - name of the data leaf node we are querying.
|
||||
@param create - when true if a node cannot be found it is created.
|
||||
*/
|
||||
NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true );
|
||||
|
||||
/**
|
||||
Deletes a node from the database.
|
||||
@param name - name of the node.
|
||||
*/
|
||||
void delDbProp( const std::string &name );
|
||||
|
||||
/**
|
||||
Returns a leaf node's content as an sint32
|
||||
@param name - name of the leaf node.
|
||||
*/
|
||||
sint32 getDbValue32( const std::string &name );
|
||||
|
||||
/**
|
||||
Returns the root branch of the database.
|
||||
*/
|
||||
NLMISC::CCDBNodeBranch* getDB() const;
|
||||
|
||||
private:
|
||||
CDBManager();
|
||||
~CDBManager();
|
||||
|
||||
static CDBManager *instance;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
169
code/nel/include/nel/gui/dbgroup_combo_box.h
Normal file
169
code/nel/include/nel/gui/dbgroup_combo_box.h
Normal file
|
@ -0,0 +1,169 @@
|
|||
// 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 NL_DBGROUP_COMBO_BOX_H
|
||||
#define NL_DBGROUP_COMBO_BOX_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBaseButton;
|
||||
class CViewText;
|
||||
class CGroupMenu;
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Widget: ComboBox of text
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBGroupComboBox : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBGroupComboBox(const TCtorParam ¶m);
|
||||
~CDBGroupComboBox();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// CInterfaceGroup Interface
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords ();
|
||||
virtual void checkCoords ();
|
||||
|
||||
// Combo Texts
|
||||
void resetTexts();
|
||||
void addText(const ucstring &text);
|
||||
void setText(uint i, const ucstring &text);
|
||||
void insertText(uint i, const ucstring &text);
|
||||
const ucstring &getText(uint i) const;
|
||||
const uint &getTextId(uint i) const;
|
||||
uint getTextPos(uint nId) const;
|
||||
const ucstring &getTexture(uint i) const;
|
||||
void removeText(uint nPos);
|
||||
uint getNumTexts() const {return (uint)_Texts.size();}
|
||||
void sortText();
|
||||
|
||||
// selection
|
||||
void setSelection(sint32 val);
|
||||
void setSelectionNoTrigger(sint32 val);
|
||||
sint32 getSelection() const;
|
||||
|
||||
// selection number
|
||||
void setSelectionNb(sint32 /* val */){}
|
||||
sint32 getSelectionNb() const {return (sint32)_Texts.size();}
|
||||
|
||||
// selection text
|
||||
void setSelectionText(const std::string & val);
|
||||
std::string getSelectionText() const;
|
||||
|
||||
// view text
|
||||
void setViewText(const ucstring & text);
|
||||
ucstring getViewText() const;
|
||||
|
||||
void setTexture(uint i, const ucstring &texture);
|
||||
|
||||
sint32 evalContentWidth() const;
|
||||
|
||||
|
||||
int luaAddText(CLuaState &ls);
|
||||
int luaRemoveSelection(CLuaState &ls);
|
||||
int luaRemoveText(CLuaState &ls);
|
||||
int luaRemoveTextByIndex(CLuaState &ls);
|
||||
int luaResetTexts(CLuaState &ls);
|
||||
int luaSetText(CLuaState &ls);
|
||||
int luaInsertText(CLuaState &ls);
|
||||
int luaGetText(CLuaState &ls);
|
||||
int luaGetNumTexts(CLuaState &ls);
|
||||
int luaSetTexture(CLuaState &ls);
|
||||
|
||||
|
||||
REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup)
|
||||
REFLECT_SINT32("selection", getSelection, setSelection)
|
||||
REFLECT_LUA_METHOD("addText", luaAddText)
|
||||
REFLECT_LUA_METHOD("setText", luaSetText)
|
||||
REFLECT_LUA_METHOD("insertText", luaInsertText)
|
||||
REFLECT_LUA_METHOD("setTexture", luaSetTexture)
|
||||
REFLECT_LUA_METHOD("getText", luaGetText)
|
||||
REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts)
|
||||
REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection)
|
||||
REFLECT_LUA_METHOD("removeText", luaRemoveText)
|
||||
REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex)
|
||||
REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
|
||||
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
|
||||
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText)
|
||||
REFLECT_UCSTRING ("view_text", getViewText, setViewText)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
protected:
|
||||
friend class CHandlerComboBoxSelectStart;
|
||||
|
||||
bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead
|
||||
bool _Setuped;
|
||||
bool _DirtySelection;
|
||||
sint32 _CacheSelection;
|
||||
|
||||
// sint32
|
||||
CInterfaceProperty _Selection;
|
||||
sint32 _NotLinkedToDBSelection;
|
||||
std::vector<std::pair<uint, ucstring> > _Texts;
|
||||
std::vector<ucstring> _Textures;
|
||||
|
||||
// Action Handler called on combo click
|
||||
std::string _AHOnSelectStart;
|
||||
|
||||
// Action handler called when the content is changed
|
||||
std::string _AHOnChange;
|
||||
std::string _AHOnChangeParams;
|
||||
bool _CallingOnChangeActionHandler; // avoid infinite loop here
|
||||
|
||||
|
||||
// Children
|
||||
CViewText *_ViewText;
|
||||
CCtrlBaseButton *_SelectButton;
|
||||
|
||||
bool _IsExternViewText;
|
||||
ucstring _ExternViewText;
|
||||
|
||||
|
||||
private:
|
||||
void setup();
|
||||
void dirt();
|
||||
public:
|
||||
// private : fill a menu with current content
|
||||
void fillMenu(CGroupMenu *groupMenu) const;
|
||||
|
||||
|
||||
static std::string measureMenu;
|
||||
static std::string selectMenu;
|
||||
static std::string selectMenuOut;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_DBGROUP_COMBO_BOX_H
|
||||
|
||||
/* End of dbgroup_combo_box.h */
|
100
code/nel/include/nel/gui/dbgroup_select_number.h
Normal file
100
code/nel/include/nel/gui/dbgroup_select_number.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
// 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 NL_DBGROUP_SELECT_NUMBER_H
|
||||
#define NL_DBGROUP_SELECT_NUMBER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBaseButton;
|
||||
class CViewText;
|
||||
class CViewBitmap;
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Widget to select a number
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBGroupSelectNumber : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBGroupSelectNumber(const TCtorParam ¶m);
|
||||
~CDBGroupSelectNumber();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// CInterfaceGroup Interface
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords ();
|
||||
virtual void checkCoords();
|
||||
virtual void draw ();
|
||||
virtual void clearViews ();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
// mod interface
|
||||
void changeValue(sint delta);
|
||||
|
||||
sint32 getMinValue () const { return _MinValue; }
|
||||
void setMinValue (sint32 m) { _MinValue = m; }
|
||||
sint32 getMaxValue () const { return _MaxValue; }
|
||||
void setMaxValue (sint32 m) { _MaxValue = m; }
|
||||
|
||||
sint32 getCurrentValue () const { return _Number.getSInt32(); }
|
||||
void setCurrentValue (sint32 val) { _Number.setSInt32(val); }
|
||||
|
||||
REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup)
|
||||
REFLECT_SINT32("min", getMinValue, setMinValue);
|
||||
REFLECT_SINT32("max", getMaxValue, setMaxValue);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
// sint32
|
||||
CInterfaceProperty _Number;
|
||||
bool _LoopMode;
|
||||
sint _MinValue;
|
||||
sint _MaxValue;
|
||||
sint _DeltaMultiplier;
|
||||
|
||||
// Children
|
||||
CViewBitmap *_SlotNumber;
|
||||
CViewText *_TextNumber;
|
||||
CCtrlBaseButton *_ButtonUp;
|
||||
CCtrlBaseButton *_ButtonDown;
|
||||
|
||||
private:
|
||||
|
||||
void setup();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_DBGROUP_SELECT_NUMBER_H
|
||||
|
||||
/* End of dbgroup_select_number.h */
|
115
code/nel/include/nel/gui/dbview_bar.h
Normal file
115
code/nel/include/nel/gui/dbview_bar.h
Normal file
|
@ -0,0 +1,115 @@
|
|||
// 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 RZ_DBVIEW_BAR_H
|
||||
#define RZ_DBVIEW_BAR_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_bitmap.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* class implementing a bitmap used as the front texture of a progress bar
|
||||
* the bitmap is drawn from _X to _W * _Range/_RangeMax
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewBar : public CViewBitmap
|
||||
{
|
||||
public:
|
||||
enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick };
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewBar(const TCtorParam ¶m)
|
||||
: CViewBitmap(param),
|
||||
_Slot(TCtorParam())
|
||||
{
|
||||
_Color= NLMISC::CRGBA::White;
|
||||
_ValueInt= 0;
|
||||
_RangeInt = 255;
|
||||
_ReferenceInt= 0;
|
||||
_Type = ViewBar_Normal;
|
||||
}
|
||||
|
||||
void setType (TViewBar vb);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
virtual void updateCoords ();
|
||||
virtual void draw ();
|
||||
|
||||
/// Nbs: Values by Int are not used if the Links are setuped
|
||||
void setValue (sint32 r) { _ValueInt = r; }
|
||||
void setRange (sint32 r) { _RangeInt = r; }
|
||||
void setReference (sint32 r) { _ReferenceInt = r; }
|
||||
sint32 getValue () const { return _ValueInt; }
|
||||
sint32 getRange () const { return _RangeInt; }
|
||||
sint32 getReference () const { return _ReferenceInt; }
|
||||
|
||||
void setValueDbLink (const std::string &r);
|
||||
void setRangeDbLink (const std::string &r);
|
||||
void setReferenceDbLink (const std::string &r);
|
||||
std::string getValueDbLink () const;
|
||||
std::string getRangeDbLink () const;
|
||||
std::string getReferenceDbLink () const;
|
||||
|
||||
// Reflect ValueInt (ie not used if the link is setuped)
|
||||
REFLECT_EXPORT_START(CDBViewBar, CViewBitmap)
|
||||
REFLECT_SINT32 ("value", getValue, setValue);
|
||||
REFLECT_SINT32 ("range", getRange, setRange);
|
||||
REFLECT_SINT32 ("reference", getReference, setReference);
|
||||
REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink);
|
||||
REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink);
|
||||
REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
CViewBitmap _Slot;
|
||||
TViewBar _Type;
|
||||
sint32 _HBar;
|
||||
NLMISC::CRGBA _ColorNegative;
|
||||
|
||||
// Value of the progression in arbitrary units. should be integer
|
||||
CInterfaceProperty _Value;
|
||||
// Max range of the progression in arbitrary units. should be integer
|
||||
CInterfaceProperty _Range;
|
||||
// Reference of the progression (substracted from value and range).
|
||||
CInterfaceProperty _Reference;
|
||||
|
||||
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
|
||||
sint32 _ValueInt;
|
||||
sint32 _RangeInt;
|
||||
sint32 _ReferenceInt;
|
||||
|
||||
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
|
||||
sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_DBVIEW_BAR_H
|
||||
|
||||
/* End of dbview_bar.h */
|
110
code/nel/include/nel/gui/dbview_bar3.h
Normal file
110
code/nel/include/nel/gui/dbview_bar3.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
// 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 RZ_DBVIEW_BAR3_H
|
||||
#define RZ_DBVIEW_BAR3_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_bitmap.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* class implementing a 3 Bar widget
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewBar3 : public CViewBitmap
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewBar3(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
virtual void updateCoords ();
|
||||
|
||||
void setMini (bool mini);
|
||||
|
||||
virtual void draw ();
|
||||
|
||||
/// Nbs: Values by Int are not used if the Links are setuped
|
||||
void setValue0 (sint32 r) { _ValueInt[0] = r; }
|
||||
void setValue1 (sint32 r) { _ValueInt[1] = r; }
|
||||
void setValue2 (sint32 r) { _ValueInt[2] = r; }
|
||||
void setRange0 (sint32 r) { _RangeInt[0] = r; }
|
||||
void setRange1 (sint32 r) { _RangeInt[1] = r; }
|
||||
void setRange2 (sint32 r) { _RangeInt[2] = r; }
|
||||
sint32 getValue0 () const { return _ValueInt[0]; }
|
||||
sint32 getValue1 () const { return _ValueInt[1]; }
|
||||
sint32 getValue2 () const { return _ValueInt[2]; }
|
||||
sint32 getRange0 () const { return _RangeInt[0]; }
|
||||
sint32 getRange1 () const { return _RangeInt[1]; }
|
||||
sint32 getRange2 () const { return _RangeInt[2]; }
|
||||
|
||||
// Reflect ValueInt (ie not used if the link is setuped)
|
||||
REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap)
|
||||
REFLECT_SINT32 ("value1", getValue0, setValue0);
|
||||
REFLECT_SINT32 ("value2", getValue1, setValue1);
|
||||
REFLECT_SINT32 ("value3", getValue2, setValue2);
|
||||
REFLECT_SINT32 ("range1", getRange0, setRange0);
|
||||
REFLECT_SINT32 ("range2", getRange1, setRange1);
|
||||
REFLECT_SINT32 ("range3", getRange2, setRange2);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
static void forceLink();
|
||||
|
||||
protected:
|
||||
|
||||
CViewBitmap _Slot;
|
||||
|
||||
// Value of the progression in arbitrary units. should be integer
|
||||
CInterfaceProperty _Value[3];
|
||||
// Max range of the progression in arbitrary units. should be integer
|
||||
CInterfaceProperty _Range[3];
|
||||
|
||||
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
|
||||
sint32 _ValueInt[3];
|
||||
sint32 _RangeInt[3];
|
||||
|
||||
|
||||
NLMISC::CRGBA _Colors[3];
|
||||
NLMISC::CRGBA _ColorsNegative[3];
|
||||
|
||||
bool _Mini;
|
||||
|
||||
// Height of the bitmap
|
||||
sint32 _BarH;
|
||||
|
||||
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
|
||||
void setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp );
|
||||
sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
|
||||
std::string getValProp( const CInterfaceProperty &prop, sint32 intProp ) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_DBVIEW_BAR3_H
|
||||
|
||||
/* End of dbview_bar3.h */
|
67
code/nel/include/nel/gui/dbview_digit.h
Normal file
67
code/nel/include/nel/gui/dbview_digit.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
// 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 NL_DBVIEW_DIGIT_H
|
||||
#define NL_DBVIEW_DIGIT_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_base.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* A number displayed with special bitmaps
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewDigit : public CViewBase
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewDigit(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void draw ();
|
||||
virtual void updateCoords();
|
||||
|
||||
protected:
|
||||
CInterfaceProperty _Number;
|
||||
sint32 _Cache;
|
||||
sint32 _NumDigit;
|
||||
NLMISC::CRGBA _Color;
|
||||
// space between each digit
|
||||
sint32 _WSpace;
|
||||
// The texture digit for the current number
|
||||
sint32 _DigitId[10];
|
||||
uint _DivBase;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_DBVIEW_DIGIT_H
|
||||
|
||||
/* End of dbview_digit.h */
|
77
code/nel/include/nel/gui/dbview_number.h
Normal file
77
code/nel/include/nel/gui/dbview_number.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 NL_DBVIEW_NUMBER_H
|
||||
#define NL_DBVIEW_NUMBER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Display a text from a database number
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewNumber : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewNumber(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
virtual void draw ();
|
||||
|
||||
void link (const std::string &dbprop)
|
||||
{
|
||||
_Number.link (dbprop.c_str());
|
||||
}
|
||||
|
||||
static void forceLink();
|
||||
|
||||
protected:
|
||||
|
||||
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
|
||||
else return (_Number.getSInt64() / _Divisor)%_Modulo; }
|
||||
|
||||
protected:
|
||||
|
||||
CInterfaceProperty _Number;
|
||||
sint64 _Cache;
|
||||
bool _Positive; // only positive values are displayed
|
||||
bool _Format; // the number will be formatted (like "1,000,000") if >= 10k
|
||||
sint64 _Divisor, _Modulo;
|
||||
// string to append to the value (eg: meters)
|
||||
CStringShared _Suffix;
|
||||
CStringShared _Prefix;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_DBVIEW_NUMBER_H
|
||||
|
||||
/* End of dbview_number.h */
|
65
code/nel/include/nel/gui/dbview_quantity.h
Normal file
65
code/nel/include/nel/gui/dbview_quantity.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
// 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 NL_DBVIEW_QUANTITY_H
|
||||
#define NL_DBVIEW_QUANTITY_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Display a text in the form of val / max or "empty"
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewQuantity : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewQuantity(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void draw ();
|
||||
|
||||
static void forceLink();
|
||||
|
||||
|
||||
protected:
|
||||
CInterfaceProperty _Number;
|
||||
CInterfaceProperty _NumberMax;
|
||||
sint32 _Cache;
|
||||
sint32 _CacheMax;
|
||||
ucstring _EmptyText;
|
||||
|
||||
void buildTextFromCache();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_DBVIEW_QUANTITY_H
|
||||
|
||||
/* End of dbview_quantity.h */
|
|
@ -1,252 +1,257 @@
|
|||
// 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 RZ_EVENT_DESCRIPTOR_H
|
||||
#define RZ_EVENT_DESCRIPTOR_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventType
|
||||
{
|
||||
key = 0,
|
||||
mouse = 1,
|
||||
system = 2
|
||||
};
|
||||
|
||||
EEventType getType() const
|
||||
{
|
||||
return _EventType;
|
||||
}
|
||||
|
||||
protected:
|
||||
//type of the event
|
||||
EEventType _EventType;
|
||||
};
|
||||
|
||||
|
||||
/** encode key events.
|
||||
*/
|
||||
class CEventDescriptorKey : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EKeyEventType
|
||||
{
|
||||
keydown = 0, // a key has been press down. The key value is stored as a TKey
|
||||
keyup, // a key has been released. The key value is stored as a TKey
|
||||
keychar, // a key has been stroke. The key is a ucchar
|
||||
keystring, // a string has been sent. The string is a ucstring
|
||||
unknown, // uninitialized event
|
||||
};
|
||||
CEventDescriptorKey() : _KeyEvent(unknown)
|
||||
{
|
||||
_EventType = key;
|
||||
}
|
||||
// ctrcuct from a CEventKey obj
|
||||
CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown)
|
||||
{
|
||||
_EventType = key;
|
||||
init(ev);
|
||||
}
|
||||
// get the type of the key event
|
||||
EKeyEventType getKeyEventType() const { return _KeyEvent; }
|
||||
// return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert
|
||||
NLMISC::TKey getKey() const
|
||||
{
|
||||
nlassert(_KeyEvent == keydown || _KeyEvent == keyup);
|
||||
return _Key;
|
||||
}
|
||||
// return the char that has been pressed. The key event type MUST be 'keychar', else => assert
|
||||
ucchar getChar() const
|
||||
{
|
||||
nlassert(_KeyEvent == keychar);
|
||||
return _Char;
|
||||
}
|
||||
// return the string that has been sent. The key event type MUST be 'keystring', else => assert
|
||||
ucstring getString() const
|
||||
{
|
||||
nlassert(_KeyEvent == keystring);
|
||||
return _String;
|
||||
}
|
||||
bool getKeyCtrl() const // is CTRL pressed ?
|
||||
{
|
||||
return _CtrlState;
|
||||
}
|
||||
bool getKeyShift() const // is SHIFT (right or left) pressed ?
|
||||
{
|
||||
return _ShiftState;
|
||||
}
|
||||
bool getKeyAlt() const // is ALT (right or left) pressed ?
|
||||
{
|
||||
return _AltState;
|
||||
}
|
||||
// init from a CEventKey obj
|
||||
void init(const NLMISC::CEventKey &ev);
|
||||
|
||||
private:
|
||||
EKeyEventType _KeyEvent;
|
||||
bool _CtrlState;
|
||||
bool _ShiftState;
|
||||
bool _AltState;
|
||||
union
|
||||
{
|
||||
NLMISC::TKey _Key;
|
||||
ucchar _Char;
|
||||
};
|
||||
ucstring _String;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorMouse : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventTypeExtended
|
||||
{
|
||||
mouseleftdown=0,
|
||||
mouseleftup=1,
|
||||
mouserightdown=2,
|
||||
mouserightup=3,
|
||||
mousewheel=4, // Complementary info stored in wheel
|
||||
mousemove=5, // Complementary info stored in x and y
|
||||
mouseleftdblclk= 6,
|
||||
mouserightdblclk= 7,
|
||||
};
|
||||
|
||||
CEventDescriptorMouse()
|
||||
{
|
||||
_EventType = mouse;
|
||||
_X = _Y = _Wheel = 0;
|
||||
}
|
||||
|
||||
CEventDescriptorMouse (sint32 x, sint32 y)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
sint32 getX() const
|
||||
{
|
||||
return _X;
|
||||
}
|
||||
|
||||
sint32 getY() const
|
||||
{
|
||||
return _Y;
|
||||
}
|
||||
|
||||
sint32 getWheel() const
|
||||
{
|
||||
return _Wheel;
|
||||
}
|
||||
|
||||
sint32 getEventTypeExtended() const
|
||||
{
|
||||
return _EventTypeExtended;
|
||||
}
|
||||
|
||||
void setX (sint32 x)
|
||||
{
|
||||
_X = x;
|
||||
}
|
||||
|
||||
void setY (sint32 y)
|
||||
{
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
void setWheel (sint32 w)
|
||||
{
|
||||
_Wheel = w;
|
||||
}
|
||||
|
||||
void setEventTypeExtended (sint32 e)
|
||||
{
|
||||
_EventTypeExtended = e;
|
||||
}
|
||||
|
||||
protected:
|
||||
sint32 _X;
|
||||
sint32 _Y;
|
||||
sint32 _Wheel;
|
||||
sint32 _EventTypeExtended;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorSystem : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventTypeExtended
|
||||
{
|
||||
activecalledonparent= 0,
|
||||
clocktick,
|
||||
setfocus,
|
||||
unknown
|
||||
};
|
||||
|
||||
sint32 getEventTypeExtended() const
|
||||
{
|
||||
return _EventTypeExtended;
|
||||
}
|
||||
void setEventTypeExtended (sint32 e)
|
||||
{
|
||||
_EventTypeExtended = e;
|
||||
}
|
||||
CEventDescriptorSystem() : _EventTypeExtended(unknown)
|
||||
{
|
||||
_EventType = system;
|
||||
}
|
||||
protected:
|
||||
sint32 _EventTypeExtended;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem
|
||||
{
|
||||
public:
|
||||
bool getActive() const { return _Active; }
|
||||
void setActive(bool active) { _Active = active; }
|
||||
CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active)
|
||||
{
|
||||
setEventTypeExtended(activecalledonparent);
|
||||
}
|
||||
protected:
|
||||
bool _Active;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorSetFocus : public CEventDescriptorSystem
|
||||
{
|
||||
public:
|
||||
bool hasFocus() const { return _HasFocus; }
|
||||
CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus)
|
||||
{
|
||||
setEventTypeExtended(setfocus);
|
||||
}
|
||||
protected:
|
||||
bool _HasFocus;
|
||||
};
|
||||
|
||||
#endif // RZ_EVENT_DESCRIPTOR_H
|
||||
|
||||
/* End of event_descriptor.h */
|
||||
// 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 RZ_EVENT_DESCRIPTOR_H
|
||||
#define RZ_EVENT_DESCRIPTOR_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/events.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventType
|
||||
{
|
||||
key = 0,
|
||||
mouse = 1,
|
||||
system = 2
|
||||
};
|
||||
|
||||
EEventType getType() const
|
||||
{
|
||||
return _EventType;
|
||||
}
|
||||
|
||||
protected:
|
||||
//type of the event
|
||||
EEventType _EventType;
|
||||
};
|
||||
|
||||
|
||||
/** encode key events.
|
||||
*/
|
||||
class CEventDescriptorKey : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EKeyEventType
|
||||
{
|
||||
keydown = 0, // a key has been press down. The key value is stored as a TKey
|
||||
keyup, // a key has been released. The key value is stored as a TKey
|
||||
keychar, // a key has been stroke. The key is a ucchar
|
||||
keystring, // a string has been sent. The string is a ucstring
|
||||
unknown, // uninitialized event
|
||||
};
|
||||
CEventDescriptorKey() : _KeyEvent(unknown)
|
||||
{
|
||||
_EventType = key;
|
||||
}
|
||||
// ctrcuct from a CEventKey obj
|
||||
CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown)
|
||||
{
|
||||
_EventType = key;
|
||||
init(ev);
|
||||
}
|
||||
// get the type of the key event
|
||||
EKeyEventType getKeyEventType() const { return _KeyEvent; }
|
||||
// return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert
|
||||
NLMISC::TKey getKey() const
|
||||
{
|
||||
nlassert(_KeyEvent == keydown || _KeyEvent == keyup);
|
||||
return _Key;
|
||||
}
|
||||
// return the char that has been pressed. The key event type MUST be 'keychar', else => assert
|
||||
ucchar getChar() const
|
||||
{
|
||||
nlassert(_KeyEvent == keychar);
|
||||
return _Char;
|
||||
}
|
||||
// return the string that has been sent. The key event type MUST be 'keystring', else => assert
|
||||
ucstring getString() const
|
||||
{
|
||||
nlassert(_KeyEvent == keystring);
|
||||
return _String;
|
||||
}
|
||||
bool getKeyCtrl() const // is CTRL pressed ?
|
||||
{
|
||||
return _CtrlState;
|
||||
}
|
||||
bool getKeyShift() const // is SHIFT (right or left) pressed ?
|
||||
{
|
||||
return _ShiftState;
|
||||
}
|
||||
bool getKeyAlt() const // is ALT (right or left) pressed ?
|
||||
{
|
||||
return _AltState;
|
||||
}
|
||||
// init from a CEventKey obj
|
||||
void init(const NLMISC::CEventKey &ev);
|
||||
|
||||
private:
|
||||
EKeyEventType _KeyEvent;
|
||||
bool _CtrlState;
|
||||
bool _ShiftState;
|
||||
bool _AltState;
|
||||
union
|
||||
{
|
||||
NLMISC::TKey _Key;
|
||||
ucchar _Char;
|
||||
};
|
||||
ucstring _String;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorMouse : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventTypeExtended
|
||||
{
|
||||
mouseleftdown=0,
|
||||
mouseleftup=1,
|
||||
mouserightdown=2,
|
||||
mouserightup=3,
|
||||
mousewheel=4, // Complementary info stored in wheel
|
||||
mousemove=5, // Complementary info stored in x and y
|
||||
mouseleftdblclk= 6,
|
||||
mouserightdblclk= 7,
|
||||
};
|
||||
|
||||
CEventDescriptorMouse()
|
||||
{
|
||||
_EventType = mouse;
|
||||
_X = _Y = _Wheel = 0;
|
||||
}
|
||||
|
||||
CEventDescriptorMouse (sint32 x, sint32 y)
|
||||
{
|
||||
_X = x;
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
sint32 getX() const
|
||||
{
|
||||
return _X;
|
||||
}
|
||||
|
||||
sint32 getY() const
|
||||
{
|
||||
return _Y;
|
||||
}
|
||||
|
||||
sint32 getWheel() const
|
||||
{
|
||||
return _Wheel;
|
||||
}
|
||||
|
||||
sint32 getEventTypeExtended() const
|
||||
{
|
||||
return _EventTypeExtended;
|
||||
}
|
||||
|
||||
void setX (sint32 x)
|
||||
{
|
||||
_X = x;
|
||||
}
|
||||
|
||||
void setY (sint32 y)
|
||||
{
|
||||
_Y = y;
|
||||
}
|
||||
|
||||
void setWheel (sint32 w)
|
||||
{
|
||||
_Wheel = w;
|
||||
}
|
||||
|
||||
void setEventTypeExtended (sint32 e)
|
||||
{
|
||||
_EventTypeExtended = e;
|
||||
}
|
||||
|
||||
protected:
|
||||
sint32 _X;
|
||||
sint32 _Y;
|
||||
sint32 _Wheel;
|
||||
sint32 _EventTypeExtended;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorSystem : public CEventDescriptor
|
||||
{
|
||||
public:
|
||||
enum EEventTypeExtended
|
||||
{
|
||||
activecalledonparent= 0,
|
||||
clocktick,
|
||||
setfocus,
|
||||
unknown
|
||||
};
|
||||
|
||||
sint32 getEventTypeExtended() const
|
||||
{
|
||||
return _EventTypeExtended;
|
||||
}
|
||||
void setEventTypeExtended (sint32 e)
|
||||
{
|
||||
_EventTypeExtended = e;
|
||||
}
|
||||
CEventDescriptorSystem() : _EventTypeExtended(unknown)
|
||||
{
|
||||
_EventType = system;
|
||||
}
|
||||
protected:
|
||||
sint32 _EventTypeExtended;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem
|
||||
{
|
||||
public:
|
||||
bool getActive() const { return _Active; }
|
||||
void setActive(bool active) { _Active = active; }
|
||||
CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active)
|
||||
{
|
||||
setEventTypeExtended(activecalledonparent);
|
||||
}
|
||||
protected:
|
||||
bool _Active;
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CEventDescriptorSetFocus : public CEventDescriptorSystem
|
||||
{
|
||||
public:
|
||||
bool hasFocus() const { return _HasFocus; }
|
||||
CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus)
|
||||
{
|
||||
setEventTypeExtended(setfocus);
|
||||
}
|
||||
protected:
|
||||
bool _HasFocus;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_EVENT_DESCRIPTOR_H
|
||||
|
||||
/* End of event_descriptor.h */
|
|
@ -1,42 +1,44 @@
|
|||
// 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 RZ_GROUP_CONTAINER_H
|
||||
#define RZ_GROUP_CONTAINER_H
|
||||
|
||||
#include "interface_group.h"
|
||||
|
||||
|
||||
|
||||
// Special group to handle the mouse wheel message
|
||||
class CInterfaceGroupWheel : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CInterfaceGroupWheel(const TCtorParam ¶m);
|
||||
/// Coming from CInterfaceElement
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual bool handleEvent (const CEventDescriptor &event);
|
||||
private:
|
||||
IActionHandler *_AHWheelUp;
|
||||
CStringShared _AHWheelUpParams;
|
||||
IActionHandler *_AHWheelDown;
|
||||
CStringShared _AHWheelDownParams;
|
||||
};
|
||||
|
||||
#endif
|
||||
// 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 EVENT_LISTENER
|
||||
#define EVENT_LISTENER
|
||||
|
||||
#include "nel/misc/event_listener.h"
|
||||
#include "nel/gui/input_handler.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventListener : public NLMISC::IEventListener
|
||||
{
|
||||
public:
|
||||
CEventListener();
|
||||
~CEventListener();
|
||||
void addToServer( NLMISC::CEventServer *server );
|
||||
void removeFromServer();
|
||||
void operator()( const NLMISC::CEvent &evnt );
|
||||
|
||||
private:
|
||||
NLGUI::CInputHandler inputHandler;
|
||||
NLMISC::CEventServer *eventServer;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
661
code/nel/include/nel/gui/group_container.h
Normal file
661
code/nel/include/nel/gui/group_container.h
Normal file
|
@ -0,0 +1,661 @@
|
|||
// 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 RZ_GROUP_CONTAINER_H
|
||||
#define RZ_GROUP_CONTAINER_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_container_base.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptorLocalised;
|
||||
class CCtrlButton;
|
||||
class CCtrlScroll;
|
||||
class CViewText;
|
||||
class CViewBitmap;
|
||||
class CGroupList;
|
||||
class COptionsContainerInsertion;
|
||||
class COptionsContainerMove;
|
||||
class COptionsLayer;
|
||||
class CGroupContainer;
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* class describing a resizer for the container
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlResizer : public CCtrlBase
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CCtrlResizer(const TCtorParam ¶m);
|
||||
virtual void draw ();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
// Add a big delta so when the user is over the Resizer, always take it whatever other controls under
|
||||
virtual uint getDeltaDepth() const { return 100; }
|
||||
|
||||
// get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded
|
||||
// if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded
|
||||
THotSpot getRealResizerPos() const;
|
||||
THotSpot getResizerPos() const { return _ResizerPos; }
|
||||
void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; }
|
||||
|
||||
bool IsMaxH; // Do this resizer is a MaxH resizer ?
|
||||
|
||||
// Max sizes for the parent
|
||||
sint32 WMin, WMax;
|
||||
sint32 HMin, HMax;
|
||||
|
||||
// from CCtrlBase
|
||||
virtual bool canChangeVirtualDesktop() const { return !_MouseDown; }
|
||||
|
||||
private:
|
||||
|
||||
sint32 resizeW (sint32 dx);
|
||||
sint32 resizeH (sint32 dy);
|
||||
|
||||
private:
|
||||
THotSpot _ResizerPos; // how the resizer should resize its parent
|
||||
bool _MouseDown;
|
||||
sint32 _MouseDownX;
|
||||
sint32 _MouseDownY;
|
||||
sint32 _XBias;
|
||||
sint32 _YBias;
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Class describing a Mover for the container
|
||||
* Clicking on it can also open the container
|
||||
* This can be used to move a container if it is movable.
|
||||
* If the container is popable, it will first pull it of the hierarchy, then it becomes movable.
|
||||
* It can also be used to change the position of a group container that is inserted in the list of another container.
|
||||
* \author Lionel Berenguier
|
||||
* \date 2003
|
||||
*/
|
||||
class CCtrlMover : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
|
||||
CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen);
|
||||
~CCtrlMover();
|
||||
virtual void draw ();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
bool canMove() { return _CanMove; }
|
||||
|
||||
bool isMoving() const {return _Moving;}
|
||||
bool isMovingInParentList() const { return _MovingInParentList; }
|
||||
|
||||
// from CCtrlBase
|
||||
virtual bool canChangeVirtualDesktop() const { return !_Moving; }
|
||||
|
||||
private:
|
||||
sint32 _MoveStartX, _MoveStartY;
|
||||
sint32 _MoveDeltaXReal, _MoveDeltaYReal;
|
||||
sint64 _ScrollTime;
|
||||
sint32 _StartIndex;
|
||||
sint32 _InsertionIndex;
|
||||
// clip window from parent list
|
||||
sint32 _ParentListTop;
|
||||
sint32 _ParentListBottom;
|
||||
//
|
||||
sint64 _WaitToOpenCloseDate;
|
||||
//
|
||||
bool _CanMove : 1;
|
||||
bool _CanOpen : 1;
|
||||
bool _Moving : 1;
|
||||
bool _MovingInParentList : 1;
|
||||
bool _HasMoved : 1;
|
||||
bool _ParentScrollingUp : 1;
|
||||
bool _ParentScrollingDown : 1;
|
||||
bool _StopScrolling : 1; // stop scrolling at next draw
|
||||
bool _WaitToOpenClose : 1;
|
||||
//
|
||||
static COptionsContainerInsertion *getInsertionOptions();
|
||||
private:
|
||||
void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
|
||||
void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
|
||||
void updateInsertionIndex(const CGroupList *gl, sint32 posY);
|
||||
void stopMove();
|
||||
bool runTitleActionHandler();
|
||||
void handleScrolling();
|
||||
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* class describing a group of views controls and other groups
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupContainer : public CGroupContainerBase
|
||||
{
|
||||
public:
|
||||
enum { NumResizers = 8 };
|
||||
public:
|
||||
// observer to know when children have moved. This can be used to keep external datas in sync
|
||||
struct IChildrenObs
|
||||
{
|
||||
virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0;
|
||||
};
|
||||
public:
|
||||
CGroupContainer(const TCtorParam ¶m);
|
||||
~CGroupContainer();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
virtual void updateCoords ();
|
||||
|
||||
virtual void draw ();
|
||||
|
||||
virtual void clearViews ();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
virtual void launch ();
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CViewBase*> &vVB); // Return true if x,y under the group
|
||||
|
||||
virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CCtrlBase*> &vICL);
|
||||
|
||||
void open();
|
||||
|
||||
void close();
|
||||
|
||||
void setup(); // Create the container
|
||||
|
||||
/** If insertion order is -1, pIC is added at the end of the container
|
||||
* otherwise it is inserted after containers of a lower order
|
||||
*/
|
||||
void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1);
|
||||
// Insert a container at the given index.
|
||||
bool attachContainerAtIndex(CGroupContainer *pIC, uint index);
|
||||
|
||||
// Before a container is detached from parent, it should be pop in
|
||||
void detachContainer (CGroupContainer *pIC);
|
||||
void removeAllContainers();
|
||||
|
||||
void setOpen(bool opened)
|
||||
{
|
||||
if (opened)
|
||||
{
|
||||
open();
|
||||
}
|
||||
else
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
bool isOpen() const { return _Opened; }
|
||||
|
||||
// Force Open for container setActive and open()
|
||||
virtual void forceOpen();
|
||||
|
||||
/// Set the title open and close
|
||||
virtual bool isMovable() const {return _Movable;}
|
||||
void setMovable(bool b);
|
||||
|
||||
void setContent (CInterfaceGroup *pC);
|
||||
|
||||
std::string getTitle () const;
|
||||
void setTitle (const std::string &title);
|
||||
std::string getTitleOpened () const;
|
||||
void setTitleOpened (const std::string &title);
|
||||
std::string getTitleClosed () const;
|
||||
void setTitleClosed (const std::string &title);
|
||||
std::string getTitleColorAsString() const;
|
||||
void setTitleColorAsString(const std::string &col);
|
||||
|
||||
void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); }
|
||||
|
||||
// Get the header color draw. NB: depends if grayed, and if active.
|
||||
NLMISC::CRGBA getDrawnHeaderColor () const;
|
||||
|
||||
ucstring getUCTitleOpened () const;
|
||||
void setUCTitleOpened (const ucstring &title);
|
||||
ucstring getUCTitleClosed () const;
|
||||
void setUCTitleClosed (const ucstring &title);
|
||||
ucstring getUCTitle () const;
|
||||
void setUCTitle (const ucstring &title);
|
||||
|
||||
void setPopable(bool popable) { _Popable = popable; }
|
||||
bool isPopable() const { return _Popable; }
|
||||
bool isPopuped() const { return _Poped; }
|
||||
|
||||
|
||||
void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; }
|
||||
bool isMovableInParentList() const { return _MovableInParentList; }
|
||||
|
||||
// high light the border of the container
|
||||
void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; }
|
||||
bool isHighLighted() const { return _HighLighted; }
|
||||
|
||||
// y offset for content of container
|
||||
sint32 getContentYOffset() const { return (sint32) _ContentYOffset; }
|
||||
void setContentYOffset(sint32 value);
|
||||
|
||||
// Window requires attention
|
||||
void requireAttention();
|
||||
|
||||
// Lua exports
|
||||
int luaBlink(CLuaState &ls);
|
||||
int luaSetHeaderColor(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase)
|
||||
REFLECT_LUA_METHOD("blink", luaBlink);
|
||||
REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor);
|
||||
REFLECT_STRING("title", getTitle, setTitle);
|
||||
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
|
||||
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
|
||||
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened);
|
||||
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed);
|
||||
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle);
|
||||
REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString);
|
||||
REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH);
|
||||
REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH);
|
||||
REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW);
|
||||
REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW);
|
||||
REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW);
|
||||
REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset);
|
||||
REFLECT_BOOL("openable", isOpenable, setOpenable);
|
||||
REFLECT_BOOL("opened", isOpen, setOpen);
|
||||
REFLECT_BOOL("lockable", isLockable, setLockable);
|
||||
REFLECT_BOOL("locked", isLocked, setLocked);
|
||||
|
||||
REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive);
|
||||
REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
sint32 getLayerSetup() const { return _LayerSetup; }
|
||||
|
||||
// if this window is popable, pop it at its actual position
|
||||
void popupCurrentPos();
|
||||
// Popup at previous memorized position
|
||||
void popup();
|
||||
/** Popin the window and possibly put it back in its father container, using the order defined in the list of the container.
|
||||
* \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL)
|
||||
* \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list
|
||||
*/
|
||||
void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true);
|
||||
|
||||
// get the mover control associated with that control, or NULL if none
|
||||
CCtrlMover *getCtrlMover() const { return _Mover; }
|
||||
|
||||
// true if there is a mover and if the window is being moved
|
||||
bool isMoving() const { return _Mover && _Mover->isMoving(); }
|
||||
|
||||
/** Force the container to blink (to tell the user that an event has happened).
|
||||
* This uses the global color, so the container must use it
|
||||
* This state is automatically disabled if the container is opened
|
||||
* \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise
|
||||
*/
|
||||
virtual void enableBlink(uint numBlinks = 0);
|
||||
virtual void disableBlink();
|
||||
virtual bool isBlinking() const { return _Blinking; }
|
||||
|
||||
CGroupList *getList() const { return _List; }
|
||||
|
||||
CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; }
|
||||
CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; }
|
||||
CInterfaceGroup *getContent() const { return _Content; }
|
||||
|
||||
void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; }
|
||||
IChildrenObs *getChildrenObs() const { return _ChildrenObs; }
|
||||
|
||||
// Get current father container (if any).
|
||||
CGroupContainer *getFatherContainer() const;
|
||||
// Get current father container (if any). If the container is popup, it gives the proprietary container
|
||||
CGroupContainer *getProprietaryContainer() const;
|
||||
|
||||
|
||||
bool isOpenable() const { return _Openable; }
|
||||
void setOpenable(bool openable);
|
||||
|
||||
bool getHeaderActive() const { return _HeaderActive; }
|
||||
void setHeaderActive(bool active) { _HeaderActive = active; }
|
||||
|
||||
bool getRightButtonEnabled() const { return _EnabledRightButton; }
|
||||
void setRightButtonEnabled(bool enabled);
|
||||
|
||||
CCtrlScroll *getScroll() const { return _ScrollBar; }
|
||||
|
||||
bool isSavable() const { return _Savable; }
|
||||
void setSavable(bool savable) { _Savable = savable; }
|
||||
bool isActiveSavable() const { return _ActiveSavable; }
|
||||
|
||||
bool isLocalize() const { return _Localize; }
|
||||
void setLocalize(bool localize) { _Localize = localize; }
|
||||
|
||||
void setPopupX(sint32 x) { _PopupX = x; }
|
||||
void setPopupY(sint32 y) { _PopupY = y; }
|
||||
void setPopupW(sint32 w) { _PopupW = w; }
|
||||
void setPopupH(sint32 h) { _PopupH = h; }
|
||||
|
||||
sint32 getPopupX() const { return _PopupX; }
|
||||
sint32 getPopupY() const { return _PopupY; }
|
||||
sint32 getPopupW() const { return _PopupW; }
|
||||
sint32 getPopupH() const { return _PopupH; }
|
||||
|
||||
sint32 getRefW() const { return _RefW; }
|
||||
|
||||
/** Increase the rollover alpha for the current frame.
|
||||
* Example of use : an edit box that has focus in a group container
|
||||
*/
|
||||
void rollOverAlphaUp();
|
||||
// force the rollover alpha to its max value, depending on there's keyboard focus or not
|
||||
void forceRolloverAlpha();
|
||||
|
||||
bool isOpenWhenPopup() const { return _OpenWhenPopup; }
|
||||
|
||||
/// Locking of window (prevent it from being moved)
|
||||
void setLockable(bool lockable);
|
||||
bool isLockable() const { return _Lockable; }
|
||||
void setLocked(bool locked);
|
||||
|
||||
// to be called by the 'deactive check' handler
|
||||
static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; }
|
||||
const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); }
|
||||
const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; }
|
||||
//
|
||||
const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); }
|
||||
const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; }
|
||||
//
|
||||
IActionHandler *getAHOnMovePtr() const { return _AHOnMove; }
|
||||
const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); }
|
||||
const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; }
|
||||
//
|
||||
IActionHandler *getAHOnResizePtr() const { return _AHOnResize; }
|
||||
const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); }
|
||||
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
|
||||
//
|
||||
IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; }
|
||||
const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); }
|
||||
const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; }
|
||||
|
||||
//
|
||||
void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); }
|
||||
void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; }
|
||||
|
||||
void setModalParentList (const std::string &name);
|
||||
bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window)
|
||||
bool isGrayed() const;
|
||||
bool blinkAllSons();
|
||||
|
||||
// true if the resizer is enabled.
|
||||
bool getEnabledResizer() const {return _EnabledResizer;}
|
||||
|
||||
sint32 getPopupMinW() const {return _PopupMinW;}
|
||||
sint32 getPopupMaxW() const {return _PopupMaxW;}
|
||||
sint32 getPopupMinH() const {return _PopupMinH;}
|
||||
sint32 getPopupMaxH() const {return _PopupMaxH;}
|
||||
sint32 getMinW() const {return _MinW;}
|
||||
void setMinW(sint32 minW) { _MinW = minW;}
|
||||
void setMaxW(sint32 maxW) { _MaxW = maxW;}
|
||||
sint32 getMaxW() const {return _MaxW;}
|
||||
void setPopupMinW(sint32 minW);
|
||||
void setPopupMaxW(sint32 maxW);
|
||||
void setPopupMinH(sint32 minW);
|
||||
void setPopupMaxH(sint32 maxW);
|
||||
|
||||
|
||||
// backup the current position of this container
|
||||
void backupPosition();
|
||||
// restore the current position of this container
|
||||
void restorePosition();
|
||||
// get x for backup position
|
||||
sint32 getBackupX() const { return _BackupX; }
|
||||
sint32 getBackupY() const { return _BackupY; }
|
||||
// Set backup position
|
||||
void setBackupPosition(sint32 x, sint32 y);
|
||||
// clear backup
|
||||
void clearBackup() { _PositionBackuped = false; }
|
||||
// Test if position has been backuped (flag cleared by 'restorePosition()')
|
||||
bool isPositionBackuped() const { return _PositionBackuped; }
|
||||
// check if the container has been moved, resized, or popuped by the user (and eventually clear that flag)
|
||||
bool getTouchFlag(bool clearFlag) const;
|
||||
// from CInterfaceGroup
|
||||
virtual void restoreAllContainersBackupPosition() { restorePosition(); }
|
||||
|
||||
// when isModal() is true, the whole interface cannot switch desktop
|
||||
bool isModal() const { return _Modal; }
|
||||
void setModal(bool modal) { _Modal = modal; }
|
||||
|
||||
// return true if the container has a modal parent window setuped => the whole interface cannot switch desktop
|
||||
bool isModalSon() const { return !_ModalParents.empty(); }
|
||||
|
||||
// return the help web page of this container. "" if none
|
||||
const std::string &getHelpPage() const { return _HelpPage; }
|
||||
// set the help web page of this container. "" if none. NB: the help button is not updated
|
||||
void setHelpPage(const std::string &newPage);
|
||||
|
||||
void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; }
|
||||
sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; }
|
||||
|
||||
protected:
|
||||
uint8 _ICurrentRolloverAlphaContainer;
|
||||
uint8 _HighLightedAlpha;
|
||||
float _CurrentRolloverAlphaContainer;
|
||||
float _CurrentRolloverAlphaContent;
|
||||
sint32 _LayerSetup;
|
||||
ucstring _TitleTextOpened;
|
||||
ucstring _TitleTextClosed;
|
||||
CViewText *_TitleOpened;
|
||||
CViewText *_TitleClosed;
|
||||
sint32 _TitleDeltaMaxW;
|
||||
CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable)
|
||||
CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin
|
||||
CCtrlButton *_HelpButton; // Help button
|
||||
|
||||
CGroupList *_List;
|
||||
CCtrlScroll *_ScrollBar;
|
||||
CGroupContainer *_OldFatherContainer;
|
||||
|
||||
// NB: _ModalParentNames is a list of modal parent, separated by '|'
|
||||
std::string _ModalParentNames; // Modal handling between container (container can be linked together,
|
||||
std::vector<CGroupContainer*> _ModalSons; // when the son is active the parent is not active
|
||||
std::vector<CGroupContainer*> _ModalParents; // (but the rest of the interface is))
|
||||
|
||||
uint _InsertionOrder;
|
||||
uint _BlinkDT;
|
||||
uint _NumBlinks;
|
||||
|
||||
CInterfaceGroup *_Content; // Read From Script
|
||||
CInterfaceGroup *_HeaderOpened; // Read From Script
|
||||
CInterfaceGroup *_HeaderClosed; // Read From Script
|
||||
|
||||
CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available
|
||||
|
||||
//
|
||||
CCtrlMover *_Mover;
|
||||
|
||||
IChildrenObs *_Obs;
|
||||
|
||||
// If layer==0 constraint on resize
|
||||
sint32 _PopupMinW;
|
||||
sint32 _PopupMaxW;
|
||||
sint32 _PopupMinH;
|
||||
sint32 _PopupMaxH;
|
||||
// If layer>0 constraint on resize
|
||||
sint32 _MinW;
|
||||
sint32 _MaxW;
|
||||
|
||||
// backuped position
|
||||
sint32 _BackupX;
|
||||
sint32 _BackupY;
|
||||
|
||||
// old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet
|
||||
sint32 _PopupX;
|
||||
sint32 _PopupY;
|
||||
sint32 _PopupW;
|
||||
sint32 _PopupH;
|
||||
//
|
||||
sint32 _RefW;
|
||||
|
||||
|
||||
sint32 _MoverDeltaW;
|
||||
|
||||
// action handler
|
||||
IActionHandler *_AHOnOpen;
|
||||
CStringShared _AHOnOpenParams;
|
||||
IActionHandler *_AHOnClose;
|
||||
CStringShared _AHOnCloseParams;
|
||||
IActionHandler *_AHOnCloseButton;
|
||||
CStringShared _AHOnCloseButtonParams;
|
||||
IActionHandler *_AHOnMove;
|
||||
CStringShared _AHOnMoveParams;
|
||||
IActionHandler *_AHOnResize;
|
||||
CStringShared _AHOnResizeParams;
|
||||
IActionHandler *_AHOnBeginMove;
|
||||
CStringShared _AHOnBeginMoveParams;
|
||||
|
||||
// action handler to test whether the windows can be deactivated (when the close button is pressed)
|
||||
IActionHandler *_AHOnDeactiveCheck;
|
||||
CStringShared _AHOnDeactiveCheckParams;
|
||||
|
||||
|
||||
// Observer to know when children have moved
|
||||
IChildrenObs *_ChildrenObs;
|
||||
|
||||
// list of container that are poped up
|
||||
std::vector<CGroupContainer *> _PopedCont;
|
||||
|
||||
// Open management
|
||||
bool _Openable : 1; // Is the container can be manually opened or closed ?
|
||||
bool _Opened : 1; // Is the container currently opened or closed ?
|
||||
bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0)
|
||||
// and close when poped in...
|
||||
bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start
|
||||
bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0)
|
||||
|
||||
// Move management
|
||||
bool _Movable : 1; // Is the container movable ?
|
||||
bool _MovableInParentList: 1;
|
||||
bool _Lockable : 1;
|
||||
bool _MovingInParentList : 1; // Mgt : currently moving ?
|
||||
|
||||
// Pop up / pop in
|
||||
bool _Popable : 1;
|
||||
bool _Poped : 1;
|
||||
|
||||
bool _EnabledResizer : 1;
|
||||
|
||||
bool _HighLighted : 1;
|
||||
bool _Blinking : 1;
|
||||
bool _BlinkState : 1;
|
||||
|
||||
bool _Savable : 1;
|
||||
bool _ActiveSavable : 1;
|
||||
|
||||
// Display title background or not
|
||||
bool _HeaderActive : 1;
|
||||
bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ?
|
||||
//
|
||||
enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString};
|
||||
uint8 _TitleClass : 2;
|
||||
//
|
||||
mutable bool _TouchFlag : 1;
|
||||
bool _PositionBackuped : 1;
|
||||
bool _Modal : 1; // the container is modal and prevent from switching virtual desktop
|
||||
//
|
||||
bool _EnabledHelpButton : 1; // Is the Button Help is enabled ?
|
||||
//
|
||||
bool _TitleOverExtendViewText : 1; // Does the title over extend view text
|
||||
bool _Localize : 1;
|
||||
|
||||
CInterfaceProperty _HeaderColor;
|
||||
|
||||
|
||||
|
||||
sint8 _ContentYOffset;
|
||||
|
||||
// Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value
|
||||
sint8 _ResizerTopSize;
|
||||
uint8 _ICurrentRolloverAlphaContent;
|
||||
|
||||
|
||||
static bool _ValidateCanDeactivate;
|
||||
|
||||
CStringShared _OptionsName;
|
||||
|
||||
// Web Page used for help
|
||||
CStringShared _HelpPage;
|
||||
|
||||
private:
|
||||
|
||||
sint32 getLayer();
|
||||
void updateResizerSize(CCtrlResizer *cr);
|
||||
void updateRightButton();
|
||||
void updateHelpButton();
|
||||
void updateMover();
|
||||
void updateViewOpenState();
|
||||
void updateTitle();
|
||||
|
||||
void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH);
|
||||
void createResizerMaxH();
|
||||
void removeResizerMaxH();
|
||||
|
||||
TTileClass convertTitleClass(const char *ptr);
|
||||
|
||||
static COptionsContainerMove *getMoveOptions();
|
||||
|
||||
COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used
|
||||
|
||||
bool hasKeyboardFocus() const;
|
||||
|
||||
// private for modal system
|
||||
void addModalParent (CGroupContainer *pParent);
|
||||
void addModalSon (CGroupContainer *pSon);
|
||||
|
||||
// Avoid each frame setup layer0, layer1 etc...
|
||||
enum {NumLayerName=10};
|
||||
static const std::string _OptionLayerName[NumLayerName];
|
||||
|
||||
public:
|
||||
// for use by CCtrlMover
|
||||
// Tell that this group is moving in its parent list
|
||||
void setMovingInParentList(bool enable);
|
||||
CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; }
|
||||
CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; }
|
||||
CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; }
|
||||
// set the 'hasMoved' flag
|
||||
void touch(bool touched = true) { _TouchFlag = touched; }
|
||||
|
||||
friend class CICDeactive;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_INTERFACE_CONTAINER_H
|
||||
|
||||
/* End of interface_container.h */
|
117
code/nel/include/nel/gui/group_container_base.h
Normal file
117
code/nel/include/nel/gui/group_container_base.h
Normal file
|
@ -0,0 +1,117 @@
|
|||
// 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 GROUP_CONTAINER_BASE_H
|
||||
#define GROUP_CONTAINER_BASE_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CGroupContainerBase : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CGroupContainerBase )
|
||||
|
||||
CGroupContainerBase( const TCtorParam ¶m );
|
||||
virtual ~CGroupContainerBase();
|
||||
|
||||
virtual void removeAllContainers();
|
||||
virtual void setLocked( bool locked );
|
||||
bool isLocked() const { return _Locked; }
|
||||
|
||||
uint8 getContainerAlpha() const { return _ContainerAlpha; }
|
||||
uint8 getContentAlpha() const { return _ContentAlpha; }
|
||||
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
|
||||
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
|
||||
|
||||
void setContainerAlpha( uint8 alpha );
|
||||
void setContentAlpha( uint8 alpha );
|
||||
void setRolloverAlphaContent( uint8 alpha );
|
||||
void setRolloverAlphaContainer( uint8 alpha );
|
||||
|
||||
// for export
|
||||
sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; }
|
||||
sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; }
|
||||
sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; }
|
||||
sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; }
|
||||
|
||||
// sin32 versions for export
|
||||
void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); }
|
||||
void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); }
|
||||
void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); }
|
||||
void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); }
|
||||
|
||||
void setUseGlobalAlpha( bool use );
|
||||
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
|
||||
|
||||
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
|
||||
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
|
||||
|
||||
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
|
||||
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
|
||||
|
||||
REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup )
|
||||
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
|
||||
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
|
||||
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
|
||||
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
|
||||
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
|
||||
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
|
||||
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
virtual bool isMoving() const{ return false; }
|
||||
|
||||
// Get the header color draw. NB: depends if grayed, and if active.
|
||||
virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); };
|
||||
|
||||
uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; }
|
||||
uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; }
|
||||
|
||||
virtual bool isGrayed() const{ return false; }
|
||||
virtual bool getTouchFlag(bool clearFlag) const{ return false; }
|
||||
virtual void backupPosition(){}
|
||||
virtual void restorePosition(){}
|
||||
|
||||
protected:
|
||||
void triggerAlphaSettingsChangedAH();
|
||||
|
||||
uint8 _CurrentContainerAlpha;
|
||||
uint8 _CurrentContentAlpha;
|
||||
uint8 _ContainerAlpha;
|
||||
uint8 _ContentAlpha;
|
||||
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
|
||||
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
|
||||
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
|
||||
bool _UseGlobalAlpha : 1;
|
||||
|
||||
IActionHandler *_AHOnAlphaSettingsChanged;
|
||||
CStringShared _AHOnAlphaSettingsChangedParams;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
368
code/nel/include/nel/gui/group_editbox.h
Normal file
368
code/nel/include/nel/gui/group_editbox.h
Normal file
|
@ -0,0 +1,368 @@
|
|||
// 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 RZ_CTRL_EDITBOX_H
|
||||
#define RZ_CTRL_EDITBOX_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_editbox_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptor;
|
||||
class CViewText;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CGroupEditBox : public CGroupEditBoxBase
|
||||
{
|
||||
public:
|
||||
|
||||
class IComboKeyHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IComboKeyHandler(){}
|
||||
virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0;
|
||||
};
|
||||
|
||||
enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with
|
||||
|
||||
DECLARE_UI_CLASS( CGroupEditBox )
|
||||
/// Constructor
|
||||
CGroupEditBox(const TCtorParam ¶m);
|
||||
/// Dtor
|
||||
~CGroupEditBox();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
|
||||
/// Accessors
|
||||
ucstring getInputString() const { return _InputString; }
|
||||
const ucstring &getInputStringRef() const { return _InputString; }
|
||||
const ucstring &getPrompt() const { return _Prompt; }
|
||||
|
||||
/** Set the prompt
|
||||
* NB : line returns are encoded as '\n', not '\r\n'
|
||||
*/
|
||||
void setPrompt(const ucstring &s) { _Prompt = s; }
|
||||
void setInputString(const ucstring &str);
|
||||
void setInputStringRef(const ucstring &str) {_InputString = str; };
|
||||
void setInputStringAsInt(sint32 val);
|
||||
sint32 getInputStringAsInt() const;
|
||||
void setInputStringAsInt64(sint64 val);
|
||||
sint64 getInputStringAsInt64() const;
|
||||
void setInputStringAsFloat(float val);
|
||||
float getInputStringAsFloat() const;
|
||||
void setInputStringAsStdString(const std::string &str);
|
||||
std::string getInputStringAsStdString() const;
|
||||
void setInputStringAsUtf8(const std::string &str);
|
||||
std::string getInputStringAsUtf8() const;
|
||||
void setColor(NLMISC::CRGBA col);
|
||||
|
||||
|
||||
/// force the selection of all the text
|
||||
void setSelectionAll();
|
||||
|
||||
virtual void checkCoords();
|
||||
virtual void updateCoords();
|
||||
virtual void clearViews ();
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
static CGroupEditBox *getMenuFather() { return _MenuFather; }
|
||||
|
||||
void setCommand(const ucstring &command, bool execute);
|
||||
|
||||
// Stop parent from blinking
|
||||
void stopParentBlink() { if (_Parent) _Parent->disableBlink(); }
|
||||
|
||||
// Get / set cursor position
|
||||
sint32 getCursorPos () const {return _CursorPos;}
|
||||
void setCursorPos (sint32 pos) {_CursorPos=pos;}
|
||||
|
||||
// Get / set cursor at previous line end
|
||||
bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;}
|
||||
void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;}
|
||||
|
||||
// Get / set current selection position
|
||||
static sint32 getSelectCursorPos () {return _SelectCursorPos;}
|
||||
static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;}
|
||||
|
||||
// Get the view text
|
||||
const CViewText *getViewText () const {return _ViewText;}
|
||||
|
||||
// Get the historic information
|
||||
sint32 getMaxHistoric() const {return _MaxHistoric;}
|
||||
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
|
||||
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
|
||||
const ucstring &getHistoric(uint32 index) const {return _Historic[index];}
|
||||
uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
|
||||
|
||||
// Get on change action handler
|
||||
const std::string &getAHOnChange() const {return _AHOnChange;}
|
||||
const std::string &getParamsOnChange() const {return _ParamsOnChange;}
|
||||
|
||||
void cutSelection();
|
||||
|
||||
/// From CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
// Copy the selection into buffer
|
||||
void copy();
|
||||
// Paste the selection into buffer
|
||||
void paste();
|
||||
// Write the string into buffer
|
||||
void writeString(const ucstring &str, bool replace = true, bool atEnd = true);
|
||||
|
||||
// Expand the expression (true if there was a '/' at the start of the line)
|
||||
bool expand();
|
||||
|
||||
// Back space
|
||||
void back();
|
||||
|
||||
// ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant)
|
||||
void bypassNextKey() { _BypassNextKey = true; }
|
||||
|
||||
// True if the editBox loose the focus on enter
|
||||
bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;}
|
||||
//
|
||||
virtual void clearAllEditBox();
|
||||
// From CInterfaceElement
|
||||
virtual bool wantSerialConfig() const;
|
||||
// From CInterfaceElement
|
||||
virtual void serialConfig(NLMISC::IStream &f);
|
||||
// From CInterfaceElement
|
||||
virtual void onQuit();
|
||||
// From CInterfaceElement
|
||||
virtual void onLoadConfig();
|
||||
|
||||
// from CCtrlBase
|
||||
virtual void elementCaptured(CCtrlBase *capturedElement);
|
||||
|
||||
// from CCtrlBase
|
||||
virtual void onKeyboardCaptureLost();
|
||||
|
||||
// set the input string as "default". will be reseted at first click (used for user information)
|
||||
void setDefaultInputString(const ucstring &str);
|
||||
|
||||
// For Interger and PositiveInteger, can specify min and max values
|
||||
void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;}
|
||||
void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;}
|
||||
void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;}
|
||||
void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;}
|
||||
|
||||
void setFocusOnText();
|
||||
|
||||
int luaSetSelectionAll(CLuaState &ls);
|
||||
int luaSetupDisplayText(CLuaState &ls);
|
||||
int luaSetFocusOnText(CLuaState &ls);
|
||||
int luaCancelFocusOnText(CLuaState &ls);
|
||||
REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase)
|
||||
REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText);
|
||||
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
|
||||
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
|
||||
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
|
||||
REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString);
|
||||
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
/** Restore the original value of the edit box.
|
||||
* This value is captured when the edit box get focus
|
||||
* (return true if no undo was available)
|
||||
* Will always fails ifthe edito box do not have the focus
|
||||
*/
|
||||
bool undo();
|
||||
|
||||
/** Cancel last undo operation
|
||||
* Return true if redo operation is available
|
||||
*/
|
||||
bool redo();
|
||||
|
||||
/// freeze the control (loose focus, and cannot edit)
|
||||
void setFrozen (bool state);
|
||||
bool getFrozen () const { return _Frozen; }
|
||||
|
||||
protected:
|
||||
|
||||
// Cursor infos
|
||||
float _BlinkTime;
|
||||
sint32 _CursorPos;
|
||||
uint32 _MaxNumChar;
|
||||
uint32 _MaxNumReturn;
|
||||
uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only
|
||||
sint32 _MaxCharsSize;
|
||||
sint32 _FirstVisibleChar;
|
||||
sint32 _LastVisibleChar;
|
||||
|
||||
// Text selection
|
||||
static sint32 _SelectCursorPos;
|
||||
bool _SelectingText;
|
||||
NLMISC::CRGBA _TextSelectColor;
|
||||
NLMISC::CRGBA _BackSelectColor;
|
||||
|
||||
// Text info
|
||||
ucstring _Prompt;
|
||||
ucstring _InputString;
|
||||
CViewText *_ViewText;
|
||||
|
||||
// undo / redo
|
||||
ucstring _StartInputString; // value of the input string when focus was acuired first
|
||||
ucstring _ModifiedInputString;
|
||||
|
||||
|
||||
// Historic info
|
||||
typedef std::deque<ucstring> THistoric;
|
||||
THistoric _Historic;
|
||||
uint32 _MaxHistoric;
|
||||
sint32 _CurrentHistoricIndex;
|
||||
sint32 _PrevNumLine;
|
||||
|
||||
// Action Handler
|
||||
std::string _AHOnChange;
|
||||
std::string _ParamsOnChange;
|
||||
std::string _ListMenuRight;
|
||||
|
||||
std::string _AHOnFocusLost;
|
||||
std::string _AHOnFocusLostParams;
|
||||
|
||||
// entry type
|
||||
TEntryType _EntryType;
|
||||
|
||||
|
||||
bool _Setupped : 1; // setup
|
||||
bool _BypassNextKey : 1;
|
||||
bool _BlinkState : 1;
|
||||
bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines)
|
||||
bool _LooseFocusOnEnter : 1;
|
||||
bool _ResetFocusOnHide : 1;
|
||||
bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed.
|
||||
// If the edit box is at the bottom of the screen and if it expands on y
|
||||
// because of multiline, thz parent container will be moved to top
|
||||
// The good position can be restored by a press on enter then
|
||||
bool _WantReturn : 1; // Want return char, don't call the enter action handler
|
||||
bool _Savable : 1; // should content be saved ?
|
||||
bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited)
|
||||
bool _Frozen : 1; // is the control frozen? (cannot edit in it)
|
||||
|
||||
bool _CanRedo : 1;
|
||||
bool _CanUndo : 1;
|
||||
|
||||
std::vector<char> _NegativeFilter;
|
||||
|
||||
sint _CursorTexID;
|
||||
sint32 _CursorWidth;
|
||||
|
||||
sint32 _IntegerMinValue;
|
||||
sint32 _IntegerMaxValue;
|
||||
uint32 _PositiveIntegerMinValue;
|
||||
uint32 _PositiveIntegerMaxValue;
|
||||
|
||||
sint32 _ViewTextDeltaX;
|
||||
|
||||
private:
|
||||
void setupDisplayText();
|
||||
void makeTopWindow();
|
||||
void handleEventChar(const NLGUI::CEventDescriptorKey &event);
|
||||
void handleEventString(const NLGUI::CEventDescriptorKey &event);
|
||||
void setup();
|
||||
void triggerOnChangeAH();
|
||||
void appendStringFromClipboard(const ucstring &str);
|
||||
|
||||
ucstring getSelection();
|
||||
|
||||
static CGroupEditBox *_MenuFather;
|
||||
|
||||
static bool isValidAlphaNumSpace(ucchar c)
|
||||
{
|
||||
if (c > 255) return false;
|
||||
char ac = (char) c;
|
||||
return (ac >= '0' && ac <= '9') ||
|
||||
(ac >= 'a' && ac <= 'z') ||
|
||||
(ac >= 'A' && ac <= 'Z') ||
|
||||
ac==' ';
|
||||
}
|
||||
|
||||
static bool isValidAlphaNum(ucchar c)
|
||||
{
|
||||
if (c > 255) return false;
|
||||
char ac = (char) c;
|
||||
return (ac >= '0' && ac <= '9') ||
|
||||
(ac >= 'a' && ac <= 'z') ||
|
||||
(ac >= 'A' && ac <= 'Z');
|
||||
}
|
||||
|
||||
static bool isValidAlpha(ucchar c)
|
||||
{
|
||||
if (c > 255) return false;
|
||||
char ac = (char) c;
|
||||
return (ac >= 'a' && ac <= 'z') ||
|
||||
(ac >= 'A' && ac <= 'Z');
|
||||
}
|
||||
|
||||
static bool isValidPlayerNameChar(ucchar c)
|
||||
{
|
||||
// valid player name (with possible shard prefix / suffix format
|
||||
return isValidAlpha(c) || c=='.' || c=='(' || c==')';
|
||||
}
|
||||
|
||||
static bool isValidFilenameChar(ucchar c)
|
||||
{
|
||||
if (c == '\\' ||
|
||||
c == '/' ||
|
||||
c == ':' ||
|
||||
c == '*' ||
|
||||
c == '?' ||
|
||||
c == '\"' ||
|
||||
c == '<' ||
|
||||
c == '>' ||
|
||||
c == '|') return false;
|
||||
return true;
|
||||
}
|
||||
//
|
||||
bool isFiltered(ucchar c)
|
||||
{
|
||||
uint length = (uint)_NegativeFilter.size();
|
||||
for (uint k = 0; k < length; ++k)
|
||||
{
|
||||
if ((ucchar) _NegativeFilter[k] == c) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static IComboKeyHandler *comboKeyHandler;
|
||||
|
||||
public:
|
||||
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_CTRL_EDITBOX_H
|
||||
|
||||
/* End of ctrl_editbox.h */
|
67
code/nel/include/nel/gui/group_editbox_base.h
Normal file
67
code/nel/include/nel/gui/group_editbox_base.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
// 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 GROUP_EDITBOX_BASE_H
|
||||
#define GROUP_EDITBOX_BASE_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CGroupEditBoxBase : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CGroupEditBoxBase )
|
||||
|
||||
CGroupEditBoxBase( const TCtorParam ¶m );
|
||||
~CGroupEditBoxBase();
|
||||
|
||||
// True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus
|
||||
bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; }
|
||||
void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; }
|
||||
|
||||
std::string getAHOnFocus(){ return _AHOnFocus; }
|
||||
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
|
||||
|
||||
// disable any current selection
|
||||
static void disableSelection(){ _CurrSelection = NULL; }
|
||||
|
||||
// Get / set current selection
|
||||
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
|
||||
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
|
||||
|
||||
void draw(){}
|
||||
|
||||
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
|
||||
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
bool _RecoverFocusOnEnter : 1;
|
||||
|
||||
std::string _AHOnFocus;
|
||||
std::string _AHOnFocusParams;
|
||||
|
||||
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
118
code/nel/include/nel/gui/group_frame.h
Normal file
118
code/nel/include/nel/gui/group_frame.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
// 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 NL_GROUP_FRAME_H
|
||||
#define NL_GROUP_FRAME_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/** A Group with a background and a frame displayed
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupFrame : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CGroupFrame(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void draw ();
|
||||
|
||||
void copyOptionFrom(const CGroupFrame &other);
|
||||
void setupOptions();
|
||||
|
||||
|
||||
void setColorAsString(const std::string & col);
|
||||
std::string getColorAsString() const;
|
||||
|
||||
REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup)
|
||||
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
static void resetDisplayTypes() { _DispTypes.clear(); }
|
||||
|
||||
// ******************
|
||||
protected:
|
||||
|
||||
bool _DisplayFrame;
|
||||
|
||||
NLMISC::CRGBA _Color;
|
||||
|
||||
uint8 _DispType;
|
||||
|
||||
std::string _Options;
|
||||
|
||||
// Fields Defined in the XML => must not herit them from extends=""
|
||||
bool _DisplayFrameDefined : 1;
|
||||
bool _ColorDefined : 1;
|
||||
bool _DispTypeDefined : 1;
|
||||
|
||||
// Static stuff
|
||||
enum
|
||||
{
|
||||
TextTL= 0,
|
||||
TextTM,
|
||||
TextTR,
|
||||
TextML,
|
||||
TextMM,
|
||||
TextMR,
|
||||
TextBL,
|
||||
TextBM,
|
||||
TextBR
|
||||
};
|
||||
|
||||
struct SDisplayType
|
||||
{
|
||||
std::string Name;
|
||||
sint32 BorderIds[9];
|
||||
uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR
|
||||
sint32 LeftBorder; // enum
|
||||
sint32 RightBorder;
|
||||
sint32 TopBorder;
|
||||
sint32 BottomBorder;
|
||||
|
||||
// -----------------------
|
||||
SDisplayType()
|
||||
{
|
||||
for (uint i = 0; i < 9; ++i)
|
||||
TileBorder[i] = 0;
|
||||
}
|
||||
};
|
||||
static std::vector<SDisplayType> _DispTypes;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_FRAME_H
|
||||
|
||||
/* End of group_frame.h */
|
93
code/nel/include/nel/gui/group_header.h
Normal file
93
code/nel/include/nel/gui/group_header.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
// 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 CL_GROUP_HEADER_H
|
||||
#define CL_GROUP_HEADER_H
|
||||
|
||||
#include "nel/gui/group_list.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CGroupHeaderEntry;
|
||||
|
||||
// *****************************************************************************************************************
|
||||
/** Display a header with movable entries.
|
||||
* Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode)
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2006
|
||||
*/
|
||||
class CGroupHeader : public CGroupList
|
||||
{
|
||||
public:
|
||||
REFLECT_EXPORT_START(CGroupHeader, CGroupList)
|
||||
REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns);
|
||||
REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
CGroupHeader(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// from CInterfaceGroup
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
sint32 getHeaderMaxSize() const { return _HeaderMaxSize; }
|
||||
// get the entries in this header
|
||||
void getEntries(std::vector<CGroupHeaderEntry *> &dest);
|
||||
// ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()'
|
||||
void enlargeColumns(sint32 margin);
|
||||
// ensure that content of each column is visible
|
||||
void resizeColumnsAndContainer(sint32 margin);
|
||||
private:
|
||||
sint32 _HeaderMaxSize;
|
||||
int luaEnlargeColumns(CLuaState &ls);
|
||||
int luaResizeColumnsAndContainer(CLuaState &ls);
|
||||
};
|
||||
|
||||
// *****************************************************************************************************************
|
||||
// an entry in a header, includes a "mover control" to move it inside its parent header
|
||||
// NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size'
|
||||
class CGroupHeaderEntry : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
CGroupHeaderEntry(const TCtorParam ¶m);
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
// from CInterfaceGroup
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
sint32 getMinSize() const { return _MinSize; }
|
||||
virtual void updateCoords();
|
||||
CInterfaceGroup *getTargetColumn() const;
|
||||
|
||||
const std::string &getAHOnResize() const { return _AHOnResize; }
|
||||
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
|
||||
|
||||
private:
|
||||
sint32 _MinSize;
|
||||
sint32 _ResizerSize;
|
||||
std::string _TargetColumnId;
|
||||
std::string _AHOnResize;
|
||||
std::string _AHOnResizeParams;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
669
code/nel/include/nel/gui/group_html.h
Normal file
669
code/nel/include/nel/gui/group_html.h
Normal file
|
@ -0,0 +1,669 @@
|
|||
// 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 CL_GROUP_HTML_H
|
||||
#define CL_GROUP_HTML_H
|
||||
|
||||
#define CURL_STATICLIB 1
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_scrolltext.h"
|
||||
#include "nel/gui/group_tree.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
#include "nel/gui/group_table.h"
|
||||
|
||||
typedef std::map<std::string, std::string> TStyle;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "libwww/WWWInit.h"
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlButton;
|
||||
class CCtrlScroll;
|
||||
class CGroupList;
|
||||
class CDBGroupComboBox;
|
||||
class CGroupParagraph;
|
||||
|
||||
|
||||
|
||||
// HTML group
|
||||
/**
|
||||
* Widget to have a resizable scrolltext and its scrollbar
|
||||
* \author Cyril 'Hulud' Corvazier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupHTML : public CGroupScrollText
|
||||
{
|
||||
public:
|
||||
friend void TextAdd (struct _HText *me, const char * buf, int len);
|
||||
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
|
||||
friend void TextEndElement (_HText *me, int element_number);
|
||||
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
|
||||
friend void TextBuild (HText * me, HTextStatus status);
|
||||
friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length);
|
||||
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
|
||||
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
|
||||
|
||||
/// Web browser options for CGroupHTML
|
||||
struct SWebOptions
|
||||
{
|
||||
public:
|
||||
/// Id of the browser ( e.g.: Chrome, Firefox, Ryzom )
|
||||
std::string appName;
|
||||
/// Version of the browser
|
||||
std::string appVersion;
|
||||
/// Language code of the browser( e.g.: en, hu )
|
||||
std::string languageCode;
|
||||
/// List of domains the widget can consider secure.
|
||||
std::vector< std::string > trustedDomains;
|
||||
|
||||
SWebOptions()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
static SWebOptions options;
|
||||
|
||||
// Constructor
|
||||
CGroupHTML(const TCtorParam ¶m);
|
||||
~CGroupHTML();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// CInterfaceGroup Interface
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void draw ();
|
||||
|
||||
// Events
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
|
||||
// Browse
|
||||
virtual void browse (const char *url);
|
||||
|
||||
// Refresh
|
||||
void refresh();
|
||||
|
||||
// submit form
|
||||
void submitForm (uint formId, const char *submitButtonName);
|
||||
|
||||
// Browse error
|
||||
void browseError (const char *msg);
|
||||
|
||||
// stop browse
|
||||
void stopBrowse ();
|
||||
|
||||
bool isBrowsing();
|
||||
|
||||
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
|
||||
|
||||
// Update coords
|
||||
void updateCoords();
|
||||
|
||||
// New paragraph
|
||||
void newParagraph(uint beginSpace);
|
||||
|
||||
// End of the paragraph
|
||||
void endParagraph();
|
||||
|
||||
// Timeout
|
||||
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
|
||||
float getTimeout() const {return (float)_TimeoutValue;}
|
||||
|
||||
// Some constants
|
||||
NLMISC::CRGBA BgColor;
|
||||
NLMISC::CRGBA ErrorColor;
|
||||
NLMISC::CRGBA LinkColor;
|
||||
NLMISC::CRGBA TextColor;
|
||||
NLMISC::CRGBA H1Color;
|
||||
NLMISC::CRGBA H2Color;
|
||||
NLMISC::CRGBA H3Color;
|
||||
NLMISC::CRGBA H4Color;
|
||||
NLMISC::CRGBA H5Color;
|
||||
NLMISC::CRGBA H6Color;
|
||||
bool ErrorColorGlobalColor;
|
||||
bool LinkColorGlobalColor;
|
||||
bool TextColorGlobalColor;
|
||||
bool H1ColorGlobalColor;
|
||||
bool H2ColorGlobalColor;
|
||||
bool H3ColorGlobalColor;
|
||||
bool H4ColorGlobalColor;
|
||||
bool H5ColorGlobalColor;
|
||||
bool H6ColorGlobalColor;
|
||||
uint TextFontSize;
|
||||
uint H1FontSize;
|
||||
uint H2FontSize;
|
||||
uint H3FontSize;
|
||||
uint H4FontSize;
|
||||
uint H5FontSize;
|
||||
uint H6FontSize;
|
||||
uint TDBeginSpace;
|
||||
uint PBeginSpace;
|
||||
uint LIBeginSpace;
|
||||
uint ULBeginSpace;
|
||||
uint LIIndent;
|
||||
uint ULIndent;
|
||||
float LineSpaceFontFactor;
|
||||
std::string DefaultButtonGroup;
|
||||
std::string DefaultFormTextGroup;
|
||||
std::string DefaultFormTextAreaGroup;
|
||||
std::string DefaultFormSelectGroup;
|
||||
std::string DefaultCheckBoxBitmapNormal;
|
||||
std::string DefaultCheckBoxBitmapPushed;
|
||||
std::string DefaultCheckBoxBitmapOver;
|
||||
std::string DefaultBackgroundBitmapView;
|
||||
std::string CurrentLinkTitle;
|
||||
|
||||
// Browser home
|
||||
std::string Home;
|
||||
|
||||
// Undo browse: Browse the precedent url browsed. no op if none
|
||||
void browseUndo ();
|
||||
// Redo browse: Browse the precedent url undoed. no op if none
|
||||
void browseRedo ();
|
||||
// clear undo/redo
|
||||
void clearUndoRedo();
|
||||
|
||||
|
||||
std::string getURL() const { return _URL; }
|
||||
void setURL(const std::string &url);
|
||||
|
||||
|
||||
int luaBrowse(CLuaState &ls);
|
||||
int luaRefresh(CLuaState &ls);
|
||||
int luaRemoveContent(CLuaState &ls);
|
||||
int luaInsertText(CLuaState &ls);
|
||||
int luaAddString(CLuaState &ls);
|
||||
int luaAddImage(CLuaState &ls);
|
||||
int luaBeginElement(CLuaState &ls);
|
||||
int luaEndElement(CLuaState &ls);
|
||||
int luaShowDiv(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
|
||||
REFLECT_LUA_METHOD("browse", luaBrowse)
|
||||
REFLECT_LUA_METHOD("refresh", luaRefresh)
|
||||
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
|
||||
REFLECT_LUA_METHOD("insertText", luaInsertText)
|
||||
REFLECT_LUA_METHOD("addString", luaAddString)
|
||||
REFLECT_LUA_METHOD("addImage", luaAddImage)
|
||||
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
|
||||
REFLECT_LUA_METHOD("endElement", luaEndElement)
|
||||
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
|
||||
REFLECT_STRING("url", getURL, setURL)
|
||||
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected :
|
||||
|
||||
// \name callback from libwww
|
||||
|
||||
// Begin of the parsing of a HTML document
|
||||
virtual void beginBuild ();
|
||||
|
||||
// End of the parsing of a HTML document
|
||||
virtual void endBuild ();
|
||||
|
||||
// A new text block has been parsed
|
||||
virtual void addText (const char * buf, int len);
|
||||
|
||||
// A link has been parsed
|
||||
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value);
|
||||
|
||||
// A new begin HTML element has been parsed (<IMG> for exemple)
|
||||
virtual void beginElement (uint element_number, const BOOL *present, const char **value);
|
||||
|
||||
// A new end HTML element has been parsed (</IMG> for exemple)
|
||||
virtual void endElement (uint element_number);
|
||||
|
||||
// A new begin unparsed element has been found
|
||||
virtual void beginUnparsedElement(const char *buffer, int length);
|
||||
|
||||
// A new end unparsed element has been found
|
||||
virtual void endUnparsedElement(const char *buffer, int length);
|
||||
|
||||
// Add GET params to the url
|
||||
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
|
||||
|
||||
// Add POST params to the libwww list
|
||||
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain);
|
||||
|
||||
// the current request is terminated
|
||||
virtual void requestTerminated(HTRequest *request);
|
||||
|
||||
// Get Home URL
|
||||
virtual std::string home();
|
||||
|
||||
// Parse style html tag
|
||||
TStyle parseStyle(const std::string &str_styles);
|
||||
|
||||
// Handle some work at each pass
|
||||
virtual void handle ();
|
||||
|
||||
// \name internal methods
|
||||
|
||||
// Add a group in the current parent group
|
||||
void addGroup (CInterfaceGroup *group, uint beginSpace);
|
||||
|
||||
// Get the current parent group
|
||||
CInterfaceGroup *getCurrentGroup();
|
||||
|
||||
// Update current paragraph dependent data
|
||||
void paragraphChange ();
|
||||
|
||||
// Clear the contexts info
|
||||
void clearContext();
|
||||
|
||||
// Translate a char
|
||||
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const;
|
||||
|
||||
// Add a string in the current paragraph
|
||||
void addString(const ucstring &str);
|
||||
|
||||
// Add an image in the current paragraph
|
||||
void addImage(const char *image, bool globalColor, bool reloadImg=false);
|
||||
|
||||
// Add a text area in the current paragraph
|
||||
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content);
|
||||
|
||||
// Add a combo box in the current paragraph
|
||||
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
|
||||
|
||||
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
|
||||
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
|
||||
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip);
|
||||
|
||||
// Set the background color
|
||||
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
|
||||
|
||||
// Set the background
|
||||
void setBackground (const std::string &bgtex, bool scale, bool tile);
|
||||
|
||||
// Force the current string to be in a single string
|
||||
void flushString();
|
||||
|
||||
// Set the title
|
||||
void setTitle (const ucstring &title);
|
||||
|
||||
// Lookup a url in local file system
|
||||
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
|
||||
|
||||
// Delete page content and prepare next page
|
||||
void removeContent ();
|
||||
|
||||
// Current URL
|
||||
std::string _URL;
|
||||
|
||||
// Current DOMAIN
|
||||
bool _TrustedDomain;
|
||||
|
||||
// Title prefix
|
||||
ucstring _TitlePrefix;
|
||||
|
||||
// Title string
|
||||
ucstring _TitleString;
|
||||
|
||||
// Need to browse next update coords..
|
||||
bool _BrowseNextTime;
|
||||
bool _PostNextTime;
|
||||
uint _PostFormId;
|
||||
std::string _PostFormSubmitButton;
|
||||
|
||||
// Browsing..
|
||||
bool _Browsing;
|
||||
bool _Connecting;
|
||||
double _TimeoutValue; // the timeout in seconds
|
||||
double _ConnectingTimeout;
|
||||
|
||||
// minimal embeded lua script support
|
||||
// Note : any embeded script is executed immediately after the closing
|
||||
// element has been found
|
||||
// True when the <lua> element has been encountered
|
||||
bool _ParsingLua;
|
||||
bool _IgnoreText;
|
||||
// the script to execute
|
||||
std::string _LuaScript;
|
||||
|
||||
bool _Object;
|
||||
std::string _ObjectScript;
|
||||
|
||||
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client.
|
||||
static CGroupHTML *_ConnectingLock;
|
||||
|
||||
// LibWWW data
|
||||
class CLibWWWData *_LibWWW;
|
||||
|
||||
// Current paragraph
|
||||
std::string _DivName;
|
||||
CGroupParagraph* _Paragraph;
|
||||
inline CGroupParagraph *getParagraph()
|
||||
{
|
||||
return _Paragraph;
|
||||
/*if (_Paragraph.empty())
|
||||
return NULL;
|
||||
return _Paragraph.back();*/
|
||||
}
|
||||
|
||||
// PRE mode
|
||||
std::vector<bool> _PRE;
|
||||
inline bool getPRE() const
|
||||
{
|
||||
if (_PRE.empty())
|
||||
return false;
|
||||
return _PRE.back();
|
||||
}
|
||||
|
||||
// UL mode
|
||||
std::vector<bool> _UL;
|
||||
inline bool getUL() const
|
||||
{
|
||||
if (_UL.empty())
|
||||
return false;
|
||||
return _UL.back();
|
||||
}
|
||||
|
||||
// A mode
|
||||
std::vector<bool> _A;
|
||||
inline bool getA() const
|
||||
{
|
||||
if (_A.empty())
|
||||
return false;
|
||||
return _A.back();
|
||||
}
|
||||
|
||||
// IL mode
|
||||
bool _LI;
|
||||
|
||||
// Current text color
|
||||
std::vector<NLMISC::CRGBA> _TextColor;
|
||||
inline const NLMISC::CRGBA &getTextColor() const
|
||||
{
|
||||
if (_TextColor.empty())
|
||||
return TextColor;
|
||||
return _TextColor.back();
|
||||
}
|
||||
|
||||
// Current global color flag
|
||||
std::vector<bool> _GlobalColor;
|
||||
inline bool getGlobalColor() const
|
||||
{
|
||||
if (_GlobalColor.empty())
|
||||
return false;
|
||||
return _GlobalColor.back();
|
||||
}
|
||||
|
||||
// Current font size
|
||||
std::vector<uint> _FontSize;
|
||||
inline uint getFontSize() const
|
||||
{
|
||||
if (_FontSize.empty())
|
||||
return TextFontSize;
|
||||
return _FontSize.back();
|
||||
}
|
||||
|
||||
// Current link
|
||||
std::vector<std::string> _Link;
|
||||
inline const char *getLink() const
|
||||
{
|
||||
if (_Link.empty())
|
||||
return "";
|
||||
return _Link.back().c_str();
|
||||
}
|
||||
|
||||
std::vector<std::string> _LinkTitle;
|
||||
inline const char *getLinkTitle() const
|
||||
{
|
||||
if (_LinkTitle.empty())
|
||||
return "";
|
||||
return _LinkTitle.back().c_str();
|
||||
}
|
||||
std::vector<std::string> _LinkClass;
|
||||
inline const char *getLinkClass() const
|
||||
{
|
||||
if (_LinkClass.empty())
|
||||
return "";
|
||||
return _LinkClass.back().c_str();
|
||||
}
|
||||
|
||||
// Divs (i.e. interface group)
|
||||
std::vector<class CInterfaceGroup*> _Divs;
|
||||
inline CInterfaceGroup *getDiv() const
|
||||
{
|
||||
if (_Divs.empty())
|
||||
return NULL;
|
||||
return _Divs.back();
|
||||
}
|
||||
|
||||
// Tables
|
||||
std::vector<class CGroupTable*> _Tables;
|
||||
inline CGroupTable *getTable() const
|
||||
{
|
||||
if (_Tables.empty())
|
||||
return NULL;
|
||||
return _Tables.back();
|
||||
}
|
||||
|
||||
// Cells
|
||||
std::vector<class CGroupCell*> _Cells;
|
||||
|
||||
// TR
|
||||
std::vector<bool> _TR;
|
||||
inline bool getTR() const
|
||||
{
|
||||
if (_TR.empty())
|
||||
return false;
|
||||
return _TR.back();
|
||||
}
|
||||
|
||||
// Forms
|
||||
class CForm
|
||||
{
|
||||
public:
|
||||
|
||||
class CEntry
|
||||
{
|
||||
public:
|
||||
CEntry ()
|
||||
{
|
||||
TextArea = NULL;
|
||||
Checkbox = NULL;
|
||||
ComboBox = NULL;
|
||||
InitialSelection = 0;
|
||||
}
|
||||
|
||||
// Variable name
|
||||
std::string Name;
|
||||
|
||||
// Variable value
|
||||
ucstring Value;
|
||||
|
||||
// Text area group
|
||||
CInterfaceGroup *TextArea;
|
||||
|
||||
// Checkbox
|
||||
CCtrlButton *Checkbox;
|
||||
|
||||
// Combobox group
|
||||
CDBGroupComboBox *ComboBox;
|
||||
|
||||
// select values (for the <select> tag)
|
||||
std::vector<std::string> SelectValues;
|
||||
sint InitialSelection; // initial selection for the combo box
|
||||
};
|
||||
|
||||
// The action the form has to perform
|
||||
std::string Action;
|
||||
|
||||
// The text area associated with the form
|
||||
std::vector<CEntry> Entries;
|
||||
};
|
||||
std::vector<CForm> _Forms;
|
||||
std::vector<CInterfaceGroup *> _Groups;
|
||||
|
||||
// Cells parameters
|
||||
class CCellParams
|
||||
{
|
||||
public:
|
||||
CCellParams () : BgColor(0,0,0,0)
|
||||
{
|
||||
Align = CGroupCell::Left;
|
||||
VAlign = CGroupCell::Top;
|
||||
LeftMargin = 0;
|
||||
NoWrap = false;
|
||||
}
|
||||
NLMISC::CRGBA BgColor;
|
||||
std::string Style;
|
||||
CGroupCell::TAlign Align;
|
||||
CGroupCell::TVAlign VAlign;
|
||||
sint32 LeftMargin;
|
||||
bool NoWrap;
|
||||
};
|
||||
std::vector<CCellParams> _CellParams;
|
||||
|
||||
// Indentation
|
||||
uint _Indent;
|
||||
|
||||
// Current node is a title
|
||||
bool _Title;
|
||||
|
||||
// Current node must be localized
|
||||
bool _Localize;
|
||||
|
||||
// Current node is a text area
|
||||
bool _TextArea;
|
||||
std::string _TextAreaTemplate;
|
||||
ucstring _TextAreaContent;
|
||||
std::string _TextAreaName;
|
||||
uint _TextAreaRow;
|
||||
uint _TextAreaCols;
|
||||
|
||||
// current mode is in select option
|
||||
bool _SelectOption;
|
||||
ucstring _SelectOptionStr;
|
||||
|
||||
// Current node is a object
|
||||
std::string _ObjectType;
|
||||
std::string _ObjectData;
|
||||
std::string _ObjectMD5Sum;
|
||||
std::string _ObjectAction;
|
||||
std::string _TextAreaScript;
|
||||
|
||||
// Get last char
|
||||
ucchar getLastChar() const;
|
||||
|
||||
// Current link view
|
||||
class CViewLink *_CurrentViewLink;
|
||||
class CViewBitmap *_CurrentViewImage;
|
||||
|
||||
// Current group table
|
||||
class CGroupCell *_CurrentCell;
|
||||
|
||||
// The main group
|
||||
class CGroupListAdaptor *_GroupListAdaptor;
|
||||
|
||||
// For auto selecting the node in a BrowseTree bound to this HTML web page
|
||||
std::string _BrowseTree;
|
||||
// select the tree node that has the correct url
|
||||
const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url);
|
||||
// search if the action / params match the url. look recurs into procedures
|
||||
bool actionLaunchUrlRecurs(const std::string &ah, const std::string ¶ms, const std::string &url);
|
||||
|
||||
// Browse undo and redo
|
||||
enum {MaxUrlUndoRedo= 256};
|
||||
std::string _BrowseUndoButton;
|
||||
std::string _BrowseRedoButton;
|
||||
std::string _BrowseRefreshButton;
|
||||
// _BrowseUrl is different from _URL, in that _URL may change in handle()
|
||||
std::string _AskedUrl;
|
||||
std::deque<std::string> _BrowseUndo;
|
||||
std::deque<std::string> _BrowseRedo;
|
||||
void pushUrlUndoRedo(const std::string &url);
|
||||
void doBrowse(const char *url);
|
||||
void updateUndoRedoButtons();
|
||||
void updateRefreshButton();
|
||||
|
||||
// For Killing request. Associate each CGroupHTML object with a unique ID.
|
||||
uint32 _GroupHtmlUID;
|
||||
static uint32 _GroupHtmlUIDPool;
|
||||
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
|
||||
static TGroupHtmlByUIDMap _GroupHtmlByUID;
|
||||
|
||||
private:
|
||||
|
||||
// decode all HTML entities
|
||||
static ucstring decodeHTMLEntities(const ucstring &str);
|
||||
|
||||
// ImageDownload system
|
||||
enum TDataType {ImgType= 0, BnpType};
|
||||
|
||||
struct CDataDownload
|
||||
{
|
||||
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f)
|
||||
{
|
||||
if (t == ImgType) imgs.push_back(i);
|
||||
}
|
||||
|
||||
CURL *curl;
|
||||
std::string url;
|
||||
std::string luaScript;
|
||||
std::string md5sum;
|
||||
TDataType type;
|
||||
FILE *fp;
|
||||
std::vector<CViewBase *> imgs;
|
||||
};
|
||||
|
||||
std::vector<CDataDownload> Curls;
|
||||
CURLM *MultiCurl;
|
||||
int RunningCurls;
|
||||
|
||||
void initImageDownload();
|
||||
void checkImageDownload();
|
||||
void addImageDownload(const std::string &url, CViewBase *img);
|
||||
std::string localImageName(const std::string &url);
|
||||
|
||||
bool isTrustedDomain(const std::string &domain);
|
||||
void setImage(CViewBase *view, const std::string &file);
|
||||
|
||||
// BnpDownload system
|
||||
void initBnpDownload();
|
||||
void checkBnpDownload();
|
||||
bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum);
|
||||
std::string localBnpName(const std::string &url);
|
||||
|
||||
void releaseDownloads();
|
||||
void checkDownloads();
|
||||
|
||||
};
|
||||
|
||||
// adapter group that store y offset for inputs inside an html form
|
||||
class CGroupHTMLInputOffset : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
sint32 Offset;
|
||||
CGroupHTMLInputOffset(const TCtorParam ¶m);
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
270
code/nel/include/nel/gui/group_list.h
Normal file
270
code/nel/include/nel/gui/group_list.h
Normal file
|
@ -0,0 +1,270 @@
|
|||
// 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 NL_GROUP_LIST_H
|
||||
#define NL_GROUP_LIST_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/group_frame.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CGroupList : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
enum EAlign
|
||||
{
|
||||
Bottom = 0,
|
||||
Top,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
///constructor
|
||||
CGroupList(const TCtorParam ¶m);
|
||||
|
||||
// dtor
|
||||
~CGroupList();
|
||||
/**
|
||||
* add a child element to the group at the last position
|
||||
* 'order' of the element is set to the last order + 1
|
||||
* \param child : pointer to the child element
|
||||
*/
|
||||
void addChild (CViewBase* child, bool deleteOnRemove=true);
|
||||
|
||||
|
||||
/** add a child before the element at the given index.
|
||||
* 'order' of the element is set to 0
|
||||
* \return true if there was enough room for that child
|
||||
*/
|
||||
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
|
||||
|
||||
/**
|
||||
* add a text child element to the group, using the text template
|
||||
* \param line : text to be added
|
||||
* \param color : text color
|
||||
*/
|
||||
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
|
||||
|
||||
/**
|
||||
* add a text child element to the group, using the text template
|
||||
* \param line : text to be added
|
||||
*/
|
||||
void addTextChild (const ucstring& line, bool multiLine = true);
|
||||
|
||||
/// Same as adding a text child but the text will be taken from the string manager
|
||||
void addTextChildID (uint32 id, bool multiLine = true);
|
||||
// the same, but with id taken from the database
|
||||
void addTextChildID (const std::string &dbPath, bool multiLine = true);
|
||||
|
||||
|
||||
bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false);
|
||||
|
||||
bool delChild(uint index, bool forceDontDelete = false);
|
||||
|
||||
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
|
||||
int luaGetChild(CLuaState &ls);
|
||||
|
||||
void deleteAllChildren();
|
||||
|
||||
void removeHead();
|
||||
|
||||
// Get the number of children
|
||||
uint getNumChildren() const { return (uint)_Elements.size(); }
|
||||
|
||||
// Get the number of active children
|
||||
uint getNumActiveChildren() const;
|
||||
|
||||
/**
|
||||
* set the template that will be used to add text;
|
||||
* \templ : a CViewText object. Only its font size, color and shadow are required.
|
||||
*/
|
||||
void setTextTemplate(const CViewText& templ);
|
||||
|
||||
/**
|
||||
* set the template that will be used to add text;
|
||||
* \templ : a CViewText object. Only its font size, color and shadow are required.
|
||||
*/
|
||||
CViewText * getTextTemplatePtr()
|
||||
{
|
||||
return &_Templ;
|
||||
}
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/**
|
||||
* parse the element and initalize it
|
||||
* \paral cur : pointer to the node describing this element
|
||||
* \param parentGroup : the parent group of this element
|
||||
* \return true if success
|
||||
*/
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
//virtual uint32 getMemory();
|
||||
/**
|
||||
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
|
||||
*/
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
|
||||
virtual void clearViews();
|
||||
virtual void clearControls();
|
||||
virtual void clearGroups();
|
||||
|
||||
void setSpace (sint32 s) { _Space = s; }
|
||||
|
||||
virtual CInterfaceElement* getElement (const std::string &id)
|
||||
{ return CInterfaceGroup::getElement (id); }
|
||||
|
||||
sint32 getNbElement() { return (sint32)_Elements.size(); }
|
||||
sint32 getSpace() { return _Space; }
|
||||
|
||||
void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; }
|
||||
bool getDynamicDisplaySize() { return _DynamicDisplaySize; }
|
||||
|
||||
void forceSizeW (sint32 newSizeW);
|
||||
void forceSizeH (sint32 newSizeH);
|
||||
|
||||
void setMinW(sint32 minW);
|
||||
void setMinH(sint32 minH);
|
||||
sint32 getMinW() const {return _MinW;}
|
||||
sint32 getMinH() const {return _MinH;}
|
||||
|
||||
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
|
||||
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
|
||||
uint getOrder(uint index) const { return _Elements[index].Order; }
|
||||
|
||||
// get element of index or -1 if not found
|
||||
sint32 getElementIndex(CViewBase* child) const;
|
||||
int luaGetElementIndex(CLuaState &ls);
|
||||
|
||||
// swap 2 entries in the list (and also their orders)
|
||||
void swapChildren(uint index1, uint index2);
|
||||
int luaUpChild(CLuaState &ls);
|
||||
int luaDownChild(CLuaState &ls);
|
||||
|
||||
// deleteOnRemove flag
|
||||
void setDelOnRemove(uint index, bool delOnRemove);
|
||||
bool getDelOnRemove(uint index) const;
|
||||
|
||||
// children number
|
||||
void setChildrenNb(sint32 /* val */){}
|
||||
sint32 getChildrenNb() const {return (sint32)_Elements.size();}
|
||||
|
||||
int luaAddChild(CLuaState &ls);
|
||||
int luaAddChildAtIndex(CLuaState &ls);
|
||||
int luaDetachChild(CLuaState &ls);
|
||||
int luaClear(CLuaState &ls); // synonimous for deleteAllChildren
|
||||
int luaAddTextChild(CLuaState &ls);
|
||||
int luaAddColoredTextChild(CLuaState &ls);
|
||||
int luaDelChild(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CGroupList, CInterfaceGroup)
|
||||
REFLECT_LUA_METHOD("addTextChild", luaAddTextChild)
|
||||
REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild)
|
||||
REFLECT_LUA_METHOD("addChild", luaAddChild);
|
||||
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
|
||||
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
|
||||
REFLECT_LUA_METHOD("clear", luaClear);
|
||||
REFLECT_LUA_METHOD("delChild", luaDelChild);
|
||||
REFLECT_LUA_METHOD("upChild", luaUpChild);
|
||||
REFLECT_LUA_METHOD("downChild", luaDownChild);
|
||||
REFLECT_LUA_METHOD("getChild", luaGetChild);
|
||||
REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex);
|
||||
REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
protected:
|
||||
std::string _HardText;
|
||||
uint32 _TextId;
|
||||
|
||||
//max number of elements
|
||||
sint32 _MaxElements;
|
||||
|
||||
// Where to add next element
|
||||
EAlign _AddElt;
|
||||
|
||||
// Where to align the newly added element
|
||||
EAlign _Align;
|
||||
|
||||
// Space between two elements in pixel
|
||||
sint32 _Space;
|
||||
|
||||
// Text template
|
||||
CViewText _Templ;
|
||||
|
||||
// Current id of the view
|
||||
sint32 _IdCounter;
|
||||
|
||||
// Used for context menu to display the same size as the whole content
|
||||
bool _DynamicDisplaySize;
|
||||
|
||||
// Do we have a color under the element pointed by the mouse
|
||||
bool _Over;
|
||||
|
||||
// If over is true so we have a color
|
||||
NLMISC::CRGBA _OverColor;
|
||||
|
||||
// Current elt over the pointer
|
||||
sint32 _OverElt;
|
||||
|
||||
struct CElementInfo
|
||||
{
|
||||
uint Order; // Used to sort the window by their insertion order.
|
||||
// This is used to put back a window at the right place if it was turned into a popup.
|
||||
CViewBase *Element;
|
||||
bool EltDeleteOnRemove;
|
||||
};
|
||||
friend struct CRemoveViewPred;
|
||||
friend struct CRemoveCtrlPred;
|
||||
friend struct CRemoveGroupPred;
|
||||
|
||||
// The list is forced to be at least this size in updateCoords().
|
||||
sint32 _MinW;
|
||||
sint32 _MinH;
|
||||
|
||||
|
||||
// To conserve elements in the order they have been added
|
||||
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
|
||||
std::vector<CElementInfo> _Elements;
|
||||
|
||||
private:
|
||||
|
||||
void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
|
||||
void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
|
||||
void setupSizes();
|
||||
void onTextChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_LIST_H
|
||||
|
||||
/* End of group_list.h */
|
||||
|
||||
|
401
code/nel/include/nel/gui/group_menu.h
Normal file
401
code/nel/include/nel/gui/group_menu.h
Normal file
|
@ -0,0 +1,401 @@
|
|||
// 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 RZ_GROUP_MENU_H
|
||||
#define RZ_GROUP_MENU_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/group_modal.h"
|
||||
#include "nel/gui/group_submenu_base.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/ctrl_text_button.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlScroll;
|
||||
class CViewBitmap;
|
||||
class CGroupList;
|
||||
class CGroupMenu;
|
||||
|
||||
|
||||
/**
|
||||
* CViewTextMenu is an element of a sub menu
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewTextMenu : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
CViewTextMenu(const TCtorParam ¶m) : CViewText(param)
|
||||
{
|
||||
_Grayed = false;
|
||||
_Checked = false;
|
||||
_Checkable = false;
|
||||
_CheckBox = NULL;
|
||||
Over = false;
|
||||
}
|
||||
|
||||
bool getGrayed() const;
|
||||
void setGrayed (bool g);
|
||||
bool getChecked() const { return _Checked; }
|
||||
void setChecked(bool c);
|
||||
bool getCheckable() const { return _Checkable; }
|
||||
void setCheckable(bool c);
|
||||
void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; }
|
||||
CViewBitmap * getCheckBox() const { return _CheckBox; }
|
||||
bool getFormatted () const { return getMultiLine (); }
|
||||
|
||||
virtual sint32 getAlpha() const;
|
||||
virtual void setAlpha (sint32 a);
|
||||
|
||||
REFLECT_EXPORT_START(CViewTextMenu, CViewText)
|
||||
REFLECT_BOOL("grayed", getGrayed, setGrayed);
|
||||
REFLECT_BOOL("checked", getChecked, setChecked);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
public:
|
||||
|
||||
bool Over;
|
||||
NLMISC::CRGBA OldColor;
|
||||
NLMISC::CRGBA OldShadowColor;
|
||||
NLMISC::CRGBA OldColorOver;
|
||||
NLMISC::CRGBA OldShadowColorOver;
|
||||
NLMISC::CRGBA OldColorGrayed;
|
||||
NLMISC::CRGBA OldShadowColorGrayed;
|
||||
|
||||
private:
|
||||
CViewBitmap *_CheckBox;
|
||||
bool _Grayed;
|
||||
bool _Checked;
|
||||
bool _Checkable;
|
||||
};
|
||||
|
||||
/**
|
||||
* CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu)
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class CGroupSubMenu : public CGroupSubMenuBase
|
||||
{
|
||||
public:
|
||||
|
||||
CGroupSubMenu(const TCtorParam ¶m);
|
||||
virtual ~CGroupSubMenu();
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL);
|
||||
|
||||
virtual void checkCoords();
|
||||
|
||||
virtual void updateCoords ();
|
||||
|
||||
virtual void draw ();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
virtual CInterfaceElement* getElement (const std::string &id);
|
||||
|
||||
// retrieve the index of a line from its id (-1 if not found)
|
||||
sint getLineFromId(const std::string &id);
|
||||
|
||||
CViewTextMenu* addLine (const ucstring &name, const std::string &ah,
|
||||
const std::string ¶ms, const std::string &id="",
|
||||
const std::string &cond = std::string(), const std::string &texture="",
|
||||
bool checkable = false, bool checked = false, bool formatted = false
|
||||
);
|
||||
CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah,
|
||||
const std::string ¶ms, const std::string &id="",
|
||||
const std::string &cond = std::string(), const std::string &texture="",
|
||||
bool checkable = false, bool checked = false, bool formatted = false
|
||||
);
|
||||
void addSeparator(const std::string &id = "");
|
||||
void addSeparatorAtIndex(uint index, const std::string &id = "");
|
||||
|
||||
|
||||
uint getNumLine() const { return (uint)_Lines.size(); }
|
||||
void removeLine(uint index);
|
||||
const std::string getActionHandler(uint lineIndex) const;
|
||||
const std::string getActionHandlerParam(uint lineIndex) const;
|
||||
|
||||
void openSubMenu (sint32 nb);
|
||||
|
||||
void hideSubMenus ();
|
||||
|
||||
// reset all entries of the sub menu
|
||||
void reset();
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
// Tell if the line is a separator or not
|
||||
bool isSeparator (uint i) const;
|
||||
|
||||
/** Set a user defined group at the given line
|
||||
* 'ownership' tells whether this menu should remove the group when it is deleted
|
||||
* Setting a user group on a line with a separator is illegal
|
||||
*/
|
||||
void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership);
|
||||
CInterfaceGroup *getUserGroupRight(uint line) const;
|
||||
//
|
||||
void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership);
|
||||
CInterfaceGroup *getUserGroupLeft(uint line) const;
|
||||
|
||||
void removeAllUserGroups();
|
||||
|
||||
uint getNumLines() const { return (uint)_Lines.size(); }
|
||||
|
||||
// return pointer to submenu or NULL if there's none
|
||||
CGroupSubMenu *getSubMenu(uint index) const;
|
||||
void setSubMenu(uint index, CGroupSubMenu *sub);
|
||||
|
||||
// if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup)
|
||||
void setSelectable(uint lineIndex, bool selectable);
|
||||
bool getSelectable(uint lineIndex) const;
|
||||
|
||||
// Gray a line.
|
||||
void setGrayedLine(uint line, bool g);
|
||||
|
||||
// Hide a line.
|
||||
void setHiddenLine(uint line, bool h);
|
||||
|
||||
// Max Visible Line (-1 == no limit)
|
||||
void setMaxVisibleLine(sint32 mvl);
|
||||
sint32 getMaxVisibleLine() { return _MaxVisibleLine; }
|
||||
|
||||
// Get the Line Id (not the full Id)
|
||||
const std::string &getLineId(uint index);
|
||||
|
||||
int luaGetNumLine(CLuaState &ls);
|
||||
int luaGetSubMenu(CLuaState &ls);
|
||||
int luaAddSubMenu(CLuaState &ls);
|
||||
int luaGetLineId(CLuaState &ls);
|
||||
int luaGetLineFromId(CLuaState &ls);
|
||||
int luaIsSeparator(CLuaState &ls);
|
||||
int luaAddLine(CLuaState &ls);
|
||||
int luaAddLineAtIndex(CLuaState &ls);
|
||||
int luaAddSeparator(CLuaState &ls);
|
||||
int luaAddSeparatorAtIndex(CLuaState &ls);
|
||||
int luaRemoveLine(CLuaState &ls);
|
||||
int luaSetUserGroupRight(CLuaState &ls);
|
||||
int luaGetUserGroupRight(CLuaState &ls);
|
||||
int luaSetUserGroupLeft(CLuaState &ls);
|
||||
int luaGetUserGroupLeft(CLuaState &ls);
|
||||
int luaReset(CLuaState &ls);
|
||||
int luaSetMaxVisibleLine(CLuaState &ls);
|
||||
//
|
||||
REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase)
|
||||
REFLECT_LUA_METHOD("getNumLine", luaGetNumLine);
|
||||
REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index
|
||||
REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found
|
||||
REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu);
|
||||
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
|
||||
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
|
||||
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
|
||||
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
|
||||
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
|
||||
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
|
||||
REFLECT_LUA_METHOD("removeLine", luaRemoveLine);
|
||||
REFLECT_LUA_METHOD("reset", luaReset);
|
||||
REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr
|
||||
REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line
|
||||
REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr
|
||||
REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line
|
||||
REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
struct SSubMenuEntry
|
||||
{
|
||||
CViewTextMenu *ViewText; // Backup of the children that are in grouplist
|
||||
CInterfaceGroup *Separator;
|
||||
std::string AHName;
|
||||
std::string AHParams;
|
||||
std::string Id;
|
||||
std::string Cond; // condition to know if the entry is grayed
|
||||
CViewBitmap *CheckBox;
|
||||
CViewBitmap *RightArrow;
|
||||
CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow
|
||||
CInterfaceGroup *UserGroupLeft;
|
||||
bool UserGroupRightOwnership;
|
||||
bool UserGroupLeftOwnership;
|
||||
bool Selectable;
|
||||
sint32 HReal; // max H of the view text and the other user group
|
||||
sint32 TextDY; // Y of the view text to set
|
||||
SSubMenuEntry()
|
||||
{
|
||||
ViewText = NULL;
|
||||
Separator = NULL;
|
||||
CheckBox = NULL;
|
||||
RightArrow = NULL;
|
||||
UserGroupRight = NULL;
|
||||
UserGroupLeft = NULL;
|
||||
UserGroupRightOwnership = false;
|
||||
Selectable = true;
|
||||
HReal= 0;
|
||||
TextDY= 0;
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
CGroupList *_GroupList;
|
||||
CCtrlScroll *_ScrollBar;
|
||||
CViewBitmap *_SelectionView;
|
||||
std::vector<SSubMenuEntry> _Lines;
|
||||
std::vector<CGroupSubMenu*> _SubMenus;
|
||||
|
||||
CGroupMenu *_GroupMenu; // Master parent
|
||||
sint32 _Selected;
|
||||
|
||||
sint32 _MaxVisibleLine; // -1 == no limit
|
||||
|
||||
friend class CGroupMenu;
|
||||
private:
|
||||
/** Clone this menu, and set its new father
|
||||
* If appendToMenu is NULL, the menu is just copied
|
||||
* otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu.
|
||||
* NB : user groups are not duplicated
|
||||
*/
|
||||
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
|
||||
void initOptions(CInterfaceGroup *parent);
|
||||
CViewBitmap *createCheckBox(bool checked);
|
||||
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
|
||||
};
|
||||
|
||||
/**
|
||||
* class describing a menu composed of one or more CGroupListSubMenu
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupMenu : public CGroupModal
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CGroupMenu(const TCtorParam ¶m);
|
||||
virtual ~CGroupMenu();
|
||||
|
||||
TCaseMode getCaseMode() { return _CaseMode; }
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
virtual void draw ();
|
||||
|
||||
void recurseDraw(CGroupSubMenu *pSubMenu);
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
virtual CInterfaceElement* getElement (const std::string &id);
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
virtual bool isWindowUnder (sint32 x, sint32 y);
|
||||
|
||||
// add line with a string, for backward compatibility
|
||||
void addLine (const std::string &name, const std::string &ah, const std::string ¶ms,
|
||||
const std::string &id = std::string(),
|
||||
const std::string &cond = std::string(), const std::string &texture="",
|
||||
bool checkable = false, bool checked = false);
|
||||
uint getNumLine() const;
|
||||
void deleteLine(uint index);
|
||||
const std::string getActionHandler(uint lineIndex) const;
|
||||
const std::string getActionHandlerParam(uint lineIndex) const;
|
||||
|
||||
|
||||
void addLine (const ucstring &name, const std::string &ah = "", const std::string ¶ms = "",
|
||||
const std::string &id = std::string(),
|
||||
const std::string &cond = std::string(), const std::string &texture="",
|
||||
bool checkable = false, bool checked = false
|
||||
);
|
||||
void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string ¶ms = "",
|
||||
const std::string &id = std::string(),
|
||||
const std::string &cond = std::string(), const std::string &texture="",
|
||||
bool checkable = false, bool checked = false
|
||||
);
|
||||
void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true);
|
||||
void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true);
|
||||
|
||||
// clear all sub menus
|
||||
void reset ();
|
||||
|
||||
// set the minW of the RootMenu.
|
||||
void setMinW(sint32 minW);
|
||||
|
||||
// Gray a line on the RootMenu
|
||||
void setGrayedLine(uint line, bool g);
|
||||
|
||||
CGroupSubMenu *getRootMenu() const { return _RootMenu; }
|
||||
|
||||
// Max Visible Line (-1 == no limit)
|
||||
void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); }
|
||||
sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); }
|
||||
|
||||
// special for menu launched from a modal....
|
||||
bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;}
|
||||
void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;}
|
||||
|
||||
int luaGetRootMenu(CLuaState &ls);
|
||||
int luaSetMinW(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CGroupMenu, CGroupModal)
|
||||
REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu);
|
||||
REFLECT_LUA_METHOD("setMinW", luaSetMinW);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
TCaseMode _CaseMode;
|
||||
|
||||
CGroupSubMenu *_RootMenu;
|
||||
|
||||
std::string _Extends;
|
||||
|
||||
// Text lookup
|
||||
NLMISC::CRGBA _Color;
|
||||
NLMISC::CRGBA _ShadowColor;
|
||||
|
||||
bool _CloseSubMenuUsingPopModal;
|
||||
bool _Shadow;
|
||||
bool _Formatted;
|
||||
uint8 _Space;
|
||||
sint32 _FontSize;
|
||||
|
||||
NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it
|
||||
NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it
|
||||
NLMISC::CRGBA _HighLightOver; // Background color of the selection
|
||||
|
||||
NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable
|
||||
NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable
|
||||
|
||||
friend class CGroupSubMenu;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_GROUP_MENU_H
|
||||
|
||||
/* End of group_menu.h */
|
||||
|
||||
|
77
code/nel/include/nel/gui/group_modal.h
Normal file
77
code/nel/include/nel/gui/group_modal.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 NL_GROUP_MODAL_H
|
||||
#define NL_GROUP_MODAL_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/group_frame.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* A group with special modal options
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupModal : public CGroupFrame
|
||||
{
|
||||
public:
|
||||
bool SpawnOnMousePos : 1;
|
||||
bool ExitClickOut : 1;
|
||||
bool ExitClickL : 1;
|
||||
bool ExitClickR : 1;
|
||||
bool ForceInsideScreen : 1;
|
||||
bool ExitKeyPushed : 1;
|
||||
sint32 SpawnMouseX, SpawnMouseY;
|
||||
std::string Category;
|
||||
|
||||
std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured
|
||||
std::string OnClickOutParams;
|
||||
std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured
|
||||
std::string OnPostClickOutParams;
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CGroupModal(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords ();
|
||||
void setBaseX(sint32 x) { _MouseDeltaX = x;}
|
||||
void setBaseY(sint32 y) { _MouseDeltaY = y;}
|
||||
|
||||
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
// ******************
|
||||
protected:
|
||||
sint32 _MouseDeltaX, _MouseDeltaY;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_MODAL_H
|
||||
|
||||
/* End of group_modal.h */
|
313
code/nel/include/nel/gui/group_paragraph.h
Normal file
313
code/nel/include/nel/gui/group_paragraph.h
Normal file
|
@ -0,0 +1,313 @@
|
|||
// 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 NL_GROUP_PARAGRAPH_H
|
||||
#define NL_GROUP_PARAGRAPH_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/group_frame.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/view_link.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CCtrlLink : public CCtrlButton
|
||||
{
|
||||
public:
|
||||
CCtrlLink (const TCtorParam ¶m) : CCtrlButton(param)
|
||||
{}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CGroupParagraph : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
enum EAlign
|
||||
{
|
||||
Bottom = 0,
|
||||
Top,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
///constructor
|
||||
CGroupParagraph(const TCtorParam ¶m);
|
||||
|
||||
// dtor
|
||||
~CGroupParagraph();
|
||||
|
||||
/**
|
||||
* add a child element to the group at the last position
|
||||
* 'order' of the element is set to the last order + 1
|
||||
* \param child : pointer to the child element
|
||||
*/
|
||||
void addChild (CViewBase* child, bool deleteOnRemove=true);
|
||||
|
||||
/**
|
||||
* add a link element to the group at the last position
|
||||
* \param child : pointer to the child element
|
||||
*/
|
||||
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
|
||||
|
||||
/** add a child before the element at the given index.
|
||||
* 'order' of the element is set to 0
|
||||
* \return true if there was enough room for that child
|
||||
*/
|
||||
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
|
||||
|
||||
/**
|
||||
* add a text child element to the group, using the text template
|
||||
* \param line : text to be added
|
||||
* \param color : text color
|
||||
*/
|
||||
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
|
||||
|
||||
/**
|
||||
* add a text child element to the group, using the text template
|
||||
* \param line : text to be added
|
||||
*/
|
||||
void addTextChild (const ucstring& line, bool multiLine = true);
|
||||
|
||||
/// Same as adding a text child but the text will be taken from the string manager
|
||||
void addTextChildID (uint32 id, bool multiLine = true);
|
||||
// the same, but with id taken from the database
|
||||
void addTextChildID (const std::string &dbPath, bool multiLine = true);
|
||||
|
||||
protected:
|
||||
|
||||
void delChild (CViewBase* child);
|
||||
|
||||
void delChild(uint index);
|
||||
|
||||
public:
|
||||
|
||||
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
|
||||
|
||||
void deleteAllChildren();
|
||||
|
||||
// void removeHead();
|
||||
|
||||
// Get the number of children
|
||||
uint getNumChildren() const { return (uint)_Elements.size(); }
|
||||
|
||||
// Get the number of active children
|
||||
uint getNumActiveChildren() const;
|
||||
|
||||
/**
|
||||
* set the template that will be used to add text;
|
||||
* \templ : a CViewText object. Only its font size, color and shadow are required.
|
||||
*/
|
||||
void setTextTemplate(const CViewText& templ);
|
||||
|
||||
/**
|
||||
* set the template that will be used to add text;
|
||||
* \templ : a CViewText object. Only its font size, color and shadow are required.
|
||||
*/
|
||||
CViewText * getTextTemplatePtr()
|
||||
{
|
||||
return &_Templ;
|
||||
}
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/**
|
||||
* parse the element and initalize it
|
||||
* \paral cur : pointer to the node describing this element
|
||||
* \param parentGroup : the parent group of this element
|
||||
* \return true if success
|
||||
*/
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
//virtual uint32 getMemory();
|
||||
/**
|
||||
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
|
||||
*/
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual void checkCoords();
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
|
||||
virtual void clearViews();
|
||||
virtual void clearControls();
|
||||
virtual void clearGroups();
|
||||
|
||||
void setSpace (sint32 s) { _Space = s; }
|
||||
|
||||
virtual CInterfaceElement* getElement (const std::string &id)
|
||||
{ return CInterfaceGroup::getElement (id); }
|
||||
|
||||
sint32 getNbElement() { return (sint32)_Elements.size(); }
|
||||
sint32 getSpace() { return _Space; }
|
||||
|
||||
void forceSizeW (sint32 newSizeW);
|
||||
void forceSizeH (sint32 newSizeH);
|
||||
|
||||
void setMinW(sint32 minW);
|
||||
void setMinH(sint32 minH);
|
||||
sint32 getMinW() const {return _MinW;}
|
||||
sint32 getMinH() const {return _MinH;}
|
||||
|
||||
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
|
||||
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
|
||||
uint getOrder(uint index) const { return _Elements[index].Order; }
|
||||
|
||||
// get element of index or -1 if not found
|
||||
sint32 getElementIndex(CViewBase* child) const;
|
||||
|
||||
// swap 2 entries in the list (and also their orders)
|
||||
// void swapChildren(uint index1, uint index2);
|
||||
|
||||
// deleteOnRemove flag
|
||||
void setDelOnRemove(uint index, bool delOnRemove);
|
||||
bool getDelOnRemove(uint index) const;
|
||||
|
||||
void setTopSpace(uint topSpace)
|
||||
{
|
||||
_TopSpace = topSpace;
|
||||
setResizeFromChildHMargin(topSpace);
|
||||
invalidateContent();
|
||||
};
|
||||
|
||||
uint getTopSpace()
|
||||
{
|
||||
return _TopSpace;
|
||||
};
|
||||
|
||||
void setIndent(uint indent) { _Indent = indent; }
|
||||
|
||||
void setFirstViewIndent(sint indent)
|
||||
{
|
||||
_FirstViewIndentView = indent;
|
||||
invalidateContent();
|
||||
}
|
||||
|
||||
// Set the HTML group used for links
|
||||
void setBrowseGroup (CInterfaceElement *group)
|
||||
{
|
||||
_BrowseGroup = group;
|
||||
}
|
||||
|
||||
/// \from CInterfaceElement
|
||||
void onInvalidateContent();
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
protected:
|
||||
|
||||
// Content validated
|
||||
bool _ContentValidated;
|
||||
|
||||
// Where to add next element
|
||||
EAlign _AddElt;
|
||||
|
||||
// Where to align the newly added element
|
||||
EAlign _Align;
|
||||
|
||||
// Space between two elements in pixel
|
||||
sint32 _Space;
|
||||
|
||||
// Text template
|
||||
CViewText _Templ;
|
||||
|
||||
// Current id of the view
|
||||
sint32 _IdCounter;
|
||||
|
||||
// Do we have a color under the element pointed by the mouse
|
||||
bool _Over;
|
||||
|
||||
// If over is true so we have a color
|
||||
NLMISC::CRGBA _OverColor;
|
||||
|
||||
// Current elt over the pointer
|
||||
sint32 _OverElt;
|
||||
|
||||
struct CElementInfo
|
||||
{
|
||||
uint Order; // Used to sort the window by their insertion order.
|
||||
// This is used to put back a window at the right place if it was turned into a popup.
|
||||
CViewBase *Element;
|
||||
bool EltDeleteOnRemove;
|
||||
};
|
||||
friend struct CRemoveViewPred;
|
||||
friend struct CRemoveCtrlPred;
|
||||
friend struct CRemoveGroupPred;
|
||||
|
||||
// The list is forced to be at least this size in updateCoords().
|
||||
sint32 _MinW;
|
||||
sint32 _MinH;
|
||||
|
||||
|
||||
// To conserve elements in the order they have been added
|
||||
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
|
||||
std::vector<CElementInfo> _Elements;
|
||||
|
||||
// Last parent width
|
||||
sint32 _LastW;
|
||||
|
||||
// Top space
|
||||
uint _TopSpace;
|
||||
|
||||
// Indent
|
||||
uint _Indent; // Left margin
|
||||
sint _FirstViewIndentView; // Additionnal left margin for the first view
|
||||
|
||||
// A link structure
|
||||
class CLink
|
||||
{
|
||||
public:
|
||||
|
||||
CLink(CViewLink *link);
|
||||
|
||||
// The link view
|
||||
CViewLink *Link;
|
||||
|
||||
// The three control button
|
||||
CCtrlLink *CtrlLink[3];
|
||||
};
|
||||
|
||||
// The links
|
||||
std::vector<CLink> _Links;
|
||||
|
||||
// The HTML group used
|
||||
CInterfaceElement *_BrowseGroup;
|
||||
|
||||
private:
|
||||
std::string _HardText;
|
||||
uint32 _TextId;
|
||||
|
||||
void setupSizes();
|
||||
void onTextChanged();
|
||||
|
||||
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
|
||||
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_PARAGRAPH_H
|
||||
|
||||
/* End of group_paragraph.h */
|
||||
|
||||
|
90
code/nel/include/nel/gui/group_scrolltext.h
Normal file
90
code/nel/include/nel/gui/group_scrolltext.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
// 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 CL_GROUP_SCROLLTEXT_H
|
||||
#define CL_GROUP_SCROLLTEXT_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBaseButton;
|
||||
class CCtrlScroll;
|
||||
class CGroupList;
|
||||
|
||||
// Can be used to build a chat window or anything that displays sequences of strings
|
||||
/**
|
||||
* Widget to have a resizable scrolltext and its scrollbar
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CGroupScrollText : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CGroupScrollText(const TCtorParam ¶m);
|
||||
~CGroupScrollText();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// CInterfaceGroup Interface
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords ();
|
||||
virtual void checkCoords ();
|
||||
virtual void draw ();
|
||||
virtual void clearViews ();
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
|
||||
|
||||
// get the list associated to this group
|
||||
CGroupList *getList() const { return _List; }
|
||||
|
||||
// Get the scroll bar
|
||||
CCtrlScroll *getScrollBar() const { return _ScrollBar; }
|
||||
|
||||
// from CCtrlBase
|
||||
virtual void elementCaptured(CCtrlBase *capturedElement);
|
||||
|
||||
|
||||
REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
private:
|
||||
CGroupList *_List;
|
||||
CCtrlScroll *_ScrollBar;
|
||||
CCtrlBaseButton *_ButtonAdd;
|
||||
CCtrlBaseButton *_ButtonSub;
|
||||
bool _Settuped;
|
||||
bool _InvertScrollBar;
|
||||
sint32 _ListHeight;
|
||||
protected:
|
||||
void setup();
|
||||
void updateScrollBar();
|
||||
public:
|
||||
// private use for action handlers
|
||||
sint32 _StartHeight;
|
||||
sint64 _EllapsedTime;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
48
code/nel/include/nel/gui/group_submenu_base.h
Normal file
48
code/nel/include/nel/gui/group_submenu_base.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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 GROUP_SUBMENU_BASE
|
||||
#define GROUP_SUBMENU_BASE
|
||||
|
||||
#include "nel/gui/group_frame.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CGroupSubMenuBase : public CGroupFrame
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CGroupSubMenuBase )
|
||||
|
||||
CGroupSubMenuBase( const TCtorParam ¶m );
|
||||
~CGroupSubMenuBase();
|
||||
|
||||
virtual void openSubMenu( sint32 nb );
|
||||
virtual void hideSubMenus();
|
||||
|
||||
REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame )
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
188
code/nel/include/nel/gui/group_tab.h
Normal file
188
code/nel/include/nel/gui/group_tab.h
Normal file
|
@ -0,0 +1,188 @@
|
|||
// 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 NL_GROUP_TAB_H
|
||||
#define NL_GROUP_TAB_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/ctrl_text_button.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlTabButton;
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Group handling Ctrl Tab, to easily simulate Tab ctrl.
|
||||
* NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order:
|
||||
* - in this group
|
||||
* - in the parent group
|
||||
* - in global
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CGroupTab : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CGroupTab(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords ();
|
||||
|
||||
// select the ctrl tab. -1 will invalidate all.
|
||||
void select(sint index);
|
||||
sint getSelection() const;
|
||||
|
||||
// select with a CCtrlTabButton ptr
|
||||
void selectFromCtrl(CCtrlTabButton *button);
|
||||
|
||||
// select a default activated tab, if the current is a special ctrlTab
|
||||
void selectDefault(CCtrlTabButton *ifSelectionIs);
|
||||
|
||||
// select a default activated tab, if the current is hid
|
||||
void selectDefaultIfCurrentHid();
|
||||
|
||||
// add new tab
|
||||
void addTab(CCtrlTabButton *tabB);
|
||||
void addTab(CCtrlTabButton *tabB, sint index);
|
||||
int luaAddTab(CLuaState &ls);
|
||||
int luaAddTabWithOrder(CLuaState &ls);
|
||||
|
||||
// remove selected tab
|
||||
void removeTab(sint index);
|
||||
int luaRemoveTab(CLuaState &ls);
|
||||
|
||||
// remove all tabs
|
||||
void removeAll();
|
||||
int luaRemoveAll(CLuaState &ls);
|
||||
|
||||
// tab number
|
||||
void setTabButtonNb(sint32 /* val */){}
|
||||
sint32 getTabButtonNb() const {return (sint32)_Buttons.size();}
|
||||
|
||||
// selection index
|
||||
void setIndexSelection(sint32 val){select((sint)val);}
|
||||
sint32 getIndexSelection() const {return (sint32)_NextSelection;}
|
||||
|
||||
// selection index
|
||||
void setAssociatedGroupSelection(const std::string & /* assG */){}
|
||||
std::string getAssociatedGroupSelection() const;
|
||||
|
||||
// get group from index
|
||||
CInterfaceGroup* getGroup(sint index);
|
||||
int luaGetGroup(CLuaState &ls);
|
||||
|
||||
// get tab from index
|
||||
CCtrlTabButton* getTabButton(sint index);
|
||||
int luaGetTabButton(CLuaState &ls);
|
||||
|
||||
// first showed tab button
|
||||
sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;}
|
||||
|
||||
// last showed tab button
|
||||
sint32 getLastTabButton() const {return (sint32)_LastTabIndex;}
|
||||
|
||||
// update showed tab buttons on function of GroupTab width
|
||||
void updateFirstTabButton();
|
||||
int luaShowTabButton(CLuaState &ls);
|
||||
|
||||
void dummySet(sint32 /* value */){}
|
||||
|
||||
REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup)
|
||||
REFLECT_LUA_METHOD("addTab", luaAddTab)
|
||||
REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder)
|
||||
REFLECT_LUA_METHOD("removeTab", luaRemoveTab)
|
||||
REFLECT_LUA_METHOD("removeAll", luaRemoveAll)
|
||||
REFLECT_LUA_METHOD("getGroup", luaGetGroup)
|
||||
REFLECT_LUA_METHOD("getTabButton", luaGetTabButton)
|
||||
REFLECT_LUA_METHOD("showTabButton", luaShowTabButton)
|
||||
REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb)
|
||||
REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection)
|
||||
REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet)
|
||||
REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet)
|
||||
REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection)
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
private:
|
||||
|
||||
std::vector<CCtrlTabButton*> _Buttons; // can't be NULL.
|
||||
std::vector<CInterfaceGroup*> _Groups; // may be NULL
|
||||
sint _Selection;
|
||||
sint _NextSelection;
|
||||
sint _BaseRenderLayer;
|
||||
bool _Setuped;
|
||||
bool _HideOutTabs;
|
||||
sint _FirstTabIndex;
|
||||
sint _LastTabIndex;
|
||||
|
||||
std::string _AHOnChange;
|
||||
std::string _ParamsOnChange;
|
||||
|
||||
void setup();
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Used with CGroupTab
|
||||
*/
|
||||
class CCtrlTabButton : public CCtrlTextButton
|
||||
{
|
||||
public:
|
||||
|
||||
CCtrlTabButton(const TCtorParam ¶m);
|
||||
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
virtual void setActive(bool state);
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
void setBlink (bool b);
|
||||
|
||||
std::string _AssociatedGroup;
|
||||
IActionHandler *_AHOnLeftClick2;
|
||||
|
||||
private:
|
||||
|
||||
sint32 _DefaultX;
|
||||
bool _Blinking;
|
||||
NLMISC::CRGBA _TextColorNormalBlink;
|
||||
bool _TextModulateGlobalColorNormalBlink;
|
||||
sint64 _BlinkDate;
|
||||
bool _BlinkState;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_TAB_H
|
||||
|
||||
/* End of group_tab.h */
|
224
code/nel/include/nel/gui/group_table.h
Normal file
224
code/nel/include/nel/gui/group_table.h
Normal file
|
@ -0,0 +1,224 @@
|
|||
// 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 NL_GROUP_TABLE_H
|
||||
#define NL_GROUP_TABLE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/group_frame.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* This group is used to simulate HTML cells.
|
||||
* They have specific parameters to be aligned like HTML cells.
|
||||
* (Percent of the table size
|
||||
*/
|
||||
class CGroupCell: public CInterfaceGroup
|
||||
{
|
||||
friend class CGroupTable;
|
||||
public:
|
||||
CGroupCell(const TCtorParam ¶m);
|
||||
|
||||
enum TAlign
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
};
|
||||
|
||||
enum TVAlign
|
||||
{
|
||||
Top,
|
||||
Middle,
|
||||
Bottom
|
||||
};
|
||||
|
||||
/// \from CInterfaceElement
|
||||
virtual void draw();
|
||||
virtual sint32 getMaxUsedW() const;
|
||||
virtual sint32 getMinUsedW() const;
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// to be called by CGroupTable
|
||||
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);
|
||||
|
||||
// If the cell is a new line. This is the first <td> after a <tr>
|
||||
bool NewLine;
|
||||
bool IgnoreMaxWidth;
|
||||
bool IgnoreMinWidth;
|
||||
bool AddChildW;
|
||||
|
||||
// The table width cell ratio. This is the <td width="50%"> parameter
|
||||
float TableRatio;
|
||||
|
||||
// The Width you want in pixel. This is the <td width="100"> parameter
|
||||
sint32 WidthWanted;
|
||||
|
||||
|
||||
// The min height of the cell
|
||||
sint32 Height;
|
||||
|
||||
// Memorize max width
|
||||
sint32 WidthMax;
|
||||
|
||||
// The cell color
|
||||
NLMISC::CRGBA BgColor;
|
||||
|
||||
// Texture
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
bool _UserTexture;
|
||||
bool _TextureTiled;
|
||||
bool _TextureScaled;
|
||||
|
||||
// Alignment
|
||||
TAlign Align;
|
||||
TVAlign VAlign;
|
||||
sint32 LeftMargin;
|
||||
|
||||
// The cell group
|
||||
CInterfaceGroup *Group;
|
||||
|
||||
// The cell is nowrap
|
||||
bool NoWrap;
|
||||
|
||||
void setTexture(const std::string & TxName);
|
||||
void setTextureTile(bool tiled);
|
||||
void setTextureScale(bool scaled);
|
||||
|
||||
static void setDebugUICell( bool d ){ DebugUICell = d; }
|
||||
static bool getDebugUICell(){ return DebugUICell; }
|
||||
|
||||
private:
|
||||
void setEnclosedGroupDefaultParams();
|
||||
static bool DebugUICell;
|
||||
};
|
||||
|
||||
/**
|
||||
* This group is used to simulate HTML table. Support "percent of the parent width" sizeRef mode.
|
||||
*/
|
||||
class CGroupTable : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
|
||||
///constructor
|
||||
CGroupTable(const TCtorParam ¶m);
|
||||
|
||||
// dtor
|
||||
~CGroupTable();
|
||||
|
||||
// Add a cell in the table
|
||||
void addChild (CGroupCell* child);
|
||||
|
||||
// The ratio you want [0 ~1]. This is the <table width="50%"> parameter
|
||||
float TableRatio;
|
||||
|
||||
// The Width you want in pixel. This is the <table width="100"> parameter
|
||||
sint32 ForceWidthMin;
|
||||
|
||||
// Table borders
|
||||
sint32 Border;
|
||||
sint32 CellPadding;
|
||||
sint32 CellSpacing;
|
||||
|
||||
// The table color
|
||||
NLMISC::CRGBA BgColor;
|
||||
uint8 CurrentAlpha;
|
||||
|
||||
bool ContinuousUpdate;
|
||||
|
||||
std::string getProperties( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
protected:
|
||||
|
||||
/// \from CInterfaceElement
|
||||
void onInvalidateContent();
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
void draw ();
|
||||
|
||||
/**
|
||||
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
|
||||
*/
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual void checkCoords();
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
|
||||
// Content validated
|
||||
bool _ContentValidated;
|
||||
|
||||
// Last parent width
|
||||
sint32 _LastParentW;
|
||||
|
||||
// Children
|
||||
std::vector<CGroupCell *> _Cells;
|
||||
|
||||
// Table column
|
||||
class CColumn
|
||||
{
|
||||
public:
|
||||
CColumn()
|
||||
{
|
||||
Width = 0;
|
||||
WidthMax = 0;
|
||||
WidthWanted = 0;
|
||||
TableRatio = 0;
|
||||
Height = 0;
|
||||
}
|
||||
sint32 Width;
|
||||
sint32 Height;
|
||||
sint32 WidthWanted;
|
||||
sint32 WidthMax;
|
||||
float TableRatio;
|
||||
};
|
||||
|
||||
// Table row
|
||||
class CRow
|
||||
{
|
||||
public:
|
||||
CRow()
|
||||
{
|
||||
Height = 0;
|
||||
}
|
||||
sint32 Height;
|
||||
};
|
||||
|
||||
// Column table
|
||||
std::vector<CColumn> _Columns;
|
||||
|
||||
// Column table
|
||||
std::vector<CRow> _Rows;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_GROUP_TABLE_H
|
||||
|
||||
/* End of group_table.h */
|
||||
|
||||
|
381
code/nel/include/nel/gui/group_tree.h
Normal file
381
code/nel/include/nel/gui/group_tree.h
Normal file
|
@ -0,0 +1,381 @@
|
|||
// 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 NL_GROUP_TREE_H
|
||||
#define NL_GROUP_TREE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/group_frame.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CViewText;
|
||||
class CViewBitmap;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class CGroupTree : public CInterfaceGroup
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
struct SNode;
|
||||
// optional callback that is called when a node has been added
|
||||
struct INodeAddedCallback
|
||||
{
|
||||
/** A node has just been added in the CGroupTree object
|
||||
* \param node The logic node from which the ui node was built
|
||||
* \param interfaceElement The ui node that was built
|
||||
*/
|
||||
virtual void nodeAdded(SNode *node, CInterfaceElement *interfaceElement) = 0;
|
||||
};
|
||||
|
||||
// Logic structure to initialize the group tree (root node is not displayed and is always opened)
|
||||
struct SNode : public CReflectableRefPtrTarget
|
||||
{
|
||||
typedef NLMISC::CRefPtr<SNode> TRefPtr;
|
||||
// Common
|
||||
std::string Id; // If not present auto-generated
|
||||
bool Opened;
|
||||
bool DisplayText; // If false instanciate a template
|
||||
bool Show; // If false, the node is not displayed (true default, Root ignored)
|
||||
sint32 YDecal;
|
||||
// Text
|
||||
ucstring Text; // Internationalized displayed text
|
||||
sint32 FontSize; // If -1 (default), then take the groupTree one
|
||||
NLMISC::CRGBA Color;
|
||||
// Template
|
||||
NLMISC::CSmartPtr<CInterfaceGroup> Template;
|
||||
// Actions Handlers (for left button)
|
||||
std::string AHName;
|
||||
std::string AHCond;
|
||||
std::string AHParams;
|
||||
// Actions Handlers (for right button)
|
||||
std::string AHNameRight;
|
||||
std::string AHParamsRight;
|
||||
// Actions Handlers (close/open node)
|
||||
std::string AHNameClose;
|
||||
std::string AHParamsClose;
|
||||
// bitmap at this level of hierarchy
|
||||
std::string Bitmap; // additionnal bitmap
|
||||
// Hierarchy
|
||||
std::vector<SNode*> Children;
|
||||
SNode *Father;
|
||||
// updated at display
|
||||
SNode *LastVisibleSon; // filled at build time, meaningfull only if son is shown and opened, undefined otherwise
|
||||
// Node added callback
|
||||
INodeAddedCallback *NodeAddedCallback;
|
||||
//
|
||||
CGroupTree *ParentTree;
|
||||
// ----------------------------
|
||||
SNode();
|
||||
~SNode();
|
||||
void updateLastVisibleSon();
|
||||
void detachChild(SNode *pNode);
|
||||
void deleteChild(SNode *pNode);
|
||||
void addChild (SNode *pNode);
|
||||
bool isChild(SNode *pNode) const;
|
||||
void addChildFront (SNode *pNode);
|
||||
void addChildAtIndex (SNode *pNode, sint index);
|
||||
void addChildSorted(SNode *pNode);
|
||||
void addChildSortedByBitmap(SNode *pNode);
|
||||
void setParentTree(CGroupTree *parent);
|
||||
void setFather(SNode *father);
|
||||
void closeAll();
|
||||
void makeOrphan();
|
||||
bool parse (xmlNodePtr cur, CGroupTree *parentGroup);
|
||||
uint getNumBitmap() const { return Bitmap.empty() ? 0 : 1; }
|
||||
SNode *getNodeFromId(const std::string &id);
|
||||
|
||||
// accessors
|
||||
void setBitmap(const std::string &bitmap) { Bitmap = bitmap; }
|
||||
std::string getBitmap() const { return Bitmap; }
|
||||
void setOpened(bool opened) { Opened = opened; }
|
||||
bool getOpened() const { return Opened; }
|
||||
void setText(const ucstring &text) { Text = text; }
|
||||
const ucstring& getText() const { return Text; }
|
||||
sint32 getFontSize() const { return FontSize; }
|
||||
void setFontSize(sint32 value) { FontSize = value; }
|
||||
sint32 getYDecal() const { return YDecal; }
|
||||
void setYDecal(sint32 value) { YDecal = value; }
|
||||
|
||||
|
||||
std::string getId() const { return Id; }
|
||||
void setId(const std::string &value) { Id = value; }
|
||||
bool getShow() const { return Show; }
|
||||
void setShow(bool value) { Show = value; }
|
||||
std::string getAHName() const { return AHName; }
|
||||
void setAHName(const std::string &value) { AHName = value; }
|
||||
std::string getAHCond() const { return AHCond; }
|
||||
void setAHCond(const std::string &value) { AHCond = value; }
|
||||
std::string getAHParams() const { return AHParams; }
|
||||
void setAHParams(const std::string &value) { AHParams = value; }
|
||||
std::string getAHNameRight() const { return AHNameRight; }
|
||||
void setAHNameRight(const std::string &value) { AHNameRight = value; }
|
||||
std::string getAHParamsRight() const { return AHParamsRight; }
|
||||
void setAHParamsRight(const std::string &value) { AHParamsRight = value; }
|
||||
std::string getAHNameClose() const { return AHNameClose; }
|
||||
void setAHNameClose(const std::string &value) { AHNameClose = value; }
|
||||
std::string getAHParamsClose() const { return AHParamsClose; }
|
||||
void setAHParamsClose(const std::string &value) { AHParamsClose = value; }
|
||||
NLMISC::CRGBA getColor() const { return Color; }
|
||||
void setColor(NLMISC::CRGBA color) { Color = color; }
|
||||
// sort branch & sons alphabetically
|
||||
void sort();
|
||||
// sort branch & sons alphabetically & by bitmap name (blank bitmap being the first)
|
||||
void sortByBitmap();
|
||||
|
||||
// lua bindings
|
||||
int luaGetNumChildren(CLuaState &ls);
|
||||
int luaGetChild(CLuaState &ls);
|
||||
int luaDetachChild(CLuaState &ls);
|
||||
int luaDeleteChild(CLuaState &ls);
|
||||
int luaAddChild(CLuaState &ls);
|
||||
int luaAddChildSorted(CLuaState &ls);
|
||||
int luaAddChildSortedByBitmap(CLuaState &ls);
|
||||
int luaIsChild(CLuaState &ls);
|
||||
int luaAddChildFront (CLuaState &ls);
|
||||
int luaAddChildAtIndex (CLuaState &ls);
|
||||
int luaCloseAll(CLuaState &ls);
|
||||
int luaGetFather(CLuaState &ls);
|
||||
int luaSort(CLuaState &ls);
|
||||
int luaSortByBitmap(CLuaState &ls);
|
||||
int luaGetNodeFromId(CLuaState &ls);
|
||||
int luaGetParentTree(CLuaState &ls);
|
||||
|
||||
// get node from first parameter on lua stack and throw necessary exception if not present
|
||||
static SNode *luaGetNodeOnStack(CLuaState &ls, const char *funcName);
|
||||
|
||||
REFLECT_EXPORT_START(CGroupTree::SNode, CReflectable)
|
||||
REFLECT_STRING("Id", getId, setId);
|
||||
REFLECT_STRING("Bitmap", getBitmap, setBitmap);
|
||||
REFLECT_SINT32("FontSize", getFontSize, setFontSize);
|
||||
REFLECT_SINT32("YDecal", getYDecal, setYDecal);
|
||||
REFLECT_STRING("AHName", getAHName, setAHName);
|
||||
REFLECT_STRING("AHCond", getAHCond, setAHCond);
|
||||
REFLECT_RGBA("Color", getColor, setColor);
|
||||
REFLECT_STRING("AHParams", getAHParams, setAHParams);
|
||||
REFLECT_STRING("AHNameRight", getAHNameRight, setAHNameRight);
|
||||
REFLECT_STRING("AHParamsRight", getAHParamsRight, setAHParamsRight);
|
||||
REFLECT_STRING("AHNameClose", getAHNameClose, setAHNameClose);
|
||||
REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose);
|
||||
REFLECT_BOOL("Opened", getOpened, setOpened);
|
||||
REFLECT_BOOL("Show", getShow, setShow);
|
||||
REFLECT_UCSTRING("Text", getText, setText);
|
||||
// lua
|
||||
REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren);
|
||||
REFLECT_LUA_METHOD("getChild", luaGetChild);
|
||||
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
|
||||
REFLECT_LUA_METHOD("deleteChild", luaDeleteChild);
|
||||
REFLECT_LUA_METHOD("addChild", luaAddChild);
|
||||
REFLECT_LUA_METHOD("addChildSorted", luaAddChildSorted);
|
||||
REFLECT_LUA_METHOD("addChildSortedByBitmap", luaAddChildSortedByBitmap);
|
||||
REFLECT_LUA_METHOD("addChildFront", luaAddChildFront);
|
||||
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
|
||||
REFLECT_LUA_METHOD("isChild", luaIsChild);
|
||||
REFLECT_LUA_METHOD("closeAll", luaCloseAll);
|
||||
REFLECT_LUA_METHOD("getFather", luaGetFather);
|
||||
REFLECT_LUA_METHOD("sort", luaSort);
|
||||
REFLECT_LUA_METHOD("sortByBitmap", luaSortByBitmap);
|
||||
REFLECT_LUA_METHOD("getNodeFromId", luaGetNodeFromId);
|
||||
REFLECT_LUA_METHOD("getParentTree", luaGetParentTree);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
///constructor
|
||||
CGroupTree(const TCtorParam ¶m);
|
||||
|
||||
// dtor
|
||||
virtual ~CGroupTree();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
|
||||
virtual void checkCoords();
|
||||
|
||||
virtual void updateCoords();
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
|
||||
|
||||
void reset();
|
||||
|
||||
// force rebuild the tree at next updateCoords()
|
||||
void forceRebuild();
|
||||
|
||||
// For SNode
|
||||
sint32 getIdNumber() { _IdGenerator++; return _IdGenerator; }
|
||||
sint32 getFontSize() { return _FontSize; }
|
||||
sint32 getYDecal() { return _YDecal; }
|
||||
|
||||
// Set root node and delete the last one the user must not delete all allocated sub node. Nb: selection is reseted
|
||||
void setRootNode (SNode *);
|
||||
// Remove all lines bitmaps and templates or texts
|
||||
void removeAll();
|
||||
|
||||
// unselect current node in tree
|
||||
void unselect();
|
||||
|
||||
// Select a node by its line index (depends on opened nodes). no-op if not possible (AH not here, line>size)
|
||||
void selectLine(uint line, bool runAH = true);
|
||||
// simulate right button click on the given line (this also select the line)
|
||||
bool rightButton(uint line);
|
||||
|
||||
// Get the Selected Node Id. empty if none selected
|
||||
const std::string &getSelectedNodeId() const;
|
||||
|
||||
// Select by the node Id. return false if not found (selection is not reseted)
|
||||
// NB: if the node was already selected, no-op (no action handler launched)
|
||||
bool selectNodeById(const std::string &nodeId, bool triggerAH = true);
|
||||
|
||||
// Get the root node (Opened State represent the current state)
|
||||
SNode *getRootNode () const {return _RootNode;}
|
||||
|
||||
// get current SNode under the mouse (possibly NULL)
|
||||
SNode *getNodeUnderMouse() const;
|
||||
|
||||
// Get/Change the NavigateOneBrnahc option. if false, then perform a reset before
|
||||
bool getNavigateOneBranch() const {return _NavigateOneBranch;}
|
||||
void changeNavigateOneBranch(bool newState);
|
||||
|
||||
// should be called by action handler when thy want to cancel the selection of the line that triggered them
|
||||
void cancelNextSelectLine();
|
||||
|
||||
// Get selected node
|
||||
SNode * getSelectedNode() { return _SelectedNode;}
|
||||
|
||||
// lua bindings
|
||||
int luaGetRootNode(CLuaState &ls);
|
||||
int luaSetRootNode(CLuaState &ls);
|
||||
int luaForceRebuild(CLuaState &ls);
|
||||
int luaSelectNodeById(CLuaState &ls);
|
||||
int luaGetSelectedNodeId(CLuaState &ls);
|
||||
int luaSelectLine(CLuaState &ls);
|
||||
int luaUnselect(CLuaState &ls);
|
||||
int luaGetNodeUnderMouse(CLuaState &ls);
|
||||
int luaCancelNextSelectLine(CLuaState &ls);
|
||||
|
||||
// Reflection
|
||||
REFLECT_EXPORT_START(CGroupTree, CInterfaceGroup)
|
||||
REFLECT_BOOL ("navigate_one_branch", getNavigateOneBranch, changeNavigateOneBranch);
|
||||
REFLECT_LUA_METHOD("getRootNode", luaGetRootNode);
|
||||
REFLECT_LUA_METHOD("setRootNode", luaSetRootNode);
|
||||
REFLECT_LUA_METHOD("forceRebuild", luaForceRebuild);
|
||||
REFLECT_LUA_METHOD("getSelectedNodeId", luaGetSelectedNodeId);
|
||||
REFLECT_LUA_METHOD("selectNodeById", luaSelectNodeById);
|
||||
REFLECT_LUA_METHOD("selectLine", luaSelectLine);
|
||||
REFLECT_LUA_METHOD("unselect", luaUnselect);
|
||||
REFLECT_LUA_METHOD("getNodeUnderMouse", luaGetNodeUnderMouse);
|
||||
REFLECT_LUA_METHOD("cancelNextSelectLine", luaCancelNextSelectLine);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
private:
|
||||
|
||||
void setupArbo();
|
||||
sint32 _BmpW, _BmpH, _FontSize, _YDecal;
|
||||
sint32 _XExtend;
|
||||
|
||||
private:
|
||||
|
||||
// Display structure
|
||||
struct SLine
|
||||
{
|
||||
CViewBase *TextOrTemplate;
|
||||
std::vector<CViewBitmap*> Bmps;
|
||||
SNode::TRefPtr Node;
|
||||
uint8 Depth;
|
||||
|
||||
SLine()
|
||||
{
|
||||
TextOrTemplate = NULL;
|
||||
}
|
||||
|
||||
~SLine()
|
||||
{
|
||||
Bmps.clear();
|
||||
}
|
||||
uint getNumAdditionnalBitmap() const;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
void rebuild();
|
||||
void addTextLine (uint8 nDepth, SNode *pNode);
|
||||
void addHierarchyBitmaps();
|
||||
|
||||
SNode *selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId);
|
||||
|
||||
SNode *_RootNode;
|
||||
sint32 _IdGenerator;
|
||||
bool _MustRebuild;
|
||||
std::vector<SLine> _Lines;
|
||||
sint32 _OverLine;
|
||||
NLMISC::CRGBA _OverColor;
|
||||
NLMISC::CRGBA _OverColorBack;
|
||||
SNode *_SelectedNode;
|
||||
sint32 _SelectedLine;
|
||||
NLMISC::CRGBA _SelectedColor;
|
||||
|
||||
// If a node is closed and a son of this node was selected, then this option force the ancestor being the new selection
|
||||
bool _SelectAncestorOnClose;
|
||||
bool _NavigateOneBranch;
|
||||
bool _AvoidSelectNodeByIdIR;
|
||||
|
||||
// when an action handler is run, it can call 'cancelSelectLine' if no selection should be done for real
|
||||
bool _CancelNextSelectLine;
|
||||
|
||||
|
||||
// Bitmap For arbo
|
||||
std::string _ArboOpenFirst;
|
||||
std::string _ArboCloseJustOne;
|
||||
std::string _ArboSonWithoutSon;
|
||||
std::string _ArboSonLast;
|
||||
std::string _ArboSon;
|
||||
std::string _ArboLevel;
|
||||
std::string _ArboXExtend;
|
||||
|
||||
// Special rectangle
|
||||
bool _RectangleOutlineMode;
|
||||
sint32 _RectangleX, _RectangleY;
|
||||
sint32 _RectangleW, _RectangleH;
|
||||
sint32 _RectangleDeltaRL;
|
||||
|
||||
sint32 getHrcIconXStart(sint32 depth);
|
||||
sint32 getHrcIconXEnd(sint32 depth);
|
||||
|
||||
void drawSelection(sint x, sint y, sint w, NLMISC::CRGBA col);
|
||||
|
||||
CViewBitmap *createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // NL_GROUP_TREE_H
|
||||
|
||||
/* End of group_tree.h */
|
||||
|
||||
|
50
code/nel/include/nel/gui/group_wheel.h
Normal file
50
code/nel/include/nel/gui/group_wheel.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
// 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 RZ_GROUP_CONTAINER_H
|
||||
#define RZ_GROUP_CONTAINER_H
|
||||
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// Special group to handle the mouse wheel message
|
||||
class CInterfaceGroupWheel : public CInterfaceGroup
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
CInterfaceGroupWheel(const TCtorParam ¶m);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// Coming from CInterfaceElement
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
private:
|
||||
IActionHandler *_AHWheelUp;
|
||||
CStringShared _AHWheelUpParams;
|
||||
IActionHandler *_AHWheelDown;
|
||||
CStringShared _AHWheelDownParams;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
36
code/nel/include/nel/gui/input_event_listener.h
Normal file
36
code/nel/include/nel/gui/input_event_listener.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
// 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 INPUTEVENTLISTENER_H
|
||||
#define INPUTEVENTLISTENER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/event_descriptor.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
/**
|
||||
@brief Interface for accepting GUI input events.
|
||||
*/
|
||||
class IInputEventListener
|
||||
{
|
||||
public:
|
||||
virtual ~IInputEventListener(){}
|
||||
virtual bool handleEvent( const CEventDescriptor &eventDesc ) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
57
code/nel/include/nel/gui/input_handler.h
Normal file
57
code/nel/include/nel/gui/input_handler.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
// 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 INPUT_HANDLER_H
|
||||
#define INPUT_HANDLER_H
|
||||
|
||||
#include "nel/misc/events.h"
|
||||
#include "nel/gui/event_descriptor.h"
|
||||
#include "nel/gui/input_event_listener.h"
|
||||
|
||||
namespace NLGUI{
|
||||
|
||||
/**
|
||||
@brief The input event entry point of the GUI library.
|
||||
|
||||
Translates the NEL input events and forwards them.
|
||||
*/
|
||||
class CInputHandler
|
||||
{
|
||||
public:
|
||||
CInputHandler();
|
||||
~CInputHandler();
|
||||
|
||||
bool handleEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleSetFocusEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleKeyboardEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseMoveEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseButtonDownEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseButtonUpEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseDblClickEvent( const NLMISC::CEvent &evnt );
|
||||
bool handleMouseWheelEvent( const NLMISC::CEvent &evnt );
|
||||
|
||||
void setListener( IInputEventListener* listener );
|
||||
|
||||
private:
|
||||
IInputEventListener *listener;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
135
code/nel/include/nel/gui/interface_anim.h
Normal file
135
code/nel/include/nel/gui/interface_anim.h
Normal file
|
@ -0,0 +1,135 @@
|
|||
// 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 RZ_INTERFACE_ANIM_H
|
||||
#define RZ_INTERFACE_ANIM_H
|
||||
|
||||
#include "nel/gui/interface_property.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/interface_link.h"
|
||||
#include "nel/3d/animation_time.h"
|
||||
#include "nel/3d/u_track.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* class managing an animation track
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CInterfaceTrack
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CInterfaceTrack();
|
||||
virtual ~CInterfaceTrack();
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
void update (double currentTime);
|
||||
|
||||
bool isDynamic () { return _Dynamic; }
|
||||
|
||||
void eval(); // Evaluate dynamic keys
|
||||
|
||||
private:
|
||||
|
||||
enum ETrackType
|
||||
{
|
||||
Track_Linear,
|
||||
Track_TCB,
|
||||
Track_Bezier
|
||||
};
|
||||
|
||||
struct SDynKey
|
||||
{
|
||||
std::string Time;
|
||||
std::string Value;
|
||||
std::string InTan;
|
||||
std::string OutTan;
|
||||
std::string Step;
|
||||
std::string Tension;
|
||||
std::string Continuity;
|
||||
std::string Bias;
|
||||
std::string EaseTo;
|
||||
std::string EaseFrom;
|
||||
};
|
||||
|
||||
bool _Dynamic;
|
||||
std::vector<SDynKey> _DynKeys;
|
||||
|
||||
ETrackType _Type;
|
||||
NL3D::UTrackKeyframer *_TrackKeyFramer;
|
||||
std::vector<CInterfaceLink::CTargetInfo> _Targets;
|
||||
};
|
||||
|
||||
/**
|
||||
* class managing an animation of the interface
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CInterfaceAnim
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
CInterfaceAnim();
|
||||
virtual ~CInterfaceAnim();
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
void update();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
bool isFinished() { return _Finished; }
|
||||
bool isDisableButtons() { return _DisableButtons; }
|
||||
|
||||
protected:
|
||||
|
||||
CInterfaceGroup *_Parent;
|
||||
|
||||
// Parsed properties
|
||||
double _Duration;
|
||||
bool _DisableButtons;
|
||||
|
||||
std::string _AHOnFinish;
|
||||
std::string _AHOnFinishParams;
|
||||
|
||||
std::string _Id;
|
||||
|
||||
std::vector<CInterfaceTrack*> _Tracks;
|
||||
|
||||
// Current anim
|
||||
double _CurrentTime;
|
||||
bool _Finished;
|
||||
bool _AnimHasToBeStopped;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_INTERFACE_ANIM_H
|
||||
|
||||
/* End of interface_anim.h */
|
||||
|
||||
|
68
code/nel/include/nel/gui/interface_common.h
Normal file
68
code/nel/include/nel/gui/interface_common.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
// 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 INTERFACE_COMMON_H
|
||||
#define INTERFACE_COMMON_H
|
||||
|
||||
enum WindowsPriority
|
||||
{
|
||||
WIN_PRIORITY_WORLD_SPACE = 0,
|
||||
WIN_PRIORITY_LOWEST = 1,
|
||||
WIN_PRIORITY_LOW = 2,
|
||||
WIN_PRIORITY_NORMAL = 3,
|
||||
WIN_PRIORITY_HIGH = 4,
|
||||
WIN_PRIORITY_HIGHEST = 5,
|
||||
WIN_PRIORITY_MAX = 8
|
||||
};
|
||||
|
||||
enum THotSpot
|
||||
{
|
||||
Hotspot_BL = 36, // 100100,
|
||||
Hotspot_BM = 34, // 100010,
|
||||
Hotspot_BR = 33, // 100001,
|
||||
Hotspot_ML = 20, // 010100,
|
||||
Hotspot_MM = 18, // 010010
|
||||
Hotspot_MR = 17, // 010001
|
||||
Hotspot_TL = 12, // 001100
|
||||
Hotspot_TM = 10, // 001010
|
||||
Hotspot_TR = 9, // 001001
|
||||
Hotspot_xR = 1, // 000001
|
||||
Hotspot_xM = 2, // 000010
|
||||
Hotspot_xL = 4, // 000100
|
||||
Hotspot_Bx = 32, // 100000
|
||||
Hotspot_Mx = 16, // 010000
|
||||
Hotspot_Tx = 8, // 001000
|
||||
Hotspot_TTAuto = 0, // Special For Tooltip PosRef. Auto mode. see CCtrlBase and tooltip info
|
||||
};
|
||||
|
||||
#define DECLARE_UI_CLASS(_class_) \
|
||||
virtual std::string getClassName() {return #_class_;} \
|
||||
static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());}
|
||||
#define REGISTER_UI_CLASS(_class_) \
|
||||
class CRegisterUIClassHelper_##_class_ \
|
||||
{ \
|
||||
public: \
|
||||
CRegisterUIClassHelper_##_class_() \
|
||||
{ \
|
||||
NLMISC::CClassRegistry::init(); \
|
||||
NLMISC::CClassRegistry::registerClass(#_class_, _class_::creator, typeid(_class_).name()); \
|
||||
} \
|
||||
} RegisterUIClassHelper_##_class_;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
637
code/nel/include/nel/gui/interface_element.h
Normal file
637
code/nel/include/nel/gui/interface_element.h
Normal file
|
@ -0,0 +1,637 @@
|
|||
// 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 NL_INTERFACE_ELEMENT_H
|
||||
#define NL_INTERFACE_ELEMENT_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/string_mapper.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/vector.h"
|
||||
#include "nel/gui/interface_property.h"
|
||||
#include "nel/gui/reflect.h"
|
||||
#include "nel/gui/interface_common.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CGroupList;
|
||||
class CInterfaceLink;
|
||||
class CInterfaceElement;
|
||||
class CInterfaceGroup;
|
||||
class CViewBase;
|
||||
class CCtrlBase;
|
||||
class IActionHandler;
|
||||
class CGroupParagraph;
|
||||
|
||||
/**
|
||||
* A visitor to walk a tree of interface elements and apply a teartment on them.
|
||||
*
|
||||
* For each vsited element, visitElement() is called
|
||||
* If the element is a control, then visitCtrl() is called, and then visitElement()
|
||||
* If the element is a view, then visitView() is called, and then visitElement()
|
||||
* If the element is a group, then visitGoup() is called, and then visitElement()
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CInterfaceElementVisitor
|
||||
{
|
||||
public:
|
||||
virtual void visit(CInterfaceElement * /* elem */) {}
|
||||
virtual void visitGroup(CInterfaceGroup * /* group */) {}
|
||||
virtual void visitView(CViewBase * /* view */) {}
|
||||
virtual void visitCtrl(CCtrlBase * /* ctrl */) {}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* class describing a localisable interface element, i.e. : an element with coordinates
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum EStrech
|
||||
{
|
||||
none=0,
|
||||
width=1,
|
||||
height=2
|
||||
};
|
||||
|
||||
/// Constructor
|
||||
CInterfaceElement()
|
||||
{
|
||||
_Parent = NULL;
|
||||
|
||||
_XReal = _YReal = _WReal = _HReal = 0;
|
||||
_X = _Y = _W = _H = 0;
|
||||
//_Snap = 1;
|
||||
|
||||
_PosRef = Hotspot_BL;
|
||||
_ParentPosRef = Hotspot_BL;
|
||||
_ParentPos = NULL;
|
||||
|
||||
_SizeRef = 0;
|
||||
_SizeDivW = 10;
|
||||
_SizeDivH = 10;
|
||||
_ParentSize = NULL;
|
||||
|
||||
_Links = NULL;
|
||||
_Active= true;
|
||||
// default to 3 pass
|
||||
_InvalidCoords= 3;
|
||||
|
||||
_ModulateGlobalColor= true;
|
||||
_RenderLayer= 0;
|
||||
|
||||
_AvoidResizeParent= false;
|
||||
|
||||
editorSelected = false;
|
||||
|
||||
serializable = true;
|
||||
}
|
||||
|
||||
// dtor
|
||||
virtual ~CInterfaceElement();
|
||||
|
||||
/** Cloning
|
||||
* Cloning is actually performed using a serial / unserial in a memory stream
|
||||
* NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only
|
||||
*/
|
||||
virtual CInterfaceElement *clone();
|
||||
|
||||
// help to serialize an action handler
|
||||
static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
|
||||
|
||||
static std::string stripId( const std::string &fullId );
|
||||
|
||||
virtual std::string getProperty( const std::string &name ) const;
|
||||
|
||||
virtual void setProperty( const std::string &name, const std::string &value );
|
||||
|
||||
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// Parse the element and initalize it
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
/// Debug info on memory
|
||||
virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
/// helper: display a parse error with the id of the lement
|
||||
void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL);
|
||||
|
||||
/// Accessors : GET
|
||||
const std::string& getId() const { return _Id; }
|
||||
std::string getShortId() const;
|
||||
std::string getIdByValue() const { return _Id; }
|
||||
|
||||
CInterfaceGroup* getParent() const { return _Parent; }
|
||||
|
||||
CInterfaceElement* getParentPos() const { return _ParentPos; }
|
||||
|
||||
CInterfaceElement* getParentSize() const { return _ParentSize; }
|
||||
|
||||
/// Get the master group of this element (recurs call.
|
||||
CInterfaceElement* getMasterGroup() const;
|
||||
|
||||
// get a possible group container
|
||||
CInterfaceGroup* getParentContainer();
|
||||
|
||||
bool getActive() const { return _Active; }
|
||||
|
||||
sint32 getX() const { return _X; }
|
||||
|
||||
sint32 getY() const { return _Y; }
|
||||
|
||||
sint32 getW() const { return (_Active?_W:0); }
|
||||
sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); }
|
||||
|
||||
sint32 getH() const { return (_Active?_H:0); }
|
||||
sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); }
|
||||
|
||||
/**
|
||||
* Get the max width used by the window.
|
||||
*
|
||||
* The view must return the largest width its content can take if it will be resized at maximum.
|
||||
* Typical use : for a CTextView multiline, it returns the size of the whole string.
|
||||
*
|
||||
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
|
||||
*/
|
||||
virtual sint32 getMaxUsedW() const { return INT_MAX; };
|
||||
|
||||
/**
|
||||
* Get the min width used by the window.
|
||||
*
|
||||
* The view must return the smallest width its content can take if it will be resized at minimum.
|
||||
* Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word.
|
||||
*
|
||||
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
|
||||
*/
|
||||
virtual sint32 getMinUsedW() const { return 0; };
|
||||
|
||||
//bool isSnapped() const { return (_Snap>1); }
|
||||
|
||||
//sint32 getSnapping() const { return _Snap; }
|
||||
|
||||
sint32 getXReal() const { return _XReal; }
|
||||
|
||||
sint32 getYReal() const { return _YReal; }
|
||||
|
||||
sint32 getWReal() const { return (_Active?_WReal:0); }
|
||||
|
||||
sint32 getHReal() const { return (_Active?_HReal:0); }
|
||||
|
||||
THotSpot getPosRef () const { return _PosRef; }
|
||||
|
||||
THotSpot getParentPosRef () const { return _ParentPosRef; }
|
||||
|
||||
sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3
|
||||
|
||||
void setSizeRef(sint32 value) { _SizeRef = value; }
|
||||
|
||||
/// Accessors : SET
|
||||
void setId (const std::string &newID) { _Id = newID; }
|
||||
|
||||
inline void setName(const std::string &name) { _Name = name; }
|
||||
inline const std::string& getName() { return _Name; }
|
||||
|
||||
virtual void setIdRecurse(const std::string &newID);
|
||||
|
||||
void setParent (CInterfaceGroup *pIG) { _Parent = pIG; }
|
||||
|
||||
void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; }
|
||||
|
||||
void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; }
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
void setX (sint32 x) { _X = x; }
|
||||
void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); }
|
||||
|
||||
void setY (sint32 y) { _Y = y; }
|
||||
void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); }
|
||||
|
||||
void setW (sint32 w);
|
||||
void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); }
|
||||
|
||||
void setH (sint32 h);
|
||||
void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); }
|
||||
|
||||
void setPosRef (THotSpot hs) { _PosRef = hs; }
|
||||
|
||||
void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; }
|
||||
|
||||
// Get the coordinate of a corner on screen
|
||||
void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot);
|
||||
|
||||
/** Test if the given coordinates are inside this element
|
||||
*/
|
||||
bool isIn(sint x, sint y) const;
|
||||
|
||||
/** Test if the given box intersect the element
|
||||
*/
|
||||
bool isIn(sint x, sint y, uint width, uint height) const;
|
||||
|
||||
/** Test if another interface element intersect this one
|
||||
*/
|
||||
bool isIn(const CInterfaceElement &other) const;
|
||||
|
||||
/**
|
||||
* get the window containing the element
|
||||
* \return NULL if the element is not on the window, otherwise returns a pointer to the window
|
||||
*/
|
||||
CInterfaceGroup* getRootWindow();
|
||||
|
||||
/** get the element Depth, ie the number of parent he has (0 if _Parent==NULL)
|
||||
* \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual)
|
||||
*/
|
||||
uint getParentDepth() const;
|
||||
|
||||
/**
|
||||
* true if the element and all its parents are active (recurs up to the root window)
|
||||
*/
|
||||
bool isActiveThroughParents() const;
|
||||
|
||||
/**
|
||||
* move the element (add dx and dy to its coords)
|
||||
* \param dx : value added to _X
|
||||
* \param dy : value added to _Y
|
||||
*/
|
||||
virtual void move (sint32 dx, sint32 dy);
|
||||
|
||||
//void resizeBR (sint32 sizex, sint32 sizey);
|
||||
//void stopResizeBR();
|
||||
//void startResizeBR();
|
||||
|
||||
// Some tools
|
||||
|
||||
void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
|
||||
const std::string &defVal);
|
||||
void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
|
||||
const std::string &defVal);
|
||||
void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
|
||||
const std::string &defVal);
|
||||
void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
|
||||
const std::string &defVal);
|
||||
|
||||
// Parse tools
|
||||
static std::string HotSpotToString( THotSpot spot );
|
||||
static std::string HotSpotCoupleToString( THotSpot parentPosRef, THotSpot posRef );
|
||||
static THotSpot convertHotSpot (const char *ptr); //
|
||||
static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
|
||||
static NLMISC::CRGBA convertColor (const char *ptr);
|
||||
static bool convertBool (const char *ptr);
|
||||
static NLMISC::CVector convertVector (const char *ptr);
|
||||
/** Convert a value that is in the form like width="50" or width="10%"
|
||||
* if the value is absolute like '50' then 'pixels' is filled, else
|
||||
* the ratio is remapped to the [0, 1] range and is copied in 'ratio'
|
||||
*/
|
||||
static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio);
|
||||
|
||||
// add an interface link to that element (kept in a smart ptr)
|
||||
void addLink(CInterfaceLink *link);
|
||||
|
||||
// remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr)
|
||||
void removeLink(CInterfaceLink *link);
|
||||
|
||||
/** Update all links for this instance and its sons.
|
||||
* Derivers should override this to update their sons.
|
||||
*/
|
||||
virtual void updateAllLinks();
|
||||
|
||||
|
||||
/** This allow to force opening an element. By default it just activate the element.
|
||||
* It allow to have different behaviour on more complex containers
|
||||
*/
|
||||
virtual void forceOpen() { setActive(true); }
|
||||
|
||||
virtual void enableBlink(uint /* numBlinks */ = 0) {}
|
||||
virtual void disableBlink() {}
|
||||
virtual bool getBlink() const { return false; }
|
||||
|
||||
// Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true
|
||||
void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;}
|
||||
bool getModulateGlobalColor() const {return _ModulateGlobalColor;}
|
||||
|
||||
|
||||
void dummySet(sint32 value);
|
||||
void dummySet(const std::string &value);
|
||||
|
||||
// lua methods
|
||||
int luaUpdateCoords(CLuaState &ls);
|
||||
int luaInvalidateCoords(CLuaState &ls);
|
||||
int luaInvalidateContent(CLuaState &ls);
|
||||
int luaCenter(CLuaState &ls);
|
||||
int luaSetPosRef(CLuaState &ls);
|
||||
int luaSetParentPos(CLuaState &ls);
|
||||
|
||||
// set sizeref as a string, like "wh", "wh5" ....
|
||||
void setSizeRef(const std::string &sizeref);
|
||||
std::string getSizeRefAsString() const;
|
||||
std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const;
|
||||
|
||||
// export some properties
|
||||
REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
|
||||
REFLECT_BOOL ("active", getActive, setActive);
|
||||
REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor);
|
||||
REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords);
|
||||
REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords);
|
||||
REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords);
|
||||
REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords);
|
||||
REFLECT_SINT32 ("x_real", getXReal, dummySet);
|
||||
REFLECT_SINT32 ("y_real", getYReal, dummySet);
|
||||
REFLECT_SINT32 ("w_real", getWReal, dummySet);
|
||||
REFLECT_SINT32 ("h_real", getHReal, dummySet);
|
||||
REFLECT_STRING ("id", getIdByValue, dummySet);
|
||||
REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef);
|
||||
REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords);
|
||||
REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords);
|
||||
REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent);
|
||||
REFLECT_LUA_METHOD("center", luaCenter);
|
||||
REFLECT_LUA_METHOD("setPosRef", luaSetPosRef);
|
||||
REFLECT_LUA_METHOD("setParentPos", luaSetParentPos);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
/* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated
|
||||
* Default 3 is needed for:
|
||||
* 1: update _W/_H and _WReal/_HReal according to Sons
|
||||
* 2: update XReal/YReal (eg: according to Scroll offset)
|
||||
*/
|
||||
void invalidateCoords(uint8 numPass= 2);
|
||||
uint8 getInvalidCoords() const {return _InvalidCoords;}
|
||||
|
||||
/* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable).
|
||||
* It invalidates the content of the parent too.
|
||||
*/
|
||||
void invalidateContent();
|
||||
|
||||
/* This call back is called when the content or the content of a child is been invalidated.
|
||||
*/
|
||||
virtual void onInvalidateContent() {}
|
||||
|
||||
// called by interfaceManager for master window only
|
||||
void resetInvalidCoords();
|
||||
|
||||
/// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord)
|
||||
virtual void updateCoords();
|
||||
/// Called each frame before draw to possibly invalidateCoords().
|
||||
virtual void checkCoords();
|
||||
|
||||
/// Test if this element is son of the given element
|
||||
bool isSonOf(const CInterfaceElement *other) const;
|
||||
|
||||
/// Called after first frame initialised
|
||||
virtual void launch () {}
|
||||
|
||||
void setRenderLayer(sint8 rl) {_RenderLayer= rl;}
|
||||
sint8 getRenderLayer() const { return _RenderLayer; }
|
||||
|
||||
void copyOptionFrom(const CInterfaceElement &other);
|
||||
|
||||
// center the element in middle of screen
|
||||
void center();
|
||||
|
||||
// for debug only: draw wired quad to see where groups and hotspots are
|
||||
enum TRenderWired
|
||||
{
|
||||
RenderView,
|
||||
RenderCtrl,
|
||||
RenderGroup
|
||||
};
|
||||
// if uiFilter is not empty, draw a quad only if the element id match
|
||||
virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter);
|
||||
|
||||
void drawHotSpot(THotSpot hs, NLMISC::CRGBA col);
|
||||
|
||||
// Returns 'true' if that element can be downcasted to a view
|
||||
virtual bool isView() const { return false; }
|
||||
|
||||
// Returns 'true' if that element can be downcasted to a ctrl
|
||||
virtual bool isCtrl() const { return false; }
|
||||
|
||||
// Returns 'true' if that element can be downcasted to an interface group
|
||||
virtual bool isGroup() const { return false; }
|
||||
|
||||
|
||||
/** This is called before the config loading begins. This is the place to restore default state for config info.
|
||||
*/
|
||||
virtual void onLoadConfig() {}
|
||||
/** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig
|
||||
* is called.
|
||||
*/
|
||||
virtual bool wantSerialConfig() const { return false; }
|
||||
// Serial config info about that element. This is called only if wantSerialConfig() returns true
|
||||
virtual void serialConfig(NLMISC::IStream &f);
|
||||
|
||||
// visit the node of the ui tree
|
||||
virtual void visit(CInterfaceElementVisitor *visitor);
|
||||
|
||||
/** When user is quitting the interface, this is called. Then the interface config is saved
|
||||
* This is where the element get the opportunity to do some cleanup.
|
||||
*/
|
||||
virtual void onQuit() {}
|
||||
|
||||
/// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add.
|
||||
virtual void onAddToGroup() {}
|
||||
|
||||
/** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so
|
||||
* this function is called on each children elements to move the XReal/Yreal only (with a delta)
|
||||
*/
|
||||
virtual void onFrameUpdateWindowPos(sint dx, sint dy);
|
||||
|
||||
/// if true, InterfaceGroup child resize won't take this element into account
|
||||
bool avoidResizeParent() const {return _AvoidResizeParent;}
|
||||
void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;}
|
||||
|
||||
virtual std::string getClassName()
|
||||
{
|
||||
nlassert(0); // forgot to implement serial & to register the class ?
|
||||
return "";
|
||||
}
|
||||
|
||||
bool isInGroup( CInterfaceGroup *group );
|
||||
|
||||
static void setEditorMode( bool b ){ editorMode = b; }
|
||||
|
||||
void setEditorSelected( bool b ){ editorSelected = b; }
|
||||
bool isEditorSelected() const{ return editorSelected; }
|
||||
|
||||
void setPosParent( const std::string &id );
|
||||
void setSizeParent( const std::string &id );
|
||||
|
||||
void setSerializable( bool b ){ serializable = b; }
|
||||
bool IsSerializable() const{ return serializable; }
|
||||
|
||||
protected:
|
||||
|
||||
bool editorSelected;
|
||||
|
||||
static bool editorMode;
|
||||
|
||||
///the parent
|
||||
CInterfaceGroup* _Parent;
|
||||
|
||||
///the id of the element
|
||||
std::string _Id;
|
||||
|
||||
std::string _Name;
|
||||
|
||||
///is the element active?
|
||||
bool _Active;
|
||||
|
||||
// if 0, don't need updateCoords(), else tell the number of pass needed
|
||||
uint8 _InvalidCoords;
|
||||
|
||||
// Real display coords
|
||||
sint32 _XReal, _YReal, _WReal, _HReal;
|
||||
|
||||
// Relative coords
|
||||
sint32 _X;
|
||||
sint32 _Y;
|
||||
sint32 _W;
|
||||
sint32 _H;
|
||||
|
||||
//sint32 _Snap;
|
||||
|
||||
// position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element
|
||||
// will be placed on the center (middle middle) of the parent window
|
||||
THotSpot _PosRef;
|
||||
THotSpot _ParentPosRef;
|
||||
NLMISC::CRefPtr<CInterfaceElement> _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it
|
||||
|
||||
sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3
|
||||
sint32 _SizeDivW, _SizeDivH;
|
||||
NLMISC::CRefPtr<CInterfaceElement> _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it
|
||||
|
||||
// Friend Class
|
||||
friend class CGroupList;
|
||||
friend class CGroupParagraph;
|
||||
|
||||
// True if must modulate the global color with the view
|
||||
bool _ModulateGlobalColor;
|
||||
// Index of layer to render it.
|
||||
sint8 _RenderLayer;
|
||||
|
||||
// Used for CInterfaceGroup ChildResize feature
|
||||
bool _AvoidResizeParent;
|
||||
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
void parseSizeRef(const char *sizeRef);
|
||||
void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH);
|
||||
|
||||
private:
|
||||
//void snapSize();
|
||||
bool serializable;
|
||||
|
||||
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
|
||||
typedef std::vector<TLinkSmartPtr> TLinkVect;
|
||||
TLinkVect *_Links; // links, or NULL if no link
|
||||
};
|
||||
|
||||
/**
|
||||
* class to compress string usage in the interface
|
||||
* \author Matthieu 'Trap' Besson
|
||||
* \author Nevrax France
|
||||
* \date October 2003
|
||||
*/
|
||||
class CStringShared
|
||||
{
|
||||
|
||||
public:
|
||||
CStringShared()
|
||||
{
|
||||
_Id = NLMISC::CStringMapper::emptyId();
|
||||
}
|
||||
|
||||
const CStringShared& operator=(const std::string &str)
|
||||
{
|
||||
_Id = _UIStringMapper->localMap(str);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const CStringShared& operator=(const CStringShared &str)
|
||||
{
|
||||
_Id = str._Id;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::string &toString() const
|
||||
{
|
||||
return _UIStringMapper->localUnmap(_Id);
|
||||
}
|
||||
|
||||
operator const std::string &() const
|
||||
{
|
||||
return _UIStringMapper->localUnmap(_Id);
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return _Id == NLMISC::CStringMapper::emptyId();
|
||||
}
|
||||
|
||||
static CStringShared emptyString()
|
||||
{
|
||||
return CStringShared();
|
||||
}
|
||||
|
||||
NLMISC::TStringId getStringId() const { return _Id; }
|
||||
|
||||
void serial(NLMISC::IStream &f)
|
||||
{
|
||||
std::string str;
|
||||
if (f.isReading())
|
||||
{
|
||||
f.serial(str);
|
||||
*this = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = this->toString();
|
||||
f.serial(str);
|
||||
}
|
||||
}
|
||||
|
||||
static void createStringMapper();
|
||||
static void deleteStringMapper();
|
||||
|
||||
private:
|
||||
|
||||
NLMISC::TStringId _Id;
|
||||
static NLMISC::CStringMapper *_UIStringMapper;
|
||||
};
|
||||
|
||||
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
|
||||
inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
|
||||
|
||||
|
||||
}
|
||||
|
||||
using namespace NLGUI;
|
||||
|
||||
#endif // NL_INTERFACE_ELEMENT_H
|
||||
|
||||
/* End of interface_element.h */
|
239
code/nel/include/nel/gui/interface_expr.h
Normal file
239
code/nel/include/nel/gui/interface_expr.h
Normal file
|
@ -0,0 +1,239 @@
|
|||
// 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 CL_INTERFACE_EXPR_H
|
||||
#define CL_INTERFACE_EXPR_H
|
||||
|
||||
|
||||
#include "nel/misc/ucstring.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
|
||||
namespace NLMISC{
|
||||
class ICDBNode;
|
||||
class CCDBNodeLeaf;
|
||||
class CCDBNodeBranch;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
struct CInterfaceExprUserType;
|
||||
class CInterfaceExprNode;
|
||||
|
||||
/** a value that can be returned by a CInterfaceExpr instance
|
||||
* It supports basic type;
|
||||
* It can be extended by user defined types
|
||||
*/
|
||||
class CInterfaceExprValue
|
||||
{
|
||||
public:
|
||||
enum TType { Boolean = 0, Integer, Double, String, RGBA, UserType, NoType };
|
||||
public:
|
||||
// default ctor
|
||||
CInterfaceExprValue() : _Type(NoType) {}
|
||||
// copy ctor
|
||||
CInterfaceExprValue(const CInterfaceExprValue &other);
|
||||
// assignment operator
|
||||
CInterfaceExprValue &operator = (const CInterfaceExprValue &other);
|
||||
// dtor
|
||||
~CInterfaceExprValue() { clean(); }
|
||||
|
||||
TType getType() const { return _Type; }
|
||||
// get. Should be used only if the type is valid
|
||||
bool getBool() const;
|
||||
sint64 getInteger() const;
|
||||
double getDouble() const;
|
||||
std::string getString() const;
|
||||
NLMISC::CRGBA getRGBA() const;
|
||||
const ucstring &getUCString() const;
|
||||
CInterfaceExprUserType *getUserType() const;
|
||||
// set
|
||||
void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; }
|
||||
void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
|
||||
void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
|
||||
void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; }
|
||||
void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; }
|
||||
void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
|
||||
void setUserType(CInterfaceExprUserType *value);
|
||||
// reset this object to initial state (no type)
|
||||
void clean();
|
||||
// conversions. They return true if success
|
||||
bool toBool();
|
||||
bool toInteger();
|
||||
bool toDouble();
|
||||
bool toString();
|
||||
bool toType(TType type);
|
||||
bool toRGBA();
|
||||
// test if the value if a bool, double, or integer
|
||||
bool isNumerical() const;
|
||||
/** evaluate a from a string
|
||||
* \param expr : where to start the evaluation
|
||||
* \return the position following the token, or NULL if the parsing failed
|
||||
*/
|
||||
const char *initFromString(const char *expr);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
TType _Type;
|
||||
union
|
||||
{
|
||||
bool _BoolValue;
|
||||
sint64 _IntegerValue;
|
||||
double _DoubleValue;
|
||||
CInterfaceExprUserType *_UserTypeValue;
|
||||
uint32 _RGBAValue;
|
||||
};
|
||||
ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack..
|
||||
private:
|
||||
const char *evalBoolean(const char *expr);
|
||||
const char *evalNumber(const char *expr);
|
||||
const char *evalString(const char *expr);
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for user defined types that are use by the 'CInterfaceExprValue' class
|
||||
* Derivers should include the 'clone' method
|
||||
*
|
||||
* CInterfaceExprValue instances have ownership of this object.
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
struct CInterfaceExprUserType
|
||||
{
|
||||
// cloning method
|
||||
virtual CInterfaceExprUserType *clone() const = 0;
|
||||
// dtor
|
||||
virtual ~CInterfaceExprUserType() {}
|
||||
};
|
||||
|
||||
|
||||
/** Evaluate expressions used in interface.
|
||||
* It can retrieve values from the database.
|
||||
* It can also build a list of database values it depends of.
|
||||
*
|
||||
* An expression can be :
|
||||
*
|
||||
* - a string : 'toto', 'abcd', 'a\nbcd', 'a\\t', the escape sequences are the one of C
|
||||
* - a integer 1, 2, 3
|
||||
* - a double 1.1, 2.2
|
||||
* - a database entry : @ui:interface:toto:truc. If the address is a leaf, it returns the leaf value and put an observer on it. If not a leaf, it returns 0, but put an observer on it.
|
||||
* - a database indirection @db:value[db:index] is replaced by @db:value0 if db:index == 0 for example
|
||||
* - a user function call : fct(expr0, epxr1, ...).
|
||||
*
|
||||
* NB : The lua language has been integrated since then (2005), and should be more suited
|
||||
* for most of the tasks.
|
||||
*
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CInterfaceExpr
|
||||
{
|
||||
public:
|
||||
// list of argument for a function
|
||||
typedef std::vector<CInterfaceExprValue> TArgList;
|
||||
/** prototype of a user callable function
|
||||
* It should return true if the result is meaningful. If not, the rest of the evaluation is stopped
|
||||
*/
|
||||
typedef bool (* TUserFct) (TArgList &args, CInterfaceExprValue &result);
|
||||
public:
|
||||
|
||||
// release memory
|
||||
static void release();
|
||||
|
||||
/** This try to eval the provided expression.
|
||||
* - This returns a result
|
||||
* - This eventually fill a vector with a set of database entries it has dependencies on
|
||||
* \param expr The expression to evaluate
|
||||
* \param result The result value
|
||||
* \param nodes If not NULL, will be filled with the database nodes this expression depends on
|
||||
* Node will only be inserted once, so we end up with a set of node (not ordered)
|
||||
* \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on.
|
||||
*/
|
||||
static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> *nodes = NULL, bool noFctCalls = false);
|
||||
|
||||
/** Build a tree from the given expression so that it can be evaluated quickly.
|
||||
* This is useful for a fixed expression that must be evaluated often
|
||||
*/
|
||||
static CInterfaceExprNode *buildExprTree(const std::string &expr);
|
||||
|
||||
|
||||
/** Register a function that can have several arguments
|
||||
* // NB : this is case sensitive
|
||||
*/
|
||||
static void registerUserFct(const char *name, TUserFct fct);
|
||||
// Simple evaluations
|
||||
static bool evalAsInt(const std::string &expr, sint64 &dest);
|
||||
static bool evalAsDouble(const std::string &expr, double &dest);
|
||||
static bool evalAsBool(const std::string &expr, bool &dest);
|
||||
static bool evalAsString(const std::string &expr, std::string &dest);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
// map of user functions
|
||||
typedef std::map<std::string, TUserFct> TUserFctMap;
|
||||
private:
|
||||
static TUserFctMap *_UserFct;
|
||||
private:
|
||||
/** eval the value of a single expression
|
||||
* \return position to the next valid character
|
||||
*/
|
||||
static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
|
||||
static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
|
||||
static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes);
|
||||
public:
|
||||
static const char *unpackDBentry(const char *expr, std::vector<NLMISC::ICDBNode *> *nodes, std::string &dest, bool *hasIndirections = NULL);
|
||||
|
||||
/** Build tree of a single expression
|
||||
* \return position to the next valid character
|
||||
*/
|
||||
private:
|
||||
static const char *buildExprTree(const char *expr, CInterfaceExprNode *&result);
|
||||
static const char *buildFctNode(const char *expr, CInterfaceExprNode *&result);
|
||||
static const char *buildDBEntryNode(const char *expr,CInterfaceExprNode *&result);
|
||||
};
|
||||
|
||||
|
||||
// helper macro to register user functions at startup
|
||||
#define REGISTER_INTERFACE_USER_FCT(name, fct) \
|
||||
const struct __InterUserFctRegister__##fct\
|
||||
{\
|
||||
__InterUserFctRegister__##fct() { CInterfaceExpr::registerUserFct(name, fct); }\
|
||||
} __InterUserFctRegisterInstance__##fct;
|
||||
|
||||
|
||||
// helper macro to declare a user function
|
||||
// the code must follow
|
||||
// arguments are available in 'args', result should be put in 'result'
|
||||
#define DECLARE_INTERFACE_USER_FCT(name) \
|
||||
bool name(CInterfaceExpr::TArgList &args, CInterfaceExprValue &result)
|
||||
|
||||
|
||||
// helper macro to declare a C constant mirroring
|
||||
#define DECLARE_INTERFACE_CONSTANT(_name, _cconst) \
|
||||
static DECLARE_INTERFACE_USER_FCT(_name) \
|
||||
{ \
|
||||
result.setInteger(_cconst); \
|
||||
return true; \
|
||||
} \
|
||||
REGISTER_INTERFACE_USER_FCT(#_name, _name)
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
118
code/nel/include/nel/gui/interface_expr_node.h
Normal file
118
code/nel/include/nel/gui/interface_expr_node.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
// 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 CL_INTERFACE_EXPR_NODE_H
|
||||
#define CL_INTERFACE_EXPR_NODE_H
|
||||
|
||||
#include "interface_expr.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Base node of an interface expression parse tree
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
virtual ~CInterfaceExprNode() {}
|
||||
// eval result of expression, and eventually get the nodes the epression depends on
|
||||
virtual void eval(CInterfaceExprValue &result) = 0;
|
||||
// The same, but get db nodes the expression depends on (appended to vector)
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes) = 0;
|
||||
// Get dependencies of the node (appended to vector)
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes) = 0;
|
||||
};
|
||||
|
||||
|
||||
// *******************************************************************************************************
|
||||
/** A constant value already parsed by interface (in a interface expr parse tree)
|
||||
*/
|
||||
class CInterfaceExprNodeValue : public CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
CInterfaceExprValue Value;
|
||||
public:
|
||||
virtual void eval(CInterfaceExprValue &result);
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
};
|
||||
|
||||
// *******************************************************************************************************
|
||||
/** A fct call (in a interface expr parse tree)
|
||||
*/
|
||||
class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
CInterfaceExpr::TUserFct Func;
|
||||
// list of parameters
|
||||
std::vector<CInterfaceExprNode *> Params;
|
||||
public:
|
||||
virtual void eval(CInterfaceExprValue &result);
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual ~CInterfaceExprNodeValueFnCall();
|
||||
};
|
||||
|
||||
// *******************************************************************************************************
|
||||
/** A db leaf read (in a interface expr parse tree)
|
||||
*/
|
||||
class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
class NLMISC::CCDBNodeLeaf *Leaf;
|
||||
public:
|
||||
virtual void eval(CInterfaceExprValue &result);
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
};
|
||||
|
||||
// *******************************************************************************************************
|
||||
/** A db branch read (in a interface expr parse tree)
|
||||
*/
|
||||
class CInterfaceExprNodeDBBranch : public CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
class NLMISC::CCDBNodeBranch *Branch;
|
||||
public:
|
||||
virtual void eval(CInterfaceExprValue &result);
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
};
|
||||
|
||||
// *******************************************************************************************************
|
||||
/** A dependant db read (in a interface expr parse tree)
|
||||
* This is rarely used so no real optim there..
|
||||
*/
|
||||
class CInterfaceExprNodeDependantDBRead : public CInterfaceExprNode
|
||||
{
|
||||
public:
|
||||
std::string Expr;
|
||||
public:
|
||||
virtual void eval(CInterfaceExprValue &result);
|
||||
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
422
code/nel/include/nel/gui/interface_group.h
Normal file
422
code/nel/include/nel/gui/interface_group.h
Normal file
|
@ -0,0 +1,422 @@
|
|||
// 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 NL_INTERFACE_GROUP_H
|
||||
#define NL_INTERFACE_GROUP_H
|
||||
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/gui/action_handler.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CInterfaceGroup : public CCtrlBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CInterfaceGroup)
|
||||
|
||||
/// Constructor
|
||||
CInterfaceGroup(const TCtorParam ¶m);
|
||||
|
||||
/// Destructor
|
||||
virtual ~CInterfaceGroup();
|
||||
|
||||
virtual void setIdRecurse(const std::string &id);
|
||||
|
||||
/// Coming from CInterfaceElement
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const;
|
||||
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
|
||||
xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
|
||||
xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
|
||||
virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
bool serializeLinks( xmlNodePtr parentNode ) const;
|
||||
|
||||
virtual uint32 getMemory ();
|
||||
|
||||
virtual CInterfaceElement* getElement (const std::string &id);
|
||||
CInterfaceElement* findFromShortId(const std::string &id);
|
||||
|
||||
/// Dynamic creation
|
||||
virtual void addView (CViewBase *child , sint eltOrder = -1);
|
||||
virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
|
||||
virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);
|
||||
|
||||
CViewBase* getView (const std::string &id);
|
||||
CCtrlBase* getCtrl (const std::string &id);
|
||||
CInterfaceGroup* getGroup(const std::string &id) const;
|
||||
|
||||
// Delete know type by ptr (return true if found and removed)
|
||||
virtual bool delView (CViewBase *child, bool dontDelete = false);
|
||||
virtual bool delCtrl (CCtrlBase *child, bool dontDelete = false);
|
||||
virtual bool delGroup (CInterfaceGroup * child, bool dontDelete = false);
|
||||
|
||||
// Delete know type by name (return true if found and removed)
|
||||
virtual bool delView (const std::string &id, bool dontDelete = false);
|
||||
virtual bool delCtrl (const std::string &id, bool dontDelete = false);
|
||||
virtual bool delGroup (const std::string &id, bool dontDelete = false);
|
||||
|
||||
// Delete unknow type by name or ptr. NB: additionaly, if it's a group, unmakeWindow() is called as necessary
|
||||
bool delElement (const std::string &id, bool noWarning=false);
|
||||
bool delElement (CInterfaceElement *pIE, bool noWarning=false);
|
||||
|
||||
uint getNumGroup() const { return (uint)_ChildrenGroups.size(); }
|
||||
CInterfaceGroup *getGroup(uint index) const;
|
||||
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
/// Coming from CCtrlBase
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
void executeControl (const std::string &sControlName);
|
||||
|
||||
const std::vector<CInterfaceGroup*> & getGroups () { return _ChildrenGroups; }
|
||||
const std::vector<CCtrlBase*> & getControls() { return _Controls; }
|
||||
const std::vector<CViewBase*> & getViews() { return _Views; }
|
||||
|
||||
// test is a group is a direct child of this interface group
|
||||
bool isChildGroup(const CInterfaceGroup *group) const;
|
||||
|
||||
virtual bool isWindowUnder (sint32 x, sint32 y); // Virtual for menu that is not square
|
||||
CInterfaceGroup *getGroupUnder (sint32 x, sint32 y);
|
||||
virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CViewBase*> &vVB); // Return true if x,y under the group
|
||||
virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CCtrlBase*> &vICL);
|
||||
virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CInterfaceGroup *> &vIGL);
|
||||
|
||||
void absoluteToRelative (sint32 &x, sint32 &y);
|
||||
|
||||
/// Coming from CViewBase
|
||||
virtual void draw ();
|
||||
// Draw with no clip (if clip is done by parent)
|
||||
virtual void drawNoClip();
|
||||
|
||||
/// Tool function to draw a single Element that should exist in the group (clipped by the group)
|
||||
void drawElement (CViewBase *el);
|
||||
|
||||
|
||||
/**
|
||||
* update the elements coords
|
||||
*/
|
||||
virtual void checkCoords();
|
||||
virtual void updateCoords();
|
||||
|
||||
/// remove all views
|
||||
virtual void clearViews();
|
||||
|
||||
/// remove all controls
|
||||
virtual void clearControls();
|
||||
|
||||
/// remove all groups
|
||||
virtual void clearGroups();
|
||||
|
||||
void setParentSizeMax(CInterfaceElement *pIE) { _ParentSizeMax = pIE; }
|
||||
void setMaxW (sint32 maxw) { _MaxW = maxw; }
|
||||
void setMaxH (sint32 maxh) { _MaxH = maxh; }
|
||||
void setOfsX (sint32 x) { _OffsetX = x; }
|
||||
void setOfsY (sint32 y) { _OffsetY = y; }
|
||||
bool moveSBTrackY (CInterfaceGroup *target, sint32 dy);
|
||||
bool moveSBTargetY (CInterfaceGroup *target, sint32 dy);
|
||||
void setResizeFromChildW(bool resize) { _ResizeFromChildW = resize; }
|
||||
void setResizeFromChildH(bool resize) { _ResizeFromChildH = resize; }
|
||||
|
||||
// Valid only for windows InterfaceGroup.
|
||||
// escapable
|
||||
void setEscapable(bool b) { _Escapable= b; }
|
||||
bool getEscapable() const { return _Escapable; }
|
||||
void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); }
|
||||
const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); }
|
||||
void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; }
|
||||
const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; }
|
||||
// enterable
|
||||
void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); }
|
||||
const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); }
|
||||
void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; }
|
||||
const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; }
|
||||
uint8 getPriority() const { return _Priority; }
|
||||
void setPriority(uint8 nprio);
|
||||
|
||||
|
||||
sint32 getMaxW () const { return _MaxW; }
|
||||
sint32 getMaxH () const { return _MaxH; }
|
||||
sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; }
|
||||
sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; }
|
||||
sint32 getOfsX () const { return _OffsetX; }
|
||||
sint32 getOfsY () const { return _OffsetY; }
|
||||
bool getResizeFromChildW() const { return _ResizeFromChildW; }
|
||||
bool getResizeFromChildH() const { return _ResizeFromChildH; }
|
||||
sint32 getResizeFromChildWMargin() const { return _ResizeFromChildWMargin; }
|
||||
sint32 getResizeFromChildHMargin() const { return _ResizeFromChildHMargin; }
|
||||
void setResizeFromChildWMargin(sint32 margin) { _ResizeFromChildWMargin = margin; }
|
||||
void setResizeFromChildHMargin(sint32 margin) { _ResizeFromChildHMargin = margin; }
|
||||
bool getOverlappable() const { return _Overlappable; }
|
||||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
// eval dimension of children bbox
|
||||
void evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const;
|
||||
|
||||
virtual void launch ();
|
||||
|
||||
|
||||
// right & left clicks handler
|
||||
void setLeftClickHandler(const std::string &handler);
|
||||
void setRightClickHandler(const std::string &handler);
|
||||
void setLeftClickHandlerParams(const std::string ¶ms) { _AHOnLeftClickParams = params; }
|
||||
void setRightClickHandlerParams(const std::string ¶ms) { _AHOnRightClickParams = params; }
|
||||
void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); }
|
||||
void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; }
|
||||
void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); }
|
||||
void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; }
|
||||
|
||||
const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); }
|
||||
const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; }
|
||||
const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); }
|
||||
const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; }
|
||||
const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); }
|
||||
const std::string &getOnActiveParams() const { return _AHOnActiveParams; }
|
||||
const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); }
|
||||
const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; }
|
||||
|
||||
// find a sub view/ctrl/group in this group from its id
|
||||
int luaFind(CLuaState &ls);
|
||||
int luaGetEnclosingContainer(CLuaState &ls);
|
||||
int luaDeleteLUAEnvTable(CLuaState &ls);
|
||||
int luaAddGroup(CLuaState &ls);
|
||||
int luaDelGroup(CLuaState &ls);
|
||||
int luaGetNumGroups(CLuaState &ls);
|
||||
int luaGetGroup(CLuaState &ls);
|
||||
|
||||
void setMaxSizeRef(const std::string &maxSizeRef);
|
||||
std::string getMaxSizeRefAsString() const;
|
||||
|
||||
|
||||
REFLECT_EXPORT_START(CInterfaceGroup, CCtrlBase)
|
||||
REFLECT_LUA_METHOD("find", luaFind);
|
||||
REFLECT_LUA_METHOD("deleteLUAEnvTable", luaDeleteLUAEnvTable);
|
||||
REFLECT_LUA_METHOD("getEnclosingContainer", luaGetEnclosingContainer);
|
||||
REFLECT_LUA_METHOD("addGroup", luaAddGroup);
|
||||
REFLECT_LUA_METHOD("delGroup", luaDelGroup);
|
||||
REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups);
|
||||
REFLECT_LUA_METHOD("getGroup", luaGetGroup);
|
||||
REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler);
|
||||
REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler);
|
||||
REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams);
|
||||
REFLECT_STRING ("right_click_params", getRightClickHandlerParams, setRightClickHandlerParams);
|
||||
REFLECT_STRING ("on_active", getOnActiveHandler, setOnActiveHandler);
|
||||
REFLECT_STRING ("on_active_params", getOnActiveParams, setOnActiveParams);
|
||||
REFLECT_STRING ("on_deactive", getOnDeactiveHandler, setOnDeactiveHandler);
|
||||
REFLECT_STRING ("on_deactive_params", getOnDeactiveParams, setOnDeactiveParams);
|
||||
REFLECT_STRING ("on_enter", getAHOnEnter, setAHOnEnter);
|
||||
REFLECT_STRING ("on_enter_params", getAHOnEnterParams, setAHOnEnterParams);
|
||||
REFLECT_STRING ("on_escape", getAHOnEscape, setAHOnEscape);
|
||||
REFLECT_STRING ("on_escape_params", getAHOnEscapeParams, setAHOnEscapeParams);
|
||||
REFLECT_SINT32 ("ofsx", getOfsX, setOfsX);
|
||||
REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
|
||||
REFLECT_BOOL("child_resize_w", getResizeFromChildW, setResizeFromChildW);
|
||||
REFLECT_SINT32("child_resize_wmargin", getResizeFromChildWMargin, setResizeFromChildWMargin);
|
||||
REFLECT_BOOL("child_resize_h", getResizeFromChildH, setResizeFromChildH);
|
||||
REFLECT_SINT32("child_resize_hmargin", getResizeFromChildHMargin, setResizeFromChildHMargin);
|
||||
REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
|
||||
REFLECT_STRING("max_sizeref", getMaxSizeRefAsString, setMaxSizeRef);
|
||||
REFLECT_SINT32 ("max_w", getMaxW, setMaxW);
|
||||
REFLECT_SINT32 ("max_h", getMaxH, setMaxH);
|
||||
REFLECT_SINT32 ("max_w_real", getMaxWReal, dummySet);
|
||||
REFLECT_SINT32 ("max_h_real", getMaxHReal, dummySet);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
|
||||
// From CCtrlBase
|
||||
virtual void updateAllLinks();
|
||||
|
||||
/// return true for some containers. false by default
|
||||
virtual bool isMovable() const {return false;}
|
||||
|
||||
virtual sint32 getAlpha() const;
|
||||
virtual void setAlpha (sint32 a);
|
||||
|
||||
/// Eval current clip coords. This is not incremental as with makeNewClip, and thus more slow. This also doesn't change the current clip window.
|
||||
void getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const;
|
||||
|
||||
// quick way to know if the group is a CGroupContainer
|
||||
bool isGroupContainer() const { return _IsGroupContainer; }
|
||||
bool isGroupScrollText() const{ return _IsGroupScrollText; }
|
||||
bool isGroupInScene() const{ return _IsGroupInScene; }
|
||||
bool isGroupList() const{ return _IsGroupList; }
|
||||
|
||||
CInterfaceGroup* getEnclosingContainer();
|
||||
|
||||
sint getInsertionOrder(CViewBase *vb) const;
|
||||
|
||||
// for debug only
|
||||
void dumpGroups();
|
||||
void dumpEltsOrder();
|
||||
|
||||
virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter);
|
||||
|
||||
virtual bool isGroup() const { return true; }
|
||||
|
||||
// clear all edit box in the ui
|
||||
virtual void clearAllEditBox();
|
||||
// restore all backuped positions for containers
|
||||
virtual void restoreAllContainersBackupPosition();
|
||||
|
||||
virtual void dumpSize(uint depth = 0) const;
|
||||
|
||||
// From CInterfaceElement
|
||||
virtual void visit(CInterfaceElementVisitor *visitor);
|
||||
|
||||
/// Visits only this group's sub-groups and then the group itself
|
||||
virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor );
|
||||
|
||||
// Check cursor
|
||||
void setUseCursor(bool use);
|
||||
bool getUseCursor() const { return _UseCursor; }
|
||||
|
||||
|
||||
// From CInterfaceElement
|
||||
virtual void onFrameUpdateWindowPos(sint dx, sint dy);
|
||||
// true for CGroupInScene for instance
|
||||
bool isNeedFrameUpdatePos() const {return _NeedFrameUpdatePos;}
|
||||
|
||||
|
||||
/// \name LUA specific
|
||||
// @{
|
||||
// Create a LUA Environement if don't exist, then push it on the LUA stack
|
||||
void pushLUAEnvTable();
|
||||
// Free the LUA Env Table
|
||||
void deleteLUAEnvTable(bool recurse = false);
|
||||
// Set the LUA script to execute at checkCoords time (empty to reset)
|
||||
void setLuaScriptOnDraw(const std::string &script);
|
||||
//
|
||||
void executeLuaScriptOnDraw();
|
||||
// Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key
|
||||
void addLuaScriptOnDBChange(const std::string &dbList, const std::string &script);
|
||||
// Remove the LUA script to execute when a list of DB change
|
||||
void removeLuaScriptOnDBChange(const std::string &dbList);
|
||||
// @}
|
||||
|
||||
virtual CInterfaceElement *clone();
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
// Return the current Depth, with no ZBias applied.
|
||||
float getDepthForZSort() const { return _DepthForZSort; }
|
||||
|
||||
protected:
|
||||
|
||||
void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH);
|
||||
void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH);
|
||||
|
||||
// Compute clip contribution for current window, and a previous clipping rectangle. This doesn't change the clip window in the driver.
|
||||
void computeCurrentClipContribution(sint32 prevX, sint32 prevY, sint32 prevW, sint32 prevH,
|
||||
sint32 &newX, sint32 &newY, sint32 &newW, sint32 &newH) const;
|
||||
|
||||
void delEltOrder (CViewBase *pElt);
|
||||
|
||||
// update coords one time
|
||||
void doUpdateCoords();
|
||||
|
||||
// notify children controls & groups that 'active' has been called on one of their parent
|
||||
void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc);
|
||||
|
||||
protected:
|
||||
|
||||
/// children interface elements
|
||||
std::vector<CInterfaceGroup*> _ChildrenGroups;
|
||||
std::vector<CCtrlBase*> _Controls;
|
||||
std::vector<CViewBase*> _Views;
|
||||
|
||||
std::vector<CViewBase*> _EltOrder;
|
||||
|
||||
/// Scroll properties
|
||||
NLMISC::CRefPtr<CInterfaceElement> _ParentSizeMax; // RefPtr in case of group destroyed in a parent group with posref on it
|
||||
sint32 _MaxW, _MaxH;
|
||||
sint32 _MaxWReal, _MaxHReal;
|
||||
sint32 _OffsetX, _OffsetY;
|
||||
|
||||
uint8 _Priority;
|
||||
|
||||
// Misc prop
|
||||
bool _Overlappable : 1;
|
||||
bool _ResizeFromChildW : 1;
|
||||
bool _ResizeFromChildH : 1;
|
||||
bool _Escapable : 1;
|
||||
bool _UseCursor : 1;
|
||||
bool _IsGroupContainer : 1; // faster than a virual call
|
||||
bool _IsGroupScrollText : 1;
|
||||
bool _IsGroupInScene : 1;
|
||||
bool _IsGroupList : 1;
|
||||
bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene
|
||||
sint32 _ResizeFromChildWMargin;
|
||||
sint32 _ResizeFromChildHMargin;
|
||||
sint32 _GroupSizeRef;
|
||||
|
||||
// Projected Depth with no ZBias applied
|
||||
float _DepthForZSort;
|
||||
|
||||
// handler for activation
|
||||
IActionHandler *_AHOnActive;
|
||||
CStringShared _AHOnActiveParams;
|
||||
IActionHandler *_AHOnDeactive;
|
||||
CStringShared _AHOnDeactiveParams;
|
||||
|
||||
// right & left clicks
|
||||
IActionHandler *_AHOnLeftClick;
|
||||
CStringShared _AHOnLeftClickParams;
|
||||
IActionHandler *_AHOnRightClick;
|
||||
CStringShared _AHOnRightClickParams;
|
||||
|
||||
// enter params.
|
||||
IActionHandler *_AHOnEnter;
|
||||
CStringShared _AHOnEnterParams;
|
||||
|
||||
// escape AH
|
||||
IActionHandler *_AHOnEscape;
|
||||
CStringShared _AHOnEscapeParams;
|
||||
|
||||
private:
|
||||
|
||||
void addToEltOrder(CViewBase *view, sint order);
|
||||
|
||||
/// \name LUA specific
|
||||
// @{
|
||||
// Lua Env Table created. Table is in the LUA_REGISTRYINDEX, with key as this CInterfaceGroup* userdata
|
||||
bool _LUAEnvTableCreated;
|
||||
// The LUA script to be executed on Draw (checkCoords)
|
||||
CStringShared _LUAOnDraw;
|
||||
// The InterfaceLink created specialy for Lua Script to be executed at some DB change
|
||||
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLUAOnDbChange;
|
||||
TLUAOnDbChange _LUAOnDbChange;
|
||||
void removeAllLUAOnDbChange();
|
||||
protected:
|
||||
void parseMaxSizeRef(const char *ptr);
|
||||
// @}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_INTERFACE_GROUP_H
|
||||
|
||||
/* End of interface_group.h */
|
||||
|
||||
|
186
code/nel/include/nel/gui/interface_link.h
Normal file
186
code/nel/include/nel/gui/interface_link.h
Normal file
|
@ -0,0 +1,186 @@
|
|||
// 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 CL_INTERFACE_LINK_H
|
||||
#define CL_INTERFACE_LINK_H
|
||||
|
||||
#include "nel/misc/cdb_branch.h"
|
||||
#include "nel/misc/cdb_branch_observing_handler.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CReflectedProperty;
|
||||
class CInterfaceExprValue;
|
||||
class CInterfaceExprNode;
|
||||
class CInterfaceElement;
|
||||
class CInterfaceGroup;
|
||||
|
||||
/** A link in an interface.
|
||||
* A link is an object that can read one or several values from the database, that can evaluate an expression
|
||||
* on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to
|
||||
* an interface property that has been exported by an interface element (the export system uses reflect.h).
|
||||
* The first time it is created, it places observers on the database entries that are needed by the expression, so each
|
||||
* time a database value changes, the link is marked as 'triggered'
|
||||
* When updateTrigeredLinks() is called, all links are effectively updated.
|
||||
*
|
||||
* Example of use : connecting a change in the db tree to the 'active' state of a window
|
||||
*
|
||||
* NB : an additionnal action handler can be provided
|
||||
* NB : The links are owned by the interface element (using a smart pointer)
|
||||
* NB : Several targets may be used.
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
|
||||
{
|
||||
public:
|
||||
#ifdef NL_DEBUG
|
||||
// for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager
|
||||
// and was created by calling CInterfaceManager::addLink, contains the name of this link
|
||||
std::string LinkName;
|
||||
#endif
|
||||
public:
|
||||
struct CTargetInfo
|
||||
{
|
||||
CInterfaceElement *Elem;
|
||||
std::string PropertyName;
|
||||
/** Affect a value to this target.
|
||||
* \return true if the affectation could be made
|
||||
*/
|
||||
bool affect(const CInterfaceExprValue &value);
|
||||
};
|
||||
|
||||
|
||||
/// Updates triggered interface links when triggered by the observed branch
|
||||
class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver
|
||||
{
|
||||
public:
|
||||
CInterfaceLinkUpdater();
|
||||
~CInterfaceLinkUpdater();
|
||||
void onObserverCallFlush();
|
||||
};
|
||||
|
||||
public:
|
||||
CInterfaceLink();
|
||||
~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement
|
||||
/** Make a link between the given interface element properties and a value that depends on database entries.
|
||||
* The link is automatically added in the link list of the targets element (it calls CInterfaceElement::addLink), so when all target elements are removed, the link is.
|
||||
* If there are no target element, the link is permanent (removed at exit)
|
||||
* NB : The target is not updated during this call.
|
||||
*/
|
||||
bool init(const std::vector<CTargetInfo> &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent);
|
||||
// force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved.
|
||||
static void updateAllLinks();
|
||||
// force all trigered links to be updated
|
||||
static void updateTrigeredLinks();
|
||||
// remove from the _LinksWithNoTarget list if the link has no target
|
||||
void uninit();
|
||||
|
||||
// Force an update of the target of this link
|
||||
void update();
|
||||
/** Remove a target element. It won't be updated anymore by that link
|
||||
* NB : this don't call removeLink() on the target
|
||||
*/
|
||||
void removeTarget(CInterfaceElement *elem);
|
||||
// Get the number of targets of this link
|
||||
uint getNumTargets() const { return (uint)_Targets.size(); }
|
||||
// Get the i-th target
|
||||
CInterfaceElement *getTarget(uint index) const { return _Targets[index]._InterfaceElement; }
|
||||
|
||||
static void removeAllLinks();
|
||||
|
||||
static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val);
|
||||
|
||||
static bool isUpdatingAllLinks() { return _UpdateAllLinks; }
|
||||
|
||||
/** From a target name of a link, retrieve the target element and its target target property
|
||||
* \return true if the target is valid
|
||||
*/
|
||||
static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm);
|
||||
|
||||
/** From several target names of a link (seprated by ','), retrieve the target elements and their target properties
|
||||
* \return true if all targets are valid
|
||||
*/
|
||||
static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector<CInterfaceLink::CTargetInfo> &targetsVect);
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
friend struct CRemoveTargetPred;
|
||||
// a target property
|
||||
struct CTarget
|
||||
{
|
||||
CInterfaceElement *_InterfaceElement;
|
||||
const CReflectedProperty *_Property;
|
||||
};
|
||||
private:
|
||||
typedef std::list<CInterfaceLink *> TLinkList;
|
||||
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
|
||||
typedef std::vector<TLinkSmartPtr> TLinkVect;
|
||||
typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
|
||||
private:
|
||||
std::vector<CTarget> _Targets;
|
||||
TNodeVect _ObservedNodes;
|
||||
std::string _Expr;
|
||||
CInterfaceExprNode *_ParseTree;
|
||||
std::string _ActionHandler;
|
||||
std::string _AHParams;
|
||||
std::string _AHCond;
|
||||
CInterfaceGroup *_AHParent;
|
||||
static TLinkList _LinkList;
|
||||
TLinkList::iterator _ListEntry;
|
||||
bool _On;
|
||||
static TLinkVect _LinksWithNoTarget; // there should be an owner for links with no targets
|
||||
static bool _UpdateAllLinks;
|
||||
///\ name triggered link mgt
|
||||
//@{
|
||||
// next/previous link that was trigered. NULL means end or start of list
|
||||
// each ptr is duplicated because with manage 2 lists : one list in which links are added, and one list in which we update links.
|
||||
// This way one link can trigger another with no prb
|
||||
CInterfaceLink *_PrevTriggeredLink[2];
|
||||
CInterfaceLink *_NextTriggeredLink[2];
|
||||
bool _Triggered[2];
|
||||
// global lists
|
||||
static CInterfaceLink *_FirstTriggeredLink[2];
|
||||
static CInterfaceLink *_LastTriggeredLink[2];
|
||||
// iterators in current list being updated : they're global so that deleting a CInterfaceLink instance prevent them from becoming dangling pointers
|
||||
static CInterfaceLink *_CurrUpdatedLink;
|
||||
static CInterfaceLink *_NextUpdatedLink;
|
||||
// Index of the list in which triggered link must be inserted
|
||||
static uint _CurrentTriggeredLinkList;
|
||||
|
||||
//
|
||||
void linkInTriggerList(uint list);
|
||||
void unlinkFromTriggerList(uint list);
|
||||
//@}
|
||||
|
||||
private:
|
||||
/** Inherited from ICDBNode::IPropertyObserver
|
||||
* This doesn't update the node directly, but mark it as 'triggered'
|
||||
* The node is really updated during the call to 'updateTrigeredLinks()'
|
||||
*/
|
||||
virtual void update(NLMISC::ICDBNode *node);
|
||||
void createObservers(const TNodeVect &nodes);
|
||||
void removeObservers(const TNodeVect &nodes);
|
||||
// debug : check that there are as many targets as reference to a link
|
||||
void checkNbRefs();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
225
code/nel/include/nel/gui/interface_options.h
Normal file
225
code/nel/include/nel/gui/interface_options.h
Normal file
|
@ -0,0 +1,225 @@
|
|||
// 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 RZ_INTERFACE_LAYER_H
|
||||
#define RZ_INTERFACE_LAYER_H
|
||||
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "libxml/globals.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
|
||||
namespace NL3D
|
||||
{
|
||||
class UAnimationSet;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
class CInterfaceOptionValue
|
||||
{
|
||||
public:
|
||||
CInterfaceOptionValue()
|
||||
{
|
||||
_Color= NLMISC::CRGBA::White;
|
||||
_Int= 0;
|
||||
_Float= 0;
|
||||
_Boolean= false;
|
||||
}
|
||||
|
||||
const std::string &getValStr () const {return _Str;}
|
||||
sint32 getValSInt32() const {return _Int;}
|
||||
float getValFloat () const {return _Float;}
|
||||
NLMISC::CRGBA getValColor () const {return _Color;}
|
||||
bool getValBool () const {return _Boolean;}
|
||||
|
||||
void init(const std::string &str);
|
||||
|
||||
// returned when InterfaceOptions param not found
|
||||
static const CInterfaceOptionValue NullValue;
|
||||
|
||||
private:
|
||||
|
||||
std::string _Str;
|
||||
NLMISC::CRGBA _Color;
|
||||
sint32 _Int;
|
||||
float _Float;
|
||||
bool _Boolean;
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class CInterfaceOptions : public NLMISC::CRefCount
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// for factory construction
|
||||
struct TCtorParam
|
||||
{
|
||||
};
|
||||
|
||||
CInterfaceOptions( const TCtorParam &/* param */ );
|
||||
virtual ~CInterfaceOptions();
|
||||
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
|
||||
// return NullValue if param not found
|
||||
const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
|
||||
|
||||
// shortcuts to getValue(paramName).getValXXX()
|
||||
const std::string &getValStr (const std::string &sParamName) const;
|
||||
sint32 getValSInt32 (const std::string &sParamName) const;
|
||||
float getValFloat (const std::string &sParamName) const;
|
||||
NLMISC::CRGBA getValColor (const std::string &sParamName) const;
|
||||
bool getValBool (const std::string &sParamName) const;
|
||||
|
||||
// copy basic map only from other CInterfaceOptions (non virtual method)
|
||||
void copyBasicMap(const CInterfaceOptions &other);
|
||||
|
||||
protected:
|
||||
|
||||
std::map<std::string, CInterfaceOptionValue> _ParamValue;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class COptionsLayer : public CInterfaceOptions
|
||||
{
|
||||
|
||||
public:
|
||||
COptionsLayer( const TCtorParam &/* param */ );
|
||||
~COptionsLayer();
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
// Container optimizer
|
||||
|
||||
sint32 Tile_Blank;
|
||||
sint32 Tile_M_Header, Tile_M_Scrollbar;
|
||||
sint32 Tile_T, Tile_B, Tile_L, Tile_R;
|
||||
sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open;
|
||||
|
||||
sint32 Scrollbar_Offset_X;
|
||||
sint32 Scrollbar_W;
|
||||
sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar;
|
||||
sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar;
|
||||
sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar;
|
||||
|
||||
sint32 TxId_L_Header, W_L_Header, H_L_Header;
|
||||
sint32 TxId_M_Header, W_M_Header, H_M_Header;
|
||||
sint32 TxId_R_Header, W_R_Header, H_R_Header;
|
||||
|
||||
sint32 TxId_TL, W_TL, H_TL;
|
||||
sint32 TxId_T, W_T, H_T;
|
||||
sint32 TxId_TR, W_TR, H_TR;
|
||||
sint32 TxId_L, W_L, H_L;
|
||||
sint32 TxId_R, W_R, H_R;
|
||||
sint32 TxId_Blank, W_Blank, H_Blank;
|
||||
sint32 TxId_BL, W_BL, H_BL;
|
||||
sint32 TxId_B, W_B, H_B;
|
||||
sint32 TxId_BR, W_BR, H_BR;
|
||||
|
||||
sint32 TxId_BL_Open, W_BL_Open, H_BL_Open;
|
||||
sint32 TxId_B_Open, W_B_Open, H_B_Open;
|
||||
sint32 TxId_BR_Open, W_BR_Open, H_BR_Open;
|
||||
sint32 TxId_EL_Open, W_EL_Open, H_EL_Open;
|
||||
sint32 TxId_EM_Open, W_EM_Open, H_EM_Open;
|
||||
sint32 TxId_ER_Open, W_ER_Open, H_ER_Open;
|
||||
sint32 TxId_E_Open, W_E_Open, H_E_Open;
|
||||
sint32 TxId_M_Open, W_M_Open, H_M_Open;
|
||||
|
||||
sint32 TxId_TL_HighLight;
|
||||
sint32 TxId_T_HighLight;
|
||||
sint32 TxId_TR_HighLight;
|
||||
sint32 TxId_L_HighLight;
|
||||
sint32 TxId_R_HighLight;
|
||||
sint32 TxId_BL_HighLight;
|
||||
sint32 TxId_B_HighLight;
|
||||
sint32 TxId_BR_HighLight;
|
||||
|
||||
sint32 HeaderH;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
class COptionsContainerInsertion : public CInterfaceOptions
|
||||
{
|
||||
public:
|
||||
COptionsContainerInsertion( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
sint32 TxId_R_Arrow;
|
||||
sint32 TxId_L_Arrow;
|
||||
sint32 TxId_T_Arrow;
|
||||
sint32 TxId_B_Arrow;
|
||||
sint32 TxId_InsertionBar;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
class COptionsContainerMove : public CInterfaceOptions
|
||||
{
|
||||
public:
|
||||
COptionsContainerMove( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
sint32 TrackW;
|
||||
sint32 TrackH;
|
||||
sint32 TrackY;
|
||||
sint32 TrackYWithTopResizer;
|
||||
sint32 TrackHWithTopResizer;
|
||||
sint32 ResizerSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* read a list of <param> with no name. id auto incremented
|
||||
*/
|
||||
class COptionsList : public CInterfaceOptions
|
||||
{
|
||||
public:
|
||||
COptionsList( const TCtorParam &/* param */ );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
|
||||
virtual bool parse (xmlNodePtr cur);
|
||||
|
||||
uint getNumParams() const {return _NumParams;}
|
||||
|
||||
// get a value by its index (from 0 to numParams)
|
||||
const CInterfaceOptionValue &getValue(uint paramId) const;
|
||||
|
||||
private:
|
||||
uint _NumParams;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_INTERFACE_LAYER_H
|
||||
|
||||
/* End of interface_layer.h */
|
||||
|
||||
|
389
code/nel/include/nel/gui/interface_parser.h
Normal file
389
code/nel/include/nel/gui/interface_parser.h
Normal file
|
@ -0,0 +1,389 @@
|
|||
// 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 RZ_INTERFACE_PARSER_H
|
||||
#define RZ_INTERFACE_PARSER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#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"
|
||||
#include "nel/gui/link_data.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CInterfaceElement;
|
||||
class CInterfaceGroup;
|
||||
class CInterfaceOptions;
|
||||
class CInterfaceLink;
|
||||
class CCtrlBase;
|
||||
class CGroupList;
|
||||
class CGroupContainer;
|
||||
class CInterfaceAnim;
|
||||
class CViewPointer;
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* class managing the interface parsing
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class CInterfaceParser : public IParser
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/// Interface for parser modules
|
||||
/// Such modules can be plugged into CInterfaceParser, and
|
||||
/// the modules then can parse GUI XMLs for widget classes that are not
|
||||
/// generic enough to be in the GUI library.
|
||||
class IParserModule
|
||||
{
|
||||
public:
|
||||
|
||||
/// Various parsing stages
|
||||
enum ParsingStage
|
||||
{
|
||||
None = 0, /// module cannot parse in any stage.
|
||||
Unresolved = 1, /// module can parse in the first stage when styles, templates, etc have not been resolved yet
|
||||
Resolved = 2, /// module can parse after resolving styles and templates
|
||||
GroupChildren = 4 /// module can parse when parsing the group children
|
||||
};
|
||||
|
||||
IParserModule(){
|
||||
parser = NULL;
|
||||
parsingStage = None;
|
||||
}
|
||||
virtual ~IParserModule(){}
|
||||
|
||||
bool canParseInStage( ParsingStage stage )
|
||||
{
|
||||
if( ( parsingStage & static_cast< uint >( stage ) ) != 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ) = 0;
|
||||
void setParser( CInterfaceParser *p ){ parser = p; }
|
||||
|
||||
protected:
|
||||
CInterfaceParser *parser;
|
||||
uint parsingStage;
|
||||
};
|
||||
|
||||
/// Interface for event handlers which can be called when setting up the options.
|
||||
class ISetupOptionCallbackClass
|
||||
{
|
||||
public:
|
||||
virtual void setupOptions() = 0;
|
||||
};
|
||||
|
||||
|
||||
struct VariableData
|
||||
{
|
||||
std::string entry;
|
||||
std::string type;
|
||||
std::string value;
|
||||
uint32 size;
|
||||
|
||||
VariableData()
|
||||
{
|
||||
size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
CInterfaceParser();
|
||||
virtual ~CInterfaceParser();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Parsing methods
|
||||
*/
|
||||
|
||||
/** Load a set of xml files
|
||||
* \param isFilename true if xmlFileNames array contains the names of the xml file, false, if each
|
||||
* array is a script itself
|
||||
*/
|
||||
bool parseInterface (const std::vector<std::string> &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false);
|
||||
|
||||
bool parseXMLDocument (xmlNodePtr root, bool reload);
|
||||
bool parseTemplateNode (xmlNodePtr node,xmlNodePtr instance,xmlNodePtr templ);
|
||||
bool parseInstance(xmlNodePtr cur);
|
||||
bool parseVector (xmlNodePtr cur);
|
||||
bool parseVariable (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
bool parseOptions (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
bool parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
|
||||
bool parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
|
||||
bool parseControl (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
|
||||
bool parseLink (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
bool parseView (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
|
||||
bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
|
||||
bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
|
||||
bool parseDefine(xmlNodePtr cur);
|
||||
bool parseProcedure(xmlNodePtr cur, bool reload);
|
||||
bool parseSheetSelection(xmlNodePtr cur);
|
||||
bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
bool parseStyle(xmlNodePtr cur);
|
||||
bool parseLUAScript (xmlNodePtr cur);
|
||||
bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
|
||||
bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
|
||||
void savePointerSettings( xmlNodePtr node );
|
||||
void saveKeySettings( xmlNodePtr node );
|
||||
|
||||
void addModule( std::string name, IParserModule *module );
|
||||
IParserModule* getModuleFor( std::string name ) const;
|
||||
void removeAllModules();
|
||||
|
||||
// Called by each parse in parseXMLDocument
|
||||
bool solveDefine(xmlNodePtr cur);
|
||||
bool solveStyle(xmlNodePtr cur);
|
||||
|
||||
// Solve All define in a string. return false if some define not founs (defError contains this define)
|
||||
bool solveDefine(const std::string &propVal, std::string &newPropVal, std::string &defError);
|
||||
|
||||
// Called after template & options parsing
|
||||
void setupOptions();
|
||||
|
||||
/**
|
||||
* Initializer
|
||||
*/
|
||||
|
||||
bool initCoordsAndLuaScript ();
|
||||
|
||||
/// Association builders : associate an element of the interface with the string ID of
|
||||
/// another element used as reference for position values
|
||||
void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID);
|
||||
std::string getParentPosAssociation( CInterfaceElement *element ) const;
|
||||
void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID);
|
||||
std::string getParentSizeAssociation( CInterfaceElement *element ) const;
|
||||
void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID);
|
||||
std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const;
|
||||
|
||||
/// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed)
|
||||
void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript);
|
||||
std::string getLuaClassAssociation( CInterfaceGroup *group ) const;
|
||||
|
||||
/**
|
||||
* Accessors
|
||||
*/
|
||||
// access to control sheet selection
|
||||
CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; }
|
||||
|
||||
/// \name Parameter variable
|
||||
// @{
|
||||
const std::string& getDefine(const std::string &id) const;
|
||||
bool isDefineExist(const std::string &id) const;
|
||||
void setDefine(const std::string &id, const std::string &value);
|
||||
// @}
|
||||
|
||||
/// \name Dynamic links mgt
|
||||
// @{
|
||||
/** Associate the given dynamic link with an ID
|
||||
* \return true if succesful
|
||||
*/
|
||||
bool addLink(CInterfaceLink *link, const std::string &id);
|
||||
/** remove the given link from its ID
|
||||
* \return true if succesful
|
||||
*/
|
||||
bool removeLink(const std::string &id);
|
||||
// @}
|
||||
|
||||
/** create a template from an instance consisting of a single group
|
||||
* \param templateName name of the template in the xml
|
||||
* \param templateParams array containing each template parameter and its name
|
||||
* \param number of template parameters in the array
|
||||
*/
|
||||
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true);
|
||||
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
|
||||
{
|
||||
if (templateParams.size() > 0)
|
||||
return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
|
||||
else
|
||||
return createGroupInstance(templateName, parentID, NULL, 0, updateLinks);
|
||||
}
|
||||
|
||||
/** create a template from an instance consisting of a single control or group
|
||||
* \param templateName name of the template in the xml
|
||||
* \param templateParams array containing each template parameter and its name
|
||||
* \param number of template parameters in the array
|
||||
*/
|
||||
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */);
|
||||
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
|
||||
{
|
||||
if (templateParams.size() > 0)
|
||||
return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
|
||||
else
|
||||
return createUIElement(templateName, parentID, NULL, 0, updateLinks);
|
||||
}
|
||||
|
||||
static void freeXMLNodeAndSibblings(xmlNodePtr node);
|
||||
|
||||
// search a "tree" node in the hierarchy that match node. may return root! NULL if not found
|
||||
static xmlNodePtr searchTreeNodeInHierarchy(xmlNodePtr root, const char *node);
|
||||
|
||||
/// \name Clearing mgt
|
||||
// @{
|
||||
void removeAllLinks();
|
||||
void removeAllProcedures();
|
||||
void removeAllDefines();
|
||||
void removeAllTemplates();
|
||||
void removeAllAnims();
|
||||
void removeAll();
|
||||
// @}
|
||||
|
||||
protected:
|
||||
/// Procedure list
|
||||
typedef TProcedureMap::iterator ItProcedureMap;
|
||||
typedef TProcedureMap::const_iterator CstItProcedureMap;
|
||||
TProcedureMap _ProcedureMap;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// get info on procedure. return 0 if procedure not found
|
||||
uint getProcedureNumActions( const std::string &procName ) const;
|
||||
|
||||
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
|
||||
bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const;
|
||||
|
||||
void setCacheUIParsing( bool b ){ cacheUIParsing = b; }
|
||||
|
||||
CInterfaceAnim* getAnim( const std::string &name ) const;
|
||||
|
||||
CProcedure* getProc( const std::string &name );
|
||||
|
||||
const TProcedureMap& getProcMap() const{ return _ProcedureMap; }
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Temporary data for init
|
||||
*/
|
||||
|
||||
/// vector storing parsed templates during init. At the end of init, only used template are kept
|
||||
std::vector<xmlNodePtr> _Templates;
|
||||
|
||||
|
||||
// map linking an element to its parent position used during init only
|
||||
std::map<CInterfaceElement*,std::string> _ParentPositionsMap;
|
||||
std::map<CInterfaceElement*,std::string> _ParentSizesMap;
|
||||
std::map<CInterfaceElement*,std::string> _ParentSizesMaxMap;
|
||||
|
||||
// map linking a group to its lua script. used during init only
|
||||
std::map<CInterfaceGroup*,std::string> _LuaClassAssociation;
|
||||
|
||||
/**
|
||||
* Data of initialized interface
|
||||
*/
|
||||
|
||||
/// Define Variable list
|
||||
typedef std::map<std::string, std::string> TVarMap;
|
||||
typedef TVarMap::iterator ItVarMap;
|
||||
typedef TVarMap::const_iterator CstItVarMap;
|
||||
TVarMap _DefineMap;
|
||||
|
||||
bool validDefineChar(char c) const;
|
||||
|
||||
class CStyleProperty
|
||||
{
|
||||
public:
|
||||
std::string Name;
|
||||
std::string Value;
|
||||
};
|
||||
class CStyle
|
||||
{
|
||||
public:
|
||||
std::vector<CStyleProperty> Properties;
|
||||
};
|
||||
|
||||
|
||||
// mgt of sheet selections (inventory, buy, sell..)
|
||||
CCtrlSheetSelection _CtrlSheetSelection;
|
||||
|
||||
// Map of dynamic links
|
||||
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLinkMap;
|
||||
TLinkMap _LinkMap;
|
||||
|
||||
// Map of anims
|
||||
typedef std::map<std::string, CInterfaceAnim *> TAnimMap;
|
||||
TAnimMap _AnimMap;
|
||||
|
||||
// Map of styles.
|
||||
typedef std::map<std::string, CStyle> TStyleMap;
|
||||
TStyleMap _StyleMap;
|
||||
|
||||
protected:
|
||||
std::map< std::string, IParserModule* > moduleMap;
|
||||
|
||||
// List of script loaded (for reloadLua command)
|
||||
std::set<std::string> _LuaFileScripts;
|
||||
|
||||
bool cacheUIParsing;
|
||||
bool luaInitialized;
|
||||
ISetupOptionCallbackClass *setupCallback;
|
||||
|
||||
uint32 linkId;
|
||||
std::map< uint32, SLinkData > links;
|
||||
|
||||
bool editorMode;
|
||||
std::map< std::string, VariableData > variableCache;
|
||||
std::map< std::string, std::string > pointerSettings;
|
||||
std::map< std::string, std::map< std::string, std::string > > keySettings;
|
||||
|
||||
public:
|
||||
void initLUA();
|
||||
void uninitLUA();
|
||||
bool isLuaInitialized() const{ return luaInitialized; }
|
||||
|
||||
/// Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed)
|
||||
bool loadLUA( const std::string &luaFile, std::string &error );
|
||||
|
||||
/// Reload all LUA scripts inserted through <lua>
|
||||
void reloadAllLuaFileScripts();
|
||||
|
||||
void setSetupOptionsCallback( ISetupOptionCallbackClass *cb ){ setupCallback = cb; }
|
||||
|
||||
bool hasProc( const std::string &name ) const;
|
||||
bool addProc( const std::string &name );
|
||||
bool removeProc( const std::string &name );
|
||||
|
||||
const std::map< uint32, SLinkData >& getLinkMap() const{ return links; }
|
||||
uint32 addLinkData( SLinkData &linkData );
|
||||
void removeLinkData( uint32 id );
|
||||
bool getLinkData( uint32 id, SLinkData &linkData );
|
||||
void updateLinkData( uint32 id, const SLinkData &linkData );
|
||||
|
||||
void setEditorMode( bool b ){ editorMode = b; }
|
||||
|
||||
bool serializeVariables( xmlNodePtr parentNode ) const;
|
||||
bool serializeProcs( xmlNodePtr parentNode ) const;
|
||||
bool serializePointerSettings( xmlNodePtr parentNode ) const;
|
||||
bool serializeKeySettings( xmlNodePtr parentNode ) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_INTERFACE_PARSER_H
|
106
code/nel/include/nel/gui/interface_property.h
Normal file
106
code/nel/include/nel/gui/interface_property.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
// 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 NL_INTERFACE_PROPERTY_H
|
||||
#define NL_INTERFACE_PROPERTY_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/misc/cdb.h"
|
||||
#include "nel/misc/cdb_leaf.h"
|
||||
#include "nel/misc/cdb_branch.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* interface property
|
||||
* class used to managed all the interface member values
|
||||
* As the database contains only sint64, several methods are needed to do the conversion
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CInterfaceProperty
|
||||
{
|
||||
public:
|
||||
//enum defining a hot spot
|
||||
|
||||
/// Constructor
|
||||
CInterfaceProperty()
|
||||
{
|
||||
_VolatileValue = NULL;
|
||||
}
|
||||
|
||||
NLMISC::CCDBNodeLeaf* getNodePtr() const
|
||||
{
|
||||
return _VolatileValue;
|
||||
}
|
||||
|
||||
void setNodePtr(NLMISC::CCDBNodeLeaf *ptr)
|
||||
{
|
||||
_VolatileValue = ptr;
|
||||
}
|
||||
|
||||
|
||||
bool link (const char *DBProp);
|
||||
bool link( NLMISC::CCDBNodeLeaf *dbNode );
|
||||
bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
|
||||
|
||||
/// float operations
|
||||
void setDouble (double value) {setSInt64((sint64&) value);}
|
||||
double getDouble () const {sint64 i = getSInt64(); return (double &) i; }
|
||||
void readDouble (const char* value, const std::string& id);
|
||||
|
||||
/// sint32 operations
|
||||
void setSInt32 (sint32 value) {_VolatileValue->setValue32 (value);}
|
||||
sint32 getSInt32 () const {return _VolatileValue->getValue32();}
|
||||
void readSInt32(const char* value, const std::string& id);
|
||||
|
||||
/// sint64 operations
|
||||
void setSInt64 (sint64 value) {_VolatileValue->setValue64(value);}
|
||||
sint64 getSInt64 () const {return _VolatileValue->getValue64();}
|
||||
void readSInt64(const char* value, const std::string& id);
|
||||
|
||||
/// CRGBA operations
|
||||
void setRGBA (const NLMISC::CRGBA & value);
|
||||
NLMISC::CRGBA getRGBA () const;
|
||||
void readRGBA (const char* value, const std::string& id);
|
||||
|
||||
/// HotSpot operations
|
||||
|
||||
void readHotSpot (const char* value, const std::string& id);
|
||||
|
||||
/// bool operations
|
||||
void setBool (bool value);
|
||||
bool getBool () const;
|
||||
void readBool (const char* value, const std::string& id);
|
||||
|
||||
// Swap the content of this 2 property (no-op if one is NULL)
|
||||
void swap32(CInterfaceProperty &o);
|
||||
|
||||
private:
|
||||
/// volatile value of the property (pointer to a leaf of the database)
|
||||
NLMISC::CCDBNodeLeaf* _VolatileValue;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_INTERFACE_PROPERTY_H
|
||||
|
||||
/* End of interface_property.h */
|
283
code/nel/include/nel/gui/libwww.h
Normal file
283
code/nel/include/nel/gui/libwww.h
Normal file
|
@ -0,0 +1,283 @@
|
|||
// 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 CL_LIB_WWW_H
|
||||
#define CL_LIB_WWW_H
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "libwww/WWWInit.h"
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBaseButton;
|
||||
class CCtrlScroll;
|
||||
class CGroupList;
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// Init the libwww
|
||||
void initLibWWW();
|
||||
|
||||
// Get an url and setup a local domain
|
||||
const std::string &setCurrentDomain(const std::string &url);
|
||||
|
||||
extern std::string CurrentCookie;
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// Some DTD table
|
||||
|
||||
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
|
||||
|
||||
#undef HTML_ATTR
|
||||
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(A,ACCESSKEY) = 0,
|
||||
HTML_ATTR(A,CHARSET),
|
||||
HTML_ATTR(A,CLASS),
|
||||
HTML_ATTR(A,COORDS),
|
||||
HTML_ATTR(A,DIR),
|
||||
HTML_ATTR(A,HREF),
|
||||
HTML_ATTR(A,HREFLANG),
|
||||
HTML_ATTR(A,ID),
|
||||
HTML_ATTR(A,NAME),
|
||||
HTML_ATTR(A,REL),
|
||||
HTML_ATTR(A,REV),
|
||||
HTML_ATTR(A,SHAPE),
|
||||
HTML_ATTR(A,STYLE),
|
||||
HTML_ATTR(A,TABINDEX),
|
||||
HTML_ATTR(A,TARGET),
|
||||
HTML_ATTR(A,TYPE),
|
||||
HTML_ATTR(A,TITLE),
|
||||
HTML_ATTR(A,Z_ACTION_CATEGORY),
|
||||
HTML_ATTR(A,Z_ACTION_PARAMS),
|
||||
HTML_ATTR(A,Z_ACTION_SHORTCUT),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(TABLE,ALIGN) = 0,
|
||||
HTML_ATTR(TABLE,BGCOLOR),
|
||||
HTML_ATTR(TABLE,BORDER),
|
||||
HTML_ATTR(TABLE,CELLPADDING),
|
||||
HTML_ATTR(TABLE,CELLSPACING),
|
||||
HTML_ATTR(TABLE,CLASS),
|
||||
HTML_ATTR(TABLE,DIR),
|
||||
HTML_ATTR(TABLE,FRAME),
|
||||
HTML_ATTR(TABLE,ID),
|
||||
HTML_ATTR(TABLE,L_MARGIN),
|
||||
HTML_ATTR(TABLE,LANG),
|
||||
HTML_ATTR(TABLE,NOWRAP),
|
||||
HTML_ATTR(TABLE,RULES),
|
||||
HTML_ATTR(TABLE,SUMMARY),
|
||||
HTML_ATTR(TABLE,STYLE),
|
||||
HTML_ATTR(TABLE,TITLE),
|
||||
HTML_ATTR(TABLE,VALIGN),
|
||||
HTML_ATTR(TABLE,WIDTH)
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(TR,ALIGN) = 0,
|
||||
HTML_ATTR(TR,BGCOLOR),
|
||||
HTML_ATTR(TR,L_MARGIN),
|
||||
HTML_ATTR(TR,NOWRAP),
|
||||
HTML_ATTR(TR,VALIGN),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(TD,ABBR) = 0,
|
||||
HTML_ATTR(TD,ALIGN),
|
||||
HTML_ATTR(TD,AXIS),
|
||||
HTML_ATTR(TD,BGCOLOR),
|
||||
HTML_ATTR(TD,CHAR),
|
||||
HTML_ATTR(TD,CHAROFF),
|
||||
HTML_ATTR(TD,CLASS),
|
||||
HTML_ATTR(TD,COLSPAN),
|
||||
HTML_ATTR(TD,DIR),
|
||||
HTML_ATTR(TD,ID),
|
||||
HTML_ATTR(TD,HEADERS),
|
||||
HTML_ATTR(TD,HEIGHT),
|
||||
HTML_ATTR(TD,L_MARGIN),
|
||||
HTML_ATTR(TD,LANG),
|
||||
HTML_ATTR(TD,NOWRAP),
|
||||
HTML_ATTR(TD,ROWSPAN),
|
||||
HTML_ATTR(TD,SCOPE),
|
||||
HTML_ATTR(TD,STYLE),
|
||||
HTML_ATTR(TD,TITLE),
|
||||
HTML_ATTR(TD,VALIGN),
|
||||
HTML_ATTR(TD,WIDTH),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(IMG,ALIGN) = 0,
|
||||
HTML_ATTR(IMG,ALT),
|
||||
HTML_ATTR(IMG,BORDER),
|
||||
HTML_ATTR(IMG,CLASS),
|
||||
HTML_ATTR(IMG,DIR),
|
||||
HTML_ATTR(IMG,GLOBAL_COLOR),
|
||||
HTML_ATTR(IMG,HEIGHT),
|
||||
HTML_ATTR(IMG,HSPACE),
|
||||
HTML_ATTR(IMG,ID),
|
||||
HTML_ATTR(IMG,ISMAP),
|
||||
HTML_ATTR(IMG,LANG),
|
||||
HTML_ATTR(IMG,LONGDESC),
|
||||
HTML_ATTR(IMG,SRC),
|
||||
HTML_ATTR(IMG,STYLE),
|
||||
HTML_ATTR(IMG,TITLE),
|
||||
HTML_ATTR(IMG,USEMAP),
|
||||
HTML_ATTR(IMG,VSPACE),
|
||||
HTML_ATTR(IMG,WIDTH),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(INPUT,ACCEPT) = 0,
|
||||
HTML_ATTR(INPUT,ACCESSKEY),
|
||||
HTML_ATTR(INPUT,ALIGN),
|
||||
HTML_ATTR(INPUT,ALT),
|
||||
HTML_ATTR(INPUT,CHECKED),
|
||||
HTML_ATTR(INPUT,CLASS),
|
||||
HTML_ATTR(INPUT,DIR),
|
||||
HTML_ATTR(INPUT,DISABLED),
|
||||
HTML_ATTR(INPUT,GLOBAL_COLOR),
|
||||
HTML_ATTR(INPUT,ID),
|
||||
HTML_ATTR(INPUT,LANG),
|
||||
HTML_ATTR(INPUT,MAXLENGTH),
|
||||
HTML_ATTR(INPUT,NAME),
|
||||
HTML_ATTR(INPUT,READONLY),
|
||||
HTML_ATTR(INPUT,SIZE),
|
||||
HTML_ATTR(INPUT,SRC),
|
||||
HTML_ATTR(INPUT,STYLE),
|
||||
HTML_ATTR(INPUT,TABINDEX),
|
||||
HTML_ATTR(INPUT,TITLE),
|
||||
HTML_ATTR(INPUT,TYPE),
|
||||
HTML_ATTR(INPUT,USEMAP),
|
||||
HTML_ATTR(INPUT,VALUE),
|
||||
HTML_ATTR(INPUT,Z_BTN_TMPL),
|
||||
HTML_ATTR(INPUT,Z_INPUT_TMPL),
|
||||
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(TEXTAREA,CLASS) = 0,
|
||||
HTML_ATTR(TEXTAREA,COLS),
|
||||
HTML_ATTR(TEXTAREA,DIR),
|
||||
HTML_ATTR(TEXTAREA,DISABLED),
|
||||
HTML_ATTR(TEXTAREA,ID),
|
||||
HTML_ATTR(TEXTAREA,LANG),
|
||||
HTML_ATTR(TEXTAREA,NAME),
|
||||
HTML_ATTR(TEXTAREA,READONLY),
|
||||
HTML_ATTR(TEXTAREA,ROWS),
|
||||
HTML_ATTR(TEXTAREA,STYLE),
|
||||
HTML_ATTR(TEXTAREA,TABINDEX),
|
||||
HTML_ATTR(TEXTAREA,TITLE),
|
||||
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
|
||||
HTML_ATTR(P,QUICK_HELP_EVENTS),
|
||||
HTML_ATTR(P,QUICK_HELP_LINK),
|
||||
HTML_ATTR(P,NAME),
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HTML_ATTR(DIV,CLASS) = 0,
|
||||
HTML_ATTR(DIV,ID),
|
||||
HTML_ATTR(DIV,NAME),
|
||||
HTML_ATTR(DIV,STYLE),
|
||||
};
|
||||
|
||||
|
||||
#undef HTML_ATTR
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// A smart ptr for LibWWW strings
|
||||
class C3WSmartPtr
|
||||
{
|
||||
public:
|
||||
C3WSmartPtr ()
|
||||
{
|
||||
_Ptr = NULL;
|
||||
}
|
||||
C3WSmartPtr (const char *ptr)
|
||||
{
|
||||
_Ptr = ptr;
|
||||
}
|
||||
~C3WSmartPtr ()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
void operator=(const char *str)
|
||||
{
|
||||
clear ();
|
||||
_Ptr = str;
|
||||
}
|
||||
operator const char *() const
|
||||
{
|
||||
return _Ptr;
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
if (_Ptr)
|
||||
{
|
||||
void *ptr = (void*)_Ptr;
|
||||
HT_FREE(ptr);
|
||||
}
|
||||
_Ptr = NULL;
|
||||
}
|
||||
private:
|
||||
const char *_Ptr;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
|
||||
bool getPercentage (sint32 &width, float &percent, const char *str);
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// Parse a HTML color
|
||||
NLMISC::CRGBA getColor (const char *color);
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line);
|
||||
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
// Standard request terminator
|
||||
int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
|
||||
|
||||
// ***************************************************************************
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,30 +1,28 @@
|
|||
// 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 LIBWWW_NEL_STREAM_H
|
||||
#define LIBWWW_NEL_STREAM_H
|
||||
|
||||
|
||||
#include "HTProt.h"
|
||||
|
||||
extern "C" HTProtCallback HTLoadNeLFile;
|
||||
|
||||
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
|
||||
void * param, int mode);
|
||||
|
||||
#endif // LIBWWW_NEL_STREAM_H
|
||||
// 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 LIBWWW_NEL_STREAM_H
|
||||
#define LIBWWW_NEL_STREAM_H
|
||||
|
||||
|
||||
#include "libwww/HTProt.h"
|
||||
|
||||
extern "C" HTProtCallback HTLoadNeLFile;
|
||||
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
|
||||
|
||||
#endif // LIBWWW_NEL_STREAM_H
|
|
@ -1,58 +1,42 @@
|
|||
// 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 NL_DBVIEW_QUANTITY_H
|
||||
#define NL_DBVIEW_QUANTITY_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#include "view_text.h"
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Display a text in the form of val / max or "empty"
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CDBViewQuantity : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CDBViewQuantity(const TCtorParam ¶m);
|
||||
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void draw ();
|
||||
|
||||
|
||||
protected:
|
||||
CInterfaceProperty _Number;
|
||||
CInterfaceProperty _NumberMax;
|
||||
sint32 _Cache;
|
||||
sint32 _CacheMax;
|
||||
ucstring _EmptyText;
|
||||
|
||||
void buildTextFromCache();
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_DBVIEW_QUANTITY_H
|
||||
|
||||
/* End of dbview_quantity.h */
|
||||
// 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 LINKDATA_H
|
||||
#define LINKDATA_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include <string>
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
struct SLinkData
|
||||
{
|
||||
public:
|
||||
uint32 id;
|
||||
std::string parent;
|
||||
std::string expr;
|
||||
std::string target;
|
||||
std::string action;
|
||||
std::string params;
|
||||
std::string cond;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
388
code/nel/include/nel/gui/lua_helper.h
Normal file
388
code/nel/include/nel/gui/lua_helper.h
Normal file
|
@ -0,0 +1,388 @@
|
|||
// 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 RZ_LUA_HELPER_H
|
||||
#define RZ_LUA_HELPER_H
|
||||
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "lua_loadlib.h"
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CLuaState;
|
||||
|
||||
namespace LuaHelperStuff
|
||||
{
|
||||
void formatLuaStackContext( std::string &stackContext );
|
||||
std::string formatLuaErrorSysInfo( const std::string &error );
|
||||
std::string formatLuaErrorNlWarn( const std::string &error );
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/** Helper class to see if a stack is restored at its initial size (or with n return results).
|
||||
* Check that the stack size remains unchanged when the object goes out of scope
|
||||
*/
|
||||
class CLuaStackChecker
|
||||
{
|
||||
public:
|
||||
CLuaStackChecker(CLuaState *state, int numWantedResults = 0);
|
||||
~CLuaStackChecker();
|
||||
/** Increment exception context counter
|
||||
* When an exception is thrown, lua stack checker do any assert bu will
|
||||
* rather restore the lua stack at its original size, and will
|
||||
* let the exception a chance to propagate
|
||||
*/
|
||||
static void incrementExceptionContextCounter();
|
||||
static void decrementExceptionContextCounter();
|
||||
|
||||
private:
|
||||
CLuaState *_State;
|
||||
int _FinalWantedSize;
|
||||
static uint _ExceptionContextCounter;
|
||||
|
||||
};
|
||||
|
||||
// **************************************************************************
|
||||
/** Helper class to restore the lua stack to the desired size when this object goes out of scope
|
||||
*/
|
||||
class CLuaStackRestorer
|
||||
{
|
||||
public:
|
||||
CLuaStackRestorer(CLuaState *state, int finalSize);
|
||||
~CLuaStackRestorer();
|
||||
private:
|
||||
int _FinalSize;
|
||||
CLuaState *_State;
|
||||
};
|
||||
|
||||
////////////////
|
||||
// EXCEPTIONS //
|
||||
////////////////
|
||||
|
||||
class ELuaError : public NLMISC::Exception
|
||||
{
|
||||
public:
|
||||
ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); }
|
||||
virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); }
|
||||
ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); }
|
||||
// what(), plus append the Reason
|
||||
virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());}
|
||||
};
|
||||
|
||||
// A parse error occured
|
||||
class ELuaParseError : public ELuaError
|
||||
{
|
||||
public:
|
||||
ELuaParseError() {}
|
||||
ELuaParseError(const std::string &reason) : ELuaError(reason) {}
|
||||
virtual ~ELuaParseError() throw() { }
|
||||
// what(), plus append the Reason
|
||||
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());}
|
||||
};
|
||||
|
||||
/** Exception thrown when something went wrong inside a wrapped function called by lua
|
||||
*/
|
||||
class ELuaWrappedFunctionException : public ELuaError
|
||||
{
|
||||
public:
|
||||
ELuaWrappedFunctionException(CLuaState *luaState);
|
||||
ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason);
|
||||
ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...);
|
||||
virtual ~ELuaWrappedFunctionException() throw() { }
|
||||
virtual const char *what() const throw() {return _Reason.c_str();}
|
||||
protected:
|
||||
void init(CLuaState *ls, const std::string &reason);
|
||||
protected:
|
||||
std::string _Reason;
|
||||
};
|
||||
|
||||
// A execution error occured
|
||||
class ELuaExecuteError : public ELuaError
|
||||
{
|
||||
public:
|
||||
ELuaExecuteError() {}
|
||||
ELuaExecuteError(const std::string &reason) : ELuaError(reason) {}
|
||||
virtual ~ELuaExecuteError() throw() { }
|
||||
// what(), plus append the Reason
|
||||
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());}
|
||||
};
|
||||
|
||||
// A bad cast occured when using lua_checkcast
|
||||
class ELuaBadCast : public ELuaError
|
||||
{
|
||||
public:
|
||||
ELuaBadCast() {}
|
||||
ELuaBadCast(const std::string &reason) : ELuaError(reason) {}
|
||||
// what(), plus append the Reason
|
||||
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaBadCast: %s", what());}
|
||||
};
|
||||
|
||||
// Error when trying to indexate an object that is not a table
|
||||
class ELuaNotATable : public ELuaError
|
||||
{
|
||||
public:
|
||||
ELuaNotATable() {}
|
||||
ELuaNotATable(const std::string &reason) : ELuaError(reason) {}
|
||||
// what(), plus append the Reason
|
||||
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaNotATable: %s", what());}
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// a function to be used with a CLuaState instance
|
||||
typedef int (* TLuaWrappedFunction) (CLuaState &ls);
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
/** C++ version of a lua state
|
||||
*/
|
||||
class CLuaState : public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
typedef NLMISC::CRefPtr<CLuaState> TRefPtr;
|
||||
|
||||
// Create a new environement
|
||||
CLuaState( bool debugger = false );
|
||||
~CLuaState();
|
||||
|
||||
|
||||
/// \name Registering
|
||||
// @{
|
||||
// register a wrapped function
|
||||
void registerFunc(const char *name, TLuaWrappedFunction function);
|
||||
// @}
|
||||
|
||||
|
||||
/// \name Script execution
|
||||
// @{
|
||||
|
||||
/** Parse a script and push as a function in top of the LUA stack
|
||||
* \throw ELuaParseError
|
||||
* \param dbgSrc is a string for debug. Should be a filename (preceded with '@'), or a short script.
|
||||
*/
|
||||
void loadScript(const std::string &code, const std::string &dbgSrc);
|
||||
|
||||
/** Execute a script from a string, possibly throwing an exception if there's a parse error
|
||||
* \throw ELuaParseError, ELuaExecuteError
|
||||
*/
|
||||
void executeScript(const std::string &code, int numRet = 0);
|
||||
|
||||
/** Execute a script from a string. If an errors occurs it is printed in the log
|
||||
* \return true if script execution was successful
|
||||
*/
|
||||
bool executeScriptNoThrow(const std::string &code, int numRet = 0);
|
||||
|
||||
/** Load a Script from a File (maybe in a BNP), and execute it
|
||||
* \return false if file not found
|
||||
* \throw ELuaParseError, ELuaExecuteError
|
||||
*/
|
||||
bool executeFile(const std::string &pathName);
|
||||
|
||||
/** execute a very Small Script (a function call for instance)
|
||||
* It is different from doString() in such there is a cache (where the key is the script itself)
|
||||
* so that the second time this script is executed, there is no parsing
|
||||
* Note: I experienced optim with about 10 times faster than a executeScript() on a simple "a= a+1;" script
|
||||
* \throw ELuaParseError, ELuaExecuteError
|
||||
*/
|
||||
void executeSmallScript(const std::string &script);
|
||||
|
||||
// @}
|
||||
|
||||
|
||||
/// \name Stack Manipulation
|
||||
// @{
|
||||
// stack manipulation (indices start at 1)
|
||||
void setTop(int index); // set new size of stack
|
||||
void clear() { setTop(0); }
|
||||
int getTop();
|
||||
bool empty() { return getTop() == 0; }
|
||||
void pushValue(int index); // copie nth element of stack to the top of the stack
|
||||
void remove(int index); // remove nth element of stack
|
||||
void insert(int index); // insert last element of the stack before the given position
|
||||
void replace(int index); // replace nth element of the stack with the top of the stack
|
||||
void pop(int numElem = 1); // remove n elements from the top of the stack
|
||||
// test the type of an element in the stack
|
||||
// return one of the following values :
|
||||
// LUA_TNIL
|
||||
// LUA_TNUMBER
|
||||
// LUA_TBOOLEAN
|
||||
// LUA_TSTRING
|
||||
// LUA_TTABLE
|
||||
// LUA_TFUNCTION
|
||||
// LUA_TUSERDATA
|
||||
// LUA_TTHREAD
|
||||
// LUA_TLIGHTUSERDATA
|
||||
int type(int index = -1);
|
||||
const char *getTypename(int type);
|
||||
bool isNil(int index = -1);
|
||||
bool isBoolean(int index = -1);
|
||||
bool isNumber(int index = -1);
|
||||
bool isString(int index = -1);
|
||||
bool isTable(int index = -1);
|
||||
bool isFunction(int index = -1);
|
||||
bool isCFunction(int index = -1);
|
||||
bool isUserData(int index = -1);
|
||||
bool isLightUserData(int index = -1);
|
||||
// converting then getting a value from the stack
|
||||
bool toBoolean(int index = -1);
|
||||
lua_Number toNumber(int index = -1);
|
||||
const char *toString(int index = -1);
|
||||
void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
|
||||
size_t strlen(int index = -1);
|
||||
lua_CFunction toCFunction(int index = -1);
|
||||
void *toUserData(int index = -1);
|
||||
const void *toPointer(int index = -1);
|
||||
/** Helper functions : get value of the wanted type in the top table after conversion
|
||||
* A default value is used if the stack entry is NULL.
|
||||
* If conversion fails then an exception is thrown (with optional msg)
|
||||
*/
|
||||
bool getTableBooleanValue(const char *name, bool defaultValue= false);
|
||||
double getTableNumberValue(const char *name, double defaultValue= 0);
|
||||
const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
|
||||
// pushing value onto the stack
|
||||
void push(bool value);
|
||||
void push(lua_Number value);
|
||||
void push(const char *str);
|
||||
void push(const char *str, int length);
|
||||
void push(const std::string &str);
|
||||
void pushNil();
|
||||
void push(lua_CFunction f);
|
||||
void push(TLuaWrappedFunction function);
|
||||
void pushLightUserData(void *); // push a light user data (use newUserData to push a full userdata)
|
||||
// metatables
|
||||
bool getMetaTable(int index = -1);
|
||||
bool setMetaTable(int index = -1); // set the metatable at top of stack to the object at 'index' (usually -2), then pop the metatable
|
||||
// even if asignment failed
|
||||
// comparison
|
||||
bool equal(int index1, int index2);
|
||||
bool rawEqual(int index1, int index2);
|
||||
bool lessThan(int index1, int index2);
|
||||
// concatenation of the n element at the top of the stack (using lua semantic)
|
||||
void concat(int numElem);
|
||||
// tables
|
||||
void newTable(); // create a new table at top of the stack
|
||||
void getTable(int index); // get value from a table at index 'index' (key is at top)
|
||||
void rawGet(int index);
|
||||
void setTable(int index); // set (key, value) from top of the stack into the given table
|
||||
// both key and value are poped
|
||||
void rawSet(int index);
|
||||
bool next(int index); // table traversal
|
||||
// UserData
|
||||
void *newUserData(uint size);
|
||||
// seting value by int index in a table
|
||||
void rawSetI(int index, int n);
|
||||
void rawGetI(int index, int n);
|
||||
/** Calling functions (it's up to the caller to clear the results)
|
||||
* The function should have been pushed on the stack
|
||||
*/
|
||||
void call(int nargs, int nresults);
|
||||
int pcall(int nargs, int nresults, int errfunc = 0);
|
||||
/** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex'
|
||||
* the behaviour is the same than with call of pcall.
|
||||
*/
|
||||
int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex = LUA_GLOBALSINDEX, int errfunc = 0);
|
||||
|
||||
// push a C closure (pop n element from the stack and associate with the function)
|
||||
void pushCClosure(lua_CFunction function, int n);
|
||||
// @}
|
||||
|
||||
|
||||
/// \name Misc
|
||||
// @{
|
||||
/** Retrieve pointer to a CLuaState environment from its lua_State pointer, or NULL
|
||||
* if there no such environment
|
||||
*/
|
||||
static CLuaState *fromStatePointer(lua_State *state);
|
||||
// Get state pointer. The state should not be closed (this object has ownership)
|
||||
lua_State *getStatePointer() const {return _State;}
|
||||
// check that an index is valid when accessing the stack
|
||||
// an assertion is raised if the index is not valid
|
||||
void checkIndex(int index);
|
||||
|
||||
// registering C function to use with a lua state pointer
|
||||
void registerFunc(const char *name, lua_CFunction function);
|
||||
|
||||
// Garbage collector
|
||||
int getGCCount(); // get memory in use in KB
|
||||
int getGCThreshold(); // get max memory in KB
|
||||
void setGCThreshold(int kb); // set max memory in KB (no-op with ref-counted version)
|
||||
|
||||
// handle garbage collector for ref-counted version of lua (no-op with standard version, in which case gc handling is automatic)
|
||||
void handleGC();
|
||||
|
||||
/** For Debug: get the Stack context of execution (filename / line)
|
||||
* \param stackLevel: get the context of execution of the given stackLevel.
|
||||
* 0 for the current function
|
||||
* 1 for the function that called 0
|
||||
* 2 ....
|
||||
* NB: if called from a C function called from LUA, remember that stackLevel 0 is the current function.
|
||||
* Hence if you want to know what LUA context called you, pass stackLevel=1!
|
||||
* \param ret string cleared if any error, else filled with formated FileName / LineNumber
|
||||
*/
|
||||
void getStackContext(std::string &ret, uint stackLevel);
|
||||
// @}
|
||||
|
||||
// for debug : dump the current content of the stack (no recursion)
|
||||
void dumpStack();
|
||||
static void dumpStack(lua_State *ls);
|
||||
void getStackAsString(std::string &dest);
|
||||
|
||||
|
||||
private:
|
||||
lua_State *_State;
|
||||
|
||||
#ifdef LUA_NEVRAX_VERSION
|
||||
int _GCThreshold; // if refcounted gc is used, then garbage collector is handled manually
|
||||
#endif
|
||||
// Small Script Cache
|
||||
uint _SmallScriptPool;
|
||||
typedef std::map<std::string, uint> TSmallScriptCache;
|
||||
TSmallScriptCache _SmallScriptCache;
|
||||
static const char * _NELSmallScriptTableName;
|
||||
|
||||
private:
|
||||
// this object isn't intended to be copied
|
||||
CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); }
|
||||
CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; }
|
||||
|
||||
void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Access to lua function
|
||||
// one should not include lua.h directly because if a debugger is present, lua
|
||||
// function pointer will be taken from a dynamic library.
|
||||
|
||||
|
||||
|
||||
//=============================================================================================
|
||||
// include implementation
|
||||
#define RZ_INCLUDE_LUA_HELPER_INLINE
|
||||
#include "lua_helper_inline.h"
|
||||
#undef RZ_INCLUDE_LUA_HELPER_INLINE
|
||||
|
||||
}
|
||||
|
||||
#endif
|
193
code/nel/include/nel/gui/lua_ihm.h
Normal file
193
code/nel/include/nel/gui/lua_ihm.h
Normal file
|
@ -0,0 +1,193 @@
|
|||
// 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 NL_LUA_IHM_H
|
||||
#define NL_LUA_IHM_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/lua_helper.h"
|
||||
#include "nel/gui/interface_element.h"
|
||||
|
||||
#define IHM_LUA_METATABLE "__ui_metatable"
|
||||
#define IHM_LUA_ENVTABLE "__ui_envtable"
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CPolygon2D;
|
||||
class CVector2f;
|
||||
class CRGBA;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CReflectable;
|
||||
class CReflectedProperty;
|
||||
|
||||
// ***************************************************************************
|
||||
/* Use this Exception for all LUA Error (eg: scripted passes bad number of paramters).
|
||||
* Does not herit from Exception because avoid nlinfo, because sent twice (catch then resent)
|
||||
* This is special to lua and IHM since it works with CLuaStackChecker, and also append to the error msg
|
||||
* the FileName/LineNumber
|
||||
*/
|
||||
class ELuaIHMException : public ELuaWrappedFunctionException
|
||||
{
|
||||
private:
|
||||
static CLuaState *getLuaState();
|
||||
public:
|
||||
ELuaIHMException() : ELuaWrappedFunctionException(getLuaState())
|
||||
{
|
||||
}
|
||||
ELuaIHMException(const std::string &reason) : ELuaWrappedFunctionException(getLuaState(), reason)
|
||||
{
|
||||
}
|
||||
ELuaIHMException(const char *format, ...) : ELuaWrappedFunctionException(getLuaState())
|
||||
{
|
||||
std::string reason;
|
||||
NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize);
|
||||
init(getLuaState(), reason);
|
||||
}
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* Define Functions to export from C to LUA
|
||||
* \author Lionel Berenguier
|
||||
* \author Nevrax France
|
||||
* \date 2004
|
||||
*/
|
||||
class CLuaIHM
|
||||
{
|
||||
public:
|
||||
static void registerAll(CLuaState &ls);
|
||||
|
||||
/** CReflectableInterfaceElement management on stack, stored by a CRefPtr.
|
||||
* May be called as well for ui element, because they derive from CReflectableRefPtrTarget
|
||||
*/
|
||||
static void pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT);
|
||||
static bool isReflectableOnStack(CLuaState &ls, sint index);
|
||||
static CReflectableRefPtrTarget *getReflectableOnStack(CLuaState &ls, sint index);
|
||||
|
||||
|
||||
// ucstring
|
||||
static bool pop(CLuaState &ls, ucstring &dest);
|
||||
static void push(CLuaState &ls, const ucstring &value);
|
||||
static bool isUCStringOnStack(CLuaState &ls, sint index);
|
||||
static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest);
|
||||
|
||||
|
||||
// RGBA
|
||||
static bool pop(CLuaState &ls, NLMISC::CRGBA &dest);
|
||||
|
||||
// CVector2f
|
||||
static bool pop(CLuaState &ls, NLMISC::CVector2f &dest);
|
||||
|
||||
// helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail)
|
||||
static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest);
|
||||
|
||||
// argument checkin helpers
|
||||
static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required
|
||||
static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required
|
||||
static void checkArgMax(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at most the one required
|
||||
static void check(CLuaState &ls, bool ok, const std::string &failReason);
|
||||
static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType);
|
||||
static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index);
|
||||
static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index);
|
||||
/** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack
|
||||
* The various check... function call this function when their test fails
|
||||
*/
|
||||
static void fails(CLuaState &ls, const char *format, ...);
|
||||
|
||||
// pop a sint32 from a lua stack, throw an exception on fail
|
||||
static bool popSINT32(CLuaState &ls, sint32 & dest);
|
||||
bool popString(CLuaState &ls, std::string & dest);
|
||||
|
||||
/** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object
|
||||
* (throws on error)
|
||||
*/
|
||||
static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException);
|
||||
|
||||
// push a reflected property on the stack
|
||||
// NB : no check is done that 'property' is part of the class info of 'reflectedObject'
|
||||
static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property);
|
||||
|
||||
private:
|
||||
// Functions for the ui metatable
|
||||
static class CInterfaceElement* getUIRelative( CInterfaceElement *pIE, const std::string &propName );
|
||||
static int luaUIIndex( CLuaState &ls );
|
||||
static int luaUINewIndex( CLuaState &ls );
|
||||
static int luaUIEq( CLuaState &ls );
|
||||
static int luaUINext( CLuaState &ls );
|
||||
static int luaUIDtor( CLuaState &ls );
|
||||
|
||||
|
||||
static void registerBasics(CLuaState &ls);
|
||||
static void registerIHM(CLuaState &ls);
|
||||
static void createLuaEnumTable(CLuaState &ls, const std::string &str);
|
||||
|
||||
public:
|
||||
static void pushUIOnStack(CLuaState &ls, CInterfaceElement *pIE);
|
||||
static bool isUIOnStack(CLuaState &ls, sint index);
|
||||
static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index);
|
||||
static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index);
|
||||
|
||||
private:
|
||||
|
||||
//////////////////////////////////////////// Exported functions //////////////////////////////////////////////////////
|
||||
|
||||
static uint32 getLocalTime();
|
||||
static double getPreciseLocalTime();
|
||||
static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace);
|
||||
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace);
|
||||
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace);
|
||||
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace);
|
||||
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int luaMethodCall(lua_State *ls);
|
||||
|
||||
static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none
|
||||
static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none
|
||||
static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none
|
||||
static int setCaptureKeyboard(CLuaState &ls);
|
||||
static int resetCaptureKeyboard(CLuaState &ls);
|
||||
static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error)
|
||||
static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none
|
||||
static int getWindowSize(CLuaState &ls);
|
||||
static int setTopWindow(CLuaState &ls); // set the top window
|
||||
static int getTextureSize(CLuaState &ls);
|
||||
static int disableModalWindow(CLuaState &ls);
|
||||
static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none
|
||||
static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none
|
||||
static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none)
|
||||
static bool fileExists(const std::string &fileName);
|
||||
static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct
|
||||
static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString
|
||||
static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString
|
||||
static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false
|
||||
static int isUCString(CLuaState &ls);
|
||||
static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ...
|
||||
static int concatString(CLuaState &ls); // speedup concatenation of several strings
|
||||
static int tableToString(CLuaState &ls); // concat element of a table to build a string
|
||||
static int getPathContent(CLuaState &ls);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_LUA_IHM_H
|
||||
|
||||
/* End of lua_ihm.h */
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
#include <lualib.h>
|
||||
#include <lua/lua.h>
|
||||
#include <lua/lauxlib.h>
|
||||
#include <lua/lualib.h>
|
||||
}
|
||||
|
||||
// load the lua dll, return 1 on success
|
78
code/nel/include/nel/gui/lua_manager.h
Normal file
78
code/nel/include/nel/gui/lua_manager.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
// 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 LUA_MANAGER_H
|
||||
#define LUA_MANAGER_H
|
||||
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CLuaState;
|
||||
|
||||
/**
|
||||
Lua Manager
|
||||
|
||||
Provides a single global access point to the Lua state, and related stuff. :(
|
||||
*/
|
||||
class CLuaManager
|
||||
{
|
||||
public:
|
||||
~CLuaManager();
|
||||
|
||||
static CLuaManager& getInstance()
|
||||
{
|
||||
if( instance == NULL )
|
||||
{
|
||||
instance = new CLuaManager();
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
|
||||
/// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
|
||||
static void enableLuaDebugging(){ debugLua = true; }
|
||||
|
||||
/// Returns the Lua state.
|
||||
NLGUI::CLuaState* getLuaState() const{ return luaState; }
|
||||
|
||||
/**
|
||||
Executes a Lua script
|
||||
@param luaScript - the script we want to execute ( the actual script, not the filename! )
|
||||
@param smallScript - true if the script is very small, so it can be cached for the possible next execution.
|
||||
*/
|
||||
bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
|
||||
|
||||
/// Resets the Lua state, that is deallocates it and allocates a new one.
|
||||
void ResetLuaState();
|
||||
|
||||
/// Forces the Garbage Collector to run.
|
||||
void forceGarbageCollect();
|
||||
|
||||
static void setEditorMode( bool b ){ editorMode = b; }
|
||||
|
||||
private:
|
||||
CLuaManager();
|
||||
|
||||
static CLuaManager *instance;
|
||||
static bool debugLua;
|
||||
static bool editorMode;
|
||||
|
||||
NLGUI::CLuaState *luaState;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
303
code/nel/include/nel/gui/lua_object.h
Normal file
303
code/nel/include/nel/gui/lua_object.h
Normal file
|
@ -0,0 +1,303 @@
|
|||
// 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 RZ_LUA_OBJECT
|
||||
#define RZ_LUA_OBJECT
|
||||
|
||||
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/gui/lua_helper.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CLuaEnumeration;
|
||||
|
||||
/**
|
||||
* Wrapper to a lua value
|
||||
*
|
||||
* Useful to navigate through lua tables without having to deal with the stack.
|
||||
*
|
||||
* The following types are tracked by reference :
|
||||
* - lua table
|
||||
* - lua user data
|
||||
* - lua functions
|
||||
*
|
||||
* The following types are kept by value :
|
||||
*
|
||||
* - lua numbers
|
||||
* - lua strings ?
|
||||
* - lua boolean
|
||||
* - lua light user datas
|
||||
* - lua 'pointers'
|
||||
*
|
||||
* Each reference object has an id giving its path in order to track bugs more easily
|
||||
*/
|
||||
class CLuaObject
|
||||
{
|
||||
public:
|
||||
CLuaObject() {}
|
||||
~CLuaObject();
|
||||
// Build this object by popping it from the given lua state
|
||||
CLuaObject(CLuaState &state, const char *id ="");
|
||||
CLuaObject(CLuaState &state, const std::string &id);
|
||||
// Build this object from another object
|
||||
CLuaObject(const CLuaObject &other);
|
||||
// Copy refrence to another lua object
|
||||
CLuaObject &operator=(const CLuaObject &other);
|
||||
// Get id for that object
|
||||
const std::string &getId() const { return _Id; }
|
||||
// Set id for that object
|
||||
void setId(const std::string &id) { _Id = id; }
|
||||
// See if the obj
|
||||
bool isValid() const;
|
||||
// Pop a new value for this lua object from the top of the stack. The stack must not be empty
|
||||
void pop(CLuaState &luaState, const char *id ="");
|
||||
// Push the object that is being referenced on the stack
|
||||
// An assertion is raised if 'pop' hasn't been called or
|
||||
// if the lua state has been destroyed
|
||||
void push() const;
|
||||
// Get the lua state in which the object resides.
|
||||
CLuaState *getLuaState() const;
|
||||
// Release the object. 'pop' must be called to make the object valid again
|
||||
void release();
|
||||
// type queries
|
||||
int type() const;
|
||||
const char *getTypename() const;
|
||||
bool isNil() const;
|
||||
bool isNumber() const;
|
||||
bool isBoolean() const;
|
||||
bool isString() const;
|
||||
bool isFunction() const;
|
||||
bool isCFunction() const;
|
||||
bool isTable() const;
|
||||
bool isUserData() const;
|
||||
bool isLightUserData() const;
|
||||
bool isRGBA() const;
|
||||
// equality
|
||||
bool rawEqual(const CLuaObject &other) const;
|
||||
// conversions (no throw) : the actual value of object is not modified!!
|
||||
NLMISC::CRGBA toRGBA() const; // default to black if not a crgba
|
||||
bool toBoolean() const;
|
||||
lua_Number toNumber() const;
|
||||
std::string toString() const;
|
||||
lua_CFunction toCFunction() const;
|
||||
void *toUserData() const;
|
||||
const void *toPointer() const;
|
||||
// implicit conversions (no throw)
|
||||
operator bool() const;
|
||||
operator float() const;
|
||||
operator double() const;
|
||||
operator std::string() const;
|
||||
/** create a sub table for this object, with a string as a key
|
||||
* This object must be a table or an exception if thrown
|
||||
*/
|
||||
CLuaObject newTable(const char *tableName) throw(ELuaNotATable);
|
||||
|
||||
|
||||
/** Set a value in a table.
|
||||
* If this object is not a table then an exception is thrown
|
||||
* NB : value should came from the same lua environment
|
||||
* \TODO other type of keys
|
||||
*/
|
||||
void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable);
|
||||
void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
|
||||
void setValue(const char *key, const std::string &value) throw(ELuaNotATable);
|
||||
void setValue(const char *key, const char *value) throw(ELuaNotATable);
|
||||
void setValue(const char *key, bool value) throw(ELuaNotATable);
|
||||
void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable);
|
||||
void setValue(const char *key, double value) throw(ELuaNotATable);
|
||||
void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
|
||||
void setNil(const char *key) throw(ELuaNotATable);
|
||||
void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); }
|
||||
/** Erase a value in a table by its key.
|
||||
* If this object is not a table then an exception is thrown.
|
||||
* \TODO other type of keys
|
||||
*/
|
||||
void eraseValue(const char *key) throw(ELuaNotATable);
|
||||
void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); }
|
||||
// test is this object is enumerable
|
||||
bool isEnumerable() const;
|
||||
// Enumeration of a table. If the object is not a table, an exception is thrown.
|
||||
CLuaEnumeration enumerate() throw(ELuaNotATable);
|
||||
// retrieve metatable of an object (or nil if object has no metatable)
|
||||
CLuaObject getMetaTable() const;
|
||||
// set metatable for this object
|
||||
bool setMetaTable(CLuaObject &metatable);
|
||||
/** Access to a sub element of a table (no throw).
|
||||
* if the element is not a table, then 'nil' is returned
|
||||
* TODO nico : add other key types if needed
|
||||
* TODO nico : version that takes destination object as a reference in its parameter to avoid an object copy
|
||||
*/
|
||||
CLuaObject operator[](double key) const;
|
||||
CLuaObject operator[](const char *key) const;
|
||||
CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); }
|
||||
/** Checked access to a sub element of a table. An exception is thrown is the element is not a table.
|
||||
*/
|
||||
CLuaObject at(const char *key) const throw (ELuaNotATable);
|
||||
CLuaObject at(const std::string &key) const { return at(key.c_str()); }
|
||||
|
||||
// Test is that table has the given key. The object must be a table or an exception is thrown
|
||||
bool hasKey(const char *key) const;
|
||||
|
||||
/** debug : recursively get value (useful for table)
|
||||
* \param maxDepth (0 for no limit)
|
||||
* \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered)
|
||||
*/
|
||||
std::string toStringRecurse(uint depth = 0, uint maxDepth = 20, std::set<const void *> *alreadySeen = NULL) const;
|
||||
|
||||
/** dump the value in the log (includes tables)
|
||||
* \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered)
|
||||
*/
|
||||
void dump(uint maxDepth = 20, std::set<const void *> *alreadySeen = NULL) const;
|
||||
// concatenate identifiers, adding a dot between them if necessary. If right is a number then brackets are added
|
||||
static std::string concatId(const std::string &left, const std::string &right);
|
||||
// If this object is a function, then call it and return true on success
|
||||
bool callNoThrow(int numArgs, int numRet);
|
||||
// Call a method of this table by name (no throw version)
|
||||
bool callMethodByNameNoThrow(const char *name, int numArgs, int numRet);
|
||||
private:
|
||||
NLMISC::CRefPtr<CLuaState> _LuaState;
|
||||
std::string _Id;
|
||||
};
|
||||
|
||||
|
||||
/** enumeration of the content of a lua table
|
||||
*
|
||||
* Example of use :
|
||||
*
|
||||
*\code
|
||||
CLuaObject table;
|
||||
table.pop(luaState); // retrieve table from the top of a lua stack
|
||||
CLuaEnumeration enueration = table.enumerate();
|
||||
while (enumeration.hasNext())
|
||||
{
|
||||
nlinfo('key = %s", enumeration.nextKey().toString().c_str());
|
||||
nlinfo('value = %s", enumeration.nextValue().toString().c_str());
|
||||
enumeration.next();
|
||||
};
|
||||
\endcode
|
||||
*
|
||||
* There is a macro called 'ENUM_LUA_TABLE' to automate that process.
|
||||
* Previous code would then be written as follow :
|
||||
*
|
||||
*
|
||||
*\code
|
||||
CLuaObject table;
|
||||
table.pop(luaState); // retrieve table from the top of a lua stack
|
||||
ENUM_LUA_TABLE(table, enumeration);
|
||||
{
|
||||
nlinfo('key = %s", enumeration.nextKey().toString().c_str());
|
||||
nlinfo('value = %s", enumeration.nextValue().toString().c_str());
|
||||
};
|
||||
\endcode
|
||||
*
|
||||
*/
|
||||
class CLuaEnumeration
|
||||
{
|
||||
public:
|
||||
// is there a next key,value pair in the table
|
||||
bool hasNext() { return _HasNext; }
|
||||
// Return next key. Assertion if 'hasNext' is false
|
||||
const CLuaObject &nextKey() const;
|
||||
// Return next value. Assertion if 'hasNext' is false
|
||||
CLuaObject &nextValue();
|
||||
// Go to the next value. Assertion if there's no such value
|
||||
void next();
|
||||
private:
|
||||
friend class CLuaObject;
|
||||
// current value & key
|
||||
CLuaObject _Table;
|
||||
CLuaObject _Key;
|
||||
CLuaObject _Value;
|
||||
CLuaObject _NextFunction; // pointer to the global 'next' function
|
||||
bool _HasNext;
|
||||
// construction from a table on the stack
|
||||
CLuaEnumeration(CLuaObject &table);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/** macro to ease lua table enumeration
|
||||
* \param object A CLuaObject which must be a table, and on which enumeration is done. An exception will be thrown as 'CLuaObject::enumerate' is
|
||||
* called if this is not the case
|
||||
* \param enumerator The enumerator object
|
||||
*/
|
||||
#define ENUM_LUA_TABLE(object, enumerator) for(CLuaEnumeration enumerator = (object).enumerate(); enumerator.hasNext(); enumerator.next())
|
||||
|
||||
|
||||
//opitmized lua string for fast comparison
|
||||
class CLuaString
|
||||
{
|
||||
public:
|
||||
explicit CLuaString(const char *value = "")
|
||||
{
|
||||
nlassert( value != NULL );
|
||||
_Str = value;
|
||||
}
|
||||
const std::string& getStr() const{ return _Str; }
|
||||
private:
|
||||
std::string _Str;
|
||||
mutable CLuaState::TRefPtr _LuaState; // ref ptr so that statics get rebuilt on lua restart
|
||||
mutable CLuaObject _InLua;
|
||||
};
|
||||
|
||||
inline bool operator==(const char* lh, const CLuaString& rh)
|
||||
{
|
||||
return std::string(lh) == rh.getStr();
|
||||
}
|
||||
|
||||
inline bool operator==( const CLuaString& lh, const CLuaString& rh)
|
||||
{
|
||||
return lh.getStr() == rh.getStr();
|
||||
}
|
||||
|
||||
inline bool operator==(const CLuaString& lh, const char* rh)
|
||||
{
|
||||
return std::string(rh) == lh.getStr();
|
||||
}
|
||||
|
||||
inline bool operator==( const CLuaString& lh, const std::string& rh)
|
||||
{
|
||||
return lh.getStr() == rh;
|
||||
}
|
||||
|
||||
inline bool operator==(const std::string& lh, const CLuaString& rh)
|
||||
{
|
||||
return lh == rh.getStr();
|
||||
}
|
||||
|
||||
class CLuaHashMapTraits
|
||||
{
|
||||
public:
|
||||
static const size_t bucket_size = 4;
|
||||
static const size_t min_buckets = 8;
|
||||
CLuaHashMapTraits()
|
||||
{}
|
||||
|
||||
// hasher for lua string -> they are unique pointers for each string, so just hash a pointer instead of a string...
|
||||
size_t operator()(const char *value) const { return ((size_t) value) >> 3; }
|
||||
|
||||
// equality for lua string for hash_map -> they are unique pointer -> compare pointers instead of string content
|
||||
bool operator()(const char *lhs, const char *rhs) const { return lhs < rhs; }
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
93
code/nel/include/nel/gui/parser.h
Normal file
93
code/nel/include/nel/gui/parser.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
// 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 PARSER_H
|
||||
#define PARSER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/proc.h"
|
||||
#include "nel/gui/link_data.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CInterfaceElement;
|
||||
class CInterfaceGroup;
|
||||
class CInterfaceAnim;
|
||||
class CCtrlSheetSelection;
|
||||
class CInterfaceLink;
|
||||
|
||||
/// Interface for the GUI XML parser class.
|
||||
class IParser
|
||||
{
|
||||
public:
|
||||
IParser();
|
||||
virtual ~IParser();
|
||||
|
||||
static IParser* createParser();
|
||||
|
||||
virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
|
||||
virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
|
||||
virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
|
||||
virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0;
|
||||
virtual std::string getParentPosAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getParentSizeAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const = 0;
|
||||
virtual std::string getLuaClassAssociation( CInterfaceGroup *group ) const = 0;
|
||||
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0;
|
||||
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
|
||||
virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
|
||||
virtual uint getProcedureNumActions( const std::string &procName ) const = 0;
|
||||
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;
|
||||
virtual const TProcedureMap& getProcMap() const = 0;
|
||||
virtual bool parseInterface( const std::vector< std::string > &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false ) = 0;
|
||||
virtual void initLUA() = 0;
|
||||
virtual void uninitLUA() = 0;
|
||||
virtual bool isLuaInitialized() const = 0;
|
||||
virtual bool loadLUA( const std::string &luaFile, std::string &error ) = 0;
|
||||
virtual void reloadAllLuaFileScripts() = 0;
|
||||
virtual void removeAllTemplates() = 0;
|
||||
virtual bool solveDefine( const std::string &propVal, std::string &newPropVal, std::string &defError ) = 0;
|
||||
virtual CInterfaceElement* createUIElement( const std::string &templateName, const std::string &parentID, const std::pair< std::string,std::string> *templateParams, uint numParams, bool updateLinks ) = 0;
|
||||
virtual CInterfaceElement* createUIElement( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
|
||||
virtual bool isDefineExist( const std::string &id ) const = 0;
|
||||
virtual CCtrlSheetSelection &getCtrlSheetSelection() = 0;
|
||||
virtual bool addLink( CInterfaceLink *link, const std::string &id ) = 0;
|
||||
virtual bool removeLink( const std::string &id ) = 0;
|
||||
virtual void removeAll() = 0;
|
||||
virtual bool hasProc( const std::string &name ) const = 0;
|
||||
virtual bool addProc( const std::string &name ) = 0;
|
||||
virtual bool removeProc( const std::string &name ) = 0;
|
||||
virtual void setEditorMode( bool b ) = 0;
|
||||
virtual const std::map< uint32, SLinkData >& getLinkMap() const = 0;
|
||||
virtual uint32 addLinkData( SLinkData &linkData ) = 0;
|
||||
virtual void removeLinkData( uint32 id ) = 0;
|
||||
virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0;
|
||||
virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0;
|
||||
virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0;
|
||||
virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0;
|
||||
virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0;
|
||||
virtual bool serializeKeySettings( xmlNodePtr parentNode ) const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
150
code/nel/include/nel/gui/proc.h
Normal file
150
code/nel/include/nel/gui/proc.h
Normal file
|
@ -0,0 +1,150 @@
|
|||
// 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>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
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;
|
||||
std::string Parameters;
|
||||
std::string Conditions;
|
||||
|
||||
// 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 CActionNameIs
|
||||
{
|
||||
public:
|
||||
CActionNameIs( const std::string &n )
|
||||
{
|
||||
name = n;
|
||||
}
|
||||
|
||||
bool operator()( const CProcAction &action )
|
||||
{
|
||||
if( action.Action == name )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
};
|
||||
|
||||
|
||||
class CProcedure
|
||||
{
|
||||
public:
|
||||
// List of the actions
|
||||
std::vector< CProcAction > Actions;
|
||||
|
||||
bool hasAction( const std::string &name ) const
|
||||
{
|
||||
std::vector< CProcAction >::const_iterator itr
|
||||
= std::find_if( Actions.begin(), Actions.end(), CActionNameIs( name ) );
|
||||
if( itr != Actions.end() )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool swap( uint32 i1, uint32 i2 )
|
||||
{
|
||||
if( i1 == i2 )
|
||||
return false;
|
||||
if( i1 >= Actions.size() )
|
||||
return false;
|
||||
if( i2 >= Actions.size() )
|
||||
return false;
|
||||
|
||||
CProcAction a = Actions[ i1 ];
|
||||
Actions[ i1 ] = Actions[ i2 ];
|
||||
Actions[ i2 ] = a;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool addAction( const std::string &name )
|
||||
{
|
||||
Actions.push_back( CProcAction() );
|
||||
Actions.back().Action = name;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeAction( uint32 i )
|
||||
{
|
||||
if( i >= Actions.size() )
|
||||
return false;
|
||||
std::vector< CProcAction >::iterator itr = Actions.begin() + i;
|
||||
Actions.erase( itr );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef std::map< std::string, CProcedure > TProcedureMap;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
368
code/nel/include/nel/gui/reflect.h
Normal file
368
code/nel/include/nel/gui/reflect.h
Normal file
|
@ -0,0 +1,368 @@
|
|||
// 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 CL_REFLECT_H
|
||||
#define CL_REFLECT_H
|
||||
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/gui/lua_object.h"
|
||||
#include <string>
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CReflectable;
|
||||
class CLuaState;
|
||||
struct CClassInfo;
|
||||
|
||||
/** A property of a reflectable object
|
||||
* NB: multiple inheritance not supported
|
||||
*/
|
||||
class CReflectedProperty
|
||||
{
|
||||
public:
|
||||
enum TType { Boolean = 0,
|
||||
SInt32,
|
||||
UInt32,
|
||||
Float,
|
||||
String,
|
||||
UCString,
|
||||
RGBA,
|
||||
LuaMethod
|
||||
}; // other types will be added when needed
|
||||
// define some pointer-to-member types
|
||||
typedef bool (CReflectable::* TGetBool) () const;
|
||||
typedef sint32 (CReflectable::* TGetSInt32) () const;
|
||||
typedef uint32 (CReflectable::* TGetUInt32) () const;
|
||||
typedef float (CReflectable::* TGetFloat) () const;
|
||||
typedef std::string (CReflectable::* TGetString) () const;
|
||||
typedef ucstring (CReflectable::* TGetUCString) () const;
|
||||
typedef NLMISC::CRGBA (CReflectable::* TGetRGBA) () const;
|
||||
//
|
||||
typedef void (CReflectable::* TSetBool) (bool);
|
||||
typedef void (CReflectable::* TSetSInt32) (sint32);
|
||||
typedef void (CReflectable::* TSetUInt32) (uint32);
|
||||
typedef void (CReflectable::* TSetFloat) (float);
|
||||
typedef void (CReflectable::* TSetString) (const std::string &);
|
||||
typedef void (CReflectable::* TSetUCString) (const ucstring &);
|
||||
typedef void (CReflectable::* TSetRGBA) (NLMISC::CRGBA col);
|
||||
//
|
||||
typedef int (CReflectable:: *TLuaMethod) (CLuaState &luaState);
|
||||
|
||||
public:
|
||||
TType Type;
|
||||
// In each union we have method pointers to retrieve / set the data of the desired type (as told in 'Type')
|
||||
union
|
||||
{
|
||||
TGetBool GetBool;
|
||||
TGetSInt32 GetSInt32;
|
||||
TGetUInt32 GetUInt32;
|
||||
TGetFloat GetFloat;
|
||||
TGetString GetString;
|
||||
TGetUCString GetUCString;
|
||||
TGetRGBA GetRGBA;
|
||||
TLuaMethod GetLuaMethod; // lua method can only be obtained, not written ...
|
||||
} GetMethod;
|
||||
union
|
||||
{
|
||||
TSetBool SetBool;
|
||||
TSetSInt32 SetSInt32;
|
||||
TSetUInt32 SetUInt32;
|
||||
TSetFloat SetFloat;
|
||||
TSetString SetString;
|
||||
TSetUCString SetUCString;
|
||||
TSetRGBA SetRGBA;
|
||||
} SetMethod;
|
||||
// name of the property
|
||||
std::string Name;
|
||||
mutable CLuaObject LuaMethodRef; // cache pointer to function call if type == LuaMethod
|
||||
const CClassInfo *ParentClass; // filled when 'registerClass' is called
|
||||
};
|
||||
|
||||
// a vector of reflected properties
|
||||
typedef std::vector<CReflectedProperty> TReflectedProperties;
|
||||
|
||||
|
||||
struct CClassInfo;
|
||||
|
||||
/** Base class for a reflectable object
|
||||
* NB: multiple inheritance not supported
|
||||
*/
|
||||
class CReflectable
|
||||
{
|
||||
public:
|
||||
virtual ~CReflectable() {}
|
||||
virtual const char *getReflectedClassName() const { return "CReflectable"; }
|
||||
virtual const char *getRflectedParentClassName() const { return ""; }
|
||||
|
||||
/** When registering classes, the reflect system will call this function on each class
|
||||
* to know which properties they exports.
|
||||
* To defines which properties are exported use the REFLECT_EXPORT_** macros.
|
||||
* By doing so, a new 'getReflectedProperties' function will be defined
|
||||
*/
|
||||
static void getReflectedProperties(TReflectedProperties &/* props */)
|
||||
{
|
||||
}
|
||||
// get class infos for this reflectable object
|
||||
const CClassInfo *getClassInfo();
|
||||
|
||||
/** get a property from this object by name
|
||||
* TODO nico : optimized version for lua string (found in CLuaIHM) would maybe fit better here ...
|
||||
*/
|
||||
const CReflectedProperty *getReflectedProperty(const std::string &propertyName, bool dspWarning= true) const;
|
||||
};
|
||||
|
||||
struct CLuaIndexedProperty
|
||||
{
|
||||
const CReflectedProperty *Prop;
|
||||
CLuaString Id; // must keep id here, so that we are sure the string is not gc in lua and its pointer remains valid
|
||||
};
|
||||
|
||||
|
||||
struct CClassInfo
|
||||
{
|
||||
TReflectedProperties Properties; // the properties exported by this class
|
||||
const CClassInfo *ParentClass; // pointer to infos of the parent class, or NULL if it is a root class
|
||||
std::string ClassName;
|
||||
/** For lua speedup (used by CLuaIHM) : because lua string are unique, we can use them to access property directly.
|
||||
*/
|
||||
typedef CHashMap<const char *, CLuaIndexedProperty, CLuaHashMapTraits> TLuaStrToPropMap;
|
||||
mutable TLuaStrToPropMap LuaStrToProp;
|
||||
};
|
||||
|
||||
/** Simple reflection system.
|
||||
* Used by the GUI and some other objects.
|
||||
* It is used to export some properties so that we can easily manipulate them in the GUI scripts (either lua or with CInterfaceExpr).
|
||||
* NB: multiple inheritance not supported
|
||||
*
|
||||
* Example of use : a class exporting a boolean
|
||||
*
|
||||
* class CTestClass : public CReflectable
|
||||
* {
|
||||
* public:
|
||||
* void setValue(bool value) { _Value = value; }
|
||||
* bool getValue() const { return _Value; }
|
||||
* \\ export the bool value
|
||||
* REFLECT_EXPORT_START(CTestClass, CReflectable)
|
||||
* REFLECT_BOOL("myValue", setValue, getValue)
|
||||
* REFLECT_EXPORT_END
|
||||
* private:
|
||||
* bool _Value;
|
||||
* };
|
||||
*
|
||||
* The class must then be registered with :
|
||||
*
|
||||
* REGISTER_REFLECTABLE_CLASS(CTestClass, CReflectable)
|
||||
*
|
||||
* NB: It should be registered after its parents
|
||||
*
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CReflectSystem
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::map<std::string, CClassInfo> TClassMap;
|
||||
|
||||
public:
|
||||
// release memory
|
||||
static void release();
|
||||
|
||||
/** register a class and its properties
|
||||
* NB : class should be registered after their parent have been, or an assertion will be raised
|
||||
*/
|
||||
static void registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties);
|
||||
|
||||
// retrieve a property of a reflectable class, or NULL if unknown
|
||||
static const CReflectedProperty *getProperty(const std::string &className, const std::string &propertyName, bool dspWarning= true);
|
||||
|
||||
// get the list of class for debug or read purpose (NULL if no register has been called)
|
||||
static const TClassMap *getClassMap() {return _ClassMap;}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
static TClassMap *_ClassMap; // each class and its infos
|
||||
};
|
||||
|
||||
|
||||
/** Helper macros to export properties of a reflectable class
|
||||
*/
|
||||
|
||||
/** Start a declaration of a reflectable class exports
|
||||
* Should be placed inside the class
|
||||
*/
|
||||
#define REFLECT_EXPORT_START(className, parentName) \
|
||||
virtual const char *getReflectedClassName() const { return #className; } \
|
||||
virtual const char *getReflectedParentClassName() const { return #parentName; } \
|
||||
static void getReflectedProperties(TReflectedProperties &props) \
|
||||
{ \
|
||||
typedef className A; \
|
||||
typedef bool (className::* TGetBoola) () const; \
|
||||
typedef sint32 (className::* TGetSInt32a) () const; \
|
||||
typedef uint32 (className::* TGetUInt32a) () const; \
|
||||
typedef float (className::* TGetFloata) () const; \
|
||||
typedef std::string (className::* TGetStringa) () const; \
|
||||
typedef ucstring (className::* TGetUCStringa) () const; \
|
||||
typedef NLMISC::CRGBA (className::* TGetRGBAa) () const; \
|
||||
typedef void (className::* TSetBoola) (bool); \
|
||||
typedef void (className::* TSetSInt32a) (sint32); \
|
||||
typedef void (className::* TSetUInt32a) (uint32); \
|
||||
typedef void (className::* TSetFloata) (float); \
|
||||
typedef void (className::* TSetStringa) (const std::string &); \
|
||||
typedef void (className::* TSetUCStringa) (const ucstring &); \
|
||||
typedef void (className::* TSetRGBAa) (NLMISC::CRGBA col); \
|
||||
typedef int (className:: *TLuaMethoda) (CLuaState &luaState); \
|
||||
nlunreferenced(props);
|
||||
|
||||
|
||||
// export a boolean value, by giving the name of the get and the set method
|
||||
#define REFLECT_BOOL(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::Boolean; \
|
||||
prop.GetMethod.GetBool = (CReflectedProperty::TGetBool) (TGetBoola) &A::getMethod; \
|
||||
prop.SetMethod.SetBool = (CReflectedProperty::TSetBool) (TSetBoola) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a sint32 value, by giving the name of the get and the set method
|
||||
#define REFLECT_SINT32(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::SInt32; \
|
||||
prop.GetMethod.GetSInt32 = (CReflectedProperty::TGetSInt32) (TGetSInt32a) &A::getMethod; \
|
||||
prop.SetMethod.SetSInt32 = (CReflectedProperty::TSetSInt32) (TSetSInt32a) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a sint32 value, by giving the name of the get and the set method
|
||||
#define REFLECT_UINT32(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::UInt32; \
|
||||
prop.GetMethod.GetUInt32 = (CReflectedProperty::TGetUInt32) (TGetUInt32a) &A::getMethod; \
|
||||
prop.SetMethod.SetUInt32 = (CReflectedProperty::TSetUInt32) (TSetUInt32a) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a float value, by giving the name of the get and the set method
|
||||
#define REFLECT_FLOAT(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::Float; \
|
||||
prop.GetMethod.GetFloat = (CReflectedProperty::TGetFloat) (TGetFloata) &A::getMethod; \
|
||||
prop.SetMethod.SetFloat = (CReflectedProperty::TSetFloat) (TSetFloata) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a string value, by giving the name of the get and the set method
|
||||
#define REFLECT_STRING(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::String; \
|
||||
prop.GetMethod.GetString = (CReflectedProperty::TGetString) (TGetStringa) &A::getMethod; \
|
||||
prop.SetMethod.SetString = (CReflectedProperty::TSetString) (TSetStringa) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a unicode string value, by giving the name of the get and the set method
|
||||
#define REFLECT_UCSTRING(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::UCString; \
|
||||
prop.GetMethod.GetUCString = (CReflectedProperty::TGetUCString) (TGetUCStringa) &A::getMethod; \
|
||||
prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) (TSetUCStringa) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
|
||||
// export a color value, by giving the name of the get and the set method
|
||||
#define REFLECT_RGBA(exportName, getMethod, setMethod) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::RGBA; \
|
||||
prop.GetMethod.GetRGBA = (CReflectedProperty::TGetRGBA) (TGetRGBAa) &A::getMethod; \
|
||||
prop.SetMethod.SetRGBA = (CReflectedProperty::TSetRGBA) (TSetRGBAa) &A::setMethod; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
// export a lua method
|
||||
#define REFLECT_LUA_METHOD(exportName, method) \
|
||||
{ \
|
||||
CReflectedProperty prop; \
|
||||
prop.Name = exportName; \
|
||||
prop.Type = CReflectedProperty::LuaMethod; \
|
||||
prop.GetMethod.GetLuaMethod = (CReflectedProperty::TLuaMethod) (TLuaMethoda) &A::method; \
|
||||
props.push_back(prop); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ends an export declaration
|
||||
#define REFLECT_EXPORT_END }
|
||||
|
||||
|
||||
// This macro registers a reflectable class to the manager
|
||||
#define REGISTER_REFLECTABLE_CLASS(className, parentName) \
|
||||
{ \
|
||||
TReflectedProperties props; \
|
||||
className::getReflectedProperties(props); \
|
||||
CReflectSystem::registerClass(#className, #parentName, props); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Reflectable refcounted object
|
||||
* NB nico : added this intermediate class so that the binding from lua to the reflection
|
||||
* system that are found in CLuaIHM can be reused for other objects as well
|
||||
* NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount'
|
||||
* because the refcount part is only used for ref pointing in the ui
|
||||
*/
|
||||
class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
virtual ~CReflectableRefPtrTarget();
|
||||
};
|
||||
|
||||
|
||||
class CReflectableLuaRef
|
||||
{
|
||||
public:
|
||||
CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {}
|
||||
NLMISC::CRefPtr<CReflectableRefPtrTarget> Ptr;
|
||||
const CClassInfo &getClassInfo() const;
|
||||
// IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo
|
||||
const CReflectedProperty *getProp(const char *luaStringPtr) const;
|
||||
private:
|
||||
// cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer)
|
||||
mutable const CClassInfo *_ClassInfo;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
32
code/nel/include/nel/gui/reflect_register.h
Normal file
32
code/nel/include/nel/gui/reflect_register.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
// 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 REFLECT_REG_H
|
||||
#define REFLECT_REG_H
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
/// Helper class to register reflectable classes
|
||||
class CReflectableRegister
|
||||
{
|
||||
public:
|
||||
static void registerClasses();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif
|
29
code/nel/include/nel/gui/string_case.h
Normal file
29
code/nel/include/nel/gui/string_case.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef STRING_CASE_H
|
||||
#define STRING_CASE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/ucstring.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
enum TCaseMode
|
||||
{
|
||||
CaseNormal = 0, // Nothing done
|
||||
CaseLower, // All letters in lowercase
|
||||
CaseUpper, // All letters in uppercase
|
||||
CaseFirstStringLetterUp, // The first letter of the string is uppercase, the others are lowercase
|
||||
CaseFirstSentenceLetterUp, // The first letter of the string and each sentences are uppercase, the others are lowercase. Sentences are seprated with '.'.
|
||||
CaseFirstWordLetterUp, // The first letter of each word is uppercase, the others are lowercase
|
||||
CaseCount
|
||||
};
|
||||
|
||||
|
||||
void setCase( ucstring &str, TCaseMode mode );
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
86
code/nel/include/nel/gui/view_base.h
Normal file
86
code/nel/include/nel/gui/view_base.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
// 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 RZ_VIEW_BASE_H
|
||||
#define RZ_VIEW_BASE_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/factory.h"
|
||||
#include "nel/gui/interface_element.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CViewBase : public CInterfaceElement
|
||||
{
|
||||
public:
|
||||
|
||||
// for factory construction
|
||||
struct TCtorParam
|
||||
{};
|
||||
|
||||
/// Constructor
|
||||
CViewBase(const TCtorParam &/* param */) : CInterfaceElement()
|
||||
{
|
||||
}
|
||||
|
||||
/// Destructor
|
||||
virtual ~CViewBase();
|
||||
|
||||
// Returns 'true' if that element can be downcasted to a view
|
||||
virtual bool isView() const { return true; }
|
||||
|
||||
/// Draw the view from XReal, YReal, WReal, HReal (implemented by derived classes)
|
||||
/// this coordinates are relative to the screen bottom left and begins the bottom left of the view
|
||||
virtual void draw () = 0;
|
||||
|
||||
virtual void updateCoords() { CInterfaceElement::updateCoords(); }
|
||||
|
||||
/// Debug
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
/// Reflection
|
||||
virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this
|
||||
virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this
|
||||
|
||||
|
||||
void copyOptionFrom(const CViewBase &other)
|
||||
{
|
||||
CInterfaceElement::copyOptionFrom(other);
|
||||
}
|
||||
|
||||
|
||||
REFLECT_EXPORT_START(CViewBase, CInterfaceElement)
|
||||
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
virtual void dumpSize(uint depth = 0) const;
|
||||
|
||||
// from CInterfaceElement
|
||||
virtual void visit(CInterfaceElementVisitor *visitor);
|
||||
|
||||
// special for mouse over : return true and fill the name of the cursor to display
|
||||
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_VIEW_BASE_H
|
||||
|
||||
/* End of view_base.h */
|
150
code/nel/include/nel/gui/view_bitmap.h
Normal file
150
code/nel/include/nel/gui/view_bitmap.h
Normal file
|
@ -0,0 +1,150 @@
|
|||
// 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 NL_VIEW_BITMAP_H
|
||||
#define NL_VIEW_BITMAP_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/**
|
||||
* class implementing a bitmap view
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewBitmap : public CViewBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS(CViewBitmap)
|
||||
enum EType { Stretched = 0, Tiled, TypeCount };
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
CViewBitmap(const TCtorParam ¶m) : CViewBase(param)
|
||||
{
|
||||
_Color = NLMISC::CRGBA(255,255,255,255);
|
||||
_Scale = false;
|
||||
_Rot = 0;
|
||||
_Flip = false;
|
||||
_Tile = false;
|
||||
_Align = 0;
|
||||
_Type = Stretched;
|
||||
_InheritGCAlpha = false;
|
||||
|
||||
// Default parameters for createTexture
|
||||
_TxtOffsetX = 0;
|
||||
_TxtOffsetY = 0;
|
||||
_TxtWidth = -1;
|
||||
_TxtHeight = -1;
|
||||
}
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/**
|
||||
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse
|
||||
* \param cur : pointer to the xml node to be parsed
|
||||
* \param parentGroup : the parent group of the view
|
||||
* \partam id : a refence to the string that will receive the view ID
|
||||
* \return true if success
|
||||
*/
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
virtual void updateCoords ();
|
||||
|
||||
/// Draw the view
|
||||
virtual void draw ();
|
||||
|
||||
bool getScale() const { return _Scale; }
|
||||
void setScale (bool s) { _Scale = s; }
|
||||
bool getTile() const { return _Tile; }
|
||||
void setTile (bool s) { _Tile = s; }
|
||||
void setColor (const NLMISC::CRGBA &r) { _Color = r; }
|
||||
|
||||
// Reflected
|
||||
|
||||
virtual void setTexture(const std::string & TxName);
|
||||
virtual std::string getTexture () const;
|
||||
|
||||
/** Force the bitmap to match current texture size
|
||||
* The 'scale' flag isnot modified
|
||||
*/
|
||||
void fitTexture();
|
||||
|
||||
bool isTextureValid() const { return _TextureId != -1; }
|
||||
|
||||
void setColorAsString(const std::string & col);
|
||||
std::string getColorAsString() const;
|
||||
|
||||
void setColorAsInt(sint32 col);
|
||||
sint32 getColorAsInt() const;
|
||||
|
||||
void setColorRGBA(NLMISC::CRGBA col);
|
||||
NLMISC::CRGBA getColorRGBA() const;
|
||||
|
||||
virtual sint32 getAlpha() const { return _Color.A; }
|
||||
virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; }
|
||||
|
||||
REFLECT_EXPORT_START(CViewBitmap, CViewBase)
|
||||
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
||||
REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt);
|
||||
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
|
||||
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
||||
REFLECT_STRING ("texture", getTexture, setTexture);
|
||||
REFLECT_BOOL("scale", getScale, setScale);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
/// \from CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
protected:
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
NLMISC::CRGBA _Color;
|
||||
sint32 _Rot;
|
||||
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
|
||||
EType _Type;
|
||||
bool _Scale : 1;
|
||||
bool _Flip : 1;
|
||||
bool _Tile : 1;
|
||||
bool _InheritGCAlpha : 1;
|
||||
|
||||
// For single texture
|
||||
|
||||
sint32 _TxtOffsetX; // Offset X of the single texture
|
||||
sint32 _TxtOffsetY; // Offset Y of the single texture
|
||||
sint32 _TxtWidth; // Width of the single texture
|
||||
sint32 _TxtHeight; // Height of the single texture
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_BITMAP_H
|
||||
|
||||
/* End of view_bitmap.h */
|
183
code/nel/include/nel/gui/view_bitmap_combo.h
Normal file
183
code/nel/include/nel/gui/view_bitmap_combo.h
Normal file
|
@ -0,0 +1,183 @@
|
|||
// 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 NL_VIEW_BITMAP_COMBO_H
|
||||
#define NL_VIEW_BITMAP_COMBO_H
|
||||
|
||||
#include "nel/misc/cdb.h"
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Description of a combo box, this can be parsed from an xml node
|
||||
* The bitmap layout is as follow :
|
||||
*
|
||||
* I W I W I W
|
||||
* t G t G t G
|
||||
* e a e a e a
|
||||
* m p m p m p
|
||||
* W S W W
|
||||
* i e i i
|
||||
* d l d d
|
||||
* t e t t
|
||||
* h c h h
|
||||
* t
|
||||
* e
|
||||
* d
|
||||
* +----+---+----+---+---+---+---+--...
|
||||
* |ssss| |****| |***| |***|
|
||||
* ItemHeight |ssss| |****| |***| |***
|
||||
* +----+---+----+---+---+---+---+--...
|
||||
* | | | | | | | |
|
||||
* HGapSeleted | | | | | | | |
|
||||
* +----+---+----+---+---+---+---+--...
|
||||
* |****| |****| |***| |***|
|
||||
* ItemHeight |****| |****| |***| |***|
|
||||
* +----+---+----+---+---+---+---+--...
|
||||
* | | | | | | | |
|
||||
* HGap | | | | | | | |
|
||||
* +----+---+----+---+---+---+---+--...
|
||||
* |****| |****| |***| |***|
|
||||
* ItemHeight |****| |****| |***| |***|
|
||||
* . . . . . . . .
|
||||
* . . . . . . . .
|
||||
* s : selected item. . . . . . .
|
||||
* * : where bitmap are displayed
|
||||
*/
|
||||
|
||||
|
||||
struct CComboBoxDesc
|
||||
{
|
||||
bool parse(xmlNodePtr cur, CInterfaceElement *owner);
|
||||
void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs);
|
||||
void getGridSize(uint &numRow,uint &numCol) const;
|
||||
void getDimensions(uint &width, uint &height) const;
|
||||
CInterfaceProperty NumRow;
|
||||
CInterfaceProperty NumCol;
|
||||
CInterfaceProperty CurrSelected;
|
||||
CInterfaceProperty ItemWidth;
|
||||
CInterfaceProperty ItemHeight;
|
||||
CInterfaceProperty Unrolled;
|
||||
CInterfaceProperty WGapSelected;
|
||||
CInterfaceProperty WGap;
|
||||
CInterfaceProperty HGapSelected;
|
||||
CInterfaceProperty HGap;
|
||||
CInterfaceProperty NumSel;
|
||||
CInterfaceProperty Align;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A combo box with several bitmaps in it
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver
|
||||
{
|
||||
public:
|
||||
typedef std::vector<sint32> TIdArray;
|
||||
typedef std::vector<std::string> TStringArray;
|
||||
typedef std::vector<NLMISC::CRGBA> TColorArray;
|
||||
public:
|
||||
/// ctor
|
||||
CViewBitmapCombo(const TCtorParam ¶m);
|
||||
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
|
||||
/**
|
||||
* parse an xml node and initialize the base view members. Must call CViewBase::parse
|
||||
* \param cur : pointer to the xml node to be parsed
|
||||
* \param parentGroup : the parent group of the view
|
||||
* \partam id : a refence to the string that will receive the view ID
|
||||
* \return true if success
|
||||
*/
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
/**
|
||||
* draw the view
|
||||
*/
|
||||
void draw();
|
||||
|
||||
// access to texture & colors
|
||||
const TStringArray &getTexs() const { return _Texs; }
|
||||
const TStringArray &getTexsOver() const { return _TexsOver; }
|
||||
const TStringArray &getTexsPushed() const { return _TexsPushed; }
|
||||
//
|
||||
const TColorArray &getColors() const { return _Col; }
|
||||
const TColorArray &getColorsOver() const { return _ColOver; }
|
||||
const TColorArray &getColorsPushed() const { return _ColPushed; }
|
||||
//
|
||||
void setTexs(const char * const tex[], uint numTex);
|
||||
void setTexsOver(const char * const tex[], uint numTex);
|
||||
void setTexsPushed(const char * const tex[], uint numTex);
|
||||
//
|
||||
void setColors(const NLMISC::CRGBA colors[], uint numColors);
|
||||
void setColorsOver(const NLMISC::CRGBA colors[], uint numColors);
|
||||
void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
//
|
||||
TStringArray _Texs;
|
||||
TStringArray _TexsOver;
|
||||
TStringArray _TexsPushed;
|
||||
TIdArray _TexsId;
|
||||
TIdArray _TexsOverId;
|
||||
TIdArray _TexsPushedId;
|
||||
TColorArray _Col;
|
||||
TColorArray _ColOver;
|
||||
TColorArray _ColPushed;
|
||||
CComboBoxDesc _CD;
|
||||
CInterfaceElement *_Owner;
|
||||
private:
|
||||
void parseTexList(const std::string &names, TStringArray &dest);
|
||||
void parseColList(const std::string &names, TColorArray &dest);
|
||||
void getTexList( const TStringArray &arr, std::string &dest ) const;
|
||||
void getColList( const TColorArray &arr, std::string &dest ) const;
|
||||
void setupSize();
|
||||
void getDimensions(uint &numRow, uint &numCol);
|
||||
// From ICDBNode::IPropertyObserver
|
||||
void update(NLMISC::ICDBNode *leaf);
|
||||
// Return a color from the array, or white if it is empty
|
||||
static NLMISC::CRGBA getCol(const TColorArray &array, uint index);
|
||||
static const std::string *getTex(const TStringArray &array, uint index);
|
||||
static sint32 getTexId(const TIdArray &array, uint index);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,56 +1,62 @@
|
|||
// 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 NL_VIEW_LINK_H
|
||||
#define NL_VIEW_LINK_H
|
||||
|
||||
#include "view_text.h"
|
||||
|
||||
/**
|
||||
* class implementing a link view
|
||||
* \author Cyril 'Hulud' Corvazier
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CViewLink : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
// Default constructor
|
||||
CViewLink (const TCtorParam ¶m);
|
||||
|
||||
// The URI
|
||||
std::string Link;
|
||||
|
||||
std::string LinkTitle;
|
||||
|
||||
// Set the main group
|
||||
void setHTMLView(class CGroupHTML *html);
|
||||
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
|
||||
|
||||
protected:
|
||||
|
||||
// The main HTML group
|
||||
CGroupHTML *HTML;
|
||||
};
|
||||
|
||||
|
||||
#endif // NL_VIEW_LINK_H
|
||||
|
||||
/* End of view_link.h */
|
||||
// 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 NL_VIEW_LINK_H
|
||||
#define NL_VIEW_LINK_H
|
||||
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CGroupHTML;
|
||||
|
||||
/**
|
||||
* class implementing a link view
|
||||
* \author Cyril 'Hulud' Corvazier
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2003
|
||||
*/
|
||||
class CViewLink : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
// Default constructor
|
||||
CViewLink (const TCtorParam ¶m);
|
||||
|
||||
// The URI
|
||||
std::string Link;
|
||||
|
||||
std::string LinkTitle;
|
||||
|
||||
// Set the main group
|
||||
void setHTMLView( CGroupHTML *html);
|
||||
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
|
||||
|
||||
protected:
|
||||
|
||||
// The main HTML group
|
||||
CGroupHTML *HTML;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_LINK_H
|
||||
|
||||
/* End of view_link.h */
|
143
code/nel/include/nel/gui/view_pointer.h
Normal file
143
code/nel/include/nel/gui/view_pointer.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
// 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 RZ_VIEW_POINTER_H
|
||||
#define RZ_VIEW_POINTER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/events.h"
|
||||
#include "nel/gui/view_pointer_base.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlBase;
|
||||
class CGroupContainer;
|
||||
|
||||
/**
|
||||
* class describing the pointer
|
||||
* \author Matthieu 'Trap' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class CViewPointer : public CViewPointerBase
|
||||
{
|
||||
|
||||
public:
|
||||
DECLARE_UI_CLASS( CViewPointer )
|
||||
|
||||
CViewPointer( const TCtorParam ¶m );
|
||||
virtual ~CViewPointer(){}
|
||||
|
||||
bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
|
||||
void draw();
|
||||
|
||||
// Set cursor mode
|
||||
void setStringMode (bool stringCursor);
|
||||
bool getStringMode() const {return _StringMode;}
|
||||
|
||||
// Set cursor string
|
||||
void setString (const ucstring &str);
|
||||
|
||||
// TEMP PATCH
|
||||
void setCursor (const std::string &name)
|
||||
{
|
||||
_TxDefault = name;
|
||||
_TxIdDefault = -2;
|
||||
}
|
||||
// TEMP PATCH
|
||||
|
||||
/// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead.
|
||||
void show(bool s) {_PointerVisible = s;}
|
||||
|
||||
static void setHWMouse( bool hw ){ hwMouse = hw; }
|
||||
static void forceLink();
|
||||
|
||||
private:
|
||||
|
||||
/// Drawing helpers
|
||||
virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
|
||||
virtual bool drawCustom(CCtrlBase* pCB);
|
||||
|
||||
protected:
|
||||
|
||||
// Look of the cursor in different situation
|
||||
std::string _TxDefault;
|
||||
std::string _TxMoveWindow;
|
||||
std::string _TxResizeBRTL;
|
||||
std::string _TxResizeBLTR;
|
||||
std::string _TxResizeTB;
|
||||
std::string _TxResizeLR;
|
||||
std::string _TxRotate;
|
||||
std::string _TxScale;
|
||||
std::string _TxColPick;
|
||||
std::string _TxPan;
|
||||
std::string _TxCanPan;
|
||||
std::string _TxPanR2;
|
||||
std::string _TxCanPanR2;
|
||||
|
||||
sint32 _TxIdDefault;
|
||||
sint32 _TxIdMoveWindow;
|
||||
sint32 _TxIdResizeBRTL;
|
||||
sint32 _TxIdResizeBLTR;
|
||||
sint32 _TxIdResizeTB;
|
||||
sint32 _TxIdResizeLR;
|
||||
sint32 _TxIdRotate;
|
||||
sint32 _TxIdScale;
|
||||
sint32 _TxIdColPick;
|
||||
sint32 _TxIdPan;
|
||||
sint32 _TxIdCanPan;
|
||||
sint32 _TxIdPanR2;
|
||||
sint32 _TxIdCanPanR2;
|
||||
|
||||
NLMISC::CRGBA _Color;
|
||||
|
||||
sint32 _OffsetX;
|
||||
sint32 _OffsetY;
|
||||
|
||||
CGroupContainer *_LastHightLight;
|
||||
|
||||
// Cursor mode
|
||||
bool _StringMode;
|
||||
bool _ForceStringMode;
|
||||
CInterfaceGroup *_StringCursor;
|
||||
CInterfaceGroup *_StringCursorHardware;
|
||||
ucstring _ContextString;
|
||||
|
||||
// draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape
|
||||
void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot);
|
||||
|
||||
private:
|
||||
// set the string into frame for software or hardware version
|
||||
void setString (const ucstring &str, CInterfaceGroup *target);
|
||||
|
||||
static bool hwMouse;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RZ_VIEW_POINTER_H
|
||||
|
||||
/* End of view_pointer.h */
|
85
code/nel/include/nel/gui/view_pointer_base.h
Normal file
85
code/nel/include/nel/gui/view_pointer_base.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
// 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 VIEW_POINTER_BASE_H
|
||||
#define VIEW_POINTER_BASE_H
|
||||
|
||||
#include "nel/misc/events.h"
|
||||
#include "nel/gui/view_base.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CViewPointerBase : public CViewBase
|
||||
{
|
||||
public:
|
||||
DECLARE_UI_CLASS( CViewPointerBase )
|
||||
|
||||
CViewPointerBase( const TCtorParam ¶m );
|
||||
virtual ~CViewPointerBase();
|
||||
|
||||
// Set the pointer position.
|
||||
void setPointerPos (sint32 x, sint32 y);
|
||||
void setPointerDispPos (sint32 x, sint32 y);
|
||||
|
||||
void resetPointerPos ();
|
||||
void setPointerDown (bool pd);
|
||||
void setPointerDownString (const std::string &s);
|
||||
|
||||
void getPointerPos (sint32 &x, sint32 &y);
|
||||
void getPointerDispPos (sint32 &x, sint32 &y);
|
||||
|
||||
void getPointerOldPos (sint32 &x, sint32 &y);
|
||||
void getPointerDownPos (sint32 &x, sint32 &y);
|
||||
bool getPointerDown ();
|
||||
std::string getPointerDownString ();
|
||||
bool getPointerDrag ();
|
||||
|
||||
/// Is the pointer visible ?
|
||||
bool show() const {return _PointerVisible;}
|
||||
|
||||
void draw(){}
|
||||
|
||||
/// set button state
|
||||
void setButtonState(NLMISC::TMouseButton state) { _Buttons = state; }
|
||||
/// get buttons state
|
||||
NLMISC::TMouseButton getButtonState() const { return _Buttons; }
|
||||
|
||||
protected:
|
||||
// (x,y) is from the TopLeft corner of the window
|
||||
sint32 _PointerX; // Current pointer position (raw, before snapping)
|
||||
sint32 _PointerY;
|
||||
sint32 _PointerOldX; // Previous frame pointer position
|
||||
sint32 _PointerOldY;
|
||||
bool _PointerDown; // Is the pointer down ?
|
||||
sint32 _PointerDownX; // Pointer down position
|
||||
sint32 _PointerDownY;
|
||||
std::string _PointerDownString; // What is under the pointer at the down position
|
||||
bool _PointerDrag; // Is the pointer down and we have moved ?
|
||||
bool _PointerVisible; // Is the pointer visible or hidden ?
|
||||
|
||||
NLMISC::TMouseButton _Buttons;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
61
code/nel/include/nel/gui/view_polygon.h
Normal file
61
code/nel/include/nel/gui/view_polygon.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// 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 RZ_VIEW_POLYGON_H
|
||||
#define RZ_VIEW_POLYGON_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
#include "nel/misc/geom_ext.h"
|
||||
#include "nel/misc/polygon.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Display of an arbitrary polygon in the ui.
|
||||
* polygon is clipped & batched
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 1/2006
|
||||
*/
|
||||
class CViewPolygon : public CViewBase
|
||||
{
|
||||
public:
|
||||
CViewPolygon();
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
void setVertices(const std::vector<NLMISC::CVector> &vertices);
|
||||
// color
|
||||
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
|
||||
NLMISC::CRGBA getColorRGBA() const { return _Color; }
|
||||
// from CViewBase
|
||||
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
|
||||
virtual void setAlpha (sint32 a);
|
||||
private:
|
||||
NLMISC::CPolygon _Poly;
|
||||
bool _Touched;
|
||||
NLMISC::CRGBA _Color;
|
||||
std::vector<NLMISC::CTriangle> _Tris;
|
||||
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
94
code/nel/include/nel/gui/view_quad.h
Normal file
94
code/nel/include/nel/gui/view_quad.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
// 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 RZ_VIEW_QUAD_H
|
||||
#define RZ_VIEW_QUAD_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
#include "nel/misc/geom_ext.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
|
||||
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
|
||||
* are driven by the quad vertices coordinates (see setQuad)
|
||||
*
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 12/2005
|
||||
*/
|
||||
class CViewQuad : public CViewBase
|
||||
{
|
||||
public:
|
||||
enum TWrapMode { Repeat = 0, Clamp, WrapModeCount };
|
||||
|
||||
|
||||
CViewQuad();
|
||||
|
||||
// from CInterfaceElement
|
||||
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
|
||||
virtual void updateCoords();
|
||||
virtual void draw();
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
// from CViewBase
|
||||
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
|
||||
virtual void setAlpha (sint32 a);
|
||||
|
||||
// texture
|
||||
void setTexture(const std::string &texName);
|
||||
std::string getTexture () const;
|
||||
|
||||
// color
|
||||
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
|
||||
NLMISC::CRGBA getColorRGBA() const { return _Color; }
|
||||
|
||||
/** Set a new quad relative to parent pos
|
||||
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
|
||||
*/
|
||||
void setQuad(const NLMISC::CQuad &quad);
|
||||
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
|
||||
/** Fit the given texture size (no hotspot for now, always centered)
|
||||
* NB : current texture is not modified.
|
||||
*/
|
||||
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
|
||||
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
|
||||
const NLMISC::CQuad &getQuad() const { return _Quad; }
|
||||
|
||||
void setAdditif(bool additif);
|
||||
bool getAdditif() const { return _Additif; }
|
||||
|
||||
void setPattern(float umin, float umax, TWrapMode wrapMode);
|
||||
|
||||
private:
|
||||
NLMISC::CRGBA _Color;
|
||||
NLMISC::CQuad _Quad;
|
||||
NLMISC::CQuadUV _RealQuad; // absolute coords
|
||||
float _ClampedUCorrection;
|
||||
CViewRenderer::CTextureId _TextureId; /// Accelerator
|
||||
bool _Additif;
|
||||
float _UMin;
|
||||
float _UMax;
|
||||
TWrapMode _WrapMode;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
597
code/nel/include/nel/gui/view_renderer.h
Normal file
597
code/nel/include/nel/gui/view_renderer.h
Normal file
|
@ -0,0 +1,597 @@
|
|||
// 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 NL_VIEW_RENDERER_H
|
||||
#define NL_VIEW_RENDERER_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/misc/uv.h"
|
||||
#include "nel/misc/plane.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "nel/3d/u_material.h"
|
||||
#include "nel/3d/u_text_context.h"
|
||||
#include "nel/3d/u_driver.h"
|
||||
#include "nel/3d/frustum.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
#define VR_NUM_LAYER 32
|
||||
#define VR_BIAS_LAYER (VR_NUM_LAYER/2)
|
||||
#define VR_LAYER_MAX (VR_NUM_LAYER-VR_BIAS_LAYER-1)
|
||||
#define VR_LAYER_MIN (-VR_BIAS_LAYER)
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* class rendering the views
|
||||
* All the quads of the interface are displayed in the following order
|
||||
*
|
||||
* 3--2
|
||||
* | |
|
||||
* 0--1
|
||||
*
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewRenderer
|
||||
{
|
||||
public:
|
||||
enum TSystemTexture
|
||||
{
|
||||
QuantityCrossTexture= 0,
|
||||
DefaultBrickTexture,
|
||||
DefaultItemTexture,
|
||||
ItemPlanTexture,
|
||||
SkillTexture,
|
||||
ItemEnchantedTexture,
|
||||
DragCopyTexture,
|
||||
ItemWornedTexture,
|
||||
OutOfRangeTexture,
|
||||
RegenTexture,
|
||||
RegenBackTexture,
|
||||
GlowStarTexture,
|
||||
ItemLockedByOwnerTexture,
|
||||
NumSystemTextures,
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** That class hold a texture id. It handle texture id destruction.
|
||||
* Please use this class in your view and not sint32 to hold a texture id
|
||||
*/
|
||||
class CTextureId
|
||||
{
|
||||
public:
|
||||
|
||||
// Default constructor
|
||||
CTextureId ()
|
||||
{
|
||||
_TextureId = -2;
|
||||
}
|
||||
|
||||
// Destructor call deleteTextureId;
|
||||
~CTextureId ();
|
||||
|
||||
// Set the texture id
|
||||
bool setTexture (const char *textureName, sint32 offsetX = 0, sint32 offsetY = 0, sint32 width = -1, sint32 height = -1,
|
||||
bool uploadDXTC=true, bool bReleasable=true);
|
||||
|
||||
// Convert in texture id
|
||||
operator sint32 () const
|
||||
{
|
||||
return _TextureId;
|
||||
}
|
||||
|
||||
void serial(NLMISC::IStream &f);
|
||||
|
||||
private:
|
||||
sint32 _TextureId;
|
||||
};
|
||||
|
||||
private:
|
||||
CViewRenderer();
|
||||
~CViewRenderer();
|
||||
|
||||
public:
|
||||
static CViewRenderer* getInstance();
|
||||
|
||||
/// setup the default values for everything
|
||||
void setup();
|
||||
|
||||
/// init when TextContext and Driver are created
|
||||
void init();
|
||||
|
||||
/// set the driver render states for the interface
|
||||
void setRenderStates ();
|
||||
|
||||
/// Delete all textures and the like and reset the view renderer
|
||||
void reset();
|
||||
|
||||
/// Release the resources of CViewRenderer, and delete the Singleton
|
||||
static void release();
|
||||
|
||||
/// Retrieves the 3d driver we are using
|
||||
static NL3D::UDriver* getDriver();
|
||||
|
||||
/// Sets the current TextContext.
|
||||
static void setTextContext( NL3D::UTextContext *textcontext );
|
||||
|
||||
/// Sets the current driver
|
||||
static void setDriver( NL3D::UDriver *driver );
|
||||
|
||||
/*
|
||||
* setClipWindow : set the current clipping window
|
||||
* (this window do not inherit properties from parent or whatever)
|
||||
*/
|
||||
void setClipWindow (sint32 x, sint32 y, sint32 w, sint32 h);
|
||||
|
||||
/*
|
||||
* getClipWindow : get the current clipping region
|
||||
*/
|
||||
void getClipWindow (sint32 &x, sint32 &y, sint32 &w, sint32 &h)
|
||||
{
|
||||
x = _ClipX;
|
||||
y = _ClipY;
|
||||
w = _ClipW;
|
||||
h = _ClipH;
|
||||
}
|
||||
|
||||
/*
|
||||
* true if the clipping region is empty: clipW or clipH is <=0
|
||||
*/
|
||||
bool isClipWindowEmpty() const {return _ClipW<=0 || _ClipH<=0;}
|
||||
|
||||
/*
|
||||
* checkNewScreenSize : check if the opengl screen size. This is SLOW !
|
||||
* NB: if the window is minimized (w==h==0), then the old screen size is kept, and isMinimized() return true
|
||||
*/
|
||||
void checkNewScreenSize ();
|
||||
|
||||
/*
|
||||
* getScreenSize : get the screen window size changed (at last checkNewScreenSize called)
|
||||
*/
|
||||
void getScreenSize (uint32 &w, uint32 &h);
|
||||
|
||||
/*
|
||||
* get OOW / OOH
|
||||
*/
|
||||
void getScreenOOSize (float &oow, float &ooh);
|
||||
|
||||
/*
|
||||
* is the Screen minimized?
|
||||
*/
|
||||
bool isMinimized() const {return _IsMinimized;}
|
||||
|
||||
/*
|
||||
* drawBitmap : this is the interface with all the views
|
||||
*
|
||||
*/
|
||||
void drawRotFlipBitmap (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv,
|
||||
sint32 nTxId, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255));
|
||||
|
||||
/*
|
||||
* Draw a simple wired quad. No flushing is done as the draw is done instantly (usually for debug)
|
||||
*/
|
||||
void drawWiredQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White);
|
||||
|
||||
/*
|
||||
* Draw a simple filled quad. No flushing is done as the draw is done instantly (usually for debug)
|
||||
*/
|
||||
void drawFilledQuad(sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col = NLMISC::CRGBA::White);
|
||||
|
||||
/*
|
||||
* drawBitmap : Tiled version
|
||||
* \param tileOrigin 2 bits 1 - Left/Right (0/1) 2 - Bottom/Top (0/1) (0-BL)(1-BR)(2-TL)(3-TR)
|
||||
*
|
||||
*/
|
||||
void drawRotFlipBitmapTiled (sint layerId, sint32 x, sint32 y, sint32 width, sint32 height, uint8 rot, bool flipv,
|
||||
sint32 nTxId, uint tileOrigin, const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255));
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* drawBitmap : draw a bitmap roted by 90 degrees in CW 'rot times'
|
||||
* flipv is a boolean that indicates if there is a vertical flip
|
||||
* this is a 1:1 ratio so if texture is x long there are x pixels on screen
|
||||
*/
|
||||
void draw11RotFlipBitmap (sint layerId, sint32 x, sint32 y, uint8 rot, bool flipv, sint32 nTxId,
|
||||
const NLMISC::CRGBA &col = NLMISC::CRGBA(255,255,255,255));
|
||||
|
||||
/** Draw an arbitrary quad (fast version) , possibly clipping it. Unlike draw11RotFlipBitmap & the like, texture is filtered here.
|
||||
* quads are all batched in the same render layer
|
||||
*/
|
||||
void drawQuad(sint layerId, const NLMISC::CQuadUV &quadUV, sint32 nTxId,
|
||||
NLMISC::CRGBA col, bool additif, bool filtered = true);
|
||||
/** Draw a set of untextured triangle in the given layer. all triangles of the same layer are batched
|
||||
*/
|
||||
void drawUnclippedTriangles(sint layerId, const std::vector<NLMISC::CTriangle> &tris, NLMISC::CRGBA col);
|
||||
|
||||
/*
|
||||
* Draw a text
|
||||
*/
|
||||
void drawText (sint layerId, float x, float y, uint wordIndex, float xmin, float ymin, float xmax, float ymax, NL3D::UTextContext &textContext);
|
||||
|
||||
/*
|
||||
* loadTextures : load all textures associated with the interface
|
||||
* this function add a globaltexture to the vector of global textures
|
||||
*/
|
||||
bool loadTextures (const std::string &textureFileName, const std::string &uvFileName, bool uploadDXTC);
|
||||
|
||||
/*
|
||||
* createTexture : create a texture for the interface, possibly from an externally created texture
|
||||
* If no external texture is given, then 'sGlobalTextureName' is the filename of the big texture
|
||||
* You should call deleteTexture when the texture is not used anymore
|
||||
* The method returns the texture id of the new texture
|
||||
*/
|
||||
sint32 createTexture (const std::string &sGlobalTextureName, // unique id identifying this big texture, (its filename if not externally created)
|
||||
sint32 offsetX = 0,
|
||||
sint32 offsetY = 0,
|
||||
sint32 width = -1,
|
||||
sint32 height = -1,
|
||||
bool uploadDXTC=true,
|
||||
bool bReleasable=true
|
||||
);
|
||||
|
||||
|
||||
// change position of a sub-texture (inside its big texture) from the sub-texture filename
|
||||
void updateTexturePos(const std::string &texturefileName,
|
||||
sint32 offsetX = 0,
|
||||
sint32 offsetY = 0,
|
||||
sint32 width = -1,
|
||||
sint32 height = -1
|
||||
);
|
||||
|
||||
/** Add / change a global texture from an externally created texture
|
||||
* \param defaultTexWidth width to used when CTextureId::createTexture is used without giving the width (e.g width = -1), useful for cropped textures
|
||||
* \param defaultTexHeight height to used when CTextureId::createTexture is used without giving the height (e.g height = -1), useful for cropped textures
|
||||
*/
|
||||
|
||||
void setExternalTexture(const std::string &sGlobalTextureName,
|
||||
NL3D::UTexture *externalTexture = NULL,
|
||||
uint32 externalTexWidth = 1,
|
||||
uint32 externalTexHeight = 1,
|
||||
uint32 defaultTexWidth = 1,
|
||||
uint32 defaultTexHeight = 1
|
||||
);
|
||||
|
||||
/*
|
||||
* deleteTexture : create a texture for the interface
|
||||
*/
|
||||
void deleteTexture (sint32 textureId);
|
||||
|
||||
// get a global texture pointer from its name
|
||||
NL3D::UTexture *getGlobalTexture(const std::string &name);
|
||||
|
||||
/*
|
||||
* Flush all parsed view and computed strings to screen
|
||||
*/
|
||||
void flush ();
|
||||
|
||||
/**
|
||||
* get a texture file pointer from a string name. O(logN)
|
||||
* \param id : the id of the texture
|
||||
* \return a texture file pointer. -1 if not found or if sName is empty()
|
||||
*/
|
||||
sint32 getTextureIdFromName (const std::string &sName) const;
|
||||
std::string getTextureNameFromId (sint32 TxID);
|
||||
void getTextureSizeFromId (sint32 id, sint32 &width, sint32 &height);
|
||||
NLMISC::CRGBA getTextureColor(sint32 id, sint32 x, sint32 y);
|
||||
|
||||
|
||||
/**
|
||||
* \return the texture associated with the param figur
|
||||
*/
|
||||
sint32 getFigurTextureId(uint index)
|
||||
{
|
||||
nlassert(index < 10);
|
||||
return _IndexesToTextureIds[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* \return the texture for figur separator '-'
|
||||
*/
|
||||
sint32 getFigurSeparator() const { return _FigurSeparatorTextureId; }
|
||||
|
||||
sint32 getFigurTextureW() const {return _WFigurTexture;}
|
||||
sint32 getFigurTextureH() const {return _HFigurTexture;}
|
||||
sint32 getFigurSeparatorW() const {return _WFigurSeparatorTexture;}
|
||||
sint32 getFigurSeparatorH() const {return _HFigurSeparatorTexture;}
|
||||
|
||||
|
||||
sint32 getFigurBlankTextureId ()
|
||||
{
|
||||
return _FigurBlankId;
|
||||
}
|
||||
sint32 getBlankTextureId ()
|
||||
{
|
||||
return _BlankId;
|
||||
}
|
||||
|
||||
|
||||
sint32 getTypoTextureW(char c);
|
||||
sint32 getTypoTextureH(char c);
|
||||
sint32 getTypoTextureId(char c);
|
||||
|
||||
/// System Texture Manager. Used to avoid storing an id in each Ctrl for some texture code is aware of
|
||||
// @{
|
||||
sint32 getSystemTextureId(TSystemTexture e) const {return _SystemTextures[e].Id;}
|
||||
sint32 getSystemTextureW(TSystemTexture e) const {return _SystemTextures[e].W;}
|
||||
sint32 getSystemTextureH(TSystemTexture e) const {return _SystemTextures[e].H;}
|
||||
// @}
|
||||
|
||||
/// For string rendering, get the RenderBuffer to the specified layer
|
||||
NL3D::URenderStringBuffer *getStringRenderBuffer(sint layerId);
|
||||
|
||||
|
||||
/** Custom Rendering Interface
|
||||
* Note that this function is EXTREMLY SLOW so it should be used with care
|
||||
* This function flush the quad cache, clip the quad passed with current clipping region
|
||||
* and draw (with drawQuedUV2) it with the material passed in parameter. There is no cache operation done.
|
||||
* uv used are from (0,0) -> (1,1) for the 2 stages
|
||||
*/
|
||||
void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height, NLMISC::CRGBA col, NL3D::UMaterial Mat);
|
||||
// Same but we can control uv mapping of first stage
|
||||
void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height,
|
||||
const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max,
|
||||
NLMISC::CRGBA col, NL3D::UMaterial Mat);
|
||||
// Same but we can control uv mapping of 2 stages
|
||||
void drawCustom (sint32 x, sint32 y, sint32 width, sint32 height,
|
||||
const NLMISC::CUV &uv0Min, const NLMISC::CUV &uv0Max, const NLMISC::CUV &uv1Min, const NLMISC::CUV &uv1Max,
|
||||
NLMISC::CRGBA col, NL3D::UMaterial Mat);
|
||||
|
||||
// **** World space interface methods
|
||||
|
||||
/** Set the current Z in projCenter.z.
|
||||
* If you want to scale the window position, set a scale!=1. projCenter.x/y is used as the
|
||||
* pivot (in window coordinates)
|
||||
*/
|
||||
void setInterfaceDepth (const NLMISC::CVector &projCenter, float scale);
|
||||
|
||||
// Activate world space transformation
|
||||
void activateWorldSpaceMatrix (bool activate);
|
||||
|
||||
// Set the screen to world space matrix
|
||||
void setWorldSpaceFrustum (const NL3D::CFrustum &cameraFrustum);
|
||||
|
||||
// Get the current Frustum
|
||||
const NL3D::CFrustum &getFrustum () const
|
||||
{
|
||||
return _CameraFrustum;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* init the map _IndexesToTextures
|
||||
*/
|
||||
void initIndexesToTextureIds ();
|
||||
void initTypo ();
|
||||
|
||||
bool needClipping (const NLMISC::CQuad &q);
|
||||
|
||||
void clip (NLMISC::CQuadColorUV &qout, const NLMISC::CQuadColorUV &qin, uint rot);
|
||||
void clip (NLMISC::CQuadColorUV2 &qout, const NLMISC::CQuadColorUV2 &qin);
|
||||
private:
|
||||
|
||||
// A layer is a vector of Quads.
|
||||
class CLayer
|
||||
{
|
||||
public:
|
||||
// unfiltered quads
|
||||
std::vector<NLMISC::CQuadColorUV> Quads;
|
||||
uint32 NbQuads;
|
||||
std::vector<NLMISC::CTriangleColorUV> Tris;
|
||||
// filtered alpha blended quads
|
||||
std::vector<NLMISC::CQuadColorUV> FilteredAlphaBlendedQuads;
|
||||
// filtered alpha blended tris
|
||||
std::vector<NLMISC::CTriangleColorUV> FilteredAlphaBlendedTris;
|
||||
// filtered additif blended quads
|
||||
std::vector<NLMISC::CQuadColorUV> FilteredAdditifQuads;
|
||||
// filtered additif blended tris
|
||||
std::vector<NLMISC::CTriangleColorUV> FilteredAdditifTris;
|
||||
|
||||
CLayer()
|
||||
{
|
||||
NbQuads= 0;
|
||||
}
|
||||
};
|
||||
|
||||
// SGlobalTexture is a texture that regroup other texture. We store also current quads to render
|
||||
struct SGlobalTexture
|
||||
{
|
||||
SGlobalTexture ()
|
||||
{
|
||||
FromGlobaleTexture = true;
|
||||
}
|
||||
uint32 Width, Height;
|
||||
uint32 DefaultWidth, DefaultHeight;
|
||||
NL3D::UTexture *Texture;
|
||||
std::string Name;
|
||||
bool FromGlobaleTexture;
|
||||
// Array of layers
|
||||
CLayer Layers[VR_NUM_LAYER];
|
||||
};
|
||||
|
||||
// For each Layer, store a string Buffer
|
||||
NL3D::URenderStringBuffer *_StringRBLayers[VR_NUM_LAYER];
|
||||
|
||||
// For each Layer, tells if empty or not
|
||||
bool _EmptyLayer[VR_NUM_LAYER];
|
||||
|
||||
// SImage is one texture of the SGlobalTexture textures
|
||||
struct SImage
|
||||
{
|
||||
std::string Name;
|
||||
SGlobalTexture *GlobalTexturePtr;
|
||||
NLMISC::CUV UVMin, UVMax;
|
||||
|
||||
// Assign UV of this image to a quad depending on the flip and rot
|
||||
void setupQuadUV(bool flipv, uint8 rot, NLMISC::CQuadColorUV &dest);
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
// \name Texture management
|
||||
// ***************************************************************************
|
||||
|
||||
// SImage accessors
|
||||
SImage *getSImage(sint32 textureId)
|
||||
{
|
||||
return &(*(_SImageIterators[textureId]));
|
||||
}
|
||||
|
||||
|
||||
// Add a SImage
|
||||
sint32 addSImage(const SImage &image)
|
||||
{
|
||||
uint i;
|
||||
for (i=0; i<_SImageIterators.size(); i++)
|
||||
{
|
||||
// Free ?
|
||||
if (_SImageIterators[i] == _SImages.end())
|
||||
break;
|
||||
}
|
||||
|
||||
// Nothing free ?
|
||||
if (i == _SImageIterators.size())
|
||||
_SImageIterators.push_back(_SImages.end());
|
||||
|
||||
_SImages.push_back(image);
|
||||
_SImageIterators[i] = _SImages.end();
|
||||
_SImageIterators[i]--;
|
||||
return (sint32)i;
|
||||
}
|
||||
|
||||
// Remove a SImage
|
||||
void removeSImage(sint32 textureId)
|
||||
{
|
||||
// Allocated ?
|
||||
nlassert (_SImageIterators[textureId] != _SImages.end());
|
||||
|
||||
// Remove the image
|
||||
_SImages.erase (_SImageIterators[textureId]);
|
||||
|
||||
// Remove the index entry
|
||||
_SImageIterators[textureId] = _SImages.end();
|
||||
}
|
||||
|
||||
typedef std::list<SGlobalTexture> TGlobalTextureList;
|
||||
typedef std::list<SImage> TSImageList;
|
||||
typedef std::vector<std::list<SImage>::iterator> TSImageIterator;
|
||||
|
||||
// List of global textures
|
||||
TGlobalTextureList _GlobalTextures;
|
||||
|
||||
// List of SImage
|
||||
TSImageList _SImages;
|
||||
|
||||
// Array used to convert a texture ID in _SImages iterator
|
||||
TSImageIterator _SImageIterators;
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
typedef std::map<std::string, uint> TTextureMap;
|
||||
TTextureMap _TextureMap;
|
||||
|
||||
NL3D::UMaterial _Material;
|
||||
|
||||
// Clip & screen system
|
||||
sint32 _ClipX, _ClipY, _ClipW, _ClipH;
|
||||
float _XMin, _XMax, _YMin, _YMax;
|
||||
|
||||
sint32 _ScreenW, _ScreenH;
|
||||
float _OneOverScreenW, _OneOverScreenH;
|
||||
bool _IsMinimized;
|
||||
|
||||
|
||||
//map linking a uint to a bitmap. Used to display figurs
|
||||
std::vector<sint32> _IndexesToTextureIds;
|
||||
sint32 _FigurSeparatorTextureId;
|
||||
sint32 _FigurBlankId, _BlankId;
|
||||
sint32 _WFigurTexture;
|
||||
sint32 _HFigurTexture;
|
||||
sint32 _WFigurSeparatorTexture;
|
||||
sint32 _HFigurSeparatorTexture;
|
||||
NLMISC::CUV _BlankUV;
|
||||
SGlobalTexture *_BlankGlobalTexture;
|
||||
|
||||
// System textures
|
||||
class CSystemTexture
|
||||
{
|
||||
public:
|
||||
sint32 Id;
|
||||
sint32 W;
|
||||
sint32 H;
|
||||
|
||||
CSystemTexture()
|
||||
{
|
||||
Id= -1;
|
||||
W= H= 0;
|
||||
}
|
||||
};
|
||||
CSystemTexture _SystemTextures[NumSystemTextures];
|
||||
|
||||
// Typo texture
|
||||
enum
|
||||
{
|
||||
NumTypoChar= 127,
|
||||
};
|
||||
sint32 _TypoCharToTextureIds[NumTypoChar];
|
||||
sint32 _TypoCharWs[NumTypoChar];
|
||||
sint32 _TypoH;
|
||||
|
||||
|
||||
void addSystemTexture(TSystemTexture e, const char *s);
|
||||
void initSystemTextures();
|
||||
|
||||
/**
|
||||
* put a new quad in the cache (call flush if texture different)
|
||||
*/
|
||||
void putQuadInLayer (SGlobalTexture >, sint layerId, const NLMISC::CQuadColorUV &qcoluv, uint rot);
|
||||
|
||||
// World space interface methods
|
||||
void worldSpaceTransformation (NLMISC::CQuadColorUV &qcoluv);
|
||||
|
||||
bool _WorldSpaceTransformation; // Transform into world space
|
||||
float _CurrentZ; // Current z used for the scene
|
||||
NL3D::CFrustum _CameraFrustum; // Transform from screen space to world space
|
||||
NLMISC::CMatrix _WorldSpaceMatrix; // Matrix to be applied for world space transformation
|
||||
bool _WorldSpaceScale;
|
||||
|
||||
|
||||
static CViewRenderer *instance;
|
||||
static NL3D::UDriver *driver;
|
||||
static NL3D::UTextContext *textcontext;
|
||||
|
||||
public:
|
||||
static NL3D::UTextContext* getTextContext(){ return textcontext; }
|
||||
|
||||
/// Set of hw cursor images
|
||||
static std::set< std::string > *hwCursors;
|
||||
static float hwCursorScale;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_RENDERER_H
|
||||
|
||||
/* End of view_renderer.h */
|
419
code/nel/include/nel/gui/view_text.h
Normal file
419
code/nel/include/nel/gui/view_text.h
Normal file
|
@ -0,0 +1,419 @@
|
|||
// 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 NL_VIEW_TEXT_H
|
||||
#define NL_VIEW_TEXT_H
|
||||
|
||||
#include "nel/gui/view_base.h"
|
||||
#include "nel/gui/string_case.h"
|
||||
#include "nel/3d/u_text_context.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CCtrlToolTip;
|
||||
|
||||
/**
|
||||
* class implementing a text view
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewText : public CViewBase
|
||||
{
|
||||
public:
|
||||
enum TTextMode { ClipWord, DontClipWord, Justified };
|
||||
public:
|
||||
|
||||
DECLARE_UI_CLASS(CViewText)
|
||||
|
||||
|
||||
/// Constructor
|
||||
CViewText (const TCtorParam ¶m);
|
||||
|
||||
/// Constructor
|
||||
CViewText (const std::string& id, const std::string Text="", sint FontSize=12,
|
||||
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false);
|
||||
|
||||
virtual ~CViewText();
|
||||
|
||||
CViewText &operator=(const CViewText &vt);
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
std::string getTextProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
bool setTextProperty( const std::string &name, const std::string &value );
|
||||
bool serializeTextOptions( xmlNodePtr node ) const;
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
void parseTextOptions (xmlNodePtr cur);
|
||||
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
|
||||
|
||||
/// Updating
|
||||
virtual void draw ();
|
||||
void updateTextContext ();
|
||||
virtual void checkCoords();
|
||||
virtual void updateCoords();
|
||||
virtual void onAddToGroup();
|
||||
|
||||
/// From CInterfaceElement
|
||||
sint32 getMaxUsedW() const;
|
||||
sint32 getMinUsedW() const;
|
||||
|
||||
/// Accessors
|
||||
|
||||
/// Set
|
||||
|
||||
void setText (const ucstring &text);
|
||||
void setFontSize (sint nFontSize);
|
||||
void setColor (const NLMISC::CRGBA &color);
|
||||
void setShadow (bool bShadow);
|
||||
void setShadowColor (const NLMISC::CRGBA &color);
|
||||
void setLineMaxW (sint nMaxW, bool invalidate=true);
|
||||
void setMultiLine (bool bMultiLine);
|
||||
void setMultiLineSpace (sint nMultiLineSpace);
|
||||
void setMultiLineMaxWOnly (bool state);
|
||||
void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance
|
||||
void setFirstLineX (uint firstLineX);
|
||||
void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
|
||||
|
||||
// Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
|
||||
void enableStringSelection(uint start, uint end);
|
||||
void disableStringSelection();
|
||||
|
||||
/// Get
|
||||
|
||||
ucstring getText() const { return _Text; }
|
||||
sint getFontSize() const;
|
||||
NLMISC::CRGBA getColor() { return _Color; }
|
||||
bool getShadow() { return _Shadow; }
|
||||
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
|
||||
sint getLineMaxW() const { return _LineMaxW; }
|
||||
bool getMultiLine() const { return _MultiLine; }
|
||||
sint getMultiLineSpace() const { return _MultiLineSpace; }
|
||||
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
|
||||
uint32 getMultiMaxLine() const { return _MultiMaxLine; }
|
||||
|
||||
// get current Hint font width, in pixels
|
||||
uint getFontWidth() const;
|
||||
// get current font height, in pixels
|
||||
uint getFontHeight() const;
|
||||
// get current font leg height, in pixels
|
||||
uint getFontLegHeight() const;
|
||||
// Set the display mode (supported with multiline only for now)
|
||||
void setTextMode(TTextMode mode);
|
||||
TTextMode getTextMode() const { return _TextMode; }
|
||||
uint getNumLine() const;
|
||||
uint getFirstLineX() const;
|
||||
uint getLastLineW () const;
|
||||
void setUnderlined (bool underlined) { _Underlined = underlined; }
|
||||
bool getUnderlined () const { return _Underlined; }
|
||||
// true if the viewText is a single line clamped.
|
||||
bool isSingleLineTextClamped() const {return _SingleLineTextClamped;}
|
||||
|
||||
// Character positions
|
||||
|
||||
/** Get position of the ith character, position are relative to the BR corner of the text.
|
||||
* \param lineEnd. When set to true, return the coordinate of the previous line if the index is at the start of a line.
|
||||
* When looking at standard edit box, we see that if a line is split accross to line with no
|
||||
* This also returns the height of the line
|
||||
*/
|
||||
void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const;
|
||||
/** From a coordinate relative to the BR BR corner of the text, return the index of a character.
|
||||
* If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text)
|
||||
*/
|
||||
void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const;
|
||||
/** From a character index, get the index of the line it belongs to, or -1 if the index is invalid
|
||||
* \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index
|
||||
*/
|
||||
sint getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine = true) const;
|
||||
/// From a line number, get the character at which it starts, or -1 if invalid
|
||||
sint getLineStartIndex(uint line) const;
|
||||
/// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid
|
||||
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
|
||||
|
||||
std::string getHardText() const { std::string result; _Text.toString (result); return result; }
|
||||
void setHardText (const std::string &ht);
|
||||
|
||||
std::string getColorAsString() const;
|
||||
void setColorAsString(const std::string &ht);
|
||||
|
||||
NLMISC::CRGBA getColorRGBA() const;
|
||||
void setColorRGBA(NLMISC::CRGBA col);
|
||||
|
||||
virtual sint32 getAlpha() const { return _Color.A; }
|
||||
virtual void setAlpha (sint32 a) { _ShadowColor.A = _Color.A = (uint8)a; }
|
||||
|
||||
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
|
||||
*/
|
||||
void setTextFormatTaged(const ucstring &text);
|
||||
|
||||
void setSingleLineTextFormatTaged(const ucstring &text);
|
||||
|
||||
// Remove end space
|
||||
void removeEndSpaces();
|
||||
|
||||
// Reset the text index because the text context has changed
|
||||
void resetTextIndex();
|
||||
|
||||
// Case mode
|
||||
void setCaseMode (TCaseMode caseMode);
|
||||
TCaseMode getCaseMode () const;
|
||||
|
||||
// OverExtendViewText
|
||||
void setOverExtendViewText(bool state) {_OverExtendViewText= state;}
|
||||
bool getOverExtendViewText() const {return _OverExtendViewText;}
|
||||
|
||||
// OverExtendViewTextUseParentRect
|
||||
void setOverExtendViewTextUseParentRect(bool state) {_OverExtendViewTextUseParentRect= state;}
|
||||
bool getOverExtendViewTextUseParentRect() const {return _OverExtendViewTextUseParentRect;}
|
||||
|
||||
// see if text ellipsis if done at right side of the text
|
||||
bool isClampRight() const { return _ClampRight; }
|
||||
|
||||
int luaSetLineMaxW(CLuaState &ls);
|
||||
|
||||
REFLECT_EXPORT_START(CViewText, CViewBase)
|
||||
REFLECT_STRING("hardtext", getHardText, setHardText);
|
||||
REFLECT_UCSTRING("uc_hardtext", getText, setText);
|
||||
REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged);
|
||||
REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged);
|
||||
REFLECT_STRING ("color", getColorAsString, setColorAsString);
|
||||
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
|
||||
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
|
||||
REFLECT_BOOL ("overExtendViewText", getOverExtendViewText, setOverExtendViewText);
|
||||
REFLECT_BOOL ("overExtendViewTextUseParentRect", getOverExtendViewTextUseParentRect, setOverExtendViewTextUseParentRect);
|
||||
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
|
||||
virtual void serial(NLMISC::IStream &f);
|
||||
|
||||
protected:
|
||||
std::string _HardtextFormat;
|
||||
/// Text to display.
|
||||
ucstring _Text;
|
||||
/// index of the computed String associated to this text control
|
||||
uint _Index;
|
||||
/// info on the computed String associated to this text control
|
||||
NL3D::UTextContext::CStringInfo _Info;
|
||||
/// the font size
|
||||
sint _FontSize;
|
||||
// width of the font in pixel. Just a Hint for tabing format (computed with '_')
|
||||
uint _FontWidth;
|
||||
// height of the font in pixel.
|
||||
// use getFontHeight
|
||||
uint _FontHeight;
|
||||
uint _FontLegHeight;
|
||||
float _SpaceWidth;
|
||||
/// the text color
|
||||
NLMISC::CRGBA _Color;
|
||||
/// the shadow mode
|
||||
bool _Shadow;
|
||||
/// the case mode
|
||||
TCaseMode _CaseMode;
|
||||
/// the text shadow color
|
||||
NLMISC::CRGBA _ShadowColor;
|
||||
/// Is the line (under p loop) should be considered at bottom (if false bottom is under p leg)
|
||||
/// maxw for the line/multiline
|
||||
sint32 _LineMaxW;
|
||||
/// For single line, true if the text is clamped (ie displayed with "...")
|
||||
bool _SingleLineTextClamped;
|
||||
|
||||
/// Multiple lines handling
|
||||
bool _MultiLine;
|
||||
bool _MultiLineMaxWOnly;
|
||||
bool _MultiLineClipEndSpace;
|
||||
uint8 _AutoClampOffset;
|
||||
TTextMode _TextMode;
|
||||
sint _MultiLineSpace;
|
||||
sint _LastMultiLineMaxW;
|
||||
uint32 _MultiMaxLine;
|
||||
|
||||
|
||||
/// FormatTag handling
|
||||
struct CFormatInfo
|
||||
{
|
||||
// The color to change
|
||||
NLMISC::CRGBA Color;
|
||||
// The Tabulation to apply, in number of "_" characters.
|
||||
uint TabX;
|
||||
// Index in vector
|
||||
sint IndexTt;
|
||||
|
||||
CFormatInfo()
|
||||
{
|
||||
Color= NLMISC::CRGBA::White;
|
||||
TabX= 0;
|
||||
IndexTt = -1;
|
||||
}
|
||||
|
||||
bool operator==(const CFormatInfo &o) const {return Color==o.Color && TabX==o.TabX && IndexTt==o.IndexTt;}
|
||||
bool operator!=(const CFormatInfo &o) const {return !operator==(o);}
|
||||
};
|
||||
struct CFormatTag : public CFormatInfo
|
||||
{
|
||||
uint Index;
|
||||
|
||||
// compare 2 tags, not a tag and a CFormatInfo
|
||||
bool sameTag(const CFormatTag &o) const
|
||||
{
|
||||
return CFormatInfo::operator==(o) && Index==o.Index;
|
||||
}
|
||||
};
|
||||
std::vector<CFormatTag> _FormatTags;
|
||||
|
||||
/// Get the current maxW for multiline, accordgin to parent and _MultiLineOptionMaxW
|
||||
sint getCurrentMultiLineMaxW() const;
|
||||
|
||||
|
||||
|
||||
|
||||
NL3D::ULetterColors * _LetterColors;
|
||||
|
||||
private:
|
||||
// A word in a line
|
||||
class CWord
|
||||
{
|
||||
public:
|
||||
// default ctor
|
||||
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
|
||||
ucstring Text;
|
||||
uint Index; // index of the info for this word
|
||||
NL3D::UTextContext::CStringInfo Info;
|
||||
uint NumSpaces; // number of spaces before this word
|
||||
// The specialized color/format of this word. White if none
|
||||
CFormatInfo Format;
|
||||
public:
|
||||
// build from a string, using the current text context
|
||||
void build(const ucstring &text, uint numSpaces= 0);
|
||||
};
|
||||
typedef std::vector<CWord> TWordVect;
|
||||
|
||||
// A line of text (which is made of one word with space, or of several words with no spaces in them)
|
||||
class CLine : public NLMISC::CRefCount
|
||||
{
|
||||
public:
|
||||
// ctor
|
||||
CLine();
|
||||
// Clear the line & remove text contexts
|
||||
void clear();
|
||||
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
|
||||
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth);
|
||||
void addWord(const CWord &word, uint fontWidth);
|
||||
uint getNumWords() const { return (uint)_Words.size(); }
|
||||
CWord &getWord(uint index) { return _Words[index]; }
|
||||
float getSpaceWidth() const { return _SpaceWidth; }
|
||||
void setSpaceWidth(float width) { _SpaceWidth = width; }
|
||||
// Get the number of chars in the line, not counting the end spaces, but couting the spaces in words
|
||||
uint getNumChars() const { return _NumChars; }
|
||||
// Get the total number of spaces between words (not including those in words, but there should not be if text is justified)
|
||||
uint getNumSpaces() const { return _NumSpaces; }
|
||||
float getStringLine() const { return _StringLine; }
|
||||
float getWidthWithoutSpaces() const { return _WidthWithoutSpaces; }
|
||||
// get total width including spaces, but not including end spaces
|
||||
float getWidth() const { return _WidthWithoutSpaces + _SpaceWidth * _NumSpaces; }
|
||||
// Get the number of spaces at the end of the line
|
||||
void setEndSpaces(uint numSpaces) { _EndSpaces = numSpaces; }
|
||||
// Set the number of spaces at the end of the line
|
||||
uint getEndSpaces() const { return _EndSpaces; }
|
||||
// Test if there's a line feed at the end of the line
|
||||
bool getLF() const { return _HasLF; }
|
||||
void setLF(bool lf) { _HasLF = lf; }
|
||||
void resetTextIndex();
|
||||
private:
|
||||
TWordVect _Words;
|
||||
uint _NumChars;
|
||||
uint _NumSpaces;
|
||||
float _SpaceWidth; // width of a space, in pixels (used with multispace alignment)
|
||||
float _StringLine;
|
||||
float _WidthWithoutSpaces; // width without space (see the Field NumSpaces in the CWord class).
|
||||
// NB : space inserted inside a word are counted, however!
|
||||
uint _EndSpaces; // spaces at the end of the line
|
||||
bool _HasLF; // a linefeed is at end of line (no breaking due to line full)
|
||||
};
|
||||
/// NB : we keep pointers on lines (each line contains a vector, that we don't want to be copied, and this occurs as the vector of lines grows..)
|
||||
|
||||
typedef NLMISC::CSmartPtr<CLine> TLineSPtr;
|
||||
typedef std::vector<TLineSPtr> TLinePtVect;
|
||||
private:
|
||||
/** Data of the updated text for multiline. It is built from the _Text field in the updateTextContext member function,
|
||||
* and is used to perform the draw
|
||||
*/
|
||||
TLinePtVect _Lines;
|
||||
|
||||
/// if true, and if the view text is isSingleLineTextClamped(), then an over will be drawn, with the text
|
||||
bool _OverExtendViewText : 1;
|
||||
/// if true and _OverExtendViewText true too, use the parent rectangle to know if must display the over or not
|
||||
bool _OverExtendViewTextUseParentRect : 1;
|
||||
/// Letter selection handling
|
||||
bool _AutoClamp : 1;
|
||||
bool _ClampRight : 1;
|
||||
bool _TextSelection : 1;
|
||||
bool _InvalidTextContext : 1;
|
||||
bool _Underlined : 1;
|
||||
bool _ContinuousUpdate : 1;
|
||||
bool _Setuped : 1;
|
||||
|
||||
uint _TextSelectionStart;
|
||||
uint _TextSelectionEnd;
|
||||
|
||||
// First line X coordinate
|
||||
uint _FirstLineX;
|
||||
|
||||
/// Dynamic tooltips
|
||||
std::vector<CCtrlToolTip*> _Tooltips;
|
||||
|
||||
|
||||
private:
|
||||
void setup ();
|
||||
void setupDefault ();
|
||||
|
||||
void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd);
|
||||
|
||||
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
|
||||
|
||||
/// \from CInterfaceElement
|
||||
void onInvalidateContent();
|
||||
|
||||
// may append a new line, and append a word to the last line (no spaces)
|
||||
void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
|
||||
// Clear all the lines and free their datas
|
||||
void clearLines();
|
||||
// Update in the case of a multiline text
|
||||
void updateTextContextMultiLine(uint nMaxWidth);
|
||||
// Update in the case of a multiline text with justification
|
||||
void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces);
|
||||
// Recompute font size info
|
||||
void computeFontSize ();
|
||||
|
||||
// used for "donctClipWord" case in updateTextContextMultiLineJustified(). currLine is reseted
|
||||
void addDontClipWordLine(std::vector<CWord> &currLine);
|
||||
|
||||
// FormatTag build.
|
||||
static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
|
||||
// FormatTag parsing.
|
||||
bool isFormatTagChange(uint textIndex, uint ctIndex) const;
|
||||
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_TEXT_H
|
||||
|
||||
/* End of view_text.h */
|
71
code/nel/include/nel/gui/view_text_formated.h
Normal file
71
code/nel/include/nel/gui/view_text_formated.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
// 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 VIEW_TEXT_FORMATED_H
|
||||
#define VIEW_TEXT_FORMATED_H
|
||||
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
/** The same as a view text id, but with some display option
|
||||
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
|
||||
* $p -> expand the player name
|
||||
* $P -> expand the player name in uppercase
|
||||
* $b -> expand the current bot name ( bot with which the player is talking)
|
||||
* $s -> expand the current short bot name (with no specification/title in it)
|
||||
* if "ui..." replace the format with CI18N
|
||||
*/
|
||||
class CViewTextFormated : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
/// Interface for classes which can format the text for this view.
|
||||
class IViewTextFormatter
|
||||
{
|
||||
public:
|
||||
virtual ~IViewTextFormatter(){}
|
||||
virtual ucstring formatString( const ucstring &inputString, const ucstring ¶mString ) = 0;
|
||||
};
|
||||
|
||||
CViewTextFormated (const TCtorParam ¶m) : CViewText(param)
|
||||
{}
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
const ucstring &getFormatString() const { return _FormatString; }
|
||||
void setFormatString(const ucstring &format);
|
||||
|
||||
static ucstring formatString(const ucstring &inputString, const ucstring ¶mString);
|
||||
|
||||
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
|
||||
|
||||
private:
|
||||
ucstring _FormatString;
|
||||
static IViewTextFormatter *textFormatter;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
157
code/nel/include/nel/gui/view_text_id.h
Normal file
157
code/nel/include/nel/gui/view_text_id.h
Normal file
|
@ -0,0 +1,157 @@
|
|||
// 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 NL_VIEW_TEXT_ID_H
|
||||
#define NL_VIEW_TEXT_ID_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
|
||||
namespace NLMISC{
|
||||
class CCDBNodeLeaf;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ***************************************************************************
|
||||
class IOnReceiveTextId
|
||||
{
|
||||
public:
|
||||
virtual ~IOnReceiveTextId() {}
|
||||
// the deriver may change the input text
|
||||
virtual void onReceiveTextId(ucstring &str) =0;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
/**
|
||||
* class implementing a text view that take the text from an id
|
||||
* \author Matthieu 'TrapII' Besson
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CViewTextID : public CViewText
|
||||
{
|
||||
public:
|
||||
|
||||
/// Interface for classes which can provide text to CViewTextId
|
||||
class IViewTextProvider
|
||||
{
|
||||
public:
|
||||
virtual ~IViewTextProvider(){}
|
||||
virtual bool getString( uint32 stringId, ucstring &result ) = 0;
|
||||
virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0;
|
||||
};
|
||||
|
||||
CViewTextID(const TCtorParam ¶m) : CViewText(param)
|
||||
{
|
||||
_StringModifier= NULL;
|
||||
_IsDBLink = false;
|
||||
_TextId = 0xFFFFFFFF;
|
||||
_Initialized = false;
|
||||
_DynamicString = false;
|
||||
_IsTextFormatTaged= false;
|
||||
}
|
||||
|
||||
// ctor with a text id
|
||||
CViewTextID (const std::string& id, uint32 nID, sint FontSize=12,
|
||||
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) :
|
||||
CViewText (id, std::string(""), FontSize, Color, Shadow)
|
||||
{
|
||||
_StringModifier= NULL;
|
||||
_IsDBLink = false;
|
||||
_TextId = nID;
|
||||
_Initialized = false;
|
||||
_DynamicString = false;
|
||||
_IsTextFormatTaged= false;
|
||||
}
|
||||
|
||||
// ctor with a db path entry
|
||||
CViewTextID (const std::string& id,
|
||||
const std::string &idDBPath,
|
||||
sint FontSize=12,
|
||||
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255),
|
||||
bool Shadow=false);
|
||||
|
||||
|
||||
~CViewTextID();
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
|
||||
bool parseTextIdOptions(xmlNodePtr cur);
|
||||
|
||||
uint32 getTextId () const;
|
||||
void setTextId (uint32 id);
|
||||
|
||||
/** set a text id from a db path
|
||||
* \return true if the link could be done
|
||||
*/
|
||||
bool setDBTextID(const std::string &dbPath);
|
||||
// set a text from a db leaf
|
||||
void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf);
|
||||
|
||||
std::string getTextIdDbLink() const;
|
||||
void setTextIdDbLink(const std::string &link);
|
||||
|
||||
void setDynamicString(bool state) {_DynamicString= state;}
|
||||
bool getDynamicString() const {return _DynamicString;}
|
||||
|
||||
// modify name when received
|
||||
void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;}
|
||||
IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;}
|
||||
|
||||
REFLECT_EXPORT_START(CViewTextID, CViewText)
|
||||
REFLECT_UINT32("textid", getTextId, setTextId);
|
||||
REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; }
|
||||
|
||||
protected:
|
||||
|
||||
bool _IsDBLink;
|
||||
CInterfaceProperty _DBTextId;
|
||||
uint32 _TextId;
|
||||
|
||||
bool _Initialized;
|
||||
|
||||
// If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString)
|
||||
bool _DynamicString;
|
||||
|
||||
// If true, setTextFormatted() is used instead of setText()
|
||||
bool _IsTextFormatTaged;
|
||||
|
||||
// Optional ucstring modifier
|
||||
IOnReceiveTextId *_StringModifier;
|
||||
std::string _DBPath;
|
||||
static IViewTextProvider* getTextProvider(){ return textProvider; }
|
||||
|
||||
private:
|
||||
static IViewTextProvider *textProvider;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_VIEW_TEXT_ID_H
|
||||
|
||||
/* End of view_text_id.h */
|
|
@ -1,50 +1,55 @@
|
|||
// 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 VIEW_TEXT_ID_FORMATED_H
|
||||
#define VIEW_TEXT_ID_FORMATED_H
|
||||
|
||||
#include "view_text_id.h"
|
||||
|
||||
/** The same as a view text id, but with some display option
|
||||
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
|
||||
* $t -> expand the value of the text id
|
||||
* $p -> expand the player name
|
||||
* $P -> expand the player name in uppercase
|
||||
* $b -> expand the current bot name ( bot with which the player is talking)
|
||||
* $s -> expand the current short bot name (with no specification/title in it)
|
||||
*/
|
||||
class CViewTextIDFormated : public CViewTextID
|
||||
{
|
||||
public:
|
||||
CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param)
|
||||
{}
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
const ucstring &getFormatString() const { return _FormatString; }
|
||||
void setFormatString(const ucstring &format);
|
||||
private:
|
||||
ucstring _FormatString;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
// 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 VIEW_TEXT_ID_FORMATED_H
|
||||
#define VIEW_TEXT_ID_FORMATED_H
|
||||
|
||||
#include "nel/gui/view_text_id.h"
|
||||
|
||||
/** The same as a view text id, but with some display option
|
||||
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
|
||||
* $t -> expand the value of the text id
|
||||
* $p -> expand the player name
|
||||
* $P -> expand the player name in uppercase
|
||||
* $b -> expand the current bot name ( bot with which the player is talking)
|
||||
* $s -> expand the current short bot name (with no specification/title in it)
|
||||
*/
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CViewTextIDFormated : public CViewTextID
|
||||
{
|
||||
public:
|
||||
CViewTextIDFormated(const TCtorParam ¶m) : CViewTextID(param)
|
||||
{}
|
||||
|
||||
std::string getProperty( const std::string &name ) const;
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
|
||||
virtual void checkCoords();
|
||||
const ucstring &getFormatString() const { return _FormatString; }
|
||||
void setFormatString(const ucstring &format);
|
||||
private:
|
||||
ucstring _FormatString;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
571
code/nel/include/nel/gui/widget_manager.h
Normal file
571
code/nel/include/nel/gui/widget_manager.h
Normal file
|
@ -0,0 +1,571 @@
|
|||
// 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 WIDGET_MANAGER_H
|
||||
#define WIDGET_MANAGER_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/gui/interface_common.h"
|
||||
#include "nel/gui/interface_options.h"
|
||||
#include "nel/gui/event_descriptor.h"
|
||||
#include "nel/3d/u_camera.h"
|
||||
#include "nel/gui/parser.h"
|
||||
#include "nel/gui/input_event_listener.h"
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class CCDBNodeLeaf;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
class CInterfaceElement;
|
||||
class CCtrlBase;
|
||||
class CViewBase;
|
||||
class CInterfaceGroup;
|
||||
class CViewPointerBase;
|
||||
class CInterfaceOptions;
|
||||
class CInterfaceAnim;
|
||||
class CProcedure;
|
||||
|
||||
/**
|
||||
GUI Widget Manager
|
||||
|
||||
Manages the GUI widgets, asks them to draw themselves, etc.
|
||||
*/
|
||||
class CWidgetManager : public IInputEventListener{
|
||||
|
||||
public:
|
||||
|
||||
/// Interface for event handlers that can be called when the screen is resized.
|
||||
class INewScreenSizeHandler
|
||||
{
|
||||
public:
|
||||
virtual ~INewScreenSizeHandler(){}
|
||||
virtual void process( uint32 w, uint32 h ) = 0;
|
||||
};
|
||||
|
||||
/// Interface for event handlers that can be called when the widgets finished drawing.
|
||||
class IOnWidgetsDrawnHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IOnWidgetsDrawnHandler(){};
|
||||
virtual void process() = 0;
|
||||
};
|
||||
|
||||
/// Frame render times
|
||||
struct SInterfaceTimes
|
||||
{
|
||||
public:
|
||||
/// Time when the last frame was rendered in ms.
|
||||
sint64 lastFrameMs;
|
||||
/// Time when the current frame was rendered in ms.
|
||||
sint64 thisFrameMs;
|
||||
/// Difference between the two times in ms.
|
||||
sint64 frameDiffMs;
|
||||
|
||||
SInterfaceTimes()
|
||||
{
|
||||
lastFrameMs = 0;
|
||||
thisFrameMs = 0;
|
||||
frameDiffMs = 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Master groups encapsulate all windows
|
||||
struct SMasterGroup
|
||||
{
|
||||
SMasterGroup()
|
||||
{
|
||||
Group = NULL;
|
||||
LastTopWindowPriority = WIN_PRIORITY_NORMAL;
|
||||
}
|
||||
|
||||
CInterfaceGroup *Group;
|
||||
std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ];
|
||||
|
||||
void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL );
|
||||
void delWindow( CInterfaceGroup *pIG );
|
||||
CInterfaceGroup *getWindowFromId( const std::string &winID );
|
||||
bool isWindowPresent( CInterfaceGroup *pIG );
|
||||
// Set a window top in its priority queue
|
||||
void setTopWindow( CInterfaceGroup *pIG );
|
||||
void setBackWindow( CInterfaceGroup *pIG );
|
||||
void deactiveAllContainers();
|
||||
void centerAllContainers();
|
||||
void unlockAllContainers();
|
||||
|
||||
// Sort the world space group
|
||||
void sortWorldSpaceGroup ();
|
||||
|
||||
uint8 LastTopWindowPriority;
|
||||
};
|
||||
|
||||
|
||||
// Infos about a modal window.
|
||||
struct SModalWndInfo
|
||||
{
|
||||
// Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after)
|
||||
NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window
|
||||
NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal;
|
||||
bool ModalClip;
|
||||
bool ModalExitClickOut;
|
||||
bool ModalExitClickL;
|
||||
bool ModalExitClickR;
|
||||
bool ModalExitKeyPushed;
|
||||
std::string ModalHandlerClickOut;
|
||||
std::string ModalClickOutParams;
|
||||
|
||||
SModalWndInfo()
|
||||
{
|
||||
ModalWindow = NULL;
|
||||
CtrlLaunchingModal = NULL;
|
||||
ModalExitClickOut = false;
|
||||
ModalExitClickL = false;
|
||||
ModalExitClickR = false;
|
||||
ModalExitKeyPushed = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static CWidgetManager* getInstance();
|
||||
static void release();
|
||||
|
||||
CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName );
|
||||
std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; }
|
||||
SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; }
|
||||
CInterfaceGroup* getWindowFromId( const std::string &groupId );
|
||||
void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
|
||||
void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
|
||||
void removeAllMasterGroups();
|
||||
|
||||
void activateMasterGroup (const std::string &sMasterGroupName, bool bActive);
|
||||
|
||||
CInterfaceElement* getElementFromId( const std::string &sEltId );
|
||||
CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId );
|
||||
|
||||
/**
|
||||
* get a window from its Id of its group.
|
||||
* NB: "ctrl_launch_modal" is a special Id which return the last ctrl which has launch a modal. NULL if modal closed.
|
||||
* \param groupId : the Id of the window group
|
||||
*/
|
||||
/// get an element from a define ID. shortcut for getElementFromId(getDefine(define))
|
||||
CInterfaceElement* getElementFromDefine( const std::string &defineId );
|
||||
|
||||
/// Get the window from an element (ui:interface:###)
|
||||
CInterfaceGroup* getWindow(CInterfaceElement*);
|
||||
|
||||
|
||||
/**
|
||||
* set the top window
|
||||
* \param win : pointer to the window to be set on top
|
||||
*/
|
||||
void setTopWindow (CInterfaceGroup *pWin);
|
||||
|
||||
/**
|
||||
* set the back window
|
||||
* \param win : pointer to the window to be set on top
|
||||
*/
|
||||
void setBackWindow (CInterfaceGroup *pWin);
|
||||
|
||||
/** get the top window in the first activated masterGroup
|
||||
*/
|
||||
CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
|
||||
|
||||
/** get the back window in the first activated masterGroup
|
||||
*/
|
||||
CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
|
||||
|
||||
/** get the last escapable top window in the first activated masterGroup
|
||||
*/
|
||||
CInterfaceGroup* getLastEscapableTopWindow() const;
|
||||
|
||||
void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority);
|
||||
|
||||
/** return the priority of the Last Window setTopWindow()-ed.
|
||||
*/
|
||||
uint8 getLastTopWindowPriority() const;
|
||||
|
||||
bool hasModal() const;
|
||||
|
||||
SModalWndInfo& getModal();
|
||||
|
||||
bool isPreviousModal( CInterfaceGroup *wnd ) const;
|
||||
|
||||
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
|
||||
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
|
||||
// Disable all modals windows
|
||||
void disableModalWindow ();
|
||||
|
||||
/** Push a modal window that becomes the current modal window
|
||||
*/
|
||||
void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
|
||||
void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
|
||||
void popModalWindow();
|
||||
// pop all top modal windows with the given category (a string stored in the modal)
|
||||
void popModalWindowCategory(const std::string &category);
|
||||
|
||||
void hideAllWindows();
|
||||
void hideAllNonSavableWindows();
|
||||
|
||||
CCtrlBase *getCtrlLaunchingModal ()
|
||||
{
|
||||
if (_ModalStack.empty()) return NULL;
|
||||
return _ModalStack.back().CtrlLaunchingModal;
|
||||
}
|
||||
/// get the currently active modal window, or NULL if none
|
||||
CInterfaceGroup *getModalWindow() const
|
||||
{
|
||||
if (_ModalStack.empty()) return NULL;
|
||||
return _ModalStack.back().ModalWindow;
|
||||
}
|
||||
|
||||
void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; }
|
||||
CCtrlBase* getCurContextHelp(){ return curContextHelp; }
|
||||
|
||||
float _DeltaTimeStopingContextHelp;
|
||||
float _MaxTimeStopingContextHelp;
|
||||
sint _LastXContextHelp;
|
||||
sint _LastYContextHelp;
|
||||
|
||||
CViewPointerBase* getPointer(){ return _Pointer; }
|
||||
void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; }
|
||||
|
||||
/**
|
||||
* get the window under a spot
|
||||
* \param : X coord of the spot
|
||||
* \param : Y coord of the spot
|
||||
* \return : pointer to the window
|
||||
*/
|
||||
CInterfaceGroup* getWindowUnder (sint32 x, sint32 y);
|
||||
CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; }
|
||||
void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; }
|
||||
CInterfaceGroup* getGroupUnder (sint32 x, sint32 y);
|
||||
|
||||
void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB );
|
||||
void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL );
|
||||
void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL );
|
||||
|
||||
const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; }
|
||||
const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; }
|
||||
const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; }
|
||||
|
||||
//
|
||||
void clearViewUnders(){ _ViewsUnderPointer.clear(); }
|
||||
void clearGroupsUnders() { _GroupsUnderPointer.clear(); }
|
||||
void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); }
|
||||
|
||||
// Remove all references on a view (called when the ctrl is destroyed)
|
||||
void removeRefOnView( CViewBase *ctrlBase );
|
||||
|
||||
// Remove all references on a ctrl (called when the ctrl is destroyed)
|
||||
void removeRefOnCtrl (CCtrlBase *ctrlBase);
|
||||
|
||||
// Remove all references on a group (called when the group is destroyed)
|
||||
void removeRefOnGroup (CInterfaceGroup *group);
|
||||
|
||||
void reset();
|
||||
|
||||
void checkCoords();
|
||||
|
||||
CInterfaceGroup* getWindowForActiveMasterGroup( const std::string &windowName );
|
||||
|
||||
void drawOverExtendViewText();
|
||||
|
||||
// Internal : adjust a tooltip with respect to its parent. Returns the number of coordinate that were clamped
|
||||
// against the screen border
|
||||
uint adjustTooltipPosition( CCtrlBase *newCtrl, CInterfaceGroup *win, THotSpot ttParentRef,
|
||||
THotSpot ttPosRef, sint32 xParent, sint32 yParent,
|
||||
sint32 wParent, sint32 hParent );
|
||||
|
||||
void updateTooltipCoords();
|
||||
|
||||
// Update tooltip coordinate if they need to be (getInvalidCoords() returns a value != 0)
|
||||
void updateTooltipCoords(CCtrlBase *newCtrl);
|
||||
|
||||
/// for ContextHelp action handler only: set the result name
|
||||
void setContextHelpText( const ucstring &text ){ _ContextHelpText = text; }
|
||||
ucstring& getContextHelpText(){ return _ContextHelpText; }
|
||||
|
||||
/// force disable the context help
|
||||
void disableContextHelp();
|
||||
|
||||
/// force disable the context help, if it is issued from the given control
|
||||
void disableContextHelpForControl(CCtrlBase *pCtrl);
|
||||
|
||||
CCtrlBase* getNewContextHelpCtrl();
|
||||
|
||||
void drawContextHelp();
|
||||
|
||||
void setContextHelpActive(bool active);
|
||||
|
||||
void getNewWindowCoordToNewScreenSize( sint32 &x, sint32 &y, sint32 w, sint32 h,
|
||||
sint32 newW, sint32 newH) const;
|
||||
|
||||
// move windows according to new screen size
|
||||
void moveAllWindowsToNewScreenSize(sint32 newScreenW, sint32 newScreenH, bool fixCurrentUI );
|
||||
|
||||
void updateAllLocalisedElements();
|
||||
|
||||
void drawViews( NL3D::UCamera camera );
|
||||
|
||||
bool handleEvent( const CEventDescriptor &evnt );
|
||||
|
||||
bool handleMouseMoveEvent( const CEventDescriptor &eventDesc );
|
||||
|
||||
// Relative move of pointer
|
||||
void movePointer (sint32 dx, sint32 dy);
|
||||
// Set absolute coordinates of pointer
|
||||
void movePointerAbs(sint32 px, sint32 py);
|
||||
|
||||
/**
|
||||
* Capture
|
||||
*/
|
||||
CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; }
|
||||
CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; }
|
||||
CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; }
|
||||
CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; }
|
||||
CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; }
|
||||
|
||||
void setCapturePointerLeft(CCtrlBase *c);
|
||||
void setCapturePointerRight(CCtrlBase *c);
|
||||
void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; }
|
||||
// NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture
|
||||
// to come back to the last captured window (resetCaptureKeyboard() not)
|
||||
void setCaptureKeyboard(CCtrlBase *c);
|
||||
/** Set the default box to use when no keyboard has been previously captured
|
||||
* The given dialog should be static
|
||||
*/
|
||||
void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; }
|
||||
|
||||
void resetCaptureKeyboard();
|
||||
|
||||
// True if the keyboard is captured
|
||||
bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;}
|
||||
|
||||
// register a view that wants to be notified at each frame (receive the msg 'clocktick')
|
||||
void registerClockMsgTarget(CCtrlBase *vb);
|
||||
void unregisterClockMsgTarget(CCtrlBase *vb);
|
||||
bool isClockMsgTarget(CCtrlBase *vb) const;
|
||||
void sendClockTickEvent();
|
||||
|
||||
void notifyElementCaptured(CCtrlBase *c);
|
||||
|
||||
// Add a group into the windows list of its master goup
|
||||
void makeWindow( CInterfaceGroup *group );
|
||||
|
||||
// Remove a group from the windows list of its master group
|
||||
void unMakeWindow( CInterfaceGroup *group, bool noWarning = false );
|
||||
|
||||
void setGlobalColor( NLMISC::CRGBA col );
|
||||
NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; }
|
||||
|
||||
void setContentAlpha( uint8 alpha );
|
||||
uint8 getContentAlpha() const{ return _ContentAlpha; }
|
||||
|
||||
NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; }
|
||||
void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; }
|
||||
void resetColorProps();
|
||||
|
||||
/// Get options by name
|
||||
CInterfaceOptions* getOptions( const std::string &optName );
|
||||
void addOptions( std::string name, CInterfaceOptions *options );
|
||||
void removeOptions( std::string name );
|
||||
void removeAllOptions();
|
||||
bool serializeOptions( xmlNodePtr parentNode ) const;
|
||||
bool serializeTreeData( xmlNodePtr parentNode ) const;
|
||||
|
||||
// Enable mouse Events to interface. if false, release Captures.
|
||||
void enableMouseHandling( bool handle );
|
||||
bool isMouseHandlingEnabled() const{ return _MouseHandlingEnabled; }
|
||||
bool isMouseOverWindow() const{ return _MouseOverWindow; }
|
||||
void setMouseOverWindow( bool b ){ _MouseOverWindow = b; }
|
||||
|
||||
// Get the User DblClick Delay (according to save...), in milisecond
|
||||
uint getUserDblClickDelay();
|
||||
|
||||
/// \name Global Interface Options
|
||||
// @{
|
||||
|
||||
// List of system options
|
||||
enum TSystemOption{
|
||||
OptionCtrlSheetGrayColor=0,
|
||||
OptionCtrlTextGrayColor,
|
||||
OptionCtrlSheetRedifyColor,
|
||||
OptionCtrlTextRedifyColor,
|
||||
OptionCtrlSheetGreenifyColor,
|
||||
OptionCtrlTextGreenifyColor,
|
||||
OptionViewTextOverBackColor,
|
||||
OptionFont,
|
||||
OptionAddCoefFont,
|
||||
OptionMulCoefAnim,
|
||||
OptionTimeoutBubbles,
|
||||
OptionTimeoutMessages,
|
||||
OptionTimeoutContext,
|
||||
OptionTimeoutContextHtml,
|
||||
NumSystemOptions
|
||||
};
|
||||
|
||||
void setupOptions();
|
||||
/** Get a system option by its enum (faster than getOptions() and getVal())
|
||||
* NB: array updated after each parseInterface()
|
||||
*/
|
||||
const CInterfaceOptionValue &getSystemOption( TSystemOption o ) const{ return _SystemOptions[ o ]; }
|
||||
|
||||
// @}
|
||||
|
||||
CInterfaceElement* getOverExtendViewText(){ return _OverExtendViewText; }
|
||||
NLMISC::CRGBA& getOverExtendViewTextBackColor(){ return _OverExtendViewTextBackColor; }
|
||||
|
||||
// For single lined ViewText that are clipped: on over of viewText too big, the text is drawn on top. A CRefPtr is kept
|
||||
void setOverExtendViewText( CInterfaceElement *vt, NLMISC::CRGBA backGround ){
|
||||
_OverExtendViewText = vt;
|
||||
_OverExtendViewTextBackColor = backGround;
|
||||
}
|
||||
|
||||
float getAlphaRolloverSpeed();
|
||||
void resetAlphaRolloverSpeed();
|
||||
|
||||
void setContainerAlpha( uint8 alpha );
|
||||
uint8 getContainerAlpha() const { return _ContainerAlpha; }
|
||||
uint8 getGlobalContentAlpha() const { return _GlobalContentAlpha; }
|
||||
uint8 getGlobalContainerAlpha() const { return _GlobalContainerAlpha; }
|
||||
uint8 getGlobalRolloverFactorContent() const { return _GlobalRolloverFactorContent; }
|
||||
uint8 getGlobalRolloverFactorContainer() const { return _GlobalRolloverFactorContainer; }
|
||||
|
||||
void updateGlobalAlphas();
|
||||
|
||||
const SInterfaceTimes& getInterfaceTimes() const{ return interfaceTimes; }
|
||||
void updateInterfaceTimes( const SInterfaceTimes × ){ interfaceTimes = times; }
|
||||
|
||||
void setIngame( bool i ){ inGame = i; }
|
||||
bool isIngame() const{ return inGame; }
|
||||
|
||||
void setScreenWH( uint32 w, uint32 h ){ screenW = w; screenH = h; }
|
||||
|
||||
void registerNewScreenSizeHandler( INewScreenSizeHandler *handler );
|
||||
void removeNewScreenSizeHandler( INewScreenSizeHandler *handler );
|
||||
|
||||
void registerOnWidgetsDrawnHandler( IOnWidgetsDrawnHandler* handler );
|
||||
void removeOnWidgetsDrawnHandler( IOnWidgetsDrawnHandler *handler );
|
||||
|
||||
void startAnim( const std::string &animId );
|
||||
void stopAnim( const std::string &animId );
|
||||
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; }
|
||||
|
||||
IParser* getParser() const{ return parser; }
|
||||
|
||||
void setCurrentEditorSelection( const std::string &name );
|
||||
|
||||
private:
|
||||
CWidgetManager();
|
||||
~CWidgetManager();
|
||||
|
||||
IParser *parser;
|
||||
|
||||
static CWidgetManager *instance;
|
||||
std::vector< SMasterGroup > _MasterGroups;
|
||||
std::vector< SModalWndInfo > _ModalStack;
|
||||
static std::string _CtrlLaunchingModalId;
|
||||
NLMISC::CRefPtr< CCtrlBase > curContextHelp;
|
||||
CViewPointerBase *_Pointer;
|
||||
|
||||
// Options description
|
||||
std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap;
|
||||
|
||||
NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder;
|
||||
|
||||
// Capture
|
||||
NLMISC::CRefPtr<CCtrlBase> _CaptureKeyboard;
|
||||
NLMISC::CRefPtr<CCtrlBase> _OldCaptureKeyboard;
|
||||
NLMISC::CRefPtr<CCtrlBase> _DefaultCaptureKeyboard;
|
||||
NLMISC::CRefPtr<CCtrlBase> _CapturePointerLeft;
|
||||
NLMISC::CRefPtr<CCtrlBase> _CapturePointerRight;
|
||||
|
||||
// What is under pointer
|
||||
std::vector< CViewBase* > _ViewsUnderPointer;
|
||||
std::vector< CCtrlBase* > _CtrlsUnderPointer;
|
||||
std::vector< CInterfaceGroup* > _GroupsUnderPointer;
|
||||
|
||||
// view that should be notified from clock msg
|
||||
std::vector<CCtrlBase*> _ClockMsgTargets;
|
||||
|
||||
NLMISC::CRGBA _GlobalColor;
|
||||
NLMISC::CRGBA _GlobalColorForContent;
|
||||
uint8 _ContentAlpha;
|
||||
|
||||
NLMISC::CCDBNodeLeaf *_RProp;
|
||||
NLMISC::CCDBNodeLeaf *_GProp;
|
||||
NLMISC::CCDBNodeLeaf *_BProp;
|
||||
NLMISC::CCDBNodeLeaf *_AProp;
|
||||
NLMISC::CCDBNodeLeaf *_AlphaRolloverSpeedDB;
|
||||
|
||||
uint8 _ContainerAlpha;
|
||||
uint8 _GlobalContentAlpha;
|
||||
uint8 _GlobalContainerAlpha;
|
||||
uint8 _GlobalRolloverFactorContent;
|
||||
uint8 _GlobalRolloverFactorContainer;
|
||||
|
||||
bool _MouseHandlingEnabled;
|
||||
|
||||
// System Options
|
||||
CInterfaceOptionValue _SystemOptions[ NumSystemOptions ];
|
||||
|
||||
// The next ViewText to draw for Over
|
||||
NLMISC::CRefPtr< CInterfaceElement > _OverExtendViewText;
|
||||
NLMISC::CRGBA _OverExtendViewTextBackColor;
|
||||
|
||||
SInterfaceTimes interfaceTimes;
|
||||
|
||||
ucstring _ContextHelpText;
|
||||
bool _ContextHelpActive;
|
||||
|
||||
bool inGame;
|
||||
|
||||
bool _MouseOverWindow;
|
||||
|
||||
CEventDescriptorKey lastKeyEvent;
|
||||
|
||||
uint32 screenH;
|
||||
uint32 screenW;
|
||||
|
||||
std::vector< CInterfaceAnim* > activeAnims;
|
||||
|
||||
std::vector< INewScreenSizeHandler* > newScreenSizeHandlers;
|
||||
std::vector< IOnWidgetsDrawnHandler* > onWidgetsDrawnHandlers;
|
||||
|
||||
std::string currentEditorSelection;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,366 +1,367 @@
|
|||
// 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 CDB_H
|
||||
#define CDB_H
|
||||
|
||||
// misc
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "nel/misc/string_mapper.h"
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class IProgressCallback;
|
||||
class CBitMemStream;
|
||||
}
|
||||
|
||||
class CCDBNodeLeaf;
|
||||
class CCDBNodeBranch;
|
||||
|
||||
///global bool, must be set to true if we want to display database modification. See displayDBModifs in commands.cpp
|
||||
extern bool VerboseDatabase;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Interface to manage a database node, can contain a unique property or a set of property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class ICDBNode : public NLMISC::CRefCount
|
||||
{
|
||||
//-----------------------------------------------------------------------
|
||||
// end of IDBNode interface
|
||||
// start of CDB sub-class definitions
|
||||
|
||||
public:
|
||||
enum EPropType
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
// Unsigned
|
||||
I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16,
|
||||
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
|
||||
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
|
||||
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
|
||||
// Signed
|
||||
S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16,
|
||||
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
|
||||
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
|
||||
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
|
||||
TEXT, Nb_Prop_Type
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* observer interface to a database property
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class IPropertyObserver : public NLMISC::CRefCount
|
||||
{
|
||||
public :
|
||||
virtual ~IPropertyObserver() {}
|
||||
virtual void update(ICDBNode* node ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Text id
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CTextId
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CTextId(): _Idx(0) {}
|
||||
|
||||
/**
|
||||
* Init this text id from a string
|
||||
*/
|
||||
explicit CTextId( const std::string& str ): _Idx(0)
|
||||
{
|
||||
const std::string &s = str;
|
||||
uint32 i, j;
|
||||
for (i=0,j=0; i+j<s.size(); j++)
|
||||
if (s[i+j]==':')
|
||||
{
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
i+=j+1; // +1 to skip the ':'
|
||||
j=0;
|
||||
}
|
||||
// deal with the last id in the string (terminated by a '\x0' and not a ':')
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a string from this text id
|
||||
*/
|
||||
std::string toString() const
|
||||
{
|
||||
if (_Ids.size()==0) return std::string("");
|
||||
std::string str=_Ids[0];
|
||||
for (unsigned i=1; i<_Ids.size(); i++)
|
||||
str +=std::string(":")+ _Ids[i];
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push back a sub name id to this id
|
||||
*/
|
||||
void push( const std::string &str ) { _Ids.push_back( str ); }
|
||||
|
||||
/**
|
||||
* Remove the last sub name id to this id
|
||||
*/
|
||||
void pop() { _Ids.pop_back(); }
|
||||
|
||||
/**
|
||||
* Return the next sub id
|
||||
*/
|
||||
const std::string &readNext() const
|
||||
{
|
||||
nlassert( _Idx < _Ids.size() );
|
||||
return _Ids[_Idx++];
|
||||
}
|
||||
|
||||
/** return true if a call to readNext can be performed
|
||||
*/
|
||||
bool hasElements() const { return _Idx < _Ids.size(); }
|
||||
|
||||
/**
|
||||
* Get the current index in Id
|
||||
*/
|
||||
uint getCurrentIndex() const { return _Idx; }
|
||||
|
||||
/**
|
||||
* Return the count of strings composing this id
|
||||
*/
|
||||
uint size() const { return (uint)_Ids.size(); }
|
||||
|
||||
/** Return an element. empty if bad index
|
||||
*/
|
||||
const std::string &getElement(uint idx)
|
||||
{
|
||||
static std::string empty;
|
||||
if(idx>=size())
|
||||
return empty;
|
||||
else
|
||||
return _Ids[idx];
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::string> _Ids;
|
||||
mutable uint _Idx;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// end of CDB sub-class definitions
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// IDBNode interface definition
|
||||
|
||||
public :
|
||||
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
virtual ~ICDBNode() {}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
virtual void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false ) = 0;
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
virtual void write( CTextId& id, FILE * f) = 0;
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param gc the server gameCycle of this update. Any outdated update are aborted
|
||||
* \param f : the stream.
|
||||
*/
|
||||
virtual void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
virtual ICDBNode * getNode( const CTextId& id, bool bCreate = true )=0 ;
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
virtual ICDBNode * getNode( uint16 idx ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
* \param index is a reference that receive the result
|
||||
* \return true if the node was found
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint & index) = 0;
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
virtual sint64 getProp( CTextId& id ) = 0;
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
virtual bool setProp( CTextId& id, sint64 value ) = 0;
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
virtual void resetData(NLMISC::TGameCycle gc, bool forceReset=false) = 0;
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doesn't exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/**
|
||||
* Inform a node of its parenthood
|
||||
*/
|
||||
virtual void setParent(CCDBNodeBranch * /* parent */) { nlassertex(0,("setParent() not overloaded for given node type!")); }
|
||||
|
||||
/**
|
||||
* get the parent of a node
|
||||
*/
|
||||
virtual CCDBNodeBranch* getParent() { nlassertex(0,("getParent() not overloaded for given node type!")); return NULL; }
|
||||
|
||||
/**
|
||||
* get the name of this node
|
||||
*/
|
||||
const std::string * getName() const { return &_DBSM->localUnmap(_Name); }
|
||||
|
||||
/**
|
||||
* get the full name of this node separator is ':' (ie UI:INTERFACE:REDSTUFF)
|
||||
* This will not return the fullname with the ROOT !
|
||||
*/
|
||||
std::string getFullName();
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const = 0;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0;
|
||||
|
||||
/// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time)
|
||||
void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; }
|
||||
|
||||
/// Return true if the branch has the atomic flag
|
||||
bool isAtomic() const { return _AtomicFlag; }
|
||||
|
||||
// test if the node is a leaf
|
||||
virtual bool isLeaf() const = 0;
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display (const std::string &/* prefix */){}
|
||||
|
||||
/// Return the string id corresponding to the argument
|
||||
static NLMISC::TStringId getStringId(const std::string& nodeName)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
return _DBSM->localMap(nodeName);
|
||||
}
|
||||
|
||||
/// Return a pointer to the string corresponding to the argument
|
||||
static const std::string *getStringFromId(NLMISC::TStringId nodeStringId)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
return &_DBSM->localUnmap(nodeStringId);
|
||||
}
|
||||
|
||||
/// release string mapper
|
||||
static void releaseStringMapper();
|
||||
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
ICDBNode() : _AtomicFlag(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
_Name = NLMISC::CStringMapper::emptyId();
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
ICDBNode (const std::string &name) : _AtomicFlag(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper();
|
||||
_Name = _DBSM->localMap(name);
|
||||
//_NameDbg = name;
|
||||
}
|
||||
|
||||
// utility to build full name efficiently (without reallocating the string at each parent level)
|
||||
void _buildFullName(NLMISC::CSString &fullName);
|
||||
|
||||
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
|
||||
bool _AtomicFlag : 1;
|
||||
|
||||
/// Name of the node
|
||||
NLMISC::TStringId _Name;
|
||||
//std::string _NameDbg;
|
||||
|
||||
static NLMISC::CStringMapper *_DBSM;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CDB_H
|
||||
// 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 CDB_H
|
||||
#define CDB_H
|
||||
|
||||
// misc
|
||||
#include "types_nl.h"
|
||||
#include "smart_ptr.h"
|
||||
#include "string_mapper.h"
|
||||
#include "sstring.h"
|
||||
|
||||
#include <libxml/parser.h>
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
class IProgressCallback;
|
||||
class CBitMemStream;
|
||||
class CCDBNodeLeaf;
|
||||
class CCDBNodeBranch;
|
||||
class CCDBBankHandler;
|
||||
|
||||
/**
|
||||
* Interface to manage a database node, can contain a unique property or a set of property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
|
||||
class ICDBNode : public CRefCount
|
||||
{
|
||||
//-----------------------------------------------------------------------
|
||||
// end of IDBNode interface
|
||||
// start of CDB sub-class definitions
|
||||
|
||||
public:
|
||||
enum EPropType
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
// Unsigned
|
||||
I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16,
|
||||
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
|
||||
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
|
||||
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
|
||||
// Signed
|
||||
S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16,
|
||||
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
|
||||
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
|
||||
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
|
||||
TEXT, Nb_Prop_Type
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* observer interface to a database property
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class IPropertyObserver : public CRefCount
|
||||
{
|
||||
public :
|
||||
virtual ~IPropertyObserver() {}
|
||||
virtual void update(ICDBNode* node ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Text id
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CTextId
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CTextId(): _Idx(0) {}
|
||||
|
||||
/**
|
||||
* Init this text id from a string
|
||||
*/
|
||||
explicit CTextId( const std::string& str ): _Idx(0)
|
||||
{
|
||||
const std::string &s = str;
|
||||
uint32 i, j;
|
||||
for (i=0,j=0; i+j<s.size(); j++)
|
||||
if (s[i+j]==':')
|
||||
{
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
i+=j+1; // +1 to skip the ':'
|
||||
j=0;
|
||||
}
|
||||
// deal with the last id in the string (terminated by a '\x0' and not a ':')
|
||||
_Ids.push_back(s.substr(i,j));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a string from this text id
|
||||
*/
|
||||
std::string toString() const
|
||||
{
|
||||
if (_Ids.size()==0) return std::string("");
|
||||
std::string str=_Ids[0];
|
||||
for (unsigned i=1; i<_Ids.size(); i++)
|
||||
str +=std::string(":")+ _Ids[i];
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push back a sub name id to this id
|
||||
*/
|
||||
void push( const std::string &str ) { _Ids.push_back( str ); }
|
||||
|
||||
/**
|
||||
* Remove the last sub name id to this id
|
||||
*/
|
||||
void pop() { _Ids.pop_back(); }
|
||||
|
||||
/**
|
||||
* Return the next sub id
|
||||
*/
|
||||
const std::string &readNext() const
|
||||
{
|
||||
nlassert( _Idx < _Ids.size() );
|
||||
return _Ids[_Idx++];
|
||||
}
|
||||
|
||||
/** return true if a call to readNext can be performed
|
||||
*/
|
||||
bool hasElements() const { return _Idx < _Ids.size(); }
|
||||
|
||||
/**
|
||||
* Get the current index in Id
|
||||
*/
|
||||
uint getCurrentIndex() const { return _Idx; }
|
||||
|
||||
/**
|
||||
* Return the count of strings composing this id
|
||||
*/
|
||||
uint size() const { return (uint)_Ids.size(); }
|
||||
|
||||
/** Return an element. empty if bad index
|
||||
*/
|
||||
const std::string &getElement(uint idx)
|
||||
{
|
||||
static std::string empty;
|
||||
if(idx>=size())
|
||||
return empty;
|
||||
else
|
||||
return _Ids[idx];
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::string> _Ids;
|
||||
mutable uint _Idx;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// end of CDB sub-class definitions
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// IDBNode interface definition
|
||||
|
||||
public :
|
||||
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
virtual ~ICDBNode() {}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ) = 0;
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
virtual void write( CTextId& id, FILE * f) = 0;
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param gc the server gameCycle of this update. Any outdated update are aborted
|
||||
* \param f : the stream.
|
||||
*/
|
||||
virtual void readDelta( TGameCycle gc, CBitMemStream & f ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
virtual ICDBNode * getNode( const CTextId& id, bool bCreate = true )=0 ;
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
virtual ICDBNode * getNode( uint16 idx ) = 0;
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
* \param index is a reference that receive the result
|
||||
* \return true if the node was found
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint & index) = 0;
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
virtual sint64 getProp( CTextId& id ) = 0;
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
virtual bool setProp( CTextId& id, sint64 value ) = 0;
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
virtual void resetData(TGameCycle gc, bool forceReset=false) = 0;
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doesn't exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id) = 0;
|
||||
|
||||
/**
|
||||
* Inform a node of its parenthood
|
||||
*/
|
||||
virtual void setParent(CCDBNodeBranch * /* parent */) { nlassertex(0,("setParent() not overloaded for given node type!")); }
|
||||
|
||||
/**
|
||||
* get the parent of a node
|
||||
*/
|
||||
virtual CCDBNodeBranch* getParent() { nlassertex(0,("getParent() not overloaded for given node type!")); return NULL; }
|
||||
|
||||
/**
|
||||
* get the name of this node
|
||||
*/
|
||||
const std::string * getName() const { return &_DBSM->localUnmap(_Name); }
|
||||
|
||||
/**
|
||||
* get the full name of this node separator is ':' (ie UI:INTERFACE:REDSTUFF)
|
||||
* This will not return the fullname with the ROOT !
|
||||
*/
|
||||
std::string getFullName();
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const = 0;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0;
|
||||
|
||||
/// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time)
|
||||
void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; }
|
||||
|
||||
/// Return true if the branch has the atomic flag
|
||||
bool isAtomic() const { return _AtomicFlag; }
|
||||
|
||||
// test if the node is a leaf
|
||||
virtual bool isLeaf() const = 0;
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display (const std::string &/* prefix */){}
|
||||
|
||||
/// Return the string id corresponding to the argument
|
||||
static TStringId getStringId(const std::string& nodeName)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
|
||||
return _DBSM->localMap(nodeName);
|
||||
}
|
||||
|
||||
/// Return a pointer to the string corresponding to the argument
|
||||
static const std::string *getStringFromId(TStringId nodeStringId)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
|
||||
return &_DBSM->localUnmap(nodeStringId);
|
||||
}
|
||||
|
||||
/// release string mapper
|
||||
static void releaseStringMapper();
|
||||
|
||||
static bool isDatabaseVerbose(){ return verboseDatabase; }
|
||||
static void setVerboseDatabase( bool b ){ verboseDatabase = b; }
|
||||
|
||||
protected:
|
||||
|
||||
/// Constructor
|
||||
ICDBNode() : _AtomicFlag(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
|
||||
_Name = CStringMapper::emptyId();
|
||||
}
|
||||
|
||||
/// Constructor
|
||||
ICDBNode (const std::string &name) : _AtomicFlag(false)
|
||||
{
|
||||
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
|
||||
_Name = _DBSM->localMap(name);
|
||||
//_NameDbg = name;
|
||||
}
|
||||
|
||||
// utility to build full name efficiently (without reallocating the string at each parent level)
|
||||
void _buildFullName(CSString &fullName);
|
||||
|
||||
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
|
||||
bool _AtomicFlag : 1;
|
||||
|
||||
/// Name of the node
|
||||
TStringId _Name;
|
||||
//std::string _NameDbg;
|
||||
|
||||
static CStringMapper *_DBSM;
|
||||
|
||||
static bool verboseDatabase;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // CDB_H
|
145
code/nel/include/nel/misc/cdb_bank_handler.h
Normal file
145
code/nel/include/nel/misc/cdb_bank_handler.h
Normal file
|
@ -0,0 +1,145 @@
|
|||
// 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 CDB_BANK_HANDLER
|
||||
#define CDB_BANK_HANDLER
|
||||
|
||||
#include <vector>
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
@brief Manages the bank names and mappings of the CDB it's associated with
|
||||
|
||||
Banks are numeric identifiers for the top-level branches of the CDB.
|
||||
They are used for saving bandwidth, because the local CDBs are updated with deltas,
|
||||
that identify the updatable top-level branch with this id.
|
||||
The CCDBBankHandler manages the mapping of banks to their names, unified (node) index,
|
||||
and the other way around.
|
||||
|
||||
*/
|
||||
class CCDBBankHandler{
|
||||
public:
|
||||
/**
|
||||
@brief The class' constructor
|
||||
@param maxbanks the maximum number of banks we need to handle
|
||||
*/
|
||||
CCDBBankHandler( uint maxbanks );
|
||||
|
||||
/// Very surprisingly this is the destructor
|
||||
~CCDBBankHandler(){}
|
||||
|
||||
/**
|
||||
@brief Returns the unified (node) index for the specified bank Id.
|
||||
@param bank The bank whose uid we need.
|
||||
@return Returns an uid or static_cast< uint >( -1 ) on failure.
|
||||
*/
|
||||
uint getUIDForBank( uint bank ) const;
|
||||
|
||||
/**
|
||||
@brief Returns the bank Id for the specified unified (node) index.
|
||||
@param uid The unified (node) index we need to translate to bank Id.
|
||||
@return Returns a bank Id.
|
||||
*/
|
||||
uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; }
|
||||
|
||||
/// Returns the last unified (node) index we mapped.
|
||||
uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; }
|
||||
|
||||
/**
|
||||
@brief Returns the number of bits used to store the number of nodes that belong to this bank.
|
||||
@param bank The banks whose id bits we need.
|
||||
@return Returns the number of bits used to store the number of nodes that belong to this bank.
|
||||
*/
|
||||
uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; }
|
||||
|
||||
/**
|
||||
@brief Returns the name of the specified bank.
|
||||
@param bank The id of the bank we need the name of.
|
||||
@return Returns the name of the specified bank.
|
||||
*/
|
||||
std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; }
|
||||
|
||||
/**
|
||||
@brief Looks up the bank Id of the bank name specified.
|
||||
@param name The name of the bank whose Id we need.
|
||||
@return Returns the id of the bank, or static_cast< uint >( -1 ) on fail.
|
||||
*/
|
||||
uint getBankByName( const std::string &name ) const;
|
||||
|
||||
/**
|
||||
@brief Maps the specified bank name to a unified (node) index and vica versa.
|
||||
@param bankName Name of the bank to map.
|
||||
*/
|
||||
void mapNodeByBank( const std::string &bankName );
|
||||
|
||||
/**
|
||||
@brief Loads the known bank names from an array ( the order decides the bank Id ).
|
||||
@param strings The array of the banks names.
|
||||
@param size The size of the array.
|
||||
*/
|
||||
void fillBankNames( const char **strings, uint size );
|
||||
|
||||
/// Resets the node to bank mapping vector
|
||||
void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); }
|
||||
|
||||
/// Resets all maps, and sets _CDBLastUnifiedIndex to 0.
|
||||
void reset();
|
||||
|
||||
uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); }
|
||||
|
||||
/// Calculates the number of bits used to store the number of nodes that belong to the banks.
|
||||
void calcIdBitsByBank();
|
||||
|
||||
/**
|
||||
@brief Looks up the unified (node) index of a bank node.
|
||||
@param bank The bank id of the node we are looking up.
|
||||
@param index The index of the node within the bank.
|
||||
@return Returns the unified (node) index of the specified bank node.
|
||||
*/
|
||||
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
|
||||
|
||||
/**
|
||||
@brief Resizes the bank holders. WARNING: Resets data contained.
|
||||
@param newSize - The new maximum number of banks.
|
||||
*/
|
||||
void resize( uint newSize );
|
||||
|
||||
private:
|
||||
/// Mapping from server database index to client database index (first-level nodes)
|
||||
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
|
||||
|
||||
/// Mapping from client database index to bank IDs (first-level nodes)
|
||||
std::vector< uint > _UnifiedIndexToBank;
|
||||
|
||||
/// Last index mapped
|
||||
uint _CDBLastUnifiedIndex;
|
||||
|
||||
/// Number of bits for first-level branches, by bank
|
||||
std::vector< uint > _FirstLevelIdBitsByBank;
|
||||
|
||||
/// Names of the CDB banks
|
||||
std::vector< std::string > _CDBBankNames;
|
||||
|
||||
/// The number of banks used
|
||||
uint maxBanks;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,336 +1,260 @@
|
|||
// 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 CDB_BRANCH_H
|
||||
#define CDB_BRANCH_H
|
||||
|
||||
#include "cdb.h"
|
||||
#include "game_share/ryzom_database_banks.h"
|
||||
|
||||
/**
|
||||
* Database Node which contains a set of properties
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeBranch : public ICDBNode
|
||||
{
|
||||
public:
|
||||
|
||||
// default constructor
|
||||
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent = NULL;
|
||||
_IdBits = 0;
|
||||
_Sorted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, class NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
|
||||
|
||||
/**
|
||||
* Add a new sub node
|
||||
* \param node is the new subnode
|
||||
* \param nodeName is the name of the node
|
||||
*/
|
||||
void attachChild( ICDBNode * node, std::string nodeName );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate=true);
|
||||
|
||||
/**
|
||||
* Get a node. Return NULL if out of bounds (no warning)
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint& index)
|
||||
{
|
||||
index=0;
|
||||
for ( std::vector<ICDBNode*>::const_iterator it = _Nodes.begin(); it != _Nodes.end(); it++)
|
||||
{
|
||||
if (*it == node)
|
||||
return true;
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return the child with the given node id, creating it if requested
|
||||
CCDBNodeLeaf *getLeaf( const char *id, bool bCreate );
|
||||
CCDBNodeLeaf *getLeaf( const std::string &id, bool bCreate ) { return getLeaf(id.c_str(), bCreate); }
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
void write( CTextId& id, FILE * f);
|
||||
|
||||
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
|
||||
void readAndMapDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream& s, TCDBBank bank );
|
||||
|
||||
/// Update the database from a stream coming from the FE
|
||||
void readDelta( NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/// Clear the node and his children
|
||||
void clear();
|
||||
|
||||
/// Reset the data corresponding to the bank (works only on top level node)
|
||||
void resetBank( NLMISC::TGameCycle gc, TCDBBank bank)
|
||||
{
|
||||
//nlassert( getParent() == NULL );
|
||||
for ( uint i=0; i!=_Nodes.size(); ++i )
|
||||
{
|
||||
if ( _UnifiedIndexToBank[i] == bank )
|
||||
_Nodes[i]->resetData(gc);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(NLMISC::TGameCycle gc, bool forceReset=false)
|
||||
{
|
||||
for ( uint i=0; i!=_Nodes.size(); ++i )
|
||||
{
|
||||
_Nodes[i]->resetData(gc, forceReset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~CCDBNodeBranch() { clear(); }
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch *parent) { _Parent=parent; }
|
||||
|
||||
virtual CCDBNodeBranch* getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
//get the number of nodes
|
||||
uint16 getNbNodes()
|
||||
{
|
||||
return (uint16)_Nodes.size();
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count );
|
||||
|
||||
virtual void display (const std::string &prefix);
|
||||
|
||||
void removeNode (const CTextId& id);
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
// Add an observer to this branch. It will be notified of any change in the sub-leaves
|
||||
|
||||
/**
|
||||
* Add observer to all sub-leaves, except if a positive filter is set:
|
||||
* If positiveLeafNameFilter is non-empty, only changes to leaves having names found in it
|
||||
* will be notified (this is equivalent to creating a sub-branch containing only the specified leaves
|
||||
* and setting a branch observer on it, except you don't need to change your database paths
|
||||
* and update large amounts of code!).
|
||||
*/
|
||||
void addBranchObserver(IPropertyObserver* observer, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
|
||||
|
||||
/**
|
||||
* Easy version of addBranchObserver() (see above).
|
||||
* Examples of dbPathFromThisNode:
|
||||
* "" -> this node
|
||||
* "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node
|
||||
*/
|
||||
void addBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
|
||||
|
||||
// Remove observer from all sub-leaves
|
||||
bool removeBranchObserver(IPropertyObserver* observer);
|
||||
|
||||
/// Easy version of removeBranchObserver() (see above and see easy version of addBranchObserver())
|
||||
void removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer);
|
||||
|
||||
virtual bool isLeaf() const { return false; }
|
||||
|
||||
/** Update all observers of branchs that have been modified
|
||||
*/
|
||||
static void flushObserversCalls();
|
||||
|
||||
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
|
||||
void linkInModifiedNodeList(NLMISC::TStringId modifiedLeafName);
|
||||
|
||||
/// Find a subnode at this level
|
||||
ICDBNode * find (const std::string &nodeName);
|
||||
|
||||
/// Main init
|
||||
static void resetNodeBankMapping() { _UnifiedIndexToBank.clear(); }
|
||||
|
||||
// reset all static mappings
|
||||
static void reset();
|
||||
|
||||
/// Internal use only
|
||||
static void mapNodeByBank( ICDBNode *node, const std::string& bankStr, bool clientOnly, uint nodeIndex );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/** Struct identifying an observer of a db branch
|
||||
* This struct can be linked in a list so that we can update observers only once per pass.
|
||||
* An observer that watch a whole branch can be updated once and only once after each element of the branch has been modified
|
||||
*/
|
||||
class CDBBranchObsInfo
|
||||
{
|
||||
public:
|
||||
NLMISC::CRefPtr<IPropertyObserver> Observer;
|
||||
// 2 linked list are required : while the observer is notified, it can triger one other observer, so we must link it in another list
|
||||
bool Touched[2];
|
||||
CDBBranchObsInfo *PrevNotifiedObserver[2]; // NULL means this is the head
|
||||
CDBBranchObsInfo *NextNotifiedObserver[2];
|
||||
ICDBNode *Owner;
|
||||
|
||||
// If non-empty, only a leaf whose name is found here will notify something
|
||||
// This is equivalent to creating a sub-branch containing only the specified leaves
|
||||
// and setting a branch observer on it, except you don't need to change your database paths
|
||||
// and update large amounts of code and script!
|
||||
std::vector<NLMISC::TStringId> PositiveLeafNameFilter;
|
||||
|
||||
public:
|
||||
|
||||
/// Constructor. See above for usage of positiveLeafNameFilter.
|
||||
CDBBranchObsInfo(IPropertyObserver *obs = NULL, ICDBNode *owner = NULL, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>())
|
||||
{
|
||||
Owner = owner;
|
||||
Observer = obs;
|
||||
Touched[0] = Touched[1] = false;
|
||||
PrevNotifiedObserver[0] = PrevNotifiedObserver[1] = NULL;
|
||||
NextNotifiedObserver[0] = NextNotifiedObserver[1] = NULL;
|
||||
for (std::vector<std::string>::const_iterator ipf=positiveLeafNameFilter.begin(); ipf!=positiveLeafNameFilter.end(); ++ipf)
|
||||
{
|
||||
PositiveLeafNameFilter.push_back(ICDBNode::getStringId(*ipf)); // the ids are also mapped at database init, we don't need to unmap them in destructor
|
||||
}
|
||||
}
|
||||
~CDBBranchObsInfo()
|
||||
{
|
||||
// should have been unlinked
|
||||
nlassert(Touched[0] == false);
|
||||
nlassert(Touched[1] == false);
|
||||
nlassert(PrevNotifiedObserver[0] == NULL);
|
||||
nlassert(PrevNotifiedObserver[1] == NULL);
|
||||
nlassert(NextNotifiedObserver[0] == NULL);
|
||||
nlassert(NextNotifiedObserver[1] == NULL);
|
||||
}
|
||||
// Unlink from the given list. This also clear the '_Touched' flag
|
||||
void unlink(uint list);
|
||||
void link(uint list, NLMISC::TStringId modifiedLeafName);
|
||||
};
|
||||
|
||||
typedef std::list<CDBBranchObsInfo> TObsList; // must use a list because pointers on CDBObserverInfo instances must remains valids
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
CCDBNodeBranch *_Parent;
|
||||
|
||||
/// database subnodes not sorted
|
||||
std::vector<ICDBNode*> _Nodes;
|
||||
|
||||
/// subnodes sorted by name
|
||||
std::vector<ICDBNode*> _NodesByName;
|
||||
|
||||
// number of bits required to stock my children's ids
|
||||
uint8 _IdBits : 7;
|
||||
bool _Sorted : 1;
|
||||
|
||||
// observers for this node or branch
|
||||
TObsList _Observers;
|
||||
|
||||
friend class CDBBranchObsInfo;
|
||||
// Global list of modified nodes
|
||||
static CDBBranchObsInfo *_FirstNotifiedObs[2];
|
||||
static CDBBranchObsInfo *_LastNotifiedObs[2];
|
||||
static uint _CurrNotifiedObsList; // 0 or 1 => tell in which list observers of modified values must be added
|
||||
// current & next observers being notified : if such observer if removed during notification, pointer will be valids
|
||||
static CDBBranchObsInfo *_CurrNotifiedObs;
|
||||
static CDBBranchObsInfo *_NextNotifiedObs;
|
||||
|
||||
/// Mapping from server database index to client database index (first-level nodes)
|
||||
static std::vector<uint> _CDBBankToUnifiedIndexMapping [NB_CDB_BANKS];
|
||||
|
||||
// Mapping from client database index to TCDBBank (first-level nodes)
|
||||
static std::vector<TCDBBank> _UnifiedIndexToBank;
|
||||
|
||||
/// Last index mapped
|
||||
static uint _CDBLastUnifiedIndex;
|
||||
|
||||
/// Number of bits for first-level branches, by bank
|
||||
static uint _FirstLevelIdBitsByBank [NB_CDB_BANKS];
|
||||
|
||||
/// called by clear
|
||||
void removeAllBranchObserver();
|
||||
void removeBranchInfoIt(TObsList::iterator it);
|
||||
};
|
||||
|
||||
|
||||
#endif // CDB_BRANCH_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 CDB_BRANCH_H
|
||||
#define CDB_BRANCH_H
|
||||
|
||||
#include "cdb.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
* Database Node which contains a set of properties
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeBranch : public ICDBNode
|
||||
{
|
||||
public:
|
||||
|
||||
class ICDBDBBranchObserverHandle
|
||||
{
|
||||
public:
|
||||
virtual ~ICDBDBBranchObserverHandle(){}
|
||||
|
||||
virtual ICDBNode* owner() = 0;
|
||||
virtual IPropertyObserver* observer() = 0;
|
||||
virtual bool observesLeaf( const std::string &leafName ) = 0;
|
||||
virtual bool inList( uint list ) = 0;
|
||||
virtual void addToFlushableList() = 0;
|
||||
virtual void removeFromFlushableList( uint list ) = 0;
|
||||
virtual void removeFromFlushableList() = 0;
|
||||
|
||||
};
|
||||
|
||||
// default constructor
|
||||
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent = NULL;
|
||||
_IdBits = 0;
|
||||
_Sorted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
|
||||
|
||||
/**
|
||||
* Add a new sub node
|
||||
* \param node is the new subnode
|
||||
* \param nodeName is the name of the node
|
||||
*/
|
||||
void attachChild( ICDBNode * node, std::string nodeName );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate=true);
|
||||
|
||||
/**
|
||||
* Get a node. Return NULL if out of bounds (no warning)
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* node , uint& index)
|
||||
{
|
||||
index=0;
|
||||
for ( std::vector<ICDBNode*>::const_iterator it = _Nodes.begin(); it != _Nodes.end(); it++)
|
||||
{
|
||||
if (*it == node)
|
||||
return true;
|
||||
index++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return the child with the given node id, creating it if requested
|
||||
CCDBNodeLeaf *getLeaf( const char *id, bool bCreate );
|
||||
CCDBNodeLeaf *getLeaf( const std::string &id, bool bCreate ) { return getLeaf(id.c_str(), bCreate); }
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
void write( CTextId& id, FILE * f);
|
||||
|
||||
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
|
||||
void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler );
|
||||
|
||||
/// Update the database from a stream coming from the FE
|
||||
void readDelta( TGameCycle gc, CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the value of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'true' if property found.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/// Clear the node and his children
|
||||
void clear();
|
||||
|
||||
void resetNode( TGameCycle gc, uint node )
|
||||
{
|
||||
if( node > _Nodes.size() )
|
||||
return;
|
||||
|
||||
_Nodes[ node ]->resetData( gc );
|
||||
}
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(TGameCycle gc, bool forceReset=false)
|
||||
{
|
||||
for ( uint i=0; i!=_Nodes.size(); ++i )
|
||||
{
|
||||
_Nodes[i]->resetData(gc, forceReset);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~CCDBNodeBranch() { clear(); }
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch *parent) { _Parent=parent; }
|
||||
|
||||
virtual CCDBNodeBranch* getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
//get the number of nodes
|
||||
uint16 getNbNodes()
|
||||
{
|
||||
return (uint16)_Nodes.size();
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const;
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count );
|
||||
|
||||
virtual void display (const std::string &prefix);
|
||||
|
||||
void removeNode (const CTextId& id);
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
// Add an observer to this branch. It will be notified of any change in the sub-leaves
|
||||
|
||||
/**
|
||||
* Add observer to all sub-leaves, except if a positive filter is set:
|
||||
* If positiveLeafNameFilter is non-empty, only changes to leaves having names found in it
|
||||
* will be notified (this is equivalent to creating a sub-branch containing only the specified leaves
|
||||
* and setting a branch observer on it, except you don't need to change your database paths
|
||||
* and update large amounts of code!).
|
||||
*/
|
||||
void addBranchObserver( ICDBDBBranchObserverHandle* handle, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
|
||||
|
||||
/**
|
||||
* Easy version of addBranchObserver() (see above).
|
||||
* Examples of dbPathFromThisNode:
|
||||
* "" -> this node
|
||||
* "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node
|
||||
*/
|
||||
void addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
|
||||
|
||||
// Remove observer from all sub-leaves
|
||||
bool removeBranchObserver(IPropertyObserver* observer);
|
||||
|
||||
/// Easy version of removeBranchObserver() (see above and see easy version of addBranchObserver())
|
||||
void removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer);
|
||||
|
||||
virtual bool isLeaf() const { return false; }
|
||||
|
||||
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
|
||||
void onLeafChanged( TStringId leafName );
|
||||
|
||||
/// Find a subnode at this level
|
||||
ICDBNode * find (const std::string &nodeName);
|
||||
|
||||
protected:
|
||||
typedef std::list< ICDBDBBranchObserverHandle* > TObserverHandleList;
|
||||
|
||||
CCDBNodeBranch *_Parent;
|
||||
|
||||
/// database subnodes not sorted
|
||||
std::vector<ICDBNode*> _Nodes;
|
||||
|
||||
/// subnodes sorted by name
|
||||
std::vector<ICDBNode*> _NodesByName;
|
||||
|
||||
// number of bits required to stock my children's ids
|
||||
uint8 _IdBits : 7;
|
||||
bool _Sorted : 1;
|
||||
|
||||
// observers for this node or branch
|
||||
TObserverHandleList observerHandles;
|
||||
|
||||
/// called by clear
|
||||
void removeAllBranchObserver();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CDB_BRANCH_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
128
code/nel/include/nel/misc/cdb_branch_observing_handler.h
Normal file
128
code/nel/include/nel/misc/cdb_branch_observing_handler.h
Normal file
|
@ -0,0 +1,128 @@
|
|||
// 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 CDB_BRANCH_OBS_HNDLR
|
||||
#define CDB_BRANCH_OBS_HNDLR
|
||||
|
||||
#include "nel/misc/cdb_branch.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
@brief Manages the CDB branch observers.
|
||||
|
||||
When a leaf's data changes, it notifies the branch, which then marks the observers as notifiable.
|
||||
The marked observers can then be notified and flushed on request.
|
||||
|
||||
*/
|
||||
class CCDBBranchObservingHandler{
|
||||
|
||||
enum{
|
||||
MAX_OBS_LST = 2
|
||||
};
|
||||
|
||||
public:
|
||||
CCDBBranchObservingHandler();
|
||||
|
||||
~CCDBBranchObservingHandler();
|
||||
|
||||
/// Notifies the observers, and flushes the list
|
||||
void flushObserverCalls();
|
||||
|
||||
void reset();
|
||||
|
||||
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter );
|
||||
|
||||
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
|
||||
|
||||
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
|
||||
|
||||
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
|
||||
|
||||
|
||||
///Observer for branch observer flush events.
|
||||
class IBranchObserverCallFlushObserver : public CRefCount{
|
||||
public:
|
||||
virtual ~IBranchObserverCallFlushObserver(){}
|
||||
virtual void onObserverCallFlush() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
void triggerFlushObservers();
|
||||
|
||||
public:
|
||||
void addFlushObserver( IBranchObserverCallFlushObserver *observer );
|
||||
void removeFlushObserver( IBranchObserverCallFlushObserver *observer );
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@brief Handle to a branch observer.
|
||||
|
||||
The handle stores the owner branch, the observer and remembers if it's marked for notifying the observer.
|
||||
Also it manages adding/removing itself to/from the marked observer handles list, which is handled by CCDBBranchObservingHandler.
|
||||
|
||||
*/
|
||||
class CCDBDBBranchObserverHandle : public CCDBNodeBranch::ICDBDBBranchObserverHandle{
|
||||
|
||||
public:
|
||||
|
||||
CCDBDBBranchObserverHandle( ICDBNode::IPropertyObserver *observer, CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler );
|
||||
|
||||
~CCDBDBBranchObserverHandle();
|
||||
|
||||
ICDBNode* owner(){ return _owner; }
|
||||
|
||||
ICDBNode::IPropertyObserver* observer(){ return _observer; }
|
||||
|
||||
bool observesLeaf( const std::string &leafName );
|
||||
|
||||
bool inList( uint list );
|
||||
|
||||
void addToFlushableList();
|
||||
|
||||
void removeFromFlushableList( uint list );
|
||||
|
||||
void removeFromFlushableList();
|
||||
|
||||
private:
|
||||
|
||||
bool _inList[ MAX_OBS_LST ];
|
||||
|
||||
std::vector< std::string > _observedLeaves;
|
||||
|
||||
CCDBNodeBranch *_owner;
|
||||
|
||||
NLMISC::CRefPtr< ICDBNode::IPropertyObserver > _observer;
|
||||
|
||||
CCDBBranchObservingHandler *_handler;
|
||||
|
||||
};
|
||||
|
||||
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* > flushableObservers[ MAX_OBS_LST ];
|
||||
|
||||
CCDBNodeBranch::ICDBDBBranchObserverHandle *currentHandle;
|
||||
|
||||
uint currentList;
|
||||
|
||||
std::vector< IBranchObserverCallFlushObserver* > flushObservers;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,87 +1,89 @@
|
|||
// 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 NL_CDB_CHECK_SUM_H
|
||||
#define NL_CDB_CHECK_SUM_H
|
||||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
|
||||
/**
|
||||
* class implementing check sum for the client database
|
||||
* these check sum can be used to ensure that linked properties have all been modified
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBCheckSum
|
||||
{
|
||||
public:
|
||||
///constructor
|
||||
CCDBCheckSum();
|
||||
|
||||
//clear the sum
|
||||
void clear()
|
||||
{
|
||||
_Sum = 0;
|
||||
};
|
||||
|
||||
///add an uint8 to the sum
|
||||
void add(uint8 el);
|
||||
|
||||
///add a value to the check sum
|
||||
template <class T>
|
||||
void add(const T & el)
|
||||
{
|
||||
T value = el;
|
||||
for (uint8 i=0; i< sizeof(T); i++)
|
||||
{
|
||||
uint8 tmp = (uint8)(value & 0xFF);
|
||||
add(tmp);
|
||||
value >>=8;
|
||||
}
|
||||
}
|
||||
|
||||
///add a vector to the sum
|
||||
template <class T>
|
||||
void addVector(const std::vector<T> & vect)
|
||||
{
|
||||
for (typename std::vector<T>::const_iterator it = vect.begin(); it != vect.end(); it++)
|
||||
add(*it);
|
||||
}
|
||||
|
||||
uint32 getSum()
|
||||
{
|
||||
return _Sum;
|
||||
}
|
||||
private:
|
||||
///the checsum result
|
||||
uint32 _Sum;
|
||||
|
||||
///the following values are used in the check algorithm
|
||||
uint32 _Factor;
|
||||
uint32 _Const1;
|
||||
uint32 _Const2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // NL_CDB_CHECK_SUM_H
|
||||
|
||||
/* End of cdb_check_sum.h */
|
||||
// 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 NL_CDB_CHECK_SUM_H
|
||||
#define NL_CDB_CHECK_SUM_H
|
||||
|
||||
#include "types_nl.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
* class implementing check sum for the client database
|
||||
* these check sum can be used to ensure that linked properties have all been modified
|
||||
* \author Nicolas Brigand
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBCheckSum
|
||||
{
|
||||
public:
|
||||
///constructor
|
||||
CCDBCheckSum();
|
||||
|
||||
//clear the sum
|
||||
void clear()
|
||||
{
|
||||
_Sum = 0;
|
||||
};
|
||||
|
||||
///add an uint8 to the sum
|
||||
void add(uint8 el);
|
||||
|
||||
///add a value to the check sum
|
||||
template <class T>
|
||||
void add(const T & el)
|
||||
{
|
||||
T value = el;
|
||||
for (uint8 i=0; i< sizeof(T); i++)
|
||||
{
|
||||
uint8 tmp = (uint8)(value & 0xFF);
|
||||
add(tmp);
|
||||
value >>=8;
|
||||
}
|
||||
}
|
||||
|
||||
///add a vector to the sum
|
||||
template <class T>
|
||||
void addVector(const std::vector<T> & vect)
|
||||
{
|
||||
for (typename std::vector<T>::const_iterator it = vect.begin(); it != vect.end(); it++)
|
||||
add(*it);
|
||||
}
|
||||
|
||||
uint32 getSum()
|
||||
{
|
||||
return _Sum;
|
||||
}
|
||||
private:
|
||||
///the checsum result
|
||||
uint32 _Sum;
|
||||
|
||||
///the following values are used in the check algorithm
|
||||
uint32 _Factor;
|
||||
uint32 _Const1;
|
||||
uint32 _Const2;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // NL_CDB_CHECK_SUM_H
|
||||
|
||||
/* End of cdb_check_sum.h */
|
|
@ -1,261 +1,264 @@
|
|||
// 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 CDB_LEAF_H
|
||||
#define CDB_LEAF_H
|
||||
|
||||
#include "cdb.h"
|
||||
#include "cdb_branch.h"
|
||||
#include "nel/misc/time_nl.h"
|
||||
|
||||
/**
|
||||
* Database node which contains a unique property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeLeaf : public ICDBNode
|
||||
{
|
||||
public:
|
||||
// flush all observers calls for modified nodes
|
||||
static void flushObserversCalls();
|
||||
|
||||
|
||||
/// Return the value of the property.
|
||||
inline sint64 getValue64() { return _Property; }
|
||||
|
||||
/// Set the value of the property (set '_Changed' flag with 'true').
|
||||
void setValue64 (sint64 prop);
|
||||
|
||||
inline sint32 getValue32() { return *((sint32*)&_Property); }
|
||||
void setValue32 (sint32 prop);
|
||||
inline sint16 getValue16() { return *((sint16*)&_Property); }
|
||||
void setValue16 (sint16 prop);
|
||||
inline sint8 getValue8() { return *((sint8*)&_Property); }
|
||||
void setValue8 (sint8 prop);
|
||||
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
|
||||
void setValueBool (bool prop);
|
||||
inline NLMISC::CRGBA getValueRGBA()
|
||||
{
|
||||
NLMISC::CRGBA col;
|
||||
col.R = (uint8)(_Property&0xff);
|
||||
col.G = (uint8)((_Property>>8)&0xff);
|
||||
col.B = (uint8)((_Property>>16)&0xff);
|
||||
col.A = (uint8)((_Property>>24)&0xff);
|
||||
return col;
|
||||
}
|
||||
void setValueRGBA (const NLMISC::CRGBA &color);
|
||||
|
||||
/// Return the value of the property before the database change
|
||||
inline sint64 getOldValue64() { return _oldProperty; }
|
||||
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); }
|
||||
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); }
|
||||
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); }
|
||||
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); }
|
||||
|
||||
|
||||
/// Return the type of the property.
|
||||
inline const EPropType &type() const {return _Type;}
|
||||
|
||||
/// Set the property Type.
|
||||
inline void type(const EPropType &t) {_Type = t;}
|
||||
|
||||
/// Return 'true' if the property changed since last call.
|
||||
inline const bool &changed() const {return _Changed;}
|
||||
|
||||
/// Set the property flag to known if the property changed since last call.
|
||||
inline void changed(const bool &c) {_Changed = c;}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CCDBNodeLeaf(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent=0;
|
||||
_Property = 0;
|
||||
_oldProperty = 0;
|
||||
_Type = UNKNOWN;
|
||||
_Changed = false;
|
||||
_LastChangeGC = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, NLMISC::IProgressCallback &progressCallBack, bool mapBanks=false );
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate);
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* /* node */, uint& /* index */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
void write( CTextId& id, FILE * f);
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param f : the stream.
|
||||
*/
|
||||
void readDelta(NLMISC::TGameCycle gc, NLMISC::CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the structure of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'false' if id is too long.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/**
|
||||
* Set the value of a property, only if gc>=_LastChangeGC
|
||||
*/
|
||||
bool setPropCheckGC(NLMISC::TGameCycle gc, sint64 value);
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(NLMISC::TGameCycle gc, bool forceReset=false);
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch* parent) { _Parent=parent; }
|
||||
|
||||
//get the node parent
|
||||
virtual CCDBNodeBranch *getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count )
|
||||
{
|
||||
if ( count == 0 )
|
||||
return this;
|
||||
else
|
||||
{
|
||||
--count;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display(const std::string &prefix);
|
||||
|
||||
|
||||
virtual bool isLeaf() const { return true; }
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
|
||||
/// get the last change GameCycle (server tick) for this value
|
||||
NLMISC::TGameCycle getLastChangeGC() const {return _LastChangeGC;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CCDBNodeBranch * _Parent;
|
||||
|
||||
/// property value
|
||||
sint64 _Property;
|
||||
sint64 _oldProperty;
|
||||
|
||||
/// property type
|
||||
EPropType _Type;
|
||||
|
||||
/// true if this value has changed
|
||||
bool _Changed;
|
||||
|
||||
/// gamecycle (servertick) of the last change for this value.
|
||||
/// change are made in readDelta only for change >= _LastChangeGC
|
||||
NLMISC::TGameCycle _LastChangeGC;
|
||||
|
||||
/// observers to call when the value really change
|
||||
std::vector<IPropertyObserver*> _Observers;
|
||||
|
||||
private:
|
||||
void notifyObservers();
|
||||
|
||||
};
|
||||
|
||||
////////////////////
|
||||
// INLINE MEMBERS //
|
||||
////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CDB_LEAF_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 CDB_LEAF_H
|
||||
#define CDB_LEAF_H
|
||||
|
||||
#include "cdb.h"
|
||||
#include "cdb_branch.h"
|
||||
#include "time_nl.h"
|
||||
#include "rgba.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/**
|
||||
* Database node which contains a unique property
|
||||
* \author Stephane Coutelas
|
||||
* \author Nevrax France
|
||||
* \date 2002
|
||||
*/
|
||||
class CCDBNodeLeaf : public ICDBNode
|
||||
{
|
||||
public:
|
||||
// flush all observers calls for modified nodes
|
||||
static void flushObserversCalls();
|
||||
|
||||
|
||||
/// Return the value of the property.
|
||||
inline sint64 getValue64() { return _Property; }
|
||||
|
||||
/// Set the value of the property (set '_Changed' flag with 'true').
|
||||
void setValue64 (sint64 prop);
|
||||
|
||||
inline sint32 getValue32() { return *((sint32*)&_Property); }
|
||||
void setValue32 (sint32 prop);
|
||||
inline sint16 getValue16() { return *((sint16*)&_Property); }
|
||||
void setValue16 (sint16 prop);
|
||||
inline sint8 getValue8() { return *((sint8*)&_Property); }
|
||||
void setValue8 (sint8 prop);
|
||||
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
|
||||
void setValueBool (bool prop);
|
||||
inline CRGBA getValueRGBA()
|
||||
{
|
||||
CRGBA col;
|
||||
col.R = (uint8)(_Property&0xff);
|
||||
col.G = (uint8)((_Property>>8)&0xff);
|
||||
col.B = (uint8)((_Property>>16)&0xff);
|
||||
col.A = (uint8)((_Property>>24)&0xff);
|
||||
return col;
|
||||
}
|
||||
void setValueRGBA (const CRGBA &color);
|
||||
|
||||
/// Return the value of the property before the database change
|
||||
inline sint64 getOldValue64() { return _oldProperty; }
|
||||
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); }
|
||||
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); }
|
||||
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); }
|
||||
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); }
|
||||
|
||||
|
||||
/// Return the type of the property.
|
||||
inline const EPropType &type() const {return _Type;}
|
||||
|
||||
/// Set the property Type.
|
||||
inline void type(const EPropType &t) {_Type = t;}
|
||||
|
||||
/// Return 'true' if the property changed since last call.
|
||||
inline const bool &changed() const {return _Changed;}
|
||||
|
||||
/// Set the property flag to known if the property changed since last call.
|
||||
inline void changed(const bool &c) {_Changed = c;}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
CCDBNodeLeaf(const std::string &name) : ICDBNode(name)
|
||||
{
|
||||
_Parent=0;
|
||||
_Property = 0;
|
||||
_oldProperty = 0;
|
||||
_Type = UNKNOWN;
|
||||
_Changed = false;
|
||||
_LastChangeGC = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the structure of the database from a file
|
||||
* \param f is the stream
|
||||
*/
|
||||
void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
|
||||
|
||||
/**
|
||||
* Get a node
|
||||
* \param idx is the node index
|
||||
*/
|
||||
ICDBNode * getNode( uint16 idx );
|
||||
|
||||
/**
|
||||
* Get a node . Create it if it does not exist yet
|
||||
* \param id : the CTextId identifying the node
|
||||
*/
|
||||
ICDBNode * getNode (const CTextId& id, bool bCreate);
|
||||
|
||||
/**
|
||||
* Get a node index
|
||||
* \param node is a pointer to the node
|
||||
*/
|
||||
virtual bool getNodeIndex( ICDBNode* /* node */, uint& /* index */)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a backup of the database
|
||||
* \param id is the text id of the property/grp
|
||||
* \param f is the stream
|
||||
*/
|
||||
void write( CTextId& id, FILE * f);
|
||||
|
||||
/**
|
||||
* Update the database from a stream coming from the FE
|
||||
* \param f : the stream.
|
||||
*/
|
||||
void readDelta(TGameCycle gc, CBitMemStream & f );
|
||||
|
||||
/**
|
||||
* Return the value of a property (the update flag is set to false)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \return the structure of the property
|
||||
*/
|
||||
sint64 getProp( CTextId& id );
|
||||
|
||||
/**
|
||||
* Set the value of a property (the update flag is set to true)
|
||||
* \param id is the text id of the property/grp
|
||||
* \param name is the name of the property
|
||||
* \param value is the value of the property
|
||||
* \return bool : 'false' if id is too long.
|
||||
*/
|
||||
bool setProp( CTextId& id, sint64 value );
|
||||
|
||||
/**
|
||||
* Set the value of a property, only if gc>=_LastChangeGC
|
||||
*/
|
||||
bool setPropCheckGC(TGameCycle gc, sint64 value);
|
||||
|
||||
/// Reset all leaf data from this point
|
||||
void resetData(TGameCycle gc, bool forceReset=false);
|
||||
|
||||
/**
|
||||
* Clear the node and his children
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
// the parent node for a branch (NULL by default)
|
||||
virtual void setParent(CCDBNodeBranch* parent) { _Parent=parent; }
|
||||
|
||||
//get the node parent
|
||||
virtual CCDBNodeBranch *getParent()
|
||||
{
|
||||
return _Parent;
|
||||
}
|
||||
|
||||
/// Count the leaves
|
||||
virtual uint countLeaves() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
|
||||
virtual CCDBNodeLeaf *findLeafAtCount( uint& count )
|
||||
{
|
||||
if ( count == 0 )
|
||||
return this;
|
||||
else
|
||||
{
|
||||
--count;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/// Debug purpose
|
||||
virtual void display(const std::string &prefix);
|
||||
|
||||
|
||||
virtual bool isLeaf() const { return true; }
|
||||
|
||||
/**
|
||||
* add an observer to a property
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node doen t exist
|
||||
*/
|
||||
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
/** remove an obsever
|
||||
* \param observer : pointer to an observer
|
||||
* \param id text id identifying the property
|
||||
* \return false if the node or observer doesn t exist
|
||||
*/
|
||||
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
|
||||
|
||||
|
||||
/// get the last change GameCycle (server tick) for this value
|
||||
TGameCycle getLastChangeGC() const {return _LastChangeGC;}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CCDBNodeBranch * _Parent;
|
||||
|
||||
/// property value
|
||||
sint64 _Property;
|
||||
sint64 _oldProperty;
|
||||
|
||||
/// property type
|
||||
EPropType _Type;
|
||||
|
||||
/// true if this value has changed
|
||||
bool _Changed;
|
||||
|
||||
/// gamecycle (servertick) of the last change for this value.
|
||||
/// change are made in readDelta only for change >= _LastChangeGC
|
||||
TGameCycle _LastChangeGC;
|
||||
|
||||
/// observers to call when the value really change
|
||||
std::vector<IPropertyObserver*> _Observers;
|
||||
|
||||
private:
|
||||
void notifyObservers();
|
||||
|
||||
};
|
||||
|
||||
////////////////////
|
||||
// INLINE MEMBERS //
|
||||
////////////////////
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif // CDB_LEAF_H
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
190
code/nel/include/nel/misc/cdb_manager.h
Normal file
190
code/nel/include/nel/misc/cdb_manager.h
Normal file
|
@ -0,0 +1,190 @@
|
|||
// 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 CDB_MANAGER_H
|
||||
#define CDB_MANAGER_H
|
||||
|
||||
#include "nel/misc/cdb_branch.h"
|
||||
#include "nel/misc/cdb_leaf.h"
|
||||
#include "nel/misc/cdb_bank_handler.h"
|
||||
#include "nel/misc/cdb_branch_observing_handler.h"
|
||||
|
||||
namespace NLMISC{
|
||||
|
||||
/// Class that encapsulates the separate CDB components
|
||||
class CCDBManager{
|
||||
|
||||
public:
|
||||
/**
|
||||
The constructor
|
||||
@param maxBanks - The maximum number of banks to be used
|
||||
|
||||
*/
|
||||
CCDBManager( const char *rootNodeName, uint maxBanks );
|
||||
|
||||
~CCDBManager();
|
||||
|
||||
|
||||
/**
|
||||
Returns the specified leaf node from the database.
|
||||
@param name The name of the leaf node.
|
||||
@param create Specifies if the node should be created if it doesn't exist yet.
|
||||
|
||||
*/
|
||||
CCDBNodeLeaf* getDbLeaf( const std::string &name, bool create = true );
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns the specified branch node from the database.
|
||||
@param name The name of the branch.
|
||||
|
||||
*/
|
||||
CCDBNodeBranch* getDbBranch( const std::string &name );
|
||||
|
||||
|
||||
/**
|
||||
Deletes the specified database node.
|
||||
@param name The name of the database node.
|
||||
|
||||
*/
|
||||
void delDbNode( const std::string &name );
|
||||
|
||||
/**
|
||||
Adds an observer to a branch of the database.
|
||||
@param branchName The name of the branch we want to observe
|
||||
@param observer The observer we want to add
|
||||
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
|
||||
|
||||
*/
|
||||
void addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
|
||||
|
||||
/**
|
||||
Adds an observer to a branch of the database.
|
||||
@param branch The branch we want to observe
|
||||
@param observer The observer we want to add
|
||||
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
|
||||
|
||||
*/
|
||||
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
|
||||
|
||||
|
||||
/**
|
||||
Adds an observer to a branch of the database.
|
||||
@param branchName The name of the branch we start from
|
||||
@param dbPathFromThisNode The path to the branch we want to observe
|
||||
@param observer The observer we want to add
|
||||
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
|
||||
@param positiveLeafNameFilterSize The size of the array
|
||||
|
||||
*/
|
||||
void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 );
|
||||
|
||||
|
||||
/**
|
||||
Adds an observer to a branch of the database.
|
||||
@param branch The branch we start from
|
||||
@param dbPathFromThisNode The path to the branch we want to observe
|
||||
@param observer The observer we want to add
|
||||
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
|
||||
@param positiveLeafNameFilterSize The size of the array
|
||||
|
||||
*/
|
||||
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
|
||||
|
||||
|
||||
/**
|
||||
Removes an observer from a branch in the database.
|
||||
@param branchName The name of the branch
|
||||
@param observer The observer we want to remove
|
||||
|
||||
*/
|
||||
void removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer );
|
||||
|
||||
|
||||
/**
|
||||
Removes an observer from a branch in the database.
|
||||
@param branch The branch
|
||||
@param observer The observer we want to remove
|
||||
|
||||
*/
|
||||
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
|
||||
|
||||
|
||||
/**
|
||||
Removes an observer from a branch in the database.
|
||||
@param branchName The name of the branch we start from
|
||||
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
|
||||
@param observer The observer we want to remove
|
||||
|
||||
*/
|
||||
void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
|
||||
|
||||
|
||||
/**
|
||||
Removes an observer from a branch in the database.
|
||||
@param branchName The name of the branch we start from
|
||||
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
|
||||
@param observer The observer we want to remove
|
||||
|
||||
*/
|
||||
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
|
||||
|
||||
|
||||
/**
|
||||
Adds a branch observer call flush observer. ( These are notified after the branch observers are notified )
|
||||
@param observer The observer
|
||||
|
||||
*/
|
||||
void addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
|
||||
|
||||
|
||||
/**
|
||||
Removes a branch observer call flush observer.
|
||||
@param observer The observer
|
||||
*/
|
||||
void removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
|
||||
|
||||
/**
|
||||
Notifies the observers whose observed branches were updated.
|
||||
*/
|
||||
void flushObserverCalls();
|
||||
|
||||
/**
|
||||
Resets the specified bank.
|
||||
@param gc GameCycle ( no idea what it is exactly, probably some time value )
|
||||
@param bank The banks we want to reset
|
||||
|
||||
*/
|
||||
void resetBank( uint gc, uint bank );
|
||||
|
||||
/**
|
||||
@brief Resizes the bank holders. WARNING: Resets data contained.
|
||||
@param newSize - The new maximum number of banks.
|
||||
*/
|
||||
void resizeBanks( uint newSize );
|
||||
|
||||
protected:
|
||||
CCDBBankHandler bankHandler;
|
||||
CCDBBranchObservingHandler branchObservingHandler;
|
||||
CRefPtr< CCDBNodeBranch > _Database;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -206,6 +206,8 @@ public:
|
|||
static void hashToUCString(uint64 hash, ucstring &dst);
|
||||
//@}
|
||||
|
||||
static void setNoResolution( bool b ){ noResolution = b; }
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<std::string, ucstring> StrMapContainer;
|
||||
|
@ -254,6 +256,9 @@ private:
|
|||
TLineFormat lineFmt,
|
||||
bool warnIfIncludesNotFound,
|
||||
TReadContext &readContext);
|
||||
|
||||
// Don't resolve labels
|
||||
static bool noResolution;
|
||||
};
|
||||
|
||||
} // NLMISC
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -237,7 +237,33 @@ inline bool fromString(const std::string &str, uint64 &val) { bool ret = sscanf(
|
|||
inline bool fromString(const std::string &str, sint64 &val) { bool ret = sscanf(str.c_str(), "%"NL_I64"d", &val) == 1; if (!ret) val = 0; return ret; }
|
||||
inline bool fromString(const std::string &str, float &val) { bool ret = sscanf(str.c_str(), "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
|
||||
inline bool fromString(const std::string &str, double &val) { bool ret = sscanf(str.c_str(), "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
|
||||
inline bool fromString(const std::string &str, bool &val) { val = (str.length() == 1) && str[0] != '0'; return (str.length() == 1) && (str[0] == '0' || str[0] == '1'); }
|
||||
|
||||
inline bool fromString(const std::string &str, bool &val)
|
||||
{
|
||||
if( str.length() == 1 )
|
||||
{
|
||||
if( str[ 0 ] == '1' )
|
||||
val = true;
|
||||
else
|
||||
if( str[ 0 ] == '0' )
|
||||
val = false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( str == "true" )
|
||||
val = true;
|
||||
else
|
||||
if( str == "false" )
|
||||
val = false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
|
||||
|
||||
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference
|
||||
|
|
|
@ -1,81 +1,81 @@
|
|||
// 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 XML_AUTO_PTR_H
|
||||
#define XML_AUTO_PTR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
/** Simple auto pointer for xml pointers
|
||||
*/
|
||||
class CXMLAutoPtr
|
||||
{
|
||||
public:
|
||||
CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
|
||||
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
|
||||
~CXMLAutoPtr() { destroy(); }
|
||||
operator const char *() const { return _Value; }
|
||||
operator bool() const { return _Value != NULL; }
|
||||
operator std::string() const { return std::string(_Value); }
|
||||
bool operator ! () const { return _Value == NULL; }
|
||||
operator const unsigned char *() const { return (const unsigned char *) _Value; }
|
||||
char operator * () const { nlassert(_Value); return *_Value; }
|
||||
/// NB : This remove previous owned pointer with xmlFree
|
||||
CXMLAutoPtr &operator = (const char *other)
|
||||
{
|
||||
if (other == _Value) return *this;
|
||||
destroy();
|
||||
_Value = other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CXMLAutoPtr &operator = (const unsigned char *other)
|
||||
{
|
||||
*this = (const char *) other;
|
||||
return *this;
|
||||
}
|
||||
char *getDatas() const { return const_cast<char *>(_Value); }
|
||||
//////////////////////////////////////////////////
|
||||
private:
|
||||
const char *_Value;
|
||||
private:
|
||||
void destroy()
|
||||
{
|
||||
if (_Value)
|
||||
{
|
||||
xmlFree(const_cast<char *>(_Value));
|
||||
_Value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// We'd rather avoid problems
|
||||
CXMLAutoPtr(const CXMLAutoPtr &/* other */)
|
||||
{
|
||||
nlassert(0);
|
||||
}
|
||||
CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */)
|
||||
{
|
||||
nlassert(0);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// 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 XML_AUTO_PTR_H
|
||||
#define XML_AUTO_PTR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
/** Simple auto pointer for xml pointers
|
||||
*/
|
||||
class CXMLAutoPtr
|
||||
{
|
||||
public:
|
||||
CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
|
||||
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
|
||||
~CXMLAutoPtr() { destroy(); }
|
||||
operator const char *() const { return _Value; }
|
||||
operator bool() const { return _Value != NULL; }
|
||||
operator std::string() const { return std::string(_Value); }
|
||||
bool operator ! () const { return _Value == NULL; }
|
||||
operator const unsigned char *() const { return (const unsigned char *) _Value; }
|
||||
char operator * () const { nlassert(_Value); return *_Value; }
|
||||
/// NB : This remove previous owned pointer with xmlFree
|
||||
CXMLAutoPtr &operator = (const char *other)
|
||||
{
|
||||
if (other == _Value) return *this;
|
||||
destroy();
|
||||
_Value = other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CXMLAutoPtr &operator = (const unsigned char *other)
|
||||
{
|
||||
*this = (const char *) other;
|
||||
return *this;
|
||||
}
|
||||
char *getDatas() const { return const_cast<char *>(_Value); }
|
||||
//////////////////////////////////////////////////
|
||||
private:
|
||||
const char *_Value;
|
||||
private:
|
||||
void destroy()
|
||||
{
|
||||
if (_Value)
|
||||
{
|
||||
xmlFree(const_cast<char *>(_Value));
|
||||
_Value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// We'd rather avoid problems
|
||||
CXMLAutoPtr(const CXMLAutoPtr &/* other */)
|
||||
{
|
||||
nlassert(0);
|
||||
}
|
||||
CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */)
|
||||
{
|
||||
nlassert(0);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,33 +1,37 @@
|
|||
ADD_SUBDIRECTORY(misc)
|
||||
|
||||
IF(WITH_3D)
|
||||
ADD_SUBDIRECTORY(3d)
|
||||
ENDIF(WITH_3D)
|
||||
|
||||
IF(WITH_GEORGES)
|
||||
ADD_SUBDIRECTORY(georges)
|
||||
ENDIF(WITH_GEORGES)
|
||||
|
||||
IF(WITH_LIGO)
|
||||
ADD_SUBDIRECTORY(ligo)
|
||||
ENDIF(WITH_LIGO)
|
||||
|
||||
IF(WITH_LOGIC)
|
||||
ADD_SUBDIRECTORY(logic)
|
||||
ENDIF(WITH_LOGIC)
|
||||
|
||||
IF(WITH_NET)
|
||||
ADD_SUBDIRECTORY(net)
|
||||
ENDIF(WITH_NET)
|
||||
|
||||
IF(WITH_SOUND)
|
||||
ADD_SUBDIRECTORY(sound)
|
||||
ENDIF(WITH_SOUND)
|
||||
|
||||
IF(WITH_NEL_CEGUI)
|
||||
ADD_SUBDIRECTORY(cegui)
|
||||
ENDIF(WITH_NEL_CEGUI)
|
||||
|
||||
IF(WITH_PACS)
|
||||
ADD_SUBDIRECTORY(pacs)
|
||||
ENDIF(WITH_PACS)
|
||||
ADD_SUBDIRECTORY(misc)
|
||||
|
||||
IF(WITH_3D)
|
||||
ADD_SUBDIRECTORY(3d)
|
||||
ENDIF(WITH_3D)
|
||||
|
||||
IF(WITH_GUI)
|
||||
ADD_SUBDIRECTORY(gui)
|
||||
ENDIF(WITH_GUI)
|
||||
|
||||
IF(WITH_GEORGES)
|
||||
ADD_SUBDIRECTORY(georges)
|
||||
ENDIF(WITH_GEORGES)
|
||||
|
||||
IF(WITH_LIGO)
|
||||
ADD_SUBDIRECTORY(ligo)
|
||||
ENDIF(WITH_LIGO)
|
||||
|
||||
IF(WITH_LOGIC)
|
||||
ADD_SUBDIRECTORY(logic)
|
||||
ENDIF(WITH_LOGIC)
|
||||
|
||||
IF(WITH_NET)
|
||||
ADD_SUBDIRECTORY(net)
|
||||
ENDIF(WITH_NET)
|
||||
|
||||
IF(WITH_SOUND)
|
||||
ADD_SUBDIRECTORY(sound)
|
||||
ENDIF(WITH_SOUND)
|
||||
|
||||
IF(WITH_NEL_CEGUI)
|
||||
ADD_SUBDIRECTORY(cegui)
|
||||
ENDIF(WITH_NEL_CEGUI)
|
||||
|
||||
IF(WITH_PACS)
|
||||
ADD_SUBDIRECTORY(pacs)
|
||||
ENDIF(WITH_PACS)
|
||||
|
|
14
code/nel/src/gui/CMakeLists.txt
Normal file
14
code/nel/src/gui/CMakeLists.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
FILE(GLOB HEADERS ../../include/nel/gui/*.h)
|
||||
|
||||
NL_TARGET_LIB(nelgui ${HEADERS} ${SRC})
|
||||
|
||||
SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "")
|
||||
NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI")
|
||||
NL_ADD_RUNTIME_FLAGS(nelgui)
|
||||
|
||||
NL_ADD_LIB_SUFFIX(nelgui)
|
||||
|
||||
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
|
||||
INSTALL(TARGETS nelgui LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
|
||||
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
|
727
code/nel/src/gui/action_handler.cpp
Normal file
727
code/nel/src/gui/action_handler.cpp
Normal file
|
@ -0,0 +1,727 @@
|
|||
// 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/action_handler.h"
|
||||
#include "nel/gui/group_container_base.h"
|
||||
#include "nel/gui/interface_property.h"
|
||||
#include "nel/gui/interface_expr.h"
|
||||
#include "nel/gui/db_manager.h"
|
||||
#include "nel/gui/interface_link.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CAHManager *CAHManager::_GlobalInstance = NULL;
|
||||
bool CAHManager::editorMode = false;
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void skipBlankAtStart (string &start)
|
||||
{
|
||||
while (!start.empty())
|
||||
{
|
||||
if ((start[0] == ' ' || start[0] == '\t' || start[0] == '\r' || start[0] == '\n'))
|
||||
start = start.substr(1,start.size());
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
static void skipBlankAtEnd (string &end)
|
||||
{
|
||||
while (!end.empty())
|
||||
{
|
||||
if ((end[end.size()-1] == ' ' || end[end.size()-1] == '\t' || end[end.size()-1] == '\r' || end[end.size()-1] == '\n'))
|
||||
end = end.substr(0,end.size()-1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
std::string IActionHandler::getParam (const string &Params, const string &ParamName)
|
||||
{
|
||||
string allparam = Params;
|
||||
skipBlankAtStart (allparam);
|
||||
string param = toLower (ParamName);
|
||||
while (allparam.size() > 0)
|
||||
{
|
||||
std::string::size_type e = allparam.find('=');
|
||||
if (e == std::string::npos || e == 0) break;
|
||||
std::string::size_type p = allparam.find('|');
|
||||
string tmp = NLMISC::toLower(allparam.substr(0,e));
|
||||
skipBlankAtEnd(tmp);
|
||||
if (tmp == param)
|
||||
{
|
||||
string tmp2 = allparam.substr(e+1,p-e-1);
|
||||
skipBlankAtStart(tmp2);
|
||||
skipBlankAtEnd(tmp2);
|
||||
return tmp2;
|
||||
}
|
||||
if (p == std::string::npos || p == 0) break;
|
||||
allparam = allparam.substr(p+1,allparam.size());
|
||||
skipBlankAtStart (allparam);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void IActionHandler::getAllParams (const string &Params, vector< pair<string,string> > &vAllParams)
|
||||
{
|
||||
string allparam = Params;
|
||||
skipBlankAtStart (allparam);
|
||||
while (allparam.size() > 0)
|
||||
{
|
||||
std::string::size_type e = allparam.find('=');
|
||||
if (e == std::string::npos || e == 0) break;
|
||||
std::string::size_type p = allparam.find('|');
|
||||
string tmp = NLMISC::toLower(allparam.substr(0,e));
|
||||
skipBlankAtEnd(tmp);
|
||||
|
||||
string tmp2 = allparam.substr(e+1,p-e-1);
|
||||
skipBlankAtStart(tmp2);
|
||||
skipBlankAtEnd(tmp2);
|
||||
|
||||
vAllParams.push_back(pair<string,string>(tmp,tmp2));
|
||||
|
||||
if (p == std::string::npos || p == 0) break;
|
||||
allparam = allparam.substr(p+1,allparam.size());
|
||||
skipBlankAtStart (allparam);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
IActionHandler* CAHManager::getAH(const std::string &name, std::string ¶ms)
|
||||
{
|
||||
// Special AH form?
|
||||
string::size_type i= name.find(':');
|
||||
if(i!=string::npos)
|
||||
{
|
||||
string ahName= name.substr(0, i);
|
||||
params= name.substr(i+1);
|
||||
return getActionHandler(ahName);
|
||||
}
|
||||
// standalone form
|
||||
else
|
||||
return getActionHandler(name);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
IActionHandler* CAHManager::getAH(const std::string &name, CStringShared ¶ms)
|
||||
{
|
||||
// Special AH form?
|
||||
string::size_type i= name.find(':');
|
||||
if(i!=string::npos)
|
||||
{
|
||||
string ahName= name.substr(0, i);
|
||||
params= name.substr(i+1);
|
||||
return getActionHandler(ahName);
|
||||
}
|
||||
// standalone form
|
||||
else
|
||||
return getActionHandler(name);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string ¶mRet)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
// Read the action handler and any param he defines
|
||||
bool paramSpecifiedInAH= false;
|
||||
if(ahId)
|
||||
{
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)ahId );
|
||||
if (prop)
|
||||
{
|
||||
string ahVal= (const char*)prop;
|
||||
if(ahVal.find(':')!= string::npos)
|
||||
paramSpecifiedInAH= true;
|
||||
ahRet = getAH(ahVal, paramRet);
|
||||
}
|
||||
}
|
||||
|
||||
// Read parameter (if specified)
|
||||
if(paramId)
|
||||
{
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)paramId );
|
||||
/* Precise stuff here (for legacy rules):
|
||||
If the param is not specified in the ahId, then replace params.
|
||||
But if it is specified, don't replace it if the prop is empty!!
|
||||
Because this cause problems with template and parameter replacement.
|
||||
*/
|
||||
if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) )
|
||||
paramRet = string((const char*)prop);
|
||||
}
|
||||
}
|
||||
|
||||
void CAHManager::parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, CStringShared ¶mRet)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
// Read the action handler and any param he defines
|
||||
bool paramSpecifiedInAH= false;
|
||||
if(ahId)
|
||||
{
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)ahId );
|
||||
if (prop)
|
||||
{
|
||||
string ahVal= (const char*)prop;
|
||||
if(ahVal.find(':')!= string::npos)
|
||||
paramSpecifiedInAH= true;
|
||||
ahRet = getAH(ahVal, paramRet);
|
||||
}
|
||||
}
|
||||
|
||||
// Read parameter (if specified)
|
||||
if(paramId)
|
||||
{
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)paramId );
|
||||
/* Precise stuff here (for legacy rules):
|
||||
If the param is not specified in the ahId, then replace params.
|
||||
But if it is specified, don't replace it if the prop is empty!!
|
||||
Because this cause problems with template and parameter replacement.
|
||||
*/
|
||||
if ((const char *)prop && (!paramSpecifiedInAH || strlen((const char*)prop)>0) )
|
||||
paramRet = string((const char*)prop);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CAHManager::runActionHandler (const string &ahCmdLine, CCtrlBase *pCaller, const string &ahUserParams)
|
||||
{
|
||||
if (ahCmdLine.empty()) return;
|
||||
|
||||
if( editorMode )
|
||||
return;
|
||||
|
||||
// Special AH form ("ah:params") ?
|
||||
string::size_type i = ahCmdLine.find(':');
|
||||
string ahName;
|
||||
string ahParams;
|
||||
if(i!=string::npos)
|
||||
{
|
||||
ahName= ahCmdLine.substr(0, i);
|
||||
ahParams= ahCmdLine.substr(i+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ahName= ahCmdLine;
|
||||
}
|
||||
|
||||
// Replace params if defined
|
||||
if(!ahUserParams.empty())
|
||||
ahParams= ahUserParams;
|
||||
|
||||
// Execute the action handler
|
||||
map<string, IActionHandler*>::iterator it = FactoryMap.find (ahName);
|
||||
if (it == FactoryMap.end())
|
||||
{
|
||||
nlwarning ("not found action handler : %s",ahName.c_str());
|
||||
return;
|
||||
}
|
||||
IActionHandler *pAH = it->second;
|
||||
pAH->execute (pCaller, ahParams);
|
||||
|
||||
// Quick Help
|
||||
const string submitQuickHelp = "submit_quick_help";
|
||||
it = FactoryMap.find(submitQuickHelp);
|
||||
if(it == FactoryMap.end())
|
||||
{
|
||||
nlwarning ("not found action handler : %s", submitQuickHelp.c_str());
|
||||
return;
|
||||
}
|
||||
pAH = it->second;
|
||||
const std::string event = ahName + ":" + ahParams;
|
||||
pAH->execute(NULL, event);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CAHManager::runActionHandler (IActionHandler *pAH, CCtrlBase *pCaller, const std::string &Params)
|
||||
{
|
||||
if (pAH == NULL)
|
||||
{
|
||||
nlwarning ("no action handler");
|
||||
return;
|
||||
}
|
||||
|
||||
if( editorMode )
|
||||
return;
|
||||
|
||||
pAH->execute (pCaller, Params);
|
||||
string AHName = CAHManager::getInstance()->getAHName(pAH);
|
||||
|
||||
// Quick Help
|
||||
const string submitQuickHelp = "submit_quick_help";
|
||||
map<string, IActionHandler*>::iterator it = FactoryMap.find (AHName);
|
||||
it = FactoryMap.find(submitQuickHelp);
|
||||
if(it == FactoryMap.end())
|
||||
{
|
||||
nlwarning ("not found action handler : %s", submitQuickHelp.c_str());
|
||||
return;
|
||||
}
|
||||
pAH = it->second;
|
||||
const std::string event = AHName + ":" + Params;
|
||||
pAH->execute(NULL, event);
|
||||
}
|
||||
|
||||
void CAHManager::submitEvent( const std::string &evt )
|
||||
{
|
||||
// Submit the event to the quick help system
|
||||
runActionHandler( "submit_quick_help", NULL, evt );
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHSet : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const string &Params)
|
||||
{
|
||||
string dblink = getParam (Params, "dblink");
|
||||
string property = getParam (Params, "target_property");
|
||||
string propertyToEval = getParam (Params, "target");
|
||||
string expr = getParam (Params, "value");
|
||||
//nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str());
|
||||
CInterfaceExprValue value;
|
||||
if (CInterfaceExpr::eval(expr, value, NULL))
|
||||
{
|
||||
if (!dblink.empty())
|
||||
{
|
||||
// Do not allow Write on SERVER: or LOCAL:
|
||||
static const std::string dbServer= "SERVER:";
|
||||
static const std::string dbLocal= "LOCAL:";
|
||||
static const std::string dbLocalR2= "LOCAL:R2";
|
||||
if( (0==dblink.compare(0, dbServer.size(), dbServer)) ||
|
||||
(0==dblink.compare(0, dbLocal.size(), dbLocal))
|
||||
)
|
||||
{
|
||||
if (0!=dblink.compare(0, dbLocalR2.size(), dbLocalR2))
|
||||
{
|
||||
//nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
|
||||
nlstop;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string dblinkeval;
|
||||
CInterfaceExpr::unpackDBentry(dblink.c_str(), NULL, dblinkeval);
|
||||
if (!value.toInteger())
|
||||
{
|
||||
nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
|
||||
}
|
||||
CInterfaceProperty ip;
|
||||
|
||||
if (!value.toInteger())
|
||||
{
|
||||
nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
|
||||
}
|
||||
if (ip.link (dblinkeval.c_str()))
|
||||
{
|
||||
ip.setSInt64(value.getInteger());
|
||||
}
|
||||
}
|
||||
|
||||
if (!propertyToEval.empty())
|
||||
{
|
||||
CInterfaceExprValue res;
|
||||
if (!CInterfaceExpr::eval(propertyToEval, res, NULL)) return;
|
||||
res.toString();
|
||||
property = res.getString();
|
||||
}
|
||||
|
||||
|
||||
if (!property.empty())
|
||||
{
|
||||
std::vector<CInterfaceLink::CTargetInfo> targets;
|
||||
// find first enclosing group
|
||||
CCtrlBase *currCtrl = pCaller;
|
||||
CInterfaceGroup *ig = NULL;
|
||||
while (currCtrl)
|
||||
{
|
||||
ig = dynamic_cast<CInterfaceGroup *>(currCtrl);
|
||||
if (ig != NULL) break;
|
||||
currCtrl = currCtrl->getParent();
|
||||
}
|
||||
if (ig == NULL)
|
||||
{
|
||||
string elt = property.substr(0,property.rfind(':'));
|
||||
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId(elt);
|
||||
ig = dynamic_cast<CInterfaceGroup*>(pIE);
|
||||
if (ig == NULL && pIE != NULL)
|
||||
ig = pIE->getParent();
|
||||
}
|
||||
|
||||
if (ig != NULL)
|
||||
{
|
||||
CInterfaceLink::splitLinkTargets(property, ig, targets);
|
||||
for(uint k = 0; k < targets.size(); ++k)
|
||||
{
|
||||
if (targets[k].Elem) targets[k].affect(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nlwarning("<CAHSet::execute> Couldn't evaluate expression to affect, expr = %s", expr.c_str());
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHSet, "set");
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHCopy : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
|
||||
{
|
||||
string dbdst = getParam (Params, "dbdst");
|
||||
string dbsrc = getParam (Params, "dbsrc");
|
||||
CCDBNodeBranch *pNBdst = NLGUI::CDBManager::getInstance()->getDbBranch(dbdst);
|
||||
CCDBNodeBranch *pNBsrc = NLGUI::CDBManager::getInstance()->getDbBranch(dbsrc);
|
||||
|
||||
// Branch copy
|
||||
|
||||
if ((pNBdst != NULL) && (pNBsrc != NULL))
|
||||
{
|
||||
//nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str());
|
||||
|
||||
// Parse all children of the src branch
|
||||
uint nbLeaves = pNBsrc->countLeaves();
|
||||
for (uint i = 0; i < nbLeaves; ++i)
|
||||
{
|
||||
uint count = i;
|
||||
CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count);
|
||||
// Find its access name
|
||||
string sTmp = *pNLsrc->getName();
|
||||
CCDBNodeBranch *pParent = pNLsrc->getParent();
|
||||
while (pParent != pNBsrc)
|
||||
{
|
||||
sTmp = *pParent->getName() + ":" + sTmp;
|
||||
pParent = pParent->getParent();
|
||||
}
|
||||
// Find the correspondant node in the dst branch
|
||||
CCDBNodeLeaf *pNLdst = dynamic_cast<CCDBNodeLeaf*>(pNBdst->getNode(ICDBNode::CTextId(sTmp)));
|
||||
if (pNLdst == NULL)
|
||||
{
|
||||
nlwarning ("cannot find destination leaf %s",sTmp.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
pNLdst->setValue64(pNLsrc->getValue64());
|
||||
|
||||
//sint32 nVal = pNLsrc->getValue64();
|
||||
//nlinfo("set value %d for node %s", nVal, sTmp.c_str());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Not branch copy so leaf copy
|
||||
|
||||
CInterfaceProperty ipsrc;
|
||||
CInterfaceProperty ipdst;
|
||||
if (!ipsrc.link (dbsrc.c_str()))
|
||||
{
|
||||
nlwarning("cannot find leaf %s",dbsrc.c_str());
|
||||
return;
|
||||
}
|
||||
if (!ipdst.link (dbdst.c_str()))
|
||||
{
|
||||
nlwarning("cannot find leaf %s",dbdst.c_str());
|
||||
return;
|
||||
}
|
||||
// copy
|
||||
ipdst.setSInt64 (ipsrc.getSInt64());
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHCopy, "copy");
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHResizeW : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const string &Params)
|
||||
{
|
||||
string elt = getParam (Params, "elt");
|
||||
|
||||
sint32 value;
|
||||
fromString(getParam(Params, "value"), value);
|
||||
|
||||
sint32 limit;
|
||||
fromString(getParam(Params, "limit"), limit);
|
||||
|
||||
CInterfaceElement *pIE = CWidgetManager::getInstance()->getElementFromId (pCaller->getId(), elt);
|
||||
if (pIE == NULL) return;
|
||||
|
||||
sint32 newW = pIE->getW();
|
||||
newW += value;
|
||||
if (value < 0)
|
||||
{
|
||||
if (newW < limit)
|
||||
newW = limit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (newW > limit)
|
||||
newW = limit;
|
||||
}
|
||||
pIE->setW (newW);
|
||||
pIE->invalidateCoords();
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHResizeW, "resize_w");
|
||||
|
||||
////////////////////////////////
|
||||
// EDITION OF CONTAINER ALPHA //
|
||||
////////////////////////////////
|
||||
|
||||
// the container whose alpha is being edited
|
||||
static CGroupContainerBase *AlphaChooserTarget = NULL;
|
||||
static bool OldUseGlobalAlpha;
|
||||
static uint8 OldContentAlpha;
|
||||
static uint8 OldBgAlpha;
|
||||
static uint8 OldRolloverAlphaBG;
|
||||
static uint8 OldRolloverAlphaContent;
|
||||
|
||||
// observer to change the container alpha
|
||||
class CContainerAlphaObserver : public ICDBNode::IPropertyObserver
|
||||
{
|
||||
public:
|
||||
bool On;
|
||||
enum TTargetAlpha { ContentAlpha = 0, BgAlpha, RolloverAlphaContent, RolloverAlphaBG };
|
||||
TTargetAlpha Target;
|
||||
virtual void update(ICDBNode *node)
|
||||
{
|
||||
if (!On) return;
|
||||
if (!AlphaChooserTarget) return;
|
||||
CCDBNodeLeaf *leaf = safe_cast<CCDBNodeLeaf *>(node);
|
||||
switch(Target)
|
||||
{
|
||||
case ContentAlpha: AlphaChooserTarget->setContentAlpha((uint8) leaf->getValue32()); break;
|
||||
case BgAlpha: AlphaChooserTarget->setContainerAlpha((uint8) leaf->getValue32()); break;
|
||||
case RolloverAlphaContent: AlphaChooserTarget->setRolloverAlphaContent((uint8) (255 - (uint8) leaf->getValue32())); break;
|
||||
case RolloverAlphaBG: AlphaChooserTarget->setRolloverAlphaContainer((uint8) (255 - (uint8) leaf->getValue32())); break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHChooseUIAlpha : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CGroupContainerBase *gc = NULL;
|
||||
CCtrlBase *cb = pCaller;
|
||||
while (cb)
|
||||
{
|
||||
gc = dynamic_cast<CGroupContainerBase*>(cb);
|
||||
if (gc) break;
|
||||
cb = cb->getParent();
|
||||
}
|
||||
if (!gc) return;
|
||||
AlphaChooserTarget = gc;
|
||||
if (!_AlphaObserversAdded)
|
||||
{
|
||||
_UiVariableBGAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_BG");
|
||||
_UiVariableContentAlpha = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_CONTENT");
|
||||
_UiVariableRolloverAlphaBG = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_BG");
|
||||
_UiVariableRolloverAlphaContent = NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:ALPHA_ROLLOVER_CONTENT");
|
||||
ICDBNode::CTextId textIdBGAlpha, textIdContentAlpha, textIdRolloverAlphaBG, textIdRolloverAlphaContent;
|
||||
_UiVariableBGAlpha->addObserver(&_BgAlphaObs, textIdBGAlpha);
|
||||
_UiVariableContentAlpha->addObserver(&_ContentAlphaObs, textIdContentAlpha);
|
||||
_UiVariableRolloverAlphaBG->addObserver(&_RolloverAlphaBGObs, textIdRolloverAlphaBG);
|
||||
_UiVariableRolloverAlphaContent->addObserver(&_RolloverAlphaContentObs, textIdRolloverAlphaContent);
|
||||
_AlphaObserversAdded = true;
|
||||
}
|
||||
// disable observers
|
||||
_ContentAlphaObs.On = false;
|
||||
_BgAlphaObs.On = false;
|
||||
_RolloverAlphaBGObs.On = false;
|
||||
_RolloverAlphaContentObs.On = false;
|
||||
// set alpha of current chosen container
|
||||
_UiVariableBGAlpha->setValue32(gc->getContainerAlpha());
|
||||
_UiVariableContentAlpha->setValue32(gc->getContentAlpha());
|
||||
_UiVariableRolloverAlphaBG->setValue32(255 - gc->getRolloverAlphaContainer());
|
||||
_UiVariableRolloverAlphaContent->setValue32(255 - gc->getRolloverAlphaContent());
|
||||
// enable observers
|
||||
_ContentAlphaObs.On = true;
|
||||
_BgAlphaObs.On = true;
|
||||
_RolloverAlphaBGObs.On = true;
|
||||
_RolloverAlphaContentObs.On = true;
|
||||
// backup current alpha (if the user cancel)
|
||||
OldContentAlpha = gc->getContentAlpha();
|
||||
OldBgAlpha = gc->getContainerAlpha();
|
||||
OldRolloverAlphaBG = gc->getRolloverAlphaContainer();
|
||||
OldRolloverAlphaContent = gc->getRolloverAlphaContent();
|
||||
OldUseGlobalAlpha = gc->isUsingGlobalAlpha();
|
||||
// Enable 'use global alpha' button
|
||||
NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(gc->isUsingGlobalAlpha() ? 0 : 1);
|
||||
// show the modal box
|
||||
CWidgetManager::getInstance()->enableModalWindow(gc, "ui:interface:define_ui_transparency");
|
||||
|
||||
}
|
||||
|
||||
|
||||
CAHChooseUIAlpha()
|
||||
{
|
||||
_UiVariableContentAlpha = NULL;
|
||||
_UiVariableBGAlpha = NULL;
|
||||
_UiVariableRolloverAlphaBG = NULL;
|
||||
_UiVariableRolloverAlphaContent = NULL;
|
||||
_AlphaObserversAdded = false;
|
||||
_BgAlphaObs.Target = CContainerAlphaObserver::BgAlpha;
|
||||
_ContentAlphaObs.Target = CContainerAlphaObserver::ContentAlpha;
|
||||
_RolloverAlphaBGObs.Target = CContainerAlphaObserver::RolloverAlphaBG;
|
||||
_RolloverAlphaContentObs.Target = CContainerAlphaObserver::RolloverAlphaContent;
|
||||
}
|
||||
private:
|
||||
// instance of observer to copy alpha from db to a container
|
||||
CContainerAlphaObserver _ContentAlphaObs;
|
||||
CContainerAlphaObserver _BgAlphaObs;
|
||||
CContainerAlphaObserver _RolloverAlphaContentObs;
|
||||
CContainerAlphaObserver _RolloverAlphaBGObs;
|
||||
// flag to know if observer have been added
|
||||
bool _AlphaObserversAdded;
|
||||
// db leaf that contains alpha for the current container
|
||||
CCDBNodeLeaf *_UiVariableContentAlpha;
|
||||
CCDBNodeLeaf *_UiVariableBGAlpha;
|
||||
CCDBNodeLeaf *_UiVariableRolloverAlphaContent;
|
||||
CCDBNodeLeaf *_UiVariableRolloverAlphaBG;
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHChooseUIAlpha, "choose_ui_alpha");
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHCancelChooseUIAlpha : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */)
|
||||
{
|
||||
if (AlphaChooserTarget)
|
||||
{
|
||||
AlphaChooserTarget->setUseGlobalAlpha(OldUseGlobalAlpha);
|
||||
AlphaChooserTarget->setContainerAlpha(OldBgAlpha);
|
||||
AlphaChooserTarget->setContentAlpha(OldContentAlpha);
|
||||
AlphaChooserTarget->setRolloverAlphaContainer(OldRolloverAlphaBG);
|
||||
AlphaChooserTarget->setRolloverAlphaContent(OldRolloverAlphaContent);
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHCancelChooseUIAlpha, "cancel_choose_ui_alpha");
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHUseGlobalAlphaSettings : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* Params */)
|
||||
{
|
||||
if (AlphaChooserTarget)
|
||||
{
|
||||
AlphaChooserTarget->setUseGlobalAlpha(!AlphaChooserTarget->isUsingGlobalAlpha());
|
||||
NLGUI::CDBManager::getInstance()->getDbProp("UI:VARIABLES:USER_ALPHA")->setValue64(AlphaChooserTarget->isUsingGlobalAlpha() ? 0 : 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHUseGlobalAlphaSettings, "use_global_alpha_settings");
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHLockUnlock : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CGroupContainerBase *gc = NULL;
|
||||
CCtrlBase *cb = pCaller;
|
||||
while (cb)
|
||||
{
|
||||
gc = dynamic_cast< CGroupContainerBase* >(cb);
|
||||
if (gc) break;
|
||||
cb = cb->getParent();
|
||||
}
|
||||
if (!gc) return;
|
||||
//gc->setMovable(!gc->isMovable());
|
||||
gc->setLocked(!gc->isLocked());
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHLockUnlock, "lock_unlock");
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHSetTransparent : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
|
||||
{
|
||||
CGroupContainerBase *pGC = dynamic_cast< CGroupContainerBase* >(CWidgetManager::getInstance()->getElementFromId(Params));
|
||||
if (pGC != NULL)
|
||||
{
|
||||
pGC->setUseGlobalAlpha(false);
|
||||
pGC->setContainerAlpha((uint8) 0);
|
||||
pGC->setContentAlpha((uint8) 255);
|
||||
pGC->setRolloverAlphaContainer((uint8) 255);
|
||||
pGC->setRolloverAlphaContent((uint8) 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHSetTransparent, "set_transparent");
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHSetAlpha : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const std::string &Params)
|
||||
{
|
||||
string ui = getParam (Params, "target");
|
||||
|
||||
uint8 alpha;
|
||||
fromString(getParam (Params, "alpha"), alpha);
|
||||
|
||||
CGroupContainerBase *pGC = dynamic_cast<CGroupContainerBase*>(CWidgetManager::getInstance()->getElementFromId(ui));
|
||||
if (pGC != NULL)
|
||||
{
|
||||
pGC->setUseGlobalAlpha(false);
|
||||
pGC->setContainerAlpha((uint8) alpha);
|
||||
pGC->setContentAlpha((uint8) 255);
|
||||
pGC->setRolloverAlphaContainer((uint8) 0);
|
||||
pGC->setRolloverAlphaContent((uint8) 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHSetAlpha, "set_alpha");
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CAHUnlockAllContainer : public IActionHandler
|
||||
{
|
||||
virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
|
||||
{
|
||||
const vector<CWidgetManager::SMasterGroup> &rVMG = CWidgetManager::getInstance()->getAllMasterGroup();
|
||||
for (uint32 nMasterGroup = 0; nMasterGroup < rVMG.size(); nMasterGroup++)
|
||||
{
|
||||
// const CInterfaceManager::SMasterGroup &rMG = rVMG[nMasterGroup];
|
||||
CWidgetManager::getInstance()->getMasterGroup((uint8)nMasterGroup).unlockAllContainers();
|
||||
}
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CAHUnlockAllContainer, "unlock_all_container");
|
||||
|
||||
}
|
485
code/nel/src/gui/ctrl_base.cpp
Normal file
485
code/nel/src/gui/ctrl_base.cpp
Normal file
|
@ -0,0 +1,485 @@
|
|||
// 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 "libxml/globals.h"
|
||||
#include "nel/misc/debug.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/ctrl_base.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
std::map< std::string, std::map< std::string, std::string > > CCtrlBase::AHCache;
|
||||
|
||||
// ***************************************************************************
|
||||
CCtrlBase::~CCtrlBase()
|
||||
{
|
||||
CWidgetManager::getInstance()->removeRefOnCtrl (this);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
|
||||
{
|
||||
if (event.getType() == NLGUI::CEventDescriptor::system)
|
||||
{
|
||||
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
|
||||
if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
|
||||
{
|
||||
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive())
|
||||
{
|
||||
// the mouse capture should be lost when the ctrl is hidden
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
|
||||
{
|
||||
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
|
||||
}
|
||||
if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
|
||||
{
|
||||
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
|
||||
}
|
||||
// NB : don't call return here because derived class may be interested
|
||||
// in handling event more speciffically
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CCtrlBase::tooltipParentToString( TToolTipParentType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case TTMouse:
|
||||
return "mouse";
|
||||
break;
|
||||
|
||||
case TTWindow:
|
||||
return "win";
|
||||
break;
|
||||
|
||||
case TTSpecialWindow:
|
||||
return "special";
|
||||
break;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str )
|
||||
{
|
||||
std::string s = toLower( str );
|
||||
|
||||
if( s == "mouse" )
|
||||
return TTMouse;
|
||||
else
|
||||
if( s == "win" )
|
||||
return TTWindow;
|
||||
else
|
||||
if( s == "special" )
|
||||
return TTSpecialWindow;
|
||||
else
|
||||
return TTCtrl;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
|
||||
{
|
||||
if(!CViewBase::parse(cur, parentGroup))
|
||||
return false;
|
||||
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
// get static toolTip
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
|
||||
if (prop)
|
||||
{
|
||||
const char *propPtr = prop;
|
||||
|
||||
_ContextHelp = ucstring(propPtr);
|
||||
|
||||
if( !editorMode && ( strlen(propPtr) > 2 ) )
|
||||
{
|
||||
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
|
||||
_ContextHelp = CI18N::get ((const char *) prop);
|
||||
}
|
||||
}
|
||||
// Force I18N tooltip
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
|
||||
if ((bool)prop && strlen((const char*)prop)>0)
|
||||
{
|
||||
if( !editorMode )
|
||||
_ContextHelp = CI18N::get ((const char *) prop);
|
||||
else
|
||||
_ContextHelp = (const char*)prop;
|
||||
}
|
||||
|
||||
// get dynamic toolTip ActionHandler
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" );
|
||||
if (prop)
|
||||
{
|
||||
_OnContextHelp= (const char*)prop;
|
||||
}
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" );
|
||||
if (prop)
|
||||
{
|
||||
_OnContextHelpParams= (const char*)prop;
|
||||
}
|
||||
|
||||
// Tooltip parent
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" );
|
||||
_ToolTipParent= TTCtrl;
|
||||
if(prop)
|
||||
{
|
||||
_ToolTipParent = stringToToolTipParent( std::string( prop ) );
|
||||
}
|
||||
|
||||
// Tooltip special parent
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" );
|
||||
_ToolTipSpecialParent= CStringShared();
|
||||
if(prop)
|
||||
{
|
||||
_ToolTipSpecialParent= std::string((const char*)prop);
|
||||
}
|
||||
|
||||
// Tooltip posref
|
||||
THotSpot tmpParentHS, tmpChildHS;
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" );
|
||||
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
|
||||
_ToolTipParentPosRef= tmpParentHS;
|
||||
_ToolTipPosRef= tmpChildHS;
|
||||
|
||||
// Alternative tooltip posref : this one will be chosen
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" );
|
||||
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
|
||||
_ToolTipParentPosRefAlt = tmpParentHS;
|
||||
_ToolTipPosRefAlt = tmpChildHS;
|
||||
|
||||
// ToolTip instant
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help");
|
||||
_ToolTipInstant= true;
|
||||
if (prop) _ToolTipInstant = convertBool(prop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string CCtrlBase::getProperty( const std::string &name ) const
|
||||
{
|
||||
if( name == "tooltip" )
|
||||
{
|
||||
return _ContextHelp.toString();
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_i18n" )
|
||||
{
|
||||
return _ContextHelp.toString();
|
||||
}
|
||||
else
|
||||
if( name == "on_tooltip" )
|
||||
{
|
||||
return _OnContextHelp.toString();
|
||||
}
|
||||
else
|
||||
if( name == "on_tooltip_params" )
|
||||
{
|
||||
return _OnContextHelpParams.toString();
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_parent" )
|
||||
{
|
||||
return tooltipParentToString( _ToolTipParent );
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_special_parent" )
|
||||
{
|
||||
return _ToolTipSpecialParent.toString();
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref" )
|
||||
{
|
||||
std::string s;
|
||||
if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) )
|
||||
return "auto";
|
||||
else{
|
||||
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( _ToolTipPosRef );
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref_alt" )
|
||||
{
|
||||
std::string s;
|
||||
if( ( _ToolTipParentPosRefAlt == Hotspot_TTAuto ) && ( _ToolTipPosRefAlt == Hotspot_TTAuto ) )
|
||||
return "auto";
|
||||
else{
|
||||
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRefAlt );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( _ToolTipPosRefAlt );
|
||||
return s;
|
||||
}
|
||||
}
|
||||
else
|
||||
if( name == "instant_help" )
|
||||
{
|
||||
return toString( _ToolTipInstant );
|
||||
}
|
||||
else
|
||||
return CInterfaceElement::getProperty( name );
|
||||
}
|
||||
|
||||
|
||||
void CCtrlBase::setProperty( const std::string &name, const std::string &value )
|
||||
{
|
||||
if( name == "tooltip" )
|
||||
{
|
||||
_ContextHelp = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_i18n" )
|
||||
{
|
||||
_ContextHelp = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "on_tooltip" )
|
||||
{
|
||||
_OnContextHelp = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "on_tooltip_params" )
|
||||
{
|
||||
_OnContextHelpParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_parent" )
|
||||
{
|
||||
_ToolTipParent = stringToToolTipParent( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_special_parent" )
|
||||
{
|
||||
_ToolTipSpecialParent = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref" )
|
||||
{
|
||||
THotSpot parentHS;
|
||||
THotSpot HS;
|
||||
convertTooltipHotSpot( value.c_str(), parentHS, HS );
|
||||
_ToolTipParentPosRef = parentHS;
|
||||
_ToolTipPosRef = HS;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tooltip_posref_alt" )
|
||||
{
|
||||
THotSpot parentHS;
|
||||
THotSpot HS;
|
||||
convertTooltipHotSpot( value.c_str(), parentHS, HS );
|
||||
_ToolTipParentPosRefAlt = parentHS;
|
||||
_ToolTipPosRefAlt = HS;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "instant_help" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_ToolTipInstant = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
CInterfaceElement::setProperty( name, value );
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr CCtrlBase::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node =
|
||||
CInterfaceElement::serialize( parentNode, type );
|
||||
|
||||
if( node == NULL )
|
||||
return NULL;
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_special_parent", BAD_CAST _ToolTipSpecialParent.toString().c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip_posref",
|
||||
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRef, _ToolTipPosRef ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip_posref_alt",
|
||||
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRefAlt, _ToolTipPosRefAlt ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "instant_help", BAD_CAST toString( _ToolTipInstant ).c_str() );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
|
||||
{
|
||||
parentHS = Hotspot_TTAuto;
|
||||
childHS = Hotspot_TTAuto;
|
||||
if(prop)
|
||||
{
|
||||
const char *ptr= (const char*)prop;
|
||||
if(stricmp(ptr, "auto")==0)
|
||||
{
|
||||
parentHS = Hotspot_TTAuto;
|
||||
childHS = Hotspot_TTAuto;
|
||||
}
|
||||
// valid ref?
|
||||
else if(strlen(ptr)>=5)
|
||||
{
|
||||
THotSpot parentPosRef;
|
||||
THotSpot posRef;
|
||||
CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef);
|
||||
parentHS = parentPosRef;
|
||||
childHS = posRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( ( parent == Hotspot_TTAuto ) && ( child == Hotspot_TTAuto ) )
|
||||
{
|
||||
s = "auto";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = CInterfaceElement::HotSpotToString( parent );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( child );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBase::emptyContextHelp() const
|
||||
{
|
||||
ucstring help;
|
||||
getContextHelp(help);
|
||||
std::string sTmp = _OnContextHelp;
|
||||
return help.empty() && sTmp.empty();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
|
||||
{
|
||||
nlassert(visitor);
|
||||
visitor->visitCtrl(this);
|
||||
CInterfaceElement::visit(visitor);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBase::serial(NLMISC::IStream &f)
|
||||
{
|
||||
CViewBase::serial(f);
|
||||
f.serial(_ContextHelp);
|
||||
f.serial(_OnContextHelp);
|
||||
f.serial(_OnContextHelpParams);
|
||||
f.serial(_ToolTipSpecialParent);
|
||||
f.serialEnum(_ToolTipParent);
|
||||
//
|
||||
|
||||
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
|
||||
THotSpot tmpToolTipPosRef = _ToolTipPosRef;
|
||||
THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt;
|
||||
THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt;
|
||||
|
||||
f.serialEnum(tmpToolTipParentPosRef);
|
||||
f.serialEnum(tmpToolTipPosRef);
|
||||
f.serialEnum(tmpToolTipParentPosRefAlt);
|
||||
f.serialEnum(tmpToolTipPosRefAlt);
|
||||
|
||||
_ToolTipParentPosRef = tmpToolTipParentPosRef;
|
||||
_ToolTipPosRef = tmpToolTipPosRef;
|
||||
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
|
||||
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
|
||||
//
|
||||
nlSerialBitBool(f, _ToolTipInstant);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
std::string CCtrlBase::getContextHelpWindowName() const
|
||||
{
|
||||
return "context_help";
|
||||
}
|
||||
|
||||
uint32 CCtrlBase::getDepth( CInterfaceGroup *group )
|
||||
{
|
||||
uint32 depth = 1;
|
||||
CInterfaceGroup *parent = getParent();
|
||||
|
||||
while( parent != NULL )
|
||||
{
|
||||
if ( parent == group )
|
||||
break;
|
||||
else
|
||||
parent = parent->getParent();
|
||||
depth++;
|
||||
}
|
||||
// The Resizer Ctrls take the precedence over Sons controls.
|
||||
return depth + getDeltaDepth();
|
||||
}
|
||||
|
||||
|
||||
void CCtrlBase::mapAHString( const std::string &key, const std::string &value )
|
||||
{
|
||||
std::map< std::string, std::map< std::string, std::string > >::iterator itr = AHCache.find( getId() );
|
||||
if( itr == AHCache.end() )
|
||||
{
|
||||
AHCache[ getId() ];
|
||||
itr = AHCache.find( getId() );
|
||||
}
|
||||
|
||||
std::map< std::string, std::string > &AHMap = itr->second;
|
||||
AHMap[ key ] = value;
|
||||
}
|
||||
|
||||
std::string CCtrlBase::getAHString( const std::string &key ) const
|
||||
{
|
||||
std::map< std::string, std::map< std::string, std::string > >::const_iterator itr = AHCache.find( getId() );
|
||||
if( itr == AHCache.end() )
|
||||
return "";
|
||||
|
||||
std::map< std::string, std::string >::const_iterator itr2 = itr->second.find( key );
|
||||
if( itr2 == itr->second.end() )
|
||||
return "";
|
||||
else
|
||||
return itr2->second;
|
||||
}
|
||||
|
||||
}
|
||||
|
966
code/nel/src/gui/ctrl_base_button.cpp
Normal file
966
code/nel/src/gui/ctrl_base_button.cpp
Normal file
|
@ -0,0 +1,966 @@
|
|||
// 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/ctrl_base_button.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/lua_ihm.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/gui/db_manager.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace
|
||||
{
|
||||
const uint KEY_REPEAT_MIN = 100;
|
||||
const uint KEY_REPEAT_MAX = 750;
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
sint64 CCtrlBaseButton::_LastLeftClickDate = 0;
|
||||
NLMISC::CRefPtr<CCtrlBaseButton> CCtrlBaseButton::_LastLeftClickButton;
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
CCtrlBaseButton::CCtrlBaseButton(const TCtorParam ¶m) : CCtrlBase(param), _Type(ToggleButton)
|
||||
{
|
||||
_Pushed = _Over = false;
|
||||
_Frozen = false;
|
||||
_FrozenHalfTone = true;
|
||||
_OverWhenPushed = true;
|
||||
_ColorOver = _ColorPushed = _ColorNormal = NLMISC::CRGBA(255,255,255,255);
|
||||
_ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= true;
|
||||
_LeftLongClickHandled = true;
|
||||
_LeftDblClickHandled = false;
|
||||
_ClickWhenPushed = false;
|
||||
_RBRefBut = NULL;
|
||||
_RBRef = NULL;
|
||||
|
||||
_AHOnOver = NULL;
|
||||
_AHOnLeftClick = NULL;
|
||||
_AHOnRightClick = NULL;
|
||||
_AHOnClockTick = NULL;
|
||||
_AHOnLeftLongClick = NULL;
|
||||
_AHOnLeftDblClick = NULL;
|
||||
}
|
||||
|
||||
std::string CCtrlBaseButton::getProperty( const std::string &name ) const
|
||||
{
|
||||
if( name == "button_type" )
|
||||
{
|
||||
return getTypeString();
|
||||
}
|
||||
else
|
||||
if( name == "pushed" )
|
||||
{
|
||||
return toString( _Pushed );
|
||||
}
|
||||
else
|
||||
if( name == "over_when_pushed" )
|
||||
{
|
||||
return toString( _OverWhenPushed );
|
||||
}
|
||||
else
|
||||
if( name == "clicked_when_pushed" )
|
||||
{
|
||||
return toString( _ClickWhenPushed );
|
||||
}
|
||||
else
|
||||
if( name == "color" )
|
||||
{
|
||||
return getColorAsString();
|
||||
}
|
||||
else
|
||||
if( name == "col_pushed" )
|
||||
{
|
||||
return getColorPushedAsString();
|
||||
}
|
||||
else
|
||||
if( name == "col_over" )
|
||||
{
|
||||
return getColorOverAsString();
|
||||
}
|
||||
else
|
||||
if( name == "global_color_normal" )
|
||||
{
|
||||
return toString( _ModulateGlobalColorNormal );
|
||||
}
|
||||
else
|
||||
if( name == "global_color_pushed" )
|
||||
{
|
||||
return toString( _ModulateGlobalColorPushed );
|
||||
}
|
||||
else
|
||||
if( name == "global_color_over" )
|
||||
{
|
||||
return toString( _ModulateGlobalColorOver );
|
||||
}
|
||||
else
|
||||
if( name == "onover" )
|
||||
{
|
||||
return getAHString( "onover" );
|
||||
}
|
||||
else
|
||||
if( name == "params_over" )
|
||||
{
|
||||
return _getParamsOnOver();
|
||||
}
|
||||
else
|
||||
if( name == "onclick_l" )
|
||||
{
|
||||
return getAHString( "onclick_l" );
|
||||
}
|
||||
else
|
||||
if( name == "params_l" )
|
||||
{
|
||||
return _getParamsOnLeftClick();
|
||||
}
|
||||
else
|
||||
if( name == "ondblclick_l" )
|
||||
{
|
||||
return getAHString( "ondblclick_l" );
|
||||
}
|
||||
else
|
||||
if( name == "params_dblclick_l" )
|
||||
{
|
||||
return _AHLeftDblClickParams.toString();
|
||||
}
|
||||
else
|
||||
if( name == "onlongclick_l" )
|
||||
{
|
||||
return getAHString( "onlongclick_l" );
|
||||
}
|
||||
else
|
||||
if( name == "params_longclick_l" )
|
||||
{
|
||||
return _AHLeftLongClickParams.toString();
|
||||
}
|
||||
else
|
||||
if( name == "onclick_r" )
|
||||
{
|
||||
return getAHString( "onclick_r" );
|
||||
}
|
||||
else
|
||||
if( name == "params_r" )
|
||||
{
|
||||
return _AHRightClickParams.toString();
|
||||
}
|
||||
else
|
||||
if( name == "onclock_tick" )
|
||||
{
|
||||
return getAHString( "onclock_tick" );
|
||||
}
|
||||
else
|
||||
if( name == "params_clock_tick" )
|
||||
{
|
||||
return _AHClockTickParams.toString();
|
||||
}
|
||||
else
|
||||
if( name == "menu_l" )
|
||||
{
|
||||
return _ListMenuLeft.toString();
|
||||
}
|
||||
else
|
||||
if( name == "menu_r" )
|
||||
{
|
||||
return _ListMenuRight.toString();
|
||||
}
|
||||
else
|
||||
if( name == "menu_b" )
|
||||
{
|
||||
if( _ListMenuLeft.toString() == _ListMenuRight.toString() )
|
||||
return _ListMenuLeft.toString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
else
|
||||
if( name == "frozen" )
|
||||
{
|
||||
return toString( _Frozen );
|
||||
}
|
||||
else
|
||||
if( name == "frozen_half_tone" )
|
||||
{
|
||||
return toString( _FrozenHalfTone );
|
||||
}
|
||||
else
|
||||
return CCtrlBase::getProperty( name );
|
||||
}
|
||||
|
||||
void CCtrlBaseButton::setProperty( const std::string &name, const std::string &value )
|
||||
{
|
||||
if( name == "button_type" )
|
||||
{
|
||||
setTypeFromString( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "pushed" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_Pushed = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "over_when_pushed" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_OverWhenPushed = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "clicked_when_pushed" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_ClickWhenPushed = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "color" )
|
||||
{
|
||||
setColorAsString( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "col_pushed" )
|
||||
{
|
||||
setColorPushedAsString( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "col_over" )
|
||||
{
|
||||
setColorOverAsString( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "global_color_normal" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_ModulateGlobalColorNormal = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "global_color_pushed" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_ModulateGlobalColorPushed = b;
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
if( name == "global_color_over" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_ModulateGlobalColorOver = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "onover" )
|
||||
{
|
||||
_AHOnOver = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "onover", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_over" )
|
||||
{
|
||||
_AHOverParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "onclick_l" )
|
||||
{
|
||||
_AHOnLeftClick = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "onclick_l", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_l" )
|
||||
{
|
||||
_AHLeftClickParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "ondblclick_l" )
|
||||
{
|
||||
_AHOnLeftDblClick = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "ondblclick_l", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_dblclick_l" )
|
||||
{
|
||||
_AHLeftDblClickParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "onlongclick_l" )
|
||||
{
|
||||
_AHOnLeftLongClick = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "onlongclick_l", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_longclick_l" )
|
||||
{
|
||||
_AHLeftLongClickParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "onclick_r" )
|
||||
{
|
||||
_AHOnRightClick = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "onclick_r", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_r" )
|
||||
{
|
||||
_AHRightClickParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "onclock_tick" )
|
||||
{
|
||||
_AHOnClockTick = CAHManager::getInstance()->getAH( value, std::string() );
|
||||
mapAHString( "onclock_tick", value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "params_clock_tick" )
|
||||
{
|
||||
_AHClockTickParams = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "menu_l" )
|
||||
{
|
||||
_ListMenuLeft = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "menu_r" )
|
||||
{
|
||||
_ListMenuRight = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "menu_b" )
|
||||
{
|
||||
_ListMenuLeft = _ListMenuRight = value;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "frozen" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_Frozen = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "frozen_half_tone" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_FrozenHalfTone = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
CCtrlBase::setProperty( name, value );
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr CCtrlBaseButton::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node = CCtrlBase::serialize( parentNode, type );
|
||||
if( node == NULL )
|
||||
return NULL;
|
||||
|
||||
xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" );
|
||||
xmlNewProp( node, BAD_CAST "button_type", BAD_CAST getTypeString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "pushed", BAD_CAST toString( _Pushed ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "over_when_pushed", BAD_CAST toString( _OverWhenPushed ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "clicked_when_pushed", BAD_CAST toString( _ClickWhenPushed ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "color", BAD_CAST getColorAsString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "col_pushed", BAD_CAST getColorPushedAsString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "col_over", BAD_CAST getColorOverAsString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "global_color_normal", BAD_CAST toString( _ModulateGlobalColorNormal ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "global_color_pushed", BAD_CAST toString( _ModulateGlobalColorPushed ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "global_color_over", BAD_CAST toString( _ModulateGlobalColorOver ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "onover", BAD_CAST getAHString( "onover" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_over", BAD_CAST _getParamsOnOver().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "onclick_l", BAD_CAST getAHString( "onclick_l" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_l", BAD_CAST _getParamsOnLeftClick().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "ondblclick_l", BAD_CAST getAHString( "ondblclick_l" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_dblclick_l", BAD_CAST _AHLeftDblClickParams.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "onlongclick_l", BAD_CAST getAHString( "onlongclick_l" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_longclick_l", BAD_CAST _AHLeftLongClickParams.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "onclick_r", BAD_CAST getAHString( "onclick_r" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_r", BAD_CAST _AHRightClickParams.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "onclock_tick", BAD_CAST getAHString( "onclock_tick" ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "params_clock_tick", BAD_CAST _AHClockTickParams.toString().c_str() );
|
||||
|
||||
|
||||
xmlNewProp( node, BAD_CAST "menu_l", BAD_CAST _ListMenuLeft.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "menu_r", BAD_CAST _ListMenuRight.toString().c_str() );
|
||||
|
||||
if( _ListMenuLeft.toString() == _ListMenuRight.toString() )
|
||||
xmlNewProp( node, BAD_CAST "menu_b", BAD_CAST _ListMenuLeft.toString().c_str() );
|
||||
else
|
||||
xmlNewProp( node, BAD_CAST "menu_b", BAD_CAST "" );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "frozen", BAD_CAST toString( _Frozen ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "frozen_half_tone", BAD_CAST toString( _FrozenHalfTone ).c_str() );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
|
||||
//try to get props that can be inherited from groups
|
||||
//if a property is not defined, try to find it in the parent group.
|
||||
//if it is undefined, set it to zero
|
||||
if (! CCtrlBase::parse(cur,parentGroup) )
|
||||
return false;
|
||||
|
||||
_Over = false;
|
||||
|
||||
// *** try to get the NEEDED specific props
|
||||
prop = xmlGetProp (cur, (xmlChar*)"button_type");
|
||||
string type;
|
||||
if (prop)
|
||||
{
|
||||
type = (const char*) prop;
|
||||
}
|
||||
|
||||
prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed");
|
||||
_Pushed = false;
|
||||
if (prop)
|
||||
_Pushed = convertBool(prop);
|
||||
|
||||
prop= (char*) xmlGetProp (cur, (xmlChar*)"over_when_pushed");
|
||||
_OverWhenPushed = true;
|
||||
if (prop)
|
||||
_OverWhenPushed = convertBool(prop);
|
||||
|
||||
prop= (char*) xmlGetProp (cur, (xmlChar*)"click_when_pushed");
|
||||
_ClickWhenPushed = false;
|
||||
if (prop)
|
||||
_ClickWhenPushed = convertBool(prop);
|
||||
|
||||
// *** Read Colors
|
||||
// get color normal
|
||||
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
|
||||
_ColorNormal = CRGBA(255,255,255,255);
|
||||
if (prop)
|
||||
_ColorNormal = convertColor (prop);
|
||||
|
||||
// Get ColorPushed
|
||||
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_pushed" );
|
||||
_ColorPushed = CRGBA(255,255,255,255);
|
||||
if (prop)
|
||||
_ColorPushed = convertColor(prop);
|
||||
|
||||
// Get ColorOver
|
||||
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_over" );
|
||||
_ColorOver = CRGBA(255,255,255,255);
|
||||
if (prop)
|
||||
_ColorOver = convertColor(prop);
|
||||
|
||||
// Default: take "global_color" param interface_element option.
|
||||
_ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= getModulateGlobalColor();
|
||||
|
||||
// Read special global_color for each state
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_normal" );
|
||||
if (prop) _ModulateGlobalColorNormal= convertBool(prop);
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_pushed" );
|
||||
if (prop) _ModulateGlobalColorPushed= convertBool(prop);
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_over" );
|
||||
if (prop) _ModulateGlobalColorOver= convertBool(prop);
|
||||
|
||||
|
||||
// *** Read Action handlers
|
||||
CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams);
|
||||
CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams);
|
||||
CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams);
|
||||
CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams);
|
||||
CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams);
|
||||
CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams);
|
||||
|
||||
if( editorMode )
|
||||
{
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "onover" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "onover", std::string( prop ) );
|
||||
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "onclick_l" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "onclick_l", std::string( prop ) );
|
||||
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "ondblclick_l" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "ondblclick_l", std::string( prop ) );
|
||||
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "onclick_r" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "onclick_r", std::string( prop ) );
|
||||
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "onlongclick_l" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "onlongclick_l", std::string( prop ) );
|
||||
|
||||
prop = (char*) xmlGetProp( cur, BAD_CAST "onclock_tick" );
|
||||
if( prop != NULL )
|
||||
mapAHString( "onclock_tick", std::string( prop ) );
|
||||
}
|
||||
|
||||
// Context menu association
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" );
|
||||
if (prop)
|
||||
{
|
||||
_ListMenuLeft = NLMISC::toLower(std::string((const char *) prop));
|
||||
}
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
|
||||
if (prop)
|
||||
{
|
||||
_ListMenuRight = NLMISC::toLower(std::string((const char *) prop));
|
||||
}
|
||||
// list menu on both clicks
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" );
|
||||
if (prop)
|
||||
{
|
||||
setListMenuBoth(NLMISC::toLower(std::string((const char *) prop)));
|
||||
}
|
||||
|
||||
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen");
|
||||
_Frozen = false;
|
||||
if (prop)
|
||||
_Frozen = convertBool(prop);
|
||||
|
||||
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen_half_tone");
|
||||
_FrozenHalfTone = true;
|
||||
if (prop)
|
||||
_FrozenHalfTone = convertBool(prop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::setModulateGlobalColorAll(bool state)
|
||||
{
|
||||
setModulateGlobalColor(state);
|
||||
setModulateGlobalColorNormal(state);
|
||||
setModulateGlobalColorPushed(state);
|
||||
setModulateGlobalColorOver(state);
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
|
||||
{
|
||||
if (CCtrlBase::handleEvent(event)) return true;
|
||||
if (!_Active || _Frozen)
|
||||
return false;
|
||||
|
||||
sint64 T1 = NLMISC::CTime::getLocalTime();
|
||||
|
||||
if (event.getType() == NLGUI::CEventDescriptor::mouse)
|
||||
{
|
||||
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
|
||||
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
|
||||
{
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
|
||||
return false;
|
||||
_LeftLongClickHandled = true;
|
||||
}
|
||||
|
||||
if (!((eventDesc.getX() >= _XReal) &&
|
||||
(eventDesc.getX() < (_XReal + _WReal))&&
|
||||
(eventDesc.getY() > _YReal) &&
|
||||
(eventDesc.getY() <= (_YReal+ _HReal))))
|
||||
return false;
|
||||
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown)
|
||||
{
|
||||
if (_AHOnLeftDblClick)
|
||||
{
|
||||
if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay())
|
||||
{
|
||||
CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams);
|
||||
_LeftDblClickHandled = true;
|
||||
_LastLeftClickButton = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_AHOnLeftLongClick != NULL)
|
||||
{
|
||||
_LeftLongClickHandled = false;
|
||||
_LeftLongClickDate = T1;
|
||||
}
|
||||
_LeftDblClickHandled = false;
|
||||
_LastLeftClickButton = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
|
||||
{
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
|
||||
return false;
|
||||
|
||||
if( editorMode )
|
||||
{
|
||||
CWidgetManager::getInstance()->setCurrentEditorSelection( getId() );
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled
|
||||
{
|
||||
_LeftDblClickHandled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Do not launch 2 times action handler if we are already pushed ! except if we want.
|
||||
if (!_ClickWhenPushed)
|
||||
{
|
||||
if ((_Type == RadioButton) && _RBRef && (*_RBRef == this))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_Type == RadioButton)
|
||||
{
|
||||
_Pushed = true;
|
||||
if(_RBRef) *_RBRef = this;
|
||||
}
|
||||
|
||||
if (_Type == ToggleButton)
|
||||
_Pushed = !_Pushed;
|
||||
|
||||
/*
|
||||
// RunAction
|
||||
if(_AHOnLeftClick != NULL)
|
||||
{
|
||||
//nlinfo("clicked on %s", _Id.c_str());
|
||||
pIM->submitEvent ("button_click:"+getId());//TEMP
|
||||
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
|
||||
//pIM->submitEvent ("button_click:"+getId());
|
||||
}
|
||||
*/
|
||||
runLeftClickAction();
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)
|
||||
|
||||
// Run Menu
|
||||
if (!_ListMenuLeft.empty())
|
||||
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft);
|
||||
|
||||
if (_AHOnLeftDblClick != NULL)
|
||||
{
|
||||
_LastLeftClickDate = T1;
|
||||
_LastLeftClickButton = this;
|
||||
}
|
||||
|
||||
// Always return true on LeftClick.
|
||||
return true;
|
||||
}
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)
|
||||
{
|
||||
_LastLeftClickButton = NULL;
|
||||
return true;
|
||||
}
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
|
||||
{
|
||||
_LastLeftClickButton = NULL;
|
||||
bool handled= false;
|
||||
if (CWidgetManager::getInstance()->getCapturePointerRight() != this)
|
||||
return false;
|
||||
|
||||
// RunAction
|
||||
if(_AHOnRightClick != NULL)
|
||||
{
|
||||
handled= true;
|
||||
CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams);
|
||||
}
|
||||
if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted
|
||||
// Run Menu
|
||||
if (!_ListMenuRight .empty())
|
||||
{
|
||||
handled= true;
|
||||
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight);
|
||||
}
|
||||
// If not handled here, ret to parent
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (event.getType() == NLGUI::CEventDescriptor::system)
|
||||
{
|
||||
const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event;
|
||||
if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick)
|
||||
{
|
||||
if (_AHOnClockTick != NULL)
|
||||
{
|
||||
CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams);
|
||||
}
|
||||
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
|
||||
{
|
||||
if (!_LeftLongClickHandled)
|
||||
{
|
||||
uint nVal = 50;
|
||||
CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED");
|
||||
if (pNL != NULL)
|
||||
nVal = pNL->getValue32();
|
||||
uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f);
|
||||
if ((T1 - _LeftLongClickDate) > repeatDelay)
|
||||
{
|
||||
_LeftLongClickHandled = true;
|
||||
CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CCtrlBaseButton::getTypeString() const
|
||||
{
|
||||
switch( _Type )
|
||||
{
|
||||
case PushButton:
|
||||
return "push_button";
|
||||
break;
|
||||
|
||||
case ToggleButton:
|
||||
return "toggle_button";
|
||||
break;
|
||||
|
||||
case RadioButton:
|
||||
return "radio_button";
|
||||
break;
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void CCtrlBaseButton::setTypeFromString( const std::string &type )
|
||||
{
|
||||
if( type.empty() || type == "toggle_button" )
|
||||
{
|
||||
_Type = ToggleButton;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( type == "push_button" )
|
||||
{
|
||||
_Type = PushButton;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( type == "radio_button" )
|
||||
{
|
||||
_Type = RadioButton;
|
||||
|
||||
initRBRef();
|
||||
if( _Pushed )
|
||||
*_RBRef = this;
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_Type = ToggleButton;
|
||||
nlinfo( ( "cannot parse button type for button " + getId() ).c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::initRBRef()
|
||||
{
|
||||
if (_RBRef != NULL) return;
|
||||
nlassert(_Parent);
|
||||
const vector<CCtrlBase*> &vCB = _Parent->getControls();
|
||||
uint i = 0;
|
||||
for (i = 0; i < vCB.size(); ++i)
|
||||
{
|
||||
CCtrlBaseButton *pBut = dynamic_cast<CCtrlBaseButton*>(vCB[i]);
|
||||
if (pBut && pBut->_Type == RadioButton)
|
||||
{
|
||||
_RBRef = &pBut->_RBRefBut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If we are the first radio button of the group and not added
|
||||
if (i == vCB.size())
|
||||
_RBRef = &this->_RBRefBut;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::initRBRefFromRadioButton(CCtrlBaseButton * pBut)
|
||||
{
|
||||
if(pBut && pBut->_Type == RadioButton)
|
||||
{
|
||||
_RBRef = &(pBut->_RBRefBut);
|
||||
_RBRefBut=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::setPushed (bool state)
|
||||
{
|
||||
_Pushed = state;
|
||||
|
||||
if (_Type == RadioButton && _RBRef)
|
||||
{
|
||||
if (state == true)
|
||||
{
|
||||
*_RBRef = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*_RBRef == this) // I have to be pushed to unpush me
|
||||
*_RBRef = NULL; // After that : All radio buttons are NOT pushed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::setFrozen (bool state)
|
||||
{
|
||||
_Frozen = state;
|
||||
if (_Frozen)
|
||||
{
|
||||
_Pushed = false;
|
||||
_Over = false;
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::setFrozenHalfTone(bool enabled)
|
||||
{
|
||||
_FrozenHalfTone = enabled;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::unselect()
|
||||
{
|
||||
if (_Type == RadioButton)
|
||||
{
|
||||
if (_RBRef) *_RBRef = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::updateOver(bool &lastOver)
|
||||
{
|
||||
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
|
||||
{
|
||||
_Over = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL)
|
||||
{
|
||||
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
|
||||
{
|
||||
_Over = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const vector<CCtrlBase*> &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer ();
|
||||
|
||||
if (!_Frozen)
|
||||
{
|
||||
uint32 i;
|
||||
lastOver = _Over;
|
||||
// show over if it is the last control that has the same father
|
||||
CCtrlBase *candidate = NULL;
|
||||
for (i = 0; i < rVB.size(); ++i)
|
||||
{
|
||||
if (rVB[i]->getParent() == this->getParent())
|
||||
{
|
||||
candidate = rVB[i];
|
||||
}
|
||||
}
|
||||
_Over = (candidate == this);
|
||||
}
|
||||
else
|
||||
_Over = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement)
|
||||
{
|
||||
// if not me, then reset my '_Over'
|
||||
if (capturedElement != this)
|
||||
{
|
||||
_Over = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBaseButton::runLeftClickAction()
|
||||
{
|
||||
if(_AHOnLeftClick != NULL)
|
||||
{
|
||||
|
||||
//nlinfo("clicked on %s", _Id.c_str());
|
||||
CAHManager::getInstance()->submitEvent( "button_click:" + getId() );
|
||||
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
|
||||
//pIM->submitEvent ("button_click:"+getId());
|
||||
}
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls)
|
||||
{
|
||||
const char *funcName = "onLeftClick";
|
||||
CLuaIHM::checkArgCount(ls, funcName, 0);
|
||||
|
||||
runLeftClickAction();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
489
code/nel/src/gui/ctrl_button.cpp
Normal file
489
code/nel/src/gui/ctrl_button.cpp
Normal file
|
@ -0,0 +1,489 @@
|
|||
// 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/ctrl_button.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
using namespace std;
|
||||
using namespace NLMISC;
|
||||
using namespace NL3D;
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button");
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
void CCtrlButton::setAlignFromString( const std::string &s )
|
||||
{
|
||||
_Align = 0;
|
||||
|
||||
std::string::size_type i;
|
||||
for( i = 0; i < s.size(); i++ )
|
||||
{
|
||||
char c = toLower( s[ i ] );
|
||||
|
||||
switch( c ){
|
||||
case 'l':
|
||||
_Align &= ~1;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
_Align |= 1;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
_Align &= ~2;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
_Align |= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string CCtrlButton::getProperty( const std::string &name ) const
|
||||
{
|
||||
if( name == "tx_normal" )
|
||||
{
|
||||
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
|
||||
}
|
||||
else
|
||||
if( name == "tx_pushed" )
|
||||
{
|
||||
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
|
||||
}
|
||||
else
|
||||
if( name == "tx_over" )
|
||||
{
|
||||
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
|
||||
}
|
||||
else
|
||||
if( name == "scale" )
|
||||
{
|
||||
return toString( _Scale );
|
||||
}
|
||||
else
|
||||
if( name == "align" )
|
||||
{
|
||||
std::string align;
|
||||
if( ( _Align & 1 ) != 0 )
|
||||
align = "r";
|
||||
else
|
||||
align = "l";
|
||||
if( ( _Align & 2 ) != 0 )
|
||||
align += "t";
|
||||
else
|
||||
align += "b";
|
||||
return align;
|
||||
}
|
||||
else
|
||||
return CCtrlBaseButton::getProperty( name );
|
||||
}
|
||||
|
||||
void CCtrlButton::setProperty( const std::string &name, const std::string &value )
|
||||
{
|
||||
if( name == "tx_normal" )
|
||||
{
|
||||
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
|
||||
if( !_TextureIdNormal.setTexture( value.c_str() ) )
|
||||
{
|
||||
_TextureIdNormal.setTexture( s.c_str() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tx_pushed" )
|
||||
{
|
||||
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
|
||||
if( !_TextureIdPushed.setTexture( value.c_str() ) )
|
||||
{
|
||||
_TextureIdPushed.setTexture( s.c_str() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "tx_over" )
|
||||
{
|
||||
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
|
||||
if( !_TextureIdOver.setTexture( value.c_str() ) )
|
||||
{
|
||||
_TextureIdOver.setTexture( s.c_str() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "scale" )
|
||||
{
|
||||
bool b;
|
||||
if( fromString( value, b ) )
|
||||
_Scale = b;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if( name == "align" )
|
||||
{
|
||||
setAlignFromString( value );
|
||||
return;
|
||||
}
|
||||
else
|
||||
CCtrlBaseButton::setProperty( name, value );
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr CCtrlButton::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type );
|
||||
if( node == NULL )
|
||||
return NULL;
|
||||
|
||||
xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tx_normal",
|
||||
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tx_pushed",
|
||||
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tx_over",
|
||||
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() );
|
||||
|
||||
std::string align;
|
||||
if( ( _Align & 1 ) != 0 )
|
||||
align = "r";
|
||||
else
|
||||
align = "l";
|
||||
if( ( _Align & 2 ) != 0 )
|
||||
align += "t";
|
||||
else
|
||||
align += "b";
|
||||
|
||||
xmlNewProp( node, BAD_CAST "align", BAD_CAST align.c_str() );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
|
||||
{
|
||||
CXMLAutoPtr prop;
|
||||
//try to get props that can be inherited from groups
|
||||
//if a property is not defined, try to find it in the parent group.
|
||||
//if it is undefined, set it to zero
|
||||
if (! CCtrlBaseButton::parse(cur,parentGroup) )
|
||||
{
|
||||
string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId();
|
||||
nlinfo(tmp.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// *** Read Textures
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
|
||||
if (prop)
|
||||
{
|
||||
string TxName = (const char *) prop;
|
||||
TxName = strlwr(TxName);
|
||||
_TextureIdNormal.setTexture(TxName.c_str());
|
||||
}
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" );
|
||||
if (prop)
|
||||
{
|
||||
string TxName = (const char *) prop;
|
||||
TxName = strlwr(TxName);
|
||||
_TextureIdPushed.setTexture(TxName.c_str());
|
||||
}
|
||||
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" );
|
||||
if (prop)
|
||||
{
|
||||
string TxName = (const char *) prop;
|
||||
TxName = strlwr(TxName);
|
||||
_TextureIdOver.setTexture(TxName.c_str());
|
||||
}
|
||||
|
||||
// *** Misc.
|
||||
prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" );
|
||||
_Scale = false;
|
||||
if (prop)
|
||||
_Scale = convertBool(prop);
|
||||
|
||||
|
||||
prop = (char*) xmlGetProp (cur, (xmlChar*)"align");
|
||||
if (prop)
|
||||
{
|
||||
setAlignFromString( std::string( prop ) );
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CCtrlButton::draw ()
|
||||
{
|
||||
sint32 nTxId = -1;
|
||||
CRGBA color;
|
||||
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent();
|
||||
|
||||
// *** Detect Over
|
||||
bool lastOver = false;
|
||||
|
||||
updateOver(lastOver);
|
||||
|
||||
|
||||
sint32 x = _XReal;
|
||||
sint32 y = _YReal;
|
||||
sint32 txw, txh;
|
||||
// the pointer is over the button
|
||||
if (_Scale)
|
||||
{
|
||||
x = _XReal;
|
||||
y = _YReal;
|
||||
txw = _WReal;
|
||||
txh = _HReal;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = _XReal;
|
||||
y = _YReal;
|
||||
}
|
||||
|
||||
switch(_Type)
|
||||
{
|
||||
case ToggleButton:
|
||||
{
|
||||
if (_Pushed && !editorMode )
|
||||
{
|
||||
nTxId = _TextureIdPushed;
|
||||
color = getCurrentColorPushed(globalColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTxId = _TextureIdNormal;
|
||||
color = getCurrentColorNormal(globalColor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case RadioButton:
|
||||
{
|
||||
// CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer();
|
||||
// Init the radio button
|
||||
initRBRef();
|
||||
|
||||
if (*_RBRef == this)
|
||||
{
|
||||
// if it is equal to the ref value, then the button must appear pushed
|
||||
nTxId = _TextureIdPushed;
|
||||
color = getCurrentColorPushed(globalColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( (_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
|
||||
{
|
||||
nTxId = _TextureIdPushed;
|
||||
color = getCurrentColorPushed(globalColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTxId = _TextureIdNormal;
|
||||
color = getCurrentColorNormal(globalColor);
|
||||
_Pushed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PushButton:
|
||||
{
|
||||
if ( _Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
|
||||
{
|
||||
nTxId = _TextureIdPushed;
|
||||
color = getCurrentColorPushed(globalColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
nTxId = _TextureIdNormal;
|
||||
color = getCurrentColorNormal(globalColor);
|
||||
_Pushed = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
|
||||
|
||||
// Fromzen ?
|
||||
if (getFrozen() && getFrozenHalfTone())
|
||||
color.A >>= 2;
|
||||
|
||||
if (!_Scale)
|
||||
{
|
||||
CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh);
|
||||
if (_Align&1)
|
||||
x = x + _WReal - txw;
|
||||
if (_Align&2)
|
||||
y = y + _HReal - txh;
|
||||
}
|
||||
rVR.drawRotFlipBitmap ( _RenderLayer, x, y, txw, txh,
|
||||
0, false,
|
||||
nTxId,
|
||||
color );
|
||||
|
||||
if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this)))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
if ( ( _Over && !editorMode ) || editorSelected )
|
||||
{
|
||||
|
||||
if( !editorMode && (lastOver == false) && (_AHOnOver != NULL))
|
||||
CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams);
|
||||
|
||||
// the pointer is over the button
|
||||
color= getCurrentColorOver(globalColor);
|
||||
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
|
||||
|
||||
// Frozen ?
|
||||
if (getFrozen())
|
||||
color.A >>= 2;
|
||||
|
||||
// draw the over. force upper layer to avoid problem with DXTC/tga
|
||||
rVR.drawRotFlipBitmap ( _RenderLayer+1, x, y, txw, txh,
|
||||
0, false,
|
||||
_TextureIdOver,
|
||||
color );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CCtrlButton::updateCoords()
|
||||
{
|
||||
if (!_Scale)
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 txw, txh;
|
||||
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
|
||||
_W = txw;
|
||||
_H = txh;
|
||||
}
|
||||
CViewBase::updateCoords();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CCtrlButton::setTexture(const std::string&name)
|
||||
{
|
||||
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
// CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
_TextureIdNormal.setTexture(name.c_str (), 0, 0, -1, -1, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CCtrlButton::setTexturePushed(const std::string&name)
|
||||
{
|
||||
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
// CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
_TextureIdPushed.setTexture(name.c_str (), 0, 0, -1, -1, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CCtrlButton::setTextureOver(const std::string&name)
|
||||
{
|
||||
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
// CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
_TextureIdOver.setTexture(name.c_str (), 0, 0, -1, -1, false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string CCtrlButton::getTexture() const
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
return rVR.getTextureNameFromId(_TextureIdNormal);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string CCtrlButton::getTexturePushed() const
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
return rVR.getTextureNameFromId(_TextureIdPushed);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
std::string CCtrlButton::getTextureOver() const
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
return rVR.getTextureNameFromId(_TextureIdOver);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CCtrlButton::getMaxUsedW() const
|
||||
{
|
||||
sint32 txw, txh;
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
|
||||
return txw;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
sint32 CCtrlButton::getMinUsedW() const
|
||||
{
|
||||
return getMaxUsedW();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlButton::fitTexture()
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
sint32 w, h;
|
||||
rVR.getTextureSizeFromId(_TextureIdNormal, w, h);
|
||||
setW(w);
|
||||
setH(h);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
|
||||
{
|
||||
if (_AHOnLeftClickString == "browse")
|
||||
{
|
||||
if (!_AHOnLeftClickStringParams.empty())
|
||||
{
|
||||
texName = "@curs_pick.tga@"+_AHOnLeftClickStringParams;
|
||||
}
|
||||
else
|
||||
{
|
||||
texName = "curs_pick.tga";
|
||||
}
|
||||
rot= 0;
|
||||
col = CRGBA::White;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue