Search in sources :

Example 1 with SoundDesc

use of com.bladecoder.engine.model.SoundDesc in project bladecoder-adventure-engine by bladecoder.

the class ModelTools method printUnusedSounds.

public static void printUnusedSounds() {
    ArrayList<String> unusedSounds = new ArrayList<>(Arrays.asList(getSoundList()));
    HashMap<String, SoundDesc> sounds = Ctx.project.getWorld().getSounds();
    if (sounds != null) {
        for (SoundDesc s : sounds.values()) {
            unusedSounds.remove(s.getFilename());
        }
    }
    for (String s : unusedSounds) EditorLogger.error(s);
}
Also used : SoundDesc(com.bladecoder.engine.model.SoundDesc) ArrayList(java.util.ArrayList)

Example 2 with SoundDesc

use of com.bladecoder.engine.model.SoundDesc in project bladecoder-adventure-engine by bladecoder.

the class WorldSerialization method read.

@Override
public void read(Json json, JsonValue jsonData) {
    String bladeVersion = json.readValue(Config.BLADE_ENGINE_VERSION_PROP, String.class, jsonData);
    BladeJson bjson = (BladeJson) json;
    if (bjson.getMode() == Mode.MODEL) {
        if (bladeVersion != null && !bladeVersion.equals(Config.getInstance().getProperty(Config.BLADE_ENGINE_VERSION_PROP, ""))) {
            EngineLogger.debug("Model Engine Version v" + bladeVersion + " differs from Current Engine Version v" + Config.getInstance().getProperty(Config.BLADE_ENGINE_VERSION_PROP, ""));
        }
        // SOUNDS
        JsonValue jsonSounds = jsonData.get("sounds");
        HashMap<String, SoundDesc> sounds = w.getSounds();
        if (jsonSounds != null) {
            for (int i = 0; i < jsonSounds.size; i++) {
                JsonValue jsonValue = jsonSounds.get(i);
                SoundDesc s = json.readValue(SoundDesc.class, jsonValue);
                sounds.put(jsonValue.name, s);
            }
        }
        // SCENES
        JsonValue jsonScenes = jsonData.get("scenes");
        Map<String, Scene> scenes = w.getScenes();
        for (int i = 0; i < jsonScenes.size; i++) {
            JsonValue jsonValue = jsonScenes.get(i);
            Scene s = new Scene(w);
            scenes.put(jsonValue.name, s);
            s.read(json, jsonValue);
        }
        w.setInitScene(json.readValue("initScene", String.class, jsonData));
        if (w.getInitScene() == null && w.getScenes().size() > 0) {
            w.setInitScene(w.getScenes().keySet().toArray(new String[0])[0]);
        }
        for (Scene s : w.getScenes().values()) {
            s.resetCamera(w.getWidth(), w.getHeight());
        }
        // Load Ink story
        if (jsonData.get("inkManager") != null) {
            w.getInkManager().read(json, jsonData.get("inkManager"));
        }
        // Add sounds to cache
        cacheSounds();
    } else {
        if (bladeVersion != null && !bladeVersion.equals(Config.getInstance().getProperty(Config.BLADE_ENGINE_VERSION_PROP, ""))) {
            EngineLogger.debug("Saved Game Engine Version v" + bladeVersion + " differs from Current Engine Version v" + Config.getInstance().getProperty(Config.BLADE_ENGINE_VERSION_PROP, ""));
        }
        String currentChapter = json.readValue("chapter", String.class, jsonData);
        String currentScene = json.readValue("currentScene", String.class, jsonData);
        try {
            loadChapter(currentChapter, currentScene, false);
        } catch (IOException e1) {
            EngineLogger.error("Error Loading Chapter");
            return;
        }
        // scenes and verbs tweens
        if (jsonData.get("inkManager") != null) {
            w.getInkManager().read(json, jsonData.get("inkManager"));
        }
        // inventories have to be put in the hash to find the actors when
        // reading saved data
        w.setCurrentInventory(json.readValue("currentInventory", String.class, jsonData));
        JsonValue jsonInventories = jsonData.get("inventories");
        for (int i = 0; i < jsonInventories.size; i++) {
            JsonValue jsonValue = jsonInventories.get(i);
            Inventory inv = new Inventory();
            w.getInventories().put(jsonValue.name, inv);
            inv.read(json, jsonValue);
        }
        if (jsonData.get("uiActors") != null) {
            w.getUIActors().read(json, jsonData.get("uiActors"));
        }
        for (Scene s : w.getScenes().values()) {
            JsonValue jsonValue = jsonData.get("scenes").get(s.getId());
            if (jsonValue != null)
                s.read(json, jsonValue);
            else
                EngineLogger.debug("LOAD WARNING: Scene not found in saved game: " + s.getId());
        }
        w.setTimeOfGame(json.readValue("timeOfGame", long.class, 0L, jsonData));
        w.setCutMode(json.readValue("cutmode", boolean.class, false, jsonData));
        w.getVerbManager().read(json, jsonData);
        // CUSTOM PROPERTIES
        JsonValue jsonProperties = jsonData.get("customProperties");
        HashMap<String, String> props = w.getCustomProperties();
        for (int i = 0; i < jsonProperties.size; i++) {
            JsonValue jsonValue = jsonProperties.get(i);
            props.put(jsonValue.name, jsonValue.asString());
        }
        String version = json.readValue(Config.VERSION_PROP, String.class, jsonData);
        if (version == null)
            version = "TEST";
        props.put(WorldProperties.SAVED_GAME_VERSION.toString(), version);
        String actorId = json.readValue("dialogActor", String.class, jsonData);
        String dialogId = json.readValue("currentDialog", String.class, jsonData);
        if (dialogId != null) {
            CharacterActor actor = (CharacterActor) w.getCurrentScene().getActor(actorId, false);
            w.setCurrentDialog(actor.getDialog(dialogId));
        }
        w.getTransition().read(json, jsonData.get("transition"));
        w.getMusicManager().read(json, jsonData.get("musicEngine"));
        w.getI18N().loadChapter(EngineAssetManager.MODEL_DIR + w.getCurrentChapter());
    }
}
Also used : SoundDesc(com.bladecoder.engine.model.SoundDesc) JsonValue(com.badlogic.gdx.utils.JsonValue) IOException(java.io.IOException) Scene(com.bladecoder.engine.model.Scene) CharacterActor(com.bladecoder.engine.model.CharacterActor) Inventory(com.bladecoder.engine.model.Inventory)

Example 3 with SoundDesc

use of com.bladecoder.engine.model.SoundDesc in project bladecoder-adventure-engine by bladecoder.

the class SoundList method copy.

@Override
protected void copy() {
    SoundDesc e = list.getSelected();
    if (e == null)
        return;
    clipboard = (SoundDesc) ElementUtils.cloneElement(e);
    toolbar.disablePaste(false);
}
Also used : SoundDesc(com.bladecoder.engine.model.SoundDesc)

Example 4 with SoundDesc

use of com.bladecoder.engine.model.SoundDesc in project bladecoder-adventure-engine by bladecoder.

the class SoundList method paste.

@Override
protected void paste() {
    SoundDesc newElement = (SoundDesc) ElementUtils.cloneElement(clipboard);
    int pos = list.getSelectedIndex() + 1;
    list.getItems().insert(pos, newElement);
    String id = newElement.getId();
    if (parent.getSounds() != null)
        id = ElementUtils.getCheckedId(newElement.getId(), parent.getSounds().keySet().toArray(new String[parent.getSounds().size()]));
    newElement.setId(id);
    parent.getSounds().put(newElement.getId(), newElement);
    list.setSelectedIndex(pos);
    list.invalidateHierarchy();
    Ctx.project.setModified();
}
Also used : SoundDesc(com.bladecoder.engine.model.SoundDesc)

Example 5 with SoundDesc

use of com.bladecoder.engine.model.SoundDesc in project bladecoder-adventure-engine by bladecoder.

the class SoundList method delete.

@Override
protected void delete() {
    SoundDesc s = removeSelected();
    parent.getSounds().remove(s.getId());
    // UNDO
    Ctx.project.getUndoStack().add(new UndoDeleteSound(s));
    Ctx.project.setModified();
}
Also used : SoundDesc(com.bladecoder.engine.model.SoundDesc) UndoDeleteSound(com.bladecoder.engineeditor.undo.UndoDeleteSound)

Aggregations

SoundDesc (com.bladecoder.engine.model.SoundDesc)7 Scene (com.bladecoder.engine.model.Scene)2 JsonValue (com.badlogic.gdx.utils.JsonValue)1 ReflectionException (com.badlogic.gdx.utils.reflect.ReflectionException)1 Action (com.bladecoder.engine.actions.Action)1 PlaySoundAction (com.bladecoder.engine.actions.PlaySoundAction)1 SoundAction (com.bladecoder.engine.actions.SoundAction)1 AnimationDesc (com.bladecoder.engine.anim.AnimationDesc)1 AnimationRenderer (com.bladecoder.engine.model.AnimationRenderer)1 BaseActor (com.bladecoder.engine.model.BaseActor)1 CharacterActor (com.bladecoder.engine.model.CharacterActor)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 Inventory (com.bladecoder.engine.model.Inventory)1 SpriteActor (com.bladecoder.engine.model.SpriteActor)1 Verb (com.bladecoder.engine.model.Verb)1 UndoCreateSound (com.bladecoder.engineeditor.undo.UndoCreateSound)1 UndoDeleteSound (com.bladecoder.engineeditor.undo.UndoDeleteSound)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1