feat(i18n): Add i18n configuration and resource management with localization support
feat(renderer): Integrate StaticResourceService for dynamic resource loading in renderer feat(font): Implement font resource management and update default font handling feat(resources): Add icon and font files for renderer and localization features
This commit is contained in:
BIN
data/renderer/Inter_24pt-Regular.ttf
Normal file
BIN
data/renderer/Inter_24pt-Regular.ttf
Normal file
Binary file not shown.
93
data/renderer/OFL.txt
Normal file
93
data/renderer/OFL.txt
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
https://openfontlicense.org
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
BIN
data/renderer/icon.png
Normal file
BIN
data/renderer/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -1,5 +1,10 @@
|
|||||||
package de.extio.game_engine.i18n;
|
package de.extio.game_engine.i18n;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -8,28 +13,33 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
import de.extio.game_engine.resource.StaticResource;
|
||||||
|
import de.extio.game_engine.resource.StaticResourceService;
|
||||||
|
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@ConditionalOnProperty(name = "game-engine.i18n.enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "game-engine.i18n.enabled", havingValue = "true", matchIfMissing = true)
|
||||||
public class LocalizationAutoConfiguration {
|
public class LocalizationAutoConfiguration {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(LocalizationServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(LocalizationServiceImpl.class);
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
LocalizationService localizationManager(@Value("${game-engine.i18n.load-on-start:true}") final boolean loadOnStart, @Value("${game-engine.i18n.resource:i18n.yaml}") final String resource) {
|
LocalizationService localizationManager(@Value("${game-engine.i18n.load-on-start:true}") final boolean loadOnStart, @Value("${game-engine.i18n.resource:i18n/i18n.yaml}") final String resource, final StaticResourceService staticResourceService) {
|
||||||
final var localizationManager = new LocalizationServiceImpl();
|
final var localizationManager = new LocalizationServiceImpl();
|
||||||
|
|
||||||
if (loadOnStart) {
|
if (loadOnStart) {
|
||||||
try (var resourceStream = LocalizationAutoConfiguration.class.getClassLoader().getResourceAsStream(resource)) {
|
final var path = new File(resource).toPath();
|
||||||
if (resourceStream != null) {
|
final var staticResource = new StaticResource(path.getParent() != null ? StreamSupport.stream(path.getParent().spliterator(), false).map(Path::toString).toList() : null, path.getFileName().toString());
|
||||||
localizationManager.load(resourceStream);
|
staticResourceService.loadStreamByPath(staticResource).ifPresent(stream -> {
|
||||||
|
try (stream) {
|
||||||
|
localizationManager.load(stream);
|
||||||
}
|
}
|
||||||
}
|
catch (final Exception e) {
|
||||||
catch (final Exception exc) {
|
LOGGER.error("An exception occured while loading localizations from resource: " + resource, e);
|
||||||
LOGGER.error("An exception occured while loading localizations from resource: " + resource, exc);
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return localizationManager;
|
return localizationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,12 +118,12 @@ public class LocalizationEditor extends JFrame {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
final LocalizationEditor frame = new LocalizationEditor();
|
final LocalizationEditor frame = new LocalizationEditor();
|
||||||
try (InputStream in = frame.getClass().getClassLoader().getResourceAsStream("icon.png")) {
|
// try (InputStream in = frame.getClass().getClassLoader().getResourceAsStream("icon.png")) {
|
||||||
final BufferedImage icon = ImageIO.read(in);
|
// final BufferedImage icon = ImageIO.read(in);
|
||||||
frame.setIconImage(icon);
|
// frame.setIconImage(icon);
|
||||||
}
|
// }
|
||||||
catch (final Exception e) {
|
// catch (final Exception e) {
|
||||||
}
|
// }
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
frame.localizationManagerImpl.reset();
|
frame.localizationManagerImpl.reset();
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package de.extio.game_engine.renderer;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@@ -21,6 +19,8 @@ import de.extio.game_engine.renderer.work.RendererWorkingSet;
|
|||||||
import de.extio.game_engine.renderer.work.RendererWorkingSetImpl;
|
import de.extio.game_engine.renderer.work.RendererWorkingSetImpl;
|
||||||
import de.extio.game_engine.renderer.work.RenderingBoPool;
|
import de.extio.game_engine.renderer.work.RenderingBoPool;
|
||||||
import de.extio.game_engine.renderer.work.RenderingBoPoolImpl;
|
import de.extio.game_engine.renderer.work.RenderingBoPoolImpl;
|
||||||
|
import de.extio.game_engine.resource.StaticResourceService;
|
||||||
|
import de.extio.game_engine.resource.StaticResourceService;
|
||||||
import de.extio.game_engine.storage.StorageService;
|
import de.extio.game_engine.storage.StorageService;
|
||||||
|
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@@ -59,9 +59,10 @@ public class RendererAutoConfiguration {
|
|||||||
final StorageService storageService,
|
final StorageService storageService,
|
||||||
final RendererWorkingSet rendererWorkingSet,
|
final RendererWorkingSet rendererWorkingSet,
|
||||||
final ModuleService moduleManager,
|
final ModuleService moduleManager,
|
||||||
final ModuleExecutor moduleExecutor) {
|
final ModuleExecutor moduleExecutor,
|
||||||
|
final StaticResourceService staticResourceService) {
|
||||||
|
|
||||||
final var rendererData = new RendererData(applicationContext, renderer, rendererControl, renderingBoPool, keycodeRegistry, eventService, storageService, rendererWorkingSet, moduleManager, moduleExecutor);
|
final var rendererData = new RendererData(applicationContext, renderer, rendererControl, renderingBoPool, keycodeRegistry, eventService, storageService, rendererWorkingSet, moduleManager, moduleExecutor, staticResourceService);
|
||||||
renderer.setRendererData(rendererData);
|
renderer.setRendererData(rendererData);
|
||||||
rendererControl.setRendererData(rendererData);
|
rendererControl.setRendererData(rendererData);
|
||||||
renderingBoPool.setRendererData(rendererData);
|
renderingBoPool.setRendererData(rendererData);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import de.extio.game_engine.renderer.model.options.UiOptions;
|
|||||||
import de.extio.game_engine.renderer.model.options.VideoOptions;
|
import de.extio.game_engine.renderer.model.options.VideoOptions;
|
||||||
import de.extio.game_engine.renderer.work.RendererWorkingSet;
|
import de.extio.game_engine.renderer.work.RendererWorkingSet;
|
||||||
import de.extio.game_engine.renderer.work.RenderingBoPool;
|
import de.extio.game_engine.renderer.work.RenderingBoPool;
|
||||||
|
import de.extio.game_engine.resource.StaticResourceService;
|
||||||
import de.extio.game_engine.storage.StorageService;
|
import de.extio.game_engine.storage.StorageService;
|
||||||
|
|
||||||
public class RendererData {
|
public class RendererData {
|
||||||
@@ -42,10 +43,12 @@ public class RendererData {
|
|||||||
private final ModuleService moduleManager;
|
private final ModuleService moduleManager;
|
||||||
|
|
||||||
private final ModuleExecutor moduleExecutor;
|
private final ModuleExecutor moduleExecutor;
|
||||||
|
|
||||||
|
private final StaticResourceService staticResourceService;
|
||||||
|
|
||||||
private RendererLoop rendererLoop;
|
private RendererLoop rendererLoop;
|
||||||
|
|
||||||
public RendererData(final ApplicationContext applicationContext, final Renderer renderer, final RendererControl rendererControl, final RenderingBoPool renderingBoPool, final KeycodeRegistry keycodeRegistry, final EventService eventService, final StorageService storageService, final RendererWorkingSet rendererWorkingSet, final ModuleService moduleManager, final ModuleExecutor moduleExecutor) {
|
public RendererData(final ApplicationContext applicationContext, final Renderer renderer, final RendererControl rendererControl, final RenderingBoPool renderingBoPool, final KeycodeRegistry keycodeRegistry, final EventService eventService, final StorageService storageService, final RendererWorkingSet rendererWorkingSet, final ModuleService moduleManager, final ModuleExecutor moduleExecutor, final StaticResourceService staticResourceService) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
this.rendererControl = rendererControl;
|
this.rendererControl = rendererControl;
|
||||||
@@ -56,6 +59,7 @@ public class RendererData {
|
|||||||
this.rendererWorkingSet = rendererWorkingSet;
|
this.rendererWorkingSet = rendererWorkingSet;
|
||||||
this.moduleManager = moduleManager;
|
this.moduleManager = moduleManager;
|
||||||
this.moduleExecutor = moduleExecutor;
|
this.moduleExecutor = moduleExecutor;
|
||||||
|
this.staticResourceService = staticResourceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationContext getApplicationContext() {
|
public ApplicationContext getApplicationContext() {
|
||||||
@@ -121,4 +125,8 @@ public class RendererData {
|
|||||||
public ModuleExecutor getModuleExecutor() {
|
public ModuleExecutor getModuleExecutor() {
|
||||||
return moduleExecutor;
|
return moduleExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StaticResourceService getStaticResourceService() {
|
||||||
|
return staticResourceService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import java.awt.event.MouseWheelListener;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -63,15 +64,15 @@ public class G2DMainFrame extends Frame {
|
|||||||
this.setLayout(null);
|
this.setLayout(null);
|
||||||
this.setBackground(Color.BLACK);
|
this.setBackground(Color.BLACK);
|
||||||
|
|
||||||
try (var in = this.getClass().getClassLoader().getResourceAsStream("icon.png")) {
|
this.rendererData.getStaticResourceService().loadStreamByPath(List.of("renderer"), "icon.png").ifPresent(stream -> {
|
||||||
if (in != null) {
|
try (var in = stream) {
|
||||||
final var icon = ImageIO.read(in);
|
final var icon = ImageIO.read(in);
|
||||||
this.setIconImage(icon);
|
this.setIconImage(icon);
|
||||||
}
|
}
|
||||||
}
|
catch (final IOException e) {
|
||||||
catch (final IOException e) {
|
LOGGER.warn(e.getMessage(), e);
|
||||||
LOGGER.error(e.getMessage(), e);
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
this.addWindowListener(new WindowListener() {
|
this.addWindowListener(new WindowListener() {
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package de.extio.game_engine.renderer.g2d;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -9,7 +10,9 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
@@ -22,8 +25,10 @@ import org.slf4j.LoggerFactory;
|
|||||||
import de.extio.game_engine.module.AbstractClientModule;
|
import de.extio.game_engine.module.AbstractClientModule;
|
||||||
import de.extio.game_engine.renderer.Renderer;
|
import de.extio.game_engine.renderer.Renderer;
|
||||||
import de.extio.game_engine.renderer.RendererData;
|
import de.extio.game_engine.renderer.RendererData;
|
||||||
|
import de.extio.game_engine.renderer.g2d.G2DRenderer.G2DRendererModule;
|
||||||
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DAbstractRenderingBo;
|
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DAbstractRenderingBo;
|
||||||
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DDrawBackground;
|
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DDrawBackground;
|
||||||
|
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DDrawFont;
|
||||||
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DDrawFpsHistory;
|
import de.extio.game_engine.renderer.g2d.bo.rendering.G2DDrawFpsHistory;
|
||||||
import de.extio.game_engine.renderer.g2d.control.G2DDrawControl;
|
import de.extio.game_engine.renderer.g2d.control.G2DDrawControl;
|
||||||
import de.extio.game_engine.renderer.g2d.control.G2DDrawControlTooltip;
|
import de.extio.game_engine.renderer.g2d.control.G2DDrawControlTooltip;
|
||||||
@@ -32,6 +37,7 @@ import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
|||||||
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBo;
|
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBo;
|
||||||
import de.extio.game_engine.renderer.model.color.RgbaColor;
|
import de.extio.game_engine.renderer.model.color.RgbaColor;
|
||||||
import de.extio.game_engine.renderer.model.event.TakeScreenshotEvent;
|
import de.extio.game_engine.renderer.model.event.TakeScreenshotEvent;
|
||||||
|
import de.extio.game_engine.resource.StaticResource;
|
||||||
import de.extio.game_engine.util.RingBuffer;
|
import de.extio.game_engine.util.RingBuffer;
|
||||||
|
|
||||||
public class G2DRenderer implements Renderer {
|
public class G2DRenderer implements Renderer {
|
||||||
@@ -65,6 +71,8 @@ public class G2DRenderer implements Renderer {
|
|||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
private volatile boolean takeScreenshot;
|
private volatile boolean takeScreenshot;
|
||||||
|
|
||||||
|
private StaticResource previousDefaultFont = null;
|
||||||
|
|
||||||
public G2DRenderer() {
|
public G2DRenderer() {
|
||||||
LOGGER.info("ctor");
|
LOGGER.info("ctor");
|
||||||
@@ -140,11 +148,15 @@ public class G2DRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final var viewPortDimension = this.rendererData.getRendererControl().getAbsoluteViewportDimension();
|
final var viewPortDimension = this.rendererData.getRendererControl().getAbsoluteViewportDimension();
|
||||||
|
|
||||||
if (viewPortDimension.getX() < 10 || viewPortDimension.getY() < 10) {
|
if (viewPortDimension.getX() < 10 || viewPortDimension.getY() < 10) {
|
||||||
// Some race condition happens rarely (mainly Windows 11) that window size is not initialized after entering full screen. Put a plaster on it...
|
// Some race condition happens rarely (mainly Windows 11) that window size is not initialized after entering full screen. Put a plaster on it...
|
||||||
throw new G2DRendererWindowNotInitializedException();
|
throw new G2DRendererWindowNotInitializedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.previousDefaultFont == null && this.rendererData.getUiOptions().getFontResource() != null && !this.rendererData.getUiOptions().getFontResource().equals(this.previousDefaultFont)) {
|
||||||
|
this.previousDefaultFont = this.rendererData.getUiOptions().getFontResource();
|
||||||
|
G2DDrawFont.updateDefaultFont(this.rendererData.getStaticResourceService(), this.rendererData.getUiOptions().getFontResource());
|
||||||
|
}
|
||||||
|
|
||||||
BufferedImage screenshotImg = null;
|
BufferedImage screenshotImg = null;
|
||||||
Graphics2D screenshotGraphics = null;
|
Graphics2D screenshotGraphics = null;
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ public class G2DRendererControl implements RendererControl {
|
|||||||
.store(List.of("gameEngine"), "g2dRendererControlOptions", this.options);
|
.store(List.of("gameEngine"), "g2dRendererControlOptions", this.options);
|
||||||
|
|
||||||
this.recalculate();
|
this.recalculate();
|
||||||
|
this.rendererData.getEventService().fire(new WindowResizeEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import de.extio.game_engine.renderer.g2d.G2DRendererCondition;
|
|||||||
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
||||||
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBo;
|
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBo;
|
||||||
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBoTextAlignment;
|
import de.extio.game_engine.renderer.model.bo.DrawFontRenderingBoTextAlignment;
|
||||||
|
import de.extio.game_engine.resource.StaticResource;
|
||||||
|
import de.extio.game_engine.resource.StaticResourceService;
|
||||||
import de.extio.game_engine.spatial2.model.CoordI2;
|
import de.extio.game_engine.spatial2.model.CoordI2;
|
||||||
import de.extio.game_engine.spatial2.model.ImmutableCoordI2;
|
import de.extio.game_engine.spatial2.model.ImmutableCoordI2;
|
||||||
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
||||||
@@ -27,20 +29,25 @@ public class G2DDrawFont extends G2DAbstractRenderingBo implements DrawFontRende
|
|||||||
|
|
||||||
private final static int FONT_SIZE_DEFAULT = 14;
|
private final static int FONT_SIZE_DEFAULT = 14;
|
||||||
|
|
||||||
private final static Font baseFont;
|
private static Font baseFont;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Font f;
|
final Map<TextAttribute, Object> attributes = new HashMap<>();
|
||||||
try {
|
attributes.put(TextAttribute.FAMILY, Font.SANS_SERIF);
|
||||||
f = Font.createFont(Font.TRUETYPE_FONT, ClassLoader.getSystemClassLoader().getResourceAsStream("Roboto-Regular.ttf"));
|
attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_SEMIBOLD);
|
||||||
}
|
baseFont = Font.getFont(attributes);
|
||||||
catch (final Exception e) {
|
}
|
||||||
final Map<TextAttribute, Object> attributes = new HashMap<>();
|
|
||||||
attributes.put(TextAttribute.FAMILY, Font.SANS_SERIF);
|
public static void updateDefaultFont(final StaticResourceService staticResourceService, final StaticResource resource) {
|
||||||
attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_SEMIBOLD);
|
staticResourceService.loadStreamByPath(resource).ifPresent(stream -> {
|
||||||
f = Font.getFont(attributes);
|
try (var in = stream) {
|
||||||
}
|
final var font = Font.createFont(Font.TRUETYPE_FONT, in);
|
||||||
baseFont = f;
|
G2DDrawFont.baseFont = font;
|
||||||
|
}
|
||||||
|
catch (final Exception e) {
|
||||||
|
LOGGER.warn(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
package de.extio.game_engine.renderer.model.options;
|
package de.extio.game_engine.renderer.model.options;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.extio.game_engine.resource.StaticResource;
|
||||||
import de.extio.game_engine.spatial2.model.CoordI2;
|
import de.extio.game_engine.spatial2.model.CoordI2;
|
||||||
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
||||||
|
|
||||||
public final class UiOptions {
|
public final class UiOptions {
|
||||||
|
|
||||||
|
private boolean drawFps = true;
|
||||||
|
|
||||||
private String backgroundResourceName0 = null;
|
private String backgroundResourceName0 = null;
|
||||||
|
|
||||||
private boolean backgroundScrolling0;
|
private boolean backgroundScrolling0;
|
||||||
@@ -15,12 +20,12 @@ public final class UiOptions {
|
|||||||
|
|
||||||
private boolean backgroundScrollingReverse1;
|
private boolean backgroundScrollingReverse1;
|
||||||
|
|
||||||
private boolean drawFps = true;
|
|
||||||
|
|
||||||
private CoordI2 backgroundOffset0 = MutableCoordI2.create();
|
private CoordI2 backgroundOffset0 = MutableCoordI2.create();
|
||||||
|
|
||||||
private CoordI2 backgroundOffset1 = MutableCoordI2.create();
|
private CoordI2 backgroundOffset1 = MutableCoordI2.create();
|
||||||
|
|
||||||
|
private StaticResource fontResource = new StaticResource(List.of("renderer"), "Inter_24pt-Regular.ttf");
|
||||||
|
|
||||||
public UiOptions() {
|
public UiOptions() {
|
||||||
if ("true".equals(System.getProperty("debug"))) {
|
if ("true".equals(System.getProperty("debug"))) {
|
||||||
this.drawFps = true;
|
this.drawFps = true;
|
||||||
@@ -91,4 +96,11 @@ public final class UiOptions {
|
|||||||
this.backgroundOffset1 = backgroundOffset1;
|
this.backgroundOffset1 = backgroundOffset1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StaticResource getFontResource() {
|
||||||
|
return fontResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFontResource(final StaticResource fontResource) {
|
||||||
|
this.fontResource = fontResource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ de.extio.game_engine.keyboard.KeycodeAutoConfiguration
|
|||||||
de.extio.game_engine.renderer.RendererAutoConfiguration
|
de.extio.game_engine.renderer.RendererAutoConfiguration
|
||||||
de.extio.game_engine.renderer.g2d.G2DAutoConfiguration
|
de.extio.game_engine.renderer.g2d.G2DAutoConfiguration
|
||||||
de.extio.game_engine.storage.StorageServiceAutoConfiguration
|
de.extio.game_engine.storage.StorageServiceAutoConfiguration
|
||||||
de.extio.game_engine.module.ModuleManagerAutoConfiguration
|
de.extio.game_engine.module.ModuleServiceAutoConfiguration
|
||||||
de.extio.game_engine.i18n.LocalizationAutoConfiguration
|
de.extio.game_engine.i18n.LocalizationAutoConfiguration
|
||||||
de.extio.game_engine.resource.StaticResourceAutoConfiguration
|
de.extio.game_engine.resource.StaticResourceAutoConfiguration
|
||||||
|
|||||||
Reference in New Issue
Block a user