Skip to content

Commit c734765

Browse files
committed
Added voice support to the Asset List. Create asset folder if doesn't exists.
1 parent 9e37fe9 commit c734765

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/model/Project.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class Project extends PropertyChange {
8585
public static final String SPRITE3D_PATH = ASSETS_PATH + "/3d";
8686
public static final String SPINE_PATH = ASSETS_PATH + "/spine";
8787
public static final String PARTICLE_PATH = ASSETS_PATH + "/particles";
88+
public static final String VOICE_PATH = ASSETS_PATH + "/voices";
8889
public static final String UI_PATH = ASSETS_PATH + "/ui";
8990
public static final String FONT_PATH = UI_PATH + "/fonts";
9091

adventure-editor/src/main/java/com/bladecoder/engineeditor/setup/BladeEngineSetup.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ public void build (ProjectBuilder builder, String outputDir, String appName, Str
283283
new File(outputDir + "/" + assetPath + "/music").mkdirs();
284284
new File(outputDir + "/" + assetPath + "/sounds").mkdirs();
285285
new File(outputDir + "/" + assetPath + "/spine").mkdirs();
286+
new File(outputDir + "/" + assetPath + "/voices").mkdirs();
287+
new File(outputDir + "/" + assetPath + "/particles").mkdirs();
286288
new File(outputDir + "/" + assetPath + "/tests").mkdirs();
287289
new File(outputDir + "/" + assetPath + "/ui/1").mkdirs();
288290
new File(outputDir + "/" + assetPath + "/ui/fonts").mkdirs();

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/AssetsList.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import com.kotcrab.vis.ui.widget.file.FileTypeFilter;
5353

5454
public class AssetsList extends Table {
55-
private static final String[] ASSET_TYPES = { "3d models", "atlases", "music", "sounds", "images", "spine", "particles" };
55+
private static final String[] ASSET_TYPES = { "3d models", "atlases", "music", "sounds", "images", "spine", "particles", "voices" };
5656

5757
private SelectBox<String> assetTypes;
5858
protected EditToolbar toolbar;
@@ -188,6 +188,8 @@ private String getAssetDir(String type) {
188188
dir = Ctx.project.getProjectPath() + "/" + Project.SPINE_PATH;
189189
} else if (type.equals("particles")) {
190190
dir = Ctx.project.getProjectPath() + "/" + Project.PARTICLE_PATH;
191+
} else if (type.equals("voices")) {
192+
dir = Ctx.project.getProjectPath() + "/" + Project.VOICE_PATH;
191193
} else {
192194
dir = Ctx.project.getProjectPath() + Project.ASSETS_PATH;
193195
}
@@ -237,6 +239,7 @@ private void create() {
237239
break;
238240
case "music":
239241
case "sounds":
242+
case "voices":
240243
typeFilter.addRule("Sound (*.mp3, *.wav, *.ogg)", "wav", "mp3", "ogg");
241244
break;
242245
case "3d models":
@@ -258,15 +261,20 @@ private void create() {
258261
public void selected(Array<FileHandle> files) {
259262

260263
try {
261-
String dir = getAssetDir(type);
264+
String dirName = getAssetDir(type);
262265
lastDir = files.get(0).parent().file();
266+
267+
// Si no existe la carpeta la creamos
268+
File dir = new File(dirName);
269+
if(!dir.exists())
270+
dir.mkdir();
263271

264272
for (FileHandle f : files) {
265273
if (type.equals("images")) {
266274
List<String> res = Ctx.project.getResolutions();
267275

268276
for (String r : res) {
269-
File destFile = new File(dir + "/" + r + "/" + f.file().getName());
277+
File destFile = new File(dirName + "/" + r + "/" + f.file().getName());
270278
float scale = Float.parseFloat(r);
271279

272280
if (scale != 1.0f) {
@@ -277,7 +285,7 @@ public void selected(Array<FileHandle> files) {
277285
}
278286
}
279287
} else {
280-
File destFile = new File(dir + "/" + f.file().getName());
288+
File destFile = new File(dir, f.file().getName());
281289
Files.copy(f.file().toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
282290
}
283291

0 commit comments

Comments
 (0)