From c62cb0b6e20635873a1e790d6eac7d9d239d2fb7 Mon Sep 17 00:00:00 2001 From: Sebastiaan de Schaetzen Date: Tue, 16 Dec 2025 11:18:34 +0100 Subject: [PATCH] Add menubar rendering to DiceOS --- src/main/java/be/seeseemelk/diceos/DiceOS.java | 15 +++++++++++++++ src/main/resources/menubar.png | Bin 0 -> 303 bytes 2 files changed, 15 insertions(+) create mode 100644 src/main/resources/menubar.png diff --git a/src/main/java/be/seeseemelk/diceos/DiceOS.java b/src/main/java/be/seeseemelk/diceos/DiceOS.java index ce062f5..38ae60b 100644 --- a/src/main/java/be/seeseemelk/diceos/DiceOS.java +++ b/src/main/java/be/seeseemelk/diceos/DiceOS.java @@ -5,6 +5,7 @@ import be.seeseemelk.diceos.system.OnStartup; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.utils.ScreenUtils; import com.badlogic.gdx.utils.viewport.ScreenViewport; @@ -24,6 +25,7 @@ public class DiceOS extends ApplicationAdapter { private Texture background; private Texture clouds; private Texture border; + private NinePatch menubar; private Viewport vmViewport; private Viewport screenViewport; private int scaling = 1; @@ -36,6 +38,7 @@ public class DiceOS extends ApplicationAdapter { background = new Texture("src/main/resources/background.png"); clouds = new Texture("src/main/resources/clouds.png"); border = new Texture("src/main/resources/border.png"); + loadMenubar(); screenViewport = new ScreenViewport(); vmViewport = new ScreenViewport(); @@ -49,6 +52,11 @@ public class DiceOS extends ApplicationAdapter { log.info("DiceOS started!"); } + private void loadMenubar() { + var texture = new Texture("src/main/resources/menubar.png"); + menubar = new NinePatch(texture, 9, 9, 15, 1); + } + @Override public void resize(int width, int height) { screenViewport.update(width, height, true); @@ -70,6 +78,7 @@ public class DiceOS extends ApplicationAdapter { ScreenUtils.clear(Color.GREEN); + // Render background for (int y = 0; y < display.getHeight(); y += 8) { for (int x = 0; x < display.getWidth(); x += 8) { display.draw(background, x, y); @@ -77,6 +86,10 @@ public class DiceOS extends ApplicationAdapter { } display.draw(clouds, 0, 0); + // Render menubar + menubar.draw(display.getBatch(), 0, display.getHeight() - 16, display.getWidth(), 16); + + // Render borders var param = new DisplayService.Parameters(); display.draw(border, 0, 0, param); param.flipX = true; @@ -86,9 +99,11 @@ public class DiceOS extends ApplicationAdapter { param.flipX = false; display.draw(border, 0, display.getHeight() - 8, param); + // Finish rendering to screen buffer display.getBatch().end(); display.getScreenBuffer().end(); + // Render screen buffer to actual screen screenViewport.apply(); display.getBatch().setProjectionMatrix(screenViewport.getCamera().combined); display.getBatch().begin(); diff --git a/src/main/resources/menubar.png b/src/main/resources/menubar.png new file mode 100644 index 0000000000000000000000000000000000000000..a46b6b09d159a95cf0b79fa9f3c9b2a4b07e0ac5 GIT binary patch literal 303 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Et!3HGD8EPYe6k~CayA$KhlREW44okYDuOkD) z#(wTUiL5}rLb6AYF9SoB8UsT^3j@P1pisjL28L1t28LG&3=CE?7#PG0=Ijcz0ZMQd zctjR6Fz6|RFk{71`!b*)dx@v7EBi|x0WJZigSu<(1BF^WT^vI^jwh!iB>Xtvz<%fU zrDG190iRYL(mvmDmhr{3x}P7W>72g5x3=|A`HA?R`-~^VCTD9J_Bobu++j30y)xHO zul<0`L6_bIYOEZb-3vd=Tru&&2}X9cV~g4tY-{>;MP^8_Nf_L_ed*i$dx{NnBxbT5 rDteM3@j*kP^uP+{hz(bxzOXR7T5eUgc&(lV&_N8Iu6{1-oD!M