Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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 @@ -5,7 +5,7 @@
import lombok.Getter;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Widget;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand Down Expand Up @@ -38,7 +38,7 @@
import slimeknights.tconstruct.library.utils.TinkerTooltipFlags;
import slimeknights.tconstruct.tables.block.entity.table.TinkerStationBlockEntity;
import slimeknights.tconstruct.tables.client.inventory.module.InfoPanelScreen;
import slimeknights.tconstruct.tables.client.inventory.module.TinkerStationButtonsScreen;
import slimeknights.tconstruct.tables.client.inventory.widget.TinkerStationButtonsWidget;
import slimeknights.tconstruct.tables.client.inventory.widget.SlotButtonItem;
import slimeknights.tconstruct.tables.menu.TinkerStationContainerMenu;
import slimeknights.tconstruct.tables.menu.slot.TinkerStationSlot;
Expand Down Expand Up @@ -108,14 +108,14 @@ public class TinkerStationScreen extends BaseTabbedScreen<TinkerStationBlockEnti
@Nonnull @Getter
private final StationSlotLayout defaultLayout;
/** Currently selected tool */
@Nonnull
@Nonnull @Getter
private StationSlotLayout currentLayout;

// components
//protected TextFieldWidget textField;
protected InfoPanelScreen tinkerInfo;
protected InfoPanelScreen modifierInfo;
protected TinkerStationButtonsScreen buttonsScreen;
protected TinkerStationButtonsWidget buttonsScreen;

/** Maximum available slots */
@Getter
Expand All @@ -126,9 +126,6 @@ public class TinkerStationScreen extends BaseTabbedScreen<TinkerStationBlockEnti
public TinkerStationScreen(TinkerStationContainerMenu container, Inventory playerInventory, Component title) {
super(container, playerInventory, title);

this.buttonsScreen = new TinkerStationButtonsScreen(this, container, playerInventory, title);
this.addModule(this.buttonsScreen);

this.tinkerInfo = new InfoPanelScreen(this, container, playerInventory, title);
this.tinkerInfo.setTextScale(8/9f);
this.addModule(this.tinkerInfo);
Expand Down Expand Up @@ -182,8 +179,6 @@ public void init() {
//this.textField.setEnableBackgroundDrawing(false);
//this.textField.setMaxStringLength(40);

this.buttonsScreen.xOffset = -2;
this.buttonsScreen.yOffset = this.centerBeam.h + this.buttonDecorationTop.h;
this.tinkerInfo.xOffset = 2;
this.tinkerInfo.yOffset = this.centerBeam.h + this.panelDecorationL.h;
this.modifierInfo.xOffset = this.tinkerInfo.xOffset;
Expand All @@ -194,6 +189,11 @@ public void init() {
}

super.init();

int buttonsStyle = this.maxInputs > 3 ? TinkerStationButtonsWidget.METAL_STYLE : TinkerStationButtonsWidget.WOOD_STYLE;
this.buttonsScreen = new TinkerStationButtonsWidget(this, this.cornerX - TinkerStationButtonsWidget.width(COLUMN_COUNT) - 2,
this.cornerY + this.centerBeam.h + this.buttonDecorationTop.h, buttonsStyle);

this.updateLayout();
}

Expand Down Expand Up @@ -442,13 +442,11 @@ protected void renderBg(PoseStack matrices, float partialTicks, int mouseX, int
this.rightBeam.draw(matrices, x, y);

// draw the decoration for the buttons
for (Widget widget : this.buttonsScreen.getButtons()) {
if (widget instanceof SlotButtonItem button) {
this.buttonDecorationTop.draw(matrices, button.x, button.y - this.buttonDecorationTop.h);
// don't draw the bottom for the buttons in the last row
if (button.buttonId < this.buttonsScreen.getButtons().size() - COLUMN_COUNT) {
this.buttonDecorationBot.draw(matrices, button.x, button.y + button.getHeight());
}
for (SlotButtonItem button : this.buttonsScreen.getButtons()) {
this.buttonDecorationTop.draw(matrices, button.x, button.y - this.buttonDecorationTop.h);
// don't draw the bottom for the buttons in the last row
if (button.buttonId < this.buttonsScreen.getButtons().size() - COLUMN_COUNT) {
this.buttonDecorationBot.draw(matrices, button.x, button.y + button.getHeight());
}
}

Expand All @@ -473,6 +471,8 @@ protected void renderBg(PoseStack matrices, float partialTicks, int mouseX, int
RenderSystem.enableDepthTest();

super.renderBg(matrices, partialTicks, mouseX, mouseY);

this.buttonsScreen.render(matrices, mouseX, mouseY, partialTicks);
}

@Override
Expand Down Expand Up @@ -633,8 +633,6 @@ protected void wood() {
this.panelDecorationL = PANEL_SPACE_LEFT.shift(18, 0);
this.panelDecorationR = PANEL_SPACE_RIGHT.shift(18, 0);

this.buttonsScreen.shiftStyle(TinkerStationButtonsScreen.WOOD_STYLE);

this.leftBeam = LEFT_BEAM;
this.rightBeam = RIGHT_BEAM;
this.centerBeam = CENTER_BEAM;
Expand All @@ -649,8 +647,6 @@ protected void metal() {
this.panelDecorationL = PANEL_SPACE_LEFT.shift(18 * 2, 0);
this.panelDecorationR = PANEL_SPACE_RIGHT.shift(18 * 2, 0);

this.buttonsScreen.shiftStyle(TinkerStationButtonsScreen.METAL_STYLE);

this.leftBeam = LEFT_BEAM.shift(0, LEFT_BEAM.h);
this.rightBeam = RIGHT_BEAM.shift(0, RIGHT_BEAM.h);
this.centerBeam = CENTER_BEAM.shift(0, CENTER_BEAM.h);
Expand Down Expand Up @@ -685,4 +681,17 @@ public void onToolSelection(StationSlotLayout layout) {
// this.container.setToolSelection(layout); TODO: needed?
TinkerNetwork.getInstance().sendToServer(new TinkerStationSelectionPacket(layout.getName()));
}

@Override
public List<Rect2i> getModuleAreas() {
List<Rect2i> list = super.getModuleAreas();
list.add(this.buttonsScreen.getArea());
return list;
}

@Override
protected boolean hasClickedOutside(double mouseX, double mouseY, int guiLeft, int guiTop, int mouseButton) {
return super.hasClickedOutside(mouseX, mouseY, guiLeft, guiTop, mouseButton)
&& !this.buttonsScreen.isMouseOver(mouseX, mouseY);
}
}

This file was deleted.

This file was deleted.

Loading