Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion EasyUI/Components/Icon.as
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ interface Icon : Stack
void SetFrameDim(uint width, uint height);
Vec2f getFrameDim();

void SetTeam(uint team);
uint getTeam();

void SetColor(SColor color);
SColor getColor();

void SetCrop(float top, float right, float bottom, float left);

void SetFixedAspectRatio(bool fixed);
Expand All @@ -22,6 +28,8 @@ class StandardIcon : Icon, StandardStack
private string texture = "";
private uint frameIndex = 0;
private Vec2f frameDim = Vec2f_zero;
private uint team = 0;
private SColor color = color_white;
private float cropTop = 0.0f;
private float cropRight = 0.0f;
private float cropBottom = 0.0f;
Expand Down Expand Up @@ -72,6 +80,34 @@ class StandardIcon : Icon, StandardStack
return frameDim;
}

void SetTeam(uint team)
{
if (this.team == team) return;

this.team = team;

DispatchEvent(Event::Team);
}

uint getTeam()
{
return team;
}

void SetColor(SColor color)
{
if (this.color == color) return;

this.color = color;

DispatchEvent(Event::Color);
}

SColor getColor()
{
return color;
}

void SetCrop(float top, float right, float bottom, float left)
{
if (cropTop == top && cropRight == right && cropBottom == bottom && cropLeft == left) return;
Expand Down Expand Up @@ -176,7 +212,7 @@ class StandardIcon : Icon, StandardStack
Vec2f scale = getScale() * 0.5f;
Vec2f offset = getOffset();

GUI::DrawIcon(texture, frameIndex, frameDim, position + offset, scale.x, scale.y, color_white);
GUI::DrawIcon(texture, frameIndex, frameDim, position + offset, scale.x, scale.y, team, color);
}

StandardStack::Render();
Expand Down
2 changes: 2 additions & 0 deletions EasyUI/Events/Events.as
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum Event
Clickable,
Text,
Font,
Team,
Color,
Wrap,
MaxLines,
Expand All @@ -49,3 +50,4 @@ enum Event
EndDrag,
Scroll,
}

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,28 @@ void SetFrameDim(uint width, uint height);
Vec2f getFrameDim();
```

#### Team

The team number of the icon.

Default: `0`

```angelscript
void SetTeam(uint team);
uint getTeam();
```

#### Color

The color of the icon.

Default: `white`

```angelscript
void SetColor(SColor color);
SColor getColor();
```

#### Crop

The icon can be cropped if it is too small compared to its frame dimensions.
Expand Down Expand Up @@ -654,3 +676,4 @@ Default: `false`
void SetChecked(bool checked);
bool isChecked();
```