From 962f2bf0cef0dde23e1f2b09d3a1b46fe3a79482 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Sun, 5 Mar 2023 05:17:08 +0100 Subject: [PATCH 1/4] Start menu --- .../com/ultreon/devices/core/TaskBar.java | 84 ++++++++++++++++-- .../devices/textures/gui/application_bar.png | Bin 5448 -> 4288 bytes 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/ultreon/devices/core/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/TaskBar.java index 532f76361..2838417c2 100644 --- a/common/src/main/java/com/ultreon/devices/core/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/TaskBar.java @@ -5,6 +5,10 @@ import com.ultreon.devices.Devices; import com.ultreon.devices.api.TrayItemAdder; import com.ultreon.devices.api.app.Application; +import com.ultreon.devices.api.app.Layout; +import com.ultreon.devices.api.app.System; +import com.ultreon.devices.api.app.component.ItemList; +import com.ultreon.devices.api.app.renderer.ListItemRenderer; import com.ultreon.devices.api.event.LaptopEvent; import com.ultreon.devices.api.utils.RenderUtil; import com.ultreon.devices.core.network.TrayItemWifi; @@ -34,6 +38,7 @@ public class TaskBar { public static final ResourceLocation APP_BAR_GUI = new ResourceLocation("devices:textures/gui/application_bar.png"); public static final int BAR_HEIGHT = 18; private static final int APPS_DISPLAYED = Devices.DEVELOPER_MODE ? 18 : 10; + private static final int TASKS_START = 18; private final CompoundTag tag; @@ -117,27 +122,34 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in bgColor = new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); RenderSystem.setShaderColor(bgColor.getRed() / 255f, bgColor.getGreen() / 255f, bgColor.getBlue() / 255f, 1f); + // Draw system tray. int trayItemsWidth = trayItems.size() * 14; GuiComponent.blit(pose, x, y, 1, 18, 0, 0, 1, 18, 256, 256); GuiComponent.blit(pose, x + 1, y, Laptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); GuiComponent.blit(pose, x + Laptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); - RenderSystem.disableBlend(); + // Draw start menu button + GuiComponent.blit(pose, x, y, 18, 18, 0, 0, 1, 18, 256, 256); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); + laptop.blit(pose, x + 1, y + 1, 52, 0, 16, 16); for (int i = 0; i < APPS_DISPLAYED && i < laptop.installedApps.size(); i++) { AppInfo info = laptop.installedApps.get(i + offset); - RenderUtil.drawApplicationIcon(pose, info, x + 2 + i * 16, y + 2); + RenderUtil.drawApplicationIcon(pose, info, TASKS_START + x + 2 + i * 16, y + 2); if (laptop.isApplicationRunning(info)) { RenderSystem.setShaderTexture(0, APP_BAR_GUI); - laptop.blit(pose, x + 1 + i * 16, y + 1, 35, 0, 16, 16); + laptop.blit(pose, TASKS_START + x + 1 + i * 16, y + 1, 35, 0, 16, 16); } } + RenderSystem.disableBlend(); + assert mc.level == null || mc.player != null; - // assert mc.level != null; //can no longer assume +// assert mc.level != null; //can no longer assume mc.font.drawShadow(pose, timeToString(mc.level != null ? mc.level.getDayTime() : 0), x + 334, y + 5, Color.WHITE.getRGB(), true); + RenderSystem.enableBlend(); + /* Settings App */ int startX = x + 317; for (int i = 0; i < trayItems.size(); i++) { @@ -148,13 +160,19 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in trayItems.get(i).getIcon().draw(pose, mc, posX + 2, y + 4); } + RenderSystem.disableBlend(); + RenderSystem.setShaderTexture(0, APP_BAR_GUI); + /* Other Apps */ + if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 17, y + 16)) { + laptop.blit(pose, x + 1, y + 1, 35, 0, 16, 16); + } /* Other Apps */ - if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 236, y + 16)) { - int appIndex = (mouseX - x - 1) / 16; + if (isMouseInside(mouseX, mouseY, TASKS_START + x + 1, y + 1, x + 236, y + 16)) { + int appIndex = (mouseX - x - 1 - TASKS_START) / 16; if (appIndex >= 0 && appIndex < offset + APPS_DISPLAYED && appIndex < laptop.installedApps.size()) { - laptop.blit(pose, x + appIndex * 16 + 1, y + 1, 35, 0, 16, 16); + laptop.blit(pose, TASKS_START + x + appIndex * 16 + 1, y + 1, 35, 0, 16, 16); laptop.renderComponentTooltip(pose, List.of(Component.literal(laptop.installedApps.get(appIndex).getName())), mouseX, mouseY); } } @@ -163,9 +181,20 @@ public void render(PoseStack pose, Laptop laptop, Minecraft mc, int x, int y, in } public void handleClick(Laptop laptop, int x, int y, int mouseX, int mouseY, int mouseButton) { - if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 236, y + 16)) { + if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 17, y + 16)) { + System system = Laptop.getSystem(); + if (system.hasContext()) { + system.closeContext(); + return; + } + Layout startMenu = createStartMenu(); + system.openContext(startMenu, x + 1, y - 1 - startMenu.height); + return; + } + + if (isMouseInside(mouseX, mouseY, TASKS_START + x + 1, y + 1, x + 236, y + 16)) { Devices.LOGGER.debug(MARKER, "Clicked on task bar"); - int appIndex = (mouseX - x - 1) / 16; + int appIndex = (mouseX - x - 1 - TASKS_START) / 16; if (appIndex >= 0 && appIndex <= offset + APPS_DISPLAYED && appIndex < laptop.installedApps.size()) { laptop.openApplication(laptop.installedApps.get(appIndex)); return; @@ -184,6 +213,43 @@ public void handleClick(Laptop laptop, int x, int y, int mouseX, int mouseY, int } } + /** + * @author Qboi + */ + private Layout createStartMenu() { + var layout = new Layout(120, 114); + + // Set background. + layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, new Color(0.65f, 0.65f, 0.65f, 0.9f).getRGB())); + + // Create app info list with installed applications. + ItemList appList = new ItemList<>(5, 5, 110, 6); + appList.setItems(laptop.installedApps); + + // Application item renderer. + appList.setListItemRenderer(new ListItemRenderer<>(16) { + @Override + public void render(PoseStack pose, AppInfo appInfo, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { + Gui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); + + // Draw text and icon. + RenderUtil.drawStringClipped(pose, appInfo.getName(), x + 16, y + 4, 70, Color.WHITE.getRGB(), false); + RenderUtil.drawApplicationIcon(pose, appInfo, x + 3, y + 3); + } + }); + + // Set handler for when the item gets clicked. + appList.setItemClickListener((appInfo, index, mouseButton) -> { + // Open the application by entry. + Laptop.getSystem().closeContext(); + laptop.openApplication(appInfo); + }); + + // Add the list to the layout and return. + layout.addComponent(appList); + return layout; + } + public boolean isMouseInside(int mouseX, int mouseY, int x1, int y1, int x2, int y2) { return mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2; } diff --git a/common/src/main/resources/assets/devices/textures/gui/application_bar.png b/common/src/main/resources/assets/devices/textures/gui/application_bar.png index 6d14386926f27559defb8e8bd39ac946c238976a..73c43b1a7019fffd97f04969326cf37c34d95799 100644 GIT binary patch literal 4288 zcmeHL{Uek6-=F6waT30#PKel1ww02Qrzo^$p7P8R3oV<6iHuD;)u|2&hm(?d%HxbO zjN`E)VveVIeu#uITg))FeW!Eo?|t7t-T%P-!*zW=@7L%3dA;86*XO!^xUNSI_BQfz zhvWbNfV`cpwG#j!CYp)?_DG8c@9?4_U??WaXiAQ@;0vjhMtllSiUNr__F zP+N}(0APRX?j@%D^W}KahTnr-+_CPkE5`nq5U^hW<~kA_9TF&U=hw5cYmzDZLfIKWiX%>Z^17HWkI3bu_2M>@yYyZFbT{EY%M&CTTH&PN-I7($R( zKaJ>+Tj&VmXj9Ga#KxleE)3Ds_@07AnQFSj95k#j;Yf|M;FI8!nxgF*8t20UZWudR zU;1aeC^FRy!eT>>A&{u3C~(wiFeW?@a>~fa2y#*%qOT7UWq=~?ps{|@AasP*-z5Lg zSR*6+!-GSy!5Fm0F0J2nOeEG+Q&hqC(y+ld{+k>f@s9x_DVJ3k9Tl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GHXE4D4{X!KNf#>`RY_g4sjVs5?>;b~PzV8nnzTe4|c2L)dKho0tV zY;vq47spe?E#K}iS$U~E*3sXe9NRiKr_SU!7{`BG)_Zc!S=3xeWyicfg_Cz8C;5D=@QXc+AO!6M>}jlTS>gJw*Wp` zXS}(Port|T0X7GnGIIQw-Z5YQ=s@SgDRMLg6ajS}(>j_f4!6jdB`^f-GC)*gH4F;T3!;*?sd#$P9Zk<&l{kD{#r}2{SN^E~1hC zBQl6TddTNoR!WTLu|B6;CSNfT|EH#yH-K_&Q+>O{QxP z7{PL(*xc+FMD`#V8ll%e0d;x>hd!g1ur43n>v~+;PQ_0rBQGE%FMf>5AJ^e7;0t!afz-lgxKR8m@1nVph`| zs#?4#D5yg0lx$`%nGXRTPAzNE!X yHq8`Yk}?Gd2>ti<-yZz;9{m3r0|X&%TX6h#i_(N#hvUwFNz1d=XUfg4-25L^u-r5N From d05dda35dbb68da5fb12bcdddc935a46716ec463 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Sun, 5 Mar 2023 05:24:15 +0100 Subject: [PATCH 2/4] Fix icon and text position in start menu. --- common/src/main/java/com/ultreon/devices/core/TaskBar.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/ultreon/devices/core/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/TaskBar.java index 2838417c2..6ba501da7 100644 --- a/common/src/main/java/com/ultreon/devices/core/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/TaskBar.java @@ -233,8 +233,8 @@ public void render(PoseStack pose, AppInfo appInfo, GuiComponent gui, Minecraft Gui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); // Draw text and icon. - RenderUtil.drawStringClipped(pose, appInfo.getName(), x + 16, y + 4, 70, Color.WHITE.getRGB(), false); - RenderUtil.drawApplicationIcon(pose, appInfo, x + 3, y + 3); + RenderUtil.drawStringClipped(pose, appInfo.getName(), x + 18, y + 4, 70, Color.WHITE.getRGB(), false); + RenderUtil.drawApplicationIcon(pose, appInfo, x + 1, y + 1); } }); From 24bb1c2c70d96adc84a507998a4b11cf30b3aa97 Mon Sep 17 00:00:00 2001 From: Qboi123 Date: Sun, 5 Mar 2023 16:02:17 +0100 Subject: [PATCH 3/4] Fix null pointer issue. --- .../java/com/ultreon/devices/core/network/Connection.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/ultreon/devices/core/network/Connection.java b/common/src/main/java/com/ultreon/devices/core/network/Connection.java index 6b898339c..7088babd6 100644 --- a/common/src/main/java/com/ultreon/devices/core/network/Connection.java +++ b/common/src/main/java/com/ultreon/devices/core/network/Connection.java @@ -59,7 +59,10 @@ public boolean isConnected() { public CompoundTag toTag() { CompoundTag tag = new CompoundTag(); tag.putString("id", routerId.toString()); - tag.put("Pos", NbtUtils.writeBlockPos(routerPos)); + if (routerPos != null) { + // FIXME: Router position can be null. Pls fix this. + tag.put("Pos", NbtUtils.writeBlockPos(routerPos)); + } return tag; } From 77244830bdfaaba9f6b73b4369cdb7dc65656faa Mon Sep 17 00:00:00 2001 From: XyperCode Date: Fri, 2 Feb 2024 21:02:55 +0100 Subject: [PATCH 4/4] Fix merge error --- .../com/ultreon/devices/core/TaskBar.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/common/src/main/java/com/ultreon/devices/core/TaskBar.java b/common/src/main/java/com/ultreon/devices/core/TaskBar.java index 4ac480b29..c1331a067 100644 --- a/common/src/main/java/com/ultreon/devices/core/TaskBar.java +++ b/common/src/main/java/com/ultreon/devices/core/TaskBar.java @@ -1,7 +1,6 @@ package com.ultreon.devices.core; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import com.ultreon.devices.Devices; import com.ultreon.devices.api.TrayItemAdder; import com.ultreon.devices.api.app.Application; @@ -20,7 +19,6 @@ import com.ultreon.devices.programs.system.SystemApp; import com.ultreon.devices.util.Vulnerability; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; @@ -111,7 +109,7 @@ public void onTick() { trayItems.forEach(TrayItem::tick); } - public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { + public void render(GuiGraphics gfx, Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, float partialTicks) { RenderSystem.setShaderColor(1f, 1f, 1f, 0.75f); RenderSystem.enableBlend(); RenderSystem.setShaderTexture(0, APP_BAR_GUI); @@ -124,21 +122,21 @@ public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int // Draw system tray. int trayItemsWidth = trayItems.size() * 14; - graphics.blit(APP_BAR_GUI, x, y, 1, 18, 0, 0, 1, 18, 256, 256); - graphics.blit(APP_BAR_GUI, x + 1, y, Laptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); - graphics.blit(APP_BAR_GUI, x + Laptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); + gfx.blit(APP_BAR_GUI, x, y, 1, 18, 0, 0, 1, 18, 256, 256); + gfx.blit(APP_BAR_GUI, x + 1, y, Laptop.SCREEN_WIDTH - 36 - trayItemsWidth, 18, 1, 0, 1, 18, 256, 256); + gfx.blit(APP_BAR_GUI, x + Laptop.SCREEN_WIDTH - 35 - trayItemsWidth, y, 35 + trayItemsWidth, 18, 2, 0, 1, 18, 256, 256); // Draw start menu button - GuiComponent.blit(pose, x, y, 18, 18, 0, 0, 1, 18, 256, 256); + gfx.blit(APP_BAR_GUI, x, y, 18, 18, 0, 0, 1, 18, 256, 256); RenderSystem.setShaderColor(1f, 1f, 1f, 1f); - laptop.blit(pose, x + 1, y + 1, 52, 0, 16, 16); + gfx.blit(APP_BAR_GUI, x + 1, y + 1, 52, 0, 16, 16); for (int i = 0; i < APPS_DISPLAYED && i < laptop.installedApps.size(); i++) { AppInfo info = laptop.installedApps.get(i + offset); - RenderUtil.drawApplicationIcon(graphics, info, TASKS_START + x + 2 + i * 16, y + 2); + RenderUtil.drawApplicationIcon(gfx, info, TASKS_START + x + 2 + i * 16, y + 2); if (laptop.isApplicationRunning(info)) { RenderSystem.setShaderTexture(0, APP_BAR_GUI); - graphics.blit(APP_BAR_GUI, TASKS_START + x + 1 + i * 16, y + 1, 35, 0, 16, 16); + gfx.blit(APP_BAR_GUI, TASKS_START + x + 1 + i * 16, y + 1, 35, 0, 16, 16); } } @@ -146,7 +144,7 @@ public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int assert mc.level == null || mc.player != null; // assert mc.level != null; //can no longer assume - graphics.drawString(mc.font, timeToString(mc.level != null ? mc.level.getDayTime() : 0), x + 334, y + 5, Color.WHITE.getRGB(), true); + gfx.drawString(mc.font, timeToString(mc.level != null ? mc.level.getDayTime() : 0), x + 334, y + 5, Color.WHITE.getRGB(), true); RenderSystem.enableBlend(); @@ -155,9 +153,9 @@ public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int for (int i = 0; i < trayItems.size(); i++) { int posX = startX - (trayItems.size() - 1 - i) * 14; if (isMouseInside(mouseX, mouseY, posX, y + 2, posX + 13, y + 15)) { - graphics.fill(posX, y + 2, posX + 14, y + 16, new Color(1f, 1f, 1f, 0.1f).getRGB()); + gfx.fill(posX, y + 2, posX + 14, y + 16, new Color(1f, 1f, 1f, 0.1f).getRGB()); } - trayItems.get(i).getIcon().draw(graphics, mc, posX + 2, y + 4); + trayItems.get(i).getIcon().draw(gfx, mc, posX + 2, y + 4); } RenderSystem.disableBlend(); @@ -165,15 +163,15 @@ public void render(GuiGraphics graphics, Laptop laptop, Minecraft mc, int x, int RenderSystem.setShaderTexture(0, APP_BAR_GUI); /* Other Apps */ if (isMouseInside(mouseX, mouseY, x + 1, y + 1, x + 17, y + 16)) { - laptop.blit(pose, x + 1, y + 1, 35, 0, 16, 16); + gfx.blit(APP_BAR_GUI, x + 1, y + 1, 35, 0, 16, 16); } /* Other Apps */ if (isMouseInside(mouseX, mouseY, TASKS_START + x + 1, y + 1, x + 236, y + 16)) { int appIndex = (mouseX - x - 1 - TASKS_START) / 16; if (appIndex >= 0 && appIndex < offset + APPS_DISPLAYED && appIndex < laptop.installedApps.size()) { - graphics.blit(APP_BAR_GUI, TASKS_START + x + appIndex * 16 + 1, y + 1, 35, 0, 16, 16); - laptop.renderComponentTooltip(graphics, List.of(Component.literal(laptop.installedApps.get(appIndex).getName())), mouseX, mouseY); + gfx.blit(APP_BAR_GUI, TASKS_START + x + appIndex * 16 + 1, y + 1, 35, 0, 16, 16); + laptop.renderComponentTooltip(gfx, List.of(Component.literal(laptop.installedApps.get(appIndex).getName())), mouseX, mouseY); } } @@ -220,7 +218,7 @@ private Layout createStartMenu() { var layout = new Layout(120, 114); // Set background. - layout.setBackground((pose, gui, mc, x, y, width, height, mouseX, mouseY, windowActive) -> Gui.fill(pose, x, y, x + width, y + height, new Color(0.65f, 0.65f, 0.65f, 0.9f).getRGB())); + layout.setBackground((gfx, mc, x, y, width, height, mouseX, mouseY, windowActive) -> gfx.fill(x, y, x + width, y + height, new Color(0.65f, 0.65f, 0.65f, 0.9f).getRGB())); // Create app info list with installed applications. ItemList appList = new ItemList<>(5, 5, 110, 6); @@ -229,12 +227,12 @@ private Layout createStartMenu() { // Application item renderer. appList.setListItemRenderer(new ListItemRenderer<>(16) { @Override - public void render(PoseStack pose, AppInfo appInfo, GuiComponent gui, Minecraft mc, int x, int y, int width, int height, boolean selected) { - Gui.fill(pose, x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); + public void render(GuiGraphics gfx, AppInfo appInfo, Minecraft mc, int x, int y, int width, int height, boolean selected) { + gfx.fill(x, y, x + width, y + height, selected ? Color.DARK_GRAY.getRGB() : Color.GRAY.getRGB()); // Draw text and icon. - RenderUtil.drawStringClipped(pose, appInfo.getName(), x + 18, y + 4, 70, Color.WHITE.getRGB(), false); - RenderUtil.drawApplicationIcon(pose, appInfo, x + 1, y + 1); + RenderUtil.drawStringClipped(gfx, appInfo.getName(), x + 18, y + 4, 70, Color.WHITE.getRGB(), false); + RenderUtil.drawApplicationIcon(gfx, appInfo, x + 1, y + 1); } });