Started with locale service.
This commit is contained in:
parent
2f4353cf3d
commit
a0b0bcf503
10 changed files with 231 additions and 94 deletions
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue