Started with locale service.

This commit is contained in:
Willem Cazander 2022-03-08 01:12:03 +01:00
parent 2f4353cf3d
commit a0b0bcf503
10 changed files with 231 additions and 94 deletions

View file

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

View file

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

View file

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

View file

@ -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<plane.getStart()+33;i++) {
if (i < 65536) {
buf.append((char)i);
}
buf.append(" ");
}
ImGui.text(buf.toString());
}
ImGui.endTable();
}
});
}
}

View file

@ -1,39 +0,0 @@
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.deskapp.DeskAppLauncher;
import love.distributedrebirth.gdxapp4d.vrgem4.service.deskapp.DeskAppMenuSection;
@Component
public class BasicConsoleComponent {
@Reference
private SystemGdxLog log;
@Reference
private VrGem4DeskAppService deskAppService;
private final DeskAppLauncher launcher;
public BasicConsoleComponent() {
launcher = new DeskAppLauncher("Basic Console", () -> 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);
}
}

View file

@ -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);
}
}

View file

@ -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<plane.getStart()+33;i++) {
if (i < 65536) {
buf.append((char)i);
}
buf.append(" ");
}
ImGui.text(buf.toString());
}
ImGui.endTable();
}
}

View file

@ -1,4 +1,4 @@
package love.distributedrebirth.gdxapp4d.vrsys5;
package love.distributedrebirth.gdxapp4d.vrsys5.apps;
import imgui.ImGui;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;

View file

@ -0,0 +1,18 @@
SystemBaseGlyphApp.title=Sys Glyph Set
SystemBaseGlyphApp.showBase27=Show base27
SystemBaseGlyphApp.colScript=Script
SystemBaseGlyphApp.col10Num=10Numbers
SystemBaseGlyphApp.col16Num=16Numbers
SystemBaseGlyphApp.col27Num=27Numbers
SystemBasePartApp.title=Sys Number Parts
SystemBasePartApp.selectBase=Base
SystemBasePartApp.selectName=Name:
SystemBasePartApp.selectPurpose=Purpose:
SystemBasePartApp.showBase10=Show base10
SystemBasePartApp.showBase16=Show base16
SystemBasePartApp.showBase27=Show base27
SystemBaseUnicodePlaneApp.title=Sys Unicode Plane
SystemBaseUnicodePlaneApp.colPlane=Unicode Plane
SystemBaseUnicodePlaneApp.colText=Example

View file

@ -0,0 +1,14 @@
SystemBaseGlyphApp.title=\uE0C0 \uE13F \uE2F4 \uE3BC \uE0ED \uE1CC \uE191 \uE2F4 \uE20F
SystemBaseGlyphApp.showBase27=\uE219 \uE362 \uE0C0 \uE13F \uE2F4 \uE387 \uE400
SystemBaseGlyphApp.colScript=\uE2F4 \uE3A1 \uE08B \uE1CB \uE2AA \uE20F
SystemBaseGlyphApp.col10Num=\uE386 \uE216 \uE171 \uE153 \uE0C0 \uE08C \uE2F4
SystemBaseGlyphApp.col16Num=\uE386 \uE3FF \uE216 \uE171 \uE153 \uE0C0 \uE08C \uE2F4
SystemBaseGlyphApp.col27Num=\uE387 \uE400 \uE216 \uE171 \uE153 \uE0C0 \uE08C \uE2F4
SystemBasePartApp.title=\uE0C0 \uE13F \uE2F4 \uE203 \uE13F \uE08C \uE20F \uE2F4
SystemBasePartApp.selectBase=\uE0C0 \uE13F \uE2F4
SystemBasePartApp.selectName=\uE216 \uE13F \uE153 \uE3EC
SystemBasePartApp.selectPurpose=\uE203 \uE171 \uE08C \uE203 \uE2F4 \uE3EC
SystemBasePartApp.showBase10=\uE219 \uE362 \uE0C0 \uE13F \uE2F4 \uE386
SystemBasePartApp.showBase16=\uE219 \uE362 \uE0C0 \uE13F \uE2F4 \uE386 \uE3FF
SystemBasePartApp.showBase27=\uE219 \uE362 \uE0C0 \uE13F \uE2F4 \uE387 \uE400