Backed out changeset: da24b99ddf3d

--HG--
branch : experimental-ui-scaling
This commit is contained in:
Nimetu 2017-05-11 11:48:05 +03:00
parent edf7551884
commit 4c605fcfe0
2 changed files with 103 additions and 197 deletions

View file

@ -542,15 +542,6 @@ CCtrlDraggable(param)
_ItemRMClassType= NULL;
_ItemRMFaberStatType= NULL;
_NotifyAnimEndTime = 0;
_SheetText = NULL;
_QualityText = NULL;
_QuantityText = NULL;
_SapText = NULL;
_QualityTextValue = -1;
_QuantityTextValue = -1;
_SapTextValue = -1;
}
// ----------------------------------------------------------------------------
@ -571,30 +562,6 @@ CDBCtrlSheet::~CDBCtrlSheet()
_GuildSymb = NULL;
}
if (_SheetText)
{
delete _SheetText;
_SheetText = NULL;
}
if (_QualityText)
{
delete _QualityText;
_QualityText = NULL;
}
if (_QuantityText)
{
delete _QuantityText;
_QuantityText = NULL;
}
if (_SapText)
{
delete _SapText;
_SapText = NULL;
}
// ensure erase static
if(this==_CurrMenuSheet) _CurrMenuSheet = NULL;
if(this == dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) )
@ -1053,19 +1020,6 @@ void CDBCtrlSheet::updateCoords ()
}
}
CInterfaceElement::updateCoords();
if (getActive())
{
// updateCoords() is called to apply possible UI scale change to font
if (_SheetText)
_SheetText->updateCoords();
if (_QualityText)
_QualityText->updateCoords();
if (_QuantityText)
_QuantityText->updateCoords();
if (_SapText)
_SapText->updateCoords();
}
}
// ----------------------------------------------------------------------------
@ -1779,107 +1733,82 @@ sint32 CDBCtrlSheet::getSPhraseId() const
// ***************************************************************************
void CDBCtrlSheet::resetCharBitmaps()
{
if (_SheetText)
_SheetText->setActive(false);
if (_QualityText)
_QualityText->setActive(false);
if (_QuantityText)
_QuantityText->setActive(false);
if (_SapText)
_SapText->setActive(false);
}
CViewText* CDBCtrlSheet::createViewText(const std::string &id, sint fontSize)
{
CViewText *text = new CViewText(CViewBase::TCtorParam());
text->setActive(false);
text->setId(getId() + ":" + id);
// icon slot does not inherit from CInterfaceGroup and cannot be used as parent
text->setParent(_Parent);
text->setParentPos(_ParentPos);
text->setParentPosRef(_ParentPosRef);
text->setFontSize(fontSize);
text->setShadow(true);
text->setColor(CRGBA::White);
text->setOverflowText(ucstring(""));
text->setModulateGlobalColor(false);
text->setMultiLineSpace(0);
text->setMultiLineMaxWOnly(true);
text->setMultiLine(false);
return text;
_CharBitmaps.clear();
}
// ***************************************************************************
void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown)
{
// Use the optString for the Macro name
_OptString = toLower(_OptString);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance();
_CharBitmaps.clear();
if(maxLine<=0)
{
if (_SheetText)
_SheetText->setActive(false);
return;
uint h = rVR.getTypoTextureH('a');
sint lineNb = 0;
sint curLineSize = 0;
uint i;
uint xChar= 0;
for (i = 0; i < _OptString.size(); ++i)
{
char c = _OptString[i];
sint32 w = rVR.getTypoTextureW(c);
if ((curLineSize + w) > maxW || (sint32)xChar>=maxWChar)
{
lineNb ++;
if (lineNb == maxLine) break;
curLineSize = 0;
xChar = 0;
}
sint32 id = rVR.getTypoTextureId(c);
if (id != -1)
{
CCharBitmap bmp;
bmp.X= curLineSize;
bmp.Y= lineNb;
bmp.Id= id;
_CharBitmaps.push_back(bmp);
}
curLineSize += w;
++xChar;
}
if (!_SheetText)
_SheetText = createViewText("opt", 8);
if (lineNb == maxLine) lineNb = maxLine-1;
_SheetText->setX(0);
for (i = 0; i < _CharBitmaps.size(); ++i)
{
_CharBitmaps[i].Y = (lineNb - _CharBitmaps[i].Y)*h;
}
// if topDown, revert Y
if (topDown)
{
_SheetText->setY(_IconH);
_SheetText->setPosRef(Hotspot_TL);
for (i = 0; i < _CharBitmaps.size(); ++i)
{
_CharBitmaps[i].Y = _IconH - _CharBitmaps[i].Y - h;
}
}
else
_SheetText->setPosRef(Hotspot_BL);
_SheetText->setActive(true);
ucstring txt;
txt.fromUtf8(_OptString);
_SheetText->setText(txt);
_SheetText->setLineMaxW(maxW);
_SheetText->setMultiLine(maxLine > 1);
_SheetText->updateTextContext();
}
// ***************************************************************************
void CDBCtrlSheet::displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, CRGBA color)
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance();
if (_SheetText)
for (uint i = 0; i < _CharBitmaps.size(); ++i)
{
sint32 ClipX, ClipY, ClipW, ClipH;
rVR.getClipWindow (ClipX, ClipY, ClipW, ClipH);
// clip region is bbox from parent
if (isIn(ClipX, ClipY, ClipW, ClipH))
{
// position text over icon
sint32 sx = x + _SheetText->getX();
sint32 sy = y + _SheetText->getY();
if (_SheetText->getPosRef() & Hotspot_Tx)
sy -= _SheetText->getHReal();
_SheetText->setRenderLayer(rdrLayer);
_SheetText->setXReal(sx);
_SheetText->setYReal(sy);
_SheetText->setColor(color);
// set clip area over icon to hide oversize text
rVR.setClipWindow(sx, sy, _WReal-2, _HReal-2);
_SheetText->draw();
rVR.setClipWindow (ClipX, ClipY, ClipW, ClipH);
}
rVR.draw11RotFlipBitmap (rdrLayer, x+_CharBitmaps[i].X, y+_CharBitmaps[i].Y, 0, false,
_CharBitmaps[i].Id, color);
}
}
// ***************************************************************************
void CDBCtrlSheet::draw()
{
@ -2199,7 +2128,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
if (_DispQuality != -1)
{
// For pact sheets, the quality gives the level of the sheet
drawQuality(x+1, y+1, wSheet, hSheet, numberColor, _DispQuality+1);
drawNumber(x+1, y+1, wSheet, hSheet, numberColor, _DispQuality+1);
}
break;
case CCtrlSheetInfo::SheetType_Skill:
@ -2254,7 +2183,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
// Draw Quality. -1 for lookandfeel. Draw it with global color
if (_DispQuality != -1)
{
drawQuality(x-1,y+1, wSheet, hSheet, numberColor, _DispQuality);
drawNumber(x-1,y+1,wSheet, hSheet, numberColor, _DispQuality);
}
// Draw Quantity
if (_UseQuantity && _DispQuantity>-1)
@ -2271,7 +2200,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
{
quantity -= getLockValuePtr()->getValue32();
}
drawQuantity(x+1+crossW, y+1, wSheet, hSheet, curSheetColor, quantity);
drawNumber(x+1+crossW, y+1, wSheet, hSheet, curSheetColor, quantity, false);
}
// Is the item enchanted ?
sint32 enchant = _Enchant.getSInt32();
@ -2280,7 +2209,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
// Yes draw the additionnal bitmap and the charge (number of enchanted spell we can launch with the enchanted item)
enchant--;
rVR.draw11RotFlipBitmap (_RenderLayer+2, x, y, 0, false, rVR.getSystemTextureId(CViewRenderer::ItemEnchantedTexture), curSheetColor);
drawSap(x+1, y+1, wSheet, hSheet, numberColor, enchant);
drawNumber(x+1, y-2+hSheet-rVR.getFigurTextureH(), wSheet, hSheet, numberColor, enchant, false);
}
// if a raw material for example, must add special icon text.
@ -2543,10 +2472,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
// Draw Quality. -1 for lookandfeel.
if( _ActualType == CCtrlSheetInfo::SheetType_SBrick )
{
if (_UseQuality && _MustDisplayLevel)
{
drawQuality(px-1, py+1, BrickSheetWidth, BrickSheetHeight, curSheetColor, _DispLevel);
}
if (_UseQuality && _MustDisplayLevel) drawNumber(px-1,py+1,BrickSheetWidth, BrickSheetHeight, curSheetColor, _DispLevel);
}
else
{
@ -2614,63 +2540,51 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
}
// ----------------------------------------------------------------------------
sint32 CDBCtrlSheet::drawQuality(sint32 x, sint32 y, sint32 wSheet, sint32 /* hSheet */, CRGBA color, sint32 value)
sint32 CDBCtrlSheet::drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 /* hSheet */, CRGBA color, sint32 value, bool rightAlign)
{
if (!_QualityText)
_QualityText = createViewText("quality", 7);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 wDigit= rVR.getFigurTextureW();
sint32 hDigit= rVR.getFigurTextureH();
if (_QualityTextValue != value)
{
_QualityText->setText(toString(value));
_QualityText->updateTextContext();
_QualityTextValue = value;
}
_QualityText->setActive(true);
_QualityText->setRenderLayer(_RenderLayer + 2);
_QualityText->setXReal(x + wSheet - _QualityText->getW());
_QualityText->setYReal(y);
_QualityText->setColor(color);
_QualityText->draw();
}
sint32 totalWidth = 0;
// ----------------------------------------------------------------------------
sint32 CDBCtrlSheet::drawQuantity(sint32 x, sint32 y, sint32 wSheet, sint32 /* hSheet */, CRGBA color, sint32 value)
if (value > -1)
{
if (!_QuantityText)
_QuantityText = createViewText(getId() + ":quantity", 7);
if (_QuantityTextValue != value)
// compute start pos
sint32 units = value;
sint32 pos;
if(rightAlign)
pos= wSheet-wDigit;
else
{
_QuantityText->setText(toString(value));
_QuantityText->updateTextContext();
_QuantityTextValue = value;
// compute number of digits to display
pos= 0;
uint numDigits= 0;
do
{
units = units / 10;
numDigits++;
}
_QuantityText->setActive(true);
_QuantityText->setRenderLayer(_RenderLayer + 2);
_QuantityText->setXReal(x);
_QuantityText->setYReal(y);
_QuantityText->setColor(color);
_QuantityText->draw();
while (units != 0);
// so pos is:
pos= numDigits*wDigit - wDigit;
}
// ----------------------------------------------------------------------------
sint32 CDBCtrlSheet::drawSap(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, CRGBA color, sint32 value)
// display digits
units = value;
do
{
if (!_SapText)
_SapText = createViewText(getId() + ":sap", 8);
if (_SapTextValue != value)
{
_SapText->setText(toString(value));
_SapText->updateTextContext();
_SapTextValue = value;
sint32 unitsID = rVR.getFigurTextureId (units % 10);
// decal layer because must drawn after Items/Brick in DXTC
rVR.drawRotFlipBitmap (_RenderLayer+2, x+pos, y, wDigit, hDigit, 0, false, unitsID, color);
units = units / 10;
pos-= wDigit;
totalWidth += wDigit;
}
_SapText->setActive(true);
_SapText->setRenderLayer(_RenderLayer + 2);
_SapText->setXReal(x);
_SapText->setYReal(y + hSheet - _SapText->getH());
_SapText->setColor(color);
_SapText->draw();
while (units != 0);
return totalWidth;
}
return -1;
}
// ----------------------------------------------------------------------------

View file

@ -27,7 +27,6 @@
#include "nel/gui/ctrl_draggable.h"
#include "nel/gui/interface_expr.h"
#include "nel/gui/action_handler.h"
#include "nel/gui/view_text.h"
#include "sphrase_manager.h"
// game share
#include "game_share/brick_types.h"
@ -51,7 +50,6 @@ class COutpostBuildingSheet;
namespace NLGUI
{
class CViewRenderer;
class CViewText;
}
@ -591,10 +589,8 @@ protected:
// setup icon from phrases
void setupDisplayAsPhrase(const std::vector<NLMISC::CSheetId> &bricks, const ucstring &phraseName);
//
sint32 drawQuality(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value);
sint32 drawQuantity(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value);
sint32 drawSap(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value);
// draw a number and returns the width of the drawn number
sint32 drawNumber(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, NLMISC::CRGBA color, sint32 value, bool rightAlign=true);
protected:
@ -707,15 +703,13 @@ protected:
NLMISC::CCDBNodeLeaf *_GrayedLink;
//
CViewText *_SheetText;
CViewText *_QualityText;
CViewText *_QuantityText;
CViewText *_SapText;
// cached values for faster comparing
sint32 _QualityTextValue;
sint32 _QuantityTextValue;
sint32 _SapTextValue;
// Macro or sentence String compiled as texture Ids and positions, from the _OptString.
struct CCharBitmap
{
sint32 X,Y;
sint32 Id;
};
std::vector<CCharBitmap> _CharBitmaps;
// Macro Id
sint32 _MacroID;
@ -759,8 +753,6 @@ private:
void resetAllTexIDs();
void setupInit();
CViewText *createViewText(const std::string &id, sint fontSize);
void setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar= 1000, bool topDown= false);
void resetCharBitmaps();
void displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, NLMISC::CRGBA color);