mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-22 05:02:34 +00:00
Feature/code improve (#221)
* Code improvement for genetics.api Code improvement for genetics.core Fix missed localization for info of Lab Stand * Code improvement for genetics.genetics package
This commit is contained in:
1 parent
9e1ec59b86
commit
3ff4957a10
105 files changed
+1500
-1443
No files matched your search
@@ -36,29 +36,29 @@ public class AnalystPageDatabase extends ControlAnalystPage {
|
||||
private final ControlScrollableContent scroll;
|
||||
boolean isMaster;
|
||||
|
||||
public AnalystPageDatabase(final IWidget parent, final Area area, final BreedingSystem system, final boolean isMaster) {
|
||||
public AnalystPageDatabase(IWidget parent, Area area, BreedingSystem system, boolean isMaster) {
|
||||
super(parent, area);
|
||||
this.isMaster = isMaster;
|
||||
final int cOfSystem = system.getColour();
|
||||
final int cr = (0xFF0000 & cOfSystem) >> 16;
|
||||
final int cg = (0xFF00 & cOfSystem) >> 8;
|
||||
final int cb = 0xFF & cOfSystem;
|
||||
int cOfSystem = system.getColour();
|
||||
int cr = (0xFF0000 & cOfSystem) >> 16;
|
||||
int cg = (0xFF00 & cOfSystem) >> 8;
|
||||
int cb = 0xFF & cOfSystem;
|
||||
float brightness = 0.1f * cb / 255.0f + 0.35f * cr / 255.0f + 0.55f * cg / 255.0f;
|
||||
brightness = 0.3f / brightness;
|
||||
if (brightness > 1.0f) {
|
||||
brightness = 1.0f;
|
||||
}
|
||||
final int newColour = (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
|
||||
this.setColour(newColour);
|
||||
int newColour = (int) (cr * brightness) * 65536 + (int) (cg * brightness) * 256 + (int) (cb * brightness);
|
||||
setColor(newColour);
|
||||
int y = 4;
|
||||
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColour(this.getColour());
|
||||
new ControlTextCentered(this, y, TextFormatting.UNDERLINE + getTitle()).setColor(getColor());
|
||||
y += 16;
|
||||
new ControlTextEdit(this, 20, y, this.width() - 40, 16) {
|
||||
new ControlTextEdit(this, 20, y, width() - 40, 16) {
|
||||
@Override
|
||||
public void onTextEdit(final String value) {
|
||||
final Collection<IAlleleSpecies> options = new ArrayList<>();
|
||||
AnalystPageDatabase.this.getSpecies(system);
|
||||
for (final IAlleleSpecies species : AnalystPageDatabase.this.getSpecies(system)) {
|
||||
public void onTextEdit(String value) {
|
||||
Collection<IAlleleSpecies> options = new ArrayList<>();
|
||||
getSpecies(system);
|
||||
for (IAlleleSpecies species : getSpecies(system)) {
|
||||
if (value != null) {
|
||||
if (!Objects.equals(value, "")) {
|
||||
if (!species.getName().toLowerCase().contains(value.toLowerCase())) {
|
||||
@@ -68,87 +68,87 @@ public class AnalystPageDatabase extends ControlAnalystPage {
|
||||
}
|
||||
options.add(species);
|
||||
}
|
||||
AnalystPageDatabase.this.scroll.deleteAllChildren();
|
||||
AnalystPageDatabase.this.scroll.setScrollableContent(AnalystPageDatabase.this.getItemScrollList(system, options));
|
||||
scroll.deleteAllChildren();
|
||||
scroll.setScrollableContent(getItemScrollList(system, options));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.setColour(5592405);
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().inset(1));
|
||||
RenderUtil.setColour(AnalystPageDatabase.this.getColour());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea());
|
||||
super.renderTextField();
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, getArea().inset(1));
|
||||
RenderUtil.setColour(AnalystPageDatabase.this.getColor());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, getArea());
|
||||
renderTextField();
|
||||
}
|
||||
};
|
||||
y += 22;
|
||||
new Panel(this, 3, y - 1, this.width() - 6, this.height() - y - 8 + 2, MinecraftGUI.PanelType.TabOutline).setColour(this.getColour());
|
||||
final boolean textView = false;
|
||||
final Collection<IAlleleSpecies> options = this.getSpecies(system);
|
||||
for (final IAlleleSpecies species : options) {
|
||||
final String height = system.getAlleleName(EnumTreeChromosome.HEIGHT, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT));
|
||||
final String fertility = system.getAlleleName(EnumTreeChromosome.FERTILITY, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY));
|
||||
final String yield = system.getAlleleName(EnumTreeChromosome.YIELD, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.YIELD));
|
||||
final String sappiness = system.getAlleleName(EnumTreeChromosome.SAPPINESS, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS));
|
||||
final String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION));
|
||||
new Panel(this, 3, y - 1, width() - 6, height() - y - 8 + 2, MinecraftGUI.PanelType.TabOutline).setColor(getColor());
|
||||
boolean textView = false;
|
||||
Collection<IAlleleSpecies> options = getSpecies(system);
|
||||
for (IAlleleSpecies species : options) {
|
||||
String height = system.getAlleleName(EnumTreeChromosome.HEIGHT, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.HEIGHT));
|
||||
String fertility = system.getAlleleName(EnumTreeChromosome.FERTILITY, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.FERTILITY));
|
||||
String yield = system.getAlleleName(EnumTreeChromosome.YIELD, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.YIELD));
|
||||
String sappiness = system.getAlleleName(EnumTreeChromosome.SAPPINESS, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.SAPPINESS));
|
||||
String maturation = system.getAlleleName(EnumTreeChromosome.MATURATION, system.getIndividual(species.getUID()).getGenome().getActiveAllele(EnumTreeChromosome.MATURATION));
|
||||
}
|
||||
if (textView) {
|
||||
this.scroll = new ControlListBox<IAlleleSpecies>(this, 4, y, this.width() - 8, this.height() - y - 8 - 20, 0) {
|
||||
scroll = new ControlListBox<IAlleleSpecies>(this, 4, y, width() - 8, height() - y - 8 - 20, 0) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
super.initialise();
|
||||
this.setOptions(options);
|
||||
setOptions(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWidget createOption(final IAlleleSpecies v, final int y) {
|
||||
return new Control(this.getContent(), 0, y, this.width(), 12) {
|
||||
public IWidget createOption(IAlleleSpecies v, int y) {
|
||||
return new Control(getContent(), 0, y, width(), 12) {
|
||||
IAlleleSpecies value = v;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
RenderUtil.drawText(this.getArea(), TextJustification.MIDDLE_CENTER, this.value.getName(), 16777215);
|
||||
RenderUtil.drawText(getArea(), TextJustification.MIDDLE_CENTER, value.getName(), 16777215);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
} else {
|
||||
this.scroll = new ControlScrollableContent(this, 4, y, this.width() - 8, this.height() - y - 8, 0);
|
||||
this.scroll.setScrollableContent(this.getItemScrollList(system, options));
|
||||
scroll = new ControlScrollableContent(this, 4, y, width() - 8, height() - y - 8, 0);
|
||||
scroll.setScrollableContent(getItemScrollList(system, options));
|
||||
}
|
||||
new ControlScrollBar(this, this.scroll.xPos() + this.scroll.width() - 6, this.scroll.yPos() + 3, 3, this.scroll.height() - 6, this.scroll) {
|
||||
new ControlScrollBar(this, scroll.xPos() + scroll.width() - 6, scroll.yPos() + 3, 3, scroll.height() - 6, scroll) {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
if (!this.isEnabled()) {
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
RenderUtil.drawGradientRect(this.getArea(), 1140850688 + AnalystPageDatabase.this.getColour(), 1140850688 + AnalystPageDatabase.this.getColour());
|
||||
RenderUtil.drawSolidRect(this.getRenderArea(), AnalystPageDatabase.this.getColour());
|
||||
RenderUtil.drawGradientRect(getArea(), 1140850688 + AnalystPageDatabase.this.getColor(), 1140850688 + AnalystPageDatabase.this.getColor());
|
||||
RenderUtil.drawSolidRect(getRenderArea(), AnalystPageDatabase.this.getColor());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private IWidget getItemScrollList(final BreedingSystem system, final Collection<IAlleleSpecies> options) {
|
||||
return new Control(this.scroll, 0, 0, this.scroll.width(), this.scroll.height()) {
|
||||
private IWidget getItemScrollList(BreedingSystem system, Collection<IAlleleSpecies> options) {
|
||||
return new Control(scroll, 0, 0, scroll.width(), scroll.height()) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
final int maxBiomePerLine = (this.width() - 4 + 2) / 18;
|
||||
final int biomeListX = -6 + (this.width() - (maxBiomePerLine * 18 - 2)) / 2;
|
||||
int maxBiomePerLine = (width() - 4 + 2) / 18;
|
||||
int biomeListX = -6 + (width() - (maxBiomePerLine * 18 - 2)) / 2;
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
for (final IAlleleSpecies species : options) {
|
||||
final IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species));
|
||||
for (IAlleleSpecies species : options) {
|
||||
IIndividual ind = system.getSpeciesRoot().templateAsIndividual(system.getSpeciesRoot().getTemplate(species));
|
||||
new ControlIndividualDisplay(this, biomeListX + dx, 2 + dy, ind) {
|
||||
@Override
|
||||
public void initialise() {
|
||||
this.addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
addSelfEventHandler(new EventMouse.Down.Handler() {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onEvent(final EventMouse.Down event) {
|
||||
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
|
||||
public void onEvent(EventMouse.Down event) {
|
||||
WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
|
||||
window.setIndividual(ind);
|
||||
}
|
||||
});
|
||||
@@ -157,15 +157,15 @@ public class AnalystPageDatabase extends ControlAnalystPage {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onRenderBackground(int guiWidth, int guiHeight) {
|
||||
final WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
|
||||
WindowAnalyst window = (WindowAnalyst) AnalystPageDatabase.this.getTopParent();
|
||||
if (window.getIndividual() != null && window.getIndividual().getGenome().getPrimary() == species) {
|
||||
RenderUtil.setColour(15658734);
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
|
||||
RenderUtil.setColour(AnalystPageDatabase.this.getColour());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, this.getArea().outset(1));
|
||||
} else if (this.calculateIsMouseOver()) {
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, getArea().outset(1));
|
||||
RenderUtil.setColour(AnalystPageDatabase.this.getColor());
|
||||
CraftGUI.render.texture(CraftGUITexture.TabOutline, getArea().outset(1));
|
||||
} else if (calculateIsMouseOver()) {
|
||||
RenderUtil.setColour(15658734);
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, this.getArea().outset(1));
|
||||
CraftGUI.render.texture(CraftGUITexture.TabSolid, getArea().outset(1));
|
||||
}
|
||||
super.onRenderBackground(guiWidth, guiHeight);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class AnalystPageDatabase extends ControlAnalystPage {
|
||||
dy += 18;
|
||||
}
|
||||
}
|
||||
this.setSize(new Point(this.width(), 4 + dy + 18));
|
||||
setSize(new Point(width(), 4 + dy + 18));
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -186,9 +186,9 @@ public class AnalystPageDatabase extends ControlAnalystPage {
|
||||
return I18N.localise("genetics.gui.analyst.registry.title");
|
||||
}
|
||||
|
||||
private Collection<IAlleleSpecies> getSpecies(final BreedingSystem system) {
|
||||
final Collection<IAlleleSpecies> species = new ArrayList<>();
|
||||
species.addAll(this.isMaster ? system.getAllSpecies() : system.getDiscoveredSpecies(this.getWindow().getWorld(), this.getWindow().getPlayer().getGameProfile()));
|
||||
private Collection<IAlleleSpecies> getSpecies(BreedingSystem system) {
|
||||
Collection<IAlleleSpecies> species = new ArrayList<>();
|
||||
species.addAll(isMaster ? system.getAllSpecies() : system.getDiscoveredSpecies(getWindow().getWorld(), getWindow().getPlayer().getGameProfile()));
|
||||
return species;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user