forked from Clones/Controlify
compatibility for tab nav bars in every screen
This commit is contained in:
@ -66,6 +66,10 @@ dependencies {
|
|||||||
listOf(
|
listOf(
|
||||||
"fabric-resource-loader-v0",
|
"fabric-resource-loader-v0",
|
||||||
"fabric-lifecycle-events-v1",
|
"fabric-lifecycle-events-v1",
|
||||||
|
|
||||||
|
// sodium requirements
|
||||||
|
"fabric-rendering-data-attachment-v1",
|
||||||
|
"fabric-rendering-fluids-v1",
|
||||||
).forEach {
|
).forEach {
|
||||||
modImplementation(fabricApi.module(it, libs.versions.fabric.api.get()))
|
modImplementation(fabricApi.module(it, libs.versions.fabric.api.get()))
|
||||||
}
|
}
|
||||||
@ -88,7 +92,7 @@ dependencies {
|
|||||||
// sodium compat
|
// sodium compat
|
||||||
modImplementation(libs.sodium)
|
modImplementation(libs.sodium)
|
||||||
// iris compat
|
// iris compat
|
||||||
modImplementation(files("libs/iris-5d0efad3.jar"))
|
modImplementation(libs.iris)
|
||||||
modRuntimeOnly("org.anarres:jcpp:1.4.14")
|
modRuntimeOnly("org.anarres:jcpp:1.4.14")
|
||||||
modRuntimeOnly("io.github.douira:glsl-transformer:2.0.0-pre9")
|
modRuntimeOnly("io.github.douira:glsl-transformer:2.0.0-pre9")
|
||||||
|
|
||||||
@ -155,10 +159,10 @@ if (modrinthId.isNotEmpty()) {
|
|||||||
versionNumber.set("${project.version}")
|
versionNumber.set("${project.version}")
|
||||||
versionType.set("release")
|
versionType.set("release")
|
||||||
uploadFile.set(tasks["remapJar"])
|
uploadFile.set(tasks["remapJar"])
|
||||||
gameVersions.set(listOf("1.19.3"))
|
gameVersions.set(listOf("1.19.4"))
|
||||||
loaders.set(listOf("fabric", "quilt"))
|
loaders.set(listOf("fabric", "quilt"))
|
||||||
changelog.set(changelogText)
|
changelog.set(changelogText)
|
||||||
syncBodyFrom.set(file("README.md").readText())
|
syncBodyFrom.set(file(".github/README.md").readText())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +177,7 @@ if (hasProperty("curseforge.token") && curseforgeId.isNotEmpty()) {
|
|||||||
|
|
||||||
id = curseforgeId
|
id = curseforgeId
|
||||||
releaseType = "release"
|
releaseType = "release"
|
||||||
addGameVersion("1.19.3")
|
addGameVersion("1.19.4")
|
||||||
addGameVersion("Fabric")
|
addGameVersion("Fabric")
|
||||||
addGameVersion("Java 17")
|
addGameVersion("Java 17")
|
||||||
|
|
||||||
|
@ -7,16 +7,17 @@ github_release = "2.+"
|
|||||||
machete = "1.+"
|
machete = "1.+"
|
||||||
grgit = "5.0.+"
|
grgit = "5.0.+"
|
||||||
|
|
||||||
minecraft = "1.19.4-rc1"
|
minecraft = "1.19.4"
|
||||||
quilt_mappings = "1"
|
quilt_mappings = "1"
|
||||||
fabric_loader = "0.14.17"
|
fabric_loader = "0.14.17"
|
||||||
fabric_api = "0.75.1+1.19.4"
|
fabric_api = "0.76.0+1.19.4"
|
||||||
mixin_extras = "0.2.0-beta.1"
|
mixin_extras = "0.2.0-beta.1"
|
||||||
yet_another_config_lib = "2.3.0+beta.3+update.1.19.4-SNAPSHOT"
|
yet_another_config_lib = "2.3.0"
|
||||||
mod_menu = "6.1.0-alpha.1"
|
mod_menu = "6.1.0-rc.1"
|
||||||
hid4java = "0.7.0"
|
hid4java = "0.7.0"
|
||||||
quilt_json5 = "1.0.3"
|
quilt_json5 = "1.0.3"
|
||||||
sodium = "0.4.10+build.211"
|
sodium = "mc1.19.4-0.4.10"
|
||||||
|
iris = "1.5.2+1.19.4"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
|
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
|
||||||
@ -28,7 +29,8 @@ yet_another_config_lib = { module = "dev.isxander:yet-another-config-lib", versi
|
|||||||
mod_menu = { module = "com.terraformersmc:modmenu", version.ref = "mod_menu" }
|
mod_menu = { module = "com.terraformersmc:modmenu", version.ref = "mod_menu" }
|
||||||
hid4java = { module = "org.hid4java:hid4java", version.ref = "hid4java" }
|
hid4java = { module = "org.hid4java:hid4java", version.ref = "hid4java" }
|
||||||
quilt_json5 = { module = "org.quiltmc:quilt-json5", version.ref = "quilt_json5" }
|
quilt_json5 = { module = "org.quiltmc:quilt-json5", version.ref = "quilt_json5" }
|
||||||
sodium = { module = "me.jellysquid.mods:sodium-fabric", version.ref = "sodium" }
|
sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" }
|
||||||
|
iris = { module = "maven.modrinth:iris", version.ref = "iris" }
|
||||||
|
|
||||||
test_fabric_loader = { module = "net.fabricmc:fabric-loader-junit", version.ref = "fabric_loader" }
|
test_fabric_loader = { module = "net.fabricmc:fabric-loader-junit", version.ref = "fabric_loader" }
|
||||||
|
|
||||||
|
Binary file not shown.
@ -72,6 +72,10 @@ public class Controlify implements ControlifyApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Controller.CONTROLLERS.isEmpty()) {
|
||||||
|
LOGGER.info("No controllers found.");
|
||||||
|
}
|
||||||
|
|
||||||
if (currentController() == Controller.DUMMY && config().isFirstLaunch()) {
|
if (currentController() == Controller.DUMMY && config().isFirstLaunch()) {
|
||||||
this.setCurrentController(Controller.CONTROLLERS.values().stream().findFirst().orElse(null));
|
this.setCurrentController(Controller.CONTROLLERS.values().stream().findFirst().orElse(null));
|
||||||
}
|
}
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
package dev.isxander.controlify.mixins.feature.screenop.vanilla;
|
|
||||||
|
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessor;
|
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessorProvider;
|
|
||||||
import dev.isxander.controlify.screenop.compat.vanilla.CreateWorldScreenProcessor;
|
|
||||||
import net.minecraft.client.gui.components.tabs.Tab;
|
|
||||||
import net.minecraft.client.gui.components.tabs.TabManager;
|
|
||||||
import net.minecraft.client.gui.components.tabs.TabNavigationBar;
|
|
||||||
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(CreateWorldScreen.class)
|
|
||||||
public class CreateWorldScreenMixin implements ScreenProcessorProvider {
|
|
||||||
@Shadow private @Nullable TabNavigationBar tabNavigationBar;
|
|
||||||
@Shadow @Final private TabManager tabManager;
|
|
||||||
|
|
||||||
@Unique private final CreateWorldScreenProcessor controlify$screenProcessor
|
|
||||||
= new CreateWorldScreenProcessor((CreateWorldScreen) (Object) this, this::changeTab);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ScreenProcessor<?> screenProcessor() {
|
|
||||||
return controlify$screenProcessor;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void changeTab(boolean reverse) {
|
|
||||||
List<Tab> tabs = ((TabNavigationBarAccessor) tabNavigationBar).getTabs();
|
|
||||||
int currentIndex = tabs.indexOf(tabManager.getCurrentTab());
|
|
||||||
|
|
||||||
int newIndex = currentIndex + (reverse ? -1 : 1);
|
|
||||||
if (newIndex < 0) newIndex = tabs.size() - 1;
|
|
||||||
if (newIndex >= tabs.size()) newIndex = 0;
|
|
||||||
|
|
||||||
tabNavigationBar.selectTab(newIndex, true);
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ package dev.isxander.controlify.mixins.feature.screenop.vanilla;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.minecraft.client.gui.components.tabs.Tab;
|
import net.minecraft.client.gui.components.tabs.Tab;
|
||||||
|
import net.minecraft.client.gui.components.tabs.TabManager;
|
||||||
import net.minecraft.client.gui.components.tabs.TabNavigationBar;
|
import net.minecraft.client.gui.components.tabs.TabNavigationBar;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
@ -10,4 +11,7 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||||||
public interface TabNavigationBarAccessor {
|
public interface TabNavigationBarAccessor {
|
||||||
@Accessor
|
@Accessor
|
||||||
ImmutableList<Tab> getTabs();
|
ImmutableList<Tab> getTabs();
|
||||||
|
|
||||||
|
@Accessor
|
||||||
|
TabManager getTabManager();
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,11 @@ import dev.isxander.controlify.InputMode;
|
|||||||
import dev.isxander.controlify.controller.Controller;
|
import dev.isxander.controlify.controller.Controller;
|
||||||
import dev.isxander.controlify.api.event.ControlifyEvents;
|
import dev.isxander.controlify.api.event.ControlifyEvents;
|
||||||
import dev.isxander.controlify.mixins.feature.screenop.vanilla.ScreenAccessor;
|
import dev.isxander.controlify.mixins.feature.screenop.vanilla.ScreenAccessor;
|
||||||
|
import dev.isxander.controlify.mixins.feature.screenop.vanilla.TabNavigationBarAccessor;
|
||||||
import net.minecraft.client.gui.ComponentPath;
|
import net.minecraft.client.gui.ComponentPath;
|
||||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.components.tabs.Tab;
|
||||||
|
import net.minecraft.client.gui.components.tabs.TabNavigationBar;
|
||||||
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
|
import net.minecraft.client.gui.navigation.FocusNavigationEvent;
|
||||||
import net.minecraft.client.gui.navigation.ScreenDirection;
|
import net.minecraft.client.gui.navigation.ScreenDirection;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@ -30,6 +33,8 @@ public class ScreenProcessor<T extends Screen> {
|
|||||||
} else {
|
} else {
|
||||||
handleVMouseNavigation(controller);
|
handleVMouseNavigation(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleTabNavigation(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInputModeChanged(InputMode mode) {
|
public void onInputModeChanged(InputMode mode) {
|
||||||
@ -104,6 +109,29 @@ public class ScreenProcessor<T extends Screen> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void handleTabNavigation(Controller<?, ?> controller) {
|
||||||
|
var nextTab = controller.bindings().GUI_NEXT_TAB.justPressed();
|
||||||
|
var prevTab = controller.bindings().GUI_PREV_TAB.justPressed();
|
||||||
|
|
||||||
|
if (nextTab || prevTab) {
|
||||||
|
screen.children().stream()
|
||||||
|
.filter(child -> child instanceof TabNavigationBar)
|
||||||
|
.map(TabNavigationBar.class::cast)
|
||||||
|
.findAny()
|
||||||
|
.ifPresent(navBar -> {
|
||||||
|
var accessor = (TabNavigationBarAccessor) navBar;
|
||||||
|
List<Tab> tabs = accessor.getTabs();
|
||||||
|
int currentIndex = tabs.indexOf(accessor.getTabManager().getCurrentTab());
|
||||||
|
|
||||||
|
int newIndex = currentIndex + (prevTab ? -1 : 1);
|
||||||
|
if (newIndex < 0) newIndex = tabs.size() - 1;
|
||||||
|
if (newIndex >= tabs.size()) newIndex = 0;
|
||||||
|
|
||||||
|
navBar.selectTab(newIndex, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onWidgetRebuild() {
|
public void onWidgetRebuild() {
|
||||||
setInitialFocus();
|
setInitialFocus();
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
package dev.isxander.controlify.screenop.compat.vanilla;
|
|
||||||
|
|
||||||
import dev.isxander.controlify.controller.Controller;
|
|
||||||
import dev.isxander.controlify.screenop.ScreenProcessor;
|
|
||||||
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
public class CreateWorldScreenProcessor extends ScreenProcessor<CreateWorldScreen> {
|
|
||||||
private final Consumer<Boolean> tabChangeMethod;
|
|
||||||
|
|
||||||
public CreateWorldScreenProcessor(CreateWorldScreen screen, Consumer<Boolean> tabChangeMethod) {
|
|
||||||
super(screen);
|
|
||||||
this.tabChangeMethod = tabChangeMethod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void handleButtons(Controller<?, ?> controller) {
|
|
||||||
if (controller.bindings().GUI_NEXT_TAB.justPressed()) {
|
|
||||||
tabChangeMethod.accept(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (controller.bindings().GUI_PREV_TAB.justPressed()) {
|
|
||||||
tabChangeMethod.accept(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.handleButtons(controller);
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,7 +32,7 @@
|
|||||||
"feature.screenop.vanilla.AbstractSelectionListMixin",
|
"feature.screenop.vanilla.AbstractSelectionListMixin",
|
||||||
"feature.screenop.vanilla.AbstractSliderButtonMixin",
|
"feature.screenop.vanilla.AbstractSliderButtonMixin",
|
||||||
"feature.screenop.vanilla.ContainerObjectSelectionListEntryMixin",
|
"feature.screenop.vanilla.ContainerObjectSelectionListEntryMixin",
|
||||||
"feature.screenop.vanilla.CreateWorldScreenMixin",
|
|
||||||
"feature.screenop.vanilla.CreativeModeInventoryScreenAccessor",
|
"feature.screenop.vanilla.CreativeModeInventoryScreenAccessor",
|
||||||
"feature.screenop.vanilla.CreativeModeInventoryScreenMixin",
|
"feature.screenop.vanilla.CreativeModeInventoryScreenMixin",
|
||||||
"feature.screenop.vanilla.JoinMultiplayerScreenAccessor",
|
"feature.screenop.vanilla.JoinMultiplayerScreenAccessor",
|
||||||
|
Reference in New Issue
Block a user