-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Controlling, in the Pick Key Screen
- Loading branch information
1 parent
775205c
commit 07d60c7
Showing
8 changed files
with
163 additions
and
23 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/dmillerw/menu/gui/controlling/ControllingDisplayMode.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,40 @@ | ||
package dmillerw.menu.gui.controlling; | ||
|
||
import com.blamejared.controlling.mixin.AccessKeyMapping; | ||
import net.minecraft.client.KeyMapping; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.screens.controls.KeyBindsList; | ||
|
||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Copy of Controlling by Jaredlll08's ControllingDisplayMode, but with a different KeyEntry | ||
* Temporary workaround, until an interface for the CategoryEntry and KeyEntry in Controlling can be implemented in 1.20.3 | ||
*/ | ||
@Deprecated | ||
public enum ControllingDisplayMode { | ||
ALL(keyEntry -> true), NONE(keyEntry -> keyEntry.getKey().isUnbound()), CONFLICTING(keyEntry -> { | ||
|
||
for(KeyMapping key : Minecraft.getInstance().options.keyMappings) { | ||
if(!key.getName().equals(keyEntry.getKey().getName()) && !key.isUnbound()) { | ||
if(((AccessKeyMapping) key).controlling$getKey() | ||
.getValue() == ((AccessKeyMapping) keyEntry.getKey()).controlling$getKey().getValue()) { | ||
return true; | ||
} | ||
} | ||
} | ||
System.out.println("Hi"); | ||
return false; | ||
}); | ||
|
||
|
||
private final Predicate<ControllingGuiControlList.KeyEntry> predicate; | ||
|
||
ControllingDisplayMode(Predicate<ControllingGuiControlList.KeyEntry> predicate) { | ||
this.predicate = predicate; | ||
} | ||
|
||
public Predicate<KeyBindsList.Entry> getPredicate() { | ||
return entry -> entry instanceof ControllingGuiControlList.KeyEntry keyEntry && predicate.test(keyEntry); | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
src/main/java/dmillerw/menu/gui/controlling/ControllingISort.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,14 @@ | ||
package dmillerw.menu.gui.controlling; | ||
|
||
import net.minecraft.client.gui.screens.controls.KeyBindsList; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Copy of Controlling by Jaredlll08's ISort, but with a different KeyEntry | ||
* Temporary workaround, until an interface for the CategoryEntry and KeyEntry in Controlling can be implemented in 1.20.3 | ||
*/ | ||
@Deprecated | ||
public interface ControllingISort { | ||
void sort(List<KeyBindsList.Entry> entries); | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/dmillerw/menu/gui/controlling/ControllingSortOrder.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,40 @@ | ||
package dmillerw.menu.gui.controlling; | ||
|
||
import com.blamejared.controlling.ControllingConstants; | ||
import net.minecraft.client.gui.screens.controls.KeyBindsList; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
/** | ||
* Copy of Controlling by Jaredlll08's SortOrder, but with a different KeyEntry | ||
* Temporary workaround, until an interface for the CategoryEntry and KeyEntry in Controlling can be implemented in 1.20.3 | ||
*/ | ||
@Deprecated | ||
public enum ControllingSortOrder { | ||
NONE("options.sortNone", entries -> {}), | ||
AZ("options.sortAZ", entries -> entries.sort(Comparator.comparing(o -> ((ControllingGuiControlList.KeyEntry) o).getKeyDesc().getString()))), | ||
ZA("options.sortZA", entries -> entries.sort(Comparator.comparing(o -> ((ControllingGuiControlList.KeyEntry) o).getKeyDesc().getString()).reversed())); | ||
|
||
private final ControllingISort sorter; | ||
private final Component display; | ||
|
||
ControllingSortOrder(String key, ControllingISort sorter) { | ||
this.sorter = sorter; | ||
this.display = ControllingConstants.COMPONENT_OPTIONS_SORT.copy().append(": ").append(Component.translatable(key)); | ||
} | ||
|
||
public ControllingSortOrder cycle() { | ||
return ControllingSortOrder.values()[(this.ordinal() + 1) % ControllingSortOrder.values().length]; | ||
} | ||
|
||
public void sort(List<KeyBindsList.Entry> list) { | ||
list.removeIf(entry -> !(entry instanceof ControllingGuiControlList.KeyEntry)); | ||
this.sorter.sort(list); | ||
} | ||
|
||
public Component getDisplay() { | ||
return this.display; | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -168,7 +168,10 @@ protected void refreshEntry() { | |
} | ||
} | ||
} | ||
} | ||
|
||
public KeyMapping getKey() { | ||
return this.key; | ||
} | ||
} | ||
} |
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