Starsector API
Loading...
Searching...
No Matches
MessageIntel.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.intel;
2
3import java.awt.Color;
4import java.util.ArrayList;
5import java.util.List;
6
7import com.fs.starfarer.api.ui.LabelAPI;
8import com.fs.starfarer.api.ui.TooltipMakerAPI;
9import com.fs.starfarer.api.util.Misc;
10
21public class MessageIntel extends BaseIntelPlugin {
22
23 public static class MessageLineData {
24 protected String text;
25 protected Color color;
26 protected String [] highlights;
27 protected Color [] colors;
28 public MessageLineData(String text) {
29 this(text, null, null, (Color [])null);
30 }
31 public MessageLineData(String text, Color color) {
32 this(text, color, null, (Color [])null);
33 }
34 public MessageLineData(String text, Color color, String [] highlights, Color ... colors) {
35 this.text = text;
36 this.color = color;
37 this.highlights = highlights;
38 this.colors = colors;
39 }
40 }
41
42// protected String text;
43// protected Color color;
44// protected String [] highlights;
45// protected Color [] colors;
46//
47// protected String text2;
48// protected Color color2;
49// protected String [] highlights2;
50// protected Color [] colors2;
51
52 protected List<MessageLineData> lines = new ArrayList<MessageLineData>();
53 protected String icon;
54 protected String sound;
55 protected String extra;
56
57 public MessageIntel() {
58
59 }
60
61 public MessageIntel(String text) {
62 this(text, null, null, (Color [])null);
63 }
64 public MessageIntel(String text, Color color) {
65 this(text, color, null, (Color [])null);
66 }
67 public MessageIntel(String text, Color color, String [] highlights, Color ... colors) {
68 addLine(text, color, highlights, colors);
69 }
70
71 public void addLine(String text) {
72 addLine(text, null, null, (Color []) null);
73 }
74 public void addLine(String text, Color color) {
75 addLine(text, color, null, (Color []) null);
76 }
77 public void addLine(String text, Color color, String [] highlights, Color ... colors) {
78 MessageLineData line = new MessageLineData(text, color, highlights, colors);
79 lines.add(line);
80 }
81
82 public void clearLines() {
83 lines.clear();
84 }
85
86 @Override
87 public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
88 float pad = 3f;
89 boolean first = true;
90 for (MessageLineData line : lines) {
91 Color c = line.color;
92 if (c == null) {
93 c = Misc.getTextColor();
94// if (first) {
95// c = Misc.getTextColor();
96// } else {
97// c = Misc.getGrayColor();
98// }
99 }
100
101 float currPad = pad;
102 if (first) {
103 currPad = 0f;
104 }
105
106 if (line.highlights != null) {
107 LabelAPI label = info.addPara(line.text, currPad, c, c, line.highlights);
108 label.setHighlight(line.highlights);
109 label.setHighlightColors(line.colors);
110 } else {
111 info.addPara(line.text, c, currPad);
112 }
113
114
115 if (!first) pad = 0f;
116 first = false;
117 }
118
119 }
120
121 public String getIcon() {
122 return icon;
123 }
124
125 public void setIcon(String icon) {
126 this.icon = icon;
127 }
128
129 public String getSound() {
130 return sound;
131 }
132
133 public void setSound(String sound) {
134 this.sound = sound;
135 }
136
137 @Override
138 public String getCommMessageSound() {
139 if (sound != null) {
140 return sound;
141 }
142 return getSoundMinorMessage();
143 }
144
145 public String getExtra() {
146 return extra;
147 }
148
149 public void setExtra(String extra) {
150 this.extra = extra;
151 }
152
153}
154
155
156
157
158
159
160
161
MessageIntel(String text, Color color, String[] highlights, Color ... colors)
void addLine(String text, Color color, String[] highlights, Color ... colors)
void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode)