Bugfixes / Copy over plugins to mod folder

This commit is contained in:
Anuken
2019-10-24 18:04:39 -04:00
parent cbfcb5de2c
commit 955dc5f48d
7 changed files with 51 additions and 9 deletions

View File

@@ -68,6 +68,25 @@ public class Schematics implements Loadable{
});
}
public void overwrite(Schematic target, Schematic newSchematic){
if(previews.containsKey(target)){
previews.get(target).dispose();
previews.remove(target);
}
target.tiles.clear();
target.tiles.addAll(newSchematic.tiles);
newSchematic.tags.putAll(target.tags);
newSchematic.file = target.file;
try{
write(newSchematic, target.file);
}catch(Exception e){
Log.err(e);
ui.showException(e);
}
}
private void loadFile(FileHandle file){
if(!file.extension().equals(schematicExtension)) return;

View File

@@ -60,7 +60,6 @@ public class DesktopInput extends InputHandler{
t.visible(() -> lastSchematic != null && !selectRequests.isEmpty());
t.bottom();
t.table(Styles.black6, b -> {
//b.touchable(Touchable.enabled);
b.defaults().left();
b.add(Core.bundle.format("schematic.flip",
Core.keybinds.get(Binding.schematic_flip_x).key.name(),
@@ -69,10 +68,19 @@ public class DesktopInput extends InputHandler{
b.table(a -> {
a.addImageTextButton("$schematic.add", Icon.saveSmall, () -> {
ui.showTextInput("$schematic.add", "$name", "", text -> {
lastSchematic.tags.put("name", text);
schematics.add(lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic);
Schematic replacement = schematics.all().find(s -> s.name().equals(text));
if(replacement != null){
ui.showConfirm("$confirm", "$schematic.replace", () -> {
schematics.overwrite(replacement, lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(replacement);
});
}else{
lastSchematic.tags.put("name", text);
schematics.add(lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic);
}
});
}).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
});

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.mod;
import io.anuke.arc.*;
import io.anuke.arc.audio.*;
import io.anuke.arc.audio.mock.*;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
@@ -52,6 +53,7 @@ public class ContentParser{
});
put(Sound.class, (type, data) -> {
if(fieldOpt(Sounds.class, data) != null) return fieldOpt(Sounds.class, data);
if(Vars.headless) return new MockSound();
String path = "sounds/" + data.asString() + (Vars.ios ? ".mp3" : ".ogg");
ModLoadingSound sound = new ModLoadingSound();

View File

@@ -169,9 +169,11 @@ public class Mods implements Loadable{
for(FileHandle file : modDirectory.list()){
if(!file.extension().equals("jar") && !file.extension().equals("zip") && !(file.isDirectory() && file.child("mod.json").exists())) continue;
Log.debug("[Mods] Loading mod {0}", file);
try{
LoadedMod mod = loadMod(file, false);
if(mod.enabled()){
if(mod.enabled() || headless){
loaded.add(mod);
}else{
disabled.add(mod);
@@ -286,7 +288,7 @@ public class Mods implements Loadable{
try{
//this binds the content but does not load it entirely
Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type);
Log.info("[{0}] Loaded '{1}'.", mod.meta.name,
Log.debug("[{0}] Loaded '{1}'.", mod.meta.name,
(loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
}catch(Exception e){
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);