mirror of
https://github.com/sigmasternchen/Dionysus
synced 2025-03-15 08:08:55 +00:00
update
This commit is contained in:
parent
57a6fab13f
commit
33db877cba
20 changed files with 905 additions and 121 deletions
47
src/main/java/net/persei/dionysus/Logger.java
Normal file
47
src/main/java/net/persei/dionysus/Logger.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package net.persei.dionysus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author overflow
|
||||
*
|
||||
*/
|
||||
public class Logger {
|
||||
|
||||
private static final String MUSIC_LOGFILE_NAME = "music.log";
|
||||
private static File musicLogFile;
|
||||
private static FileWriter musicLogFileWriter;
|
||||
|
||||
static {
|
||||
try {
|
||||
musicLogFile = new File(MUSIC_LOGFILE_NAME);
|
||||
musicLogFile.mkdirs();
|
||||
musicLogFile.delete();
|
||||
musicLogFile.createNewFile();
|
||||
musicLogFileWriter = new FileWriter(musicLogFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void logMusic(String file) {
|
||||
try {
|
||||
musicLogFileWriter.append(new File(file).toPath().toRealPath().toString() + "\n");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
try {
|
||||
musicLogFileWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,23 @@
|
|||
package net.persei.dionysus;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.sound.midi.MidiUnavailableException;
|
||||
|
||||
import net.persei.dionysus.commands.Command;
|
||||
import net.persei.dionysus.commands.DelayCommand;
|
||||
import net.persei.dionysus.commands.MultiCommand;
|
||||
import net.persei.dionysus.commands.MusicCommand;
|
||||
import net.persei.dionysus.commands.MusicCommandType;
|
||||
import net.persei.dionysus.commands.MusicPlayCommand;
|
||||
import net.persei.dionysus.commands.ProvokeCommand;
|
||||
import net.persei.dionysus.commands.ResetContextCommand;
|
||||
import net.persei.dionysus.commands.SetContextCommand;
|
||||
import net.persei.dionysus.commands.SoundFXComanndType;
|
||||
import net.persei.dionysus.commands.SoundFXCommand;
|
||||
import net.persei.dionysus.commands.VideoCommand;
|
||||
import net.persei.dionysus.commands.VideoCommandType;
|
||||
import net.persei.dionysus.commands.VideoPlayCommand;
|
||||
import net.persei.dionysus.events.Event;
|
||||
import net.persei.dionysus.exceptions.LibrariesNotFoundException;
|
||||
|
@ -16,6 +28,7 @@ import net.persei.dionysus.managers.MidiSource;
|
|||
import net.persei.dionysus.managers.MusicManager;
|
||||
import net.persei.dionysus.managers.PlayerManager;
|
||||
import net.persei.dionysus.managers.Sequence;
|
||||
import net.persei.dionysus.managers.SoundFXManager;
|
||||
import net.persei.dionysus.managers.VideoManager;
|
||||
import net.persei.dionysus.players.PlayerType;
|
||||
import uk.co.caprica.vlcj.binding.LibVlc;
|
||||
|
@ -24,34 +37,52 @@ import uk.co.caprica.vlcj.discovery.NativeDiscovery;
|
|||
public class Main {
|
||||
|
||||
public static final String TITLE = "Dionysus";
|
||||
private static VideoManager videoManager;
|
||||
private static CommandManager commandManager;
|
||||
private static MidiManager midiManager;
|
||||
private static Sequence contextSequence;
|
||||
private static Context musicContext;
|
||||
private static Context fxContext;
|
||||
private static Context videoContext;
|
||||
private static Context sceneContext;
|
||||
private static MusicManager musicManager;
|
||||
private static Context fightContext;
|
||||
private static SoundFXManager soundManager;
|
||||
public static boolean test = false;
|
||||
private static Scanner scanner;
|
||||
|
||||
public static void main(String[] args)
|
||||
throws LibrariesNotFoundException, MidiUnavailableException, InterruptedException {
|
||||
throws LibrariesNotFoundException, MidiUnavailableException, InterruptedException, FileNotFoundException {
|
||||
if (!findLibs())
|
||||
throw new LibrariesNotFoundException();
|
||||
System.out.println(LibVlc.INSTANCE.libvlc_get_version());
|
||||
|
||||
System.out.println("Instancing video manager...");
|
||||
VideoManager videoManager = new VideoManager("MainVideoManager");
|
||||
videoManager = new VideoManager("MainVideoManager");
|
||||
PlayerManager.getInstance().create(PlayerType.Video, "primary", true);
|
||||
PlayerManager.getInstance().create(PlayerType.Video, "secondary", true);
|
||||
|
||||
System.out.println("Instancing music manager...");
|
||||
MusicManager musicManager = new MusicManager("MainMusicManager");
|
||||
musicManager = new MusicManager("MainMusicManager");
|
||||
|
||||
System.out.println("Instancing sound fx manager...");
|
||||
soundManager = new SoundFXManager("MainSoundFXManager");
|
||||
|
||||
System.out.println("Instancing command manager...");
|
||||
CommandManager commandManager = new CommandManager();
|
||||
commandManager = new CommandManager();
|
||||
System.out.println("Instancing midi manager...");
|
||||
MidiManager midiManager = new MidiManager(commandManager);
|
||||
midiManager = new MidiManager(commandManager);
|
||||
|
||||
System.out.println("Adding commands...");
|
||||
|
||||
Sequence contextSequence = new Sequence().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 7, 0));
|
||||
contextSequence = new Sequence().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 7, 0));
|
||||
Sequence resetContext = new Sequence().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 6, 0));
|
||||
|
||||
Context musicContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 0, 0));
|
||||
Context fxContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 1, 0));
|
||||
Context videoContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 2, 0));
|
||||
Context unusedContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 3, 0));
|
||||
musicContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 0, 0));
|
||||
fxContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 1, 0));
|
||||
videoContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 2, 0));
|
||||
sceneContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 3, 0));
|
||||
fightContext = new Context().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 4, 0));
|
||||
|
||||
commandManager.addCommand(resetContext, new ResetContextCommand("ResetContext", commandManager));
|
||||
|
||||
|
@ -61,30 +92,543 @@ public class Main {
|
|||
new SetContextCommand("FXContext", commandManager, fxContext));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(videoContext),
|
||||
new SetContextCommand("VideoContext", commandManager, videoContext));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(unusedContext),
|
||||
new SetContextCommand("UnusedContext", commandManager, unusedContext));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(sceneContext),
|
||||
new SetContextCommand("SceneContext", commandManager, sceneContext));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(fightContext),
|
||||
new SetContextCommand("FightContext", commandManager, fightContext));
|
||||
|
||||
commandManager.addCommand(new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 7, 0)),
|
||||
new MusicPlayCommand("Play_Merlins's_Study", musicManager,
|
||||
"resources/audio/camelot/Merlin's Study.mp3"));
|
||||
commandManager.addCommand(new Sequence().append(new Event(MidiSource.LAUNCHPAD, true, 0, 8, 5, 0)),
|
||||
new MultiCommand("kill-everybody",
|
||||
new MusicCommand("stop-music", musicManager, MusicCommandType.stop, null, 0, false),
|
||||
new SoundFXCommand("stop-sound", soundManager, SoundFXComanndType.stop, null),
|
||||
new VideoCommand("stop-video-primary", VideoCommandType.stop, videoManager, "primary", null,
|
||||
false),
|
||||
new VideoCommand("stop-video-secondary", VideoCommandType.stop, videoManager, "secondary", null,
|
||||
false)));
|
||||
|
||||
commandManager.addCommand(new Sequence(videoContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 6, 0)),
|
||||
new VideoPlayCommand("Show_Mountains", videoManager, "primary",
|
||||
"resources/video/mountains.mp4", true));
|
||||
// Real Commands
|
||||
/*
|
||||
* ******************************************** NATURE
|
||||
* ********************************************
|
||||
*/
|
||||
|
||||
Context natureContext = new Context(sceneContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 0, 0));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(natureContext),
|
||||
new SetContextCommand("NutureSceneContext", commandManager, natureContext));
|
||||
|
||||
/*
|
||||
* FOREST
|
||||
*/
|
||||
|
||||
Sequence forestNoWaterSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 1, 0));
|
||||
commandManager.addCommand(forestNoWaterSequence, basicScene("forest", "forest.mp4", "environment/peace.mp3"));
|
||||
|
||||
Sequence forestWaterSequenceNoRain = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 1, 0));
|
||||
commandManager.addCommand(forestWaterSequenceNoRain,
|
||||
basicScene("forestWater2", "water2.mp4", "environment/peace2.mp3"));
|
||||
|
||||
Sequence forestWaterSequenceNoRain2 = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 1, 0));
|
||||
commandManager.addCommand(forestWaterSequenceNoRain2,
|
||||
basicScene("forestWater", "water.mp4", "environment/quiet.mp3"));
|
||||
|
||||
Sequence forestWaterSequenceRain = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 1, 0));
|
||||
commandManager.addCommand(forestWaterSequenceRain,
|
||||
basicScene("forestRain", "lake-storm.mp4", "environment/scene-specific/elves-woods.mp3"));
|
||||
|
||||
Sequence forestNoWaterChaseSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 1, 0));
|
||||
commandManager.addCommand(forestNoWaterChaseSequence,
|
||||
basicScene("forestChase", "forest.mp4", "environment/chase.mp3"));
|
||||
|
||||
Sequence forestNoWaterChase2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 1, 0));
|
||||
commandManager.addCommand(forestNoWaterChase2Sequence,
|
||||
basicScene("forestChase2", "forest.mp4", "environment/scene-specific/running-woods.mp3"));
|
||||
|
||||
Sequence forestWater2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 1, 0));
|
||||
commandManager.addCommand(forestWater2Sequence,
|
||||
basicScene("forestWater2", "river.mp4", "environment/scene-specific/river.mp3"));
|
||||
|
||||
Sequence forestWater3Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 1, 0));
|
||||
commandManager.addCommand(forestWater3Sequence,
|
||||
basicScene("forestWater3", "forest2.mp4", "environment/beginning.mp3"));
|
||||
|
||||
// TODO forest night
|
||||
|
||||
Sequence forestNightSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 2, 0));
|
||||
commandManager.addCommand(forestNightSequence,
|
||||
basicScene("forestNight1", "forest-night.mp4", "environment/night.mp3"));
|
||||
|
||||
Sequence forestNight2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 2, 0));
|
||||
commandManager.addCommand(forestNight2Sequence,
|
||||
basicScene("forestNight2", "forest-night.mp4", "environment/mystic.mp3"));
|
||||
|
||||
Sequence forestNight3Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 2, 0));
|
||||
commandManager.addCommand(forestNight3Sequence,
|
||||
basicScene("forestNight3", "forest-night.mp4", "environment/something-walk.mp3"));
|
||||
|
||||
/*
|
||||
* FIELD
|
||||
*/
|
||||
|
||||
Sequence fieldSunSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 3, 0));
|
||||
commandManager.addCommand(fieldSunSequence, basicScene("field", "field.mp4", "environment/land.mp3"));
|
||||
|
||||
Sequence fieldNoSunSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 3, 0));
|
||||
commandManager.addCommand(fieldNoSunSequence, basicScene("fieldNoSun", "field2.mp4", "environment/joyful.mp3"));
|
||||
|
||||
Sequence fieldSun2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 3, 0));
|
||||
commandManager.addCommand(fieldSun2Sequence, basicScene("field2", "field.mp4", "environment/life.mp3"));
|
||||
|
||||
Sequence fieldNoSun3Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 3, 0));
|
||||
commandManager.addCommand(fieldNoSun3Sequence,
|
||||
basicScene("fieldNoSun3", "field2.mp4", "environment/evening.ogg"));
|
||||
|
||||
Sequence fieldSun3Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 3, 0));
|
||||
commandManager.addCommand(fieldSun3Sequence, basicScene("fieldNoSun", "field.mp4", "environment/journey.mp3"));
|
||||
|
||||
/*
|
||||
* MOUNTAIN
|
||||
*/
|
||||
|
||||
Sequence mountainSeaSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 4, 0));
|
||||
commandManager.addCommand(mountainSeaSequence,
|
||||
basicScene("mountains", "mountains.mp4", "environment/equinox.mp3"));
|
||||
|
||||
Sequence mountainSnowSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 4, 0));
|
||||
commandManager.addCommand(mountainSnowSequence, basicScene("snow", "snow-storm.mp4", "environment/now.mp3"));
|
||||
|
||||
Sequence mountainSea2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 4, 0));
|
||||
commandManager.addCommand(mountainSea2Sequence,
|
||||
basicScene("mountains", "mountains.mp4", "environment/glory.mp3"));
|
||||
|
||||
Sequence mountainSnow2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 4, 0));
|
||||
commandManager.addCommand(mountainSnow2Sequence,
|
||||
basicScene("snow", "snow-storm.mp4", "environment/dynamic.mp3"));
|
||||
|
||||
/*
|
||||
* DESERT
|
||||
*/
|
||||
|
||||
Sequence dessertSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 5, 0));
|
||||
commandManager.addCommand(dessertSequence,
|
||||
basicScene("dessert", "dessert3.mp4", "environment/scene-specific/dessert.mp3"));
|
||||
|
||||
Sequence dessert2Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 5, 0));
|
||||
commandManager.addCommand(dessert2Sequence,
|
||||
basicScene("dessert2", "dessert.mp4", "environment/wind-journey.mp3"));
|
||||
|
||||
Sequence dessert3Sequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 5, 0));
|
||||
commandManager.addCommand(dessert3Sequence, basicScene("dessert3", "dessert2.mp4", "environment/try.mp3"));
|
||||
|
||||
/*
|
||||
* OCEAN
|
||||
*/
|
||||
|
||||
Sequence oceanSequence = new Sequence(natureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 6, 0));
|
||||
commandManager.addCommand(oceanSequence, basicScene("ocean", "ocean2.mp4", "environment/ocean.mp3"));
|
||||
|
||||
Sequence ocean2Sequence = new Sequence(natureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 6, 0));
|
||||
commandManager.addCommand(ocean2Sequence, basicScene("ocean2", "ocean.mp4", "environment/quiet.mp3"));
|
||||
|
||||
/*
|
||||
* NIGHT
|
||||
*/
|
||||
|
||||
Sequence nightSequence = new Sequence(natureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 7, 0));
|
||||
commandManager.addCommand(nightSequence, basicScene("night", "night.mp4", "environment/night.mp3"));
|
||||
|
||||
Sequence night2Sequence = new Sequence(natureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 7, 0));
|
||||
commandManager.addCommand(night2Sequence, basicScene("night2", "night.mp4", "environment/mystic2.mp3"));
|
||||
|
||||
Sequence nightmareSequence = new Sequence(natureContext)
|
||||
.append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 7, 0));
|
||||
commandManager.addCommand(nightmareSequence, basicScene("nightmare", "night.mp4", "environment/nightmare.mp3"));
|
||||
|
||||
/*
|
||||
* GARDEN
|
||||
*/
|
||||
Sequence gardenSequence = new Sequence(natureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 7, 0));
|
||||
commandManager.addCommand(gardenSequence, basicScene("garden", "garden.mp4", "environment/friendly.mp3"));
|
||||
|
||||
/*
|
||||
* ******************************************** CITIES
|
||||
* ********************************************
|
||||
*/
|
||||
|
||||
Context cityContext = new Context(sceneContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 0, 0));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(cityContext),
|
||||
new SetContextCommand("CitySceneContext", commandManager, cityContext));
|
||||
|
||||
Sequence elmaratu = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 1, 0));
|
||||
commandManager.addCommand(elmaratu,
|
||||
basicScene("elmaratu", "images/city/elmaratu.jpg", "environment/city-specific/elmaratu.mp3"));
|
||||
|
||||
Sequence silvas = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 1, 0));
|
||||
commandManager.addCommand(silvas,
|
||||
basicScene("silvas", "images/city/silvas.jpg", "environment/city-specific/silvas.mp3"));
|
||||
|
||||
Sequence feras = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 1, 0));
|
||||
commandManager.addCommand(feras,
|
||||
basicScene("feras", "images/city/feras.jpg", "environment/city-specific/feras.mp3"));
|
||||
|
||||
Sequence finas = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 2, 0));
|
||||
commandManager.addCommand(finas,
|
||||
basicScene("finas", "images/city/finas.jpg", "environment/city-specific/finas.ogg"));
|
||||
|
||||
Sequence novis = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 2, 0));
|
||||
commandManager.addCommand(novis,
|
||||
basicScene("novis", "images/city/novis.jpg", "environment/city-specific/novis.mp3"));
|
||||
|
||||
Sequence arata = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 3, 0));
|
||||
commandManager.addCommand(arata,
|
||||
basicScene("arata", "images/city/arata.jpg", "environment/city-specific/arata.ogg"));
|
||||
|
||||
Sequence mariat = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 3, 0));
|
||||
commandManager.addCommand(mariat,
|
||||
basicScene("mariat", "images/city/mariat.jpg", "environment/city-specific/mariat2.mp3"));
|
||||
|
||||
Sequence urbas = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 4, 0));
|
||||
commandManager.addCommand(urbas,
|
||||
basicScene("urbas", "images/city/urbas.jpg", "environment/city-specific/urbas.mp3"));
|
||||
|
||||
Sequence flumas = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 5, 0));
|
||||
commandManager.addCommand(flumas,
|
||||
basicScene("flumas", "images/city/flumas.jpg", "environment/city-specific/flumas.ogg"));
|
||||
|
||||
Sequence litera = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 5, 0));
|
||||
commandManager.addCommand(litera,
|
||||
basicScene("litera", "images/city/litera.jpg", "environment/city-specific/litera.ogg"));
|
||||
|
||||
Sequence versura = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 6, 0));
|
||||
commandManager.addCommand(versura,
|
||||
basicScene("versura", "images/city/versura.jpg", "environment/city-specific/versura.mp3"));
|
||||
|
||||
Sequence arem = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 3, 0));
|
||||
commandManager.addCommand(arem,
|
||||
basicScene("arem", "images/city/arem2.jpg", "environment/city-specific/arem.mp3"));
|
||||
|
||||
Sequence pesa = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 4, 0));
|
||||
commandManager.addCommand(pesa,
|
||||
basicScene("pesa", "images/city/pesa.jpg", "environment/city-specific/pesa.ogg"));
|
||||
|
||||
Sequence mansas = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 5, 0));
|
||||
commandManager.addCommand(mansas,
|
||||
basicScene("mansas", "images/city/mansas.jpg", "environment/city-specific/mansas2.ogg"));
|
||||
|
||||
Sequence lamata = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 4, 0));
|
||||
commandManager.addCommand(lamata,
|
||||
basicScene("lamata", "images/city/lamata.jpg", "environment/city-specific/lamata.mp3"));
|
||||
|
||||
Sequence porta = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 6, 0));
|
||||
commandManager.addCommand(porta,
|
||||
basicScene("porta", "images/city/porta.jpg", "environment/city-specific/porta.mp3"));
|
||||
|
||||
Sequence inlua = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 7, 0));
|
||||
commandManager.addCommand(inlua,
|
||||
basicScene("inlua", "images/city/inlua.jpg", "environment/city-specific/inlua.mp3"));
|
||||
|
||||
Sequence medala = new Sequence(cityContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 7, 0));
|
||||
commandManager.addCommand(medala,
|
||||
basicScene("medala", "images/city/medala.jpg", "environment/city-specific/medala.mp3"));
|
||||
|
||||
Context cityContext2 = new Context(sceneContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 0, 0));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(cityContext2),
|
||||
new SetContextCommand("CitySceneContext2", commandManager, cityContext2));
|
||||
|
||||
Sequence mansas2 = new Sequence(cityContext2).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 5, 0));
|
||||
commandManager.addCommand(mansas2,
|
||||
basicScene("mansas2", "images/city/mansas.jpg", "environment/city-specific/mansas.ogg"));
|
||||
|
||||
Sequence urbas2 = new Sequence(cityContext2).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 4, 0));
|
||||
commandManager.addCommand(urbas2,
|
||||
basicScene("urbas2", "images/city/urbas.jpg", "environment/city-specific/urbas2.ogg"));
|
||||
|
||||
Sequence flumas2 = new Sequence(cityContext2).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 5, 0));
|
||||
commandManager.addCommand(flumas2,
|
||||
basicScene("flumas2", "images/city/flumas.jpg", "environment/city-specific/flumas2.mp3"));
|
||||
|
||||
Sequence elmaratu2 = new Sequence(cityContext2).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 1, 0));
|
||||
commandManager.addCommand(elmaratu2,
|
||||
basicScene("elmaratu2", "images/city/elmaratu.jpg", "environment/city-specific/elmaratu3.mp3"));
|
||||
|
||||
/*
|
||||
* CULTURE
|
||||
*/
|
||||
|
||||
Context cultureContext = new Context(sceneContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 0, 0));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(cultureContext),
|
||||
new SetContextCommand("CultureSceneContext", commandManager, cultureContext));
|
||||
|
||||
Sequence church = new Sequence(cultureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 1, 0));
|
||||
commandManager.addCommand(church,
|
||||
new MultiCommand("church",
|
||||
new SoundFXCommand("playChurchDoor", soundManager, SoundFXComanndType.play,
|
||||
"resources/audio/sfx/door4.wav"),
|
||||
new DelayCommand("delayedChurchSounds",
|
||||
new SoundFXCommand("playChurchSounds", soundManager, SoundFXComanndType.play,
|
||||
"resources/audio/sfx/church2.wav"),
|
||||
500),
|
||||
basicScene("churchScene", "images/church.jpg", "gaudete.mp3")));
|
||||
|
||||
Sequence church2 = new Sequence(cultureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 2, 0));
|
||||
commandManager.addCommand(church2,
|
||||
new MultiCommand("church2",
|
||||
new SoundFXCommand("playChurchDoor", soundManager, SoundFXComanndType.play,
|
||||
"resources/audio/sfx/door4.wav"),
|
||||
new DelayCommand("delayedChurch2Sounds",
|
||||
new SoundFXCommand("playChurch2Sounds", soundManager, SoundFXComanndType.play,
|
||||
"resources/audio/sfx/church2.wav"),
|
||||
500),
|
||||
basicScene("church2Scene", "images/church2.jpg", "shchedryk.mp3")));
|
||||
|
||||
Sequence castle = new Sequence(cultureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 1, 0));
|
||||
commandManager.addCommand(castle, basicScene("castleScene", "images/castle.jpg", "environment/castle.mp3"));
|
||||
|
||||
Sequence castle2 = new Sequence(cultureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 2, 0));
|
||||
commandManager.addCommand(castle2, basicScene("castleScene", "images/castle.jpg", "environment/king-.ogg"));
|
||||
|
||||
Sequence heaven = new Sequence(cultureContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 7, 0));
|
||||
commandManager.addCommand(heaven, basicScene("heavenScene", "images/heaven.jpg", "angels.mp3"));
|
||||
|
||||
/*
|
||||
* FIREPLACE
|
||||
*/
|
||||
Context firePlaceContext = new Context(sceneContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 0, 0));
|
||||
commandManager.addCommand(new Sequence(contextSequence).append(firePlaceContext),
|
||||
new SetContextCommand("FireplaceSceneContext", commandManager, firePlaceContext));
|
||||
// TODO
|
||||
|
||||
// TODO
|
||||
|
||||
/*
|
||||
* FIGHTS
|
||||
*/
|
||||
|
||||
Sequence before = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 0, 0));
|
||||
commandManager.addCommand(before, new MusicPlayCommand("beforeMusic", musicManager,
|
||||
"resources/audio/environment/fights/before-fight.mp3", 1000, true));
|
||||
|
||||
Sequence roundBasedIntro = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 0, 0));
|
||||
commandManager.addCommand(roundBasedIntro,
|
||||
new MultiCommand("roundBasedSplitter",
|
||||
new MusicCommand("stopMusic", musicManager, MusicCommandType.stop, null, 200, false),
|
||||
new SoundFXCommand("playDrop", soundManager, SoundFXComanndType.play,
|
||||
"resources/audio/sfx/subfrequ2.wav")));
|
||||
|
||||
Sequence roundBased1 = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 1, 0));
|
||||
commandManager.addCommand(roundBased1, new MusicPlayCommand("round-based", musicManager,
|
||||
"resources/audio/environment/fights/fight-round-based.mp3", 200));
|
||||
|
||||
Sequence facing = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 0, 0));
|
||||
commandManager.addCommand(facing,
|
||||
new MultiCommand("facing1",
|
||||
new MusicPlayCommand("facingMusic", musicManager,
|
||||
"resources/audio/environment/fights/alive.mp3", 200, false),
|
||||
new DelayCommand("facing2Delay",
|
||||
new ProvokeCommand("facing2Command",
|
||||
new Sequence().append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 1, 0)),
|
||||
commandManager),
|
||||
(2 * 60) * 1000)));
|
||||
|
||||
Sequence black = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 1, 0));
|
||||
commandManager.addCommand(black, new MusicPlayCommand("blackMusic", musicManager,
|
||||
"resources/audio/environment/fights/black.mp3", 1000, true));
|
||||
|
||||
Sequence confrontation = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 0, 0));
|
||||
commandManager.addCommand(confrontation, new MusicPlayCommand("confrontationMusic", musicManager,
|
||||
"resources/audio/environment/fights/confrontation.mp3", 1000, true));
|
||||
|
||||
Sequence sorrow = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 7, 0));
|
||||
commandManager.addCommand(sorrow, new MusicPlayCommand("sorrowMusic", musicManager,
|
||||
"resources/audio/environment/fights/death-sorrow.ogg", 1000, true));
|
||||
|
||||
Sequence devil = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 7, 0));
|
||||
commandManager.addCommand(devil, new MusicPlayCommand("devilMusic", musicManager,
|
||||
"resources/audio/environment/fights/devil.mp3", 1000, true));
|
||||
|
||||
Sequence empire = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 7, 0));
|
||||
commandManager.addCommand(empire, new MusicPlayCommand("empireMusic", musicManager,
|
||||
"resources/audio/environment/fights/empire.mp3", 1000, true));
|
||||
|
||||
Sequence empire2 = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 6, 0));
|
||||
commandManager.addCommand(empire2, new MusicPlayCommand("empire2Music", musicManager,
|
||||
"resources/audio/environment/fights/empire2.mp3", 1000, true));
|
||||
|
||||
Sequence first = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 2, 0));
|
||||
commandManager.addCommand(first, new MusicPlayCommand("firstMusic", musicManager,
|
||||
"resources/audio/environment/fights/first.mp3", 1000, true));
|
||||
|
||||
Sequence fleeing = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 5, 0));
|
||||
commandManager.addCommand(fleeing, new MusicPlayCommand("fleeingMusic", musicManager,
|
||||
"resources/audio/environment/fights/fleeing.mp3", 1000, true));
|
||||
|
||||
Sequence fun = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 7, 0));
|
||||
commandManager.addCommand(fun, new MusicPlayCommand("funMusic", musicManager,
|
||||
"resources/audio/environment/fights/fun.ogg", 1000, true));
|
||||
|
||||
Sequence gate = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 1, 0));
|
||||
commandManager.addCommand(gate, new MusicPlayCommand("gateMusic", musicManager,
|
||||
"resources/audio/environment/fights/gate.mp3", 1000, true));
|
||||
|
||||
Sequence hell = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 4, 6, 0));
|
||||
commandManager.addCommand(hell, new MusicPlayCommand("hellMusic", musicManager,
|
||||
"resources/audio/environment/fights/hell.mp3", 1000, true));
|
||||
|
||||
Sequence mountains = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 7, 0));
|
||||
commandManager.addCommand(mountains, new MusicPlayCommand("mountainsMusic", musicManager,
|
||||
"resources/audio/environment/fights/mountains-battle.ogg", 1000, true));
|
||||
|
||||
Sequence power = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 0, 0));
|
||||
commandManager.addCommand(power, new MusicPlayCommand("powerMusic", musicManager,
|
||||
"resources/audio/environment/fights/power.mp3", 1000, true));
|
||||
|
||||
Sequence redemption = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 7, 0));
|
||||
commandManager.addCommand(redemption, new MusicPlayCommand("redemptionMusic", musicManager,
|
||||
"resources/audio/environment/fights/redemption.mp3", 1000, true));
|
||||
|
||||
Sequence secondary = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 3, 0));
|
||||
commandManager.addCommand(secondary, new MusicPlayCommand("secondaryMusic", musicManager,
|
||||
"resources/audio/environment/fights/secondary.mp3", 1000, true));
|
||||
|
||||
Sequence slow = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 0, 0));
|
||||
commandManager.addCommand(slow, new MusicPlayCommand("slowMusic", musicManager,
|
||||
"resources/audio/environment/fights/slow.ogg", 1000, true));
|
||||
|
||||
Sequence steel = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 2, 0));
|
||||
commandManager.addCommand(steel, new MusicPlayCommand("steelMusic", musicManager,
|
||||
"resources/audio/environment/fights/steel.mp3", 1000, true));
|
||||
|
||||
Sequence time = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 4, 0));
|
||||
commandManager.addCommand(time, new MusicPlayCommand("timeMusic", musicManager,
|
||||
"resources/audio/environment/fights/time.mp3", 1000, true));
|
||||
|
||||
Sequence trap = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 4, 0));
|
||||
commandManager.addCommand(trap, new MusicPlayCommand("trapMusic", musicManager,
|
||||
"resources/audio/environment/fights/trap.mp3", 1000, true));
|
||||
|
||||
Sequence veniVediVeci = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 2, 0));
|
||||
commandManager.addCommand(veniVediVeci, new MusicPlayCommand("veniVediVeciMusic", musicManager,
|
||||
"resources/audio/environment/fights/veni-vedi-veci.mp3", 1000, true));
|
||||
|
||||
Sequence victory = new Sequence(fightContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 6, 7, 0));
|
||||
commandManager.addCommand(victory, new MusicPlayCommand("victoryusic", musicManager,
|
||||
"resources/audio/environment/fights/victory.mp3", 1000, true));
|
||||
|
||||
/*
|
||||
* MUSIC
|
||||
*/
|
||||
|
||||
Sequence army = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 0, 0));
|
||||
commandManager.addCommand(army,
|
||||
new MusicPlayCommand("armyMusic", musicManager, "resources/audio/environment/army.ogg", 1000, true));
|
||||
|
||||
Sequence badTruth = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 0, 2, 0));
|
||||
commandManager.addCommand(badTruth, new MusicPlayCommand("badTruthMusic", musicManager,
|
||||
"resources/audio/environment/bad-truth.mp3", 1000, true));
|
||||
|
||||
Sequence blood = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 0, 0));
|
||||
commandManager.addCommand(blood,
|
||||
new MusicPlayCommand("bloodMusic", musicManager, "resources/audio/environment/blood.mp3", 1000, true));
|
||||
|
||||
Sequence chance = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 0, 0));
|
||||
commandManager.addCommand(chance, new MusicPlayCommand("chanceMusic", musicManager,
|
||||
"resources/audio/environment/chance.mp3", 1000, true));
|
||||
|
||||
Sequence change = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 2, 0));
|
||||
commandManager.addCommand(change, new MusicPlayCommand("changeMusic", musicManager,
|
||||
"resources/audio/environment/change.mp3", 1000, true));
|
||||
|
||||
Sequence chase = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 3, 0));
|
||||
commandManager.addCommand(chase,
|
||||
new MusicPlayCommand("chaseMusic", musicManager, "resources/audio/environment/chase.mp3", 1000, true));
|
||||
|
||||
Sequence danger = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 1, 1, 0));
|
||||
commandManager.addCommand(danger, new MusicPlayCommand("dangerMusic", musicManager,
|
||||
"resources/audio/environment/danger.ogg", 1000, true));
|
||||
|
||||
Sequence druidic = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 5, 0));
|
||||
commandManager.addCommand(druidic, new MusicPlayCommand("druidicMusic", musicManager,
|
||||
"resources/audio/environment/druidic.mp3", 1000, true));
|
||||
|
||||
Sequence dwarfs = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 7, 0));
|
||||
commandManager.addCommand(dwarfs, new MusicPlayCommand("dwarfsMusic", musicManager,
|
||||
"resources/audio/environment/dwarfs.mp3", 1000, true));
|
||||
|
||||
Sequence dwarfs2 = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 5, 6, 0));
|
||||
commandManager.addCommand(dwarfs2, new MusicPlayCommand("dwarfs2Music", musicManager,
|
||||
"resources/audio/environment/dwarfs2.mp3", 1000, true));
|
||||
|
||||
Sequence lightDark = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 2, 7, 0));
|
||||
commandManager.addCommand(lightDark, new MusicPlayCommand("lightDarkMusic", musicManager,
|
||||
"resources/audio/environment/light-dark.mp3", 1000, true));
|
||||
|
||||
Sequence race = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 3, 5, 0));
|
||||
commandManager.addCommand(race,
|
||||
new MusicPlayCommand("raceMusic", musicManager, "resources/audio/environment/race.mp3", 1000, true));
|
||||
|
||||
Sequence woundedLand = new Sequence(musicContext).append(new Event(MidiSource.LAUNCHPAD, true, 0, 7, 7, 0));
|
||||
commandManager.addCommand(woundedLand, new MusicPlayCommand("woundedLandMusic", musicManager,
|
||||
"resources/audio/environment/wounded-land.ogg", 1000, true));
|
||||
|
||||
System.out.println("Adding shutdown hook...");
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
midiManager.close();
|
||||
Logger.close();
|
||||
scanner.close();
|
||||
}
|
||||
});
|
||||
|
||||
while (true)
|
||||
Thread.sleep(Long.MAX_VALUE);
|
||||
|
||||
scanner = new Scanner(System.in);
|
||||
|
||||
while (true) {
|
||||
if (scanner.nextLine().contains("t")) {
|
||||
if (test) {
|
||||
System.out.println("Disabling test mode.");
|
||||
test = false;
|
||||
} else {
|
||||
System.out.println("Enabling test mode.");
|
||||
test = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// while (true)
|
||||
// Thread.sleep(Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
private static boolean findLibs() {
|
||||
return new NativeDiscovery().discover();
|
||||
}
|
||||
|
||||
private static Command basicScene(String scene, String videoFile, String musicFile) throws FileNotFoundException {
|
||||
Command video = new VideoPlayCommand("show " + scene, videoManager, "primary", "resources/video/" + videoFile,
|
||||
true);
|
||||
Command audio = new MusicPlayCommand("play " + scene, musicManager, "resources/audio/" + musicFile, 1000, true);
|
||||
return new MultiCommand("scene " + scene, video, audio);
|
||||
}
|
||||
}
|
||||
|
|
36
src/main/java/net/persei/dionysus/commands/DelayCommand.java
Normal file
36
src/main/java/net/persei/dionysus/commands/DelayCommand.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
public class DelayCommand extends Command {
|
||||
|
||||
private Command command;
|
||||
private long time;
|
||||
private String name;
|
||||
|
||||
public DelayCommand(String name, Command command, long time) {
|
||||
this.command = command;
|
||||
this.time = time;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
System.out.println(name + ": Executing " + command.getName());
|
||||
command.execute();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
41
src/main/java/net/persei/dionysus/commands/MultiCommand.java
Normal file
41
src/main/java/net/persei/dionysus/commands/MultiCommand.java
Normal file
|
@ -0,0 +1,41 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MultiCommand extends Command {
|
||||
private String name;
|
||||
private List<Command> commands;
|
||||
|
||||
public MultiCommand(String name, Command... commands) {
|
||||
this.name = name;
|
||||
this.commands = Arrays.asList(commands);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
for (Command command : commands) {
|
||||
System.out.println(name + ": Executing " + command.getName());
|
||||
command.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!obj.getClass().equals(this.getClass()))
|
||||
return false;
|
||||
MultiCommand command = (MultiCommand) obj;
|
||||
if (!command.getName().equals(this.getName()))
|
||||
return false;
|
||||
if (!command.commands.equals(commands))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import net.persei.dionysus.managers.MusicManager;
|
||||
|
||||
public class MusicCommand extends Command {
|
||||
|
@ -10,11 +13,14 @@ public class MusicCommand extends Command {
|
|||
private long duration;
|
||||
private boolean loop;
|
||||
|
||||
public MusicCommand(String name, MusicManager musicManager, MusicCommandType type, String file, long duration, boolean loop) {
|
||||
public MusicCommand(String name, MusicManager musicManager, MusicCommandType type, String file, long duration, boolean loop) throws FileNotFoundException {
|
||||
this.name = name;
|
||||
this.musicManager = musicManager;
|
||||
this.type = type;
|
||||
this.file = file;
|
||||
if (file != null)
|
||||
if (!new File(file).exists())
|
||||
throw new FileNotFoundException(file);
|
||||
this.duration = duration;
|
||||
this.loop = loop;
|
||||
}
|
||||
|
|
|
@ -1,18 +1,20 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import net.persei.dionysus.managers.MusicManager;
|
||||
|
||||
public class MusicPlayCommand extends MusicCommand {
|
||||
public MusicPlayCommand(String name, MusicManager musicManager, String file) {
|
||||
public MusicPlayCommand(String name, MusicManager musicManager, String file) throws FileNotFoundException {
|
||||
this(name, musicManager, file, 0);
|
||||
}
|
||||
|
||||
public MusicPlayCommand(String name, MusicManager musicManager, String file, long duration) {
|
||||
public MusicPlayCommand(String name, MusicManager musicManager, String file, long duration) throws FileNotFoundException {
|
||||
this(name, musicManager, file, duration, true);
|
||||
}
|
||||
|
||||
public MusicPlayCommand(String name, MusicManager musicManager, String file, long duration,
|
||||
boolean loop) {
|
||||
boolean loop) throws FileNotFoundException {
|
||||
super(name, musicManager, MusicCommandType.play, file, duration, loop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import net.persei.dionysus.managers.CommandManager;
|
||||
import net.persei.dionysus.managers.Sequence;
|
||||
|
||||
public class ProvokeCommand extends Command {
|
||||
|
||||
private Sequence sequence;
|
||||
private String name;
|
||||
private CommandManager commandManager;
|
||||
|
||||
public ProvokeCommand(String name, Sequence sequence, CommandManager commandManager) {
|
||||
this.sequence = sequence;
|
||||
this.name = name;
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
commandManager.registerSequence(sequence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import net.persei.dionysus.managers.MusicManager;
|
||||
import net.persei.dionysus.managers.SoundFXManager;
|
||||
|
||||
public class SoundFXCommand extends Command {
|
||||
|
@ -9,10 +8,11 @@ public class SoundFXCommand extends Command {
|
|||
private SoundFXManager soundManager;
|
||||
private String file;
|
||||
|
||||
public SoundFXCommand(String name, SoundFXManager soundManager, MusicCommandType type, String file) {
|
||||
public SoundFXCommand(String name, SoundFXManager soundManager, SoundFXComanndType type, String file) {
|
||||
this.name = name;
|
||||
this.soundManager = soundManager;
|
||||
this.file = file;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public SoundFXCommand(String name) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import net.persei.dionysus.managers.VideoManager;
|
||||
|
||||
public class VideoCommand extends Command {
|
||||
|
@ -11,10 +14,13 @@ public class VideoCommand extends Command {
|
|||
private boolean loop;
|
||||
|
||||
public VideoCommand(String name, VideoCommandType type, VideoManager videoManager, String playerName, String file,
|
||||
boolean loop) {
|
||||
boolean loop) throws FileNotFoundException {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.videoManager = videoManager;
|
||||
if (file != null)
|
||||
if (!new File(file).exists())
|
||||
throw new FileNotFoundException(file);
|
||||
this.file = file;
|
||||
this.playerName = playerName;
|
||||
this.loop = loop;
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package net.persei.dionysus.commands;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import net.persei.dionysus.managers.VideoManager;
|
||||
|
||||
public class VideoPlayCommand extends VideoCommand {
|
||||
public VideoPlayCommand(String name, VideoManager videoManager, String playerName,
|
||||
String file, boolean loop) {
|
||||
String file, boolean loop) throws FileNotFoundException {
|
||||
super(name, VideoCommandType.play, videoManager, playerName, file, loop);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
package net.persei.dionysus.managers;
|
||||
|
||||
public interface Command {
|
||||
void execute();
|
||||
String getName();
|
||||
}
|
|
@ -3,6 +3,7 @@ package net.persei.dionysus.managers;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.persei.dionysus.Main;
|
||||
import net.persei.dionysus.commands.Command;
|
||||
import net.persei.dionysus.events.Event;
|
||||
|
||||
|
@ -54,6 +55,20 @@ public class CommandManager {
|
|||
|
||||
static public long maxInterval = 1 * 1000;
|
||||
|
||||
public boolean registerSequence(Sequence sequence) {
|
||||
checkTimeout();
|
||||
this.sequence.addAll(sequence);
|
||||
lastChange = System.currentTimeMillis();
|
||||
return checkForCommand();
|
||||
}
|
||||
|
||||
private void checkTimeout() {
|
||||
if (System.currentTimeMillis() - lastChange > maxInterval) {
|
||||
this.sequence = new Sequence(context);
|
||||
executedCommands = new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean registerEvent(Event event) {
|
||||
if (System.currentTimeMillis() - lastChange > maxInterval) {
|
||||
sequence = new Sequence(context);
|
||||
|
@ -77,6 +92,7 @@ public class CommandManager {
|
|||
if (executedCommands.contains(ct))
|
||||
continue;
|
||||
System.out.println("Executing " + ct.command.getName() + "...");
|
||||
if (!Main.test)
|
||||
ct.command.execute();
|
||||
executedCommands.add(ct);
|
||||
result = true;
|
||||
|
@ -91,6 +107,38 @@ public class CommandManager {
|
|||
|
||||
public void addCommand(Sequence sequence, Command command) {
|
||||
System.out.println("Adding command " + command.getName() + " on " + sequence);
|
||||
if (containsSequence(sequence)) {
|
||||
System.err.println("#########\nDuplicated sequence!\n#########");
|
||||
return;
|
||||
}
|
||||
commands.add(new CommandTuple(sequence, command));
|
||||
}
|
||||
|
||||
private boolean containsSequence(Sequence sequence) {
|
||||
for (CommandTuple tuple : commands) {
|
||||
if (tuple.sequence.equals(sequence))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<Event> getEventsOfCommandsInSequence() {
|
||||
checkTimeout();
|
||||
List<Event> events = new LinkedList<Event>();
|
||||
for (CommandTuple tuple : commands) {
|
||||
int miss = 0;
|
||||
Event missedEvent = null;
|
||||
for (Event event : tuple.sequence) {
|
||||
if (sequence.contains(event))
|
||||
continue;
|
||||
if (++miss > 1)
|
||||
break;
|
||||
missedEvent = event;
|
||||
}
|
||||
if (miss != 1)
|
||||
continue;
|
||||
events.add(missedEvent);
|
||||
}
|
||||
return events;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,13 @@ package net.persei.dionysus.managers;
|
|||
import net.persei.dionysus.events.Event;
|
||||
|
||||
public class Context extends Sequence {
|
||||
public Context(Context context) {
|
||||
super();
|
||||
addAll(context);
|
||||
}
|
||||
public Context() {
|
||||
super();
|
||||
}
|
||||
public Context append(Event event) {
|
||||
add(event);
|
||||
return this;
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
package net.persei.dionysus.managers;
|
||||
|
||||
public class Event {
|
||||
static private boolean velocitySensitive = false;
|
||||
|
||||
private MidiSource source;
|
||||
private boolean press;
|
||||
private int channel;
|
||||
private int x;
|
||||
private int y;
|
||||
private int v;
|
||||
|
||||
public Event(MidiSource source, boolean press, int channel, int x, int y, int v) {
|
||||
this.source = source;
|
||||
this.press = press;
|
||||
this.channel = channel;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public static boolean isVelocitySensitive() {
|
||||
return velocitySensitive;
|
||||
}
|
||||
|
||||
public static void setVelocitySensitive(boolean velocitySensitive) {
|
||||
Event.velocitySensitive = velocitySensitive;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof Event))
|
||||
return false;
|
||||
Event event = (Event) obj;
|
||||
if (event.source != source)
|
||||
return false;
|
||||
if (event.press != press)
|
||||
return false;
|
||||
if (event.channel != channel)
|
||||
return false;
|
||||
if (event.x != x)
|
||||
return false;
|
||||
if (event.y != y)
|
||||
return false;
|
||||
if (velocitySensitive)
|
||||
if (event.v != v)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return (press ? "press" : "release") + " on " + source + " x:" + x + ", y:" + y + ", v:" + v;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ import javax.sound.midi.MidiDevice;
|
|||
import javax.sound.midi.MidiMessage;
|
||||
import javax.sound.midi.MidiDevice.Info;
|
||||
|
||||
import net.persei.dionysus.commands.Command;
|
||||
import net.persei.dionysus.events.Event;
|
||||
|
||||
public class MidiManager {
|
||||
|
@ -28,6 +29,8 @@ public class MidiManager {
|
|||
|
||||
System.out.println("Searching for midi devices...");
|
||||
for (Info info : infos) {
|
||||
if (info.getName().contains("[default]"))
|
||||
continue;
|
||||
MidiDevice device = MidiSystem.getMidiDevice(info);
|
||||
if (info.getName().contains("MPD18")) {
|
||||
System.out.println("Found MPD18: " + info.getName());
|
||||
|
@ -110,8 +113,10 @@ public class MidiManager {
|
|||
}
|
||||
|
||||
private void handle(boolean press, MidiSource source, int channel, int x, int y, int v) {
|
||||
System.out.println(press + " on " + source + ": " + x + ", " + y + " - " + v);
|
||||
commandManager.registerEvent(new Event(source, press, channel, x, y, v));
|
||||
// System.out.println(press + " on " + source + ": " + x + ", " + y + " - " + v);
|
||||
if (commandManager.registerEvent(new Event(source, press, channel, x, y, v))) {
|
||||
// System.out.println("no command on " + source + ": " + x + ", " + y + " - " + v);
|
||||
}
|
||||
}
|
||||
|
||||
public void feedbackSequence() {
|
||||
|
@ -138,29 +143,63 @@ public class MidiManager {
|
|||
return;
|
||||
}
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
List<Event> events = new Sequence(commandManager.getSequence());
|
||||
List<Event> context = commandManager.getContext();
|
||||
List<Event> available = commandManager.getEventsOfCommandsInSequence();
|
||||
|
||||
for (Event event : context) {
|
||||
if (events.contains(event))
|
||||
events.remove(event);
|
||||
}
|
||||
|
||||
for (Event event : available) {
|
||||
if (events.contains(event))
|
||||
events.remove(event);
|
||||
}
|
||||
|
||||
int intensity = 0x03
|
||||
- (int) ((3.0 * (System.currentTimeMillis() - commandManager.getLastChange())
|
||||
/ CommandManager.maxInterval));
|
||||
|
||||
clearLaunchpad(launchpad);
|
||||
for (Event event : context) {
|
||||
setLaunchpad(launchpad, event.getX(), event.getY(), 0x00, 0x03);
|
||||
}
|
||||
if (intensity > 0) {
|
||||
for (Event event : events) {
|
||||
setLaunchpad(launchpad, event.getX(), event.getY(), intensity, 0x00);
|
||||
for (int x = 0; x < 9; x++) {
|
||||
for (int y = 0; y < 8; y++) {
|
||||
if (coordinateIsInEventList(context, x, y))
|
||||
setLaunchpad(launchpad, x, y, 0x00, 0x03);
|
||||
else if (intensity > 0 && coordinateIsInEventList(events, x, y))
|
||||
setLaunchpad(launchpad, x, y, intensity, 0x00);
|
||||
else if (coordinateIsInEventList(available, x, y))
|
||||
setLaunchpad(launchpad, x, y, 0x01, 0x01);
|
||||
else
|
||||
setLaunchpad(launchpad, x, y, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// clearLaunchpad(launchpad);
|
||||
//
|
||||
// for (Event event : context) {
|
||||
// if (event.getSource() != MidiSource.LAUNCHPAD)
|
||||
// continue;
|
||||
// setLaunchpad(launchpad, event.getX(), event.getY(), 0x00, 0x03);
|
||||
// }
|
||||
//
|
||||
// for (Event event : available) {
|
||||
// if (event.getSource() != MidiSource.LAUNCHPAD)
|
||||
// continue;
|
||||
// setLaunchpad(launchpad, event.getX(), event.getY(), 0x01, 0x01);
|
||||
// }
|
||||
//
|
||||
// if (intensity > 0) {
|
||||
// for (Event event : events) {
|
||||
// if (event.getSource() != MidiSource.LAUNCHPAD)
|
||||
// continue;
|
||||
// setLaunchpad(launchpad, event.getX(), event.getY(), intensity, 0x00);
|
||||
// }
|
||||
// }
|
||||
Thread.sleep(100);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -190,4 +229,14 @@ public class MidiManager {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean coordinateIsInEventList(List<Event> events, int x, int y) {
|
||||
for (Event event : events) {
|
||||
if (event.getSource() != MidiSource.LAUNCHPAD)
|
||||
continue;
|
||||
if (event.getX() == x && event.getY() == y)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package net.persei.dionysus.managers;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.persei.dionysus.players.AudioPlayer;
|
||||
import net.persei.dionysus.players.PlayerType;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
|
@ -26,13 +28,18 @@ public class MusicManager {
|
|||
public void change(String file, long fadeduration, boolean loop) {
|
||||
if (!isPlaying[0]) {
|
||||
// use 0
|
||||
System.out.println("Using crossfade player 0.");
|
||||
stopPlayer(1, fadeduration);
|
||||
startPlayer(0, file, fadeduration, loop);
|
||||
System.out.println("Done.");
|
||||
} else if (!isPlaying[1]) {
|
||||
// use 2
|
||||
// use 1
|
||||
System.out.println("Using crossfade player 1.");
|
||||
stopPlayer(0, fadeduration);
|
||||
startPlayer(1, file, fadeduration, loop);
|
||||
System.out.println("Done.");
|
||||
} else {
|
||||
System.err.println("No player applicable for " + file + ".");
|
||||
// no player is applicable
|
||||
}
|
||||
}
|
||||
|
@ -56,23 +63,33 @@ public class MusicManager {
|
|||
|
||||
crossfadePlayers[playerId].playFile(file);
|
||||
crossfadePlayers[playerId].setLoop(loop);
|
||||
if (fadeduration == 0) {
|
||||
|
||||
try {
|
||||
|
||||
if (fadeduration < 0.1) {
|
||||
player.setVolume(BASE_VOLUME);
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.sleep(50);
|
||||
player.setVolume(0);
|
||||
Thread.sleep(50);
|
||||
|
||||
int targetVolume = BASE_VOLUME;
|
||||
int sourceVolume = 0;
|
||||
int stepsPerSecond = 10;
|
||||
int sourceVolume = player.getVolume();
|
||||
int stepsPerSecond = 20;
|
||||
int numberOfSteps = (int) ((fadeduration * stepsPerSecond) / 1000);
|
||||
int msPerStep = (int) (fadeduration / numberOfSteps);
|
||||
int incrementPerStep = (sourceVolume - targetVolume) / numberOfSteps;
|
||||
int incrementPerStep = -(sourceVolume - targetVolume) / numberOfSteps;
|
||||
|
||||
// System.out.println(targetVolume + ", " + sourceVolume + ", " + stepsPerSecond + ", " + numberOfSteps
|
||||
// + ", " + msPerStep + ", " + incrementPerStep);
|
||||
|
||||
try {
|
||||
for (int i = 0; i < numberOfSteps; i++) {
|
||||
player.setVolume(player.getVolume() + incrementPerStep);
|
||||
Thread.sleep(msPerStep);
|
||||
int val = player.getVolume() + incrementPerStep;
|
||||
// System.out.println(val);
|
||||
player.setVolume(val);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -88,8 +105,15 @@ public class MusicManager {
|
|||
private void stopPlayer(int playerId, long fadeduration) {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
if (!crossfadePlayers[playerId].isPlaying())
|
||||
if (!crossfadePlayers[playerId].isPlaying()) {
|
||||
setPlaying(playerId, false);
|
||||
return;
|
||||
}
|
||||
if (fadeduration < 0.1) {
|
||||
crossfadePlayers[playerId].stop();
|
||||
setPlaying(playerId, false);
|
||||
return;
|
||||
}
|
||||
MediaPlayer player = crossfadePlayers[playerId].getMediaPlayer();
|
||||
int targetVolume = 0;
|
||||
int sourceVolume = player.getVolume();
|
||||
|
|
|
@ -18,12 +18,14 @@ public class SoundFXManager {
|
|||
for (AudioPlayer player : players) {
|
||||
if (player.isPlaying())
|
||||
continue;
|
||||
player.getMediaPlayer().setVolume(100);
|
||||
player.playFile(file);
|
||||
return;
|
||||
}
|
||||
AudioPlayer player = (AudioPlayer) PlayerManager.getInstance().create(PlayerType.Audio,
|
||||
"FXPlayer_" + name + "_" + players.size());
|
||||
players.add(player);
|
||||
player.getMediaPlayer().setVolume(100);
|
||||
player.playFile(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ public class VideoManager {
|
|||
public void play(String name, String file, boolean loop) {
|
||||
getVideoPlayer(name).playFile(file);
|
||||
getVideoPlayer(name).setLoop(loop);
|
||||
getVideoPlayer(name).getMediaPlayer().setVolume(70);
|
||||
}
|
||||
|
||||
public void play(String name) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.persei.dionysus.players;
|
||||
|
||||
import net.persei.dionysus.Logger;
|
||||
import uk.co.caprica.vlcj.component.AudioMediaPlayerComponent;
|
||||
import uk.co.caprica.vlcj.player.MediaPlayer;
|
||||
|
||||
|
@ -19,6 +20,7 @@ public class AudioPlayer implements Player {
|
|||
}
|
||||
|
||||
public void playFile(String file) {
|
||||
Logger.logMusic(file);
|
||||
getMediaPlayer().playMedia(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class VideoPlayer extends JFrame implements Player {
|
|||
setVisible(true);
|
||||
}
|
||||
public VideoPlayer(String name) throws HeadlessException {
|
||||
super(Main.TITLE);
|
||||
super(Main.TITLE + " - " + name);
|
||||
|
||||
this.name = name;
|
||||
setBounds(100, 100, 600, 400);
|
||||
|
|
Loading…
Reference in a new issue