renderCheck) {
260 | this.optionsText = options;
261 | this.displayText = display;
262 | this.renderCheck = renderCheck;
263 | this.defaultV = defaultV;
264 | }
265 |
266 | public String getOptionsText() {
267 | return "paperDoll_show"+optionsText;
268 | }
269 |
270 | public MutableComponent getDisplayText() {
271 | return new TranslatableComponent("gui.paper_doll."+displayText+"");
272 | }
273 |
274 | public boolean showInMenu() {
275 | return this != NONE && this != ALWAYS_ON;
276 | }
277 | }
278 | }
279 |
--------------------------------------------------------------------------------
/src/main/java/com/stereowalker/controllermod/client/VirtualMouseHelper.java:
--------------------------------------------------------------------------------
1 | package com.stereowalker.controllermod.client;
2 |
3 | import java.nio.file.Path;
4 | import java.nio.file.Paths;
5 | import java.util.Arrays;
6 |
7 | import org.lwjgl.glfw.GLFWCursorPosCallbackI;
8 | import org.lwjgl.glfw.GLFWDropCallback;
9 | import org.lwjgl.glfw.GLFWMouseButtonCallbackI;
10 | import org.lwjgl.glfw.GLFWScrollCallbackI;
11 |
12 | import com.mojang.blaze3d.Blaze3D;
13 | import com.mojang.blaze3d.platform.InputConstants;
14 |
15 | import net.minecraft.client.KeyMapping;
16 | import net.minecraft.client.Minecraft;
17 | import net.minecraft.client.MouseHandler;
18 | import net.minecraft.client.gui.components.events.GuiEventListener;
19 | import net.minecraft.client.gui.screens.Screen;
20 | import net.minecraft.util.Mth;
21 | import net.minecraftforge.api.distmarker.Dist;
22 | import net.minecraftforge.api.distmarker.OnlyIn;
23 |
24 | @OnlyIn(Dist.CLIENT)
25 | public class VirtualMouseHelper extends MouseHandler {
26 |
27 | public VirtualMouseHelper(Minecraft minecraftIn) {
28 | super(minecraftIn);
29 | }
30 |
31 | /**
32 | * Will be called when a mouse button is pressed or released.
33 | *
34 | * @see GLFWMouseButtonCallbackI
35 | */
36 | public void mouseButtonCallback(long handle, int button, int action, int mods) {
37 | if (handle == this.minecraft.getWindow().getWindow()) {
38 | boolean flag = action == 1;
39 | if (Minecraft.ON_OSX && button == 0) {
40 | if (flag) {
41 | if ((mods & 2) == 2) {
42 | button = 1;
43 | ++this.fakeRightMouse;
44 | }
45 | } else if (this.fakeRightMouse > 0) {
46 | button = 1;
47 | --this.fakeRightMouse;
48 | }
49 | }
50 |
51 | if (flag) {
52 | if (this.minecraft.options.touchscreen && this.clickDepth++ > 0) {
53 | return;
54 | }
55 |
56 | this.activeButton = button;
57 | this.mousePressedTime = Blaze3D.getTime();
58 | } else if (this.activeButton != -1) {
59 | if (this.minecraft.options.touchscreen && --this.clickDepth > 0) {
60 | return;
61 | }
62 |
63 | this.activeButton = -1;
64 | }
65 |
66 | boolean[] aboolean = new boolean[]{false};
67 | if (this.minecraft.getOverlay() == null) {
68 | if (this.minecraft.screen == null) {
69 | if (!this.mouseGrabbed && flag) {
70 | this.grabMouse();
71 | }
72 | if (net.minecraftforge.client.ForgeHooksClient.onRawMouseClicked(button, action, mods)) return;
73 | } else {
74 | double d0 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getWidth();
75 | double d1 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getHeight();
76 | int p_198023_3_f = button;
77 | if (flag) {
78 | Screen.wrapScreenError(() -> {
79 | aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPre(this.minecraft.screen, d0, d1, p_198023_3_f);
80 | if (!aboolean[0]) aboolean[0] = this.minecraft.screen.mouseClicked(d0, d1, p_198023_3_f);
81 | if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseClickedPost(this.minecraft.screen, d0, d1, p_198023_3_f, aboolean[0]);
82 | }, "mouseClicked event handler", this.minecraft.screen.getClass().getCanonicalName());
83 | } else {
84 | Screen.wrapScreenError(() -> {
85 | aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPre(this.minecraft.screen, d0, d1, p_198023_3_f);
86 | if (!aboolean[0]) aboolean[0] = this.minecraft.screen.mouseReleased(d0, d1, p_198023_3_f);
87 | if (!aboolean[0]) aboolean[0] = net.minecraftforge.client.ForgeHooksClient.onScreenMouseReleasedPost(this.minecraft.screen, d0, d1, p_198023_3_f, aboolean[0]);
88 | }, "mouseReleased event handler", this.minecraft.screen.getClass().getCanonicalName());
89 | }
90 | }
91 | }
92 |
93 | if (!aboolean[0] && (this.minecraft.screen == null || this.minecraft.screen.passEvents) && this.minecraft.getOverlay() == null) {
94 | if (button == 0) {
95 | this.isLeftPressed = flag;
96 | } else if (button == 2) {
97 | this.isMiddlePressed = flag;
98 | } else if (button == 1) {
99 | this.isRightPressed = flag;
100 | }
101 |
102 | KeyMapping.set(InputConstants.Type.MOUSE.getOrCreate(button), flag);
103 | if (flag) {
104 | if (this.minecraft.player.isSpectator() && button == 2) {
105 | this.minecraft.gui.getSpectatorGui().onMouseMiddleClick();
106 | } else {
107 | KeyMapping.click(InputConstants.Type.MOUSE.getOrCreate(button));
108 | }
109 | }
110 | }
111 | net.minecraftforge.client.ForgeHooksClient.fireMouseInput(button, action, mods);
112 | }
113 | }
114 |
115 | /**
116 | * Will be called when a scrolling device is used, such as a mouse wheel or scrolling area of a touchpad.
117 | *
118 | * @see GLFWScrollCallbackI
119 | */
120 | public void scrollCallback(long handle, double xoffset, double yoffset) {
121 | if (handle == Minecraft.getInstance().getWindow().getWindow()) {
122 | double d0 = (this.minecraft.options.discreteMouseScroll ? Math.signum(yoffset) : yoffset) * this.minecraft.options.mouseWheelSensitivity;
123 | if (this.minecraft.getOverlay() == null) {
124 | if (this.minecraft.screen != null) {
125 | double d1 = this.xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getWidth();
126 | double d2 = this.ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getHeight();
127 | if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPre(this, this.minecraft.screen, d0)) return;
128 | if (this.minecraft.screen.mouseScrolled(d1, d2, d0)) return;
129 | net.minecraftforge.client.ForgeHooksClient.onScreenMouseScrollPost(this, this.minecraft.screen, d0);
130 | } else if (this.minecraft.player != null) {
131 | if (this.accumulatedScroll != 0.0D && Math.signum(d0) != Math.signum(this.accumulatedScroll)) {
132 | this.accumulatedScroll = 0.0D;
133 | }
134 |
135 | this.accumulatedScroll += d0;
136 | int f1 = (int)this.accumulatedScroll;
137 | if (f1 == 0.0F) {
138 | return;
139 | }
140 |
141 | this.accumulatedScroll -= (double)f1;
142 | // if (net.minecraftforge.client.ForgeHooksClient.onMouseScrolled(this, d0)) return;
143 | if (this.minecraft.player.isSpectator()) {
144 | if (this.minecraft.gui.getSpectatorGui().isMenuActive()) {
145 | this.minecraft.gui.getSpectatorGui().onMouseScrolled(-f1);
146 | } else {
147 | float f = Mth.clamp(this.minecraft.player.getAbilities().getFlyingSpeed() + f1 * 0.005F, 0.0F, 0.2F);
148 | this.minecraft.player.getAbilities().setFlyingSpeed(f);
149 | }
150 | } else {
151 | this.minecraft.player.getInventory().swapPaint((double)f1);
152 | }
153 | }
154 | }
155 | }
156 |
157 | }
158 |
159 | @Override
160 | public void setup(long handle) {
161 | InputConstants.setupMouseCallbacks(handle, (p_228032_1_, p_228032_3_, p_228032_5_) -> {
162 | this.minecraft.execute(() -> {
163 | this.onMove(p_228032_1_, p_228032_3_, p_228032_5_);
164 | });
165 | }, (p_228028_1_, p_228028_3_, p_228028_4_, p_228028_5_) -> {
166 | this.minecraft.execute(() -> {
167 | this.mouseButtonCallback(p_228028_1_, p_228028_3_, p_228028_4_, p_228028_5_);
168 | });
169 | }, (p_228029_1_, p_228029_3_, p_228029_5_) -> {
170 | this.minecraft.execute(() -> {
171 | this.scrollCallback(p_228029_1_, p_228029_3_, p_228029_5_);
172 | });
173 | }, (p_238227_1_, p_238227_3_, p_238227_4_) -> {
174 | Path[] apath = new Path[p_238227_3_];
175 |
176 | for(int i = 0; i < p_238227_3_; ++i) {
177 | apath[i] = Paths.get(GLFWDropCallback.getName(p_238227_4_, i));
178 | }
179 |
180 | this.minecraft.execute(() -> {
181 | this.onDrop(p_238227_1_, Arrays.asList(apath));
182 | });
183 | });
184 | }
185 |
186 | /**
187 | * Will be called when the cursor is moved.
188 | *
189 | * The callback function receives the cursor position, measured in screen coordinates but relative to the top-left
190 | * corner of the window client area. On platforms that provide it, the full sub-pixel cursor position is passed
191 | * on.
192 | *
193 | * @see GLFWCursorPosCallbackI
194 | */
195 | @Override
196 | public void onMove(long handle, double xpos, double ypos) {
197 | if (handle == Minecraft.getInstance().getWindow().getWindow()) {
198 | if (this.ignoreFirstMove) {
199 | this.xpos = xpos;
200 | this.ypos = ypos;
201 | this.ignoreFirstMove = false;
202 | }
203 |
204 | GuiEventListener iguieventlistener = this.minecraft.screen;
205 | if (iguieventlistener != null && this.minecraft.getOverlay() == null) {
206 | double d0 = xpos * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getWidth();
207 | double d1 = ypos * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getHeight();
208 | Screen.wrapScreenError(() -> {
209 | iguieventlistener.mouseMoved(d0, d1);
210 | }, "mouseMoved event handler", iguieventlistener.getClass().getCanonicalName());
211 | if (this.activeButton != -1 && this.mousePressedTime > 0.0D) {
212 | double d2 = (xpos - this.xpos) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getWidth();
213 | double d3 = (ypos - this.ypos) * (double)this.minecraft.getWindow().getGuiScaledHeight() / (double)this.minecraft.getWindow().getHeight();
214 | Screen.wrapScreenError(() -> {
215 | if (net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPre(this.minecraft.screen, d0, d1, this.activeButton, d2, d3)) return;
216 | if (iguieventlistener.mouseDragged(d0, d1, this.activeButton, d2, d3)) return;
217 | net.minecraftforge.client.ForgeHooksClient.onScreenMouseDragPost(this.minecraft.screen, d0, d1, this.activeButton, d2, d3);
218 | }, "mouseDragged event handler", iguieventlistener.getClass().getCanonicalName());
219 | }
220 | }
221 |
222 | this.minecraft.getProfiler().push("mouse");
223 | if (this.isMouseGrabbed() && this.minecraft.isWindowActive()) {
224 | this.accumulatedDX += xpos - this.xpos;
225 | this.accumulatedDY += ypos - this.ypos;
226 | }
227 |
228 | this.turnPlayer();
229 | this.xpos = xpos;
230 | this.ypos = ypos;
231 | this.minecraft.getProfiler().pop();
232 | }
233 | }
234 |
235 | @Override
236 | public void turnPlayer() {
237 | double d0 = Blaze3D.getTime();
238 | double d1 = d0 - this.lastMouseEventTime;
239 | this.lastMouseEventTime = d0;
240 | if (this.isMouseGrabbed() && this.minecraft.isWindowActive()) {
241 | double d4 = this.minecraft.options.sensitivity * (double)0.6F + (double)0.2F;
242 | double d5 = d4 * d4 * d4 * 8.0D;
243 | double d2;
244 | double d3;
245 | if (this.minecraft.options.smoothCamera) {
246 | double d6 = this.smoothTurnX.getNewDeltaValue(this.accumulatedDX * d5, d1 * d5);
247 | double d7 = this.smoothTurnY.getNewDeltaValue(this.accumulatedDY * d5, d1 * d5);
248 | d2 = d6;
249 | d3 = d7;
250 | } else {
251 | this.smoothTurnX.reset();
252 | this.smoothTurnY.reset();
253 | d2 = this.accumulatedDX * d5;
254 | d3 = this.accumulatedDY * d5;
255 | }
256 |
257 | this.accumulatedDX = 0.0D;
258 | this.accumulatedDY = 0.0D;
259 | int i = 1;
260 | if (this.minecraft.options.invertYMouse) {
261 | i = -1;
262 | }
263 |
264 | this.minecraft.getTutorial().onMouse(d2, d3);
265 | if (this.minecraft.player != null) {
266 | this.minecraft.player.turn(d2, d3 * (double)i);
267 | }
268 |
269 | } else {
270 | this.accumulatedDX = 0.0D;
271 | this.accumulatedDY = 0.0D;
272 | }
273 | }
274 |
275 | /**
276 | * Will set the focus to ingame if the Minecraft window is the active with focus. Also clears any GUI screen
277 | * currently displayed
278 | */
279 | @Override
280 | public void grabMouse() {
281 | if (this.minecraft.isWindowActive()) {
282 | if (!this.mouseGrabbed) {
283 | if (!Minecraft.ON_OSX) {
284 | KeyMapping.setAll();
285 | }
286 |
287 | this.mouseGrabbed = true;
288 | this.xpos = (double)(this.minecraft.getWindow().getWidth() / 2);
289 | this.ypos = (double)(this.minecraft.getWindow().getHeight() / 2);
290 | InputConstants.grabOrReleaseMouse(this.minecraft.getWindow().getWindow(), 212995, this.xpos, this.ypos);
291 | this.minecraft.setScreen((Screen)null);
292 | // this.minecraft.leftClickCounter = 10000;
293 | this.ignoreFirstMove = true;
294 | }
295 | }
296 | }
297 |
298 | /**
299 | * Resets the player keystate, disables the ingame focus, and ungrabs the mouse cursor.
300 | */
301 | public void ungrabMouse() {
302 | if (this.mouseGrabbed) {
303 | this.mouseGrabbed = false;
304 | this.xpos = (double)(this.minecraft.getWindow().getWidth() / 2);
305 | this.ypos = (double)(this.minecraft.getWindow().getHeight() / 2);
306 | InputConstants.grabOrReleaseMouse(this.minecraft.getWindow().getWindow(), 212993, this.xpos, this.ypos);
307 | }
308 | }
309 | }
--------------------------------------------------------------------------------
/src/main/java/com/stereowalker/controllermod/client/gui/widget/list/ControllerBindingList.java:
--------------------------------------------------------------------------------
1 | package com.stereowalker.controllermod.client.gui.widget.list;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 | import java.util.List;
6 |
7 | import org.apache.commons.lang3.ArrayUtils;
8 |
9 | import com.google.common.collect.ImmutableList;
10 | import com.google.common.collect.Lists;
11 | import com.mojang.blaze3d.vertex.PoseStack;
12 | import com.stereowalker.controllermod.ControllerMod;
13 | import com.stereowalker.controllermod.client.controller.ControllerMap;
14 | import com.stereowalker.controllermod.client.controller.ControllerMapping;
15 | import com.stereowalker.controllermod.client.controller.ControllerModel;
16 | import com.stereowalker.controllermod.client.controller.ControllerUtil.InputType;
17 | import com.stereowalker.controllermod.client.gui.screen.ControllerInputOptionsScreen;
18 | import com.stereowalker.unionlib.client.gui.components.OverlayImageButton;
19 |
20 | import net.minecraft.ChatFormatting;
21 | import net.minecraft.client.Minecraft;
22 | import net.minecraft.client.gui.components.Button;
23 | import net.minecraft.client.gui.components.ContainerObjectSelectionList;
24 | import net.minecraft.client.gui.components.events.GuiEventListener;
25 | import net.minecraft.client.gui.narration.NarratableEntry;
26 | import net.minecraft.network.chat.Component;
27 | import net.minecraft.network.chat.MutableComponent;
28 | import net.minecraft.network.chat.TextComponent;
29 | import net.minecraft.network.chat.TranslatableComponent;
30 | import net.minecraftforge.api.distmarker.Dist;
31 | import net.minecraftforge.api.distmarker.OnlyIn;
32 |
33 | @OnlyIn(Dist.CLIENT)
34 | public class ControllerBindingList extends ContainerObjectSelectionList {
35 | private final ControllerInputOptionsScreen controlsScreen;
36 | private int maxListLabelWidth;
37 | private ControllerMod mod;
38 |
39 | public ControllerBindingList(ControllerInputOptionsScreen controls, Minecraft mcIn, ControllerMod modIn) {
40 | super(mcIn, controls.width + 45, controls.height, 43, controls.height - 32, 20);
41 | this.controlsScreen = controls;
42 | this.mod = modIn;
43 | ControllerMapping[] akeybinding = ArrayUtils.clone(modIn.controllerOptions.controllerBindings);
44 | Arrays.sort(akeybinding);
45 | String s = null;
46 |
47 | for(ControllerMapping keybinding : akeybinding) {
48 | String s1 = keybinding.getCategory();
49 | if (!s1.equals(s)) {
50 | s = s1;
51 | this.addEntry(new ControllerBindingList.CategoryEntry(new TranslatableComponent(s1)));
52 | }
53 |
54 | Component itextcomponent = new TranslatableComponent(keybinding.getDescripti());
55 | int i = mcIn.font.width(itextcomponent);
56 | if (i > this.maxListLabelWidth) {
57 | this.maxListLabelWidth = i;
58 | }
59 |
60 | this.addEntry(new ControllerBindingList.KeyEntry(keybinding, itextcomponent));
61 | }
62 |
63 | }
64 |
65 | @Override
66 | protected int getScrollbarPosition() {
67 | return super.getScrollbarPosition() + 15 + 40;
68 | }
69 |
70 | @Override
71 | public int getRowWidth() {
72 | return super.getRowWidth() + 72;
73 | }
74 |
75 | @OnlyIn(Dist.CLIENT)
76 | public class CategoryEntry extends ControllerBindingList.Entry {
77 | private final Component labelText;
78 | private final int labelWidth;
79 |
80 | public CategoryEntry(Component p_i232280_2_) {
81 | this.labelText = p_i232280_2_;
82 | this.labelWidth = ControllerBindingList.this.minecraft.font.width(this.labelText);
83 | }
84 |
85 | @Override
86 | public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
87 | ControllerBindingList.this.minecraft.font.draw(p_230432_1_, this.labelText, (float)(ControllerBindingList.this.minecraft.screen.width / 2 - this.labelWidth / 2), (float)(p_230432_3_ + p_230432_6_ - 9 - 1), 16777215);
88 | }
89 |
90 | @Override
91 | public boolean changeFocus(boolean focus) {
92 | return false;
93 | }
94 |
95 | @Override
96 | public List extends GuiEventListener> children() {
97 | return Collections.emptyList();
98 | }
99 |
100 | @Override
101 | public List extends NarratableEntry> narratables() {
102 | return Collections.emptyList();
103 | }
104 | }
105 |
106 | @OnlyIn(Dist.CLIENT)
107 | public abstract static class Entry extends ContainerObjectSelectionList.Entry {
108 | }
109 |
110 | @OnlyIn(Dist.CLIENT)
111 | public class KeyEntry extends ControllerBindingList.Entry {
112 | /** The controllerBinding specified for this KeyEntry */
113 | private final ControllerMapping controllerBinding;
114 | /** The localized key description for this KeyEntry */
115 | private final Component keyDesc;
116 | private final OverlayImageButton btnChangeKeyBinding;
117 | private final Button btnInputType;
118 | private final Button btnReset;
119 |
120 | private KeyEntry(final ControllerMapping controllerBinding, final Component keyDesc) {
121 | this.controllerBinding = controllerBinding;
122 | this.keyDesc = keyDesc;
123 | ControllerModel model = ControllerMod.getInstance().controllerOptions.controllerModel;
124 | this.btnChangeKeyBinding = new OverlayImageButton(0, 0, 65 /*Forge: add space*/, 20,
125 | //Overlay1
126 | 0, 0, 20, 20, null, 20, 20,
127 | //Overlay2
128 | 0, 0, 20, 20, null, 20, 20,
129 | (p_214386_2_) -> {
130 | ControllerBindingList.this.controlsScreen.keyToSet = controllerBinding;
131 | }, keyDesc) {
132 | @Override
133 | protected MutableComponent createNarrationMessage() {
134 | return controllerBinding.isBoundToButton(model) ? new TranslatableComponent("narrator.controls.unbound", keyDesc) : new TranslatableComponent("narrator.controls.bound", keyDesc, super.createNarrationMessage());
135 | }
136 | };
137 | this.btnReset = new Button(0, 0, 50, 20, new TranslatableComponent("controls.reset"), (p_214387_2_) -> {
138 | controllerBinding.setToDefault(ControllerMod.getInstance().controllerOptions.controllerModel);
139 | ControllerBindingList.this.mod.controllerOptions.setKeyBindingCode(ControllerMod.getInstance().controllerOptions.controllerModel, controllerBinding, controllerBinding.getDefault(ControllerMod.getInstance().controllerOptions.controllerModel));
140 | // ControllerBinding.resetKeyBindingArrayAndHash();
141 | }) {
142 | protected MutableComponent createNarrationMessage() {
143 | return new TranslatableComponent("narrator.controls.reset", keyDesc);
144 | }
145 | };
146 | this.btnInputType = new Button(0, 10, 70, 20, controllerBinding.getInputType(ControllerMod.getInstance().controllerOptions.controllerModel) != null ? controllerBinding.getInputType(ControllerMod.getInstance().controllerOptions.controllerModel).getDisplayName() : new TextComponent(""), (p_214387_2_) -> {
147 | if (controllerBinding.isAxis()) {
148 | ControllerBindingList.this.mod.controllerOptions.setKeyBindingInverted(ControllerMod.getInstance().controllerOptions.controllerModel, controllerBinding, !controllerBinding.isAxisInverted(ControllerMod.getInstance().controllerOptions.controllerModel));
149 | } else {
150 | if (controllerBinding.getInputType(ControllerMod.getInstance().controllerOptions.controllerModel) == InputType.PRESS) ControllerBindingList.this.mod.controllerOptions.setKeyBindingInputType(ControllerMod.getInstance().controllerOptions.controllerModel, controllerBinding, InputType.TOGGLE);
151 | else if (controllerBinding.getInputType(ControllerMod.getInstance().controllerOptions.controllerModel) == InputType.TOGGLE) ControllerBindingList.this.mod.controllerOptions.setKeyBindingInputType(ControllerMod.getInstance().controllerOptions.controllerModel ,controllerBinding, InputType.HOLD);
152 | else ControllerBindingList.this.mod.controllerOptions.setKeyBindingInputType(ControllerMod.getInstance().controllerOptions.controllerModel, controllerBinding, InputType.PRESS);
153 | }
154 | }) {
155 | @Override
156 | protected MutableComponent createNarrationMessage() {
157 | return new TranslatableComponent("narrator.controls.reset", keyDesc);
158 | }
159 | };
160 | }
161 |
162 | @Override
163 | public void render(PoseStack p_230432_1_, int p_230432_2_, int p_230432_3_, int p_230432_4_, int p_230432_5_, int p_230432_6_, int p_230432_7_, int p_230432_8_, boolean p_230432_9_, float p_230432_10_) {
164 | boolean flag = ControllerBindingList.this.controlsScreen.keyToSet == this.controllerBinding;
165 | ControllerModel model = ControllerMod.getInstance().controllerOptions.controllerModel;
166 | ControllerMap.Button[] button = model.getOrCreate(Lists.newArrayList(controllerBinding.getButtonOnController(model)));
167 | ControllerBindingList.this.minecraft.font.draw(p_230432_1_, this.keyDesc, (float)(p_230432_4_ + 65 - ControllerBindingList.this.maxListLabelWidth), (float)(p_230432_3_ + p_230432_6_ / 2 - 9 / 2), 16777215);
168 | this.btnInputType.x = p_230432_4_ + 166;
169 | this.btnInputType.y = p_230432_3_;
170 | if (controllerBinding.isAxis()) {
171 | this.btnInputType.setMessage(controllerBinding.isAxisInverted(model) ? new TranslatableComponent("gui.inverted") : new TranslatableComponent("Not Inverted"));
172 | } else {
173 | this.btnInputType.setMessage(controllerBinding.getInputType(model).getDisplayName());
174 | }
175 | this.btnInputType.render(p_230432_1_, p_230432_7_, p_230432_8_, p_230432_10_);
176 | this.btnReset.x = p_230432_4_ + 190 + 50;
177 | this.btnReset.y = p_230432_3_;
178 | this.btnReset.active = !this.controllerBinding.isDefault(model);
179 | this.btnReset.render(p_230432_1_, p_230432_7_, p_230432_8_, p_230432_10_);
180 | this.btnChangeKeyBinding.x = p_230432_4_ + 98;
181 | this.btnChangeKeyBinding.y = p_230432_3_;
182 | this.btnChangeKeyBinding.setFirstOverlay(button[0].getIcon());
183 | this.btnChangeKeyBinding.adjustFirstOverlay(0, 0);
184 | this.btnChangeKeyBinding.adjustSecondOverlay(0, 0);
185 | if (button.length > 1) {
186 | this.btnChangeKeyBinding.setSecondOverlay(button[1].getIcon());
187 | this.btnChangeKeyBinding.adjustFirstOverlay(-15, 0);
188 | this.btnChangeKeyBinding.adjustSecondOverlay(15, 0);
189 | this.btnChangeKeyBinding.showMessage();
190 | this.btnChangeKeyBinding.setMessage(new TextComponent("+"));
191 | } else {
192 | if (button[0].getIcon() != null)
193 | this.btnChangeKeyBinding.hideMessage();
194 | this.btnChangeKeyBinding.setSecondOverlay(null);
195 | this.btnChangeKeyBinding.setMessage(new TextComponent(ControllerMap.map(controllerBinding.getButtonOnController(model).get(0), model)));
196 | }
197 | boolean flag1 = false;
198 | boolean keyCodeModifierConflict = false;//true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G
199 | if (this.controllerBinding.isBoundToButton(model)) {
200 | for(ControllerMapping keybinding : ControllerMod.getInstance().controllerOptions.controllerBindings) {
201 | if (keybinding == this.controllerBinding || !this.controllerBinding.same(keybinding, model)) continue;
202 | flag1 = true;
203 | break;
204 | // keyCodeModifierConflict &= keybinding.hasKeyCodeModifierConflict(keybinding);
205 | }
206 | }
207 |
208 | if (flag) {
209 | this.btnChangeKeyBinding.setFirstOverlay(null);
210 | this.btnChangeKeyBinding.setSecondOverlay(null);
211 | this.btnChangeKeyBinding.showMessage();
212 | if (button[0].getIcon() != null)
213 | this.btnChangeKeyBinding.setMessage((new TextComponent("> ")).append(" <").withStyle(ChatFormatting.YELLOW));
214 | else
215 | this.btnChangeKeyBinding.setMessage((new TextComponent("> ")).append(this.btnChangeKeyBinding.getMessage().copy().withStyle(ChatFormatting.YELLOW)).append(" <").withStyle(ChatFormatting.YELLOW));
216 | } else if (flag1) {
217 | this.btnChangeKeyBinding.showMessage();
218 | if (button[0].getIcon() != null)
219 | this.btnChangeKeyBinding.setMessage(new TextComponent("CONFLICT").withStyle(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED));
220 | else
221 | this.btnChangeKeyBinding.setMessage(this.btnChangeKeyBinding.getMessage().copy().withStyle(keyCodeModifierConflict ? ChatFormatting.GOLD : ChatFormatting.RED));
222 | }
223 |
224 | this.btnChangeKeyBinding.render(p_230432_1_, p_230432_7_, p_230432_8_, p_230432_10_);
225 | }
226 |
227 | @Override
228 | public List extends GuiEventListener> children() {
229 | return ImmutableList.of(this.btnChangeKeyBinding, this.btnReset, this.btnInputType);
230 | }
231 |
232 | @Override
233 | public List extends NarratableEntry> narratables() {
234 | return ImmutableList.of(this.btnChangeKeyBinding, this.btnReset, this.btnInputType);
235 | }
236 |
237 | @Override
238 | public boolean mouseClicked(double mouseX, double mouseY, int button) {
239 | if (this.btnChangeKeyBinding.mouseClicked(mouseX, mouseY, button)) {
240 | return true;
241 | } else if (this.btnInputType.mouseClicked(mouseX, mouseY, button)) {
242 | return true;
243 | } else {
244 | return this.btnReset.mouseClicked(mouseX, mouseY, button);
245 | }
246 | }
247 |
248 | @Override
249 | public boolean mouseReleased(double mouseX, double mouseY, int button) {
250 | return this.btnChangeKeyBinding.mouseReleased(mouseX, mouseY, button) || this.btnReset.mouseReleased(mouseX, mouseY, button) || this.btnInputType.mouseReleased(mouseX, mouseY, button);
251 | }
252 | }
253 | }
254 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
2 | International Public License
3 |
4 | By exercising the Licensed Rights (defined below), You accept and agree
5 | to be bound by the terms and conditions of this Creative Commons
6 | Attribution-NonCommercial-NoDerivatives 4.0 International Public
7 | License ("Public License"). To the extent this Public License may be
8 | interpreted as a contract, You are granted the Licensed Rights in
9 | consideration of Your acceptance of these terms and conditions, and the
10 | Licensor grants You such rights in consideration of benefits the
11 | Licensor receives from making the Licensed Material available under
12 | these terms and conditions.
13 |
14 |
15 | Section 1 -- Definitions.
16 |
17 | a. Adapted Material means material subject to Copyright and Similar
18 | Rights that is derived from or based upon the Licensed Material
19 | and in which the Licensed Material is translated, altered,
20 | arranged, transformed, or otherwise modified in a manner requiring
21 | permission under the Copyright and Similar Rights held by the
22 | Licensor. For purposes of this Public License, where the Licensed
23 | Material is a musical work, performance, or sound recording,
24 | Adapted Material is always produced where the Licensed Material is
25 | synched in timed relation with a moving image.
26 |
27 | b. Copyright and Similar Rights means copyright and/or similar rights
28 | closely related to copyright including, without limitation,
29 | performance, broadcast, sound recording, and Sui Generis Database
30 | Rights, without regard to how the rights are labeled or
31 | categorized. For purposes of this Public License, the rights
32 | specified in Section 2(b)(1)-(2) are not Copyright and Similar
33 | Rights.
34 |
35 | c. Effective Technological Measures means those measures that, in the
36 | absence of proper authority, may not be circumvented under laws
37 | fulfilling obligations under Article 11 of the WIPO Copyright
38 | Treaty adopted on December 20, 1996, and/or similar international
39 | agreements.
40 |
41 | d. Exceptions and Limitations means fair use, fair dealing, and/or
42 | any other exception or limitation to Copyright and Similar Rights
43 | that applies to Your use of the Licensed Material.
44 |
45 | e. Licensed Material means the artistic or literary work, database,
46 | or other material to which the Licensor applied this Public
47 | License.
48 |
49 | f. Licensed Rights means the rights granted to You subject to the
50 | terms and conditions of this Public License, which are limited to
51 | all Copyright and Similar Rights that apply to Your use of the
52 | Licensed Material and that the Licensor has authority to license.
53 |
54 | g. Licensor means the individual(s) or entity(ies) granting rights
55 | under this Public License.
56 |
57 | h. NonCommercial means not primarily intended for or directed towards
58 | commercial advantage or monetary compensation. For purposes of
59 | this Public License, the exchange of the Licensed Material for
60 | other material subject to Copyright and Similar Rights by digital
61 | file-sharing or similar means is NonCommercial provided there is
62 | no payment of monetary compensation in connection with the
63 | exchange.
64 |
65 | i. Share means to provide material to the public by any means or
66 | process that requires permission under the Licensed Rights, such
67 | as reproduction, public display, public performance, distribution,
68 | dissemination, communication, or importation, and to make material
69 | available to the public including in ways that members of the
70 | public may access the material from a place and at a time
71 | individually chosen by them.
72 |
73 | j. Sui Generis Database Rights means rights other than copyright
74 | resulting from Directive 96/9/EC of the European Parliament and of
75 | the Council of 11 March 1996 on the legal protection of databases,
76 | as amended and/or succeeded, as well as other essentially
77 | equivalent rights anywhere in the world.
78 |
79 | k. You means the individual or entity exercising the Licensed Rights
80 | under this Public License. Your has a corresponding meaning.
81 |
82 |
83 | Section 2 -- Scope.
84 |
85 | a. License grant.
86 |
87 | 1. Subject to the terms and conditions of this Public License,
88 | the Licensor hereby grants You a worldwide, royalty-free,
89 | non-sublicensable, non-exclusive, irrevocable license to
90 | exercise the Licensed Rights in the Licensed Material to:
91 |
92 | a. reproduce and Share the Licensed Material, in whole or
93 | in part, for NonCommercial purposes only; and
94 |
95 | b. produce and reproduce, but not Share, Adapted Material
96 | for NonCommercial purposes only.
97 |
98 | 2. Exceptions and Limitations. For the avoidance of doubt, where
99 | Exceptions and Limitations apply to Your use, this Public
100 | License does not apply, and You do not need to comply with
101 | its terms and conditions.
102 |
103 | 3. Term. The term of this Public License is specified in Section
104 | 6(a).
105 |
106 | 4. Media and formats; technical modifications allowed. The
107 | Licensor authorizes You to exercise the Licensed Rights in
108 | all media and formats whether now known or hereafter created,
109 | and to make technical modifications necessary to do so. The
110 | Licensor waives and/or agrees not to assert any right or
111 | authority to forbid You from making technical modifications
112 | necessary to exercise the Licensed Rights, including
113 | technical modifications necessary to circumvent Effective
114 | Technological Measures. For purposes of this Public License,
115 | simply making modifications authorized by this Section 2(a)
116 | (4) never produces Adapted Material.
117 |
118 | 5. Downstream recipients.
119 |
120 | a. Offer from the Licensor -- Licensed Material. Every
121 | recipient of the Licensed Material automatically
122 | receives an offer from the Licensor to exercise the
123 | Licensed Rights under the terms and conditions of this
124 | Public License.
125 |
126 | b. No downstream restrictions. You may not offer or impose
127 | any additional or different terms or conditions on, or
128 | apply any Effective Technological Measures to, the
129 | Licensed Material if doing so restricts exercise of the
130 | Licensed Rights by any recipient of the Licensed
131 | Material.
132 |
133 | 6. No endorsement. Nothing in this Public License constitutes or
134 | may be construed as permission to assert or imply that You
135 | are, or that Your use of the Licensed Material is, connected
136 | with, or sponsored, endorsed, or granted official status by,
137 | the Licensor or others designated to receive attribution as
138 | provided in Section 3(a)(1)(A)(i).
139 |
140 | b. Other rights.
141 |
142 | 1. Moral rights, such as the right of integrity, are not
143 | licensed under this Public License, nor are publicity,
144 | privacy, and/or other similar personality rights; however, to
145 | the extent possible, the Licensor waives and/or agrees not to
146 | assert any such rights held by the Licensor to the limited
147 | extent necessary to allow You to exercise the Licensed
148 | Rights, but not otherwise.
149 |
150 | 2. Patent and trademark rights are not licensed under this
151 | Public License.
152 |
153 | 3. To the extent possible, the Licensor waives any right to
154 | collect royalties from You for the exercise of the Licensed
155 | Rights, whether directly or through a collecting society
156 | under any voluntary or waivable statutory or compulsory
157 | licensing scheme. In all other cases the Licensor expressly
158 | reserves any right to collect such royalties, including when
159 | the Licensed Material is used other than for NonCommercial
160 | purposes.
161 |
162 |
163 | Section 3 -- License Conditions.
164 |
165 | Your exercise of the Licensed Rights is expressly made subject to the
166 | following conditions.
167 |
168 | a. Attribution.
169 |
170 | 1. If You Share the Licensed Material, You must:
171 |
172 | a. retain the following if it is supplied by the Licensor
173 | with the Licensed Material:
174 |
175 | i. identification of the creator(s) of the Licensed
176 | Material and any others designated to receive
177 | attribution, in any reasonable manner requested by
178 | the Licensor (including by pseudonym if
179 | designated);
180 |
181 | ii. a copyright notice;
182 |
183 | iii. a notice that refers to this Public License;
184 |
185 | iv. a notice that refers to the disclaimer of
186 | warranties;
187 |
188 | v. a URI or hyperlink to the Licensed Material to the
189 | extent reasonably practicable;
190 |
191 | b. indicate if You modified the Licensed Material and
192 | retain an indication of any previous modifications; and
193 |
194 | c. indicate the Licensed Material is licensed under this
195 | Public License, and include the text of, or the URI or
196 | hyperlink to, this Public License.
197 |
198 | For the avoidance of doubt, You do not have permission under
199 | this Public License to Share Adapted Material.
200 |
201 | 2. You may satisfy the conditions in Section 3(a)(1) in any
202 | reasonable manner based on the medium, means, and context in
203 | which You Share the Licensed Material. For example, it may be
204 | reasonable to satisfy the conditions by providing a URI or
205 | hyperlink to a resource that includes the required
206 | information.
207 |
208 | 3. If requested by the Licensor, You must remove any of the
209 | information required by Section 3(a)(1)(A) to the extent
210 | reasonably practicable.
211 |
212 |
213 | Section 4 -- Sui Generis Database Rights.
214 |
215 | Where the Licensed Rights include Sui Generis Database Rights that
216 | apply to Your use of the Licensed Material:
217 |
218 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right
219 | to extract, reuse, reproduce, and Share all or a substantial
220 | portion of the contents of the database for NonCommercial purposes
221 | only and provided You do not Share Adapted Material;
222 |
223 | b. if You include all or a substantial portion of the database
224 | contents in a database in which You have Sui Generis Database
225 | Rights, then the database in which You have Sui Generis Database
226 | Rights (but not its individual contents) is Adapted Material; and
227 |
228 | c. You must comply with the conditions in Section 3(a) if You Share
229 | all or a substantial portion of the contents of the database.
230 |
231 | For the avoidance of doubt, this Section 4 supplements and does not
232 | replace Your obligations under this Public License where the Licensed
233 | Rights include other Copyright and Similar Rights.
234 |
235 |
236 | Section 5 -- Disclaimer of Warranties and Limitation of Liability.
237 |
238 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
239 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
240 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
241 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
242 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
243 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
244 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
245 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
246 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
247 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
248 |
249 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
250 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
251 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
252 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
253 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
254 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
255 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
256 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
257 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
258 |
259 | c. The disclaimer of warranties and limitation of liability provided
260 | above shall be interpreted in a manner that, to the extent
261 | possible, most closely approximates an absolute disclaimer and
262 | waiver of all liability.
263 |
264 |
265 | Section 6 -- Term and Termination.
266 |
267 | a. This Public License applies for the term of the Copyright and
268 | Similar Rights licensed here. However, if You fail to comply with
269 | this Public License, then Your rights under this Public License
270 | terminate automatically.
271 |
272 | b. Where Your right to use the Licensed Material has terminated under
273 | Section 6(a), it reinstates:
274 |
275 | 1. automatically as of the date the violation is cured, provided
276 | it is cured within 30 days of Your discovery of the
277 | violation; or
278 |
279 | 2. upon express reinstatement by the Licensor.
280 |
281 | For the avoidance of doubt, this Section 6(b) does not affect any
282 | right the Licensor may have to seek remedies for Your violations
283 | of this Public License.
284 |
285 | c. For the avoidance of doubt, the Licensor may also offer the
286 | Licensed Material under separate terms or conditions or stop
287 | distributing the Licensed Material at any time; however, doing so
288 | will not terminate this Public License.
289 |
290 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
291 | License.
292 |
293 |
294 | Section 7 -- Other Terms and Conditions.
295 |
296 | a. The Licensor shall not be bound by any additional or different
297 | terms or conditions communicated by You unless expressly agreed.
298 |
299 | b. Any arrangements, understandings, or agreements regarding the
300 | Licensed Material not stated herein are separate from and
301 | independent of the terms and conditions of this Public License.
302 |
303 |
304 | Section 8 -- Interpretation.
305 |
306 | a. For the avoidance of doubt, this Public License does not, and
307 | shall not be interpreted to, reduce, limit, restrict, or impose
308 | conditions on any use of the Licensed Material that could lawfully
309 | be made without permission under this Public License.
310 |
311 | b. To the extent possible, if any provision of this Public License is
312 | deemed unenforceable, it shall be automatically reformed to the
313 | minimum extent necessary to make it enforceable. If the provision
314 | cannot be reformed, it shall be severed from this Public License
315 | without affecting the enforceability of the remaining terms and
316 | conditions.
317 |
318 | c. No term or condition of this Public License will be waived and no
319 | failure to comply consented to unless expressly agreed to by the
320 | Licensor.
321 |
322 | d. Nothing in this Public License constitutes or may be interpreted
323 | as a limitation upon, or waiver of, any privileges and immunities
324 | that apply to the Licensor or You, including from the legal
325 | processes of any jurisdiction or authority.
--------------------------------------------------------------------------------