34 public static interface AdvancedSimOption {
35 public String getId();
36 public float getPadAfter();
39 public static class SimOptionData {
42 public String tooltip;
43 public String iconKey =
null;
44 public boolean enabled =
true;
45 public String unmetReq =
null;
46 public float extraPad = 0f;
47 public SimOptionData(String
id, String text, String tooltip, String iconKey) {
50 this.tooltip = tooltip;
52 this.iconKey = iconKey;
55 public SimOptionData(String
id, String text, String tooltip,
boolean enabled, String unmetReq, String iconKey) {
59 this.tooltip = tooltip;
60 this.enabled = enabled;
61 this.unmetReq = unmetReq;
63 this.iconKey = iconKey;
68 public static class SimOptionSelectorData
implements AdvancedSimOption {
71 public List<SimOptionData> options =
new ArrayList<SimOptionData>();
72 public boolean compact =
true;
75 public SimOptionSelectorData(String
id, String text,
boolean compact) {
78 this.compact = compact;
80 public String getId() {
83 public float getPadAfter() {
88 public static class SimOptionCheckboxData
implements AdvancedSimOption {
91 public String tooltip;
92 public boolean showOnOffState =
true;
95 public boolean enabled =
true;
96 public String unmetReq =
null;
98 public SimOptionCheckboxData(String
id, String text, String tooltip) {
101 this.tooltip = tooltip;
103 public SimOptionCheckboxData(String
id, String text, String tooltip,
boolean enabled, String unmetReq) {
106 this.tooltip = tooltip;
107 this.enabled = enabled;
108 this.unmetReq = unmetReq;
110 public String getId() {
113 public float getPadAfter() {
119 public static class SimCategoryData {
122 public Color nameColor;
123 public String iconName;
125 public boolean custom =
false;
126 public boolean nonFactionCategory =
false;
127 public FactionAPI faction;
129 public List<String> variants;
130 public int maxVariants;
134 public static class SimUIStateData {
135 public String selectedCategory =
null;
136 public boolean showAdvanced =
false;
137 public int groupSize;
138 public Map<String, String> settings =
new LinkedHashMap<String, String>();
140 public void fromJSON(JSONObject json) {
141 selectedCategory = json.optString(
"selected",
null);
142 showAdvanced = json.optBoolean(
"advanced",
false);
143 groupSize = json.optInt(
"groupSize", 0);
144 settings =
new LinkedHashMap<String, String>();
145 JSONObject map = json.optJSONObject(
"settings");
147 for (String
id : JSONObject.getNames(map)) {
148 String value = map.optString(
id,
null);
150 settings.put(
id, value);
156 public JSONObject toJSON() throws JSONException {
157 JSONObject json =
new JSONObject();
158 if (selectedCategory !=
null) {
159 json.put(
"selected", selectedCategory);
161 json.put(
"advanced", showAdvanced);
162 json.put(
"groupSize", groupSize);
163 JSONObject map =
new JSONObject();
164 json.put(
"settings", map);
165 for (String
id : settings.keySet()) {
166 map.put(
id, (String) settings.get(
id));