diff --git a/src/net/fexcraft/app/fmt/ui/editor/ModelGroupEditor.java b/src/net/fexcraft/app/fmt/ui/editor/ModelGroupEditor.java index 925a8a22..3a8929e1 100644 --- a/src/net/fexcraft/app/fmt/ui/editor/ModelGroupEditor.java +++ b/src/net/fexcraft/app/fmt/ui/editor/ModelGroupEditor.java @@ -116,7 +116,7 @@ public void run(){ protected boolean processButtonClick(int x, int y, boolean left){ if(FMTB.MODEL.getSelected().isEmpty()) return true; if(!left){ - FMTB.showDialogbox(this.getText(), "test", null, DialogBox.NOTHING, null); + FMTB.showDialogbox(this.getText(), "ok", null, DialogBox.NOTHING, null); this.setText("", true); return true; } @@ -129,16 +129,16 @@ public void updateTextField(){ if(anim == null){ FMTB.showDialogbox("Animation not found!", "ok", null, DialogBox.NOTHING, null); return; - } anim.copy(); + } final Animation ani = anim.copy(); ArrayList lists = FMTB.MODEL.getDirectlySelectedGroups(); AfterTask task = new AfterTask(){ @Override public void run(){ for(TurboList list : lists){ - list.animations.add(anim.copy()); + list.animations.add(ani); } FMTB.MODEL.updateFields(); } - }; task.settings = anim.settings; + }; task.settings = ani.settings; UserInterface.SETTINGSBOX.show("Animator Settings", task); } }.setText("null", true).setRowCol(9, 0)); @@ -207,11 +207,10 @@ public void addSubElements(){ @Override protected boolean processButtonClick(int x, int y, boolean left){ if(left){ - Animation anim = list.animations.get(j); this.deselect(); - FMTB.MODEL.updateFields(); if(anim == null) return true; + Animation anim = list.animations.get(j); this.deselect(); if(anim == null) return true; AfterTask task = new AfterTask(){ - @Override public void run(){ FMTB.MODEL.updateFields(); } - }; task.settings = anim.settings; UserInterface.SETTINGSBOX.reset(); + @Override public void run(){ anim.onSettingsUpdate(); FMTB.MODEL.updateFields(); } + }; task.settings = anim.settings; FMTB.MODEL.updateFields(); UserInterface.SETTINGSBOX.show("[" + anim.id + "] Settings", task); } else{ diff --git a/src/net/fexcraft/app/fmt/ui/general/SettingsBox.java b/src/net/fexcraft/app/fmt/ui/general/SettingsBox.java index d02ac5eb..c48e6204 100644 --- a/src/net/fexcraft/app/fmt/ui/general/SettingsBox.java +++ b/src/net/fexcraft/app/fmt/ui/general/SettingsBox.java @@ -146,8 +146,8 @@ public void show(Object... objects){ @Override public void reset(){ - this.visible = false; this.elements.removeIf(pre -> !pre.id.equals("confirm")); - this.Confirm.setVisible(false); this.Cancel.setVisible(false); this.settings.clear(); + this.visible = false; this.elements.removeIf(pre -> !(pre.id.equals("confirm") || pre.id.equals("cancel"))); + this.Confirm.setVisible(false); this.Cancel.setVisible(false); this.settings.clear(); this.updateFields(); } } diff --git a/src/net/fexcraft/app/fmt/utils/Animator.java b/src/net/fexcraft/app/fmt/utils/Animator.java index 3c59ffd7..e19ab667 100644 --- a/src/net/fexcraft/app/fmt/utils/Animator.java +++ b/src/net/fexcraft/app/fmt/utils/Animator.java @@ -4,6 +4,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; + import net.fexcraft.app.fmt.utils.Settings.Setting; import net.fexcraft.app.fmt.utils.Settings.Type; import net.fexcraft.app.fmt.wrappers.PolygonWrapper; @@ -13,11 +14,15 @@ public class Animator { public static final HashSet nani = new HashSet<>(); static { - nani.add(new Rotator("rotator", new Setting(Type.FLOAT, "x", 0f), new Setting(Type.FLOAT, "y", 0f), new Setting(Type.FLOAT, "z", 0f))); + nani.add(new Rotator("rotator", new Setting(Type.FLOAT, "x", 0f), new Setting(Type.FLOAT, "y", 0f), new Setting(Type.FLOAT, "z", 0f), + new Setting(Type.FLOAT, "x_min", -360f), new Setting(Type.FLOAT, "y_min", -360f), new Setting(Type.FLOAT, "z_min", -360f), + new Setting(Type.FLOAT, "x_max", 360f), new Setting(Type.FLOAT, "y_max", 360f), new Setting(Type.FLOAT, "z_max", 360f), + new Setting(Type.BOOLEAN, "loop", true), new Setting(Type.BOOLEAN, "opposite_on_end", false))); nani.add(new Translator("translator", new Setting(Type.FLOAT, "x", 0f), new Setting(Type.FLOAT, "y", 0f), new Setting(Type.FLOAT, "z", 0f), new Setting(Type.FLOAT, "x_min",-1f), new Setting(Type.FLOAT, "y_min", -1f), new Setting(Type.FLOAT, "z_min", -1f), new Setting(Type.FLOAT, "x_max", 1f), new Setting(Type.FLOAT, "y_max", 1f), new Setting(Type.FLOAT, "z_max", 1f), - new Setting(Type.BOOLEAN, "loop", true))); + new Setting(Type.BOOLEAN, "loop", true), new Setting(Type.BOOLEAN, "opposite_on_end", false))); + //nani.add(new Transparency("glass", new Setting(Type.RGB, "color", RGB.BLUE))); } public static abstract class Animation { @@ -32,6 +37,7 @@ public Animation(String id, Setting... settings){ public abstract void pre(TurboList list); public abstract void post(TurboList list); protected abstract Animation COPY(String id, Setting[] settings); + public void onSettingsUpdate(){} public Animation copy(){ Setting[] settings = new Setting[this.settings.size()]; @@ -43,6 +49,10 @@ public Setting get(String id, Setting[] list){ for(Setting setting : list) if(setting.getId().equals(id)) return setting; return null; } + public Setting get(String id, Iterable list){ + for(Setting setting : list) if(setting.getId().equals(id)) return setting; return null; + } + } public static Set get(){ @@ -55,22 +65,53 @@ public static Animation get(String string){ public static class Rotator extends Animation { - private Setting x, y, z; + private Setting x, y, z, x_max, y_max, z_max, x_min, y_min, z_min, loop, ooe; + private int xdir = 1, ydir = 1, zdir = 1; private float xpass, ypass, zpass; public Rotator(String id, Setting... settings){ super(id, settings); x = get("x", settings); y = get("y", settings); z = get("z", settings); + x_min = get("x_min", settings); y_min = get("y_min", settings); z_min = get("z_min", settings); + x_max = get("x_max", settings); y_max = get("y_max", settings); z_max = get("z_max", settings); + loop = get("loop", settings); ooe = get("opposite_on_end", settings); } @Override public void pre(TurboList list){ - for(PolygonWrapper wrap : list){ - wrap.addPosRot(false, x.getValue(), y.getValue(), z.getValue()); + xpass += xdir * x.getFloatValue(); ypass += ydir * y.getFloatValue(); zpass += zdir * z.getFloatValue(); + // + if(xpass > x_max.getFloatValue()){ + xpass = x_max.getFloatValue(); if(ooe.getBooleanValue()) xdir = -xdir; + if(loop.getBooleanValue()) xpass = x_min.getFloatValue(); + } + if(xpass < x_min.getFloatValue()){ + xpass = x_min.getFloatValue(); if(ooe.getBooleanValue()) xdir = -xdir; + if(loop.getBooleanValue()) xpass = x_max.getFloatValue(); + } + // + if(ypass > y_max.getFloatValue()){ + ypass = y_max.getFloatValue(); if(ooe.getBooleanValue()) ydir = -ydir; + if(loop.getBooleanValue()) ypass = y_min.getFloatValue(); } + if(ypass < y_min.getFloatValue()){ + ypass = y_min.getFloatValue(); if(ooe.getBooleanValue()) ydir = -ydir; + if(loop.getBooleanValue()) ypass = y_max.getFloatValue(); + } + // + if(zpass > z_max.getFloatValue()){ + zpass = z_max.getFloatValue(); if(ooe.getBooleanValue()) zdir = -zdir; + if(loop.getBooleanValue()) zpass = z_min.getFloatValue(); + } + if(zpass < z_min.getFloatValue()){ + zpass = z_min.getFloatValue(); if(ooe.getBooleanValue()) zdir = -zdir; + if(loop.getBooleanValue()) zpass = z_max.getFloatValue(); + } + // + for(PolygonWrapper wrap : list){ wrap.addPosRot(false, xpass, ypass, zpass); } } @Override public void post(TurboList list){ - // + for(PolygonWrapper wrap : list){ wrap.addPosRot(false, -xpass, -ypass, -zpass); } } @Override @@ -82,29 +123,46 @@ protected Animation COPY(String id, Setting[] settings){ public static class Translator extends Animation { - private Setting x, y, z, x_max, y_max, z_max, x_min, y_min, z_min, loop; + private Setting x, y, z, x_max, y_max, z_max, x_min, y_min, z_min, loop, ooe; private int xdir = 1, ydir = 1, zdir = 1; private float xpass, ypass, zpass; public Translator(String id, Setting... settings){ - super(id, settings); - x = get("x", settings); y = get("y", settings); z = get("z", settings); + super(id, settings); x = get("x", settings); y = get("y", settings); z = get("z", settings); x_min = get("x_min", settings); y_min = get("y_min", settings); z_min = get("z_min", settings); x_max = get("x_max", settings); y_max = get("y_max", settings); z_max = get("z_max", settings); - loop = get("loop", settings); + loop = get("loop", settings); ooe = get("opposite_on_end", settings); } @Override public void pre(TurboList list){ xpass += xdir * x.getFloatValue(); ypass += ydir * y.getFloatValue(); zpass += zdir * z.getFloatValue(); // - if(xpass > x_max.getFloatValue()){ xpass = x_max.getFloatValue(); if(loop.getBooleanValue()) xdir = -xdir; } - if(xpass < x_min.getFloatValue()){ xpass = x_min.getFloatValue(); if(loop.getBooleanValue()) xdir = -xdir; } + if(xpass > x_max.getFloatValue()){ + xpass = x_max.getFloatValue(); if(ooe.getBooleanValue()) xdir = -xdir; + if(loop.getBooleanValue()) xpass = x_min.getFloatValue(); + } + if(xpass < x_min.getFloatValue()){ + xpass = x_min.getFloatValue(); if(ooe.getBooleanValue()) xdir = -xdir; + if(loop.getBooleanValue()) xpass = x_max.getFloatValue(); + } // - if(ypass > y_max.getFloatValue()){ ypass = y_max.getFloatValue(); if(loop.getBooleanValue()) ydir = -ydir; } - if(ypass < y_min.getFloatValue()){ ypass = y_min.getFloatValue(); if(loop.getBooleanValue()) ydir = -ydir; } + if(ypass > y_max.getFloatValue()){ + ypass = y_max.getFloatValue(); if(ooe.getBooleanValue()) ydir = -ydir; + if(loop.getBooleanValue()) ypass = y_min.getFloatValue(); + } + if(ypass < y_min.getFloatValue()){ + ypass = y_min.getFloatValue(); if(ooe.getBooleanValue()) ydir = -ydir; + if(loop.getBooleanValue()) ypass = y_max.getFloatValue(); + } // - if(zpass > z_max.getFloatValue()){ zpass = z_max.getFloatValue(); if(loop.getBooleanValue()) zdir = -zdir; } - if(zpass < z_min.getFloatValue()){ zpass = z_min.getFloatValue(); if(loop.getBooleanValue()) zdir = -zdir; } + if(zpass > z_max.getFloatValue()){ + zpass = z_max.getFloatValue(); if(ooe.getBooleanValue()) zdir = -zdir; + if(loop.getBooleanValue()) zpass = z_min.getFloatValue(); + } + if(zpass < z_min.getFloatValue()){ + zpass = z_min.getFloatValue(); if(ooe.getBooleanValue()) zdir = -zdir; + if(loop.getBooleanValue()) zpass = z_max.getFloatValue(); + } // for(PolygonWrapper wrap : list){ wrap.addPosRot(true, xpass, ypass, zpass); } } @@ -120,5 +178,41 @@ protected Animation COPY(String id, Setting[] settings){ } } + + /*public static class Transparency extends Animation { + + private RGB color; + + public Transparency(String id, Setting... settings){ + super(id, settings); this.onSettingsUpdate(); + } + + @Override + public void pre(TurboList list){ + GL11.glPushMatrix(); + GL11.glDepthMask(false); + GL11.glEnable(GL11.GL_ALPHA_TEST); + color.glColorApply(); + } + + @Override + public void post(TurboList list){ + RGB.glColorReset(); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDepthMask(true); + GL11.glPopMatrix(); + } + + @Override + protected Animation COPY(String id, Setting[] settings){ + return new Transparency(id, settings); + } + + @Override + public void onSettingsUpdate(){ + color = get("color", settings).getValue(); color.alpha = 0.2f; + } + + }*/ } diff --git a/src/net/fexcraft/app/fmt/utils/GGR.java b/src/net/fexcraft/app/fmt/utils/GGR.java index 88dded7d..0d960ab8 100644 --- a/src/net/fexcraft/app/fmt/utils/GGR.java +++ b/src/net/fexcraft/app/fmt/utils/GGR.java @@ -114,7 +114,17 @@ private void acceptInputKeyboard(){ } private String getKeyName(int i){ - return GGR.isShiftDown() ? Keyboard.getKeyName(i) : Keyboard.getKeyName(i).toLowerCase(); + return GGR.isShiftDown() ? i < 12 ? getSpecialChar(i) : Keyboard.getKeyName(i) : Keyboard.getKeyName(i).toLowerCase(); + } + + private String getSpecialChar(int i){ + switch(i){ + case 2: return "!"; case 3: return "@"; + case 4: return "#"; case 5: return "$"; + case 6: return "%"; case 7: return "^"; + case 8: return "&"; case 9: return "*"; + case 10: return "("; case 11: return ")"; + } return Keyboard.getKeyName(i); } private boolean clickedL, clickedR, panning; @@ -213,7 +223,11 @@ else if(panning){ } public static boolean isShiftDown(){ - return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_FUNCTION); + } + + public static boolean iControlDown(){ + return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); } } \ No newline at end of file diff --git a/src/net/fexcraft/app/fmt/utils/HelperCollector.java b/src/net/fexcraft/app/fmt/utils/HelperCollector.java index d3c4c1af..88ed1be8 100644 --- a/src/net/fexcraft/app/fmt/utils/HelperCollector.java +++ b/src/net/fexcraft/app/fmt/utils/HelperCollector.java @@ -37,7 +37,7 @@ public static final GroupCompound load(File file, ExImPorter exim, Map