@Override public void read(Json json, JsonValue jsonData) { try { colors = json.readValue("colors", Array.class, jsonData); fonts = json.readValue("fonts", Array.class, jsonData); classStyleMap = new OrderedMap<>(); for (JsonValue data : jsonData.get("classStyleMap").iterator()) { classStyleMap.put(ClassReflection.forName(data.name), json.readValue(Array.class, data)); } for (Array<StyleData> styleDatas : classStyleMap.values()) { for (StyleData styleData : styleDatas) { styleData.jsonData = this; } } customClasses = json.readValue("customClasses", Array.class, CustomClass.class, new Array<>(), jsonData); for (CustomClass customClass : customClasses) { customClass.setMain(main); } } catch (ReflectionException e) { Gdx.app.log(getClass().getName(), "Error parsing json data during file read", e); main.getDialogFactory().showDialogError("Error while reading file...", "Error while attempting to read save file.\nPlease ensure that file is not corrupted.\n\nOpen error log?"); } }
@Override public InventoryItem createNewInstance() { UsableItem returnValue = (UsableItem) super.createNewInstance(); returnValue.usesLeft = s_maxUses; returnValue.useCondition = useCondition; returnValue.targetType = targetType; returnValue.targetScript = targetScript; returnValue.effects = new OrderedMap<Effect, Array<EffectParameter>>(); for (Effect key : effects.keys()) { Array<EffectParameter> originalParams = effects.get(key); Array<EffectParameter> newCopyParam = new Array<EffectParameter>(); for (EffectParameter param : originalParams) { newCopyParam.add(param); } returnValue.effects.put(key, newCopyParam); } return returnValue; }
@SuppressWarnings("unchecked") public void readJsonObject(JsonObject element, OrderedMap<String, Object> jsonData) { Entries<String, Object> entries = jsonData.entries(); for (Entry<String, Object> entry : entries) { if (entry.value instanceof OrderedMap) { JsonObject obj = new JsonObject(); element.elements.put(entry.key, obj); // unchecked, but safe: readJsonObject(obj, (OrderedMap<String, Object>) entry.value); } else if (entry.value instanceof Array) { JsonArray arr = new JsonArray(); element.elements.put(entry.key, arr); // unchecked, but safe: readJsonArray(arr, (Array<OrderedMap<String, Object>>) entry.value); } else { element.values.put(entry.key, entry.value.toString()); } } }
/*** * Implement Json Serializable */ @SuppressWarnings("unchecked") @Override public void read(Json json, OrderedMap<String, Object> jsonData) { // read basic properties currentLevelId = json.readValue("currentLevelId", Integer.class, jsonData); credits = json.readValue("credits", Integer.class, jsonData); // change Json Hashmap default formatted strings to integers (levelId) Map<String, Integer> highScores = json.readValue("highScores", HashMap.class, Integer.class, jsonData); for (String levelIdAsString : highScores.keySet()) { int levelId = Integer.valueOf(levelIdAsString); Integer highScore = highScores.get(levelIdAsString); this.highScores.put(levelId, highScore); } // read the playerCharacter playerCharacter = json.readValue("playerCharacter", PlayerCharacter.class, jsonData); }
private static OrderedMap<String, GenPref> map(GenPref...objects){ OrderedMap<String, GenPref> prefs = new OrderedMap<>(); for(int i = 0; i < objects.length; i ++){ GenPref pref = (GenPref)objects[i]; prefs.put(pref.name, pref); } return prefs; }
Tilemap() { this.objects = new ObjectMap<>(); this.entrypoints = new ObjectMap<>(); this.tileLayers = new Array<>(true, 16); this.imageLayers = new Array<>(true, 16); this.tilesets = new OrderedMap<>(); }
public UIController(Environment parent, MultiRenderer renderer) { this.destroyed = false; this.renderer = renderer; this.environment = parent; this.removed = new ObjectSet<>(); this.events = new EventHelper(this); this.camera = new OrthographicCamera(OverworldController.RENDER_WIDTH, OverworldController.RENDER_HEIGHT); this.camera.position.x += OverworldController.RENDER_WIDTH / 2F; this.camera.position.y += OverworldController.RENDER_HEIGHT / 2F; this.camera.update(); this.aObj = new OrderedMap<>(); this.bObj = new OrderedMap<>(); }
private Text() { this.components = new OrderedMap<>(); this.instantiationTime = TimeUtils.millis(); this.stringBounds = new Pair<>(0, 0); this.spaceTaken = new Pair<>(-1F, -1F); this.transform = new Transform(); this.m_valuePair = new Pair<>(); this.m_drawnTransform = new Transform(); }
public StyleData(StyleData styleData, String styleName, Main main) { name = styleName; this.main = main; clazz = styleData.clazz; properties = new OrderedMap<>(); for (Entry<String, StyleProperty> entry : styleData.properties.entries()) { properties.put(entry.key, new StyleProperty(entry.value)); } deletable = true; }
public StyleData (Class clazz, String styleName, Main main) { name = styleName; this.main = main; this.clazz = clazz; properties = new OrderedMap<>(); deletable = true; resetProperties(); }
@Override public void read(Json json, JsonValue jsonData) { name = jsonData.getString("name"); properties = json.readValue("properties", OrderedMap.class, jsonData); deletable = jsonData.getBoolean("deletable"); try { clazz = ClassReflection.forName(jsonData.getString("clazz")); } catch (ReflectionException ex) { Gdx.app.error(getClass().toString(), "Error reading from serialized object" , ex); main.getDialogFactory().showDialogError("Read Error...","Error reading from serialized object.\n\nOpen log?"); } }
@Override protected <T> void addAsset(String fileName, Class<T> type, T asset) { super.addAsset(fileName, type, asset); // this is VERY ugly, but a bit more future proof in case of changes in the parent // than just copying the parent method ObjectMap<String, RefCountedContainer> typeToAssets = assets.get(type); if (!(typeToAssets instanceof OrderedMap)) { RefCountedContainer value = typeToAssets.get(fileName); typeToAssets = new OrderedMap<String, RefCountedContainer>(); typeToAssets.put(fileName, value); assets.put(type, typeToAssets); } }
public TrapType(FileHandle file) throws IOException { s_id = file.nameWithoutExtension().toLowerCase(Locale.ENGLISH); s_effects = new OrderedMap<Effect, Array<EffectParameter>>(); s_projectile = null; s_automaticOnHitAnimation = true; loadFromXML(file); }
@Override public void loadFromXML(FileHandle file) throws IOException { effects = new OrderedMap<Effect, Array<EffectParameter>>(); super.loadFromXML(file); if (s_weaponDamageMax < s_weaponDamageMin) { throw new GdxRuntimeException("Max damage cannot be less than min damage for "+getId()); } }
@Override public InventoryItem createNewInstance() { Weapon newInstance = (Weapon) super.createNewInstance(); newInstance.effects = new OrderedMap<Effect, Array<EffectParameter>>(); for (Entry<Effect, Array<EffectParameter>> entry : this.effects.entries()) { newInstance.effects.put(entry.key, entry.value); } return newInstance; }
public Perk(FileHandle file) throws IOException { s_id = file.nameWithoutExtension().toLowerCase(Locale.ENGLISH); s_modifiers = new Array<Modifier>(); s_effects = new OrderedMap<Effect, Array<EffectParameter>>(); s_isAttack = false; s_isActivated = false; s_automaticOnHitAnimation = true; projectile = null; loadFromXML(file); }
private void percentEncodeAndOrderParameters() { percentEncodedParameters = new OrderedMap<String, String>(); ObjectMap.Entries<String, String> entries = parameters.iterator(); while (entries.hasNext()) { ObjectMap.Entry<String, String> pair = entries.next(); percentEncodedParameters.put(PercentEncoder.encode(pair.key), PercentEncoder.encode(pair.value)); } }
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new ordered map with the given values. Not fail-fast - be careful when passing arguments, or it might * result in unexpected map values. */ @SuppressWarnings("unchecked") public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final OrderedMap<Key, Value> map = new OrderedMap<Key, Value>(); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
/** @param keyAndValues pairs of keys and values. Each value has to be proceeded by a key. * @return a new ordered map with the given values. Not fail-fast - be careful when passing arguments, or it might * result in unexpected map values. * @param <Key> type of map keys. * @param <Value> type of map values. */ @SuppressWarnings("unchecked") public static <Key, Value> OrderedMap<Key, Value> newOrderedMap(final Object... keyAndValues) { if (keyAndValues.length % 2 != 0) { throw new IllegalArgumentException("Total number of keys and values has to be even."); } final OrderedMap<Key, Value> map = new OrderedMap<Key, Value>(); for (int pairIndex = 0; pairIndex < keyAndValues.length; pairIndex++) { map.put((Key) keyAndValues[pairIndex], (Value) keyAndValues[++pairIndex]); } return map; }
/** @param map will be copied. * @return a new ordered map with the passed values. * @param <Key> type of map keys. * @param <Value> type of map values. */ public static <Key, Value> OrderedMap<Key, Value> toOrdered(final ObjectMap<? extends Key, ? extends Value> map) { final OrderedMap<Key, Value> orderedMap = new OrderedMap<Key, Value>(); for (final ObjectMap.Entry<? extends Key, ? extends Value> entry : map) { orderedMap.put(entry.key, entry.value); } return orderedMap; }
/** * Returns a Dictson instance with the text values obtained from dictionary.json file * * @param aLocale * @return a Dictson instance with the requested Locale or English if not supported */ @SuppressWarnings("unchecked") public static Dictson getInstance(Locale aLocale) { INSTANCE.wordsMap = new Json().fromJson(OrderedMap.class, Gdx.files.internal("data/dictionary.json")); INSTANCE.setLocale(getSupportedLocale(aLocale)); return INSTANCE; }
private void newPage () { Page page = new Page(); page.image = new Pixmap(pageWidth, pageHeight, pageFormat); page.root = new Node(0, 0, pageWidth, pageHeight, null, null, null); page.rects = new OrderedMap<String, Rectangle>(); pages.add(page); currPage = page; }
public void readJsonArray(JsonArray array, Array<OrderedMap<String, Object>> jsonArray) { for (OrderedMap<String, Object> jsonObject : jsonArray) { JsonObject obj = new JsonObject(); array.elements.add(obj); readJsonObject(obj, jsonObject); } }
/*** * Implement Json Serializable utility */ @Override public void read(Json json, OrderedMap<String, Object> jsonData) { playerModel = PlayerModel.valueOf (json.readValue("playerModel", String.class, jsonData)); spellType = SpellType.valueOf (json.readValue("spellType", String.class, jsonData)); shield = Shield.valueOf (json.readValue("shield", String.class, jsonData)); }
private void newPage() { PixmapPacker.Page localPage = new PixmapPacker.Page(this); localPage.image = new Pixmap(this.pageWidth, this.pageHeight, this.pageFormat); localPage.root = new PixmapPacker.Node(0, 0, this.pageWidth, this.pageHeight, null, null, null); localPage.rects = new OrderedMap(); this.pages.add(localPage); this.currPage = localPage; }
@Override public OrderedMap create (int length){ return new OrderedMap(length); }
public Scheduler(Environment env) { this.env = env; this.destroyed = false; this.tasks = new LongMap<>(); this.activeTasks = new OrderedMap<>(); }
/** * Internal method. * * <p>Responsible for DRYing the process of iterating * through each character within the string bounds.</p> * * <p>The consumer takes a pair of integers and a * TextComponent. The first integer is the index of the * component's first character in the entire text. The * second integer is the index of the current character, * local to the scope of the current TextComponent.</p> * * <p>Assume a component with the text content <code> * "Hello, world!"</code>. To point to the character * <code>o</code> at index 4, the consumer is provided * with 4 and the component holding the text * <code>(component.getText().charAt(4) = * 'o')</code></p> * * @param consumer the consumer that processes each * character */ private void processCharacters(BiConsumer<Pair<Integer>, TextComponent> consumer) { int boundL = this.getStringBounds().getA(); int boundR = this.getStringBounds().getB(); if (boundL < 0) { boundL = this.getText().length() - Math.abs(boundL); } if (boundR < 0) { boundR = this.getText().length() - Math.abs(boundR); } TextComponent first = boundL == 0 ? null : this.getTextComponentAt(boundL); TextComponent last = boundR == 0 ? null : this.getTextComponentAt(boundR); for (OrderedMap.Entry<Integer, TextComponent> entry : this.components.entries()) { if (first != null) { // if first is null, we've found the first component to iterate through if (entry.value != first) { continue; } first = null; } int localIndex = 0; if (boundL != 0 && entry.key < boundL) { localIndex += boundL - entry.key; } this.m_valuePair.setA(entry.key); for (int ind = localIndex; ind < entry.value.getText().length(); ind++) { this.m_valuePair.setB(ind); consumer.accept(this.m_valuePair, entry.value); if (boundR != 0 && entry.key + ind >= boundR) { return; } } if (entry.value == last) { return; } } }
public OrderedMap<Class, Array<StyleData>> getClassStyleMap() { return classStyleMap; }
public StyleData getSelectedStyle() { OrderedMap<Class, Array<StyleData>> classStyleMap = main.getProjectData().getJsonData().getClassStyleMap(); return classStyleMap.get(getSelectedClass()).get(styleSelectBox.getSelectedIndex()); }
@Override public void loadFromXML(FileHandle file) throws IOException { effects = new OrderedMap<Effect, Array<EffectParameter>>(); super.loadFromXML(file); }
public TwitterRequest build() { if (this.token != null && this.token.length() > 0) { put("oauth_token", this.token); } headerString = "OAuth "; String timestamp = Long.toString(TimeUtils.millis() / 1000L); put("oauth_consumer_key", this.consumerKey); put("oauth_nonce", timestamp + "NOUNCE"); put("oauth_signature_method", "HMAC-SHA1"); put("oauth_timestamp", timestamp); put("oauth_version", "1.0"); TwitterSignature twitterSignature = new TwitterSignature(requestType, this.url, this.consumerSecret, this.tokenSecret, parameters); String signature = twitterSignature.getSignature(); put("oauth_signature", signature); OrderedMap.Entries<String, String> entries = parameters.iterator(); while (entries.hasNext()) { OrderedMap.Entry<String, String> pair = entries.next(); if (pair.key.equals("oauth_token") || pair.key.equals("oauth_signature") || pair.key.equals("oauth_version") || pair.key.equals("oauth_consumer_key") || pair.key.equals("oauth_nonce") || pair.key.equals("oauth_signature_method") || pair.key.equals("oauth_timestamp")) { headerString += PercentEncoder.encode(pair.key) + "=\"" + PercentEncoder.encode(pair.value) + "\", "; } else { dataString += PercentEncoder.encode(pair.key) + "=" + PercentEncoder.encode(pair.value) + "&"; } } headerString = headerString.substring(0, headerString.length() - 2); if (dataString.length() > 0) { dataString = dataString.substring(0, dataString.length() - 1); } return this; }
/** @return an empty, new ordered map. */ public static <Key, Value> OrderedMap<Key, Value> newOrderedMap() { return new OrderedMap<Key, Value>(); }
/** @return a new ordered map with the passed values. */ public static <Key, Value> OrderedMap<Key, Value> newOrderedMap( final ObjectMap<? extends Key, ? extends Value> map) { return new OrderedMap<Key, Value>(map); }
/** @return a new ordered map with the passed values. */ public static <Key, Value> OrderedMap<Key, Value> toOrdered(final ObjectMap<? extends Key, ? extends Value> map) { return new OrderedMap<Key, Value>(map); }
/** @return an empty, new ordered map. * @param <Key> type of map keys. * @param <Value> type of map values. */ public static <Key, Value> OrderedMap<Key, Value> newOrderedMap() { return new OrderedMap<Key, Value>(); }
/** @param map will be copied. * @return a new ordered map with the passed values. * @param <Key> type of map keys. * @param <Value> type of map values. */ public static <Key, Value> OrderedMap<Key, Value> newOrderedMap( final OrderedMap<? extends Key, ? extends Value> map) { return new OrderedMap<Key, Value>(map); }
public OrderedMap<String, Rectangle> getRects () { return rects; }
protected OrderedMap<String, E> getEnumMap () { return enumMap; }
@Override public void read(Json json, OrderedMap<String, Object> jsonData) { readJsonObject(root, jsonData); }