aboutsummaryrefslogtreecommitdiff
path: root/src/Java/binnie/craftgui/mod/database/PageBranchOverview.java
blob: 57ddc63fabdf408ef96ae42421ea80fcc5c36cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package binnie.craftgui.mod.database;

import binnie.craftgui.controls.ControlText;
import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.CraftGUI;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.renderer.Renderer;
import forestry.api.genetics.IAlleleSpecies;
import forestry.api.genetics.IClassification;
import java.util.ArrayList;
import java.util.List;

public class PageBranchOverview
  extends PageBranch
{
  private ControlText pageBranchOverview_branchName;
  private ControlText pageBranchOverview_branchScientific;
  private ControlText pageBranchOverview_branchAuthority;
  
  public PageBranchOverview(IWidget parent, DatabaseTab tab)
  {
    super(parent, tab);
    
    this.pageBranchOverview_branchName = new ControlTextCentered(this, 8.0F, "");
    
    this.pageBranchOverview_branchScientific = new ControlTextCentered(this, 32.0F, "");
    this.pageBranchOverview_branchAuthority = new ControlTextCentered(this, 44.0F, "");
  }
  
  private List<ControlText> pageBranchOverview_branchDescription = new ArrayList();
  
  public void onValueChanged(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");
    for (IWidget widget : this.pageBranchOverview_branchDescription) {
      deleteChild(widget);
    }
    this.pageBranchOverview_branchDescription.clear();
    
    String desc = branch.getDescription();
    if ((desc == null) || (desc == "")) {
      desc = "No Description Provided.";
    }
    String line = "";
    
    List<String> descLines = new ArrayList();
    for (String str : desc.split(" "))
    {
      if (CraftGUI.Render.textWidth(line + " " + str) > 134)
      {
        descLines.add("§o" + line + "§r");
        line = "";
      }
      line = line + " " + str;
    }
    descLines.add(line);
    
    int i = 0;
    for (String dLine : descLines) {
      this.pageBranchOverview_branchDescription.add(new ControlTextCentered(this, 84 + 12 * i++, dLine));
    }
  }
}