Moved two apps to seperate bundle and chains.

This commit is contained in:
Willem Cazander 2022-03-03 23:20:19 +01:00
parent 812e80fa5e
commit c47d626eef
57 changed files with 1011 additions and 305 deletions

View file

@ -1,9 +1,118 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gdxapp4d-app-tosamp</artifactId>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gdxapp4d-app-tosamp</artifactId>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>love.distributedrebirth.gdxapp4d</groupId>
<artifactId>gdxapp4d-vrgem4</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<exportScr>true</exportScr>
<instructions>
<_donotcopy>(.git)</_donotcopy>
<_dsannotations>*</_dsannotations>
<_metatypeannotations>*</_metatypeannotations>
<Import-Package>
org.osgi.framework,
org.osgi.service.packageadmin,
org.osgi.service.url,
org.osgi.service.startlevel,
org.osgi.util.tracker,
love.distributedrebirth.gdxapp4d.tos4.service,
love.distributedrebirth.gdxapp4d.vrgem4.service,
love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp,
com.badlogic.gdx,
com.badlogic.gdx.assets,
com.badlogic.gdx.assets.loaders,
com.badlogic.gdx.assets.loaders.resolvers,
com.badlogic.gdx.audio,
com.badlogic.gdx.files,
com.badlogic.gdx.graphics,
com.badlogic.gdx.graphics.g2d,
com.badlogic.gdx.graphics.g2d.freetype,
com.badlogic.gdx.graphics.g3d,
com.badlogic.gdx.graphics.g3d.attributes,
com.badlogic.gdx.graphics.g3d.decals,
com.badlogic.gdx.graphics.g3d.environment,
com.badlogic.gdx.graphics.g3d.loader,
com.badlogic.gdx.graphics.g3d.model,
com.badlogic.gdx.graphics.g3d.model.data,
com.badlogic.gdx.graphics.g3d.particles,
com.badlogic.gdx.graphics.g3d.particles.bactches,
com.badlogic.gdx.graphics.g3d.particles.emitters,
com.badlogic.gdx.graphics.g3d.particles.influencers,
com.badlogic.gdx.graphics.g3d.particles.renderers,
com.badlogic.gdx.graphics.g3d.particles.values,
com.badlogic.gdx.graphics.g3d.shaders,
com.badlogic.gdx.graphics.g3d.utils,
com.badlogic.gdx.graphics.g3d.utils.shapebuilders,
com.badlogic.gdx.graphics.glutils,
com.badlogic.gdx.graphics.profiling,
com.badlogic.gdx.input,
com.badlogic.gdx.maps,
com.badlogic.gdx.maps.objects,
com.badlogic.gdx.maps.tiled,
com.badlogic.gdx.maps.tiled.objects,
com.badlogic.gdx.maps.tiled.renderers,
com.badlogic.gdx.maps.tiled.tiles,
com.badlogic.gdx.math,
com.badlogic.gdx.math.collision,
com.badlogic.gdx.net,
com.badlogic.gdx.scenes.scene2d,
com.badlogic.gdx.scenes.scene2d.actions,
com.badlogic.gdx.scenes.scene2d.ui,
com.badlogic.gdx.scenes.scene2d.utils,
com.badlogic.gdx.utils,
com.badlogic.gdx.utils.async,
com.badlogic.gdx.utils.compression,
com.badlogic.gdx.utils.compression.lz,
com.badlogic.gdx.utils.compression.lzma,
com.badlogic.gdx.utils.compression.rangecoder,
com.badlogic.gdx.utils.reflect,
com.badlogic.gdx.utils.viewport,
imgui,
imgui.flag,
imgui.glfw,
imgui.gl3,
imgui.type,
net.spookygames.gdx.nativefilechooser,
love.distributedrebirth.bassboonyd,
love.distributedrebirth.bassboonyd.jmx,
love.distributedrebirth.numberxd,
love.distributedrebirth.numberxd.base2t,
love.distributedrebirth.numberxd.base2t.part,
love.distributedrebirth.numberxd.base2t.part.warp,
love.distributedrebirth.numberxd.base2t.type,
love.distributedrebirth.numberxd.base2t.typexl,
love.distributedrebirth.numberxd.glyph,
love.distributedrebirth.numberxd.x4o,
love.distributedrebirth.warpme,
love.distributedrebirth.warpme.core,
love.distributedrebirth.warpme.hash,
love.distributedrebirth.warpme.sea,
love.distributedrebirth.warpme.ship,
love.distributedrebirth.unicode4d,
love.distributedrebirth.unicode4d.atlas
</Import-Package>
<Bundle-Vendor>distributedrebirth.love</Bundle-Vendor>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<root:ocean xmlns:root="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root"
xmlns:link="http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-link"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://wrap-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root http://warp-sea.x4o.distributedrebirth.love/xml/ns/warp-sea-root-1.0.xsd">
<link:sea name="TosAmp" provider="gdxapp4d.apps" author="willemtsade">
<link:magic file="gdxapp4d-app-tosamp.jar" mime="application/vnd.osgi.bundle"/>
</link:sea>
</root:ocean>

View file

@ -0,0 +1,34 @@
package love.distributedrebirth.gdxapp4d.app.tosamp;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
@Component
public class TosAmpComponent {
@Reference
private SystemGdxLog log;
@Reference
private VrGem4DeskAppService deskAppService;
@Reference
private SystemGdxBootArgs bootArgs;
@Activate
void open() {
log.info(this, "Activated TosAmpComponent");
deskAppService.registrateDeskApp(new DeskAppLauncher("TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser())));
}
@Deactivate
void close() {
}
}

View file

@ -0,0 +1,130 @@
package love.distributedrebirth.gdxapp4d.app.tosamp;
import java.util.function.Consumer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import imgui.ImGui;
import imgui.flag.ImGuiSelectableFlags;
import imgui.flag.ImGuiTableColumnFlags;
import imgui.flag.ImGuiTableFlags;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp4d.app.tosamp.music.MusicManager;
import love.distributedrebirth.gdxapp4d.app.tosamp.music.MusicSong;
import love.distributedrebirth.gdxapp4d.vrgem4.FontAwesomeIcons;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.AbstractDeskApp;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppContourSection;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer;
import net.spookygames.gdx.nativefilechooser.NativeFileChooser;
import net.spookygames.gdx.nativefilechooser.NativeFileChooserCallback;
import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
private final MusicManager music;
private final NativeFileChooser fileChooser;
private NativeFileChooserConfiguration fileChooserConfig;
public TosAmpDeskApp(NativeFileChooser fileChooser) {
this.fileChooser = fileChooser;
this.music = new MusicManager();
}
public void create() {
getContours().setTitle("\uf001 TosAmp");
getContours().registrateContour(DeskAppContourSection.MAIN, this);
getContours().registrateContour(DeskAppContourSection.FILE_NEW, new DeskAppRenderer() {
@Override
public void render() {
if (ImGui.menuItem(FontAwesomeIcons.Plus + " Add")) {
fileChooser.chooseFile(fileChooserConfig,
NativeFileChooserCallbackAdapter.onFileChosen(v -> music.addBackgroundMusic(v)));
}
}
});
fileChooserConfig = new NativeFileChooserConfiguration();
fileChooserConfig.directory = Gdx.files.absolute(System.getProperty("user.home"));
fileChooserConfig.mimeFilter = "audio/*";
fileChooserConfig.title = "Choose audio file";
}
@Override
public void render() {
ImGui.text("Current Song:");
MusicSong currentSong = music.getCurrentSong();
if (currentSong != null) {
ImGui.sameLine();
ImGui.text(currentSong.getName());
}
ImGui.separator();
if (currentSong != null) {
if (ImGui.button("Play")) {
music.play(currentSong);
}
} else {
ImGui.text("Play");
}
ImGui.sameLine();
if (ImGui.button("<")) {
music.prev();
}
ImGui.sameLine();
if (ImGui.button(">")) {
music.next();
}
ImGui.sameLine();
if (ImGui.button("Stop")) {
music.stop();
}
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
ImGui.beginTable("playlist", 3, flags);
ImGui.tableSetupColumn("#", ImGuiTableColumnFlags.NoHide);
ImGui.tableSetupColumn("Play");
ImGui.tableSetupColumn("Name");
ImGui.tableHeadersRow();
int i=1;
for (MusicSong song:music.getBackgroundSongs()) {
ImGui.pushID(i);
ImGui.tableNextRow();
ImGui.tableNextColumn();
ImGui.selectable(""+i, song.isPlaying(), ImGuiSelectableFlags.None);
ImGui.tableNextColumn();
if (ImGui.smallButton(">")) {
music.play(song);
}
ImGui.tableNextColumn();
ImGui.selectable(song.getName(), song.isPlaying(), ImGuiSelectableFlags.None);
ImGui.popID();
i++;
}
ImGui.endTable();
}
static class NativeFileChooserCallbackAdapter implements NativeFileChooserCallback {
@Override
public void onFileChosen(FileHandle file) {
}
@Override
public void onCancellation() {
}
@Override
public void onError(Exception exception) {
}
static NativeFileChooserCallbackAdapter onFileChosen(Consumer<FileHandle> eater) {
return new NativeFileChooserCallbackAdapter() {
@Override
public void onFileChosen(FileHandle file) {
eater.accept(file);
}
};
}
}
}

View file

@ -0,0 +1,38 @@
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class M3UParser {
private static final String M3U_HEADER = "#EXTM3U";
public class M3UPlaylist {
private List<M3UTrack> tracks = new ArrayList<>();
}
public class M3UTrack {
}
public M3UPlaylist parse(InputStream stream) throws IOException {
M3UPlaylist result = new M3UPlaylist();
BufferedReader buffer = new BufferedReader(new InputStreamReader(stream));
String line = buffer.readLine();
if (!line.startsWith(M3U_HEADER)) {
throw new IOException("Missing header");
}
while ((line = buffer.readLine()) != null) {
}
return result;
}
}

View file

@ -0,0 +1,143 @@
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
import java.util.ArrayList;
import java.util.List;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Music.OnCompletionListener;
import com.badlogic.gdx.files.FileHandle;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
/**
* Manages the background and others songs.
*/
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class MusicManager {
// private final MusicSong introSong;
// private final MusicSong creditsSong;
private final List<MusicSong> backgroundSongs;
private final NextSongListener nextSongListener;
private MusicSong currentSong = null;
private boolean noMusic = false;
public MusicManager() {
backgroundSongs = new ArrayList<>();
// introSong = new MusicSong(Gdx.audio.newMusic(Gdx.files.internal("music/panoramacircle-waterfowl.mp3")),"panoramacircle-waterfowl");
// creditsSong = new MusicSong(Gdx.audio.newMusic(Gdx.files.internal("music/idtech-doom-sigil.mp3")), "idtech-doom-sigil");
nextSongListener = new NextSongListener();
}
public void addBackgroundMusic(FileHandle file) {
Music music = Gdx.audio.newMusic(file);
music.setOnCompletionListener(nextSongListener);
backgroundSongs.add(new MusicSong(music, file.name()));
}
public void init(boolean noMusic) {
this.noMusic = noMusic;
/*
addBackgroundMusic(Gdx.files.internal("music/sanctumwave-risen.mp3"));
addBackgroundMusic(Gdx.files.internal("music/sanctumwave-devine-intellect.mp3"));
addBackgroundMusic(Gdx.files.internal("music/theselfhelpgroup-temple-os.mp3"));
addBackgroundMusic(Gdx.files.internal("music/sanctumwave-nightwalk.mp3"));
addBackgroundMusic(Gdx.files.internal("music/beeble-i-used-temple-os-to-write.mp3"));
addBackgroundMusic(Gdx.files.internal("music/ryanfarran-risen-temple-os.mp3"));
*/
}
public void dispose() {
// introSong.music.dispose();
// creditsSong.music.dispose();
for (MusicSong song:backgroundSongs) {
song.music.dispose();
}
}
public List<MusicSong> getBackgroundSongs() {
return backgroundSongs;
}
public MusicSong getCurrentSong() {
return currentSong;
}
public void stop() {
if (currentSong != null) {
currentSong.music.stop();
}
}
public void play(MusicSongType type) {
MusicSong nextSong = null;
if (MusicSongType.INTRO.equals(type)) {
// nextSong = introSong;
// play(nextSong);
} else if (MusicSongType.CREDITS.equals(type)) {
// nextSong = creditsSong;
// play(nextSong);
} else {
int currentBackground = backgroundSongs.indexOf(currentSong);
if (currentBackground == -1 && !backgroundSongs.isEmpty()) {
nextSong = backgroundSongs.get(0);
} else {
nextSong = currentSong;
}
if (!noMusic && nextSong!=null) {
play(nextSong);
}
}
}
public void play(MusicSong song) {
if (song == null) {
return;
}
stop();
currentSong = song;
currentSong.music.play();
}
class NextSongListener implements OnCompletionListener {
@Override
public void onCompletion(Music music) {
next();
play(currentSong);
}
}
public void next() {
int currentBackground = backgroundSongs.indexOf(currentSong);
if (currentBackground == -1) {
return; // some other
}
if (currentBackground == backgroundSongs.size()-1) {
currentBackground = -1; // loop to start
}
boolean play = currentSong.music.isPlaying();
currentSong.music.stop();
currentSong = backgroundSongs.get(currentBackground+1);
if (play) {
currentSong.music.play();
}
}
public void prev() {
int currentBackground = backgroundSongs.indexOf(currentSong);
if (currentBackground == -1) {
return; // some other
}
if (currentBackground == 0) {
currentBackground = backgroundSongs.size(); // loop to end
}
boolean play = currentSong.music.isPlaying();
currentSong.music.stop();
currentSong = backgroundSongs.get(currentBackground-1);
if (play) {
currentSong.music.play();
}
}
}

View file

@ -0,0 +1,27 @@
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
import com.badlogic.gdx.audio.Music;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
/**
* The music with the (file) name.
*/
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class MusicSong {
protected final Music music;
private final String name;
public MusicSong(Music music, String name) {
this.music = music;
this.name = name;
}
public String getName() {
return name;
}
public boolean isPlaying() {
return music.isPlaying();
}
}

View file

@ -0,0 +1,13 @@
package love.distributedrebirth.gdxapp4d.app.tosamp.music;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
/**
* The song types.
*/
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public enum MusicSongType {
INTRO,
CREDITS,
BACKGROUND
}