-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ExtraUtilities.ui; | ||
|
||
import arc.scene.ui.layout.Table; | ||
import arc.util.Strings; | ||
import mindustry.type.Item; | ||
import mindustry.type.ItemStack; | ||
import mindustry.ui.Styles; | ||
import mindustry.world.meta.StatUnit; | ||
|
||
public class ItemDisplay extends Table { | ||
public final Item item; | ||
public final int amount; | ||
|
||
public ItemDisplay(Item item){ | ||
this(item, 0); | ||
} | ||
|
||
public ItemDisplay(Item item, int amount, boolean showName){ | ||
add(new ItemImage(new ItemStack(item, amount))); | ||
if(showName) add(item.localizedName).padLeft(4 + amount > 99 ? 4 : 0); | ||
|
||
this.item = item; | ||
this.amount = amount; | ||
} | ||
|
||
public ItemDisplay(Item item, int amount){ | ||
this(item, amount, true); | ||
} | ||
|
||
/** Displays the item with a "/sec" qualifier based on the time period, in ticks. */ | ||
public ItemDisplay(Item item, int amount, float timePeriod, boolean showName){ | ||
add(new ItemImage(item.uiIcon, amount)); | ||
add((showName ? item.localizedName + "\n" : "") + "[lightgray]" + Strings.autoFixed(amount / (timePeriod / 60f), 2) + StatUnit.perSecond.localized()).padLeft(2).padRight(5).style(Styles.outlineLabel); | ||
|
||
this.item = item; | ||
this.amount = amount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ExtraUtilities.ui; | ||
|
||
import arc.graphics.g2d.TextureRegion; | ||
import arc.scene.ui.Image; | ||
import arc.scene.ui.layout.Stack; | ||
import arc.scene.ui.layout.Table; | ||
import arc.util.Scaling; | ||
import mindustry.core.UI; | ||
import mindustry.type.ItemStack; | ||
import mindustry.type.PayloadStack; | ||
import mindustry.ui.Styles; | ||
|
||
public class ItemImage extends Stack { | ||
|
||
public ItemImage(TextureRegion region, int amount){ | ||
|
||
add(new Table(o -> { | ||
o.left(); | ||
o.add(new Image(region)).size(32f).scaling(Scaling.fit); | ||
})); | ||
|
||
if(amount != 0){ | ||
add(new Table(t -> { | ||
t.left().bottom(); | ||
t.add(amount >= 1000 ? UI.formatAmount(amount) : amount + "").style(Styles.outlineLabel); | ||
t.pack(); | ||
})); | ||
} | ||
} | ||
|
||
public ItemImage(ItemStack stack){ | ||
this(stack.item.uiIcon, stack.amount); | ||
} | ||
|
||
public ItemImage(PayloadStack stack){ | ||
this(stack.item.uiIcon, stack.amount); | ||
} | ||
} |