mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-27 15:33:12 +00:00
Localization and refactoring (#77)
* Some refactoring for bee production * Code cleanup * Code cleanup * Added some localization * Fix wrong dropped class * Added some localization * Added some localization * Added some localization * Fix wrong import
This commit is contained in:
1 parent
68bbe7710c
commit
1ea7b62e5f
157 files changed
+3240
-5045
No files matched your search
@@ -22,9 +22,9 @@ import binnie.core.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import binnie.core.util.I18N;
|
||||
import binnie.extrabees.core.ExtraBeeTexture;
|
||||
import binnie.extrabees.gui.punnett.ExtraBeeGUITexture;
|
||||
import binnie.extrabees.gui.ExtraBeeGUITexture;
|
||||
import binnie.genetics.gui.ControlChromosome;
|
||||
import binnie.genetics.machine.Analyser;
|
||||
import binnie.genetics.machine.analyser.Analyser;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package binnie.core.craftgui.controls.button;
|
||||
package binnie.core.craftgui.controls;
|
||||
|
||||
import binnie.core.craftgui.CraftGUI;
|
||||
import binnie.core.craftgui.IWidget;
|
||||
@@ -1,10 +0,0 @@
|
||||
package binnie.core.craftgui.controls;
|
||||
|
||||
// TODO unused interface?
|
||||
public interface IControlSelection<T> {
|
||||
T getSelectedValue();
|
||||
|
||||
void setSelectedValue(T p0);
|
||||
|
||||
boolean isSelected(IControlSelectionOption<T> p0);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package binnie.core.craftgui.controls.button;
|
||||
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.core.IControlValue;
|
||||
import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
// TODO unused class?
|
||||
public class ControlEnumButton<T> extends ControlButton implements IControlValue<T> {
|
||||
public static String eventEnumChanged = "eventEnumButtonChanged";
|
||||
private T currentSelection;
|
||||
private List<T> enumConstants;
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return currentSelection.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMouseClick(EventMouse.Down event) {
|
||||
int index = enumConstants.indexOf(currentSelection);
|
||||
if (index < enumConstants.size() - 1) {
|
||||
index++;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
T newEnum = enumConstants.get(index);
|
||||
setValue(newEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(T selection) {
|
||||
if (currentSelection != selection) {
|
||||
currentSelection = selection;
|
||||
callEvent(new EventValueChanged<Object>(this, getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public ControlEnumButton(IWidget parent, float x, float y, float width, float height, T[] values) {
|
||||
super(parent, x, y, width, height, "");
|
||||
enumConstants = new ArrayList<T>();
|
||||
Collections.addAll(enumConstants, values);
|
||||
if (values.length > 0) {
|
||||
currentSelection = values[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return currentSelection;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package binnie.core.craftgui.controls.button;
|
||||
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.events.EventMouse;
|
||||
import binnie.core.craftgui.events.EventToggleButtonClicked;
|
||||
|
||||
// TODO unused class?
|
||||
public class ControlToggleButton extends ControlButton {
|
||||
boolean toggled;
|
||||
|
||||
@Override
|
||||
public void onMouseClick(EventMouse.Down event) {
|
||||
callEvent(new EventToggleButtonClicked(this, toggled));
|
||||
}
|
||||
|
||||
public ControlToggleButton(IWidget parent, int x, int y, int width, int height) {
|
||||
super(parent, x, y, width, height);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package binnie.core.craftgui.controls.core;
|
||||
|
||||
// TODO unused interface?
|
||||
public interface IControlIndexed {
|
||||
int getIndex();
|
||||
|
||||
void setIndex(int index);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package binnie.core.craftgui.database;
|
||||
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.controls.ControlText;
|
||||
import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
// TODO unused class?
|
||||
public class PageBreederStats extends Control {
|
||||
String player;
|
||||
|
||||
public PageBreederStats(IWidget parent, int w, int h, String player) {
|
||||
super(parent, 0.0f, 0.0f, w, h);
|
||||
this.player = player;
|
||||
ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, EnumChatFormatting.UNDERLINE + "§tats" + EnumChatFormatting.RESET);
|
||||
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
|
||||
}
|
||||
}
|
||||
@@ -31,17 +31,4 @@ public abstract class EventKey extends Event {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO unused class?
|
||||
public static class Up extends EventKey {
|
||||
public Up(IWidget origin, char character, int key) {
|
||||
super(origin, character, key);
|
||||
}
|
||||
|
||||
public abstract static class Handler extends EventHandler<Up> {
|
||||
public Handler() {
|
||||
super(Up.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,7 @@ import net.minecraft.world.World;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT
|
||||
{
|
||||
public abstract class Window extends TopLevelWidget implements INetwork.RecieveGuiNBT {
|
||||
private GuiCraftGUI gui;
|
||||
private ContainerCraftGUI container;
|
||||
private WindowInventory windowInventory;
|
||||
@@ -76,7 +75,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
if (widget.hasAttribute(WidgetAttribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +96,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
if (widget.hasAttribute(WidgetAttribute.BlockTooltip)) {
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,32 +120,36 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
public Window(float width, float height, EntityPlayer player, IInventory inventory, Side side) {
|
||||
this.side = side;
|
||||
titleButtonLeft = 8.0f;
|
||||
titleButtonRight = 8.0f;
|
||||
bgText1 = null;
|
||||
bgText2 = null;
|
||||
hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
setInventories(player, inventory);
|
||||
container = new ContainerCraftGUI(this);
|
||||
windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSize(new IPoint(width, height));
|
||||
gui = new GuiCraftGUI(this);
|
||||
for (EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<Integer>());
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
(CraftGUI.Render = new Renderer(gui)).stylesheet(StyleSheetManager.getDefault());
|
||||
|
||||
CraftGUI.Render = new Renderer(gui);
|
||||
CraftGUI.Render.stylesheet(StyleSheetManager.getDefault());
|
||||
titleButtonLeft = -14.0f;
|
||||
|
||||
if (showHelpButton()) {
|
||||
new ControlHelp(this, titleButtonLeft += 22.0f, 8.0f);
|
||||
}
|
||||
if (showInfoButton() != null) {
|
||||
new ControlInfo(this, titleButtonLeft += 22.0f, 8.0f, showInfoButton());
|
||||
}
|
||||
|
||||
addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(EventWidget.ChangeSize event) {
|
||||
@@ -163,7 +164,8 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
(this.title = new ControlTextCentered(this, 12.0f, title)).setColor(4210752);
|
||||
this.title = new ControlTextCentered(this, 12.0f, title);
|
||||
this.title.setColor(0x404040);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -183,10 +185,12 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
if (hasBeenInitialised) {
|
||||
return;
|
||||
}
|
||||
|
||||
bgText1 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(1));
|
||||
if (getSize().x() > 256.0f) {
|
||||
bgText2 = new StandardTexture(0, 0, 256, 256, getBackgroundTextureFile(2));
|
||||
}
|
||||
|
||||
if (!BinnieCore.proxy.checkTexture(bgText1.getTexture())) {
|
||||
bgText1 = null;
|
||||
bgText2 = null;
|
||||
@@ -198,11 +202,12 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
public abstract void initialiseClient();
|
||||
|
||||
public void initialiseServer() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.colour(16777215);
|
||||
CraftGUI.Render.colour(0xffffff);
|
||||
if (getBackground1() != null) {
|
||||
CraftGUI.Render.texture(getBackground1(), IPoint.ZERO);
|
||||
}
|
||||
@@ -267,9 +272,6 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
return BinnieCore.proxy.getWorld();
|
||||
}
|
||||
|
||||
public void onInventoryUpdate() {
|
||||
}
|
||||
|
||||
public void sendClientAction(String name, NBTTagCompound action) {
|
||||
action.setString("type", name);
|
||||
MessageCraftGUI packet = new MessageCraftGUI(action);
|
||||
@@ -282,19 +284,20 @@ public abstract class Window extends TopLevelWidget implements INetwork.RecieveG
|
||||
float w = w();
|
||||
float titleButtonRight = this.titleButtonRight + 16.0f;
|
||||
this.titleButtonRight = titleButtonRight;
|
||||
ControlUser controlUser = new ControlUser(this, w - titleButtonRight, 8.0f, nbt.getString("username"));
|
||||
new ControlUser(this, w - titleButtonRight, 8.0f, nbt.getString("username"));
|
||||
this.titleButtonRight += 6.0f;
|
||||
}
|
||||
if (side == Side.CLIENT && name.equals("power-system")) {
|
||||
float w2 = w();
|
||||
float titleButtonRight2 = titleButtonRight + 16.0f;
|
||||
titleButtonRight = titleButtonRight2;
|
||||
ControlPowerSystem controlPowerSystem = new ControlPowerSystem(this, w2 - titleButtonRight2, 8.0f, PowerSystem.get(nbt.getByte("system")));
|
||||
new ControlPowerSystem(this, w2 - titleButtonRight2, 8.0f, PowerSystem.get(nbt.getByte("system")));
|
||||
titleButtonRight += 6.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void onWindowInventoryChanged() {
|
||||
// ignored
|
||||
}
|
||||
|
||||
public Texture getBackground1() {
|
||||
|
||||
@@ -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 ControlHelp extends Control implements ITooltip {
|
||||
public ControlHelp(IWidget parent, float x, float y) {
|
||||
@@ -22,10 +24,10 @@ public class ControlHelp extends Control implements ITooltip {
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.setType(Tooltip.Type.Help);
|
||||
tooltip.add("Help");
|
||||
tooltip.add("To activate help tooltips,");
|
||||
tooltip.add("hold down the tab key and");
|
||||
tooltip.add("mouse over controls.");
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.help"));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.help.0"));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.help.1"));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.help.2"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 ControlInfo extends Control implements ITooltip {
|
||||
private String info;
|
||||
@@ -25,7 +27,7 @@ public class ControlInfo extends Control implements ITooltip {
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.setType(Tooltip.Type.Information);
|
||||
tooltip.add("Info");
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.info"));
|
||||
tooltip.add(info);
|
||||
tooltip.setMaxWidth(200);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import binnie.core.machines.inventory.MachineSide;
|
||||
import binnie.core.machines.inventory.TankSlot;
|
||||
import binnie.core.machines.power.ITankMachine;
|
||||
import binnie.core.machines.power.TankInfo;
|
||||
import binnie.core.util.I18N;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -89,7 +90,6 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
if (isTankValid()) {
|
||||
float height = horizontal ? 16.0f : 58.0f;
|
||||
int squaled = (int) (height * (getTank().getAmount() / getTank().getCapacity()));
|
||||
int yPos = (int) height + 1;
|
||||
Fluid fluid = getTank().liquid.getFluid();
|
||||
int hex = fluid.getColor(getTank().liquid);
|
||||
int r = (hex & 0xFF0000) >> 16;
|
||||
@@ -144,25 +144,32 @@ public class ControlLiquidTank extends Control implements ITooltip {
|
||||
|
||||
TankSlot slot = getTankSlot();
|
||||
tooltip.add(slot.getName());
|
||||
tooltip.add("Capacity: " + getTankCapacity() + " mB");
|
||||
tooltip.add("Insert Side: " + MachineSide.asString(slot.getInputSides()));
|
||||
tooltip.add("Extract Side: " + MachineSide.asString(slot.getOutputSides()));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.capacity", getTankCapacity()));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.insertSide", MachineSide.asString(slot.getInputSides())));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.extractSide", MachineSide.asString(slot.getOutputSides())));
|
||||
|
||||
if (slot.isReadOnly()) {
|
||||
tooltip.add("Output Only Tank");
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.outputOnlyTank"));
|
||||
}
|
||||
|
||||
if (slot.getValidator() == null) {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.acceptsAny"));
|
||||
} else {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.accepts", slot.getValidator().getTooltip()));
|
||||
}
|
||||
tooltip.add("Accepts: " + ((slot.getValidator() == null) ? "Any Item" : slot.getValidator().getTooltip()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
if (isTankValid()) {
|
||||
int percentage = (int) (100.0 * getTank().getAmount() / getTankCapacity());
|
||||
tooltip.add(getTank().getName());
|
||||
tooltip.add(percentage + "% full");
|
||||
tooltip.add((int) getTank().getAmount() + " mB");
|
||||
if (!isTankValid()) {
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.empty"));
|
||||
return;
|
||||
}
|
||||
tooltip.add("Empty");
|
||||
|
||||
int percentage = (int) (100.0 * getTank().getAmount() / getTankCapacity());
|
||||
tooltip.add(getTank().getName());
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.full", percentage));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.tank.amount", (int) getTank().getAmount()));
|
||||
}
|
||||
|
||||
private TankSlot getTankSlot() {
|
||||
|
||||
@@ -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;
|
||||
@@ -8,6 +9,7 @@ import binnie.core.craftgui.WidgetAttribute;
|
||||
import binnie.core.craftgui.controls.core.Control;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import binnie.core.machines.power.PowerSystem;
|
||||
import binnie.core.util.I18N;
|
||||
|
||||
public class ControlPowerSystem extends Control implements ITooltip {
|
||||
private PowerSystem system;
|
||||
@@ -26,8 +28,8 @@ public class ControlPowerSystem extends Control implements ITooltip {
|
||||
@Override
|
||||
public void getTooltip(Tooltip tooltip) {
|
||||
tooltip.setType(Tooltip.Type.Power);
|
||||
tooltip.add("Power Supply");
|
||||
tooltip.add("Powered by " + system.getUnitName());
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.powerSupply"));
|
||||
tooltip.add(I18N.localise(BinnieCore.instance, "gui.tooltip.poweredBy", system.getUnitName()));
|
||||
tooltip.setMaxWidth(200);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package binnie.core.craftgui.minecraft.render;
|
||||
|
||||
import binnie.core.craftgui.geometry.IArea;
|
||||
import binnie.core.resource.IBinnieTexture;
|
||||
|
||||
// TODO unused class?
|
||||
public class MinecraftTexture {
|
||||
protected IArea textureArea;
|
||||
protected IBinnieTexture texture;
|
||||
|
||||
public MinecraftTexture() {
|
||||
textureArea = new IArea(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package binnie.core.craftgui.minecraft.render;
|
||||
|
||||
import binnie.core.craftgui.IWidget;
|
||||
import binnie.core.craftgui.minecraft.GuiCraftGUI;
|
||||
|
||||
// TODO unused class?
|
||||
public abstract class RenderCommand {
|
||||
protected IWidget widget;
|
||||
|
||||
public RenderCommand(IWidget widget) {
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
public abstract void render(GuiCraftGUI p0);
|
||||
}
|
||||
Reference in new issue
Block a user