mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-26 23:12:58 +00:00
Added title localization and inventory slot texture (#81)
This commit is contained in:
1 parent
3968cc320e
commit
1d0568388a
24 files changed
+61
-27
No files matched your search
@@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.minecraft.InventoryType;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.network.packet.MessageCraftGUI;
|
||||
|
||||
public class ControlPlayerInventory extends Control {
|
||||
@@ -24,19 +25,21 @@ public class ControlPlayerInventory extends Control {
|
||||
slots = new ArrayList<>();
|
||||
for (int row = 0; row < 3; ++row) {
|
||||
for (int column = 0; column < 9; ++column) {
|
||||
ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18);
|
||||
ControlSlot slot = new ControlSlot(this, (wide ? 58 : 0) + column * 18, row * 18)
|
||||
.setSlotTexture(CraftGUITexture.SlotInventory);
|
||||
slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
if (wide) {
|
||||
for (int i1 = 0; i1 < 9; ++i1) {
|
||||
ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18);
|
||||
ControlSlot slot2 = new ControlSlot(this, i1 % 3 * 18, i1 / 3 * 18)
|
||||
.setSlotTexture(CraftGUITexture.SlotInventory);
|
||||
slots.add(slot2);
|
||||
}
|
||||
} else {
|
||||
for (int i1 = 0; i1 < 9; ++i1) {
|
||||
ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f);
|
||||
ControlSlot slot2 = new ControlSlot(this, i1 * 18, 58.0f).setSlotTexture(CraftGUITexture.SlotInventory);
|
||||
slots.add(slot2);
|
||||
}
|
||||
}
|
||||
@@ -51,7 +54,8 @@ public class ControlPlayerInventory extends Control {
|
||||
slots = new ArrayList<>();
|
||||
for (int row = 0; row < 6; ++row) {
|
||||
for (int column = 0; column < 6; ++column) {
|
||||
ControlSlot slot = new ControlSlot(this, column * 18, row * 18);
|
||||
ControlSlot slot = new ControlSlot(this, column * 18, row * 18)
|
||||
.setSlotTexture(CraftGUITexture.SlotInventory);
|
||||
slots.add(slot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +49,12 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
public Slot slot;
|
||||
private CraftGUITexture slotTexture;
|
||||
|
||||
public ControlSlot(IWidget parent, float x, float y) {
|
||||
super(parent, x, y);
|
||||
slot = null;
|
||||
slotTexture = CraftGUITexture.Slot;
|
||||
addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
|
||||
@Override
|
||||
@@ -80,11 +82,17 @@ public class ControlSlot extends ControlSlotBase {
|
||||
public ControlSlot(IWidget parent, int x, int y, Slot slot) {
|
||||
super(parent, x, y);
|
||||
this.slot = slot;
|
||||
slotTexture = CraftGUITexture.Slot;
|
||||
}
|
||||
|
||||
public ControlSlot setSlotTexture(CraftGUITexture texture) {
|
||||
slotTexture = texture == null ? CraftGUITexture.Slot : texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.render.texture(CraftGUITexture.Slot, IPoint.ZERO);
|
||||
CraftGUI.render.texture(slotTexture, IPoint.ZERO);
|
||||
if (slot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public enum CraftGUITexture {
|
||||
Button("button"),
|
||||
ButtonHighlighted("button.highlighted"),
|
||||
Slot("slot"),
|
||||
SlotInventory("slot.inventory"),
|
||||
SlotBorder("slot.border"),
|
||||
SlotOverlay("slot.overlay"),
|
||||
SlotCharge("slot.charge"),
|
||||
|
||||
@@ -32,6 +32,11 @@ public abstract class MachinePackage {
|
||||
return I18N.localise(group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID());
|
||||
}
|
||||
|
||||
public String getGuiDisplayName() {
|
||||
String guiKey = group.getMod().getModID() + ".machine." + group.getShortUID() + "." + getUID() + ".title";
|
||||
return I18N.canLocalise(guiKey) ? I18N.localise(guiKey) : getDisplayName();
|
||||
}
|
||||
|
||||
public Integer getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getGuiDisplayName());
|
||||
int x = 16;
|
||||
int y = 32;
|
||||
ComponentCompartmentInventory inv = Machine.getMachine(getInventory())
|
||||
|
||||
@@ -12,7 +12,6 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.network.packet.MessageCraftGUI;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
@@ -35,7 +34,7 @@ public class WindowAlvearyFrame extends Window {
|
||||
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
setTitle(I18N.localise("extrabees.machine.alveay.frame"));
|
||||
setTitle(machine.getPackage().getGuiDisplayName());
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
playerInventory = new ControlPlayerInventory(this).create(actions);
|
||||
new ControlSlot(this, 79.0f, 30.0f).assign(actions, InventoryType.Machine, 0);
|
||||
|
||||
@@ -12,7 +12,6 @@ import binnie.core.craftgui.minecraft.control.ControlSlotArray;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.network.packet.MessageCraftGUI;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extrabees.apiary.machine.hatchery.AlvearyHatchery;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -37,7 +36,7 @@ public class WindowAlvearyHatchery extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
setTitle(I18N.localise("extrabees.machine.alveay.hatchery"));
|
||||
setTitle(machine.getPackage().getGuiDisplayName());
|
||||
playerInventory = new ControlPlayerInventory(this).create(actions);
|
||||
new ControlSlotArray(this, 43, 30, 5, 1).create(actions, InventoryType.Machine, AlvearyHatchery.SLOT_LARVAE);
|
||||
MessageCraftGUI.sendToServer(actions);
|
||||
|
||||
@@ -44,7 +44,7 @@ public class WindowAlvearyMutator extends Window {
|
||||
public void initialiseClient() {
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
|
||||
setTitle(I18N.localise("extrabees.machine.alveay.mutator"));
|
||||
setTitle(machine.getPackage().getGuiDisplayName());
|
||||
playerInventory = new ControlPlayerInventory(this).create(actions);
|
||||
new ControlSlot(this, 79.0f, 30.0f).assign(actions, InventoryType.Machine, AlvearyMutator.SLOT_MUTATOR);
|
||||
new ControlText(
|
||||
|
||||
@@ -14,7 +14,6 @@ import binnie.core.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.network.packet.MessageCraftGUI;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extrabees.apiary.machine.stimulator.AlvearyStimulator;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -39,7 +38,7 @@ public class WindowAlvearyStimulator extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
setTitle(I18N.localise("extrabees.machine.alveay.stimulator"));
|
||||
setTitle(machine.getPackage().getGuiDisplayName());
|
||||
playerInventory = new ControlPlayerInventory(this).create(actions);
|
||||
new ControlSlot(this, 41.0f, 28.0f).assign(actions, InventoryType.Machine, AlvearyStimulator.SLOT_CIRCUIT);
|
||||
new ControlEnergyBar(this, 75, 29, 60, 16, Position.LEFT);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class WindowLumbermill extends Window {
|
||||
public void initialiseClient() {
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getGuiDisplayName());
|
||||
new ControlSlot(this, 42.0f, 43.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_WOOD);
|
||||
new ControlSlot(this, 148.0f, 43.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_PLANKS);
|
||||
new ControlSlot(this, 172.0f, 28.0f).assign(actions, InventoryType.Machine, Lumbermill.SLOT_BARK);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class WindowWoodworker extends Window {
|
||||
public void initialiseClient() {
|
||||
final NBTTagList actions = new NBTTagList();
|
||||
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getDisplayName());
|
||||
setTitle(Machine.getMachine(getInventory()).getPackage().getGuiDisplayName());
|
||||
new ControlText(
|
||||
this,
|
||||
new IArea(190.0f, 36.0f, 114.0f, 10.0f),
|
||||
|
||||
@@ -64,7 +64,7 @@ public class WindowAcclimatiser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.labMachine.acclimatiser");
|
||||
return I18N.localise("gui.genetics.machine.labMachine.acclimatiser.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,7 @@ public class WindowAnalyser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.labMachine.analyser");
|
||||
return I18N.localise("gui.genetics.machine.labMachine.analyser.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WindowGenepool extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.labMachine.genepool");
|
||||
return I18N.localise("gui.genetics.machine.labMachine.genepool.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class WindowIncubator extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.labMachine.incubator");
|
||||
return I18N.localise("gui.genetics.machine.labMachine.incubator.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -89,7 +89,7 @@ public class WindowInoculator extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.machine.inoculator");
|
||||
return I18N.localise("gui.genetics.machine.machine.inoculator.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,7 +76,7 @@ public class WindowIsolator extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.machine.isolator");
|
||||
return I18N.localise("gui.genetics.machine.machine.isolator.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -75,7 +75,7 @@ public class WindowPolymeriser extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.machine.polymeriser");
|
||||
return I18N.localise("gui.genetics.machine.machine.polymeriser.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -104,7 +104,7 @@ public class WindowSequencer extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.machine.sequencer");
|
||||
return I18N.localise("gui.genetics.machine.machine.sequencer.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -83,7 +83,7 @@ public class WindowSplicer extends WindowMachine {
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18N.localise("genetics.machine.advMachine.splicer");
|
||||
return I18N.localise("gui.genetics.machine.advMachine.splicer.title");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -123,12 +123,12 @@ public class WindowAnalyst extends Window {
|
||||
public void initialiseClient() {
|
||||
if (isDatabase) {
|
||||
if (isMaster) {
|
||||
setTitle(I18N.localise("genetics.item.registry.1.name"));
|
||||
setTitle(I18N.localise("genetics.gui.registry.1.title"));
|
||||
} else {
|
||||
setTitle(I18N.localise("genetics.item.registry.0.name"));
|
||||
setTitle(I18N.localise("genetics.gui.registry.title"));
|
||||
}
|
||||
} else {
|
||||
setTitle(I18N.localise("genetics.item.analyst.name"));
|
||||
setTitle(I18N.localise("genetics.gui.analyst.title"));
|
||||
}
|
||||
|
||||
getWindowInventory().createSlot(0);
|
||||
|
||||
Reference in new issue
Block a user