Compare commits
5 Commits
7602b4c55e
...
28ef958b5d
| Author | SHA1 | Date | |
|---|---|---|---|
| 28ef958b5d | |||
| 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.
|
* **Dependency Injection:** Uses `avaje-inject`. Components are marked with `@Component` and injected via constructor.
|
||||||
* **Boilerplate:** Uses `lombok` for boilerplate reduction.
|
* **Boilerplate:** Uses `lombok` for boilerplate reduction.
|
||||||
* **Rendering:** Built on LibGDX. Main entry point is `DiceOS.java` which extends `ApplicationAdapter`.
|
* **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:**
|
* **Project Structure:**
|
||||||
* `src/main/java/be/seeseemelk/diceos/system`: Core OS services (Display, Window, Input, etc.).
|
* `src/main/java/be/seeseemelk/diceos/system`: Core OS services (Display, Window, Input, etc.).
|
||||||
* `src/main/resources`: Assets (backgrounds, system textures, fonts).
|
* `src/main/resources`: Assets (backgrounds, system textures, fonts).
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ dependencies {
|
|||||||
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")
|
testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}")
|
||||||
|
|
||||||
// Dependency Injection
|
// Dependency Injection
|
||||||
implementation("io.avaje:avaje-config:4.4")
|
implementation("io.avaje:avaje-config:5.1")
|
||||||
implementation("io.avaje:avaje-inject:${avajeInjectVersion}")
|
implementation("io.avaje:avaje-inject:${avajeInjectVersion}")
|
||||||
annotationProcessor("io.avaje:avaje-inject-generator:${avajeInjectVersion}")
|
annotationProcessor("io.avaje:avaje-inject-generator:${avajeInjectVersion}")
|
||||||
testImplementation("io.avaje:avaje-inject-test:${avajeInjectVersion}")
|
testImplementation("io.avaje:avaje-inject-test:${avajeInjectVersion}")
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# 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
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
|||||||
Vendored
+10
-22
@@ -23,8 +23,8 @@
|
|||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
setlocal EnableExtensions
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
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 Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
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 Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:exitWithErrorLevel
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
|
|
||||||
: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
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package be.seeseemelk.diceos.system;
|
|||||||
|
|
||||||
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
||||||
import com.badlogic.gdx.ApplicationAdapter;
|
import com.badlogic.gdx.ApplicationAdapter;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
@@ -71,6 +72,10 @@ public class DiceOS extends ApplicationAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
|
int mouseX = Gdx.input.getX();
|
||||||
|
int mouseY = display.getHeight() - Gdx.input.getY();
|
||||||
|
windowService.update(mouseX, mouseY, Gdx.input.isTouched());
|
||||||
|
|
||||||
cursorService.updateCursor();
|
cursorService.updateCursor();
|
||||||
|
|
||||||
ScreenUtils.clear(Color.BLACK);
|
ScreenUtils.clear(Color.BLACK);
|
||||||
@@ -84,6 +89,9 @@ public class DiceOS extends ApplicationAdapter {
|
|||||||
// Render background
|
// Render background
|
||||||
gc.draw(clouds, 0, 0);
|
gc.draw(clouds, 0, 0);
|
||||||
|
|
||||||
|
// Render windows
|
||||||
|
windowService.render(gc);
|
||||||
|
|
||||||
gc.scissor(0, 0, gc.getWidth(), gc.getHeight(), windowService::paint);
|
gc.scissor(0, 0, gc.getWidth(), gc.getHeight(), windowService::paint);
|
||||||
|
|
||||||
// Render borders
|
// Render borders
|
||||||
|
|||||||
@@ -2,26 +2,49 @@ package be.seeseemelk.diceos.system;
|
|||||||
|
|
||||||
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
||||||
import be.seeseemelk.diceos.system.toolkit.Menubar;
|
import be.seeseemelk.diceos.system.toolkit.Menubar;
|
||||||
|
import be.seeseemelk.diceos.system.toolkit.Window;
|
||||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
import io.avaje.inject.Component;
|
import io.avaje.inject.Component;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
public class WindowService implements OnStartup {
|
public class WindowService implements OnStartup {
|
||||||
private final ResourceLoader resourceLoader;
|
private final ResourceLoader resourceLoader;
|
||||||
|
private final List<Window> windows = new ArrayList<>();
|
||||||
private NinePatch menubar;
|
private NinePatch menubar;
|
||||||
|
private NinePatch windowDecoration;
|
||||||
private Menubar systemMenubar;
|
private Menubar systemMenubar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartup() {
|
public void onStartup() {
|
||||||
menubar = resourceLoader.loadNinePatch("system/menubar.png");
|
menubar = resourceLoader.loadNinePatch("system/menubar.png");
|
||||||
|
windowDecoration = resourceLoader.loadNinePatch("system/window.png");
|
||||||
|
|
||||||
systemMenubar = new Menubar()
|
systemMenubar = new Menubar()
|
||||||
.addItem("Dice")
|
.addItem("Dice")
|
||||||
.addItem("System");
|
.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) {
|
void paint(GraphicsContext gc) {
|
||||||
// Render menubar
|
// Render menubar
|
||||||
gc.draw(menubar, 0, 0, gc.getWidth(), 14);
|
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;
|
package be.seeseemelk.diceos.system.toolkit;
|
||||||
|
|
||||||
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
import be.seeseemelk.diceos.system.gfx.GraphicsContext;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@@ -8,9 +9,47 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
public class Window extends Container {
|
public class Window extends Container {
|
||||||
private String title;
|
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
|
@Override
|
||||||
public void paint(GraphicsContext gc) {
|
public void paint(GraphicsContext gc) {
|
||||||
|
if (decoration != null) {
|
||||||
|
decoration.draw(gc.getBatch(), x, y, width, height);
|
||||||
|
}
|
||||||
super.paint(gc);
|
super.paint(gc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
Reference in New Issue
Block a user