From a0b0bcf503312fbd7686281362cc159785d0e313 Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Tue, 8 Mar 2022 01:12:03 +0100 Subject: [PATCH] Started with locale service. --- .../vrgem4/VrGem4LocaleServiceImpl.java | 75 +++++++++++++++++++ .../vrgem4/service/VrGem4LocaleService.java | 15 ++++ .../vrgem4/view/DeskTopScreenMenu.java | 2 - .../view/apps/SystemBaseUnicodePlaneApp.java | 52 ------------- .../vrsys5/BasicConsoleComponent.java | 39 ---------- .../gdxapp4d/vrsys5/VrSys5Component.java | 49 ++++++++++++ .../vrsys5/apps/BaseUnicodePlaneDeskApp.java | 59 +++++++++++++++ .../{ => apps}/BasicConsoleDeskApp.java | 2 +- .../gdxapp4d/vrsys5/Main.properties | 18 +++++ .../gdxapp4d/vrsys5/Main_hiero.properties | 14 ++++ 10 files changed, 231 insertions(+), 94 deletions(-) create mode 100644 gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4LocaleServiceImpl.java create mode 100644 gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java delete mode 100644 gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/apps/SystemBaseUnicodePlaneApp.java delete mode 100644 gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/BasicConsoleComponent.java create mode 100644 gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/VrSys5Component.java create mode 100644 gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/apps/BaseUnicodePlaneDeskApp.java rename gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/{ => apps}/BasicConsoleDeskApp.java (95%) create mode 100644 gdxapp4d-vrsys5/src/main/resources/love/distributedrebirth/gdxapp4d/vrsys5/Main.properties create mode 100644 gdxapp4d-vrsys5/src/main/resources/love/distributedrebirth/gdxapp4d/vrsys5/Main_hiero.properties diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4LocaleServiceImpl.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4LocaleServiceImpl.java new file mode 100644 index 00000000..efd503fd --- /dev/null +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/VrGem4LocaleServiceImpl.java @@ -0,0 +1,75 @@ +package love.distributedrebirth.gdxapp4d.vrgem4; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Locale; +import java.util.Properties; + +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.SystemGdxLog; +import love.distributedrebirth.gdxapp4d.tos4.service.SystemWarpBase; +import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4LocaleService; + +@Component +public class VrGem4LocaleServiceImpl implements VrGem4LocaleService { + + @Reference + private SystemGdxLog log; + + @Reference + private SystemWarpBase warpBase; + + private Properties properties; + + enum LocaleKey { + TEXT_LOCALE, + NUMBER10_LOCALE, + NUMBER16_LOCALE, + NUMBER27_LOCALE, + } + + public VrGem4LocaleServiceImpl() { + properties = new Properties(); + } + + @Activate + void open() { + log.debug(this, SystemGdxLog.ACTIVATE); + + File propFile = new File(warpBase.getWarpshipHome(), "etc/locale.properties"); + if (propFile.exists()) { + try { + properties.loadFromXML(new FileInputStream(propFile)); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Deactivate + void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + } + + @Override + public void setTextLocaleI18n(String isoCode) { + // TODO Auto-generated method stub + + } + + @Override + public String getTextLocaleI18n() { + return properties.getProperty(LocaleKey.TEXT_LOCALE.name(), "en"); + } + + @Override + public Locale getTextLocale() { + return new Locale(getTextLocaleI18n()); + } +} diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java new file mode 100644 index 00000000..89d6149e --- /dev/null +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/service/VrGem4LocaleService.java @@ -0,0 +1,15 @@ +package love.distributedrebirth.gdxapp4d.vrgem4.service; + +import java.util.Locale; + +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppLauncher; +import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection; + +public interface VrGem4LocaleService { + + void setTextLocaleI18n(String isoCode); + + String getTextLocaleI18n(); + + Locale getTextLocale(); +} diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/DeskTopScreenMenu.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/DeskTopScreenMenu.java index f49ba8ab..6431231e 100644 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/DeskTopScreenMenu.java +++ b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/DeskTopScreenMenu.java @@ -25,7 +25,6 @@ import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSectio import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppRenderer; import love.distributedrebirth.gdxapp4d.vrgem4.view.apps.SystemBaseGlyphApp; import love.distributedrebirth.gdxapp4d.vrgem4.view.apps.SystemBasePartApp; -import love.distributedrebirth.gdxapp4d.vrgem4.view.apps.SystemBaseUnicodePlaneApp; import love.distributedrebirth.gdxapp4d.vrgem4.view.apps.Unicode4DApp; @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @@ -46,7 +45,6 @@ public class DeskTopScreenMenu { apps = new ArrayList<>(); apps.add(new DeskAppLauncher("Sys Glyph Set", () -> new SystemBaseGlyphApp())); apps.add(new DeskAppLauncher("Sys Number Parts", () -> new SystemBasePartApp())); - apps.add(new DeskAppLauncher("Sys Unicode", () -> new SystemBaseUnicodePlaneApp())); apps.add(new DeskAppLauncher("Unicode4D", () -> new Unicode4DApp())); } diff --git a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/apps/SystemBaseUnicodePlaneApp.java b/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/apps/SystemBaseUnicodePlaneApp.java deleted file mode 100644 index 84ea5c8a..00000000 --- a/gdxapp4d-vrgem4/src/main/java/love/distributedrebirth/gdxapp4d/vrgem4/view/apps/SystemBaseUnicodePlaneApp.java +++ /dev/null @@ -1,52 +0,0 @@ -package love.distributedrebirth.gdxapp4d.vrgem4.view.apps; - -import java.util.Locale; -import java.util.ResourceBundle; - -import imgui.ImGui; -import imgui.flag.ImGuiTableFlags; -import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; -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 love.distributedrebirth.unicode4d.UnicodePlaneᶻᴰ; - -@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") -public class SystemBaseUnicodePlaneApp extends AbstractDeskApp { - - private String getTxt(String key) { - ResourceBundle bundle = ResourceBundle.getBundle("love.distributedrebirth.gdxapp.Main", new Locale("en")); - return bundle.getString("SystemBaseUnicodePlaneApp."+key); - } - - public void create() { - getContours().setTitle(getTxt("title")); - getContours().registrateContour(DeskAppContourSection.MAIN, new DeskAppRenderer() { - - @Override - public void render() { - int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV | ImGuiTableFlags.Resizable; - ImGui.beginTable("base-part", 2, flags); - ImGui.tableSetupColumn(getTxt("colPlane")); - ImGui.tableSetupColumn(getTxt("colText")); - ImGui.tableHeadersRow(); - for (UnicodePlaneᶻᴰ plane:UnicodePlaneᶻᴰ.values()) { - ImGui.tableNextRow(); - ImGui.tableNextColumn(); - ImGui.text(plane.name()); - ImGui.tableNextColumn(); - StringBuilder buf = new StringBuilder(); - for (int i=plane.getStart();i new BasicConsoleDeskApp()); - } - - @Activate - void open() { - log.debug(this, SystemGdxLog.ACTIVATE); - deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher); - } - - @Deactivate - void close() { - log.debug(this, SystemGdxLog.DEACTIVATE); - deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, launcher); - } -} diff --git a/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/VrSys5Component.java b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/VrSys5Component.java new file mode 100644 index 00000000..260aed06 --- /dev/null +++ b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/VrSys5Component.java @@ -0,0 +1,49 @@ +package love.distributedrebirth.gdxapp4d.vrsys5; + +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.SystemGdxLog; +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; +import love.distributedrebirth.gdxapp4d.vrsys5.apps.BaseUnicodePlaneDeskApp; +import love.distributedrebirth.gdxapp4d.vrsys5.apps.BasicConsoleDeskApp; + +@Component +public class VrSys5Component { + + @Reference + private SystemGdxLog log; + + @Reference + private VrGem4DeskAppService deskAppService; + + @Reference + private VrGem4LocaleService localeService; + + private final DeskAppLauncher basicLauncher; + private final DeskAppLauncher unicodeLauncher; + + public VrSys5Component() { + basicLauncher = new DeskAppLauncher("Basic Console", () -> new BasicConsoleDeskApp()); + unicodeLauncher = new DeskAppLauncher("Base Unicode Plane", () -> new BaseUnicodePlaneDeskApp(localeService)); + } + + @Activate + void open() { + log.debug(this, SystemGdxLog.ACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, basicLauncher); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, unicodeLauncher); + } + + @Deactivate + void close() { + log.debug(this, SystemGdxLog.DEACTIVATE); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, basicLauncher); + deskAppService.installDeskApp(DeskAppMenuSection.SYSTEM, unicodeLauncher); + } +} diff --git a/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/apps/BaseUnicodePlaneDeskApp.java b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/apps/BaseUnicodePlaneDeskApp.java new file mode 100644 index 00000000..9357cb16 --- /dev/null +++ b/gdxapp4d-vrsys5/src/main/java/love/distributedrebirth/gdxapp4d/vrsys5/apps/BaseUnicodePlaneDeskApp.java @@ -0,0 +1,59 @@ +package love.distributedrebirth.gdxapp4d.vrsys5.apps; + +import java.util.Locale; +import java.util.ResourceBundle; + +import imgui.ImGui; +import imgui.flag.ImGuiTableFlags; +import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; +import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4LocaleService; +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 love.distributedrebirth.unicode4d.UnicodePlaneᶻᴰ; + +@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") +public class BaseUnicodePlaneDeskApp extends AbstractDeskApp implements DeskAppRenderer { + + private final VrGem4LocaleService localeService; + + public BaseUnicodePlaneDeskApp(VrGem4LocaleService localeService) { + this.localeService = localeService; + } + + private String getTxt(String key) { + Locale loc = localeService.getTextLocale(); + ResourceBundle bundle = ResourceBundle.getBundle("love.distributedrebirth.gdxapp4d.vrsys5.Main", loc); + return bundle.getString("SystemBaseUnicodePlaneApp."+key); + } + + public void create() { + getContours().setTitle(getTxt("title")); + getContours().registrateContour(DeskAppContourSection.MAIN, this); + } + + @Override + public void render() { + int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV | ImGuiTableFlags.Resizable; + ImGui.beginTable("base-part", 2, flags); + ImGui.tableSetupColumn(getTxt("colPlane")); + ImGui.tableSetupColumn(getTxt("colText")); + ImGui.tableHeadersRow(); + for (UnicodePlaneᶻᴰ plane:UnicodePlaneᶻᴰ.values()) { + ImGui.tableNextRow(); + ImGui.tableNextColumn(); + ImGui.text(plane.name()); + ImGui.tableNextColumn(); + StringBuilder buf = new StringBuilder(); + for (int i=plane.getStart();i