mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-22 21:19:56 +00:00
SideOnly fixes
This commit is contained in:
1 parent
14c107ab71
commit
a97f5a2baa
21 files changed
+262
-181
No files matched your search
@@ -7,7 +7,10 @@ import binnie.core.craftgui.controls.listbox.ControlList;
|
||||
import binnie.core.craftgui.controls.listbox.ControlTextOption;
|
||||
import binnie.core.craftgui.geometry.CraftGUIUtil;
|
||||
import binnie.core.craftgui.geometry.Point;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlColourOption extends ControlTextOption<IFlowerColour> {
|
||||
ControlColourDisplay controlBee;
|
||||
Point boxPosition;
|
||||
|
||||
@@ -48,20 +48,7 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
new PageSpeciesMutations(this.getInfoPages(Mode.SPECIES), new DatabaseTab(Botany.instance, "species.further", 0));
|
||||
new PageBranchOverview(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.overview", 0));
|
||||
new PageBranchSpecies(this.getInfoPages(Mode.BRANCHES), new DatabaseTab(Botany.instance, "branches.species", 0));
|
||||
this.createMode(FlowerMode.Colour, new ModeWidgets(FlowerMode.Colour, this) {
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = new ArrayList<>();
|
||||
Collections.addAll(colors, EnumFlowerColor.values());
|
||||
this.listBox.setOptions(colors);
|
||||
}
|
||||
});
|
||||
this.createMode(FlowerMode.Colour, new FlowerColourModeWidgets());
|
||||
new PageColourMixResultant(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.resultant", 0));
|
||||
new PageColourMix(this.getInfoPages(FlowerMode.Colour), new DatabaseTab(Botany.instance, "colour.further", 0));
|
||||
new PageBreeder(this.getInfoPages(Mode.BREEDER), this.getUsername(), new DatabaseTab(Botany.instance, "breeder", 0));
|
||||
@@ -85,4 +72,24 @@ public class WindowBotanistDatabase extends WindowAbstractDatabase {
|
||||
return Botany.proxy.localise("gui.database.mode." + this.name().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class FlowerColourModeWidgets extends ModeWidgets {
|
||||
public FlowerColourModeWidgets() {
|
||||
super(FlowerMode.Colour, WindowBotanistDatabase.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox<IFlowerColour>(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12) {
|
||||
@Override
|
||||
public IWidget createOption(final IFlowerColour value, final int y) {
|
||||
return new ControlColourOption(this.getContent(), value, y);
|
||||
}
|
||||
};
|
||||
final List<IFlowerColour> colors = new ArrayList<>();
|
||||
Collections.addAll(colors, EnumFlowerColor.values());
|
||||
this.listBox.setOptions(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import binnie.botany.Botany;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.core.resource.BinnieSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class FlowerSpriteManager {
|
||||
|
||||
@@ -23,6 +25,7 @@ public class FlowerSpriteManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getStem(IFlowerType type, int section, boolean flowered){
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if(flower == null){
|
||||
@@ -32,6 +35,7 @@ public class FlowerSpriteManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered){
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if(flower == null){
|
||||
@@ -41,6 +45,7 @@ public class FlowerSpriteManager {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered){
|
||||
FlowerSprites flower = flowerSprites.get(type);
|
||||
if(flower == null){
|
||||
@@ -71,16 +76,19 @@ public class FlowerSpriteManager {
|
||||
this.unflowered[section] = Binnie.RESOURCE.getBlockSprite(Botany.instance, "flowers/" + pre + type.toString().toLowerCase() + suf + ".3");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getStem(IFlowerType type, int section, boolean flowered){
|
||||
return stem[section % sections].getSprite();
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getPetal(IFlowerType type, int section, boolean flowered){
|
||||
return (flowered ? petal[section % this.sections] : this.unflowered[section % this.sections]).getSprite();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SideOnly(Side.CLIENT)
|
||||
public TextureAtlasSprite getVariant(IFlowerType type, int section, boolean flowered){
|
||||
return flowered ? variant[section % this.sections].getSprite() : null;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package binnie.core.craftgui;
|
||||
|
||||
import binnie.core.craftgui.renderer.TextureRenderer;
|
||||
import binnie.core.craftgui.resource.minecraft.CraftGUIResourceManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CraftGUI {
|
||||
public static CraftGUIResourceManager resourceManager;
|
||||
public static final TextureRenderer render = new TextureRenderer();
|
||||
|
||||
@@ -18,6 +18,8 @@ import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -67,6 +69,7 @@ public class ControlDatabaseIndividualDisplay extends ControlItemDisplay impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderForeground(int guiWidth, int guiHeight) {
|
||||
|
||||
TextureAtlasSprite icon = null;
|
||||
|
||||
@@ -7,11 +7,14 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlSpeciesBox extends ControlListBox<IAlleleSpecies> {
|
||||
private IClassification branch;
|
||||
|
||||
|
||||
@@ -7,11 +7,14 @@ import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.craftgui.renderer.RenderUtil;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PageBranchOverview extends PageBranch {
|
||||
private ControlText pageBranchOverview_branchName;
|
||||
private ControlText pageBranchOverview_branchScientific;
|
||||
|
||||
@@ -7,7 +7,10 @@ import binnie.core.craftgui.controls.ControlTextCentered;
|
||||
import binnie.core.craftgui.events.EventValueChanged;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IClassification;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PageBranchSpecies extends PageBranch {
|
||||
private ControlText pageBranchSpecies_title;
|
||||
private ControlSpeciesBox pageBranchSpecies_speciesList;
|
||||
|
||||
@@ -21,7 +21,6 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.craftgui.minecraft.control.ControlHelp;
|
||||
import binnie.core.craftgui.window.Panel;
|
||||
import binnie.core.genetics.BreedingSystem;
|
||||
import binnie.core.util.IValidator;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
@@ -126,12 +125,7 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
@Override
|
||||
public void onEvent(final EventTextEdit event) {
|
||||
for (final ModeWidgets widgets : WindowAbstractDatabase.this.modes.values()) {
|
||||
widgets.listBox.setValidator(new IValidator<IWidget>() {
|
||||
@Override
|
||||
public boolean isValid(final IWidget object) {
|
||||
return Objects.equals(event.getValue(), "") || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase());
|
||||
}
|
||||
});
|
||||
widgets.listBox.setValidator(object -> Objects.equals(event.getValue(), "") || ((ControlTextOption) object).getText().toLowerCase().contains(event.getValue().toLowerCase()));
|
||||
}
|
||||
}
|
||||
}.setOrigin(EventHandler.Origin.DirectChild, this));
|
||||
@@ -140,29 +134,9 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
(this.panelSearch = new Panel(this, 176, 24, this.selectionBoxWidth, 160, MinecraftGUI.PanelType.Black)).setColour(860416);
|
||||
this.modePages = new ControlPages<>(this, 0, 0, this.getSize().x(), this.getSize().y());
|
||||
new ControlTextEdit(this, 176, 184, this.selectionBoxWidth, 16);
|
||||
this.createMode(Mode.SPECIES, new ModeWidgets(Mode.SPECIES, this) {
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IAlleleSpecies> speciesList = this.database.isNEI ? this.database.system.getAllSpecies() : this.database.system.getDiscoveredSpecies(this.database.getWorld(), playerName);
|
||||
(this.listBox = new ControlSpeciesBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height())).setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
this.createMode(Mode.BRANCHES, new ModeWidgets(Mode.BRANCHES, this) {
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
final EntityPlayer player = this.database.getPlayer();
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IClassification> speciesList = this.database.isNEI ? this.database.system.getAllBranches() : this.database.system.getDiscoveredBranches(this.database.getWorld(), playerName);
|
||||
(this.listBox = new ControlBranchBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height())).setOptions(speciesList);
|
||||
}
|
||||
});
|
||||
this.createMode(Mode.BREEDER, new ModeWidgets(Mode.BREEDER, this) {
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
|
||||
}
|
||||
});
|
||||
this.createMode(Mode.SPECIES, new SpeciesModeWidgets());
|
||||
this.createMode(Mode.BRANCHES, new BranchesModeWidgets());
|
||||
this.createMode(Mode.BREEDER, new BreederModeWidgets());
|
||||
this.addTabs();
|
||||
final ControlTabBar<IDatabaseMode> tab = new ControlTabBar<IDatabaseMode>(this, 176 + this.selectionBoxWidth, 24, 22, 176, Position.RIGHT, this.modePages.getValues()) {
|
||||
@Override
|
||||
@@ -247,4 +221,49 @@ public abstract class WindowAbstractDatabase extends Window {
|
||||
|
||||
public abstract void createListBox(final Area p0);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class SpeciesModeWidgets extends ModeWidgets {
|
||||
public SpeciesModeWidgets() {
|
||||
super(Mode.SPECIES, WindowAbstractDatabase.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IAlleleSpecies> speciesList = this.database.isNEI ? this.database.system.getAllSpecies() : this.database.system.getDiscoveredSpecies(this.database.getWorld(), playerName);
|
||||
ControlSpeciesBox controlSpeciesBox = new ControlSpeciesBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height());
|
||||
controlSpeciesBox.setOptions(speciesList);
|
||||
this.listBox = controlSpeciesBox;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class BranchesModeWidgets extends ModeWidgets {
|
||||
public BranchesModeWidgets() {
|
||||
super(Mode.BRANCHES, WindowAbstractDatabase.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
final EntityPlayer player = this.database.getPlayer();
|
||||
final GameProfile playerName = WindowAbstractDatabase.this.getUsername();
|
||||
final Collection<IClassification> speciesList = this.database.isNEI ? this.database.system.getAllBranches() : this.database.system.getDiscoveredBranches(this.database.getWorld(), playerName);
|
||||
ControlBranchBox controlBranchBox = new ControlBranchBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height());
|
||||
controlBranchBox.setOptions(speciesList);
|
||||
this.listBox = controlBranchBox;
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class BreederModeWidgets extends ModeWidgets {
|
||||
public BreederModeWidgets() {
|
||||
super(Mode.BREEDER, WindowAbstractDatabase.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createListBox(final Area area) {
|
||||
this.listBox = new ControlListBox(this.modePage, area.xPos(), area.yPos(), area.width(), area.height(), 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import binnie.core.craftgui.resource.minecraft.CraftGUITexture;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class Dialog extends Control {
|
||||
public Dialog(final IWidget parent, final int w, final int h) {
|
||||
super(parent, (parent.width() - w) / 2, (parent.height() - h) / 2, w, h);
|
||||
|
||||
@@ -65,7 +65,7 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
|
||||
private EntityPlayer player;
|
||||
@Nullable
|
||||
private IInventory entityInventory;
|
||||
private Side side;
|
||||
private final Side side;
|
||||
|
||||
public Window(final int width, final int height, final EntityPlayer player, @Nullable final IInventory inventory, final Side side) {
|
||||
this.titleButtonLeft = 8;
|
||||
@@ -73,41 +73,39 @@ public abstract class Window extends TopLevelWidget implements INetwork.ReceiveG
|
||||
this.bgText1 = null;
|
||||
this.bgText2 = null;
|
||||
this.hasBeenInitialised = false;
|
||||
this.side = Side.CLIENT;
|
||||
this.side = side;
|
||||
this.player = player;
|
||||
this.entityInventory = inventory;
|
||||
this.container = new ContainerCraftGUI(this);
|
||||
this.windowInventory = new WindowInventory(this);
|
||||
if (side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setSize(new Point(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
CraftGUI.render.setStyleSheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22, 8);
|
||||
}
|
||||
String showInfoButton = this.showInfoButton();
|
||||
if (showInfoButton != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, showInfoButton);
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient()) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new Point(Window.this.width(), Window.this.title.height()));
|
||||
if (side == Side.CLIENT) {
|
||||
this.setSize(new Point(width, height));
|
||||
this.gui = new GuiCraftGUI(this);
|
||||
for (final EnumHighlighting h : EnumHighlighting.values()) {
|
||||
ControlSlot.highlighting.put(h, new ArrayList<>());
|
||||
}
|
||||
CraftGUI.render.setStyleSheet(StyleSheetManager.getDefault());
|
||||
this.titleButtonLeft = -14;
|
||||
if (this.showHelpButton()) {
|
||||
new ControlHelp(this, this.titleButtonLeft += 22, 8);
|
||||
}
|
||||
String showInfoButton = this.showInfoButton();
|
||||
if (showInfoButton != null) {
|
||||
new ControlInfo(this, this.titleButtonLeft += 22, 8, showInfoButton);
|
||||
}
|
||||
this.addSelfEventHandler(new EventWidget.ChangeSize.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventWidget.ChangeSize event) {
|
||||
if (Window.this.isClient()) {
|
||||
Window.this.getGui().resize(Window.this.getSize());
|
||||
if (Window.this.title != null) {
|
||||
Window.this.title.setSize(new Point(Window.this.width(), Window.this.title.height()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void getTooltip(final Tooltip tooltip) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ControlIconDisplay extends Control {
|
||||
private final TextureAtlasSprite sprite;
|
||||
|
||||
|
||||
@@ -298,112 +298,7 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void createSearchDialog() {
|
||||
new Dialog(this, 252, 192) {
|
||||
Control slotGrid;
|
||||
String textSearch = "";
|
||||
boolean sortByName = false;
|
||||
boolean includeItems = true;
|
||||
boolean includeBlocks = true;
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
final ControlScrollableContent<IWidget> scroll = new ControlScrollableContent<IWidget>(this, 124, 16, 116, 92, 6) {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.setColour(11184810);
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea().inset(new Border(0, 6, 0, 0)));
|
||||
}
|
||||
};
|
||||
scroll.setScrollableContent(this.slotGrid = new Control(scroll, 1, 1, 108, 18));
|
||||
new ControlPlayerInventory(this, true);
|
||||
new ControlTextEdit(this, 16, 16, 100, 14).addEventHandler(new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventTextEdit event) {
|
||||
textSearch = event.value;
|
||||
updateSearch();
|
||||
}
|
||||
});
|
||||
this.includeItems = true;
|
||||
this.includeBlocks = true;
|
||||
new ControlCheckbox(this, 16, 40, 100, "Sort A-Z", this.sortByName) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
sortByName = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
new ControlCheckbox(this, 16, 64, 100, "Include Items", this.includeItems) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
includeItems = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
new ControlCheckbox(this, 16, 88, 100, "Include Blocks", this.includeBlocks) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
includeBlocks = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
this.updateSearch();
|
||||
}
|
||||
|
||||
private void updateSearch() {
|
||||
Map<Integer, String> slotIds = new HashMap<>();
|
||||
final IInventory inv = WindowCompartment.this.getInventory();
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
final ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty()) {
|
||||
final String name = stack.getDisplayName().toLowerCase();
|
||||
if (this.textSearch == null || name.contains(this.textSearch)) {
|
||||
if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) {
|
||||
if (this.includeItems || Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) {
|
||||
slotIds.put(i, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.sortByName) {
|
||||
final List<Entry<Integer, String>> list = new LinkedList<>(slotIds.entrySet());
|
||||
list.sort((o1, o2) -> -o2.getValue().compareTo(o1.getValue()));
|
||||
final Map<Integer, String> result = new LinkedHashMap<>();
|
||||
for (final Map.Entry<Integer, String> entry : list) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
slotIds = result;
|
||||
}
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
final int width = 108;
|
||||
final int height = 2 + 18 * (1 + (slotIds.size() - 1) / 6);
|
||||
this.slotGrid.deleteAllChildren();
|
||||
this.slotGrid.setSize(new Point(width, height));
|
||||
for (final int k : slotIds.keySet()) {
|
||||
new ControlSlot.Builder(this.slotGrid, x, y).assign(k);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
while (y < 108 || x != 0) {
|
||||
// TODO: what was this supposed to do?
|
||||
new ControlSlot.Builder(this.slotGrid, x, y);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
new SearchDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -458,4 +353,115 @@ public class WindowCompartment extends WindowMachine implements IWindowAffectsSh
|
||||
public CompartmentTab getCurrentTab() {
|
||||
return this.getTab(this.currentTab);
|
||||
}
|
||||
|
||||
private class SearchDialog extends Dialog {
|
||||
Control slotGrid;
|
||||
String textSearch = "";
|
||||
boolean sortByName = false;
|
||||
boolean includeItems = true;
|
||||
boolean includeBlocks = true;
|
||||
|
||||
public SearchDialog() {
|
||||
super(WindowCompartment.this, 252, 192);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialise() {
|
||||
final ControlScrollableContent<IWidget> scroll = new ControlScrollableContent<IWidget>(this, 124, 16, 116, 92, 6) {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.setColour(11184810);
|
||||
CraftGUI.render.texture(CraftGUITexture.Outline, this.getArea().inset(new Border(0, 6, 0, 0)));
|
||||
}
|
||||
};
|
||||
scroll.setScrollableContent(this.slotGrid = new Control(scroll, 1, 1, 108, 18));
|
||||
new ControlPlayerInventory(this, true);
|
||||
new ControlTextEdit(this, 16, 16, 100, 14).addEventHandler(new EventTextEdit.Handler() {
|
||||
@Override
|
||||
public void onEvent(final EventTextEdit event) {
|
||||
textSearch = event.value;
|
||||
updateSearch();
|
||||
}
|
||||
});
|
||||
this.includeItems = true;
|
||||
this.includeBlocks = true;
|
||||
new ControlCheckbox(this, 16, 40, 100, "Sort A-Z", this.sortByName) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
sortByName = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
new ControlCheckbox(this, 16, 64, 100, "Include Items", this.includeItems) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
includeItems = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
new ControlCheckbox(this, 16, 88, 100, "Include Blocks", this.includeBlocks) {
|
||||
@Override
|
||||
protected void onValueChanged(final boolean value) {
|
||||
includeBlocks = value;
|
||||
updateSearch();
|
||||
}
|
||||
};
|
||||
this.updateSearch();
|
||||
}
|
||||
|
||||
private void updateSearch() {
|
||||
Map<Integer, String> slotIds = new HashMap<>();
|
||||
final IInventory inv = WindowCompartment.this.getInventory();
|
||||
for (int i = 0; i < inv.getSizeInventory(); ++i) {
|
||||
final ItemStack stack = inv.getStackInSlot(i);
|
||||
if (!stack.isEmpty()) {
|
||||
final String name = stack.getDisplayName().toLowerCase();
|
||||
if (this.textSearch == null || name.contains(this.textSearch)) {
|
||||
if (this.includeBlocks || Block.getBlockFromItem(stack.getItem()) == Blocks.AIR) {
|
||||
if (this.includeItems || Block.getBlockFromItem(stack.getItem()) != Blocks.AIR) {
|
||||
slotIds.put(i, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.sortByName) {
|
||||
final List<Entry<Integer, String>> list = new LinkedList<>(slotIds.entrySet());
|
||||
list.sort((o1, o2) -> -o2.getValue().compareTo(o1.getValue()));
|
||||
final Map<Integer, String> result = new LinkedHashMap<>();
|
||||
for (final Entry<Integer, String> entry : list) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
slotIds = result;
|
||||
}
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
final int width = 108;
|
||||
final int height = 2 + 18 * (1 + (slotIds.size() - 1) / 6);
|
||||
this.slotGrid.deleteAllChildren();
|
||||
this.slotGrid.setSize(new Point(width, height));
|
||||
for (final int k : slotIds.keySet()) {
|
||||
new ControlSlot.Builder(this.slotGrid, x, y).assign(k);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
while (y < 108 || x != 0) {
|
||||
// TODO: what was this supposed to do?
|
||||
new ControlSlot.Builder(this.slotGrid, x, y);
|
||||
x += 18;
|
||||
if (x >= 108) {
|
||||
x = 0;
|
||||
y += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,12 @@ import binnie.core.genetics.TreeBreedingSystem;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PageFruit extends PageAbstract<ItemStack> {
|
||||
boolean treesThatBearFruit;
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ import binnie.extratrees.block.IPlankType;
|
||||
import binnie.extratrees.block.WoodManager;
|
||||
import binnie.extratrees.block.decor.FenceType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PagePlanksOverview extends PageAbstract<ItemStack> {
|
||||
public PagePlanksOverview(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -12,9 +12,12 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PagePlanksTrees extends PageAbstract<ItemStack> {
|
||||
public PagePlanksTrees(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -27,11 +27,14 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PageSpeciesTreeGenome extends PageSpecies {
|
||||
public PageSpeciesTreeGenome(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -12,9 +12,12 @@ import binnie.core.craftgui.minecraft.Window;
|
||||
import binnie.core.genetics.TreeBreedingSystem;
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PageWood extends PageAbstract<ItemStack> {
|
||||
public PageWood(final IWidget parent, final DatabaseTab tab) {
|
||||
super(parent, tab);
|
||||
|
||||
@@ -16,10 +16,14 @@ import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.apiculture.PluginApiculture;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Locale;
|
||||
|
||||
//TODO:localise
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class AnalystPageBiology extends ControlAnalystPage {
|
||||
public AnalystPageBiology(final IWidget parent, final Area area, final IIndividual ind) {
|
||||
super(parent, area);
|
||||
|
||||
@@ -223,7 +223,8 @@ public class AnalystPageMutations extends ControlAnalystPage {
|
||||
y += 8;
|
||||
this.setSize(new Point(this.width(), y));
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void drawSprite(BinnieSprite sprite){
|
||||
RenderUtil.drawSprite(new Point(14, 0), sprite.getSprite());
|
||||
}
|
||||
|
||||
@@ -17,9 +17,12 @@ import forestry.api.arboriculture.ITreeGenome;
|
||||
import forestry.api.genetics.IAlleleBoolean;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class AnalystPageWood extends AnalystPageProduce {
|
||||
public AnalystPageWood(final IWidget parent, final Area area, final ITree ind) {
|
||||
super(parent, area);
|
||||
|
||||
Reference in new issue
Block a user