🔖 LambdaControls v1.4.0: Analog movements, 1.16.2 compat, better API, etc.

This commit is contained in:
LambdAurora
2020-07-18 18:41:46 +02:00
parent 127c44a046
commit 5dd5597037
24 changed files with 321 additions and 204 deletions

View File

@@ -74,3 +74,18 @@ This update also has a backport 1.14.4 version ([#9](https://github.com/LambdAur
- Improved reacharound API. - Improved reacharound API.
- Improved [REI](https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items) compatibility. - Improved [REI](https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items) compatibility.
## v1.4.0
- Added analog movements ([#10](https://github.com/LambdAurora/LambdaControls/issues/10)).
- Improved Ok Zoomer compability.
- Updated [SpruceUI](https://github.com/LambdAurora/SpruceUI) to 1.5.8 to ensure 1.16.2 compability.
- Internal changes:
- Added analog input value to button bindings.
- Replace lot of strings with Texts.
- Improved block outline rendering injection.
- Shadow library jars instead of Jar-in-Jar.
- Fixed crash in inventory ([#16](https://github.com/LambdAurora/LambdaControls/issues/16))
- WIP:
- Started to work on action ring.
- Will allow for better compability with other mods.
- Might be interesting for keyboard users too.

View File

@@ -7,13 +7,15 @@
![Version](https://img.shields.io/github/v/tag/LambdAurora/LambdaControls?label=version&style=flat-square) ![Version](https://img.shields.io/github/v/tag/LambdAurora/LambdaControls?label=version&style=flat-square)
[![CurseForge](http://cf.way2muchnoise.eu/title/354231.svg)](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols) [![CurseForge](http://cf.way2muchnoise.eu/title/354231.svg)](https://www.curseforge.com/minecraft/mc-mods/lambdacontrols)
A Fabric Minecraft mod which adds better controls like controller support. A Fabric Minecraft mod which adds better controls, reach-around and controller support.
## What's this mod? ## What's this mod?
This mod adds better controls, reach-around features, etc.
Haven't you dreamed to travel in your modded Minecraft world with your controller? Yes? Then this mod is made for you! Haven't you dreamed to travel in your modded Minecraft world with your controller? Yes? Then this mod is made for you!
This mod adds a controller support (and an experimental touchscreen support). This mod also adds controller support.
## ✅ Features: ## ✅ Features:
@@ -21,7 +23,7 @@ This mod adds a controller support (and an experimental touchscreen support).
- Touchscreen support (very experimental and buggy). - Touchscreen support (very experimental and buggy).
- Keyboard controls to look around. - Keyboard controls to look around.
- Toggleable on screen button indicator (like in Bedrock Edition). - Toggleable on screen button indicator (like in Bedrock Edition).
- Vertical reacharound. - Vertical reach-around.
- Many Bedrock Edition features: - Many Bedrock Edition features:
- Toggleable fly drifting - Toggleable fly drifting
- Front block placing (be careful with this one) - Front block placing (be careful with this one)

View File

@@ -20,14 +20,6 @@ allprojects {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
publishing { publishing {
repositories { repositories {
mavenLocal() mavenLocal()

View File

@@ -15,6 +15,8 @@ dependencies {
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
} }
publishing { publishing {

View File

@@ -1,3 +1,5 @@
import net.fabricmc.loom.task.RemapJarTask
plugins { plugins {
id 'fabric-loom' version '0.4-SNAPSHOT' id 'fabric-loom' version '0.4-SNAPSHOT'
id 'java-library' id 'java-library'
@@ -38,28 +40,27 @@ dependencies {
//to change the versions see the gradle.properties file //to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}" mappings "net.fabricmc:yarn:${project.yarn_mappings}"
modCompile "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API. This is technically optional, but you probably want it anyway.
modApi "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompile "io.github.prospector:modmenu:${project.modmenu_version}" modImplementation "io.github.prospector:modmenu:${project.modmenu_version}"
modCompile "com.github.lambdaurora:spruceui:${project.spruceui_version}" modImplementation "com.github.lambdaurora:spruceui:${project.spruceui_version}"
include "com.github.lambdaurora:spruceui:${project.spruceui_version}" include "com.github.lambdaurora:spruceui:${project.spruceui_version}"
// Compatibility mods // Compatibility mods
modCompile "io.github.joaoh1:okzoomer:4.0.0-alpha.3.1.16.pre5" modImplementation "io.github.joaoh1:okzoomer:4.0.0-alpha.4.1.16.1"
modCompile "me.shedaniel:RoughlyEnoughItems:4.5.5" modImplementation "me.shedaniel:RoughlyEnoughItems:4.5.5"
api project(":core") api project(":core")
shadow project(":core") shadow project(":core")
include "org.jetbrains:annotations:17.0.0" shadow("org.aperlambda:lambdajcommon:1.8.0") {
include("org.aperlambda:lambdajcommon:1.8.0") {
exclude group: 'com.google.code.gson' exclude group: 'com.google.code.gson'
exclude group: 'com.google.guava' exclude group: 'com.google.guava'
} }
include "com.electronwill.night-config:core:3.5.3" shadow "com.electronwill.night-config:core:3.5.3"
include "com.electronwill.night-config:toml:3.5.3" shadow "com.electronwill.night-config:toml:3.5.3"
} }
processResources { processResources {
@@ -78,6 +79,8 @@ processResources {
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
} }
jar { jar {
@@ -92,6 +95,26 @@ jar {
} }
} }
task shadowJar(type: Jar) {
archiveClassifier.set("dev")
from sourceSets.main.output
from {
configurations.shadow.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
task shadowRemapJar(type: RemapJarTask) {
dependsOn shadowJar
input = file("${project.buildDir}/libs/$archivesBaseName-$version-dev.jar")
archiveName = "${archivesBaseName}-${version}.jar"
addNestedDependencies = true
}
// configure the maven publication // configure the maven publication
publishing { publishing {
publications { publications {
@@ -107,5 +130,6 @@ publishing {
} }
} }
shadowJar.dependsOn(":core:jar")
build.dependsOn(":core:build") build.dependsOn(":core:build")
publish.dependsOn(":core:publish") publish.dependsOn(":core:publish")

View File

@@ -9,7 +9,8 @@
package me.lambdaurora.lambdacontrols.client; package me.lambdaurora.lambdacontrols.client;
import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable; import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -20,7 +21,7 @@ import java.util.Optional;
* Represents a controller type. * Represents a controller type.
* *
* @author LambdAurora * @author LambdAurora
* @version 1.0.0 * @version 1.4.0
* @since 1.0.0 * @since 1.0.0
*/ */
public enum ControllerType implements Nameable public enum ControllerType implements Nameable
@@ -32,11 +33,13 @@ public enum ControllerType implements Nameable
STEAM(4), STEAM(4),
OUYA(5); OUYA(5);
private final int id; private final int id;
private final Text text;
ControllerType(int id) ControllerType(int id)
{ {
this.id = id; this.id = id;
this.text = new TranslatableText(this.getTranslationKey());
} }
/** /**
@@ -54,7 +57,7 @@ public enum ControllerType implements Nameable
* *
* @return The next available controller type. * @return The next available controller type.
*/ */
public ControllerType next() public @NotNull ControllerType next()
{ {
ControllerType[] v = values(); ControllerType[] v = values();
if (v.length == this.ordinal() + 1) if (v.length == this.ordinal() + 1)
@@ -63,13 +66,23 @@ public enum ControllerType implements Nameable
} }
/** /**
* Gets the translated name of this controller type. * Returns the translation key of this controller type.
* *
* @return The translated name of this controller type. * @return The translation key.
*/ */
public String getTranslatedName() public @NotNull String getTranslationKey()
{ {
return I18n.translate("lambdacontrols.controller_type." + this.getName()); return "lambdacontrols.controller_type." + this.getName();
}
/**
* Gets the translated text of this controller type.
*
* @return The translated text of this controller type.
*/
public @NotNull Text getTranslatedText()
{
return this.text;
} }
@Override @Override
@@ -84,7 +97,7 @@ public enum ControllerType implements Nameable
* @param id The identifier of the controller type. * @param id The identifier of the controller type.
* @return The controller type if found, else empty. * @return The controller type if found, else empty.
*/ */
public static Optional<ControllerType> byId(@NotNull String id) public static @NotNull Optional<ControllerType> byId(@NotNull String id)
{ {
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
} }

View File

@@ -10,6 +10,8 @@
package me.lambdaurora.lambdacontrols.client; package me.lambdaurora.lambdacontrols.client;
import net.minecraft.client.resource.language.I18n; import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable; import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -20,7 +22,7 @@ import java.util.Optional;
* Represents the hud side which is the side where the movements buttons are. * Represents the hud side which is the side where the movements buttons are.
* *
* @author LambdAurora * @author LambdAurora
* @version 1.0.0 * @version 1.4.0
* @since 1.0.0 * @since 1.0.0
*/ */
public enum HudSide implements Nameable public enum HudSide implements Nameable
@@ -28,12 +30,19 @@ public enum HudSide implements Nameable
LEFT, LEFT,
RIGHT; RIGHT;
private final Text text;
HudSide()
{
this.text = new TranslatableText(this.getTranslationKey());
}
/** /**
* Returns the next side available. * Returns the next side available.
* *
* @return The next available side. * @return The next available side.
*/ */
public HudSide next() public @NotNull HudSide next()
{ {
HudSide[] v = values(); HudSide[] v = values();
if (v.length == this.ordinal() + 1) if (v.length == this.ordinal() + 1)
@@ -42,13 +51,23 @@ public enum HudSide implements Nameable
} }
/** /**
* Gets the translated name of this hud side. * Returns the translation key of this hud side.
* *
* @return The translated name of this hud side. * @return The translation key of this hude side.
*/ */
public String getTranslatedName() public @NotNull String getTranslationKey()
{ {
return I18n.translate("lambdacontrols.hud_side." + this.getName()); return "lambdacontrols.hud_side." + this.getName();
}
/**
* Gets the translated text of this hud side.
*
* @return The translated text of this hud side.
*/
public @NotNull Text getTranslatedText()
{
return this.text;
} }
@Override @Override
@@ -63,7 +82,7 @@ public enum HudSide implements Nameable
* @param id The identifier of the hud side. * @param id The identifier of the hud side.
* @return The hud side if found, else empty. * @return The hud side if found, else empty.
*/ */
public static Optional<HudSide> byId(@NotNull String id) public static @NotNull Optional<HudSide> byId(@NotNull String id)
{ {
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
} }

View File

@@ -9,7 +9,8 @@
package me.lambdaurora.lambdacontrols.client; package me.lambdaurora.lambdacontrols.client;
import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable; import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -19,7 +20,7 @@ import java.util.Optional;
/** /**
* Represents the virtual mouse skins. * Represents the virtual mouse skins.
* *
* @version 1.2.0 * @version 1.4.0
* @since 1.2.0 * @since 1.2.0
*/ */
public enum VirtualMouseSkin implements Nameable public enum VirtualMouseSkin implements Nameable
@@ -29,11 +30,13 @@ public enum VirtualMouseSkin implements Nameable
SECOND_LIGHT("second_light"), SECOND_LIGHT("second_light"),
SECOND_DARK("second_dark"); SECOND_DARK("second_dark");
private String name; private final String name;
private final Text text;
VirtualMouseSkin(String name) VirtualMouseSkin(String name)
{ {
this.name = name; this.name = name;
this.text = new TranslatableText(this.getTranslationKey());
} }
/** /**
@@ -41,7 +44,7 @@ public enum VirtualMouseSkin implements Nameable
* *
* @return The next available virtual mouse skin. * @return The next available virtual mouse skin.
*/ */
public VirtualMouseSkin next() public @NotNull VirtualMouseSkin next()
{ {
VirtualMouseSkin[] v = values(); VirtualMouseSkin[] v = values();
if (v.length == this.ordinal() + 1) if (v.length == this.ordinal() + 1)
@@ -50,13 +53,23 @@ public enum VirtualMouseSkin implements Nameable
} }
/** /**
* Gets the translated name of this controller type. * Returns the translation key of this virtual mouse skin.
* *
* @return The translated name of this controller type. * @return The virtual mouse skin's translation key.
*/ */
public String getTranslatedName() public @NotNull String getTranslationKey()
{ {
return I18n.translate("lambdacontrols.virtual_mouse.skin." + this.getName()); return "lambdacontrols.virtual_mouse.skin." + this.getName();
}
/**
* Gets the translated text of this virtual mouse skin.
*
* @return The translated text of this virtual mouse skin.
*/
public @NotNull Text getTranslatedText()
{
return this.text;
} }
@Override @Override
@@ -66,12 +79,12 @@ public enum VirtualMouseSkin implements Nameable
} }
/** /**
* Gets the controller type from its identifier. * Gets the virtual mouse skin from its identifier.
* *
* @param id The identifier of the controller type. * @param id The identifier of the virtual mouse skin.
* @return The controller type if found, else empty. * @return The virtual mouse skin if found, else empty.
*/ */
public static Optional<VirtualMouseSkin> byId(@NotNull String id) public static @NotNull Optional<VirtualMouseSkin> byId(@NotNull String id)
{ {
return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst(); return Arrays.stream(values()).filter(mode -> mode.getName().equalsIgnoreCase(id)).findFirst();
} }

View File

@@ -41,7 +41,7 @@ public class LambdaControlsCompat
*/ */
public static void init(@NotNull LambdaControlsClient mod) public static void init(@NotNull LambdaControlsClient mod)
{ {
if (FabricLoader.getInstance().isModLoaded("okzoomer") && LambdaReflection.doesClassExist(OkZoomerCompat.OKZOOMER_CLASS_PATH)) { if (FabricLoader.getInstance().isModLoaded("okzoomer")) {
mod.log("Adding okzoomer compatibility..."); mod.log("Adding okzoomer compatibility...");
HANDLERS.add(new OkZoomerCompat()); HANDLERS.add(new OkZoomerCompat());
} }

View File

@@ -10,8 +10,10 @@
package me.lambdaurora.lambdacontrols.client.compat; package me.lambdaurora.lambdacontrols.client.compat;
import io.github.joaoh1.okzoomer.client.OkZoomerClientMod; import io.github.joaoh1.okzoomer.client.OkZoomerClientMod;
import io.github.joaoh1.okzoomer.main.OkZoomerMod;
import me.lambdaurora.lambdacontrols.client.LambdaControlsClient; import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
import org.aperlambda.lambdacommon.Identifier;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
@@ -37,6 +39,25 @@ public class OkZoomerCompat implements CompatHandler
.linkKeybind(OkZoomerClientMod.zoomKeyBinding) .linkKeybind(OkZoomerClientMod.zoomKeyBinding)
.register(); .register();
// @TODO Zoom in and out new ButtonBinding.Builder("zoom.in")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER, true))
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(OkZoomerClientMod.increaseZoomKeyBinding)
.register();
new ButtonBinding.Builder("zoom.out")
.buttons(GLFW.GLFW_GAMEPAD_BUTTON_DPAD_UP, ButtonBinding.axisAsButton(GLFW.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER, true))
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(OkZoomerClientMod.decreaseZoomKeyBinding)
.register();
new ButtonBinding.Builder("zoom.reset")
.onlyInGame()
.cooldown(true)
.category(ButtonBinding.MISC_CATEGORY)
.linkKeybind(OkZoomerClientMod.resetZoomKeyBinding)
.register();
} }
} }

View File

@@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
* @version 1.3.0 * @version 1.3.0
* @since 1.2.0 * @since 1.2.0
*/ */
@Mixin(RecipeViewingScreen.class) @Mixin(value = RecipeViewingScreen.class, remap = false)
public interface RecipeViewingScreenAccessor public interface RecipeViewingScreenAccessor
{ {
@Accessor("categoryBack") @Accessor("categoryBack")

View File

@@ -24,7 +24,7 @@ import java.util.List;
* @version 1.2.0 * @version 1.2.0
* @since 1.2.0 * @since 1.2.0
*/ */
@Mixin(VillagerRecipeViewingScreen.class) @Mixin(value = VillagerRecipeViewingScreen.class, remap = false)
public interface VillagerRecipeViewingScreenAccessor public interface VillagerRecipeViewingScreenAccessor
{ {
@Accessor("categories") @Accessor("categories")

View File

@@ -13,6 +13,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
import me.lambdaurora.lambdacontrols.client.controller.InputManager; import me.lambdaurora.lambdacontrols.client.controller.InputManager;
import me.lambdaurora.spruceui.SpruceButtonWidget; import me.lambdaurora.spruceui.SpruceButtonWidget;
import me.lambdaurora.spruceui.SpruceTexts;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.options.ControlsOptionsScreen; import net.minecraft.client.gui.screen.options.ControlsOptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
@@ -61,7 +62,7 @@ public class ControllerControlsScreen extends Screen
btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options)))); btn -> this.client.openScreen(new ControlsOptionsScreen(this, this.client.options))));
if (!this.hideSettings) if (!this.hideSettings)
this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20, this.addButton(new SpruceButtonWidget(this.width / 2 - 155 + 160, 18, 150, 20,
new TranslatableText("menu.options"), SpruceTexts.MENU_OPTIONS,
btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true)))); btn -> this.client.openScreen(new LambdaControlsSettingsScreen(this, true))));
this.bindingsListWidget = new ControlsListWidget(this, this.client); this.bindingsListWidget = new ControlsListWidget(this, this.client);
this.children.add(this.bindingsListWidget); this.children.add(this.bindingsListWidget);
@@ -69,7 +70,7 @@ public class ControllerControlsScreen extends Screen
new TranslatableText("controls.resetAll"), new TranslatableText("controls.resetAll"),
btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton())))); btn -> InputManager.streamBindings().forEach(binding -> this.mod.config.setButtonBinding(binding, binding.getDefaultButton()))));
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20, this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, 20,
new TranslatableText("gui.done"), SpruceTexts.GUI_DONE,
btn -> this.client.openScreen(this.parent))); btn -> this.client.openScreen(this.parent)));
} }

View File

@@ -12,6 +12,7 @@ package me.lambdaurora.lambdacontrols.client.gui;
import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding; import me.lambdaurora.lambdacontrols.client.controller.ButtonBinding;
import me.lambdaurora.lambdacontrols.client.controller.ButtonCategory; import me.lambdaurora.lambdacontrols.client.controller.ButtonCategory;
import me.lambdaurora.lambdacontrols.client.controller.InputManager; import me.lambdaurora.lambdacontrols.client.controller.InputManager;
import me.lambdaurora.spruceui.SpruceTexts;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
@@ -105,7 +106,7 @@ public class ControlsListWidget extends ElementListWidget<ControlsListWidget.Ent
return new TranslatableText("narrator.controls.reset", bindingName); return new TranslatableText("narrator.controls.reset", bindingName);
} }
}; };
this.unboundButton = new ButtonWidget(0, 0, 50, 20, new TranslatableText("lambdacontrols.menu.unbound"), this.unboundButton = new ButtonWidget(0, 0, 50, 20, SpruceTexts.OPTIONS_GENERIC_UNBOUND,
btn -> { btn -> {
gui.mod.config.setButtonBinding(binding, UNBOUND); gui.mod.config.setButtonBinding(binding, UNBOUND);
gui.focusedBinding = null; gui.focusedBinding = null;

View File

@@ -15,6 +15,7 @@ import me.lambdaurora.lambdacontrols.client.LambdaControlsClient;
import me.lambdaurora.lambdacontrols.client.controller.Controller; import me.lambdaurora.lambdacontrols.client.controller.Controller;
import me.lambdaurora.spruceui.SpruceButtonWidget; import me.lambdaurora.spruceui.SpruceButtonWidget;
import me.lambdaurora.spruceui.SpruceLabelWidget; import me.lambdaurora.spruceui.SpruceLabelWidget;
import me.lambdaurora.spruceui.SpruceTexts;
import me.lambdaurora.spruceui.Tooltip; import me.lambdaurora.spruceui.Tooltip;
import me.lambdaurora.spruceui.option.*; import me.lambdaurora.spruceui.option.*;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry; import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
@@ -87,14 +88,14 @@ public class LambdaControlsSettingsScreen extends Screen
synchronized (this.mod.config) { synchronized (this.mod.config) {
this.mod.config.setRotationSpeed(newValue); this.mod.config.setRotationSpeed(newValue);
} }
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())), }, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
new TranslatableText("lambdacontrols.tooltip.rotation_speed")); new TranslatableText("lambdacontrols.tooltip.rotation_speed"));
this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed, this.mouseSpeedOption = new SpruceDoubleOption("lambdacontrols.menu.mouse_speed", 0.0, 150.0, 0.5F, this.mod.config::getMouseSpeed,
newValue -> { newValue -> {
synchronized (this.mod.config) { synchronized (this.mod.config) {
this.mod.config.setMouseSpeed(newValue); this.mod.config.setMouseSpeed(newValue);
} }
}, option -> option.getDisplayPrefix().append(String.valueOf(option.get())), }, option -> option.getDisplayText(new LiteralText(String.valueOf(option.get()))),
new TranslatableText("lambdacontrols.tooltip.mouse_speed")); new TranslatableText("lambdacontrols.tooltip.mouse_speed"));
this.resetOption = new SpruceResetOption(btn -> { this.resetOption = new SpruceResetOption(btn -> {
this.mod.config.reset(); this.mod.config.reset();
@@ -123,11 +124,11 @@ public class LambdaControlsSettingsScreen extends Screen
}, option -> { }, option -> {
String controllerName = this.mod.config.getController().getName(); String controllerName = this.mod.config.getController().getName();
if (!this.mod.config.getController().isConnected()) if (!this.mod.config.getController().isConnected())
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED)); return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
else if (!this.mod.config.getController().isGamepad()) else if (!this.mod.config.getController().isGamepad())
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD)); return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
else else
return option.getDisplayPrefix().append(controllerName); return option.getDisplayText(new LiteralText(controllerName));
}, null); }, null);
this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2", this.secondControllerOption = new SpruceCyclingOption("lambdacontrols.menu.controller2",
amount -> { amount -> {
@@ -139,16 +140,16 @@ public class LambdaControlsSettingsScreen extends Screen
}, option -> this.mod.config.getSecondController().map(controller -> { }, option -> this.mod.config.getSecondController().map(controller -> {
String controllerName = controller.getName(); String controllerName = controller.getName();
if (!controller.isConnected()) if (!controller.isConnected())
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.RED)); return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.RED));
else if (!controller.isGamepad()) else if (!controller.isGamepad())
return option.getDisplayPrefix().append(new LiteralText(controllerName).formatted(Formatting.GOLD)); return option.getDisplayText(new LiteralText(controllerName).formatted(Formatting.GOLD));
else else
return option.getDisplayPrefix().append(controllerName); return option.getDisplayText(new LiteralText(controllerName));
}).orElse(option.getDisplayPrefix().append(new TranslatableText("options.off").formatted(Formatting.RED))), }).orElse(option.getDisplayText(SpruceTexts.OPTIONS_OFF.shallowCopy().formatted(Formatting.RED))),
new TranslatableText("lambdacontrols.tooltip.controller2")); new TranslatableText("lambdacontrols.tooltip.controller2"));
this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type", this.controllerTypeOption = new SpruceCyclingOption("lambdacontrols.menu.controller_type",
amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()), amount -> this.mod.config.setControllerType(this.mod.config.getControllerType().next()),
option -> option.getDisplayPrefix().append(this.mod.config.getControllerType().getTranslatedName()), option -> option.getDisplayText(this.mod.config.getControllerType().getTranslatedText()),
new TranslatableText("lambdacontrols.tooltip.controller_type")); new TranslatableText("lambdacontrols.tooltip.controller_type"));
this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone, this.deadZoneOption = new SpruceDoubleOption("lambdacontrols.menu.dead_zone", 0.05, 1.0, 0.05F, this.mod.config::getDeadZone,
newValue -> { newValue -> {
@@ -157,7 +158,7 @@ public class LambdaControlsSettingsScreen extends Screen
} }
}, option -> { }, option -> {
String value = String.valueOf(option.get()); String value = String.valueOf(option.get());
return option.getDisplayPrefix().append(value.substring(0, Math.min(value.length(), 5))); return option.getDisplayText(new LiteralText(value.substring(0, Math.min(value.length(), 5))));
}, new TranslatableText("lambdacontrols.tooltip.dead_zone")); }, new TranslatableText("lambdacontrols.tooltip.dead_zone"));
this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis, this.invertsRightXAxis = new SpruceBooleanOption("lambdacontrols.menu.invert_right_x_axis", this.mod.config::doesInvertRightXAxis,
newValue -> { newValue -> {
@@ -177,14 +178,14 @@ public class LambdaControlsSettingsScreen extends Screen
this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true); this.mod.config::setVirtualMouse, new TranslatableText("lambdacontrols.tooltip.virtual_mouse"), true);
this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin", this.virtualMouseSkinOption = new SpruceCyclingOption("lambdacontrols.menu.virtual_mouse.skin",
amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()), amount -> this.mod.config.setVirtualMouseSkin(this.mod.config.getVirtualMouseSkin().next()),
option -> option.getDisplayPrefix().append(this.mod.config.getVirtualMouseSkin().getTranslatedName()), option -> option.getDisplayText(this.mod.config.getVirtualMouseSkin().getTranslatedText()),
null); null);
// HUD options // HUD options
this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled, this.hudEnableOption = new SpruceBooleanOption("lambdacontrols.menu.hud_enable", this.mod.config::isHudEnabled,
this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true); this.mod::setHudEnabled, new TranslatableText("lambdacontrols.tooltip.hud_enable"), true);
this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side", this.hudSideOption = new SpruceCyclingOption("lambdacontrols.menu.hud_side",
amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()), amount -> this.mod.config.setHudSide(this.mod.config.getHudSide().next()),
option -> option.getDisplayPrefix().append(this.mod.config.getHudSide().getTranslatedName()), option -> option.getDisplayText(this.mod.config.getHudSide().getTranslatedText()),
new TranslatableText("lambdacontrols.tooltip.hud_side")); new TranslatableText("lambdacontrols.tooltip.hud_side"));
} }
@@ -266,7 +267,7 @@ public class LambdaControlsSettingsScreen extends Screen
this.children.add(this.gamepadToolUrlLabel); this.children.add(this.gamepadToolUrlLabel);
this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150)); this.addButton(this.resetOption.createButton(this.client.options, this.width / 2 - 155, this.height - 29, 150));
this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, new TranslatableText("gui.done"), this.addButton(new ButtonWidget(this.width / 2 - 155 + 160, this.height - 29, 150, buttonHeight, SpruceTexts.GUI_DONE,
(buttonWidget) -> this.client.openScreen(this.parent))); (buttonWidget) -> this.client.openScreen(this.parent)));
} }

View File

@@ -9,7 +9,8 @@
package me.lambdaurora.lambdacontrols.client.ring; package me.lambdaurora.lambdacontrols.client.ring;
import net.minecraft.client.resource.language.I18n; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import org.aperlambda.lambdacommon.utils.Nameable; import org.aperlambda.lambdacommon.utils.Nameable;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -26,11 +27,13 @@ public enum RingButtonMode implements Nameable
HOLD("hold"), HOLD("hold"),
TOGGLE("toggle"); TOGGLE("toggle");
private String name; private final String name;
private final Text text;
RingButtonMode(@NotNull String name) RingButtonMode(@NotNull String name)
{ {
this.name = name; this.name = name;
this.text = new TranslatableText(this.getTranslationKey());
} }
/** /**
@@ -38,7 +41,7 @@ public enum RingButtonMode implements Nameable
* *
* @return The next ring button mode. * @return The next ring button mode.
*/ */
public RingButtonMode next() public @NotNull RingButtonMode next()
{ {
RingButtonMode[] v = values(); RingButtonMode[] v = values();
if (v.length == this.ordinal() + 1) if (v.length == this.ordinal() + 1)
@@ -46,14 +49,24 @@ public enum RingButtonMode implements Nameable
return v[this.ordinal() + 1]; return v[this.ordinal() + 1];
} }
/**
* Returns the translation key of this ring button mode.
*
* @return The translation key of this ring button mode.
*/
public @NotNull String getTranslationKey()
{
return "lambdacontrols.ring.button_mode." + this.getName();
}
/** /**
* Gets the translated name of this ring button mode. * Gets the translated name of this ring button mode.
* *
* @return The translated name of this ring button mode. * @return The translated name of this ring button mode.
*/ */
public String getTranslatedName() public @NotNull Text getTranslatedText()
{ {
return I18n.translate("lambdacontrols.ring.button_mode." + this.getName()); return this.text;
} }
@Override @Override

View File

@@ -31,6 +31,9 @@
"lambdacontrols.action.toggle_smooth_camera": "Toggle Cinematic Camera", "lambdacontrols.action.toggle_smooth_camera": "Toggle Cinematic Camera",
"lambdacontrols.action.use": "Use", "lambdacontrols.action.use": "Use",
"lambdacontrols.action.zoom": "Zoom", "lambdacontrols.action.zoom": "Zoom",
"lambdacontrols.action.zoom.in": "Increase Zoom",
"lambdacontrols.action.zoom.out": "Decrease Zoom",
"lambdacontrols.action.zoom.reset": "Reset Zoom",
"lambdacontrols.button.a": "A", "lambdacontrols.button.a": "A",
"lambdacontrols.button.b": "B", "lambdacontrols.button.b": "B",
"lambdacontrols.button.x": "X", "lambdacontrols.button.x": "X",
@@ -98,7 +101,6 @@
"lambdacontrols.menu.title.gameplay": "Gameplay Options", "lambdacontrols.menu.title.gameplay": "Gameplay Options",
"lambdacontrols.menu.title.general": "General Options", "lambdacontrols.menu.title.general": "General Options",
"lambdacontrols.menu.title.hud": "HUD Options", "lambdacontrols.menu.title.hud": "HUD Options",
"lambdacontrols.menu.unbound": "Unbound",
"lambdacontrols.menu.unfocused_input": "Unfocused Input", "lambdacontrols.menu.unfocused_input": "Unfocused Input",
"lambdacontrols.menu.virtual_mouse": "Virtual Mouse", "lambdacontrols.menu.virtual_mouse": "Virtual Mouse",
"lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin", "lambdacontrols.menu.virtual_mouse.skin": "Virtual Mouse Skin",

View File

@@ -97,7 +97,6 @@
"lambdacontrols.menu.title.gameplay": "Options de Gameplay", "lambdacontrols.menu.title.gameplay": "Options de Gameplay",
"lambdacontrols.menu.title.general": "Options générales", "lambdacontrols.menu.title.general": "Options générales",
"lambdacontrols.menu.title.hud": "Options du HUD", "lambdacontrols.menu.title.hud": "Options du HUD",
"lambdacontrols.menu.unbound": "Délier",
"lambdacontrols.menu.unfocused_input": "Entrée en fond", "lambdacontrols.menu.unfocused_input": "Entrée en fond",
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle", "lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle", "lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",

View File

@@ -97,7 +97,6 @@
"lambdacontrols.menu.title.gameplay": "Options de Gameplay", "lambdacontrols.menu.title.gameplay": "Options de Gameplay",
"lambdacontrols.menu.title.general": "Options générales", "lambdacontrols.menu.title.general": "Options générales",
"lambdacontrols.menu.title.hud": "Options du HUD", "lambdacontrols.menu.title.hud": "Options du HUD",
"lambdacontrols.menu.unbound": "Délier",
"lambdacontrols.menu.unfocused_input": "Entrée en fond", "lambdacontrols.menu.unfocused_input": "Entrée en fond",
"lambdacontrols.menu.virtual_mouse": "Souris virtuelle", "lambdacontrols.menu.virtual_mouse": "Souris virtuelle",
"lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle", "lambdacontrols.menu.virtual_mouse.skin": "Apparence souris virtuelle",

View File

@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/use # check these on https://fabricmc.net/use
minecraft_version=1.16.1 minecraft_version=1.16.1
yarn_mappings=1.16.1+build.18:v2 yarn_mappings=1.16.1+build.21:v2
loader_version=0.8.8+build.202 loader_version=0.9.0+build.204
# Mod Properties # Mod Properties
mod_version = 1.4.0 mod_version = 1.4.0
@@ -14,6 +14,6 @@ org.gradle.jvmargs=-Xmx1G
# Dependencies # Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.14.0+build.371-1.16 fabric_version=0.15.0+build.379-1.16.1
spruceui_version=1.5.2 spruceui_version=1.5.9
modmenu_version=1.12.2+build.17 modmenu_version=1.12.2+build.17

Binary file not shown.

View File

@@ -1,6 +1,5 @@
#Mon Oct 28 18:23:18 CET 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip

35
gradlew vendored
View File

@@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -125,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
@@ -154,19 +156,19 @@ if $cygwin ; then
else else
eval `echo args$i`="\"$arg\"" eval `echo args$i`="\"$arg\""
fi fi
i=$((i+1)) i=`expr $i + 1`
done done
case $i in case $i in
(0) set -- ;; 0) set -- ;;
(1) set -- "$args0" ;; 1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;; 2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;; 3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
@@ -175,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " " echo " "
} }
APP_ARGS=$(save "$@") APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

4
gradlew.bat vendored
View File

@@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%