Skip to content

Commit

Permalink
Added ability to rename helper/preview models.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fexcraft committed Apr 19, 2020
1 parent ffab8b5 commit 53195c8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions resources/lang/default.lang
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ editor.preview.container.position_sixteenth=Position (1/16th)
editor.preview.container.rotation=Rotation (degrees)
editor.preview.container.scale_full=Scale (full units / OpenGL)
editor.preview.container.scale_sixteenth=Scale (1/16th OpenGL)
editor.preview.container.name=Helper/Preview Name
editor.texture.palette=Palette / Color
editor.texture.palette.inputfield=HEX Color Input
editor.texture.palette.large=Large Color Palette
Expand Down Expand Up @@ -278,6 +279,7 @@ error.dialog_title=Error
error.feature_not_available_yet=This feature is not available yet.
error.feature_not_reimplemented_yet=This feature is not reimplemented yet.
error.no_polygon_selected=no polygon/s selected
error.no_preview_selected=no helper/preview selected
error.todo=//TODO

# Other
5 changes: 3 additions & 2 deletions src/net/fexcraft/app/fmt/FMTB.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
* */
public class FMTB {

public static final String VERSION = "2.3.1";
public static final String VERSION = "2.4.0";
public static final String deftitle = "[FPS:%s] Fexcraft Modelling Toolbox " + VERSION + " - %s";
public static final String CLID = "587016218196574209";
//
Expand All @@ -99,7 +99,7 @@ public class FMTB {
public static GroupCompound MODEL = new GroupCompound(null);
public static Timer BACKUP_TIMER, TEX_UPDATE_TIMER;
private static int disk_update;
public static String NO_POLYGON_SELECTED;
public static String NO_POLYGON_SELECTED, NO_PREVIEW_SELECTED;
//
public static final ST_Timer timer = new ST_Timer();
public float delta, accumulator = 0f, interval = 1f / 30f, alpha;
Expand Down Expand Up @@ -150,6 +150,7 @@ public void run() throws InterruptedException, IOException, NoSuchMethodExceptio
ggr = new GGR(0, 4, 4); ggr.rotation.xCoord = 45;
//
NO_POLYGON_SELECTED = Translator.translate("error.no_polygon_selected");
NO_PREVIEW_SELECTED = Translator.translate("error.no_preview_selected");
Settings.THEME_CHANGE_LISTENER.add(bool -> {
if(bool){
Themes.setDefaultTheme(new FlatColoredTheme(
Expand Down
15 changes: 15 additions & 0 deletions src/net/fexcraft/app/fmt/ui/editor/PreviewEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import org.liquidengine.legui.component.Label;

import net.fexcraft.app.fmt.FMTB;
import net.fexcraft.app.fmt.ui.UserInterfaceUtils;
import net.fexcraft.app.fmt.ui.field.NumberField;
import net.fexcraft.app.fmt.ui.field.TextField;
import net.fexcraft.app.fmt.utils.HelperCollector;
import net.fexcraft.app.fmt.wrappers.GroupCompound;
import net.fexcraft.lib.common.math.Vec3f;
Expand All @@ -12,10 +15,22 @@ public class PreviewEditor extends EditorBase {
public static NumberField pos_x, pos_y, pos_z, poss_x, poss_y, poss_z;
public static NumberField rot_x, rot_y, rot_z;
public static NumberField size_x, size_y, size_z, size16_x, size16_y, size16_z;
public static TextField helper_name;

@SuppressWarnings("unchecked")
public PreviewEditor(){
super(); int pass = -20;
EditorWidget preview = new EditorWidget(this, translate("editor.preview.container"), 0, 0, 0, 0);
preview.getContainer().add(new Label(translate("editor.preview.container.name"), 3, pass += 24, 290, 20));
preview.getContainer().add(helper_name = new TextField(FMTB.NO_POLYGON_SELECTED, 3, pass += 24, 290, 20));
helper_name.addTextInputContentChangeEventListener(event -> {
String validated = UserInterfaceUtils.validateString(event);
GroupCompound compound = HelperCollector.getSelected();
if(compound == null || !compound.name.contains("/")) return;
compound.name = compound.name.substring(0, compound.name.indexOf('/') + 1);
compound.name += validated;
compound.button.update();
});
preview.getContainer().add(new Label(translate("editor.preview.container.position_full"), 3, pass += 24, 290, 20));
preview.getContainer().add(pos_x = new NumberField(4, pass += 24, 90, 20).setup(Integer.MIN_VALUE, Integer.MAX_VALUE, true, () -> updatePos(true)));
preview.getContainer().add(pos_y = new NumberField(102, pass, 90, 20).setup(Integer.MIN_VALUE, Integer.MAX_VALUE, true, () -> updatePos(true)));
Expand Down
2 changes: 2 additions & 0 deletions src/net/fexcraft/app/fmt/ui/tree/TreeGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ else if(parent.name.startsWith("frame/")){
updateColor();
model = HelperCollector.getSelected();
if(model == null){
PreviewEditor.helper_name.getTextState().setText(FMTB.NO_PREVIEW_SELECTED);
PreviewEditor.pos_x.apply(0);
PreviewEditor.pos_y.apply(0);
PreviewEditor.pos_z.apply(0);
Expand All @@ -197,6 +198,7 @@ else if(parent.name.startsWith("frame/")){
PreviewEditor.size16_z.apply(16);
}
else{
PreviewEditor.helper_name.getTextState().setText(model.name.substring(model.name.indexOf('/') + 1));
PreviewEditor.pos_x.apply(model.pos == null ? 0 : model.pos.xCoord);
PreviewEditor.pos_y.apply(model.pos == null ? 0 : model.pos.yCoord);
PreviewEditor.pos_z.apply(model.pos == null ? 0 : model.pos.zCoord);
Expand Down
2 changes: 2 additions & 0 deletions src/net/fexcraft/app/fmt/utils/SaveLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ else if(jsn.get("name").getAsString().startsWith("fmtb/")){
porter.getSettings(false).forEach(setting -> map.put(setting.getId(), setting));
helperpreview = HelperCollector.load(file, porter, map);
}
helperpreview.name = jsn.get("name").getAsString();
helperpreview.button.update();
if(jsn.has("pos_x")){
helperpreview.pos = new Vec3f(jsn.get("pos_x").getAsFloat(), jsn.get("pos_y").getAsFloat(), jsn.get("pos_z").getAsFloat());
}
Expand Down

0 comments on commit 53195c8

Please sign in to comment.