From 5afbf1615acf4a6ed1fb2b40224d8a58a1940d77 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 28 Jun 2012 07:07:44 +0200 Subject: [PATCH] CHANGED: CDBViewDigit is now part of the NELGUI library and is under the NLGUI namespace. --- .../include/nel/gui}/dbview_digit.h | 57 +++---- code/nel/src/gui/dbview_digit.cpp | 142 ++++++++++++++++++ .../client/src/interface_v3/dbview_digit.cpp | 141 ----------------- .../src/interface_v3/interface_parser.cpp | 2 +- 4 files changed, 172 insertions(+), 170 deletions(-) rename code/{ryzom/client/src/interface_v3 => nel/include/nel/gui}/dbview_digit.h (55%) create mode 100644 code/nel/src/gui/dbview_digit.cpp delete mode 100644 code/ryzom/client/src/interface_v3/dbview_digit.cpp diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.h b/code/nel/include/nel/gui/dbview_digit.h similarity index 55% rename from code/ryzom/client/src/interface_v3/dbview_digit.h rename to code/nel/include/nel/gui/dbview_digit.h index 0589e38d8..05a5db6b2 100644 --- a/code/ryzom/client/src/interface_v3/dbview_digit.h +++ b/code/nel/include/nel/gui/dbview_digit.h @@ -15,47 +15,48 @@ // along with this program. If not, see . - #ifndef NL_DBVIEW_DIGIT_H #define NL_DBVIEW_DIGIT_H #include "nel/misc/types_nl.h" - #include "nel/gui/view_base.h" - -// *************************************************************************** -/** - * A number displayed with special bitmaps - * \author Lionel Berenguier - * \author Nevrax France - * \date 2002 - */ -class CDBViewDigit : public CViewBase +namespace NLGUI { -public: - /// Constructor - CDBViewDigit(const TCtorParam ¶m); + // *************************************************************************** + /** + * A number displayed with special bitmaps + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewDigit : public CViewBase + { + public: - virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual void draw (); - virtual void updateCoords(); + /// Constructor + CDBViewDigit(const TCtorParam ¶m); -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; + 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 diff --git a/code/nel/src/gui/dbview_digit.cpp b/code/nel/src/gui/dbview_digit.cpp new file mode 100644 index 000000000..f8affb858 --- /dev/null +++ b/code/nel/src/gui/dbview_digit.cpp @@ -0,0 +1,142 @@ +// Ryzom - MMORPG Framework +// 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 . + + +#include "nel/gui/dbview_digit.h" +#include "nel/misc/xml_auto_ptr.h" +#include "nel/gui/view_renderer.h" + +using namespace std; +using namespace NL3D; +using namespace NLMISC; + +NLMISC_REGISTER_OBJECT(CViewBase, CDBViewDigit, std::string, "digit"); + +namespace NLGUI +{ + + // *************************************************************************** + CDBViewDigit::CDBViewDigit(const TCtorParam ¶m) + : CViewBase(param) + { + _NumDigit= 2; + _WSpace= -1; + _DivBase= 1; + } + + + // *************************************************************************** + bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) + { + if(!CViewBase::parse(cur, parentGroup)) + return false; + + CViewRenderer &rVR = *CViewRenderer::getInstance(); + + // link to the db + CXMLAutoPtr ptr; + ptr = xmlGetProp (cur, (xmlChar*)"value"); + if ( ptr ) + _Number.link ( ptr ); + else + { + nlinfo ("no value in %s", _Id.c_str()); + return false; + } + + // read options + ptr = xmlGetProp (cur, (xmlChar*)"numdigit"); + if(ptr) fromString((const char*)ptr, _NumDigit); + clamp(_NumDigit, 1, 10); + + ptr = xmlGetProp (cur, (xmlChar*)"wspace"); + if(ptr) fromString((const char*)ptr, _WSpace); + + ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" ); + _Color = CRGBA(255,255,255,255); + if (ptr) + _Color = convertColor (ptr); + + // compute window size. Remove one space. + sint32 wDigit= rVR.getFigurTextureW(); + sint32 hDigit= rVR.getFigurTextureH(); + setW((wDigit+_WSpace)*_NumDigit - _WSpace); + setH(hDigit); + + // some init + // For _NumDigit=2; set the divBase to 100, etc... + _DivBase= 1; + for(uint i= 0;i<(uint)_NumDigit;i++) + { + _DivBase*= 10; + } + + // init cache. + _Cache= -1; + + return true; + } + + + // *************************************************************************** + void CDBViewDigit::updateCoords() + { + CViewBase::updateCoords(); + } + + + // *************************************************************************** + void CDBViewDigit::draw () + { + CViewRenderer &rVR = *CViewRenderer::getInstance(); + sint32 wDigit= rVR.getFigurTextureW(); + sint32 hDigit= rVR.getFigurTextureH(); + + // change bitmap ids + sint32 val= _Number.getSInt32(); + val= max(val, sint32(0)); + if(_Cache!=val) + { + _Cache= val; + // clamp the value to max possible (eg:99) + if(val>(sint32)_DivBase-1) + val=(sint32)_DivBase-1; + // compute each digit id + uint divisor= _DivBase/10; + for(sint i=0;i<_NumDigit;i++) + { + sint digitVal= (val/divisor)%10; + // set the digit text id + _DigitId[i]= rVR.getFigurTextureId(digitVal); + // next divisor + divisor/= 10; + } + } + + // Display bitmaps + sint32 x= _XReal; + sint32 y= _YReal; + for(sint i=0;i<_NumDigit;i++) + { + rVR.drawRotFlipBitmap ( _RenderLayer, x, y, wDigit, hDigit, 0, false, _DigitId[i], _Color ); + // next digit + x+= wDigit+_WSpace; + } + + } + +} + diff --git a/code/ryzom/client/src/interface_v3/dbview_digit.cpp b/code/ryzom/client/src/interface_v3/dbview_digit.cpp deleted file mode 100644 index 683662fef..000000000 --- a/code/ryzom/client/src/interface_v3/dbview_digit.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - - - -#include "stdpch.h" - -#include "dbview_digit.h" -#include "interface_manager.h" -#include "nel/misc/xml_auto_ptr.h" - -using namespace std; -using namespace NL3D; -using namespace NLMISC; - -NLMISC_REGISTER_OBJECT(CViewBase, CDBViewDigit, std::string, "digit"); - -// *************************************************************************** -CDBViewDigit::CDBViewDigit(const TCtorParam ¶m) -: CViewBase(param) -{ - _NumDigit= 2; - _WSpace= -1; - _DivBase= 1; -} - - -// *************************************************************************** -bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup) -{ - if(!CViewBase::parse(cur, parentGroup)) - return false; - - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - - // link to the db - CXMLAutoPtr ptr; - ptr = xmlGetProp (cur, (xmlChar*)"value"); - if ( ptr ) - _Number.link ( ptr ); - else - { - nlinfo ("no value in %s", _Id.c_str()); - return false; - } - - // read options - ptr = xmlGetProp (cur, (xmlChar*)"numdigit"); - if(ptr) fromString((const char*)ptr, _NumDigit); - clamp(_NumDigit, 1, 10); - - ptr = xmlGetProp (cur, (xmlChar*)"wspace"); - if(ptr) fromString((const char*)ptr, _WSpace); - - ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" ); - _Color = CRGBA(255,255,255,255); - if (ptr) - _Color = convertColor (ptr); - - // compute window size. Remove one space. - sint32 wDigit= rVR.getFigurTextureW(); - sint32 hDigit= rVR.getFigurTextureH(); - setW((wDigit+_WSpace)*_NumDigit - _WSpace); - setH(hDigit); - - // some init - // For _NumDigit=2; set the divBase to 100, etc... - _DivBase= 1; - for(uint i= 0;i<(uint)_NumDigit;i++) - { - _DivBase*= 10; - } - - // init cache. - _Cache= -1; - - return true; -} - - -// *************************************************************************** -void CDBViewDigit::updateCoords() -{ - CViewBase::updateCoords(); -} - - -// *************************************************************************** -void CDBViewDigit::draw () -{ - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - CViewRenderer &rVR = *CViewRenderer::getInstance(); - sint32 wDigit= rVR.getFigurTextureW(); - sint32 hDigit= rVR.getFigurTextureH(); - - // change bitmap ids - sint32 val= _Number.getSInt32(); - val= max(val, sint32(0)); - if(_Cache!=val) - { - _Cache= val; - // clamp the value to max possible (eg:99) - if(val>(sint32)_DivBase-1) - val=(sint32)_DivBase-1; - // compute each digit id - uint divisor= _DivBase/10; - for(sint i=0;i<_NumDigit;i++) - { - sint digitVal= (val/divisor)%10; - // set the digit text id - _DigitId[i]= rVR.getFigurTextureId(digitVal); - // next divisor - divisor/= 10; - } - } - - // Display bitmaps - sint32 x= _XReal; - sint32 y= _YReal; - for(sint i=0;i<_NumDigit;i++) - { - rVR.drawRotFlipBitmap ( _RenderLayer, x, y, wDigit, hDigit, 0, false, _DigitId[i], _Color ); - // next digit - x+= wDigit+_WSpace; - } - -} diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 33a5e4dd4..97d152d1d 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -50,7 +50,7 @@ #include "nel/gui/dbview_bar3.h" #include "dbview_number.h" #include "dbview_quantity.h" -#include "dbview_digit.h" +#include "nel/gui/dbview_digit.h" // Ctrl #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h"