Compare commits
5 Commits
936942c1bf
...
543a256587
| Author | SHA1 | Date | |
|---|---|---|---|
| 543a256587 | |||
| 7c0321265a | |||
| e579eef380 | |||
| 4e53d84727 | |||
| d4e087f992 |
@@ -0,0 +1,23 @@
|
||||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Build and Test
|
||||
run: ./gradlew build
|
||||
@@ -16,6 +16,7 @@ The project uses Gradle.
|
||||
* **Dependency Injection:** Uses `avaje-inject`. Components are marked with `@Component` and injected via constructor.
|
||||
* **Boilerplate:** Uses `lombok` for boilerplate reduction.
|
||||
* **Rendering:** Built on LibGDX. Main entry point is `DiceOS.java` which extends `ApplicationAdapter`.
|
||||
* **Asset Loading:** All assets, including textures, fonts, and NinePatches, must be loaded via the `ResourceLoader` service to ensure proper lifecycle management and caching.
|
||||
* **Project Structure:**
|
||||
* `src/main/java/be/seeseemelk/diceos/system`: Core OS services (Display, Window, Input, etc.).
|
||||
* `src/main/resources`: Assets (backgrounds, system textures, fonts).
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ dependencies {
|
||||
api("com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion")
|
||||
api("com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop")
|
||||
|
||||
testImplementation(platform("org.junit:junit-bom:5.14.4"))
|
||||
testImplementation(platform("org.junit:junit-bom:6.0.3"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -172,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
|
||||
Vendored
+10
-22
@@ -23,8 +23,8 @@
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@@ -51,7 +51,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -65,30 +65,18 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package be.seeseemelk.diceos.system;
|
||||
|
||||
import io.avaje.inject.Component;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class WindowSpawnTask implements OnStartup {
|
||||
private final WindowService windowService;
|
||||
|
||||
@Override
|
||||
public void onStartup() {
|
||||
windowService.spawnWindow(50, 50, 200, 150);
|
||||
}
|
||||
}
|
||||
@@ -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,47 @@ 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;
|
||||
}
|
||||
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + height;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
Reference in New Issue
Block a user