Some reformat code for 1.11.2 source (#84)

* Optimized imports

* Some code reformat

* Some refactoring and code reformat

* Some code reformat
This commit is contained in:
Alexander Kornilov authored and mezz committed 2017-06-01 00:48:08 -07:00
1 parent 886c36a308
commit c3809fbc27
508 files changed
+6677 -6238

No files matched your search

@@ -3,7 +3,11 @@ package binnie.genetics.gui;
import binnie.Binnie;
import binnie.botany.api.IFlower;
import binnie.core.AbstractMod;
import binnie.core.craftgui.*;
import binnie.core.craftgui.Attribute;
import binnie.core.craftgui.CraftGUI;
import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.Tooltip;
import binnie.core.craftgui.Widget;
import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.craftgui.controls.scroll.ControlScrollBar;
@@ -69,16 +73,12 @@ public class WindowAnalyst extends Window {
boolean isDatabase;
boolean isMaster;
boolean lockedSearch;
private Control analystNone;
private ControlSlide slideUpInv;
@Nullable
IIndividual current;
@Nullable
BreedingSystem currentSystem;
public static GeneticsGUI.WindowFactory create(final boolean database, final boolean master) {
return (player, inventory, side) -> new WindowAnalyst(player, inventory, side, database, master);
}
private Control analystNone;
private ControlSlide slideUpInv;
public WindowAnalyst(final EntityPlayer player, @Nullable final IInventory inventory, final Side side, final boolean database, final boolean master) {
super(312, 230, player, inventory, side);
@@ -96,6 +96,10 @@ public class WindowAnalyst extends Window {
this.lockedSearch = this.isDatabase;
}
public static GeneticsGUI.WindowFactory create(final boolean database, final boolean master) {
return (player, inventory, side) -> new WindowAnalyst(player, inventory, side, database, master);
}
@Override
protected AbstractMod getMod() {
return Genetics.instance;
@@ -280,37 +284,6 @@ public class WindowAnalyst extends Window {
this.setSystem(Binnie.GENETICS.beeBreedingSystem);
}
@SideOnly(Side.CLIENT)
public void setIndividual(final IIndividual ind) {
if (!this.isDatabase) {
if (ind == null) {
this.analystNone.show();
this.slideUpInv.hide();
} else {
this.analystNone.hide();
this.slideUpInv.show();
}
}
if (ind == this.current || (ind != null && this.current != null && ind.isGeneticEqual(this.current))) {
return;
}
final boolean systemChange = (this.current = ind) != null && ind.getGenome().getSpeciesRoot() != this.getSystem().getSpeciesRoot();
if (systemChange) {
this.currentSystem = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot());
}
this.updatePages(systemChange);
}
@SideOnly(Side.CLIENT)
public void setSystem(final BreedingSystem system) {
if (system == this.currentSystem) {
return;
}
this.currentSystem = system;
this.current = null;
this.updatePages(true);
}
@SideOnly(Side.CLIENT)
public void updatePages(final boolean systemChange) {
int oldLeft = -1;
@@ -361,59 +334,59 @@ public class WindowAnalyst extends Window {
}
this.tabBar.deleteAllChildren();
if (this.analystPages.size() > 0) {
final int width = this.tabBar.width() / this.analystPages.size();
int x = 0;
for (final ControlAnalystPage page : this.analystPages) {
new ControlTooltip(this.tabBar, x, 0, width, this.tabBar.height()) {
ControlAnalystPage value;
final int width = this.tabBar.width() / this.analystPages.size();
int x = 0;
for (final ControlAnalystPage page : this.analystPages) {
new ControlTooltip(this.tabBar, x, 0, width, this.tabBar.height()) {
ControlAnalystPage value;
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(this.value.getTitle());
}
@Override
public void getTooltip(final Tooltip tooltip) {
tooltip.add(this.value.getTitle());
}
@Override
protected void initialise() {
super.initialise();
this.addAttribute(Attribute.MouseOver);
this.value = page;
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
final int currentIndex = WindowAnalyst.this.analystPages.indexOf(WindowAnalyst.this.rightPage.getContent());
int clickedIndex = WindowAnalyst.this.analystPages.indexOf(value);
if (WindowAnalyst.this.isDatabase) {
if (clickedIndex != 0 && clickedIndex != currentIndex) {
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, value);
@Override
protected void initialise() {
super.initialise();
this.addAttribute(Attribute.MouseOver);
this.value = page;
this.addSelfEventHandler(new EventMouse.Down.Handler() {
@Override
public void onEvent(final EventMouse.Down event) {
final int currentIndex = WindowAnalyst.this.analystPages.indexOf(WindowAnalyst.this.rightPage.getContent());
int clickedIndex = WindowAnalyst.this.analystPages.indexOf(value);
if (WindowAnalyst.this.isDatabase) {
if (clickedIndex != 0 && clickedIndex != currentIndex) {
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, value);
}
} else {
if (clickedIndex < 0) {
clickedIndex = 0;
}
if (clickedIndex < currentIndex) {
++clickedIndex;
}
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, WindowAnalyst.this.analystPages.get(clickedIndex));
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, WindowAnalyst.this.analystPages.get(clickedIndex - 1));
}
} else {
if (clickedIndex < 0) {
clickedIndex = 0;
}
if (clickedIndex < currentIndex) {
++clickedIndex;
}
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, null);
WindowAnalyst.this.setPage(WindowAnalyst.this.rightPage, WindowAnalyst.this.analystPages.get(clickedIndex));
WindowAnalyst.this.setPage(WindowAnalyst.this.leftPage, WindowAnalyst.this.analystPages.get(clickedIndex - 1));
}
}
});
}
});
}
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
final boolean active = this.value == WindowAnalyst.this.leftPage.getContent() || this.value == WindowAnalyst.this.rightPage.getContent();
RenderUtil.setColour((active ? -16777216 : 1140850688) + this.value.getColour());
CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
RenderUtil.setColour(this.value.getColour());
CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().inset(1));
super.onRenderBackground(guiWidth, guiHeight);
}
};
x += width;
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
final boolean active = this.value == WindowAnalyst.this.leftPage.getContent() || this.value == WindowAnalyst.this.rightPage.getContent();
RenderUtil.setColour((active ? -16777216 : 1140850688) + this.value.getColour());
CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
RenderUtil.setColour(this.value.getColour());
CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().inset(1));
super.onRenderBackground(guiWidth, guiHeight);
}
};
x += width;
}
this.setPage(this.leftPage, this.analystPages.get((oldLeft >= 0) ? oldLeft : 0));
if (this.analystPages.size() > 1) {
@@ -504,7 +477,38 @@ public class WindowAnalyst extends Window {
return this.current;
}
@SideOnly(Side.CLIENT)
public void setIndividual(final IIndividual ind) {
if (!this.isDatabase) {
if (ind == null) {
this.analystNone.show();
this.slideUpInv.hide();
} else {
this.analystNone.hide();
this.slideUpInv.show();
}
}
if (ind == this.current || (ind != null && this.current != null && ind.isGeneticEqual(this.current))) {
return;
}
final boolean systemChange = (this.current = ind) != null && ind.getGenome().getSpeciesRoot() != this.getSystem().getSpeciesRoot();
if (systemChange) {
this.currentSystem = Binnie.GENETICS.getSystem(ind.getGenome().getSpeciesRoot());
}
this.updatePages(systemChange);
}
public BreedingSystem getSystem() {
return this.currentSystem;
}
@SideOnly(Side.CLIENT)
public void setSystem(final BreedingSystem system) {
if (system == this.currentSystem) {
return;
}
this.currentSystem = system;
this.current = null;
this.updatePages(true);
}
}