feat(renderer): add background scaling option to UiOptions and update G2DDrawBackground rendering logic
This commit is contained in:
@@ -5,24 +5,18 @@ import java.awt.Graphics2D;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.VolatileImage;
|
import java.awt.image.VolatileImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import de.extio.game_engine.renderer.RendererControl;
|
|
||||||
import de.extio.game_engine.renderer.g2d.G2DRendererControl;
|
import de.extio.game_engine.renderer.g2d.G2DRendererControl;
|
||||||
import de.extio.game_engine.renderer.g2d.theme.G2DThemeManager;
|
import de.extio.game_engine.renderer.g2d.theme.G2DThemeManager;
|
||||||
import de.extio.game_engine.renderer.model.RenderingBo;
|
import de.extio.game_engine.renderer.model.RenderingBo;
|
||||||
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
import de.extio.game_engine.renderer.model.RenderingBoLayer;
|
||||||
import de.extio.game_engine.renderer.model.color.ImmutableRgbaColor;
|
import de.extio.game_engine.renderer.model.options.UiOptions;
|
||||||
import de.extio.game_engine.renderer.model.color.RgbaColor;
|
|
||||||
import de.extio.game_engine.resource.StaticResource;
|
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.ImmutableCoordI2;
|
|
||||||
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
import de.extio.game_engine.spatial2.model.MutableCoordI2;
|
||||||
import de.extio.game_engine.util.rng.ThreadLocalXorShift128Random;
|
|
||||||
|
|
||||||
public class G2DDrawBackground extends G2DAbstractRenderingBo {
|
public class G2DDrawBackground extends G2DAbstractRenderingBo {
|
||||||
|
|
||||||
@@ -100,6 +94,17 @@ public class G2DDrawBackground extends G2DAbstractRenderingBo {
|
|||||||
this.createVolatileBackgroundImage(graphics, index);
|
this.createVolatileBackgroundImage(graphics, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final var uiOptions = this.rendererData.getUiOptions();
|
||||||
|
if (uiOptions.getBackgroundMode0() == UiOptions.BackgroundMode.SCALING) {
|
||||||
|
graphics.drawImage(G2DDrawBackground.BACKGROUND_IMAGE,
|
||||||
|
0, 0,
|
||||||
|
viewPort.getX(), viewPort.getY(),
|
||||||
|
0, 0,
|
||||||
|
G2DDrawBackground.BACKGROUND_IMAGE.getWidth(), G2DDrawBackground.BACKGROUND_IMAGE.getHeight(),
|
||||||
|
null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.sourceOffset.setXY(Math.floorMod(offset.getX(), G2DDrawBackground.BACKGROUND_IMAGE.getWidth()), Math.floorMod(offset.getY(), G2DDrawBackground.BACKGROUND_IMAGE.getHeight()));
|
this.sourceOffset.setXY(Math.floorMod(offset.getX(), G2DDrawBackground.BACKGROUND_IMAGE.getWidth()), Math.floorMod(offset.getY(), G2DDrawBackground.BACKGROUND_IMAGE.getHeight()));
|
||||||
this.destPosition.setXY(0, 0);
|
this.destPosition.setXY(0, 0);
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -96,6 +96,21 @@ public final class UiOptions {
|
|||||||
this.backgroundOffset1 = backgroundOffset1;
|
this.backgroundOffset1 = backgroundOffset1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum BackgroundMode {
|
||||||
|
TILING,
|
||||||
|
SCALING
|
||||||
|
}
|
||||||
|
|
||||||
|
private BackgroundMode backgroundMode0 = BackgroundMode.TILING;
|
||||||
|
|
||||||
|
public BackgroundMode getBackgroundMode0() {
|
||||||
|
return this.backgroundMode0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackgroundMode0(final BackgroundMode backgroundMode0) {
|
||||||
|
this.backgroundMode0 = backgroundMode0;
|
||||||
|
}
|
||||||
|
|
||||||
public StaticResource getFontResource() {
|
public StaticResource getFontResource() {
|
||||||
return fontResource;
|
return fontResource;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user