mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-26 15:03:14 +00:00
Feature/refactoring (#81)
* Added some localization * Added some localization * Added some localization * Added some localization
This commit is contained in:
1 parent
618b291015
commit
b5a6919f7f
32 files changed
+362
-142
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package binnie.core.craftgui.minecraft.control;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.Tooltip;
|
||||
@@ -14,6 +15,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.machines.inventory.InventorySlot;
|
||||
import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.util.I18N;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
@@ -142,7 +144,7 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
private List<ControlSlot> getControlSlots() {
|
||||
List<ControlSlot> slots = new ArrayList<ControlSlot>();
|
||||
List<ControlSlot> slots = new ArrayList<>();
|
||||
if (getParent() instanceof ControlSlotArray || getParent() instanceof ControlPlayerInventory) {
|
||||
for (IWidget child : getParent().getWidgets()) {
|
||||
slots.add((ControlSlot) child);
|
||||
@@ -166,11 +168,9 @@ public class ControlSlot extends ControlSlotBase {
|
||||
}
|
||||
|
||||
public ControlSlot assign(InventoryType inventory, int index) {
|
||||
if (slot != null) {
|
||||
return this;
|
||||
if (slot == null) {
|
||||
slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
}
|
||||
|
||||
slot = ((Window) getSuperParent()).getContainer().getOrCreateSlot(inventory, index);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -183,22 +183,34 @@ public class ControlSlot extends ControlSlotBase {
|
||||
InventorySlot slot = getInventorySlot();
|
||||
if (getInventorySlot() != null) {
|
||||
tooltip.add(slot.getName());
|
||||
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
|
||||
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.side.insertSide", MachineSide.asString(slot.getInputSides())));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.side.extractSide", MachineSide.asString(slot.getOutputSides())));
|
||||
|
||||
if (slot.isReadOnly()) {
|
||||
tooltip.add("Pickup Only Slot");
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.pickupOnly"));
|
||||
}
|
||||
|
||||
if (slot.getValidator() == null) {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", I18N.localise(BinnieCore.instance, "gui.slot.anyItem")));
|
||||
} else {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", slot.getValidator().getTooltip()));
|
||||
}
|
||||
tooltip.add("Accepts: " + ((slot.getValidator() == null) ? "Any Item" : slot.getValidator().getTooltip()));
|
||||
} else if (this.slot.inventory instanceof WindowInventory) {
|
||||
SlotValidator s = ((WindowInventory) this.slot.inventory).getValidator(this.slot.getSlotIndex());
|
||||
tooltip.add("Accepts: " + ((s == null) ? "Any Item" : s.getTooltip()));
|
||||
if (s == null) {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", I18N.localise(BinnieCore.instance, "gui.slot.anyItem")));
|
||||
} else {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.accepts", s.getTooltip()));
|
||||
}
|
||||
} else if (this.slot.inventory instanceof InventoryPlayer) {
|
||||
tooltip.add("Player Inventory");
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.slot.playerInventory"));
|
||||
}
|
||||
}
|
||||
|
||||
public InventorySlot getInventorySlot() {
|
||||
return (slot instanceof CustomSlot) ? ((CustomSlot) slot).getInventorySlot() : null;
|
||||
return (slot instanceof CustomSlot)
|
||||
? ((CustomSlot) slot).getInventorySlot()
|
||||
: null;
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package binnie.core.craftgui.minecraft.control;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.ITooltip;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -7,6 +8,7 @@ import binnie.core.craftgui.Tooltip;
|
||||
import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ControlUser extends Control implements ITooltip {
|
||||
protected String team;
|
||||
@@ -28,8 +30,9 @@ public class ControlUser extends Control implements ITooltip {
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.setType(Tooltip.Type.User);
|
||||
tooltip.add("Owner");
|
||||
if (username != "") {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.owner"));
|
||||
|
||||
if (!username.isEmpty()) {
|
||||
tooltip.add(username);
|
||||
}
|
||||
tooltip.setMaxWidth(200);
|
||||
|
||||
@@ -1,24 +1,37 @@
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class MachineSide {
|
||||
private static EnumSet<ForgeDirection> All = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
|
||||
public static EnumSet<ForgeDirection> TopAndBottom = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
|
||||
public static EnumSet<ForgeDirection> None = EnumSet.noneOf(ForgeDirection.class);
|
||||
public static EnumSet<ForgeDirection> Top = EnumSet.of(ForgeDirection.UP);
|
||||
public static EnumSet<ForgeDirection> Bottom = EnumSet.of(ForgeDirection.DOWN);
|
||||
public static EnumSet<ForgeDirection> Sides = EnumSet.of(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST);
|
||||
public static final EnumSet<ForgeDirection> TOP_AND_BOTTOM = EnumSet.of(ForgeDirection.UP, ForgeDirection.DOWN);
|
||||
public static final EnumSet<ForgeDirection> NONE = EnumSet.noneOf(ForgeDirection.class);
|
||||
public static final EnumSet<ForgeDirection> SIDES = EnumSet.of(
|
||||
ForgeDirection.NORTH,
|
||||
ForgeDirection.SOUTH,
|
||||
ForgeDirection.EAST,
|
||||
ForgeDirection.WEST
|
||||
);
|
||||
|
||||
private static final EnumSet<ForgeDirection> ALL = EnumSet.of(
|
||||
ForgeDirection.UP,
|
||||
ForgeDirection.DOWN,
|
||||
ForgeDirection.NORTH,
|
||||
ForgeDirection.SOUTH,
|
||||
ForgeDirection.EAST,
|
||||
ForgeDirection.WEST
|
||||
);
|
||||
|
||||
public static String asString(Collection<ForgeDirection> sides) {
|
||||
if (sides.containsAll(MachineSide.All)) {
|
||||
return "Any";
|
||||
if (sides.containsAll(MachineSide.ALL)) {
|
||||
return I18N.localise(BinnieCore.instance, "gui.side.any");
|
||||
}
|
||||
if (sides.isEmpty()) {
|
||||
return "None";
|
||||
return I18N.localise(BinnieCore.instance, "gui.side.none");
|
||||
}
|
||||
|
||||
String text = "";
|
||||
@@ -26,48 +39,48 @@ public class MachineSide {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Up";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.up");
|
||||
}
|
||||
|
||||
if (sides.contains(ForgeDirection.DOWN)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Down";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.down");
|
||||
}
|
||||
|
||||
if (sides.containsAll(MachineSide.Sides)) {
|
||||
if (sides.containsAll(MachineSide.SIDES)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "Sides";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.sides");
|
||||
} else {
|
||||
if (sides.contains(ForgeDirection.NORTH)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "North";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.north");
|
||||
}
|
||||
|
||||
if (sides.contains(ForgeDirection.EAST)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "East";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.east");
|
||||
}
|
||||
|
||||
if (sides.contains(ForgeDirection.SOUTH)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "South";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.south");
|
||||
}
|
||||
|
||||
if (sides.contains(ForgeDirection.WEST)) {
|
||||
if (sides.size() > 0) {
|
||||
text += ", ";
|
||||
}
|
||||
text += "West";
|
||||
text += I18N.localise(BinnieCore.instance, "gui.side.west");
|
||||
}
|
||||
}
|
||||
return text;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package binnie.core.machines.inventory;
|
||||
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.I18N;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -53,7 +55,7 @@ public abstract class SlotValidator extends Validator<ItemStack> {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Breedable Individual";
|
||||
return I18N.localise(BinnieCore.instance, "gui.slot.breedableIndividual");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user