-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add .editorconfig * Add .gitattributes * Experimental input adapter, detecting key modifier * Experimental Math util exposure: intersection calculation for mouse enter and exit * Input API, allow registering multiple processors on top of normal Gdx.input * Move single-use utils closer to calling class * Simplify GameAssetLoaderMixin, moving complexity into helper class * Use Gradle Kotlin DSL: better IDE support and less weird warnings (that adds "noise") * Work on UI Component API * Initial children components * Preparing exact mouse enter and exit detection
- Loading branch information
1 parent
3c77e7c
commit b0ef8c5
Showing
25 changed files
with
2,196 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 100 | ||
tab_width = 4 | ||
ij_continuation_indent_size = 4 | ||
ij_formatter_off_tag = @formatter:off | ||
ij_formatter_on_tag = @formatter:on | ||
ij_formatter_tags_enabled = false | ||
ij_smart_tabs = false | ||
ij_wrap_on_typing = false | ||
|
||
[*.java] | ||
ij_java_imports_layout = $*,|,* | ||
ij_java_class_count_to_use_import_on_demand = 999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto eol=lf | ||
*.bat text eol=crlf |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
object Constants { | ||
const val GROUP = "dev.crmodders" | ||
const val MODID = "flux-api" | ||
const val VERSION = "0.8.0-alpha.1" | ||
|
||
const val TITLE = "Flux API" | ||
const val DESCRIPTION = "Community focused API for Cosmic Reach Quilt" | ||
|
||
const val VERSION_COSMIC_REACH = "0.3.6" | ||
const val VERSION_COSMIC_QUILT = "03cc947b041184bc656e170d164ced5bc1477b37" | ||
} | ||
|
||
base { | ||
group = Constants.GROUP | ||
archivesName = Constants.MODID | ||
version = Constants.VERSION | ||
} | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
id("cosmicloom") | ||
} | ||
|
||
java { | ||
withSourcesJar() | ||
// withJavadocJar() | ||
|
||
// Sets the Java version | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
loom { | ||
accessWidenerPath = file("src/main/resources/flux-api.accesswidener") | ||
} | ||
|
||
repositories { | ||
flatDir { | ||
dirs("lib") | ||
} | ||
} | ||
|
||
dependencies { | ||
cosmicReach(loom.cosmicReachClient("pre-alpha", Constants.VERSION_COSMIC_REACH)) | ||
modImplementation(loom.cosmicQuilt(Constants.VERSION_COSMIC_QUILT)) | ||
runtimeOnly(":testmod:") | ||
|
||
compileOnly("com.badlogicgames.gdx:gdx:1.12.1") | ||
} | ||
|
||
tasks.withType<ProcessResources> { | ||
// Locations of where to inject the properties | ||
val resourceTargets = listOf( | ||
"quilt.mod.json" | ||
) | ||
|
||
// Left item is the name in the target, right is the variable name | ||
val replaceProperties = mapOf( | ||
"mod_group" to Constants.GROUP, | ||
"mod_id" to Constants.MODID, | ||
"mod_version" to Constants.VERSION, | ||
|
||
"mod_name" to Constants.TITLE, | ||
"mod_desc" to Constants.DESCRIPTION, | ||
|
||
"cosmic_reach_version" to Constants.VERSION_COSMIC_REACH, | ||
) | ||
|
||
inputs.properties(replaceProperties) | ||
|
||
filesMatching(resourceTargets) { | ||
expand(replaceProperties) | ||
} | ||
} | ||
|
||
testing { | ||
suites { | ||
val test by getting(JvmTestSuite::class) { | ||
useJUnitJupiter() | ||
|
||
// sources { | ||
// val main by sourceSets.getting | ||
// runtimeClasspath += main.runtimeClasspath | ||
// compileClasspath += main.compileClasspath | ||
// } | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = Constants.GROUP | ||
artifactId = Constants.MODID | ||
|
||
from(components["java"]) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
buildscript { | ||
repositories { | ||
maven { | ||
name = "JitPack" | ||
url = uri("https://jitpack.io") | ||
} | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath( | ||
group = "org.codeberg.CRModders", | ||
name = "cosmic-loom", | ||
version = "PR7-SNAPSHOT", | ||
) | ||
} | ||
} | ||
|
||
rootProject.name = "Flux API" |
172 changes: 172 additions & 0 deletions
172
src/main/java/dev/crmodders/flux/api/input/client/InputAdapterEx.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package dev.crmodders.flux.api.input.client; | ||
|
||
import com.badlogic.gdx.Input; | ||
import com.badlogic.gdx.InputProcessor; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
@ApiStatus.Experimental | ||
public abstract class InputAdapterEx implements InputProcessor { | ||
public static class Modifiers { | ||
public static final int ALT = 1; | ||
public static final int ALT_LEFT = 2; | ||
public static final int ALT_RIGHT = 4; | ||
public static final int CONTROL = 8; | ||
public static final int CONTROL_LEFT = 16; | ||
public static final int CONTROL_RIGHT = 32; | ||
public static final int SHIFT = 64; | ||
public static final int SHIFT_LEFT = 128; | ||
public static final int SHIFT_RIGHT = 256; | ||
|
||
public static final int ANY_ALT = ALT | ALT_LEFT | ALT_RIGHT; | ||
public static final int ANY_CONTROL = CONTROL | CONTROL_LEFT | CONTROL_RIGHT; | ||
public static final int ANY_SHIFT = SHIFT | SHIFT_LEFT | SHIFT_RIGHT; | ||
|
||
public static boolean isAltDown(final int i) { | ||
return (i & ANY_ALT) != 0; | ||
} | ||
|
||
public static boolean isControlDown(final int i) { | ||
return (i & ANY_CONTROL) != 0; | ||
} | ||
|
||
public static boolean isShiftDown(final int i) { | ||
return (i & ANY_SHIFT) != 0; | ||
} | ||
|
||
public static boolean isAltOnly(final int i) { | ||
return isAltDown(i) && (i & ~ANY_ALT) == 0; | ||
} | ||
|
||
public static boolean isControlOnly(final int i) { | ||
return isControlDown(i) && (i & ~ANY_CONTROL) == 0; | ||
} | ||
|
||
public static boolean isShiftOnly(final int i) { | ||
return isShiftDown(i) && (i & ~ANY_SHIFT) == 0; | ||
} | ||
} | ||
|
||
private int modifiers; | ||
|
||
@Override | ||
public boolean keyDown(final int keycode) { | ||
final var modifiers = this.modifiers |= switch (keycode) { | ||
case Input.Keys.ALT_LEFT -> Modifiers.ALT | Modifiers.ALT_LEFT; | ||
case Input.Keys.ALT_RIGHT -> Modifiers.ALT | Modifiers.ALT_RIGHT; | ||
case Input.Keys.SHIFT_LEFT -> Modifiers.SHIFT | Modifiers.SHIFT_LEFT; | ||
case Input.Keys.SHIFT_RIGHT -> Modifiers.SHIFT | Modifiers.CONTROL_RIGHT; | ||
case Input.Keys.CONTROL_LEFT -> Modifiers.CONTROL | Modifiers.CONTROL_LEFT; | ||
case Input.Keys.CONTROL_RIGHT -> Modifiers.CONTROL | Modifiers.CONTROL_RIGHT; | ||
default -> 0; | ||
}; | ||
return this.keyDownEx(keycode, modifiers); | ||
} | ||
|
||
protected abstract boolean keyDownEx(int keycode, int modifiers); | ||
|
||
@Override | ||
public boolean keyUp(final int keycode) { | ||
final var modifiers = this.modifiers; | ||
final var result = this.keyUpEx(keycode, modifiers); | ||
|
||
final int mask1; | ||
final int mask2; | ||
switch (keycode) { | ||
case Input.Keys.ALT_LEFT -> { | ||
mask1 = Modifiers.ALT | Modifiers.ALT_LEFT; | ||
mask2 = Modifiers.ALT | Modifiers.ALT_RIGHT; | ||
} | ||
case Input.Keys.ALT_RIGHT -> { | ||
mask1 = Modifiers.ALT | Modifiers.ALT_RIGHT; | ||
mask2 = Modifiers.ALT | Modifiers.ALT_LEFT; | ||
} | ||
case Input.Keys.CONTROL_LEFT -> { | ||
mask1 = Modifiers.CONTROL | Modifiers.CONTROL_LEFT; | ||
mask2 = Modifiers.CONTROL | Modifiers.CONTROL_RIGHT; | ||
} | ||
case Input.Keys.CONTROL_RIGHT -> { | ||
mask1 = Modifiers.CONTROL | Modifiers.CONTROL_RIGHT; | ||
mask2 = Modifiers.CONTROL | Modifiers.CONTROL_LEFT; | ||
} | ||
case Input.Keys.SHIFT_LEFT -> { | ||
mask1 = Modifiers.SHIFT | Modifiers.SHIFT_LEFT; | ||
mask2 = Modifiers.SHIFT | Modifiers.SHIFT_RIGHT; | ||
} | ||
case Input.Keys.SHIFT_RIGHT -> { | ||
mask1 = Modifiers.SHIFT | Modifiers.SHIFT_RIGHT; | ||
mask2 = Modifiers.SHIFT | Modifiers.SHIFT_LEFT; | ||
} | ||
default -> { | ||
mask1 = 0; | ||
mask2 = 0; | ||
} | ||
} | ||
final var mask = (modifiers & mask2) != mask2 ? mask1 : mask1 & ~mask2; | ||
this.modifiers = modifiers & ~mask; | ||
|
||
return result; | ||
} | ||
|
||
protected abstract boolean keyUpEx(int keycode, int modifiers); | ||
|
||
@Override | ||
public boolean touchDown( | ||
final int screenX, | ||
final int screenY, | ||
final int pointer, | ||
final int button | ||
) { | ||
return this.touchDownEx(screenX, screenY, pointer, button, this.modifiers); | ||
} | ||
|
||
protected abstract boolean touchDownEx(int screenX, int screenY, int pointer, int button, int modifiers); | ||
|
||
@Override | ||
public boolean touchUp( | ||
final int screenX, | ||
final int screenY, | ||
final int pointer, | ||
final int button | ||
) { | ||
return this.touchUpEx(screenX, screenY, pointer, button, this.modifiers); | ||
} | ||
|
||
protected abstract boolean touchUpEx(int screenX, int screenY, int pointer, int button, int modifiers); | ||
|
||
@Override | ||
public boolean touchCancelled( | ||
final int screenX, | ||
final int screenY, | ||
final int pointer, | ||
final int button | ||
) { | ||
return this.touchCancelledEx(screenX, screenY, pointer, button, this.modifiers); | ||
} | ||
|
||
protected abstract boolean touchCancelledEx(int screenX, int screenY, int pointer, int button, int modifiers); | ||
|
||
@Override | ||
public boolean touchDragged( | ||
final int screenX, | ||
final int screenY, | ||
final int pointer | ||
) { | ||
return this.touchDraggedEx(screenX, screenY, pointer, this.modifiers); | ||
} | ||
|
||
protected abstract boolean touchDraggedEx(int screenX, int screenY, int pointer, int modifiers); | ||
|
||
@Override | ||
public boolean mouseMoved(final int screenX, final int screenY) { | ||
return this.mouseMovedEx(screenX, screenY, this.modifiers); | ||
} | ||
|
||
protected abstract boolean mouseMovedEx(int screenX, int screenY, int modifiers); | ||
|
||
@Override | ||
public boolean scrolled(final float amountX, final float amountY) { | ||
return this.scrolledEx(amountX, amountY, this.modifiers); | ||
} | ||
|
||
protected abstract boolean scrolledEx(float amountX, float amountY, int modifiers); | ||
} |
Oops, something went wrong.