Skip to content

Commit

Permalink
Merge branch 'main' into ignite-spell-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
miyucomics authored Sep 28, 2024
2 parents 0c3720b + 16b2cfd commit fbfb646
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ public interface ClientConfigAccess {

double gridSnapThreshold();

boolean clickingTogglesDrawing();

boolean DEFAULT_CTRL_TOGGLES_OFF_STROKE_ORDER = false;
boolean DEFAULT_INVERT_SPELLBOOK_SCROLL = false;
boolean DEFAULT_INVERT_ABACUS_SCROLL = false;
double DEFAULT_GRID_SNAP_THRESHOLD = 0.5;
boolean DEFAULT_CLICKING_TOGGLES_DRAWING = false;
}

public interface ServerConfigAccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@ class GuiSpellcasting constructor(
if (super.mouseClicked(mxOut, myOut, pButton)) {
return true
}
if (HexConfig.client().clickingTogglesDrawing()) {
return if (this.drawState is PatternDrawState.BetweenPatterns)
drawStart(mxOut, myOut)
else
drawEnd()
}
return drawStart(mxOut, myOut)
}

private fun drawStart(mxOut: Double, myOut: Double): Boolean {
val mx = Mth.clamp(mxOut, 0.0, this.width.toDouble())
val my = Mth.clamp(myOut, 0.0, this.height.toDouble())
if (this.drawState is PatternDrawState.BetweenPatterns) {
Expand All @@ -156,11 +165,23 @@ class GuiSpellcasting constructor(
return false
}

override fun mouseMoved(mxOut: Double, myOut: Double) {
super.mouseMoved(mxOut, myOut)

if (HexConfig.client().clickingTogglesDrawing() && this.drawState !is PatternDrawState.BetweenPatterns)
drawMove(mxOut, myOut)
}

override fun mouseDragged(mxOut: Double, myOut: Double, pButton: Int, pDragX: Double, pDragY: Double): Boolean {
if (super.mouseDragged(mxOut, myOut, pButton, pDragX, pDragY)) {
return true
}
if (HexConfig.client().clickingTogglesDrawing())
return false
return drawMove(mxOut, myOut)
}

private fun drawMove(mxOut: Double, myOut: Double): Boolean {
val mx = Mth.clamp(mxOut, 0.0, this.width.toDouble())
val my = Mth.clamp(myOut, 0.0, this.height.toDouble())

Expand Down Expand Up @@ -237,7 +258,12 @@ class GuiSpellcasting constructor(
if (super.mouseReleased(mx, my, pButton)) {
return true
}
if (HexConfig.client().clickingTogglesDrawing())
return false
return drawEnd()
}

private fun drawEnd(): Boolean {
when (this.drawState) {
PatternDrawState.BetweenPatterns -> {}
is PatternDrawState.JustStarted -> {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "hexcasting.action.hexcasting:cycle_variant",
"category": "hexcasting:patterns/spells",
"icon": "minecraft:smithing_table",
"sortnum": 6,
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:cycle_variant",
"anchor": "hexcasting:cycle_variant",
"input": "",
"output": "",
"text": "hexcasting.page.cycle_variant"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"category": "hexcasting:patterns/spells",
"icon": "minecraft:feather",
"advancement": "hexcasting:root",
"sortnum": 6,
"sortnum": 7,
"read_by_default": true,
"pages": [
"hexcasting.page.flights.1",
Expand Down
Binary file modified Common/src/main/resources/assets/hexcasting/sounds/abacus1.ogg
Binary file not shown.
Binary file modified Common/src/main/resources/assets/hexcasting/sounds/abacus2.ogg
Binary file not shown.
Binary file modified Common/src/main/resources/assets/hexcasting/sounds/abacus3.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public static final class Client implements HexConfig.ClientConfigAccess, Config
private boolean invertAbacusScrollDirection = DEFAULT_INVERT_SPELLBOOK_SCROLL;
@ConfigEntry.Gui.Tooltip
private double gridSnapThreshold = DEFAULT_GRID_SNAP_THRESHOLD;
@ConfigEntry.Gui.Tooltip
private boolean clickingTogglesDrawing = DEFAULT_CLICKING_TOGGLES_DRAWING;

@Override
public void validatePostLoad() throws ValidationException {
Expand All @@ -157,6 +159,11 @@ public boolean invertAbacusScrollDirection() {
public double gridSnapThreshold() {
return gridSnapThreshold;
}

@Override
public boolean clickingTogglesDrawing() {
return clickingTogglesDrawing;
}
}

@Config(name = "server")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static class Client implements HexConfig.ClientConfigAccess {
private static ForgeConfigSpec.BooleanValue invertSpellbookScrollDirection;
private static ForgeConfigSpec.BooleanValue invertAbacusScrollDirection;
private static ForgeConfigSpec.DoubleValue gridSnapThreshold;
private static ForgeConfigSpec.BooleanValue clickingTogglesDrawing;

public Client(ForgeConfigSpec.Builder builder) {
ctrlTogglesOffStrokeOrder = builder.comment(
Expand All @@ -98,6 +99,9 @@ public Client(ForgeConfigSpec.Builder builder) {
"When using a staff, the distance from one dot you have to go to snap to the next dot, where 0.5 " +
"means 50% of the way.")
.defineInRange("gridSnapThreshold", DEFAULT_GRID_SNAP_THRESHOLD, 0.5, 1.0);
clickingTogglesDrawing = builder.comment(
"Whether you click to start and stop drawing instead of clicking and dragging")
.define("clickingTogglesDrawing", DEFAULT_CLICKING_TOGGLES_DRAWING);
}

@Override
Expand All @@ -119,6 +123,11 @@ public boolean ctrlTogglesOffStrokeOrder() {
public double gridSnapThreshold() {
return gridSnapThreshold.get();
}

@Override
public boolean clickingTogglesDrawing() {
return clickingTogglesDrawing.get();
}
}

public static class Server implements HexConfig.ServerConfigAccess {
Expand Down

0 comments on commit fbfb646

Please sign in to comment.