001package com.fs.starfarer.api.loading; 002 003import java.awt.Color; 004import java.util.ArrayList; 005import java.util.List; 006 007import org.json.JSONArray; 008import org.json.JSONException; 009import org.json.JSONObject; 010 011public class CampaignPingSpec { 012// "danger":{ 013// "sounds":["ui_new_radar_icon", "", ""], 014// "color":"textEnemyColor", 015// "range":100, 016// "duration":1, 017// "invert":false, 018// 019// "num":3, 020// "delay":0.5, 021// }, 022 023 024 private String id; 025 private List<String> sounds = new ArrayList<String>(); 026 private Color color; 027 private float minRange, range, duration, delay = 1f, width, alphaMult = 1f, inFraction = 0.1f; 028 private boolean invert; 029 private boolean useFactionColor; 030 private int num = 1; 031 032 033 034 public CampaignPingSpec() { 035 super(); 036 } 037 038 public CampaignPingSpec(String id, Color color, JSONObject json) throws JSONException { 039 this.id = id; 040 041 this.color = color; 042 043 sounds = new ArrayList<String>(); 044 JSONArray arr = json.optJSONArray("sounds"); 045 if (arr != null) { 046 for (int i = 0; i < arr.length(); i++) { 047 sounds.add(arr.getString(i)); 048 } 049 } 050 051 inFraction = (float) json.optDouble("inFraction", 0.1f); 052 minRange = (float) json.optDouble("minRange", 0f); 053 range = (float) json.getDouble("range"); 054 width = (float) json.getDouble("width"); 055 duration = (float) json.getDouble("duration"); 056 delay = (float) json.optDouble("delay", 1f); 057 alphaMult = (float) json.optDouble("alphaMult", 1f); 058 num = json.optInt("num", 1); 059 060 invert = json.optBoolean("invert", false); 061 useFactionColor = json.optBoolean("useFactionColor", false); 062 } 063 064 public float getAlphaMult() { 065 return alphaMult; 066 } 067 068 public float getInFraction() { 069 return inFraction; 070 } 071 072 public boolean isUseFactionColor() { 073 return useFactionColor; 074 } 075 076 public String getId() { 077 return id; 078 } 079 080 public List<String> getSounds() { 081 return sounds; 082 } 083 084 public Color getColor() { 085 return color; 086 } 087 088 public float getRange() { 089 return range; 090 } 091 092 public float getDuration() { 093 return duration; 094 } 095 096 public float getDelay() { 097 return delay; 098 } 099 100 public boolean isInvert() { 101 return invert; 102 } 103 104 public int getNum() { 105 return num; 106 } 107 108 public float getWidth() { 109 return width; 110 } 111 112 public float getMinRange() { 113 return minRange; 114 } 115 116 public void setId(String id) { 117 this.id = id; 118 } 119 120 public void setSounds(List<String> sounds) { 121 this.sounds = sounds; 122 } 123 124 public void setColor(Color color) { 125 this.color = color; 126 } 127 128 public void setMinRange(float minRange) { 129 this.minRange = minRange; 130 } 131 132 public void setRange(float range) { 133 this.range = range; 134 } 135 136 public void setDuration(float duration) { 137 this.duration = duration; 138 } 139 140 public void setDelay(float delay) { 141 this.delay = delay; 142 } 143 144 public void setWidth(float width) { 145 this.width = width; 146 } 147 148 public void setAlphaMult(float alphaMult) { 149 this.alphaMult = alphaMult; 150 } 151 152 public void setInFraction(float inFraction) { 153 this.inFraction = inFraction; 154 } 155 156 public void setInvert(boolean invert) { 157 this.invert = invert; 158 } 159 160 public void setUseFactionColor(boolean useFactionColor) { 161 this.useFactionColor = useFactionColor; 162 } 163 164 public void setNum(int num) { 165 this.num = num; 166 } 167 168 169} 170 171 172 173 174 175 176