Merge pull request #9 from CanFight/experimental

Added GridHotkeys and Fixed typecast thing
This commit is contained in:
Retera 2022-04-25 11:18:38 -05:00 committed by GitHub
commit 09a2320ee1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 11 deletions

View File

@ -42,6 +42,7 @@ public class WarsmashConstants {
public static final boolean LOAD_UNITS_FROM_WORLDEDIT_DATA = false;
public static final boolean CRASH_ON_INCOMPATIBLE_132_FEATURES = false;
public static final boolean FIRE_DEATH_EVENTS_ON_REMOVEUNIT = false;
public static final int INPUT_HOTKEY_MODE = 1;
public static final String getGameId() {
return (GAME_VERSION == 0) ? GamingNetwork.GAME_ID_BASE : GamingNetwork.GAME_ID_XPAC;

View File

@ -189,12 +189,7 @@ public class CommandCardIcon extends AbstractRenderableFrame implements Clickabl
}
public boolean checkHotkey(final char c, final int keycode) {
if ((c == this.hotkey) || (Character.toUpperCase(c) == this.hotkey)
|| ((this.hotkey == 0x7E) && (keycode == Input.Keys.ESCAPE))) {
onClick(Input.Buttons.LEFT);
return true;
}
return false;
return (c == this.hotkey) || (Character.toUpperCase(c) == this.hotkey) || ((this.hotkey == 0x7E) && (keycode == Input.Keys.ESCAPE));
}
@Override

View File

@ -370,6 +370,10 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
private final BuildOnBuildingIntersector buildOnBuildingIntersector = new BuildOnBuildingIntersector();
public int[][] commandCardGridHotkeys ={{Input.Keys.Q,Input.Keys.W,Input.Keys.E,Input.Keys.R},
{Input.Keys.A,Input.Keys.S,Input.Keys.D,Input.Keys.F},
{Input.Keys.Z,Input.Keys.X,Input.Keys.C,Input.Keys.V}};
public MeleeUI(final DataSource dataSource, final ExtendViewport uiViewport, final Scene uiScene,
final Scene portraitScene, final CameraPreset[] cameraPresets, final CameraRates cameraRates,
final War3MapViewer war3MapViewer, final RootFrameListener rootFrameListener,
@ -2988,9 +2992,19 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
final char c = keyString.length() == 1 ? keyString.charAt(0) : ' ';
for (int j = 0; j < COMMAND_CARD_HEIGHT; j++) {
for (int i = 0; i < COMMAND_CARD_WIDTH; i++) {
if (this.commandCard[j][i].checkHotkey(c, keycode)) {
this.war3MapViewer.getUiSounds().getSound("InterfaceClick").play(this.uiScene.audioContext, 0, 0,
0);
boolean match = false;
switch (WarsmashConstants.INPUT_HOTKEY_MODE){
case 0:
if (this.commandCard[j][i].checkHotkey(c, keycode)) match = true;
break;
case 1:
if(keycode == this.commandCardGridHotkeys[j][i]) match = true;
break;
}
if(match){
this.commandCard[j][i].onClick(Input.Buttons.LEFT);
this.war3MapViewer.getUiSounds().getSound("InterfaceClick").play(this.uiScene.audioContext, 0, 0,0);
}
}
}

View File

@ -184,8 +184,8 @@ public class DesktopLauncher {
}
};
Extensions.audio = new AudioExtension() {
final FloatBuffer orientation = BufferUtils.createFloatBuffer(6).clear();
final FloatBuffer position = BufferUtils.createFloatBuffer(3).clear();
final FloatBuffer orientation = (FloatBuffer)BufferUtils.createFloatBuffer(6).clear();
final FloatBuffer position = (FloatBuffer)BufferUtils.createFloatBuffer(3).clear();
@Override
public float getDuration(final Sound sound) {