Skip to content

Commit

Permalink
Merge pull request #187 from niente1899/Add-KeyConfig-DeleteKey
Browse files Browse the repository at this point in the history
Add KeyConfig DeleteKey
  • Loading branch information
exch-bms2 committed Feb 24, 2018
2 parents 6d13662 + 8b28259 commit e3b4785
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/bms/player/beatoraja/config/KeyConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public class KeyConfiguration extends MainState {
private ControllerConfig[] controllerConfigs;
private MidiConfig midiconfig;

private boolean deletepressed = false;

public KeyConfiguration(MainController main) {
super(main);

Expand Down Expand Up @@ -162,6 +164,10 @@ public void render() {
setMidiKeyAssign(midikeysa[cursorpos]);
keyinput = false;
}
if (input.isDeletePressed()) {
deletepressed = true;
input.setDeletePressed(false);
}
} else {
if (cursor[0] && cursortime[0] != 0) {
cursortime[0] = 0;
Expand Down Expand Up @@ -247,6 +253,12 @@ public void render() {
main.saveConfig();
main.changeState(MainController.STATE_SELECTMUSIC);
}

if (input.isDeletePressed()) {
if(!deletepressed) resetKeyAssign(keysa[cursorpos], bmkeysa[cursorpos], midikeysa[cursorpos]);
deletepressed = true;
input.setDeletePressed(false);
} else deletepressed = false;
}

sprite.begin();
Expand Down Expand Up @@ -407,6 +419,30 @@ private void resetKeyAssign(int index) {
}
}

private void resetKeyAssign(int KBIndex, int BMIndex, int MidiIndex) {
final int noAssign = -1;
if (KBIndex >= 0) keyboardConfig.getKeyAssign()[KBIndex] = noAssign;
if(BMIndex >= 0) {
for (ControllerConfig cc : controllerConfigs) {
cc.getKeyAssign()[BMIndex] = noAssign;
}
} else if (BMIndex == -1) {
for (int i = 0; i < controllerConfigs.length; i++) {
controllerConfigs[i].setStart(noAssign);
}
} else if (BMIndex == -2) {
for (int i = 0; i < controllerConfigs.length; i++) {
controllerConfigs[i].setSelect(noAssign);
}
}
if(MidiIndex >= 0) midiconfig.setKeyAssign(MidiIndex, null);
else if (MidiIndex == -1) {
midiconfig.setStart(null);
} else if (MidiIndex == -2) {
midiconfig.setSelect(null);
}
}

private void setMidiKeyAssign(int index) {
resetKeyAssign(index);
if (index >= 0) {
Expand Down
9 changes: 9 additions & 0 deletions src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public BMSPlayerInputProcessor(Config config, PlayerConfig player) {

private boolean exitPressed;
private boolean enterPressed;
private boolean deletePressed;

boolean[] cursor = new boolean[4];
long[] cursortime = new long[4];
Expand Down Expand Up @@ -348,6 +349,14 @@ public void setEnterPressed(boolean enterPressed) {
this.enterPressed = enterPressed;
}

public boolean isDeletePressed() {
return deletePressed;
}

public void setDeletePressed(boolean deletePressed) {
this.deletePressed = deletePressed;
}

public boolean[] getFunctionstate() {
return functionstate;
}
Expand Down
9 changes: 8 additions & 1 deletion src/bms/player/beatoraja/input/KeyBoardInputProcesseor.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public class KeyBoardInputProcesseor extends BMSPlayerInputDevice implements Inp
private int exit = Keys.ESCAPE;

private int enter = Keys.ENTER;


private int delete = Keys.FORWARD_DEL;

private final IntArray reserved;
/**
* 最後に押されたキー
Expand Down Expand Up @@ -172,6 +174,11 @@ public void poll(final long presstime) {
keystate[enter] = enterpressed;
this.bmsPlayerInputProcessor.setEnterPressed(enterpressed);
}
final boolean deletepressed = Gdx.input.isKeyPressed(delete);
if (deletepressed != keystate[delete]) {
keystate[delete] = deletepressed;
this.bmsPlayerInputProcessor.setDeletePressed(deletepressed);
}
}

public boolean mouseMoved(int arg0, int arg1) {
Expand Down

0 comments on commit e3b4785

Please sign in to comment.