Skip to content

Commit

Permalink
Adding database and soil localisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedelosk committed Oct 26, 2016
1 parent 7e9a87f commit a300bc0
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 33 deletions.
9 changes: 6 additions & 3 deletions src/main/java/binnie/botany/flower/ItemBotany.java
Expand Up @@ -129,10 +129,13 @@ private IAlleleFlowerSpecies getPrimarySpecies(final ItemStack itemstack) {
@Override
public String getItemStackDisplayName(final ItemStack itemstack) {
if (!itemstack.hasTagCompound()) {
return "Unknown";
return Binnie.Language.localise("item.botany.flower.corrupted.name");
}
final IIndividual individual = this.getIndividual(itemstack);
return (individual != null && individual.getGenome() != null) ? (individual.getDisplayName() + tag) : "Corrupted Flower";
IIndividual individual = this.getIndividual(itemstack);
if (individual != null && individual.getGenome() != null) {
return individual.getDisplayName() + (!tag.isEmpty() ? " " + Binnie.Language.localise("item.botany." + tag + ".name") : "");
}
return Binnie.Language.localise("item.botany.flower.corrupted.name");
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/binnie/botany/gardening/BlockSoil.java
Expand Up @@ -44,6 +44,7 @@ public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
super(Material.GROUND);
this.weedKilled = weedKilled;
setUnlocalizedName("botany.soil." + type.getName());
this.setCreativeTab(CreativeTabBotany.instance);
this.setRegistryName(blockName);
this.setTickRandomly(true);
Expand All @@ -52,6 +53,12 @@ public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
this.setSoundType(SoundType.GROUND);
this.type = type;
}


@Override
public String getUnlocalizedName() {
return super.getUnlocalizedName().replaceFirst("tile.", "");
}

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/binnie/botany/gardening/ItemSoil.java
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

Expand Down Expand Up @@ -38,10 +39,9 @@ public void addInformation(final ItemStack stack, final EntityPlayer playerIn, f
tooltip.add(TextFormatting.GREEN + Binnie.Language.localise("botany.soil.weedkiller"));
}
}

@Override
public String getItemStackDisplayName(final ItemStack stack) {
return this.type.name().substring(0, 1) + this.type.name().toLowerCase().substring(1);

public String getItemStackDisplayName(ItemStack stack){
return this.getUnlocalizedNameInefficiently(stack).trim();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/binnie/botany/genetics/ModuleGenetics.java
Expand Up @@ -35,8 +35,8 @@ public void preInit() {
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);

Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, "");
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "Pollen");
Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, " Germling");
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "pollen");
Botany.seed = new ItemBotany("seed", EnumFlowerStage.SEED, "germling");
Botany.database = new ItemDictionary();
Botany.encyclopedia = new ItemEncyclopedia(false);
Botany.encyclopediaIron = new ItemEncyclopedia(true);
Expand Down
@@ -1,10 +1,12 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.IWidget;
import forestry.api.genetics.IClassification;
import net.minecraft.util.text.TextFormatting;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,22 +28,22 @@ public PageBranchOverview(final IWidget parent, final DatabaseTab tab) {

@Override
public void onValueChanged(final IClassification branch) {
this.pageBranchOverview_branchName.setValue("§n" + branch.getName() + " Branch§r");
this.pageBranchOverview_branchScientific.setValue("§oApidae " + branch.getScientific() + "§r");
this.pageBranchOverview_branchAuthority.setValue("Discovered by §l" + branch.getMemberSpecies()[0].getAuthority() + "§r");
this.pageBranchOverview_branchName.setValue(TextFormatting.UNDERLINE + branch.getName() + Binnie.Language.localise("binniecore.gui.database.branch.branch"));
this.pageBranchOverview_branchScientific.setValue(TextFormatting.ITALIC + Binnie.Language.localise("binniecore.gui.database.branch.apidae") + " " + branch.getScientific());
this.pageBranchOverview_branchAuthority.setValue(Binnie.Language.localise("binniecore.gui.database.discovered") + " " + TextFormatting.BOLD + branch.getMemberSpecies()[0].getAuthority());
for (final IWidget widget : this.pageBranchOverview_branchDescription) {
this.deleteChild(widget);
}
this.pageBranchOverview_branchDescription.clear();
String desc = branch.getDescription();
if (desc == null || Objects.equals(desc, "")) {
desc = "No Description Provided.";
desc = Binnie.Language.localise("binniecore.gui.database.no.description");
}
String line = "";
final List<String> descLines = new ArrayList<>();
for (final String str : desc.split(" ")) {
if (CraftGUI.Render.textWidth(line + " " + str) > 134) {
descLines.add("§o" + line + "§r");
descLines.add(TextFormatting.ITALIC + line + TextFormatting.RESET);
line = "";
}
line = line + " " + str;
Expand Down
@@ -1,5 +1,6 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.IWidget;
Expand All @@ -18,7 +19,7 @@ public void onHandleEvent(final EventValueChanged<IAlleleSpecies> event) {

public PageBranchSpecies(final IWidget parent, final DatabaseTab tab) {
super(parent, tab);
this.pageBranchSpecies_title = new ControlTextCentered(this, 8.0f, "Species");
this.pageBranchSpecies_title = new ControlTextCentered(this, 8.0f, Binnie.Language.localise("binniecore.gui.database.species"));
this.addEventHandler(new EventValueChanged.Handler() {
@Override
public void onEvent(final EventValueChanged event) {
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/binnie/craftgui/mod/database/PageBreeder.java
@@ -1,10 +1,13 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.core.genetics.BreedingSystem;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.controls.page.ControlPage;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.minecraft.Window;
import net.minecraft.util.text.TextFormatting;

import com.mojang.authlib.GameProfile;

public class PageBreeder extends ControlPage<DatabaseTab> {
Expand All @@ -22,15 +25,15 @@ public void onPageRefresh() {
}
final BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem();
final String descriptor = system.getDescriptor();
new ControlTextCentered(this, 8.0f, "§n" + system.getDescriptor() + " Profile§r");
new ControlTextCentered(this, 75.0f, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " Species");
new ControlTextCentered(this, 8.0f, TextFormatting.UNDERLINE + system.getDescriptor() + " " + Binnie.Language.localise("binniecore.gui.database.breeder.profile"));
new ControlTextCentered(this, 75.0f, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " " + Binnie.Language.localise("binniecore.gui.database.species"));
new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
new ControlTextCentered(this, 115.0f, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " Branches");
new ControlTextCentered(this, 115.0f, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " " + Binnie.Language.localise("binniecore.gui.database.breeder.branches"));
new ControlBreedingProgress(this, 20, 127, 102, 14, system, system.discoveredBranchPercentage);
if (system.discoveredSecretCount > 0) {
new ControlTextCentered(this, 155.0f, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " Secret Species");
new ControlTextCentered(this, 155.0f, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " " + Binnie.Language.localise("binniecore.gui.database.breeder.species.secret"));
}
new ControlTextCentered(this, 32.0f, this.player.getName());
new ControlTextCentered(this, 44.0f, "§o" + system.getEpitome() + "§r");
new ControlTextCentered(this, 44.0f, TextFormatting.ITALIC + system.getEpitome());
}
}
@@ -1,18 +1,20 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.core.genetics.BreedingSystem;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.controls.core.Control;
import binnie.craftgui.core.IWidget;
import net.minecraft.util.text.TextFormatting;

public class PageBreederStats extends Control {
String player;

public PageBreederStats(final IWidget parent, final int w, final int h, final String player) {
super(parent, 0.0f, 0.0f, w, h);
this.player = player;
final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, "§nStats§r");
final ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, TextFormatting.UNDERLINE + Binnie.Language.localise("binniecore.gui.database.breeder.stats"));
final BreedingSystem system = ((WindowAbstractDatabase) this.getSuperParent()).getBreedingSystem();
}
}
@@ -1,5 +1,6 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.IWidget;
Expand All @@ -11,7 +12,7 @@ public class PageSpeciesMutations extends PageSpecies {

public PageSpeciesMutations(final IWidget parent, final DatabaseTab tab) {
super(parent, tab);
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, "Further Mutations");
this.pageSpeciesFurther_Title = new ControlTextCentered(this, 8.0f, Binnie.Language.localise("binniecore.gui.database.mutations.further"));
this.pageSpeciesFurther_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Further);
}

Expand Down
@@ -1,5 +1,6 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.CraftGUI;
Expand All @@ -8,6 +9,7 @@
import binnie.craftgui.core.geometry.IPoint;
import binnie.craftgui.core.geometry.TextJustification;
import forestry.api.genetics.IAlleleSpecies;
import net.minecraft.util.text.TextFormatting;

import java.util.Objects;

Expand All @@ -28,7 +30,7 @@ public PageSpeciesOverview(final IWidget parent, final DatabaseTab tab) {
this.controlName = new ControlTextCentered(this, 8.0f, "");
this.controlScientific = new ControlTextCentered(this, 32.0f, "");
this.controlAuthority = new ControlTextCentered(this, 44.0f, "");
this.controlComplexity = new ControlTextCentered(this, 56.0f, "");
this.controlComplexity = new ControlTextCentered(this, 68.0f, "");
this.controlDescription = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.MiddleCenter);
this.controlSignature = new ControlText(this, new IArea(8.0f, 84.0f, this.getSize().x() - 16.0f, 0.0f), "", TextJustification.BottomRight);
}
Expand All @@ -39,15 +41,15 @@ public void onValueChanged(final IAlleleSpecies species) {
this.controlInd2.setSpecies(species, EnumDiscoveryState.Show);
final String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
final String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
this.controlName.setValue("§n" + species.getName() + "§r");
this.controlScientific.setValue("§o" + branchBinomial + " " + species.getBinomial() + "§r");
this.controlAuthority.setValue("Discovered by §l" + species.getAuthority() + "§r");
this.controlComplexity.setValue("Complexity: " + species.getComplexity());
this.controlName.setValue(TextFormatting.UNDERLINE + species.getName());
this.controlScientific.setValue(TextFormatting.ITALIC + branchBinomial + " " + species.getBinomial());
this.controlAuthority.setValue(Binnie.Language.localise("binniecore.gui.database.discovered") + ": " + TextFormatting.BOLD + species.getAuthority());
this.controlComplexity.setValue(Binnie.Language.localise("binniecore.gui.database.overview.complexity") + ": " + species.getComplexity());
final String desc = species.getDescription();
String descBody = "§o";
String descBody = TextFormatting.ITALIC.toString();
String descSig = "";
if (desc == null || Objects.equals(desc, "")) {
descBody += "No Description Provided.";
descBody += Binnie.Language.localise("binniecore.gui.database.no.description");
} else {
final String[] descStrings = desc.split("\\|");
descBody += descStrings[0];
Expand All @@ -58,8 +60,8 @@ public void onValueChanged(final IAlleleSpecies species) {
descSig += descStrings[descStrings.length - 1];
}
}
this.controlDescription.setValue(descBody + "§r");
this.controlSignature.setValue(descSig + "§r");
this.controlDescription.setValue(descBody + TextFormatting.RESET);
this.controlSignature.setValue(descSig);
final float descHeight = CraftGUI.Render.textHeight(this.controlDescription.getValue(), this.controlDescription.getSize().x());
this.controlSignature.setPosition(new IPoint(this.controlSignature.pos().x(), this.controlDescription.getPosition().y() + descHeight + 10.0f));
}
Expand Down
@@ -1,5 +1,6 @@
package binnie.craftgui.mod.database;

import binnie.Binnie;
import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.IWidget;
Expand All @@ -11,7 +12,7 @@ public class PageSpeciesResultant extends PageSpecies {

public PageSpeciesResultant(final IWidget parent, final DatabaseTab tab) {
super(parent, tab);
this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8.0f, "Resultant Mutations");
this.pageSpeciesResultant_Title = new ControlTextCentered(this, 8.0f, Binnie.Language.localise("binniecore.gui.database.mutations.resultant"));
this.pageSpeciesResultant_List = new ControlMutationBox(this, 4, 20, 136, 152, ControlMutationBox.Type.Resultant);
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/binniecore/lang/en_US.lang
Expand Up @@ -212,6 +212,18 @@ binniecore.gui.database.nodescription=No Description Provided.
binniecore.gui.database.mode.species=Species
binniecore.gui.database.mode.branches=Branches
binniecore.gui.database.mode.breeder=Breeder
binniecore.gui.database.species=Species
binniecore.gui.database.no.description=No Description Provided.
binniecore.gui.database.discovered=Discovered by
binniecore.gui.database.overview.complexity=Complexity
binniecore.gui.database.breeder.profile=Profile
binniecore.gui.database.breeder.species.secret=Secret Species
binniecore.gui.database.breeder.branches=Branches
binniecore.gui.database.breeder.stats=Stats
binniecore.gui.database.mutations.further=Further Mutations
binniecore.gui.database.mutations.resultant=Resultant Mutations
binniecore.gui.database.branch.branch=Branch
binniecore.gui.database.branch.apidae=Apidae

binniecore.gui.temperature.short=Temp.
binniecore.gui.humidity.short=Humid.
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/botany/lang/en_US.lang
Expand Up @@ -22,6 +22,10 @@ botany.plant.weeds_very_long=Weed Very Long
botany.plant.dead_flower=Dead Flower
botany.plant.decaying_flower=Decaying Flower

item.botany.germling.name=Germling
item.botany.pollen.name=Pollen
item.botany.flower.corrupted.name=Corrupted Flower

item.trowelWood.name=Wooden Trowel
item.trowelStone.name=Stone Trowel
item.trowelIron.name=Iron Trowel
Expand Down

0 comments on commit a300bc0

Please sign in to comment.