Backed out changeset: da24b99ddf3d

--HG--
branch : experimental-ui-scaling
Nimetu 8 years ago
parent edf7551884
commit 4c605fcfe0

@ -542,15 +542,6 @@ CCtrlDraggable(param)
_ItemRMClassType= NULL; _ItemRMClassType= NULL;
_ItemRMFaberStatType= NULL; _ItemRMFaberStatType= NULL;
_NotifyAnimEndTime = 0; _NotifyAnimEndTime = 0;
_SheetText = NULL;
_QualityText = NULL;
_QuantityText = NULL;
_SapText = NULL;
_QualityTextValue = -1;
_QuantityTextValue = -1;
_SapTextValue = -1;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -571,30 +562,6 @@ CDBCtrlSheet::~CDBCtrlSheet()
_GuildSymb = NULL; _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 // ensure erase static
if(this==_CurrMenuSheet) _CurrMenuSheet = NULL; if(this==_CurrMenuSheet) _CurrMenuSheet = NULL;
if(this == dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) ) if(this == dynamic_cast< CDBCtrlSheet* >( CCtrlDraggable::getDraggedSheet() ) )
@ -1053,19 +1020,6 @@ void CDBCtrlSheet::updateCoords ()
} }
} }
CInterfaceElement::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() void CDBCtrlSheet::resetCharBitmaps()
{ {
if (_SheetText) _CharBitmaps.clear();
_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;
} }
// *************************************************************************** // ***************************************************************************
void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown) void CDBCtrlSheet::setupCharBitmaps(sint32 maxW, sint32 maxLine, sint32 maxWChar, bool topDown)
{ {
// Use the optString for the Macro name // Use the optString for the Macro name
_OptString = toLower(_OptString);
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
_CharBitmaps.clear();
if(maxLine<=0) if(maxLine<=0)
{
if (_SheetText)
_SheetText->setActive(false);
return; return;
}
if (!_SheetText) uint h = rVR.getTypoTextureH('a');
_SheetText = createViewText("opt", 8); sint lineNb = 0;
sint curLineSize = 0;
_SheetText->setX(0); uint i;
if (topDown) 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)
{ {
_SheetText->setY(_IconH); lineNb ++;
_SheetText->setPosRef(Hotspot_TL); 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;
} }
else
_SheetText->setPosRef(Hotspot_BL);
_SheetText->setActive(true); if (lineNb == maxLine) lineNb = maxLine-1;
ucstring txt; for (i = 0; i < _CharBitmaps.size(); ++i)
txt.fromUtf8(_OptString); {
_SheetText->setText(txt); _CharBitmaps[i].Y = (lineNb - _CharBitmaps[i].Y)*h;
_SheetText->setLineMaxW(maxW); }
_SheetText->setMultiLine(maxLine > 1);
_SheetText->updateTextContext(); // if topDown, revert Y
if (topDown)
{
for (i = 0; i < _CharBitmaps.size(); ++i)
{
_CharBitmaps[i].Y = _IconH - _CharBitmaps[i].Y - h;
}
}
} }
// *************************************************************************** // ***************************************************************************
void CDBCtrlSheet::displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, CRGBA color) void CDBCtrlSheet::displayCharBitmaps(sint32 rdrLayer, sint32 x, sint32 y, CRGBA color)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
if (_SheetText) for (uint i = 0; i < _CharBitmaps.size(); ++i)
{ {
sint32 ClipX, ClipY, ClipW, ClipH; rVR.draw11RotFlipBitmap (rdrLayer, x+_CharBitmaps[i].X, y+_CharBitmaps[i].Y, 0, false,
rVR.getClipWindow (ClipX, ClipY, ClipW, ClipH); _CharBitmaps[i].Id, color);
// 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);
}
} }
} }
// *************************************************************************** // ***************************************************************************
void CDBCtrlSheet::draw() void CDBCtrlSheet::draw()
{ {
@ -2199,7 +2128,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
if (_DispQuality != -1) if (_DispQuality != -1)
{ {
// For pact sheets, the quality gives the level of the sheet // 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; break;
case CCtrlSheetInfo::SheetType_Skill: 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 // Draw Quality. -1 for lookandfeel. Draw it with global color
if (_DispQuality != -1) if (_DispQuality != -1)
{ {
drawQuality(x-1,y+1, wSheet, hSheet, numberColor, _DispQuality); drawNumber(x-1,y+1,wSheet, hSheet, numberColor, _DispQuality);
} }
// Draw Quantity // Draw Quantity
if (_UseQuantity && _DispQuantity>-1) if (_UseQuantity && _DispQuantity>-1)
@ -2271,7 +2200,7 @@ void CDBCtrlSheet::drawSheet (sint32 x, sint32 y, bool draging, bool showSelecti
{ {
quantity -= getLockValuePtr()->getValue32(); 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 ? // Is the item enchanted ?
sint32 enchant = _Enchant.getSInt32(); 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) // Yes draw the additionnal bitmap and the charge (number of enchanted spell we can launch with the enchanted item)
enchant--; enchant--;
rVR.draw11RotFlipBitmap (_RenderLayer+2, x, y, 0, false, rVR.getSystemTextureId(CViewRenderer::ItemEnchantedTexture), curSheetColor); 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. // 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. // Draw Quality. -1 for lookandfeel.
if( _ActualType == CCtrlSheetInfo::SheetType_SBrick ) if( _ActualType == CCtrlSheetInfo::SheetType_SBrick )
{ {
if (_UseQuality && _MustDisplayLevel) if (_UseQuality && _MustDisplayLevel) drawNumber(px-1,py+1,BrickSheetWidth, BrickSheetHeight, curSheetColor, _DispLevel);
{
drawQuality(px-1, py+1, BrickSheetWidth, BrickSheetHeight, curSheetColor, _DispLevel);
}
} }
else 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) CInterfaceManager *pIM = CInterfaceManager::getInstance();
_QualityText = createViewText("quality", 7); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 wDigit= rVR.getFigurTextureW();
if (_QualityTextValue != value) sint32 hDigit= rVR.getFigurTextureH();
{
_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 (!_QuantityText)
_QuantityText = createViewText(getId() + ":quantity", 7);
if (_QuantityTextValue != value) if (value > -1)
{
// compute start pos
sint32 units = value;
sint32 pos;
if(rightAlign)
pos= wSheet-wDigit;
else
{
// compute number of digits to display
pos= 0;
uint numDigits= 0;
do
{ {
_QuantityText->setText(toString(value)); units = units / 10;
_QuantityText->updateTextContext(); numDigits++;
_QuantityTextValue = value;
} }
_QuantityText->setActive(true); while (units != 0);
_QuantityText->setRenderLayer(_RenderLayer + 2); // so pos is:
_QuantityText->setXReal(x); pos= numDigits*wDigit - wDigit;
_QuantityText->setYReal(y); }
_QuantityText->setColor(color); // display digits
_QuantityText->draw(); units = value;
} do
// ----------------------------------------------------------------------------
sint32 CDBCtrlSheet::drawSap(sint32 x, sint32 y, sint32 wSheet, sint32 hSheet, CRGBA color, sint32 value)
{
if (!_SapText)
_SapText = createViewText(getId() + ":sap", 8);
if (_SapTextValue != value)
{ {
_SapText->setText(toString(value)); sint32 unitsID = rVR.getFigurTextureId (units % 10);
_SapText->updateTextContext(); // decal layer because must drawn after Items/Brick in DXTC
_SapTextValue = value; rVR.drawRotFlipBitmap (_RenderLayer+2, x+pos, y, wDigit, hDigit, 0, false, unitsID, color);
units = units / 10;
pos-= wDigit;
totalWidth += wDigit;
}
while (units != 0);
return totalWidth;
} }
_SapText->setActive(true); return -1;
_SapText->setRenderLayer(_RenderLayer + 2);
_SapText->setXReal(x);
_SapText->setYReal(y + hSheet - _SapText->getH());
_SapText->setColor(color);
_SapText->draw();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

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

Loading…
Cancel
Save