Starsector API
Loading...
Searching...
No Matches
Description.java
Go to the documentation of this file.
1package com.fs.starfarer.api.loading;
2
3import java.util.ArrayList;
4import java.util.List;
5
6public class Description {
7
8 public static enum Type {
9 SHIP,
10 WEAPON,
11 SHIP_SYSTEM,
12 RESOURCE,
13 ACTION_TOOLTIP,
14 PLANET,
15 ASTEROID,
16 FACTION,
17 TERRAIN,
18 CUSTOM,
19 }
20
21 private Type type;
22 private String id;
23
24 private String text1 ="No description... yet", text2 ="No description... yet", text3 ="No description... yet";
25 private String text4 = null;
26
27 public Description(String id, Type type) {
28 this.type = type;
29 this.id = id;
30 }
31
32 public String getUID() {
33 return id + "_" + type.name();
34 }
35
36 public String getText4() {
37 return text4;
38 }
39
40 public void setText4(String text4) {
41 this.text4 = text4;
42 }
43 public boolean hasText4() {
44 return text4 != null && !text4.isEmpty();
45 }
46
47 public String getText1() {
48 return text1;
49 }
50
51 public String getText1FirstPara() {
52 if (text1 != null) {
53 int index = text1.indexOf('\n');
54 if (index != -1) {
55 return text1.substring(0, index);
56 }
57 }
58 return text1;
59 }
60
61 public List<String> getText1Paras() {
62 List<String> result = new ArrayList<String>();
63 if (text1 == null) return result;
64
65 String [] temp = text1.split("\\n");
66 for (String p : temp) {
67 p = p.trim();
68 if (p.isEmpty()) continue;
69 result.add(p);
70 }
71 return result;
72 }
73
74
75 public void setText1(String text1) {
76 if (text1 == null || text1.equals("")) text1 = "No description... yet";
77 this.text1 = text1.trim();
78 }
79
80 public String getText2() {
81 return text2;
82 }
83
84 public void setText2(String text2) {
85 if (text2 == null || text2.equals("")) text2 = "No description... yet";
86 this.text2 = text2.trim();
87 }
88
89 public String getText3() {
90 return text3;
91 }
92
93 public void setText3(String text3) {
94 if (text3 == null || text3.equals("")) text3 = "No description... yet";
95 this.text3 = text3.trim();
96 }
97
98 public boolean hasText2() {
99 String str = getText2();
100 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
101 return true;
102 }
103 public boolean hasText1() {
104 String str = getText1();
105 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
106 return true;
107 }
108 public boolean hasText3() {
109 String str = getText3();
110 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
111 return true;
112 }
113
114
115}