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
6import com.fs.starfarer.api.ModSpecAPI;
7
8public class Description implements WithSourceMod {
9
10 public static enum Type {
11 SHIP,
12 WEAPON,
13 SHIP_SYSTEM,
14 RESOURCE,
15 ACTION_TOOLTIP,
16 PLANET,
17 ASTEROID,
18 FACTION,
19 TERRAIN,
20 GALLERY,
21 CUSTOM,
22 }
23
24 private Type type;
25 private String id;
26
27 private String text1 ="No description... yet", text2 ="No description... yet", text3 ="No description... yet";
28 private String text4 = null;
29 private String text5 = null;
30
31 public Description(String id, Type type) {
32 this.type = type;
33 this.id = id;
34 }
35
36 public String getUID() {
37 return id + "_" + type.name();
38 }
39
40 public String getText5() {
41 return text5;
42 }
43
44 public void setText5(String text5) {
45 this.text5 = text5;
46 }
47
48 public String getText4() {
49 return text4;
50 }
51
52 public void setText4(String text4) {
53 this.text4 = text4;
54 }
55 public boolean hasText4() {
56 return text4 != null && !text4.isEmpty();
57 }
58 public boolean hasText5() {
59 return text5 != null && !text5.isEmpty();
60 }
61
62 public String getText1() {
63 return text1;
64 }
65
66 public String getText1FirstPara() {
67 if (text1 != null) {
68 int index = text1.indexOf('\n');
69 if (index != -1) {
70 return text1.substring(0, index);
71 }
72 }
73 return text1;
74 }
75
76 public List<String> getText1Paras() {
77 return getParas(text1);
78 }
79 public List<String> getText2Paras() {
80 return getParas(text2);
81 }
82 public List<String> getText3Paras() {
83 return getParas(text3);
84 }
85 public List<String> getText4Paras() {
86 return getParas(text4);
87 }
88 public List<String> getText5Paras() {
89 return getParas(text5);
90 }
91
92 public List<String> getParas(String text) {
93 List<String> result = new ArrayList<String>();
94 if (text == null) return result;
95
96 String [] temp = text.split("\\n");
97 for (String p : temp) {
98 p = p.trim();
99 if (p.isEmpty()) continue;
100 result.add(p);
101 }
102 return result;
103 }
104
105
106 public void setText1(String text1) {
107 if (text1 == null || text1.equals("")) text1 = "No description... yet";
108 this.text1 = text1.trim();
109 }
110
111 public String getText2() {
112 return text2;
113 }
114
115 public void setText2(String text2) {
116 if (text2 == null || text2.equals("")) text2 = "No description... yet";
117 this.text2 = text2.trim();
118 }
119
120 public String getText3() {
121 return text3;
122 }
123
124 public void setText3(String text3) {
125 if (text3 == null || text3.equals("")) text3 = "No description... yet";
126 this.text3 = text3.trim();
127 }
128
129 public boolean hasText2() {
130 String str = getText2();
131 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
132 return true;
133 }
134 public boolean hasText1() {
135 String str = getText1();
136 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
137 return true;
138 }
139 public boolean hasText3() {
140 String str = getText3();
141 if (str == null || str.isEmpty() || str.equals("No description... yet")) return false;
142 return true;
143 }
144
145 private ModSpecAPI sourceMod = null;
147 return sourceMod;
148 }
149 public void setSourceMod(ModSpecAPI sourceMod) {
150 this.sourceMod = sourceMod;
151 }
152}
List< String > getParas(String text)
void setSourceMod(ModSpecAPI sourceMod)