diff --git a/adventure-editor/build.gradle b/adventure-editor/build.gradle index 29736ad3..9a7ec753 100644 --- a/adventure-editor/build.gradle +++ b/adventure-editor/build.gradle @@ -67,6 +67,7 @@ dependencies { implementation project(":blade-engine") implementation project(":blade-engine-spine-plugin") + implementation files('libs/gdx-particle-editor.jar') } task setVersion(type: WriteProperties) { diff --git a/adventure-editor/libs/gdx-particle-editor.jar b/adventure-editor/libs/gdx-particle-editor.jar new file mode 100644 index 00000000..1cc16801 Binary files /dev/null and b/adventure-editor/libs/gdx-particle-editor.jar differ diff --git a/adventure-editor/src/main/java/com/bladecoder/engineeditor/scneditor/ToolsWindow.java b/adventure-editor/src/main/java/com/bladecoder/engineeditor/scneditor/ToolsWindow.java index bad2277e..3e01c847 100644 --- a/adventure-editor/src/main/java/com/bladecoder/engineeditor/scneditor/ToolsWindow.java +++ b/adventure-editor/src/main/java/com/bladecoder/engineeditor/scneditor/ToolsWindow.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright 2014 Rafael Garcia Moreno. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,11 +15,6 @@ ******************************************************************************/ package com.bladecoder.engineeditor.scneditor; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Texture.TextureFilter; @@ -50,526 +45,530 @@ import com.kotcrab.vis.ui.widget.file.FileChooser.ViewMode; import com.kotcrab.vis.ui.widget.file.FileChooserListener; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + public class ToolsWindow extends Container { - ScnWidget scnWidget; - com.bladecoder.engine.model.BaseActor actor; + ScnWidget scnWidget; + com.bladecoder.engine.model.BaseActor actor; + + public ToolsWindow(Skin skin, ScnWidget sw) { + + scnWidget = sw; + + Table table = new Table(skin); + TextButton tmpButton = new TextButton("Temporal tool", skin, "no-toggled"); + TextButton testOnAndroidButton = new TextButton("Test on Android device", skin, "no-toggled"); + TextButton testOnIphoneEmulatorButton = new TextButton("Test on Iphone emulator", skin, "no-toggled"); + TextButton testOnIpadEmulatorButton = new TextButton("Test on Ipad emulator", skin, "no-toggled"); + TextButton testOnIOSDeviceButton = new TextButton("Test on IOS device", skin, "no-toggled"); + TextButton exportTSVButton = new TextButton("I18N - Export texts as .tsv", skin, "no-toggled"); + TextButton importTSVButton = new TextButton("I18N - Import.tsv file", skin, "no-toggled"); - public ToolsWindow(Skin skin, ScnWidget sw) { + TextButton exportUIImages = new TextButton("Export UI Images", skin, "no-toggled"); + TextButton createUIAtlas = new TextButton("Create UI Atlas", skin, "no-toggled"); + TextButton particleEditor = new TextButton("Particle Editor", skin, "no-toggled"); + TextButton compileInk = new TextButton("Compile Ink Script", skin, "no-toggled"); - scnWidget = sw; + table.defaults().left().expandX(); + table.top().pad(DPIUtils.getSpacing() / 2); + table.add(new Label("Tools", skin, "big")).center(); - Table table = new Table(skin); - TextButton tmpButton = new TextButton("Temporal tool", skin, "no-toggled"); - TextButton testOnAndroidButton = new TextButton("Test on Android device", skin, "no-toggled"); - TextButton testOnIphoneEmulatorButton = new TextButton("Test on Iphone emulator", skin, "no-toggled"); - TextButton testOnIpadEmulatorButton = new TextButton("Test on Ipad emulator", skin, "no-toggled"); - TextButton testOnIOSDeviceButton = new TextButton("Test on IOS device", skin, "no-toggled"); - TextButton exportTSVButton = new TextButton("I18N - Export texts as .tsv", skin, "no-toggled"); - TextButton importTSVButton = new TextButton("I18N - Import.tsv file", skin, "no-toggled"); + Drawable drawable = skin.getDrawable("trans"); + setBackground(drawable); - TextButton exportUIImages = new TextButton("Export UI Images", skin, "no-toggled"); - TextButton createUIAtlas = new TextButton("Create UI Atlas", skin, "no-toggled"); - TextButton particleEditor = new TextButton("Particle Editor", skin, "no-toggled"); - TextButton compileInk = new TextButton("Compile Ink Script", skin, "no-toggled"); + table.row(); + table.add(testOnAndroidButton).expandX().fill(); - table.defaults().left().expandX(); - table.top().pad(DPIUtils.getSpacing() / 2); - table.add(new Label("Tools", skin, "big")).center(); + table.row(); + table.add(testOnIphoneEmulatorButton).expandX().fill(); - Drawable drawable = skin.getDrawable("trans"); - setBackground(drawable); + table.row(); + table.add(testOnIpadEmulatorButton).expandX().fill(); - table.row(); - table.add(testOnAndroidButton).expandX().fill(); + table.row(); + table.add(testOnIOSDeviceButton).expandX().fill(); - table.row(); - table.add(testOnIphoneEmulatorButton).expandX().fill(); + // disable if not mac + if (!System.getProperty("os.name").toLowerCase().contains("mac")) { + testOnIphoneEmulatorButton.setDisabled(true); + testOnIpadEmulatorButton.setDisabled(true); + testOnIOSDeviceButton.setDisabled(true); + } + + table.row(); + table.add(exportTSVButton).expandX().fill(); + + table.row(); + table.add(importTSVButton).expandX().fill(); + + table.row(); + table.add(exportUIImages).expandX().fill(); + + table.row(); + table.add(createUIAtlas).expandX().fill(); + + table.row(); + table.add(particleEditor).expandX().fill(); + + table.row(); + table.add(compileInk).expandX().fill(); + + // table.row(); + // table.add(tmpButton).expandX().fill(); + + // ADD CUTMODE FOR VERBS THAT ONLY HAVE A LOOKAT OR SAY ACTION + tmpButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + ModelTools.fixSaySubtitleActor(); + + Message.showMsg(getStage(), "TOOL PROCESSED", 4); + } + + }); + + // TEST ON ANDROID DEVICE + testOnAndroidButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + testOnAndroid(); + } - table.row(); - table.add(testOnIpadEmulatorButton).expandX().fill(); + }); + + testOnIphoneEmulatorButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + testOnIphoneEmulator(); + } + + }); + + testOnIpadEmulatorButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + testOnIpadEmulator(); + } + + }); + + testOnIOSDeviceButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + testOnIOSDevice(); + } + + }); + + exportTSVButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + exportTSV(); + } + }); + + importTSVButton.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + importTSV(); + } + }); + + exportUIImages.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + exportUIImages(); + } + }); + + createUIAtlas.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + createUIAtlas(); + } + }); + + particleEditor.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + particleEditor(); + } + }); - table.row(); - table.add(testOnIOSDeviceButton).expandX().fill(); - - // disable if not mac - if (!System.getProperty("os.name").toLowerCase().contains("mac")) { - testOnIphoneEmulatorButton.setDisabled(true); - testOnIpadEmulatorButton.setDisabled(true); - testOnIOSDeviceButton.setDisabled(true); - } - - table.row(); - table.add(exportTSVButton).expandX().fill(); - - table.row(); - table.add(importTSVButton).expandX().fill(); - - table.row(); - table.add(exportUIImages).expandX().fill(); - - table.row(); - table.add(createUIAtlas).expandX().fill(); - - // TODO: Enable particle editor when ported to LWJGL3 - //table.row(); - //table.add(particleEditor).expandX().fill(); - - table.row(); - table.add(compileInk).expandX().fill(); - - // table.row(); - // table.add(tmpButton).expandX().fill(); - - // ADD CUTMODE FOR VERBS THAT ONLY HAVE A LOOKAT OR SAY ACTION - tmpButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - ModelTools.fixSaySubtitleActor(); - - Message.showMsg(getStage(), "TOOL PROCESSED", 4); - } - - }); - - // TEST ON ANDROID DEVICE - testOnAndroidButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - testOnAndroid(); - } - - }); - - testOnIphoneEmulatorButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - testOnIphoneEmulator(); - } - - }); - - testOnIpadEmulatorButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - testOnIpadEmulator(); - } - - }); - - testOnIOSDeviceButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - testOnIOSDevice(); - } - - }); - - exportTSVButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - exportTSV(); - } - }); - - importTSVButton.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - importTSV(); - } - }); - - exportUIImages.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - exportUIImages(); - } - }); - - createUIAtlas.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - createUIAtlas(); - } - }); - - particleEditor.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - particleEditor(); - } - }); - - compileInk.addListener(new ChangeListener() { - @Override - public void changed(ChangeEvent event, Actor actor) { - compileInk(); - } - }); - - table.pack(); - setActor(table); - prefSize(table.getWidth(), Math.max(200, table.getHeight())); - setSize(table.getWidth(), Math.max(200, table.getHeight())); - } - - protected void compileInk() { - new CompileInkDialog(getActor().getSkin()).show(getStage()); - } - - protected void createUIAtlas() { - FileChooser fileChooser = new FileChooser(Mode.OPEN); - fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); - fileChooser.setViewMode(ViewMode.LIST); - - fileChooser.setSelectionMode(SelectionMode.DIRECTORIES); - getStage().addActor(fileChooser); - - fileChooser.setListener(new FileChooserListener() { - - @Override - public void selected(Array files) { - - List res = Ctx.project.getResolutions(); - - for (String r : res) { - float scale = Float.parseFloat(r); - - try { - int maxWH = (int) (ImageUtils.getRecommendedAtlasSize() * scale); + compileInk.addListener(new ChangeListener() { + @Override + public void changed(ChangeEvent event, Actor actor) { + compileInk(); + } + }); + + table.pack(); + setActor(table); + prefSize(table.getWidth(), Math.max(200, table.getHeight())); + setSize(table.getWidth(), Math.max(200, table.getHeight())); + } + + protected void compileInk() { + new CompileInkDialog(getActor().getSkin()).show(getStage()); + } + + protected void createUIAtlas() { + FileChooser fileChooser = new FileChooser(Mode.OPEN); + fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); + fileChooser.setViewMode(ViewMode.LIST); + + fileChooser.setSelectionMode(SelectionMode.DIRECTORIES); + getStage().addActor(fileChooser); + + fileChooser.setListener(new FileChooserListener() { + + @Override + public void selected(Array files) { + + List res = Ctx.project.getResolutions(); + + for (String r : res) { + float scale = Float.parseFloat(r); + + try { + int maxWH = (int) (ImageUtils.getRecommendedAtlasSize() * scale); - ImageUtils.createAtlas(files.get(0).file().getAbsolutePath(), - Ctx.project.getAssetPath() + Project.UI_PATH + "/" + r, "ui" + ".atlas", scale, maxWH, - maxWH, TextureFilter.Linear, TextureFilter.Nearest, "png", false); - } catch (IOException e) { - EditorLogger.error(e.getMessage()); - Message.showMsgDialog(getStage(), "Error creating atlas", e.getMessage()); - return; - } - } - - Message.showMsg(getStage(), "UI Atlas created sucessfully.", 4); - } + ImageUtils.createAtlas(files.get(0).file().getAbsolutePath(), + Ctx.project.getAssetPath() + Project.UI_PATH + "/" + r, "ui" + ".atlas", scale, maxWH, + maxWH, TextureFilter.Linear, TextureFilter.Nearest, "png", false); + } catch (IOException e) { + EditorLogger.error(e.getMessage()); + Message.showMsgDialog(getStage(), "Error creating atlas", e.getMessage()); + return; + } + } + + Message.showMsg(getStage(), "UI Atlas created sucessfully.", 4); + } - @Override - public void canceled() { + @Override + public void canceled() { - } - }); + } + }); - } - - protected void exportUIImages() { - FileChooser fileChooser = new FileChooser(Mode.OPEN); - fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); - fileChooser.setViewMode(ViewMode.LIST); + } + + protected void exportUIImages() { + FileChooser fileChooser = new FileChooser(Mode.OPEN); + fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); + fileChooser.setViewMode(ViewMode.LIST); - fileChooser.setSelectionMode(SelectionMode.DIRECTORIES); - getStage().addActor(fileChooser); - - fileChooser.setListener(new FileChooserListener() { - - @Override - public void selected(Array files) { - try { - // fileChooser.setTitle("Select the file to export the - // project texts"); + fileChooser.setSelectionMode(SelectionMode.DIRECTORIES); + getStage().addActor(fileChooser); + + fileChooser.setListener(new FileChooserListener() { + + @Override + public void selected(Array files) { + try { + // fileChooser.setTitle("Select the file to export the + // project texts"); - ImageUtils.unpackAtlas(new File(Ctx.project.getAssetPath() + Project.UI_PATH + "/1/ui.atlas"), - files.get(0).file()); + ImageUtils.unpackAtlas(new File(Ctx.project.getAssetPath() + Project.UI_PATH + "/1/ui.atlas"), + files.get(0).file()); - Message.showMsg(getStage(), "UI Atlas images exported sucessfully.", 4); - } catch (Exception e) { - Message.showMsg(getStage(), "There was a problem exporting images from UI Atlas.", 4); - EditorLogger.printStackTrace(e); - } - } + Message.showMsg(getStage(), "UI Atlas images exported sucessfully.", 4); + } catch (Exception e) { + Message.showMsg(getStage(), "There was a problem exporting images from UI Atlas.", 4); + EditorLogger.printStackTrace(e); + } + } - @Override - public void canceled() { + @Override + public void canceled() { - } - }); + } + }); - } + } - private void exportTSV() { + private void exportTSV() { - FileChooser fileChooser = new FileChooser(Mode.SAVE); - fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); - fileChooser.setViewMode(ViewMode.LIST); + FileChooser fileChooser = new FileChooser(Mode.SAVE); + fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); + fileChooser.setViewMode(ViewMode.LIST); - fileChooser.setSelectionMode(SelectionMode.FILES); - getStage().addActor(fileChooser); + fileChooser.setSelectionMode(SelectionMode.FILES); + getStage().addActor(fileChooser); - fileChooser.setListener(new FileChooserListener() { + fileChooser.setListener(new FileChooserListener() { - @Override - public void selected(Array files) { - try { - // fileChooser.setTitle("Select the file to export the - // project texts"); + @Override + public void selected(Array files) { + try { + // fileChooser.setTitle("Select the file to export the + // project texts"); - I18NUtils.exportTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, - files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default"); + I18NUtils.exportTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, + files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default"); - Message.showMsg(getStage(), files.get(0).file().getName() + " exported sucessfully.", 4); - } catch (IOException e) { - Message.showMsg(getStage(), "There was a problem generating the .tsv file.", 4); - EditorLogger.printStackTrace(e); - } - } + Message.showMsg(getStage(), files.get(0).file().getName() + " exported sucessfully.", 4); + } catch (IOException e) { + Message.showMsg(getStage(), "There was a problem generating the .tsv file.", 4); + EditorLogger.printStackTrace(e); + } + } - @Override - public void canceled() { + @Override + public void canceled() { - } - }); - } + } + }); + } - private void importTSV() { + private void importTSV() { - FileChooser fileChooser = new FileChooser(Mode.OPEN); - fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); - fileChooser.setViewMode(ViewMode.LIST); - - fileChooser.setSelectionMode(SelectionMode.FILES); - getStage().addActor(fileChooser); - - fileChooser.setListener(new FileChooserListener() { - - @Override - public void selected(Array files) { - try { - // chooser.setTitle("Select the .tsv file to import"); - - I18NUtils.importTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, - files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default"); + FileChooser fileChooser = new FileChooser(Mode.OPEN); + fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f); + fileChooser.setViewMode(ViewMode.LIST); + + fileChooser.setSelectionMode(SelectionMode.FILES); + getStage().addActor(fileChooser); + + fileChooser.setListener(new FileChooserListener() { + + @Override + public void selected(Array files) { + try { + // chooser.setTitle("Select the .tsv file to import"); + + I18NUtils.importTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, + files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default"); - // Reload texts - Ctx.project.getI18N().load(Ctx.project.getChapter().getId()); + // Reload texts + Ctx.project.getI18N().load(Ctx.project.getChapter().getId()); - Message.showMsg(getStage(), files.get(0).file().getName() + " imported sucessfully.", 4); + Message.showMsg(getStage(), files.get(0).file().getName() + " imported sucessfully.", 4); - } catch (IOException e) { - Message.showMsg(getStage(), "There was a problem importing the .tsv file.", 4); - EditorLogger.printStackTrace(e); - } - } - - @Override - public void canceled() { - - } - }); - } - - private void testOnAndroid() { - if (Ctx.project.getSelectedScene() == null) { - String msg = "There are no scenes in this chapter."; - Message.showMsg(getStage(), msg, 3); - return; - } - - Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); - Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " - + ex.getMessage(); - Message.showMsgDialog(getStage(), "Error", msg); - return; - } - - new Thread(new Runnable() { - Stage stage = getStage(); - - @Override - public void run() { - Message.showMsg(stage, "Running scene on Android device...", 5); - - if (!RunProccess.runGradle(Ctx.project.getProjectDir(), - "android:uninstallFullDebug android:installFullDebug android:run")) { - Message.showMsg(stage, "There was a problem running the project", 4); - } - - Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); - Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() - + " - " + ex.getMessage(); - EditorLogger.error(msg); - return; - } - - } - }).start(); - - } - - private void testOnIphoneEmulator() { - if (Ctx.project.getSelectedScene() == null) { - String msg = "There are no scenes in this chapter."; - Message.showMsg(getStage(), msg, 3); - return; - } - - Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); - Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " - + ex.getMessage(); - Message.showMsgDialog(getStage(), "Error", msg); - return; - } - - new Thread(new Runnable() { - Stage stage = getStage(); - - @Override - public void run() { - Message.showMsg(stage, "Running scene on Iphone emulator...", 5); - - if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIPhoneSimulator")) { - Message.showMsg(stage, "There was a problem running the project", 4); - } - - Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); - Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() - + " - " + ex.getMessage(); - EditorLogger.error(msg); - return; - } - - } - }).start(); - - } - - private void testOnIpadEmulator() { - if (Ctx.project.getSelectedScene() == null) { - String msg = "There are no scenes in this chapter."; - Message.showMsg(getStage(), msg, 3); - return; - } - - Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); - Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " - + ex.getMessage(); - Message.showMsgDialog(getStage(), "Error", msg); - return; - } - - new Thread(new Runnable() { - Stage stage = getStage(); - - @Override - public void run() { - Message.showMsg(stage, "Running scene on Ipad simulator...", 5); - - if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIPadSimulator")) { - Message.showMsg(stage, "There was a problem running the project", 4); - } - - Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); - Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() - + " - " + ex.getMessage(); - EditorLogger.error(msg); - return; - } - - } - }).start(); - - } - - private void testOnIOSDevice() { - if (Ctx.project.getSelectedScene() == null) { - String msg = "There are no scenes in this chapter."; - Message.showMsg(getStage(), msg, 3); - return; - } - - Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); - Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " - + ex.getMessage(); - Message.showMsgDialog(getStage(), "Error", msg); - return; - } - - new Thread(new Runnable() { - Stage stage = getStage(); - - @Override - public void run() { - Message.showMsg(stage, "Running scene on IOS device...", 5); - - if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIOSDevice")) { - Message.showMsg(stage, "There was a problem running the project", 4); - } - - Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); - Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); - Ctx.project.setModified(); - - try { - Ctx.project.saveProject(); - } catch (Exception ex) { - String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() - + " - " + ex.getMessage(); - EditorLogger.error(msg); - return; - } - - } - }).start(); - - } - - private void particleEditor() { - // Open the particle editor - List cp = new ArrayList<>(); - cp.add(System.getProperty("java.class.path")); - try { - RunProccess.runJavaProccess("com.badlogic.gdx.tools.particleeditor.ParticleEditor", cp, null); - } catch (IOException e) { - Message.showMsgDialog(getStage(), "Error", "Error launching Particle Editor."); - EditorLogger.printStackTrace(e); - } - } + } catch (IOException e) { + Message.showMsg(getStage(), "There was a problem importing the .tsv file.", 4); + EditorLogger.printStackTrace(e); + } + } + + @Override + public void canceled() { + + } + }); + } + + private void testOnAndroid() { + if (Ctx.project.getSelectedScene() == null) { + String msg = "There are no scenes in this chapter."; + Message.showMsg(getStage(), msg, 3); + return; + } + + Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); + Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " + + ex.getMessage(); + Message.showMsgDialog(getStage(), "Error", msg); + return; + } + + new Thread(new Runnable() { + Stage stage = getStage(); + + @Override + public void run() { + Message.showMsg(stage, "Running scene on Android device...", 5); + + if (!RunProccess.runGradle(Ctx.project.getProjectDir(), + "android:uninstallFullDebug android:installFullDebug android:run")) { + Message.showMsg(stage, "There was a problem running the project", 4); + } + + Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); + Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + + " - " + ex.getMessage(); + EditorLogger.error(msg); + return; + } + + } + }).start(); + + } + + private void testOnIphoneEmulator() { + if (Ctx.project.getSelectedScene() == null) { + String msg = "There are no scenes in this chapter."; + Message.showMsg(getStage(), msg, 3); + return; + } + + Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); + Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " + + ex.getMessage(); + Message.showMsgDialog(getStage(), "Error", msg); + return; + } + + new Thread(new Runnable() { + Stage stage = getStage(); + + @Override + public void run() { + Message.showMsg(stage, "Running scene on Iphone emulator...", 5); + + if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIPhoneSimulator")) { + Message.showMsg(stage, "There was a problem running the project", 4); + } + + Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); + Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + + " - " + ex.getMessage(); + EditorLogger.error(msg); + return; + } + + } + }).start(); + + } + + private void testOnIpadEmulator() { + if (Ctx.project.getSelectedScene() == null) { + String msg = "There are no scenes in this chapter."; + Message.showMsg(getStage(), msg, 3); + return; + } + + Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); + Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " + + ex.getMessage(); + Message.showMsgDialog(getStage(), "Error", msg); + return; + } + + new Thread(new Runnable() { + Stage stage = getStage(); + + @Override + public void run() { + Message.showMsg(stage, "Running scene on Ipad simulator...", 5); + + if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIPadSimulator")) { + Message.showMsg(stage, "There was a problem running the project", 4); + } + + Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); + Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + + " - " + ex.getMessage(); + EditorLogger.error(msg); + return; + } + + } + }).start(); + + } + + private void testOnIOSDevice() { + if (Ctx.project.getSelectedScene() == null) { + String msg = "There are no scenes in this chapter."; + Message.showMsg(getStage(), msg, 3); + return; + } + + Ctx.project.getProjectConfig().setProperty(Config.CHAPTER_PROP, Ctx.project.getChapter().getId()); + Ctx.project.getProjectConfig().setProperty(Config.TEST_SCENE_PROP, Ctx.project.getSelectedScene().getId()); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + " - " + + ex.getMessage(); + Message.showMsgDialog(getStage(), "Error", msg); + return; + } + + new Thread(new Runnable() { + Stage stage = getStage(); + + @Override + public void run() { + Message.showMsg(stage, "Running scene on IOS device...", 5); + + if (!RunProccess.runGradle(Ctx.project.getProjectDir(), "ios:launchIOSDevice")) { + Message.showMsg(stage, "There was a problem running the project", 4); + } + + Ctx.project.getProjectConfig().removeProperty(Config.CHAPTER_PROP); + Ctx.project.getProjectConfig().removeProperty(Config.TEST_SCENE_PROP); + Ctx.project.setModified(); + + try { + Ctx.project.saveProject(); + } catch (Exception ex) { + String msg = "Something went wrong while saving the project.\n\n" + ex.getClass().getSimpleName() + + " - " + ex.getMessage(); + EditorLogger.error(msg); + return; + } + + } + }).start(); + + } + + private void particleEditor() { + // Open the particle editor + List cp = new ArrayList<>(); + cp.add(System.getProperty("java.class.path")); + try { + RunProccess.runJavaProccess("com.ray3k.gdxparticleeditor.lwjgl3.Lwjgl3Launcher", cp, null); + } catch (IOException e) { + Message.showMsgDialog(getStage(), "Error", "Error launching Particle Editor."); + EditorLogger.printStackTrace(e); + } + } } diff --git a/blade-engine/src/com/bladecoder/engine/ui/DialogUI.java b/blade-engine/src/com/bladecoder/engine/ui/DialogUI.java index 170d9853..66b603e6 100644 --- a/blade-engine/src/com/bladecoder/engine/ui/DialogUI.java +++ b/blade-engine/src/com/bladecoder/engine/ui/DialogUI.java @@ -102,15 +102,15 @@ public void setUpDownVisibility() { "setUpDownVisibility: " + isScrollY() + " maxY: " + getMaxY() + " Margin: " + DPIUtils.getMarginSize()); if (isScrollY() && getMaxY() > DPIUtils.getMarginSize()) { - if (getScrollPercentY() > 0f && up.isVisible() == false) { + if (getScrollPercentY() > 0f && !up.isVisible()) { up.setVisible(true); - } else if (getScrollPercentY() == 0f && up.isVisible() == true) { + } else if (getScrollPercentY() == 0f && up.isVisible()) { up.setVisible(false); } - if (getScrollPercentY() < 1f && down.isVisible() == false) { + if (getScrollPercentY() < 1f && !down.isVisible()) { down.setVisible(true); - } else if (getScrollPercentY() == 1f && down.isVisible() == true) { + } else if (getScrollPercentY() == 1f && down.isVisible()) { down.setVisible(false); } } else { @@ -145,7 +145,7 @@ public void setScrollY(float pixels) { private void show() { choices = world.getDialogOptions(); - if (choices.size() == 0) { + if (choices.isEmpty()) { setVisible(false); return; } else if (style.autoselect && choices.size() == 1) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e411586a..a5952066 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists