From dc8d23e1ff101080ce6f03ab9406bb90d203fb3d Mon Sep 17 00:00:00 2001 From: Chazoshtare Date: Sat, 25 Jun 2022 19:34:08 +0200 Subject: [PATCH] Set correct input mode depending on charts keymode, refactor music select input option picking --- src/bms/player/beatoraja/PlayerConfig.java | 10 +- .../beatoraja/config/KeyConfiguration.java | 30 +++- .../input/BMSPlayerInputProcessor.java | 6 + src/bms/player/beatoraja/play/BMSPlayer.java | 11 +- .../player/beatoraja/select/BarRenderer.java | 2 +- .../select/MusicSelectInputProcessor.java | 6 +- .../select/MusicSelectKeyProperty.java | 130 +++++++++++------- .../beatoraja/select/MusicSelector.java | 21 +-- 8 files changed, 131 insertions(+), 85 deletions(-) diff --git a/src/bms/player/beatoraja/PlayerConfig.java b/src/bms/player/beatoraja/PlayerConfig.java index 01e499c25..ca7df8824 100644 --- a/src/bms/player/beatoraja/PlayerConfig.java +++ b/src/bms/player/beatoraja/PlayerConfig.java @@ -214,7 +214,7 @@ public class PlayerConfig { /** * 選曲時でのキー入力方式 */ - private int musicselectinput = 0; + private MusicSelectKeyProperty musicSelectInputOption = MusicSelectKeyProperty.BEAT_7K; private IRConfig[] irconfig; @@ -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() { diff --git a/src/bms/player/beatoraja/config/KeyConfiguration.java b/src/bms/player/beatoraja/config/KeyConfiguration.java index 1829c9e5e..af43aff17 100644 --- a/src/bms/player/beatoraja/config/KeyConfiguration.java +++ b/src/bms/player/beatoraja/config/KeyConfiguration.java @@ -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; @@ -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(); @@ -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)) { @@ -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()); } } @@ -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); @@ -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(); diff --git a/src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java b/src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java index 55fdc8488..747fca083 100644 --- a/src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java +++ b/src/bms/player/beatoraja/input/BMSPlayerInputProcessor.java @@ -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); } diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index f3851fb2d..dd30bf91a 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -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); } @@ -475,8 +477,7 @@ 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()); @@ -484,7 +485,7 @@ public void create() { 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()); } } diff --git a/src/bms/player/beatoraja/select/BarRenderer.java b/src/bms/player/beatoraja/select/BarRenderer.java index 857a0cbc3..36640583d 100644 --- a/src/bms/player/beatoraja/select/BarRenderer.java +++ b/src/bms/player/beatoraja/select/BarRenderer.java @@ -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(); diff --git a/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java b/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java index 47f618ab6..bc1ba2a15 100644 --- a/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java +++ b/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java @@ -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); } diff --git a/src/bms/player/beatoraja/select/MusicSelectKeyProperty.java b/src/bms/player/beatoraja/select/MusicSelectKeyProperty.java index ea582a4e2..ca81077fb 100644 --- a/src/bms/player/beatoraja/select/MusicSelectKeyProperty.java +++ b/src/bms/player/beatoraja/select/MusicSelectKeyProperty.java @@ -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; @@ -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; } } diff --git a/src/bms/player/beatoraja/select/MusicSelector.java b/src/bms/player/beatoraja/select/MusicSelector.java index 762f24596..ad7435238 100644 --- a/src/bms/player/beatoraja/select/MusicSelector.java +++ b/src/bms/player/beatoraja/select/MusicSelector.java @@ -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; @@ -363,13 +363,6 @@ 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); @@ -377,8 +370,8 @@ public void create() { // 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());