i18n for tosamp

This commit is contained in:
Willem Cazander 2022-03-26 22:44:17 +01:00
parent 168bb55af4
commit fabf63607b
4 changed files with 46 additions and 12 deletions

View file

@ -1,5 +1,7 @@
package love.distributedrebirth.gdxapp4d.app.tosamp;
import java.util.ResourceBundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@ -10,6 +12,7 @@ import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxBootArgs;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemGdxLog;
import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpShip;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4DeskAppService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4LocaleService;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection;
@ -28,15 +31,23 @@ public class TosAmpComponent {
@Reference
private SystemWarpShip warpShip;
@Reference
private VrGem4LocaleService localeService;
private final static String I18N_BUNDLE = "love.distributedrebirth.gdxapp4d.app.tosamp.Messages";
private DeskAppLauncher launcher;
public TosAmpComponent() {
}
private ResourceBundle createBundle() {
return ResourceBundle.getBundle(I18N_BUNDLE, localeService.getTextLocale());
}
@Activate
void open(final BundleContext context) {
log.debug(this, SystemGdxLog.ACTIVATE);
launcher = new DeskAppLauncher(DeskAppMenuSection.MULTIMEDIA, "TosAmp", () -> new TosAmpDeskApp(bootArgs.getFileChooser(), context, warpShip));
launcher = new DeskAppLauncher(DeskAppMenuSection.MULTIMEDIA, "TosAmp", () -> new TosAmpDeskApp(createBundle(), bootArgs.getFileChooser(), context, warpShip));
deskAppService.installDeskApp(launcher);
}

View file

@ -1,5 +1,6 @@
package love.distributedrebirth.gdxapp4d.app.tosamp;
import java.util.ResourceBundle;
import java.util.function.Consumer;
import org.osgi.framework.BundleContext;
@ -26,23 +27,29 @@ import net.spookygames.gdx.nativefilechooser.NativeFileChooserConfiguration;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
private final ResourceBundle bundle;
private final MusicManager music;
private final NativeFileChooser fileChooser;
private NativeFileChooserConfiguration fileChooserConfig;
public TosAmpDeskApp(NativeFileChooser fileChooser, BundleContext context, SystemWarpShip warpShip) {
public TosAmpDeskApp(ResourceBundle bundle, NativeFileChooser fileChooser, BundleContext context, SystemWarpShip warpShip) {
this.bundle = bundle;
this.fileChooser = fileChooser;
this.music = new MusicManager();
this.music.init(context, warpShip);
}
private String getTxt(String key) {
return bundle.getString(TosAmpDeskApp.class.getSimpleName()+"."+key);
}
public void create() {
getContours().setTitle("\uf001 TosAmp");
getContours().setTitle(getTxt("title"));
getContours().registrateContour(DeskAppContourSection.MAIN, this);
getContours().registrateContour(DeskAppContourSection.FILE_NEW, new DeskAppRenderer() {
@Override
public void render() {
if (ImGui.menuItem(FontAwesomeIcons.Plus + " Add")) {
if (ImGui.menuItem(getTxt("menuAdd"))) {
fileChooser.chooseFile(fileChooserConfig,
NativeFileChooserCallbackAdapter.onFileChosen(v -> music.addBackgroundMusic(v)));
}
@ -56,7 +63,7 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
@Override
public void render() {
ImGui.text("Current Song:");
ImGui.text(getTxt("currentSong"));
MusicSong currentSong = music.getCurrentSong();
if (currentSong != null) {
ImGui.sameLine();
@ -64,11 +71,11 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
}
ImGui.separator();
if (currentSong != null) {
if (ImGui.button("Play")) {
if (ImGui.button(getTxt("play"))) {
music.play(currentSong);
}
} else {
ImGui.text("Play");
ImGui.text(getTxt("actionPlay"));
}
ImGui.sameLine();
if (ImGui.button("<")) {
@ -79,15 +86,15 @@ public class TosAmpDeskApp extends AbstractDeskApp implements DeskAppRenderer {
music.next();
}
ImGui.sameLine();
if (ImGui.button("Stop")) {
if (ImGui.button(getTxt("actionStop"))) {
music.stop();
}
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
ImGui.beginTable("playlist", 4, flags);
ImGui.tableSetupColumn("#", ImGuiTableColumnFlags.NoHide);
ImGui.tableSetupColumn("Play");
ImGui.tableSetupColumn("List");
ImGui.tableSetupColumn("Name");
ImGui.tableSetupColumn(getTxt("listPlay"));
ImGui.tableSetupColumn(getTxt("listName"));
ImGui.tableSetupColumn(getTxt("listSong"));
ImGui.tableHeadersRow();
int i=1;
for (MusicSong song:music.getMusicSongs()) {

View file

@ -0,0 +1,8 @@
TosAmpDeskApp.title=\uf001 TosAmp
TosAmpDeskApp.menuAdd=\uf067 Add
TosAmpDeskApp.currentSong=Current Song:
TosAmpDeskApp.actionPlay=Play
TosAmpDeskApp.actionStop=Stop
TosAmpDeskApp.listPlay=Do
TosAmpDeskApp.listName=Playlist
TosAmpDeskApp.listSong=Song

View file

@ -0,0 +1,8 @@
TosAmpDeskApp.title=\uf001 TosAmp
TosAmpDeskApp.menuAdd=\uf067 Add
TosAmpDeskApp.currentSong=Current Song:
TosAmpDeskApp.actionPlay=Play
TosAmpDeskApp.actionStop=Stop
TosAmpDeskApp.listPlay=Do
TosAmpDeskApp.listName=Playlist
TosAmpDeskApp.listSong=Song