mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-11 13:15:38 +02:00
vcmi: allow set font size on component
Now it is possible to set arbitrary font size for CComponent. So, let's use it
This commit is contained in:
parent
716dd9a43b
commit
8a05f5bed7
@ -33,22 +33,22 @@
|
||||
#include "../../lib/NetPacksBase.h"
|
||||
#include "../../lib/CArtHandler.h"
|
||||
|
||||
CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize)
|
||||
: perDay(false)
|
||||
CComponent::CComponent(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font):
|
||||
perDay(false)
|
||||
{
|
||||
init(Type, Subtype, Val, imageSize);
|
||||
init(Type, Subtype, Val, imageSize, font);
|
||||
}
|
||||
|
||||
CComponent::CComponent(const Component & c, ESize imageSize)
|
||||
CComponent::CComponent(const Component & c, ESize imageSize, EFonts font)
|
||||
: perDay(false)
|
||||
{
|
||||
if(c.id == Component::RESOURCE && c.when==-1)
|
||||
perDay = true;
|
||||
|
||||
init((Etype)c.id, c.subtype, c.val, imageSize);
|
||||
init((Etype)c.id, c.subtype, c.val, imageSize, font);
|
||||
}
|
||||
|
||||
void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
|
||||
void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts fnt)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
||||
@ -58,6 +58,7 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
|
||||
subtype = Subtype;
|
||||
val = Val;
|
||||
size = imageSize;
|
||||
font = fnt;
|
||||
|
||||
assert(compType < typeInvalid);
|
||||
assert(size < sizeInvalid);
|
||||
@ -67,13 +68,14 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
|
||||
pos.w = image->pos.w;
|
||||
pos.h = image->pos.h;
|
||||
|
||||
EFonts font = FONT_SMALL;
|
||||
if (imageSize < small)
|
||||
font = FONT_TINY; //other sizes?
|
||||
font = FONT_TINY; //for tiny images - tiny font
|
||||
|
||||
pos.h += 4; //distance between text and image
|
||||
|
||||
auto max = 80;
|
||||
if (size < large)
|
||||
max = 60;
|
||||
if (size < medium)
|
||||
max = 40;
|
||||
if (size < small)
|
||||
|
@ -47,13 +47,14 @@ private:
|
||||
void setSurface(std::string defName, int imgPos);
|
||||
std::string getSubtitleInternal();
|
||||
|
||||
void init(Etype Type, int Subtype, int Val, ESize imageSize);
|
||||
void init(Etype Type, int Subtype, int Val, ESize imageSize, EFonts font = FONT_SMALL);
|
||||
|
||||
public:
|
||||
std::shared_ptr<CAnimImage> image;
|
||||
|
||||
Etype compType; //component type
|
||||
ESize size; //component size.
|
||||
EFonts font; //Font size of label
|
||||
int subtype; //type-dependant subtype. See getSomething methods for details
|
||||
int val; // value \ strength \ amount of component. See getSomething methods for details
|
||||
bool perDay; // add "per day" text to subtitle
|
||||
@ -61,8 +62,8 @@ public:
|
||||
std::string getDescription();
|
||||
std::string getSubtitle();
|
||||
|
||||
CComponent(Etype Type, int Subtype, int Val = 0, ESize imageSize=large);
|
||||
CComponent(const Component &c, ESize imageSize=large);
|
||||
CComponent(Etype Type, int Subtype, int Val = 0, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||
CComponent(const Component &c, ESize imageSize=large, EFonts font = FONT_SMALL);
|
||||
|
||||
void clickRight(tribool down, bool previousState) override; //call-in
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user