diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java index 2059cbc..b83dea5 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Droplist.java @@ -36,7 +36,7 @@ public class Droplist extends JSONElement { public static class DroppedItem { //Available from parsed state; public String item_id = null; - public Double chance = null; + public String chance = null; public Integer quantity_min = null; public Integer quantity_max = null; @@ -114,7 +114,8 @@ public class Droplist extends JSONElement { Map droppedItemJson = (Map)droppedItemJsonObj; DroppedItem droppedItem = new DroppedItem(); droppedItem.item_id = (String) droppedItemJson.get("itemID"); - if (droppedItemJson.get("chance") != null) droppedItem.chance = JSONElement.parseChance(droppedItemJson.get("chance").toString()); + //if (droppedItemJson.get("chance") != null) droppedItem.chance = JSONElement.parseChance(droppedItemJson.get("chance").toString()); + droppedItem.chance = (String) droppedItemJson.get("chance"); Map droppedItemQtyJson = (Map) droppedItemJson.get("quantity"); if (droppedItemQtyJson != null) { droppedItem.quantity_min = JSONElement.getInteger((Number) droppedItemQtyJson.get("min")); @@ -217,7 +218,8 @@ public class Droplist extends JSONElement { } else if (droppedItem.item_id != null) { droppedItemJson.put("itemID", droppedItem.item_id); } - if (droppedItem.chance != null) droppedItemJson.put("chance", JSONElement.printJsonChance(droppedItem.chance)); + //if (droppedItem.chance != null) droppedItemJson.put("chance", JSONElement.printJsonChance(droppedItem.chance)); + if (droppedItem.chance != null) droppedItemJson.put("chance", droppedItem.chance); if (droppedItem.quantity_min != null || droppedItem.quantity_max != null) { Map quantityJson = new LinkedHashMap(); droppedItemJson.put("quantity", quantityJson); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java index ab6de8d..de1ced3 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/AboutEditor.java @@ -26,7 +26,9 @@ public class AboutEditor extends Editor { private static final long serialVersionUID = 6230549148222457139L; public static final String WELCOME_STRING = - "
" + + "" + + "" + + "" + "![]() | " +
"Welcome to "+ATContentStudio.APP_NAME+" "+ATContentStudio.APP_VERSION+" " + @@ -51,7 +53,7 @@ public class AboutEditor extends Editor { " " + "Contributors: " + "Quentin Delvallet " + - "Žižkin " + + "Žižkin " + " " + "This project uses the following libraries: " + "JSON.simple by Yidong Fang & Chris Nokleberg. " + @@ -79,7 +81,7 @@ public class AboutEditor extends Editor { "jsoup by Jonathan Hedley " + "License: MIT License " + " " + - "A slightly modified version of General PO Parser by Balázs Tóth " + + "A slightly modified version of General PO Parser by Bal�zs T�th " + "License: GPL v3 " + " " + "A slightly modified version of Minify.java by Charles Bihis " + diff --git a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java index edb5912..093dd93 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java @@ -348,6 +348,138 @@ public abstract class Editor extends JPanel implements ProjectElementListener { return spinner; } + + private static final String percent = "%"; + private static final String ratio = "x/y"; + public static JComponent addChanceField(JPanel pane, String label, String initialValue, String defaultValue, boolean editable, final FieldUpdateListener listener) { + int defaultChance = 1; + int defaultMaxChance = 100; + if (defaultValue != null) { + if (defaultValue.contains("/")) { + int c = defaultValue.indexOf('/'); + try { defaultChance = Integer.parseInt(defaultValue.substring(0, c)); } catch (NumberFormatException nfe) {}; + try { defaultMaxChance = Integer.parseInt(defaultValue.substring(c+1)); } catch (NumberFormatException nfe) {}; + } else { + try { defaultChance = Integer.parseInt(defaultValue); } catch (NumberFormatException nfe) {}; + } + } + + boolean currentFormIsRatio = true; + int chance = defaultChance; + int maxChance = defaultMaxChance; + if (initialValue != null) { + if (initialValue.contains("/")) { + int c = initialValue.indexOf('/'); + try { chance = Integer.parseInt(initialValue.substring(0, c)); } catch (NumberFormatException nfe) {}; + try { maxChance = Integer.parseInt(initialValue.substring(c+1)); } catch (NumberFormatException nfe) {}; + } else { + try { + chance = Integer.parseInt(initialValue); + currentFormIsRatio = false; + } catch (NumberFormatException nfe) {}; + } + } + + final JPanel tfPane = new JPanel(); + tfPane.setLayout(new JideBoxLayout(tfPane, JideBoxLayout.LINE_AXIS, 6)); + JLabel tfLabel = new JLabel(label); + tfPane.add(tfLabel, JideBoxLayout.FIX); + + final JComboBox |