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);
}
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());
}
}
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);
}
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();
}
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();
}
Aggregations