Text colors wrap to EnumChatFormatting

* Fix #22
Text colors wrap to EnumChatFormatting

* Fix #22
Fixed code error with "paragraph" char in EnumColor
This commit is contained in:
Alexander Kornilov authored and marcin212 committed 2017-04-27 15:06:23 +02:00
1 parent f402cb155f
commit 856f08b752
33 files changed
+403 -340

No files matched your search

@@ -5,6 +5,7 @@ import binnie.core.craftgui.IWidget;
import binnie.core.craftgui.controls.ControlText;
import binnie.core.craftgui.controls.ControlTextCentered;
import forestry.api.genetics.IClassification;
import net.minecraft.util.EnumChatFormatting;
import java.util.ArrayList;
import java.util.List;
@@ -25,9 +26,9 @@ public class PageBranchOverview extends PageBranch {
@Override
public void onValueChanged(IClassification branch) {
pageBranchOverview_branchName.setValue("§n" + branch.getName() + " Branch§r");
pageBranchOverview_branchScientific.setValue("§oApidae " + branch.getScientific() + "§r");
pageBranchOverview_branchAuthority.setValue("Discovered by §l" + branch.getMemberSpecies()[0].getAuthority() + "§r");
pageBranchOverview_branchName.setValue(EnumChatFormatting.UNDERLINE + branch.getName() + " Branch" + EnumChatFormatting.RESET);
pageBranchOverview_branchScientific.setValue(EnumChatFormatting.ITALIC + "Apidae " + branch.getScientific() + EnumChatFormatting.RESET);
pageBranchOverview_branchAuthority.setValue("Discovered by " + EnumChatFormatting.BOLD + branch.getMemberSpecies()[0].getAuthority() + EnumChatFormatting.RESET);
for (IWidget widget : pageBranchOverview_branchDescription) {
deleteChild(widget);
}
@@ -42,7 +43,7 @@ public class PageBranchOverview extends PageBranch {
List<String> descLines = new ArrayList<String>();
for (String str : desc.split(" ")) {
if (CraftGUI.Render.textWidth(line + " " + str) > 134) {
descLines.add("§o" + line + "§r");
descLines.add(EnumChatFormatting.ITALIC + line + EnumChatFormatting.RESET);
line = "";
}
line = line + " " + str;
@@ -6,6 +6,7 @@ import binnie.core.craftgui.controls.page.ControlPage;
import binnie.core.craftgui.minecraft.Window;
import binnie.core.genetics.BreedingSystem;
import com.mojang.authlib.GameProfile;
import net.minecraft.util.EnumChatFormatting;
public class PageBreeder extends ControlPage<DatabaseTab> {
private GameProfile player;
@@ -23,7 +24,7 @@ public class PageBreeder extends ControlPage<DatabaseTab> {
BreedingSystem system = ((WindowAbstractDatabase) Window.get(this)).getBreedingSystem();
String descriptor = system.getDescriptor();
new ControlTextCentered(this, 8.0f, "§n" + system.getDescriptor() + " Profile§r");
new ControlTextCentered(this, 8.0f, EnumChatFormatting.UNDERLINE + system.getDescriptor() + " Profile" + EnumChatFormatting.RESET);
new ControlTextCentered(this, 75.0f, "" + system.discoveredSpeciesCount + "/" + system.totalSpeciesCount + " Species");
new ControlBreedingProgress(this, 20, 87, 102, 14, system, system.discoveredSpeciesPercentage);
new ControlTextCentered(this, 115.0f, "" + system.discoveredBranchCount + "/" + system.totalBranchCount + " Branches");
@@ -33,6 +34,6 @@ public class PageBreeder extends ControlPage<DatabaseTab> {
new ControlTextCentered(this, 155.0f, "" + system.discoveredSecretCount + "/" + system.totalSecretCount + " Secret Species");
}
new ControlTextCentered(this, 32.0f, player.getName());
new ControlTextCentered(this, 44.0f, "§o" + system.getEpitome() + "§r");
new ControlTextCentered(this, 44.0f, EnumChatFormatting.ITALIC + system.getEpitome() + EnumChatFormatting.RESET);
}
}
@@ -5,6 +5,7 @@ import binnie.core.craftgui.controls.ControlText;
import binnie.core.craftgui.controls.ControlTextCentered;
import binnie.core.craftgui.controls.core.Control;
import binnie.core.genetics.BreedingSystem;
import net.minecraft.util.EnumChatFormatting;
// TODO unused class?
public class PageBreederStats extends Control {
@@ -13,7 +14,7 @@ public class PageBreederStats extends Control {
public PageBreederStats(IWidget parent, int w, int h, String player) {
super(parent, 0.0f, 0.0f, w, h);
this.player = player;
ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, "§nStats§r");
ControlText pageBranchOverview_branchName = new ControlTextCentered(this, 8.0f, EnumChatFormatting.UNDERLINE + "§tats" + EnumChatFormatting.RESET);
BreedingSystem system = ((WindowAbstractDatabase) getSuperParent()).getBreedingSystem();
}
}
@@ -8,6 +8,7 @@ import binnie.core.craftgui.geometry.IArea;
import binnie.core.craftgui.geometry.IPoint;
import binnie.core.craftgui.geometry.TextJustification;
import forestry.api.genetics.IAlleleSpecies;
import net.minecraft.util.EnumChatFormatting;
public class PageSpeciesOverview extends PageSpecies {
private ControlText controlName;
@@ -37,12 +38,12 @@ public class PageSpeciesOverview extends PageSpecies {
controlInd2.setSpecies(species, EnumDiscoveryState.Show);
String branchBinomial = (species.getBranch() != null) ? species.getBranch().getScientific() : "<Unknown>";
String branchName = (species.getBranch() != null) ? species.getBranch().getName() : "Unknown";
controlName.setValue("§n" + species.getName() + "§r");
controlScientific.setValue("§o" + branchBinomial + " " + species.getBinomial() + "§r");
controlAuthority.setValue("Discovered by §l" + species.getAuthority() + "§r");
controlName.setValue(EnumChatFormatting.UNDERLINE + species.getName() + EnumChatFormatting.RESET);
controlScientific.setValue(EnumChatFormatting.ITALIC + branchBinomial + " " + species.getBinomial() + EnumChatFormatting.RESET);
controlAuthority.setValue("Discovered by " + EnumChatFormatting.BOLD + species.getAuthority() + EnumChatFormatting.RESET);
controlComplexity.setValue("Complexity: " + species.getComplexity());
String desc = species.getDescription();
String descBody = "§o";
String descBody = EnumChatFormatting.ITALIC.toString();
String descSig = "";
if (desc == null || desc == "") {
@@ -58,8 +59,8 @@ public class PageSpeciesOverview extends PageSpecies {
}
}
controlDescription.setValue(descBody + "§r");
controlSignature.setValue(descSig + "§r");
controlDescription.setValue(descBody + EnumChatFormatting.RESET);
controlSignature.setValue(descSig + EnumChatFormatting.RESET);
float descHeight = CraftGUI.Render.textHeight(controlDescription.getValue(), controlDescription.getSize().x());
controlSignature.setPosition(new IPoint(controlSignature.pos().x(), controlDescription.getPosition().y() + descHeight + 10.0f));
}
@@ -1,11 +1,7 @@
//
// Decompiled by Procyon v0.5.30
//
package binnie.core.craftgui.minecraft;
public enum EnumColor
{
// TODO replace to EnumChatFormatting?
public enum EnumColor {
Black("Black", 0, '0'),
DarkBlue("Dark Blue", 170, '1'),
DarkGreen("Dark Green", 43520, '2'),
@@ -23,9 +19,9 @@ public enum EnumColor
Yellow("Yellow", 16777045, 'e'),
White("White", 16777215, 'f');
int colour;
String name;
char code;
protected int colour;
protected String name;
protected char code;
EnumColor(String name, int colour, char code) {
this.name = name;
@@ -38,7 +34,7 @@ public enum EnumColor
}
public String getCode() {
return "§" + code;
return "\u00a7" + code;
}
@Override
@@ -1,5 +1,7 @@
package binnie.core.machines.inventory;
import net.minecraft.util.EnumChatFormatting;
enum AccessDirection {
Both,
In,
@@ -59,15 +61,15 @@ enum AccessDirection {
public String getTextColour() {
switch (this) {
case Both:
return "§a";
return EnumChatFormatting.GREEN.toString();
case In:
return "§e";
return EnumChatFormatting.YELLOW.toString();
case Neither:
return "§c";
return EnumChatFormatting.RED.toString();
}
return "§b";
return EnumChatFormatting.AQUA.toString();
}
public int getShadeColour() {