diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-19 17:38:35 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-19 17:38:35 +1000 |
commit | 7011e367ac5ccc34473283d6245bc2cec93b835e (patch) | |
tree | cc5675471f1101631bec2cde9713cb9c0004cc8f /src/Java/binnie/craftgui/controls/listbox | |
parent | c68c67d74f39c3eb075ac29e88936a1976ef089b (diff) | |
download | GT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.tar.gz GT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.tar.bz2 GT5-Unofficial-7011e367ac5ccc34473283d6245bc2cec93b835e.zip |
Removed Hard dependency on gregtech as another Project and added dev versions of all requires libs.
Also started work on GT-EU EnderIO conduits, adding @Optional annotations where possible and a few other nice things.
Diffstat (limited to 'src/Java/binnie/craftgui/controls/listbox')
4 files changed, 0 insertions, 332 deletions
diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlList.java b/src/Java/binnie/craftgui/controls/listbox/ControlList.java deleted file mode 100644 index d1b6be8821..0000000000 --- a/src/Java/binnie/craftgui/controls/listbox/ControlList.java +++ /dev/null @@ -1,146 +0,0 @@ -package binnie.craftgui.controls.listbox; - -import binnie.core.util.IValidator; -import binnie.craftgui.controls.core.Control; -import binnie.craftgui.controls.core.IControlValue; -import binnie.craftgui.core.IWidget; -import binnie.craftgui.core.geometry.IPoint; -import binnie.craftgui.events.EventValueChanged; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; - -public class ControlList<T> - extends Control - implements IControlValue<T> -{ - ControlListBox<T> parent; - - protected ControlList(ControlListBox<T> parent, float x, float y, float w, float h) - { - super(parent, x, y, w, h); - this.parent = parent; - } - - T value = null; - Map<T, IWidget> allOptions = new LinkedHashMap(); - Map<T, IWidget> optionWidgets = new LinkedHashMap(); - - public T getValue() - { - return this.value; - } - - public void setValue(T value) - { - if (value == this.value) { - return; - } - this.value = value; - if ((value != null) && (this.optionWidgets.containsKey(value))) - { - IWidget child = (IWidget)this.optionWidgets.get(value); - this.parent.ensureVisible(child.y(), child.y() + child.h(), h()); - } - getParent().callEvent(new EventValueChanged(getParent(), value)); - } - - boolean creating = false; - IValidator<IWidget> validator; - - public void setOptions(Collection<T> options) - { - deleteAllChildren(); - this.allOptions.clear(); - int i = 0; - for (T option : options) - { - IWidget optionWidget = ((ControlListBox)getParent()).createOption(option, 0); - if (optionWidget != null) { - this.allOptions.put(option, optionWidget); - } - i++; - } - filterOptions(); - } - - public void filterOptions() - { - int height = 0; - this.optionWidgets.clear(); - for (Map.Entry<T, IWidget> entry : this.allOptions.entrySet()) { - if (isValidOption((IWidget)entry.getValue())) - { - ((IWidget)entry.getValue()).show(); - this.optionWidgets.put(entry.getKey(), entry.getValue()); - ((IWidget)entry.getValue()).setPosition(new IPoint(0.0F, height)); - height = (int)(height + ((IWidget)entry.getValue()).getSize().y()); - } - else - { - ((IWidget)entry.getValue()).hide(); - } - } - this.creating = true; - setValue(getValue()); - setSize(new IPoint(getSize().x(), height)); - } - - public Collection<T> getOptions() - { - return this.optionWidgets.keySet(); - } - - public Collection<T> getAllOptions() - { - return this.allOptions.keySet(); - } - - public int getIndexOf(T value) - { - int index = 0; - for (T option : getOptions()) - { - if (option.equals(value)) { - return index; - } - index++; - } - return -1; - } - - public int getCurrentIndex() - { - return getIndexOf(getValue()); - } - - public void setIndex(int currentIndex) - { - int index = 0; - for (T option : getOptions()) - { - if (index == currentIndex) - { - setValue(option); - return; - } - index++; - } - setValue(null); - } - - private boolean isValidOption(IWidget widget) - { - return this.validator == null ? true : this.validator.isValid(widget); - } - - public void setValidator(IValidator<IWidget> validator) - { - if (this.validator != validator) - { - this.validator = validator; - filterOptions(); - } - } -} diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java b/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java deleted file mode 100644 index e9370daa3d..0000000000 --- a/src/Java/binnie/craftgui/controls/listbox/ControlListBox.java +++ /dev/null @@ -1,76 +0,0 @@ -package binnie.craftgui.controls.listbox; - -import binnie.core.util.IValidator; -import binnie.craftgui.controls.core.IControlValue; -import binnie.craftgui.controls.scroll.ControlScrollableContent; -import binnie.craftgui.core.IWidget; -import binnie.craftgui.events.EventKey.Down; -import binnie.craftgui.events.EventKey.Down.Handler; -import java.util.Collection; - -public class ControlListBox<T> - extends ControlScrollableContent<ControlList<T>> - implements IControlValue<T> -{ - public ControlListBox(IWidget parent, float x, float y, float w, float h, float scrollBarSize) - { - super(parent, x, y, w, h, scrollBarSize); - } - - public void initialise() - { - setScrollableContent(new ControlList(this, 1.0F, 1.0F, w() - 2.0F - this.scrollBarSize, h() - 2.0F)); - - addEventHandler(new EventKey.Down.Handler() - { - public void onEvent(EventKey.Down event) - { - EventKey.Down eventKey = event; - if (ControlListBox.this.calculateIsMouseOver()) - { - int currentIndex = ((ControlList)ControlListBox.this.getContent()).getCurrentIndex(); - if (eventKey.getKey() == 208) - { - currentIndex++; - if (currentIndex >= ((ControlList)ControlListBox.this.getContent()).getOptions().size()) { - currentIndex = 0; - } - } - else if (eventKey.getKey() == 200) - { - currentIndex--; - if (currentIndex < 0) { - currentIndex = ((ControlList)ControlListBox.this.getContent()).getOptions().size() - 1; - } - } - ((ControlList)ControlListBox.this.getContent()).setIndex(currentIndex); - } - } - }); - } - - public final T getValue() - { - return ((ControlList)getContent()).getValue(); - } - - public final void setValue(T value) - { - ((ControlList)getContent()).setValue(value); - } - - public void setOptions(Collection<T> options) - { - ((ControlList)getContent()).setOptions(options); - } - - public IWidget createOption(T value, int y) - { - return new ControlOption((ControlList)getContent(), value, y); - } - - public void setValidator(IValidator<IWidget> validator) - { - ((ControlList)getContent()).setValidator(validator); - } -} diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlOption.java deleted file mode 100644 index 7a643101cf..0000000000 --- a/src/Java/binnie/craftgui/controls/listbox/ControlOption.java +++ /dev/null @@ -1,73 +0,0 @@ -package binnie.craftgui.controls.listbox; - -import binnie.craftgui.controls.core.Control; -import binnie.craftgui.controls.core.IControlValue; -import binnie.craftgui.core.Attribute; -import binnie.craftgui.core.CraftGUI; -import binnie.craftgui.core.geometry.IPoint; -import binnie.craftgui.core.renderer.Renderer; -import binnie.craftgui.events.EventMouse.Down; -import binnie.craftgui.events.EventMouse.Down.Handler; -import binnie.craftgui.resource.minecraft.CraftGUITexture; - -public class ControlOption<T> - extends Control - implements IControlValue<T> -{ - T value; - - public void onUpdateClient() - { - if (getValue() == null) { - return; - } - int colour = 10526880; - if (isCurrentSelection()) { - colour = 16777215; - } - setColour(colour); - } - - public ControlOption(ControlList<T> controlList, T option) - { - this(controlList, option, 16); - } - - public ControlOption(ControlList<T> controlList, T option, int height) - { - super(controlList, 0.0F, height, controlList.getSize().x(), 20.0F); - this.value = option; - if (this.value != null) { - addAttribute(Attribute.MouseOver); - } - addSelfEventHandler(new EventMouse.Down.Handler() - { - public void onEvent(EventMouse.Down event) - { - ((IControlValue)ControlOption.this.getParent()).setValue(ControlOption.this.getValue()); - } - }); - } - - public T getValue() - { - return this.value; - } - - public void setValue(T value) - { - this.value = value; - } - - public boolean isCurrentSelection() - { - return (getValue() != null) && (getValue().equals(((IControlValue)getParent()).getValue())); - } - - public void onRenderForeground() - { - if (isCurrentSelection()) { - CraftGUI.Render.texture(CraftGUITexture.Outline, getArea()); - } - } -} diff --git a/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java b/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java deleted file mode 100644 index 6a47ec5d41..0000000000 --- a/src/Java/binnie/craftgui/controls/listbox/ControlTextOption.java +++ /dev/null @@ -1,37 +0,0 @@ -package binnie.craftgui.controls.listbox; - -import binnie.craftgui.controls.ControlText; -import binnie.craftgui.core.geometry.TextJustification; -import binnie.craftgui.events.EventHandler.Origin; -import binnie.craftgui.events.EventWidget.ChangeColour; -import binnie.craftgui.events.EventWidget.ChangeColour.Handler; - -public class ControlTextOption<T> - extends ControlOption<T> -{ - public ControlTextOption(ControlList<T> controlList, T option, String optionName, int y) - { - super(controlList, option, y); - this.textWidget = new ControlText(this, getArea(), optionName, TextJustification.MiddleCenter); - - addEventHandler(new EventWidget.ChangeColour.Handler() - { - public void onEvent(EventWidget.ChangeColour event) - { - ControlTextOption.this.textWidget.setColour(ControlTextOption.this.getColour()); - } - }.setOrigin(EventHandler.Origin.Self, this)); - } - - public ControlTextOption(ControlList<T> controlList, T option, int y) - { - this(controlList, option, option.toString(), y); - } - - protected ControlText textWidget = null; - - public String getText() - { - return this.textWidget.getValue(); - } -} |