Skip to content

Commit

Permalink
Set correct input mode depending on charts keymode, refactor music se…
Browse files Browse the repository at this point in the history
…lect input option picking
  • Loading branch information
Chazoshtare committed Jun 25, 2022
1 parent 7af5826 commit dc8d23e
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 85 deletions.
10 changes: 5 additions & 5 deletions src/bms/player/beatoraja/PlayerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public class PlayerConfig {
/**
* 選曲時でのキー入力方式
*/
private int musicselectinput = 0;
private MusicSelectKeyProperty musicSelectInputOption = MusicSelectKeyProperty.BEAT_7K;

private IRConfig[] irconfig;

Expand Down Expand Up @@ -489,12 +489,12 @@ public void setSort(int sort) {
this.sort = sort;
}

public int getMusicselectinput() {
return musicselectinput;
public MusicSelectKeyProperty getMusicSelectInputOption() {
return musicSelectInputOption;
}

public void setMusicselectinput(int musicselectinput) {
this.musicselectinput = musicselectinput;
public void nextMusicSelectInputOption() {
this.musicSelectInputOption = this.musicSelectInputOption.nextValue();
}

public SkinConfig[] getSkin() {
Expand Down
30 changes: 24 additions & 6 deletions src/bms/player/beatoraja/config/KeyConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public class KeyConfiguration extends MainState {
-2 } };
private static final int playerOffset = 100;

private static final String[] SELECTKEY = { "2dx sp", "popn", "2dx dp" };

private int cursorpos = 0;
private int scrollpos = 0;
private boolean keyinput = false;
Expand Down Expand Up @@ -112,6 +110,8 @@ public void create() {
titlefont = generator.generateFont(parameter);
shape = new ShapeRenderer();

config = main.getPlayerResource().getPlayerConfig();
reinitializeInputConfigs();
input = main.getInputProcessor();
keyboard = input.getKeyBoardInputProcesseor();
controllers = input.getBMInputProcessor();
Expand Down Expand Up @@ -171,7 +171,8 @@ public void render() {
cursorpos = (cursorpos + 1) % keys.length;
}
if (input.isControlKeyPressed(ControlKeys.NUM1)) {
config.setMusicselectinput((config.getMusicselectinput() + 1) % 3);
config.nextMusicSelectInputOption();
reinitializeInputConfigs();
}
// change controller device 1
if (input.isControlKeyPressed(ControlKeys.NUM2)) {
Expand All @@ -183,7 +184,7 @@ public void render() {
}
}
pc.getController()[0]
.setName(controllers[(index + 1) % controllers.length].getName());
.setName(controllers[(index + 1) % controllers.length].getName());
pc.setController(pc.getController());
}
}
Expand Down Expand Up @@ -257,7 +258,7 @@ public void render() {
titlefont.draw(sprite, "MIDI", 630 * scaleX, 620 * scaleY);
titlefont.setColor(Color.ORANGE);
titlefont.draw(sprite, "Music Select (press [1] to change) : ", 750 * scaleX, 620 * scaleY);
titlefont.draw(sprite, SELECTKEY[config.getMusicselectinput()], 780 * scaleX, 590 * scaleY);
titlefont.draw(sprite, config.getMusicSelectInputOption().toString(), 780 * scaleX, 590 * scaleY);

titlefont.draw(sprite, "Controller Device 1 (press [2] to change) : ", 750 * scaleX, 500 * scaleY);
titlefont.draw(sprite, pc.getController()[0].getName(), 780 * scaleX, 470 * scaleY);
Expand Down Expand Up @@ -309,9 +310,26 @@ public void render() {
}
}

private void reinitializeInputConfigs() {
BMSPlayerInputProcessor input = main.getInputProcessor();
PlayModeConfig playModeConfig;
switch (config.getMusicSelectInputOption()) {
case POPN_9K:
playModeConfig = config.getMode9();
break;
case BEAT_14K:
playModeConfig = config.getMode14();
break;
case BEAT_7K:
default:
playModeConfig = config.getMode7();
break;
}
input.setAllInputConfigs(playModeConfig);
}

private void setMode(int mode) {
this.mode = mode;
config = main.getPlayerResource().getPlayerConfig();
pc = config.getPlayConfig(MODE_HINT[mode]);
keyboardConfig = pc.getKeyboardConfig();
controllerConfigs = pc.getController();
Expand Down
6 changes: 6 additions & 0 deletions src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ public BMSPlayerInputProcessor(Config config, PlayerConfig player) {

private Type type = Type.KEYBOARD;

public void setAllInputConfigs(PlayModeConfig playModeConfig) {
setKeyboardConfig(playModeConfig.getKeyboardConfig());
setControllerConfig(playModeConfig.getController());
setMidiConfig(playModeConfig.getMidiConfig());
}

public void setKeyboardConfig(KeyboardConfig config) {
kbinput.setConfig(config);
}
Expand Down
11 changes: 6 additions & 5 deletions src/bms/player/beatoraja/play/BMSPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,10 @@ public void create() {
}

final BMSPlayerInputProcessor input = main.getInputProcessor();
if(autoplay.mode == BMSPlayerMode.Mode.PLAY || autoplay.mode == BMSPlayerMode.Mode.PRACTICE) {
input.setPlayConfig(config.getPlayConfig(model.getMode()));
if (autoplay.mode == BMSPlayerMode.Mode.PLAY || autoplay.mode == BMSPlayerMode.Mode.PRACTICE) {
PlayModeConfig playModeConfig = config.getPlayConfig(model.getMode());
input.setAllInputConfigs(playModeConfig);
input.setPlayConfig(playModeConfig);
} else if (autoplay.mode == BMSPlayerMode.Mode.AUTOPLAY || autoplay.mode == BMSPlayerMode.Mode.REPLAY) {
input.setEnable(false);
}
Expand Down Expand Up @@ -475,16 +477,15 @@ public void create() {
practice.create(model);
state = STATE_PRACTICE;
} else {

if(resource.getRivalScoreData() == null) {
if (resource.getRivalScoreData() == null) {
int rivalscore = TargetProperty.getTargetProperty(config.getTargetid()).getTarget(main);
ScoreData rivalScore = new ScoreData();
rivalScore.setPlayer(TargetProperty.getTargetProperty(config.getTargetid()).getName());
rivalScore.setEpg(rivalscore / 2);
rivalScore.setEgr(rivalscore % 2);
resource.setRivalScoreData(rivalScore);
}
getScoreDataProperty().setTargetScore(score.getExscore(), score.decodeGhost(), resource.getRivalScoreData() != null ? resource.getRivalScoreData().getExscore() : 0 , null, model.getTotalNotes());
getScoreDataProperty().setTargetScore(score.getExscore(), score.decodeGhost(), resource.getRivalScoreData() != null ? resource.getRivalScoreData().getExscore() : 0, null, model.getTotalNotes());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/bms/player/beatoraja/select/BarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public void render(SkinObjectRenderer sprite, MusicSelectSkin skin, SkinBar baro
public void input() {
BMSPlayerInputProcessor input = select.main.getInputProcessor();

final MusicSelectKeyProperty property = MusicSelectKeyProperty.values()[select.main.getPlayerResource().getPlayerConfig().getMusicselectinput()];
final MusicSelectKeyProperty property = select.main.getPlayerResource().getPlayerConfig().getMusicSelectInputOption();

// song bar scroll on mouse wheel
int mov = -input.getScroll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ public void canceled() {
select.executeEvent(EventType.lnmode);
}

final MusicSelectKeyProperty property = MusicSelectKeyProperty.values()[config.getMusicselectinput()];
final MusicSelectKeyProperty property = config.getMusicSelectInputOption();

if(!input.startPressed() && !input.isSelectPressed() && !input.getControlKeyState(ControlKeys.NUM5)){
if (!input.startPressed() && !input.isSelectPressed() && !input.getControlKeyState(ControlKeys.NUM5)) {
//オプションキー入力なし
isOptionKeyReleased = true;
if(isOptionKeyPressed) {
if (isOptionKeyPressed) {
isOptionKeyPressed = false;
select.play(SOUND_OPTIONCLOSE);
}
Expand Down
130 changes: 79 additions & 51 deletions src/bms/player/beatoraja/select/MusicSelectKeyProperty.java
Original file line number Diff line number Diff line change
@@ -1,59 +1,74 @@
package bms.player.beatoraja.select;

import static bms.player.beatoraja.select.MusicSelectKeyProperty.MusicSelectKey.*;
import bms.player.beatoraja.input.BMSPlayerInputProcessor;

import static bms.player.beatoraja.select.MusicSelectKeyProperty.MusicSelectKey.*;

public enum MusicSelectKeyProperty {

BEAT_7K(new MusicSelectKey[][]{
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE ,DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN}
}),
POPN_9K(new MusicSelectKey[][]{
{AUTO, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{FOLDER_CLOSE, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{DOWN, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{PLAY, FOLDER_OPEN, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{UP, OPTION2_UP, BPMGUIDE ,DURATION_UP},
{PRACTICE, FOLDER_OPEN, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{TARGET_UP, NEXT_REPLAY},
{REPLAY, TARGET_DOWN}
}),
BEAT_14K(new MusicSelectKey[][]{
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE ,DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN},
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE ,DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN}
}),
;

private final MusicSelectKey[][] assign;

private MusicSelectKeyProperty(MusicSelectKey[][] assign) {
this.assign = assign;
}
BEAT_7K(
"2dx sp",
new MusicSelectKey[][]{
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE, DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN}
}
),
POPN_9K(
"popn",
new MusicSelectKey[][]{
{AUTO, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{FOLDER_CLOSE, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{DOWN, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{PLAY, FOLDER_OPEN, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{UP, OPTION2_UP, BPMGUIDE, DURATION_UP},
{PRACTICE, FOLDER_OPEN, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{TARGET_UP, NEXT_REPLAY},
{REPLAY, TARGET_DOWN}
}
),
BEAT_14K(
"2dx dp",
new MusicSelectKey[][]{
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE, DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN},
{PLAY, FOLDER_OPEN, OPTION1_DOWN, JUDGEWINDOW_UP, BGA_DOWN},
{FOLDER_CLOSE, OPTION1_UP, CONSTANT, GAUGEAUTOSHIFT_DOWN},
{PRACTICE, FOLDER_OPEN, GAUGE_DOWN, JUDGEAREA, NOTESDISPLAYTIMING_AUTOADJUST},
{FOLDER_CLOSE, OPTIONDP_DOWN, LEGACYNOTE, DURATION_DOWN},
{FOLDER_OPEN, AUTO, HSFIX_DOWN, MARKNOTE, NOTESDISPLAYTIMING_DOWN},
{NEXT_REPLAY, OPTION2_UP, BPMGUIDE, DURATION_UP},
{FOLDER_OPEN, REPLAY, OPTION2_DOWN, NOMINE, NOTESDISPLAYTIMING_UP},
{UP, TARGET_UP},
{DOWN, TARGET_DOWN}
}
),
;

private static final MusicSelectKeyProperty[] VALUES = values();

private final String text;

private final MusicSelectKey[][] assign;

MusicSelectKeyProperty(String text, MusicSelectKey[][] assign) {
this.text = text;
this.assign = assign;
}

public int getAnalogChange(BMSPlayerInputProcessor input, MusicSelectKey code) {
int dTicks = 0;
Expand Down Expand Up @@ -105,6 +120,19 @@ public enum MusicSelectKey {
OPTION1_UP, OPTION1_DOWN, GAUGE_UP, GAUGE_DOWN, OPTIONDP_UP, OPTIONDP_DOWN, HSFIX_UP, HSFIX_DOWN, OPTION2_UP, OPTION2_DOWN, TARGET_UP, TARGET_DOWN,
JUDGEAREA, NOMINE, BPMGUIDE, LEGACYNOTE, CONSTANT, JUDGEWINDOW_UP, JUDGEWINDOW_DOWN, MARKNOTE,
BGA_UP, BGA_DOWN, GAUGEAUTOSHIFT_UP, GAUGEAUTOSHIFT_DOWN, DURATION_UP, DURATION_DOWN, NOTESDISPLAYTIMING_UP, NOTESDISPLAYTIMING_DOWN, NOTESDISPLAYTIMING_AUTOADJUST, NEXT_REPLAY
;;
}

public MusicSelectKeyProperty nextValue() {
int nextPosition = this.ordinal() + 1;
if (nextPosition == VALUES.length) {
return VALUES[0];
} else {
return VALUES[nextPosition];
}
}

@Override
public String toString() {
return text;
}
}
21 changes: 7 additions & 14 deletions src/bms/player/beatoraja/select/MusicSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ public void create() {
main.getSoundManager().shuffle();
setSound(SOUND_BGM, "select.wav", SoundType.BGM, true);
setSound(SOUND_SCRATCH, "scratch.wav", SoundType.SOUND, false);
setSound(SOUND_FOLDEROPEN, "f-open.wav", SoundType.SOUND,false);
setSound(SOUND_FOLDERCLOSE, "f-close.wav", SoundType.SOUND,false);
setSound(SOUND_OPTIONCHANGE, "o-change.wav", SoundType.SOUND,false);
setSound(SOUND_OPTIONOPEN, "o-open.wav", SoundType.SOUND,false);
setSound(SOUND_OPTIONCLOSE, "o-close.wav", SoundType.SOUND,false);
setSound(SOUND_FOLDEROPEN, "f-open.wav", SoundType.SOUND, false);
setSound(SOUND_FOLDERCLOSE, "f-close.wav", SoundType.SOUND, false);
setSound(SOUND_OPTIONCHANGE, "o-change.wav", SoundType.SOUND, false);
setSound(SOUND_OPTIONOPEN, "o-open.wav", SoundType.SOUND, false);
setSound(SOUND_OPTIONCLOSE, "o-close.wav", SoundType.SOUND, false);

play = null;
showNoteGraph = false;
Expand All @@ -363,22 +363,15 @@ public void create() {

preview = new PreviewMusicProcessor(main.getAudioProcessor(), main.getPlayerResource().getConfig());
preview.setDefault(getSound(SOUND_BGM));

final BMSPlayerInputProcessor input = main.getInputProcessor();
PlayModeConfig pc = (config.getMusicselectinput() == 0 ? config.getMode7()
: (config.getMusicselectinput() == 1 ? config.getMode9() : config.getMode14()));
input.setKeyboardConfig(pc.getKeyboardConfig());
input.setControllerConfig(pc.getController());
input.setMidiConfig(pc.getMidiConfig());
bar.updateBar();

loadSkin(SkinType.MUSIC_SELECT);

// search text field
Rectangle searchRegion = ((MusicSelectSkin) getSkin()).getSearchTextRegion();
if (searchRegion != null && (getStage() == null ||
(search != null && !searchRegion.equals(search.getSearchBounds())))) {
if(search != null) {
(search != null && !searchRegion.equals(search.getSearchBounds())))) {
if (search != null) {
search.dispose();
}
search = new SearchTextField(this, main.getPlayerResource().getConfig().getResolution());
Expand Down

0 comments on commit dc8d23e

Please sign in to comment.