Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import com.cleanroommc.modularui.widgets.SlotGroupWidget;
import com.cleanroommc.modularui.widgets.TextWidget;
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Column;
import com.cleanroommc.modularui.widgets.layout.Flow;
import com.cleanroommc.modularui.widgets.layout.Row;
import com.cleanroommc.modularui.widgets.slot.ItemSlot;
import com.cleanroommc.modularui.widgets.slot.ModularSlot;
import com.cubefury.vendingmachine.VMConfig;
Expand Down Expand Up @@ -146,7 +144,8 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe
}
});
panel.child(createCategoryTabs(this.tabController));
Flow mainColumn = new Column().width(170);
Flow mainColumn = Flow.column()
.width(170);
if (VendingMachine.proxy.isClient()) { // client side sort and filtering
panel.child(createQolButtonColumn());
mainColumn.child(
Expand All @@ -161,7 +160,8 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe
mainColumn.child(createInventoryRow());
panel.child(mainColumn);
panel.child(
new Column().size(20)
Flow.column()
.size(20)
.right(5));
panel.child(createIOColumn());
return panel;
Expand All @@ -175,7 +175,8 @@ public void restorePreviousSettings() {
}

public IWidget createQolButtonColumn() {
Flow buttonColumn = new Column().width(8)
Flow buttonColumn = Flow.column()
.width(8)
.height(20)
.left(-17)
.top(1)
Expand Down Expand Up @@ -221,7 +222,8 @@ public IWidget createQolButtonColumn() {
}

public IWidget createCategoryTabs(PagedWidget.Controller tabController) {
Flow tabColumn = new Column().width(40)
Flow tabColumn = Flow.column()
.width(40)
.height(300)
.left(-29)
.top(40)
Expand Down Expand Up @@ -361,22 +363,29 @@ private IWidget createIOColumn() {
.top(40)
.widgetTheme(WidgetThemes.BACKGROUND_SIDEPANEL)
.child(
new Column().child(
GuiTextures.INPUT_SPRITE.asWidget()
.leftRel(0.5f)
.top(8)
.width(30)
.height(20))
Flow.column()
.child(
new Row().child(createInputSlots().center())
GuiTextures.INPUT_SPRITE.asWidget()
.leftRel(0.5f)
.top(8)
.width(30)
.height(20))
.child(
(IWidget) new TextWidget(IKey.lang("vendingmachine.gui.in")).textAlign(Alignment.CENTER)
.top(8)
.widthRel(1.0f))
.child(
Flow.row()
.child(createInputSlots().center())
.top(20)
.height(18 * 4))
.child(
new Row().child(
new ToggleButton().overlay(GTGuiTextures.OVERLAY_BUTTON_CYCLIC)
.tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.item_eject")))
.syncHandler("ejectItems")
.right(6))
Flow.row()
.child(
new ToggleButton().overlay(GTGuiTextures.OVERLAY_BUTTON_CYCLIC)
.tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.item_eject")))
.syncHandler("ejectItems")
.right(6))
.child(
new ToggleButton().overlay(
GuiTextures.EJECT_COINS.asIcon()
Expand All @@ -389,11 +398,16 @@ private IWidget createIOColumn() {
.child(
GuiTextures.OUTPUT_SPRITE.asWidget()
.leftRel(0.5f)
.bottom(70)
.bottom(73)
.width(30)
.height(20))
.child(
new Row().child(createOutputSlots().center())
(IWidget) new TextWidget(IKey.lang("vendingmachine.gui.out")).textAlign(Alignment.CENTER)
.bottom(81)
.widthRel(1.0f))
.child(
Flow.row()
.child(createOutputSlots().center())
.bottom(6)
.height(18 * 4))
.right(1));
Expand Down Expand Up @@ -538,10 +552,10 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
.height(144)
.collapseDisabledChild(true);

tradeList.child(new Row().height(2));
tradeList.child(Flow.row().height(2));

// Incomplete Structure status message
Flow statusRow = new Row().height(10).width(TRADE_ROW_WIDTH).marginLeft(2)
Flow statusRow = Flow.row().height(10).width(TRADE_ROW_WIDTH).marginLeft(2)
.child(new TextWidget(IKey.lang("vendingmachine.gui.error.incomplete_structure")))
.setEnabledIf(slot -> !this.getBase().getActive());
tradeList.child(statusRow);
Expand Down Expand Up @@ -607,11 +621,11 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t
row = new TradeRow().height(LIST_ITEM_HEIGHT).width(TRADE_ROW_WIDTH).marginLeft(2);
}

tradeList.child(new Row().height(2)); // bottom padding for last row
tradeList.child(Flow.row().height(2)); // bottom padding for last row
paged.addPage(tradeList);
}

return new Row().child(paged.top(0))
return Flow.row().child(paged.top(0))
.left(3)
.top(24);
}
Expand All @@ -628,19 +642,21 @@ private static String getReadableStringFromCoinAmount(int amount) {
}

private IWidget createCoinInventoryRow(TradeMainPanel panel, PanelSyncManager syncManager) {
Flow parent = new Row() // .background(GuiTextures.TEXT_FIELD_BACKGROUND)
Flow parent = Flow.row()
.width(162)
.height(36)
.top(172)
.left(3);
Flow coinColumn = new Column().width(COIN_COLUMN_WIDTH);
Flow coinColumn = Flow.column()
.width(COIN_COLUMN_WIDTH);
int coinCount = 0;

for (CurrencyType type : CurrencyType.values()) {
coinColumn.child(createCoinDisplay(panel, type, syncManager));
if (++coinCount % COIN_COLUMN_ROW_COUNT == 0) {
parent.child(coinColumn.left(3 + COIN_COLUMN_WIDTH * (coinCount / COIN_COLUMN_ROW_COUNT - 1)));
coinColumn = new Column().width(COIN_COLUMN_WIDTH);
coinColumn = Flow.column()
.width(COIN_COLUMN_WIDTH);
}
}
if (coinColumn.hasChildren()) {
Expand All @@ -651,22 +667,23 @@ private IWidget createCoinInventoryRow(TradeMainPanel panel, PanelSyncManager sy

private IWidget createCoinDisplay(TradeMainPanel panel, CurrencyType type, PanelSyncManager syncManager) {
IntSyncValue coinSyncValue = syncManager.findSyncHandler("coinAmount_" + type.id, 0, IntSyncValue.class);
return new Row().child(
new CoinButton(panel, type).overlay(
type.texture.asIcon()
.size(12))
.size(12)
.left(0)
.syncHandler("ejectCoin_" + type.id)
.tooltipDynamic((builder) -> {
builder.clearText();
builder.addLine(coinSyncValue.getValue() + " " + type.getLocalizedName());
builder.emptyLine();
builder.addLine(
IKey.str(Translator.translate("vendingmachine.gui.single_coin_type_eject_hint"))
.style(IKey.GRAY, IKey.ITALIC));
builder.setAutoUpdate(true);
}))
return Flow.row()
.child(
new CoinButton(panel, type).overlay(
type.texture.asIcon()
.size(12))
.size(12)
.left(0)
.syncHandler("ejectCoin_" + type.id)
.tooltipDynamic((builder) -> {
builder.clearText();
builder.addLine(coinSyncValue.getValue() + " " + type.getLocalizedName());
builder.emptyLine();
builder.addLine(
IKey.str(Translator.translate("vendingmachine.gui.single_coin_type_eject_hint"))
.style(IKey.GRAY, IKey.ITALIC));
builder.setAutoUpdate(true);
}))
.child(
IKey.dynamic(() -> getReadableStringFromCoinAmount(coinSyncValue.getValue()))
.scale(0.8f)
Expand All @@ -679,9 +696,11 @@ private IWidget createCoinDisplay(TradeMainPanel panel, CurrencyType type, Panel

// why is the original method private lmao
private IWidget createInventoryRow() {
return new Row().widthRel(1)
return Flow.row()
.widthRel(1)
.height(76)
.alignX(0)
.leftRel(0)
.anchorLeft(0)
.bottom(5)
.childIf(
base.doesBindPlayerInventory(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.cubefury.vendingmachine.blocks.gui;

import com.cleanroommc.modularui.api.GuiAxis;
import com.cleanroommc.modularui.api.widget.IWidget;
import com.cleanroommc.modularui.widgets.layout.Row;
import com.cleanroommc.modularui.widgets.layout.Flow;

public class TradeRow extends Row {
public class TradeRow extends Flow {

public TradeRow() {
super();
super(GuiAxis.X);
this.collapseDisabledChild(true)
.setEnabledIf(
r -> r.getChildren()
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/vendingmachine/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ vendingmachine.gui.cooldown_display.second=s
vendingmachine.gui.cooldown_display.minute=m
vendingmachine.gui.cooldown_display.hour=h
vendingmachine.gui.cooldown_display.day=d
vendingmachine.gui.in=IN
vendingmachine.gui.out=OUT

vendingmachine.gui.error.incomplete_structure=Incomplete Structure.
vendingmachine.gui.error.player_using=Someone is using the vending machine at the moment.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading