Skip to content

Commit 9251fd1

Browse files
committed
Save/Load for "Animations"
1 parent 2c95ce8 commit 9251fd1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/net/fexcraft/app/fmt/utils/SaveLoad.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import net.fexcraft.app.fmt.ui.general.DialogBox;
2727
import net.fexcraft.app.fmt.ui.general.NFC.AfterTask;
2828
import net.fexcraft.app.fmt.ui.general.NFC.ChooserMode;
29+
import net.fexcraft.app.fmt.utils.Animator.Animation;
2930
import net.fexcraft.app.fmt.utils.Settings.Setting;
3031
import net.fexcraft.app.fmt.wrappers.GroupCompound;
3132
import net.fexcraft.app.fmt.wrappers.PolygonWrapper;
@@ -229,6 +230,24 @@ public static JsonObject modelToJTMT(GroupCompound root, boolean export){
229230
group.addProperty("texture_size_y", list.textureY);
230231
group.addProperty("texture_scale", list.textureS);
231232
}
233+
if(!list.animations.isEmpty()){
234+
JsonArray animations = new JsonArray();
235+
for(Animation ani : list.animations){
236+
JsonObject jsn = new JsonObject();
237+
jsn.addProperty("id", ani.id);
238+
JsonArray settings = new JsonArray();
239+
for(Setting setting : ani.settings){
240+
JsonObject sett = new JsonObject();
241+
sett.addProperty("id", setting.getId());
242+
sett.addProperty("type", setting.getType().name().toLowerCase());
243+
sett.add("value", setting.save());
244+
settings.add(sett);
245+
}
246+
jsn.add("settings", settings);
247+
animations.add(jsn);
248+
}
249+
group.add("animations", animations);
250+
}
232251
}
233252
group.addProperty("name", list.id);
234253
for(PolygonWrapper wrapper : list){
@@ -320,6 +339,24 @@ public static GroupCompound getModel(File from, JsonObject obj, boolean ggr){
320339
JsonArray polygons = group.get("polygons").getAsJsonArray();
321340
for(JsonElement elm : polygons){ list.add(JsonToTMT.parseWrapper(compound, elm.getAsJsonObject())); }
322341
compound.getCompound().put(entry.getKey(), list);
342+
if(group.has("animations")){
343+
JsonArray arr = group.get("animations").getAsJsonArray();
344+
for(JsonElement elm : arr){
345+
JsonObject animjsn = elm.getAsJsonObject();
346+
Animation anim = Animator.get(animjsn.get("id").getAsString());
347+
JsonArray settin = animjsn.get("settings").getAsJsonArray();
348+
for(JsonElement elm0 : settin){
349+
JsonObject sett = elm0.getAsJsonObject();
350+
Setting setting = new Setting(sett.get("type").getAsString(), sett.get("id").getAsString(), sett.get("value"));
351+
for(Setting satt : anim.settings){
352+
if(satt.getId().equals(setting.getId()) && satt.getType() == setting.getType()){
353+
satt.setValue(setting.getValue());
354+
}
355+
}
356+
}
357+
list.animations.add(anim);
358+
}
359+
}
323360
}
324361
catch(Exception e){
325362
e.printStackTrace();

0 commit comments

Comments
 (0)