mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-15 20:23:47 +00:00
CHANGED: #1471 CDBGroupSelectNumber is now part of the NELGUI library and is under the NLGUI namespace. Also had to add a workaround so that the linker doesn't drop the seemingly unused code from the library. Thanks goes to Kaetami for that!
This commit is contained in:
parent
2290971c81
commit
f5091dacd4
12 changed files with 367 additions and 340 deletions
96
code/nel/include/nel/gui/dbgroup_select_number.h
Normal file
96
code/nel/include/nel/gui/dbgroup_select_number.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
// 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();
|
||||
|
||||
/// 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 */
|
|
@ -70,6 +70,8 @@ namespace NLGUI
|
|||
REFLECT_SINT32 ("range3", getRange2, setRange2);
|
||||
REFLECT_EXPORT_END
|
||||
|
||||
static void forceLink();
|
||||
|
||||
protected:
|
||||
|
||||
CViewBitmap _Slot;
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace NLGUI
|
|||
_Number.link (dbprop.c_str());
|
||||
}
|
||||
|
||||
static void forceLink();
|
||||
|
||||
protected:
|
||||
|
||||
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
|
||||
|
|
234
code/nel/src/gui/dbgroup_select_number.cpp
Normal file
234
code/nel/src/gui/dbgroup_select_number.cpp
Normal file
|
@ -0,0 +1,234 @@
|
|||
// 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/dbgroup_select_number.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/view_bitmap.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
#include "nel/gui/interface_property.h"
|
||||
#include "nel/gui/action_handler.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NL3D;
|
||||
using namespace NLMISC;
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number");
|
||||
|
||||
// ***************************************************************************
|
||||
CDBGroupSelectNumber::CDBGroupSelectNumber(const TCtorParam ¶m) :
|
||||
CInterfaceGroup(param)
|
||||
{
|
||||
_SlotNumber= NULL;
|
||||
_TextNumber= NULL;
|
||||
_ButtonUp= NULL;
|
||||
_ButtonDown= NULL;
|
||||
_LoopMode= true;
|
||||
_MinValue= 0;
|
||||
_MaxValue= 9;
|
||||
_DeltaMultiplier= 1;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
CDBGroupSelectNumber::~CDBGroupSelectNumber()
|
||||
{
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CDBGroupSelectNumber::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
|
||||
{
|
||||
if(!CInterfaceGroup::parse(cur, parentGroup))
|
||||
return false;
|
||||
|
||||
// read params
|
||||
CXMLAutoPtr ptr;
|
||||
ptr = xmlGetProp (cur, (xmlChar*)"value");
|
||||
if ( ptr )
|
||||
_Number.link ( ptr );
|
||||
else
|
||||
{
|
||||
nlinfo ("no value in %s", _Id.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop, min and max
|
||||
_LoopMode= false;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"loop");
|
||||
if(ptr) _LoopMode= convertBool(ptr);
|
||||
_MinValue = 0;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"min");
|
||||
if(ptr) fromString((const char*)ptr, _MinValue);
|
||||
_MaxValue = 0;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"max");
|
||||
if(ptr) fromString((const char*)ptr, _MaxValue);
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"delta");
|
||||
if(ptr) fromString((const char*)ptr, _DeltaMultiplier);
|
||||
|
||||
// set min val in DB
|
||||
_Number.setSInt32(_MinValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::setup()
|
||||
{
|
||||
if (_SlotNumber != NULL)
|
||||
return;
|
||||
|
||||
// bind to the controls.
|
||||
_SlotNumber= dynamic_cast<CViewBitmap*>(CInterfaceGroup::getView("slot_number"));
|
||||
_TextNumber= dynamic_cast<CViewText*>(CInterfaceGroup::getView("number"));
|
||||
_ButtonUp= dynamic_cast<CCtrlBaseButton*>(CInterfaceGroup::getCtrl("arrow_up"));
|
||||
_ButtonDown= dynamic_cast<CCtrlBaseButton*>(CInterfaceGroup::getCtrl("arrow_down"));
|
||||
|
||||
// checks
|
||||
if(_SlotNumber==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: bitmap 'slot_number' missing or bad type");
|
||||
if(_TextNumber==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: text view 'number' missing or bad type");
|
||||
if(_ButtonUp==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: button 'arrow_up' missing or bad type");
|
||||
if(_ButtonDown==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: button 'arrow_down' missing or bad type");
|
||||
if(_SlotNumber==NULL || _TextNumber==NULL || _ButtonUp==NULL || _ButtonDown==NULL)
|
||||
return;
|
||||
|
||||
// actions
|
||||
_ButtonUp->setActionOnLeftClick("sn_up");
|
||||
_ButtonDown->setActionOnLeftClick("sn_down");
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::updateCoords ()
|
||||
{
|
||||
setup();
|
||||
CInterfaceGroup::updateCoords();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDBGroupSelectNumber::checkCoords()
|
||||
{
|
||||
if(_TextNumber)
|
||||
_TextNumber->setText( toString(_Number.getSInt32()) );
|
||||
CInterfaceGroup::checkCoords();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::draw ()
|
||||
{
|
||||
CInterfaceGroup::draw();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::clearViews ()
|
||||
{
|
||||
CInterfaceGroup::clearViews();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CDBGroupSelectNumber::handleEvent (const NLGUI::CEventDescriptor &event)
|
||||
{
|
||||
if (event.getType() == NLGUI::CEventDescriptor::mouse)
|
||||
{
|
||||
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
|
||||
if (isIn(eventDesc.getX(), eventDesc.getY()))
|
||||
{
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel)
|
||||
{
|
||||
changeValue (eventDesc.getWheel());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CInterfaceGroup::handleEvent(event)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::changeValue(sint delta)
|
||||
{
|
||||
delta*= _DeltaMultiplier;
|
||||
|
||||
// get DB and add
|
||||
sint32 val= _Number.getSInt32();
|
||||
val+= delta;
|
||||
|
||||
// Loop or clamp
|
||||
if(_LoopMode)
|
||||
{
|
||||
sint32 dval= _MaxValue+1 - _MinValue;
|
||||
if (dval <= 0)
|
||||
{
|
||||
val = 0;
|
||||
return;
|
||||
}
|
||||
val -= _MinValue;
|
||||
val = val% dval; val = (val+dval)% dval;
|
||||
val += _MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
clamp(val, _MinValue, _MaxValue);
|
||||
}
|
||||
|
||||
// set in DB
|
||||
_Number.setSInt32(val);
|
||||
if(_TextNumber)
|
||||
_TextNumber->setText( toString(_Number.getSInt32()) );
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// ***************************************************************************
|
||||
// Actions Handlers
|
||||
// ***************************************************************************
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class CSNUp : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CDBGroupSelectNumber *pSN = dynamic_cast<CDBGroupSelectNumber*>(pCaller->getParent());
|
||||
if (pSN == NULL) return;
|
||||
pSN->changeValue(+1);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CSNUp, "sn_up");
|
||||
|
||||
// ***************************************************************************
|
||||
class CSNDown : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CDBGroupSelectNumber *pSN = dynamic_cast<CDBGroupSelectNumber*>(pCaller->getParent());
|
||||
if (pSN == NULL) return;
|
||||
pSN->changeValue(-1);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CSNDown, "sn_down");
|
||||
|
||||
}
|
||||
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
#include "nel/gui/dbview_bar3.h"
|
||||
#include "nel/misc/xml_auto_ptr.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
#include "nel/gui/widget_manager.h"
|
||||
#include "nel/gui/db_manager.h"
|
||||
#include "nel/gui/interface_group.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NL3D;
|
||||
|
@ -27,7 +27,6 @@ using namespace NLMISC;
|
|||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CDBViewBar3, std::string, "bar3");
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -235,5 +234,9 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDBViewBar3::forceLink()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,5 +124,9 @@ namespace NLGUI
|
|||
CViewText::draw();
|
||||
}
|
||||
|
||||
void CDBViewNumber::forceLink()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
12
code/nel/src/gui/link_hack.cpp
Normal file
12
code/nel/src/gui/link_hack.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "nel/gui/dbview_bar3.h"
|
||||
#include "nel/gui/dbview_number.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
/// Necessary so the linker doesn't drop the code of these classes from the library
|
||||
void LinkHack()
|
||||
{
|
||||
CDBViewBar3::forceLink();
|
||||
CDBViewNumber::forceLink();
|
||||
}
|
||||
}
|
|
@ -25,17 +25,26 @@
|
|||
#include "nel/gui/group_editbox_base.h"
|
||||
#include "nel/gui/interface_options.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
void LinkHack();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
const uint DOUBLE_CLICK_MIN = 50;
|
||||
const uint DOUBLE_CLICK_MAX = 750;
|
||||
const float ROLLOVER_MIN_DELTA_PER_MS = 0.28f;
|
||||
const float ROLLOVER_MAX_DELTA_PER_MS = 0.12f;
|
||||
|
||||
void Hack()
|
||||
{
|
||||
NLGUI::LinkHack();
|
||||
}
|
||||
}
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
CWidgetManager* CWidgetManager::instance = NULL;
|
||||
std::string CWidgetManager::_CtrlLaunchingModalId= "ctrl_launch_modal";
|
||||
IParser* CWidgetManager::parser = NULL;
|
||||
|
|
|
@ -1,237 +0,0 @@
|
|||
// 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 "stdpch.h"
|
||||
|
||||
|
||||
#include "dbgroup_select_number.h"
|
||||
#include "nel/gui/view_text.h"
|
||||
#include "nel/gui/view_bitmap.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
#include "nel/gui/interface_property.h"
|
||||
#include "interface_manager.h"
|
||||
#include "nel/gui/action_handler.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace NL3D;
|
||||
using namespace NLMISC;
|
||||
|
||||
NLMISC_REGISTER_OBJECT(CViewBase, CDBGroupSelectNumber, std::string, "select_number");
|
||||
|
||||
// ***************************************************************************
|
||||
CDBGroupSelectNumber::CDBGroupSelectNumber(const TCtorParam ¶m)
|
||||
: CInterfaceGroup(param)
|
||||
{
|
||||
_SlotNumber= NULL;
|
||||
_TextNumber= NULL;
|
||||
_ButtonUp= NULL;
|
||||
_ButtonDown= NULL;
|
||||
_LoopMode= true;
|
||||
_MinValue= 0;
|
||||
_MaxValue= 9;
|
||||
_DeltaMultiplier= 1;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
CDBGroupSelectNumber::~CDBGroupSelectNumber()
|
||||
{
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CDBGroupSelectNumber::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
|
||||
{
|
||||
if(!CInterfaceGroup::parse(cur, parentGroup))
|
||||
return false;
|
||||
|
||||
// read params
|
||||
CXMLAutoPtr ptr;
|
||||
ptr = xmlGetProp (cur, (xmlChar*)"value");
|
||||
if ( ptr )
|
||||
_Number.link ( ptr );
|
||||
else
|
||||
{
|
||||
nlinfo ("no value in %s", _Id.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loop, min and max
|
||||
_LoopMode= false;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"loop");
|
||||
if(ptr) _LoopMode= convertBool(ptr);
|
||||
_MinValue = 0;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"min");
|
||||
if(ptr) fromString((const char*)ptr, _MinValue);
|
||||
_MaxValue = 0;
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"max");
|
||||
if(ptr) fromString((const char*)ptr, _MaxValue);
|
||||
ptr= xmlGetProp (cur, (xmlChar*)"delta");
|
||||
if(ptr) fromString((const char*)ptr, _DeltaMultiplier);
|
||||
|
||||
// set min val in DB
|
||||
_Number.setSInt32(_MinValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::setup()
|
||||
{
|
||||
if (_SlotNumber != NULL)
|
||||
return;
|
||||
|
||||
// bind to the controls.
|
||||
_SlotNumber= dynamic_cast<CViewBitmap*>(CInterfaceGroup::getView("slot_number"));
|
||||
_TextNumber= dynamic_cast<CViewText*>(CInterfaceGroup::getView("number"));
|
||||
_ButtonUp= dynamic_cast<CCtrlBaseButton*>(CInterfaceGroup::getCtrl("arrow_up"));
|
||||
_ButtonDown= dynamic_cast<CCtrlBaseButton*>(CInterfaceGroup::getCtrl("arrow_down"));
|
||||
|
||||
// checks
|
||||
if(_SlotNumber==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: bitmap 'slot_number' missing or bad type");
|
||||
if(_TextNumber==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: text view 'number' missing or bad type");
|
||||
if(_ButtonUp==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: button 'arrow_up' missing or bad type");
|
||||
if(_ButtonDown==NULL)
|
||||
nlwarning("Interface: SelectNumberGroup: button 'arrow_down' missing or bad type");
|
||||
if(_SlotNumber==NULL || _TextNumber==NULL || _ButtonUp==NULL || _ButtonDown==NULL)
|
||||
return;
|
||||
|
||||
// actions
|
||||
_ButtonUp->setActionOnLeftClick("sn_up");
|
||||
_ButtonDown->setActionOnLeftClick("sn_down");
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::updateCoords ()
|
||||
{
|
||||
setup();
|
||||
CInterfaceGroup::updateCoords();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDBGroupSelectNumber::checkCoords()
|
||||
{
|
||||
if(_TextNumber)
|
||||
_TextNumber->setText( toString(_Number.getSInt32()) );
|
||||
CInterfaceGroup::checkCoords();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::draw ()
|
||||
{
|
||||
CInterfaceGroup::draw();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::clearViews ()
|
||||
{
|
||||
CInterfaceGroup::clearViews();
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CDBGroupSelectNumber::handleEvent (const NLGUI::CEventDescriptor &event)
|
||||
{
|
||||
if (event.getType() == NLGUI::CEventDescriptor::mouse)
|
||||
{
|
||||
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
|
||||
if (isIn(eventDesc.getX(), eventDesc.getY()))
|
||||
{
|
||||
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousewheel)
|
||||
{
|
||||
changeValue (eventDesc.getWheel());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CInterfaceGroup::handleEvent(event)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
void CDBGroupSelectNumber::changeValue(sint delta)
|
||||
{
|
||||
delta*= _DeltaMultiplier;
|
||||
|
||||
// get DB and add
|
||||
sint32 val= _Number.getSInt32();
|
||||
val+= delta;
|
||||
|
||||
// Loop or clamp
|
||||
if(_LoopMode)
|
||||
{
|
||||
sint32 dval= _MaxValue+1 - _MinValue;
|
||||
if (dval <= 0)
|
||||
{
|
||||
val = 0;
|
||||
return;
|
||||
}
|
||||
val -= _MinValue;
|
||||
val = val% dval; val = (val+dval)% dval;
|
||||
val += _MinValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
clamp(val, _MinValue, _MaxValue);
|
||||
}
|
||||
|
||||
// set in DB
|
||||
_Number.setSInt32(val);
|
||||
if(_TextNumber)
|
||||
_TextNumber->setText( toString(_Number.getSInt32()) );
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// ***************************************************************************
|
||||
// Actions Handlers
|
||||
// ***************************************************************************
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class CSNUp : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CDBGroupSelectNumber *pSN = dynamic_cast<CDBGroupSelectNumber*>(pCaller->getParent());
|
||||
if (pSN == NULL) return;
|
||||
pSN->changeValue(+1);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CSNUp, "sn_up");
|
||||
|
||||
// ***************************************************************************
|
||||
class CSNDown : public IActionHandler
|
||||
{
|
||||
public:
|
||||
virtual void execute (CCtrlBase *pCaller, const std::string &/* Params */)
|
||||
{
|
||||
CDBGroupSelectNumber *pSN = dynamic_cast<CDBGroupSelectNumber*>(pCaller->getParent());
|
||||
if (pSN == NULL) return;
|
||||
pSN->changeValue(-1);
|
||||
}
|
||||
};
|
||||
REGISTER_ACTION_HANDLER (CSNDown, "sn_down");
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
// 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();
|
||||
|
||||
/// 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 */
|
|
@ -85,7 +85,7 @@
|
|||
#include "nel/gui/group_tab.h"
|
||||
#include "group_table.h"
|
||||
// DBGroup
|
||||
#include "dbgroup_select_number.h"
|
||||
#include "nel/gui/dbgroup_select_number.h"
|
||||
#include "dbgroup_list_sheet.h"
|
||||
#include "dbgroup_combo_box.h"
|
||||
#include "dbgroup_list_sheet_trade.h"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "nel/gui/group_container_base.h"
|
||||
#include "nel/gui/group_container.h"
|
||||
#include "nel/gui/group_list.h"
|
||||
#include "dbgroup_select_number.h"
|
||||
#include "nel/gui/dbgroup_select_number.h"
|
||||
#include "nel/gui/ctrl_button.h"
|
||||
#include "nel/gui/ctrl_text_button.h"
|
||||
#include "nel/gui/ctrl_col_pick.h"
|
||||
|
|
Loading…
Reference in a new issue