Rename github to gitea
Build and Test / build (push) Failing after 44s

This commit is contained in:
2026-05-13 12:59:53 +02:00
parent 4e53d84727
commit e579eef380
5 changed files with 67 additions and 0 deletions
@@ -2,6 +2,7 @@ package be.seeseemelk.diceos.system;
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
@@ -71,6 +72,10 @@ public class DiceOS extends ApplicationAdapter {
@Override
public void render() {
int mouseX = Gdx.input.getX();
int mouseY = display.getHeight() - Gdx.input.getY();
windowService.update(mouseX, mouseY, Gdx.input.isTouched());
cursorService.updateCursor();
ScreenUtils.clear(Color.BLACK);
@@ -84,6 +89,9 @@ public class DiceOS extends ApplicationAdapter {
// Render background
gc.draw(clouds, 0, 0);
// Render windows
windowService.render(gc);
gc.scissor(0, 0, gc.getWidth(), gc.getHeight(), windowService::paint);
// Render borders
@@ -2,26 +2,49 @@ package be.seeseemelk.diceos.system;
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
import be.seeseemelk.diceos.system.toolkit.Menubar;
import be.seeseemelk.diceos.system.toolkit.Window;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import io.avaje.inject.Component;
import lombok.RequiredArgsConstructor;
import java.util.ArrayList;
import java.util.List;
@RequiredArgsConstructor
@Component
public class WindowService implements OnStartup {
private final ResourceLoader resourceLoader;
private final List<Window> windows = new ArrayList<>();
private NinePatch menubar;
private NinePatch windowDecoration;
private Menubar systemMenubar;
@Override
public void onStartup() {
menubar = resourceLoader.loadNinePatch("system/menubar.png");
windowDecoration = resourceLoader.loadNinePatch("system/window.png");
systemMenubar = new Menubar()
.addItem("Dice")
.addItem("System");
}
public void spawnWindow(int x, int y, int width, int height) {
windows.add(new Window(x, y, width, height, windowDecoration));
}
public void update(int mouseX, int mouseY, boolean isTouched) {
for (Window window : windows) {
window.handleInput(mouseX, mouseY, isTouched);
}
}
public void render(GraphicsContext gc) {
for (Window window : windows) {
window.paint(gc);
}
}
void paint(GraphicsContext gc) {
// Render menubar
gc.draw(menubar, 0, 0, gc.getWidth(), 14);
@@ -1,6 +1,7 @@
package be.seeseemelk.diceos.system.toolkit;
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import lombok.Getter;
import lombok.Setter;
@@ -8,9 +9,43 @@ import lombok.Setter;
@Getter
public class Window extends Container {
private String title;
private int x, y, width, height;
private boolean active;
private NinePatch decoration;
public Window(int x, int y, int width, int height, NinePatch decoration) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.decoration = decoration;
}
private int dragOffsetX, dragOffsetY;
private boolean isDragging;
public void handleInput(int mouseX, int mouseY, boolean isTouched) {
if (isTouched) {
if (!isDragging && isHovered(mouseX, mouseY)) {
isDragging = true;
dragOffsetX = mouseX - x;
dragOffsetY = mouseY - y;
}
} else {
isDragging = false;
}
if (isDragging) {
x = mouseX - dragOffsetX;
y = mouseY - dragOffsetY;
}
}
@Override
public void paint(GraphicsContext gc) {
if (decoration != null) {
decoration.draw(gc.getBatch(), x, y, width, height);
}
super.paint(gc);
}
}