From d033af4ec1161cbca892dbee303a1208eb5f898b Mon Sep 17 00:00:00 2001 From: Heon Jeong Date: Sat, 23 Sep 2023 08:29:51 -0400 Subject: [PATCH 01/74] Make the game window not resizable With the user using tiling window manager which tries to move all the windows in the tile, the game shows skewed screen regardless of configured value. Making the window not resizable will fix that issue, allowing the window to be positioned and sized as configured. --- src/bms/player/beatoraja/MainLoader.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bms/player/beatoraja/MainLoader.java b/src/bms/player/beatoraja/MainLoader.java index afd91841..8a68eb61 100644 --- a/src/bms/player/beatoraja/MainLoader.java +++ b/src/bms/player/beatoraja/MainLoader.java @@ -136,6 +136,7 @@ public static void play(Path f, BMSPlayerMode auto, boolean forceExit, Config co LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.width = config.getResolution().width; cfg.height = config.getResolution().height; + cfg.resizable = false; // fullscreen switch (config.getDisplaymode()) { From ec3d3169724190159cfe2ec56b073d97554c2803 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sun, 12 Nov 2023 21:19:48 +0900 Subject: [PATCH 02/74] MainLoader : refactor --- src/bms/player/beatoraja/MainController.java | 14 ++------- src/bms/player/beatoraja/MainLoader.java | 32 ++++++++++++++++++-- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/bms/player/beatoraja/MainController.java b/src/bms/player/beatoraja/MainController.java index ce9d5c20..19df414d 100644 --- a/src/bms/player/beatoraja/MainController.java +++ b/src/bms/player/beatoraja/MainController.java @@ -1,6 +1,7 @@ package bms.player.beatoraja; import java.io.*; +import java.lang.reflect.Field; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -39,7 +40,6 @@ import bms.player.beatoraja.skin.SkinLoader; import bms.player.beatoraja.skin.SkinObject.SkinOffset; import bms.player.beatoraja.skin.SkinProperty; -import bms.player.beatoraja.skin.property.StringPropertyFactory; import bms.player.beatoraja.song.*; import bms.player.beatoraja.stream.StreamController; import bms.tool.mdprocessor.MusicDownloadProcessor; @@ -49,9 +49,9 @@ * * @author exch */ -public class MainController extends ApplicationAdapter { +public class MainController { - private static final String VERSION = "beatoraja 0.8.6"; + private static final String VERSION = "beatoraja 0.8.7"; public static final boolean debug = false; @@ -111,8 +111,6 @@ public class MainController extends ApplicationAdapter { */ private PlayDataAccessor playdata; - static final Path configpath = Paths.get("config.json"); - private SystemSoundManager sound; private Thread screenshot; @@ -311,7 +309,6 @@ public void setPlayMode(BMSPlayerMode auto) { } - @Override public void create() { final long t = System.currentTimeMillis(); sprite = new SpriteBatch(); @@ -416,7 +413,6 @@ public void create() { private final StringBuilder message = new StringBuilder(); - @Override public void render() { // input.poll(); timer.update(); @@ -576,7 +572,6 @@ public void render() { } } - @Override public void dispose() { saveConfig(); @@ -615,17 +610,14 @@ public void dispose() { Logger.getGlobal().info("全リソース破棄完了"); } - @Override public void pause() { current.pause(); } - @Override public void resize(int width, int height) { current.resize(width, height); } - @Override public void resume() { current.resume(); } diff --git a/src/bms/player/beatoraja/MainLoader.java b/src/bms/player/beatoraja/MainLoader.java index 46a037d8..4e295116 100644 --- a/src/bms/player/beatoraja/MainLoader.java +++ b/src/bms/player/beatoraja/MainLoader.java @@ -9,6 +9,7 @@ import javax.swing.JOptionPane; +import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Graphics; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.ObjectMapper; @@ -93,7 +94,7 @@ public static void main(String[] args) { - if (Files.exists(MainController.configpath) && (bmsPath != null || auto != null)) { + if (Files.exists(Config.configpath) && (bmsPath != null || auto != null)) { IRConnectionManager.getAllAvailableIRConnectionName(); play(bmsPath, auto, true, null, null, bmsPath != null); } else { @@ -115,7 +116,7 @@ public static void play(Path f, BMSPlayerMode auto, boolean forceExit, Config co } try { - MainController main = new MainController(f, config, player, auto, songUpdated); + final MainController main = new MainController(f, config, player, auto, songUpdated); LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.width = config.getResolution().width; @@ -148,7 +149,32 @@ public static void play(Path f, BMSPlayerMode auto, boolean forceExit, Config co } // System.setProperty("org.lwjgl.opengl.Display.allowSoftwareOpenGL", // "true"); - new LwjglApplication(main, cfg); + new LwjglApplication(new ApplicationListener() { + + public void resume() { + main.resume(); + } + + public void resize(int width, int height) { + main.resize(width, height); + } + + public void render() { + main.render(); + } + + public void pause() { + main.pause(); + } + + public void dispose() { + main.dispose(); + } + + public void create() { + main.create(); + } + }, cfg); // Lwjgl3ApplicationConfiguration cfg = new Lwjgl3ApplicationConfiguration(); // From d781d0aa741b6c5ca93653f7167ad69c13f9aa2e Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sun, 12 Nov 2023 21:21:33 +0900 Subject: [PATCH 03/74] BMSPlayer : modify chart preview timer (41 -> 141) --- src/bms/player/beatoraja/play/BMSPlayer.java | 10 +++++----- src/bms/player/beatoraja/play/LaneRenderer.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index 9298d7e5..048eafed 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -506,18 +506,18 @@ public void render() { // 楽曲ロード case STATE_PRELOAD: if(config.isChartPreview()) { - if(timer.isTimerOn(TIMER_PLAY) && micronow > startpressedtime) { - timer.setTimerOff(TIMER_PLAY); + if(timer.isTimerOn(141) && micronow > startpressedtime) { + timer.setTimerOff(141); lanerender.init(model); - } else if(!timer.isTimerOn(TIMER_PLAY) && micronow == startpressedtime){ - timer.setMicroTimer(TIMER_PLAY, micronow - starttimeoffset * 1000); + } else if(!timer.isTimerOn(141) && micronow == startpressedtime){ + timer.setMicroTimer(141, micronow - starttimeoffset * 1000); } } if (resource.mediaLoadFinished() && micronow > (skin.getLoadstart() + skin.getLoadend()) * 1000 && micronow - startpressedtime > 1000000) { if(config.isChartPreview()) { - timer.setTimerOff(TIMER_PLAY); + timer.setTimerOff(141); lanerender.init(model); } bga.prepare(this); diff --git a/src/bms/player/beatoraja/play/LaneRenderer.java b/src/bms/player/beatoraja/play/LaneRenderer.java index 77ddd086..d633e974 100644 --- a/src/bms/player/beatoraja/play/LaneRenderer.java +++ b/src/bms/player/beatoraja/play/LaneRenderer.java @@ -254,8 +254,8 @@ public void drawLane(SkinObjectRenderer sprite, long time, SkinLane[] lanes, Ski offsetH += offset.h; } - time = (main.timer.isTimerOn(TIMER_PLAY) ? time - main.timer.getTimer(TIMER_PLAY) : 0) - + config.getJudgetiming(); + time = (main.timer.isTimerOn(TIMER_PLAY) ? time - main.timer.getTimer(TIMER_PLAY) : + (main.timer.isTimerOn(141) ? time - main.timer.getTimer(141) : 0)) + config.getJudgetiming(); if (main.getState() == BMSPlayer.STATE_PRACTICE) { time = main.getPracticeConfiguration().getPracticeProperty().starttime; pos = 0; From 4a35e9e51fbe489182dd368647b71607249059e6 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sun, 12 Nov 2023 21:22:29 +0900 Subject: [PATCH 04/74] MainStateAccessor : add audio_play, audio_loop, audio_stop --- .../beatoraja/skin/lua/MainStateAccessor.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/bms/player/beatoraja/skin/lua/MainStateAccessor.java b/src/bms/player/beatoraja/skin/lua/MainStateAccessor.java index 2fabcfa9..734ff0b3 100644 --- a/src/bms/player/beatoraja/skin/lua/MainStateAccessor.java +++ b/src/bms/player/beatoraja/skin/lua/MainStateAccessor.java @@ -135,6 +135,27 @@ public LuaValue call() { return LuaInteger.ZERO; } }); + table.set("audio_play", new OneArgFunction() { + @Override + public LuaValue call(LuaValue path) { + state.main.getAudioProcessor().play(path.tojstring(), state.main.getConfig().getAudioConfig().getSystemvolume(), false); + return LuaBoolean.TRUE; + } + }); + table.set("audio_loop", new OneArgFunction() { + @Override + public LuaValue call(LuaValue path) { + state.main.getAudioProcessor().play(path.tojstring(), state.main.getConfig().getAudioConfig().getSystemvolume(), true); + return LuaBoolean.TRUE; + } + }); + table.set("audio_stop", new OneArgFunction() { + @Override + public LuaValue call(LuaValue path) { + state.main.getAudioProcessor().stop(path.tojstring()); + return LuaBoolean.TRUE; + } + }); } /** From 17caab40bbc39bc85ae57f73e6f348d64a110cce Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Thu, 16 Nov 2023 12:01:15 +0900 Subject: [PATCH 05/74] RivalDataAccessor : refactor --- .../player/beatoraja/RivalDataAccessor.java | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/bms/player/beatoraja/RivalDataAccessor.java b/src/bms/player/beatoraja/RivalDataAccessor.java index ee10308b..1fbb08aa 100644 --- a/src/bms/player/beatoraja/RivalDataAccessor.java +++ b/src/bms/player/beatoraja/RivalDataAccessor.java @@ -17,18 +17,60 @@ import bms.player.beatoraja.select.ScoreDataCache; import bms.player.beatoraja.song.SongData; +/** + * ライバルデータ管理用 + * + * @author exch + */ public class RivalDataAccessor { + /** + * ライバル情報 + */ private PlayerInformation[] rivals = new PlayerInformation[0]; + /** + * ライバルスコアデータキャッシュ + */ private ScoreDataCache[] rivalcaches = new ScoreDataCache[0]; + /** + * ライバル情報を取得する + * + * @param index インデックス + * @return ライバル情報 + */ + public PlayerInformation getRivalInformation(int index) { + return index >= 0 && index < rivals.length ? rivals[index] : null; + } + + @Deprecated public PlayerInformation[] getRivals() { return rivals; } + /** + * ライバルスコアデータキャッシュを取得する + * + * @param index インデックス + * @return ライバルスコアデータキャッシュ + */ + public ScoreDataCache getRivalScoreDataCache(int index) { + return index >= 0 && index < rivalcaches.length ? rivalcaches[index] : null; + } + + @Deprecated public ScoreDataCache[] getRivalScoreDataCaches() { return rivalcaches; } + + /** + * ライバル数を取得する + * + * @return ライバル数 + */ + public int getRivalCount() { + return rivals.length; + } public void update(MainController main) { if(main.getIRStatus().length > 0) { @@ -60,8 +102,8 @@ public void update(MainController main) { } // ライバルキャッシュ作成 - Array rivals = new Array(); - Array rivalcaches = new Array(); + Array rivals = new Array(); + Array rivalcaches = new Array(); if(main.getIRStatus()[0].config.isImportrival()) { for(IRPlayerData irplayer : response.getData()) { From 518f1f7af54d1a43188a9fa24926e315a1b042bd Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Thu, 16 Nov 2023 22:16:56 +0900 Subject: [PATCH 06/74] BarRenderer : add rival name to rival score --- src/bms/player/beatoraja/select/BarRenderer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bms/player/beatoraja/select/BarRenderer.java b/src/bms/player/beatoraja/select/BarRenderer.java index 0b9c3836..92b15cd5 100644 --- a/src/bms/player/beatoraja/select/BarRenderer.java +++ b/src/bms/player/beatoraja/select/BarRenderer.java @@ -1162,6 +1162,7 @@ public void run() { final MainController main = select.main; final PlayerConfig config = select.resource.getPlayerConfig(); final ScoreDataCache rival = select.getRivalScoreDataCache(); + final String rivalName = rival != null ? select.getRival().getName() : null; final Array songarray = new Array<>(bars.length); for (Bar bar : bars) { @@ -1179,7 +1180,11 @@ public void run() { bar.setScore(select.getScoreDataCache().readScoreData(sd, config.getLnmode())); } if (rival != null && bar.getRivalScore() == null) { - bar.setRivalScore(rival.readScoreData(sd, config.getLnmode())); + final ScoreData rivalScore = rival.readScoreData(sd, config.getLnmode()); + if(rivalScore != null) { + rivalScore.setPlayer(rivalName); + } + bar.setRivalScore(rivalScore); } boolean[] replay = new boolean[MusicSelector.REPLAY]; for (int i = 0; i < MusicSelector.REPLAY; i++) { From 78baff325721b7c97db8f59f5453ce338c9273db Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Fri, 17 Nov 2023 02:56:51 +0900 Subject: [PATCH 07/74] PlayerResource : add target score --- src/bms/player/beatoraja/PlayerResource.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bms/player/beatoraja/PlayerResource.java b/src/bms/player/beatoraja/PlayerResource.java index e061428b..21f020a3 100755 --- a/src/bms/player/beatoraja/PlayerResource.java +++ b/src/bms/player/beatoraja/PlayerResource.java @@ -57,6 +57,10 @@ public class PlayerResource { * ライバルスコア */ private ScoreData rscore; + /** + * ターゲットスコア + */ + private ScoreData tscore; private RankingData ranking; /** @@ -131,7 +135,8 @@ public void clear() { courseindex = 0; cscore = null; score = null; - rscore = null; +// rscore = null; + tscore = null; gauge = null; courseReplay.clear(); coursegauge.clear(); @@ -258,6 +263,14 @@ public void setRivalScoreData(ScoreData rscore) { this.rscore = rscore; } + public ScoreData getTargetScoreData() { + return tscore; + } + + public void setTargetScoreData(ScoreData tscore) { + this.tscore = tscore; + } + public RankingData getRankingData() { return ranking; } From 45c9ab2307ffbe03b7d136498e04a4990f5dc5bf Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Fri, 17 Nov 2023 02:59:21 +0900 Subject: [PATCH 08/74] StringPropertyFactory : modify rival, target --- src/bms/player/beatoraja/play/BMSPlayer.java | 8 +++++--- .../beatoraja/skin/property/StringPropertyFactory.java | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index 048eafed..3713d0c5 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -474,10 +474,12 @@ public void create() { } else { if(resource.getRivalScoreData() == null || resource.getCourseBMSModels() != null) { - ScoreData rivalScore = TargetProperty.getTargetProperty(config.getTargetid()).getTarget(main); - resource.setRivalScoreData(rivalScore); + ScoreData targetScore = TargetProperty.getTargetProperty(config.getTargetid()).getTarget(main); + resource.setTargetScoreData(targetScore); + } else { + resource.setTargetScoreData(resource.getRivalScoreData()); } - getScoreDataProperty().setTargetScore(score.getExscore(), score.decodeGhost(), resource.getRivalScoreData() != null ? resource.getRivalScoreData().getExscore() : 0 , null, model.getTotalNotes()); + getScoreDataProperty().setTargetScore(score.getExscore(), score.decodeGhost(), resource.getTargetScoreData() != null ? resource.getTargetScoreData().getExscore() : 0 , null, model.getTotalNotes()); } } diff --git a/src/bms/player/beatoraja/skin/property/StringPropertyFactory.java b/src/bms/player/beatoraja/skin/property/StringPropertyFactory.java index 0cb69e51..136f7ffb 100644 --- a/src/bms/player/beatoraja/skin/property/StringPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/StringPropertyFactory.java @@ -60,7 +60,7 @@ public enum StringType { final PlayerInformation rival = ((MusicSelector) state).getRival(); return rival != null ? rival.getName() : ""; } else { - final ScoreData rival = state.resource.getRivalScoreData(); + final ScoreData rival = state.resource.getTargetScoreData(); return rival != null ? rival.getPlayer() : ""; } }), @@ -69,8 +69,8 @@ public enum StringType { if (state instanceof MusicSelector) { return TargetProperty.getTargetName(state.resource.getPlayerConfig().getTargetid()); } else { - final ScoreData rival = state.resource.getRivalScoreData(); - return rival != null ? rival.getPlayer() : ""; + final ScoreData target = state.resource.getTargetScoreData(); + return target != null ? target.getPlayer() : ""; } }), title(10, (state) -> { From fe4857a8f2ba4cf5a45902c2217b325d48c746eb Mon Sep 17 00:00:00 2001 From: sr8e Date: Fri, 17 Nov 2023 23:06:50 +0900 Subject: [PATCH 09/74] add getRandomPattern method to LaneShuffleModifier --- .../pattern/LaneShuffleModifier.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/bms/player/beatoraja/pattern/LaneShuffleModifier.java b/src/bms/player/beatoraja/pattern/LaneShuffleModifier.java index 45e54911..24f32471 100644 --- a/src/bms/player/beatoraja/pattern/LaneShuffleModifier.java +++ b/src/bms/player/beatoraja/pattern/LaneShuffleModifier.java @@ -288,4 +288,37 @@ public List modify(BMSModel model) { return log; } + public boolean isToDisplay() { + switch (type) { + case RANDOM: + case R_RANDOM: + case CROSS: + case RANDOM_EX: + return true; + default: + return false; + } + } + + public int[] getRandomPattern(Mode mode) { + int targetSide = getModifyTarget(); + int keys = mode.key / mode.player; + int[] repr = new int[keys]; + switch (type) { + case RANDOM: + case R_RANDOM: + case CROSS: + case RANDOM_EX: + if (mode.scratchKey.length > 0 && type != Random.RANDOM_EX) { // BEAT-*K + System.arraycopy(random, keys * targetSide, repr, 0, keys - 1); + repr[keys - 1] = mode.scratchKey[targetSide]; + } else { + System.arraycopy(random, keys * targetSide, repr, 0, keys); + } + break; + default: + break; + } + return repr; + } } From 601bc67f9c56ab06f795e25b9cda10546f7d8bd8 Mon Sep 17 00:00:00 2001 From: sr8e Date: Fri, 17 Nov 2023 23:09:29 +0900 Subject: [PATCH 10/74] add laneShufflePattern member to ReplayData to keep pattern --- src/bms/player/beatoraja/ReplayData.java | 1 + src/bms/player/beatoraja/play/BMSPlayer.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/bms/player/beatoraja/ReplayData.java b/src/bms/player/beatoraja/ReplayData.java index 52037403..0ef108bf 100644 --- a/src/bms/player/beatoraja/ReplayData.java +++ b/src/bms/player/beatoraja/ReplayData.java @@ -34,6 +34,7 @@ public class ReplayData implements Validatable { * 譜面オプションによる変更ログ */ public PatternModifyLog[] pattern; + public int[][] laneShufflePattern; /** * ランダムシーケンスを含むbmsの場合、選択されたRANDOM番号 */ diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index 3713d0c5..13d8858f 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -358,6 +358,8 @@ public BMSPlayer(MainController main, PlayerResource resource) { mods.add(mod); } + int[][] patternArray = new int[model.getMode().player][]; + List pattern = new ArrayList(); for(PatternModifier mod : mods) { pattern = PatternModifier.merge(pattern,mod.modify(model)); @@ -366,8 +368,16 @@ public BMSPlayer(MainController main, PlayerResource resource) { assist = Math.max(assist, mod.getAssistLevel() == PatternModifier.AssistLevel.ASSIST ? 2 : 1); score = false; } + + if (mod instanceof LaneShuffleModifier){ + LaneShuffleModifier lmod = (LaneShuffleModifier)mod; + if(lmod.isToDisplay()){ + patternArray[lmod.getModifyTarget()] = lmod.getRandomPattern(model.getMode()); + } + } } // playinfo.pattern = pattern.toArray(new PatternModifyLog[pattern.size()]); + playinfo.laneShufflePattern = patternArray; } @@ -909,6 +919,7 @@ public ScoreData createScoreData() { replay.date = Calendar.getInstance().getTimeInMillis() / 1000; replay.keylog = main.getInputProcessor().getKeyInputLog(); // replay.pattern = playinfo.pattern; + replay.laneShufflePattern = playinfo.laneShufflePattern; replay.rand = playinfo.rand; replay.gauge = config.getGauge(); replay.sevenToNinePattern = config.getSevenToNinePattern(); From 9a7e5511573fb381f1b5c9c32de50c15a062c380 Mon Sep 17 00:00:00 2001 From: sr8e Date: Fri, 17 Nov 2023 23:11:39 +0900 Subject: [PATCH 11/74] add skin property to refer lane assignment of random op --- .../player/beatoraja/skin/SkinProperty.java | 19 ++++++ .../skin/property/IntegerPropertyFactory.java | 64 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/src/bms/player/beatoraja/skin/SkinProperty.java b/src/bms/player/beatoraja/skin/SkinProperty.java index 940c0c5b..10af4ef6 100644 --- a/src/bms/player/beatoraja/skin/SkinProperty.java +++ b/src/bms/player/beatoraja/skin/SkinProperty.java @@ -507,6 +507,25 @@ public class SkinProperty { public static final int NUMBER_RANKING1_CLEAR = 390; public static final int NUMBER_RANKING10_CLEAR = 399; + public static final int NUMBER_RANDOM_1P_1KEY = 450; + public static final int NUMBER_RANDOM_1P_2KEY = 451; + public static final int NUMBER_RANDOM_1P_3KEY = 452; + public static final int NUMBER_RANDOM_1P_4KEY = 453; + public static final int NUMBER_RANDOM_1P_5KEY = 454; + public static final int NUMBER_RANDOM_1P_6KEY = 455; + public static final int NUMBER_RANDOM_1P_7KEY = 456; + public static final int NUMBER_RANDOM_1P_8KEY = 457; + public static final int NUMBER_RANDOM_1P_9KEY = 458; + public static final int NUMBER_RANDOM_1P_SCR = 459; + public static final int NUMBER_RANDOM_2P_1KEY = 460; + public static final int NUMBER_RANDOM_2P_2KEY = 461; + public static final int NUMBER_RANDOM_2P_3KEY = 462; + public static final int NUMBER_RANDOM_2P_4KEY = 463; + public static final int NUMBER_RANDOM_2P_5KEY = 464; + public static final int NUMBER_RANDOM_2P_6KEY = 465; + public static final int NUMBER_RANDOM_2P_7KEY = 466; + public static final int NUMBER_RANDOM_2P_SCR = 469; + public static final int VALUE_JUDGE_1P_DURATION = 525; public static final int VALUE_JUDGE_2P_DURATION = 526; diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index 23de7ab4..7dc4e503 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -5,6 +5,8 @@ import java.util.Arrays; import java.util.Calendar; +import bms.model.Mode; +import bms.player.beatoraja.pattern.Random; import com.badlogic.gdx.Gdx; import bms.model.BMSModel; @@ -1200,6 +1202,25 @@ public enum IndexType { cleartype_ranking8(397, createRankinCleartypeProperty(7)), cleartype_ranking9(398, createRankinCleartypeProperty(8)), cleartype_ranking10(399, createRankinCleartypeProperty(9)), + pattern_1p_1(450, getAssignedLane(0, false)), + pattern_1p_2(451, getAssignedLane(1, false)), + pattern_1p_3(452, getAssignedLane(2, false)), + pattern_1p_4(453, getAssignedLane(3, false)), + pattern_1p_5(454, getAssignedLane(4, false)), + pattern_1p_6(455, getAssignedLane(5, false)), + pattern_1p_7(456, getAssignedLane(6, false)), + pattern_1p_8(457, getAssignedLane(7, false)), + pattern_1p_9(458, getAssignedLane(8, false)), + pattern_1p_SCR(459, getAssignedLane(-1, false)), + pattern_2p_1(460, getAssignedLane(0, true)), + pattern_2p_2(461, getAssignedLane(1, true)), + pattern_2p_3(462, getAssignedLane(2, true)), + pattern_2p_4(463, getAssignedLane(3, true)), + pattern_2p_5(464, getAssignedLane(4, true)), + pattern_2p_6(465, getAssignedLane(5, true)), + pattern_2p_7(466, getAssignedLane(6, true)), + pattern_2p_SCR(469, getAssignedLane(-1, true)), + // 旧仕様 assist_constant(BUTTON_ASSIST_CONSTANT, (state) -> (state.resource.getPlayerConfig().getScrollMode() == 1 ? 1 : 0)), @@ -1237,6 +1258,49 @@ private static IntegerProperty createRankinCleartypeProperty(int index) { return score != null ? score.clear.id : Integer.MIN_VALUE; }; } + + /** + * ランダムオプションで割り当てられたレーンを返す + */ + private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ + return (state) -> { + PlayerConfig pc = state.resource.getPlayerConfig(); + Random type = Random.getRandom(is2PSide? pc.getRandom2(): pc.getRandom()); + + switch (type){ + case RANDOM: + case R_RANDOM: + case CROSS: + case RANDOM_EX: + break; + default: + return 0; + } + + Mode mode = state.resource.getBMSModel().getMode(); + if(mode.player == 1 && is2PSide){ + return 0; + } + int keyNum = mode.key / mode.player; + + int index; + if(key >= keyNum) { + return 0; + } else if(key == -1){ // scratch + if (mode.scratchKey.length == 0){ // no scratch + return 0; + } + index = mode.scratchKey[0]; + } else { + index = key; + } + int[] pattern = state.resource.getReplayData().laneShufflePattern[is2PSide? 1 : 0]; + if (pattern == null){ + return 0; + } + return pattern[index] + 1 - (is2PSide? keyNum: 0); + }; + } } private static class FolderTotalClearCountProperty implements IntegerProperty { From c5e60869d1ad11578a87146716527cd049792315 Mon Sep 17 00:00:00 2001 From: sr8e Date: Sat, 18 Nov 2023 05:43:27 +0900 Subject: [PATCH 12/74] disable getAssignedLane for scratch when no-SCR random option is used --- .../player/beatoraja/skin/property/IntegerPropertyFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index 7dc4e503..4f287af6 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -1287,7 +1287,7 @@ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ if(key >= keyNum) { return 0; } else if(key == -1){ // scratch - if (mode.scratchKey.length == 0){ // no scratch + if (mode.scratchKey.length == 0 || type != Random.RANDOM_EX){ // no scratch return 0; } index = mode.scratchKey[0]; From e95cfd162dd7fca0fcfdc9392221097d7dedda82 Mon Sep 17 00:00:00 2001 From: sr8e Date: Sun, 19 Nov 2023 00:51:45 +0900 Subject: [PATCH 13/74] fix NullPointerException out of result screen --- .../beatoraja/skin/property/IntegerPropertyFactory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index 4f287af6..39bc804f 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -7,6 +7,7 @@ import bms.model.Mode; import bms.player.beatoraja.pattern.Random; +import bms.player.beatoraja.result.MusicResult; import com.badlogic.gdx.Gdx; import bms.model.BMSModel; @@ -1264,6 +1265,9 @@ private static IntegerProperty createRankinCleartypeProperty(int index) { */ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ return (state) -> { + if (!(state instanceof MusicResult)){ + return 0; + } PlayerConfig pc = state.resource.getPlayerConfig(); Random type = Random.getRandom(is2PSide? pc.getRandom2(): pc.getRandom()); From 1a931215f40aca422b844af79431f71996a03577 Mon Sep 17 00:00:00 2001 From: sr8e Date: Sun, 19 Nov 2023 00:54:39 +0900 Subject: [PATCH 14/74] disable specifying scratch key index directly in getAssignedLane() --- .../player/beatoraja/skin/property/IntegerPropertyFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index 39bc804f..abb42e55 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -1288,7 +1288,7 @@ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ int keyNum = mode.key / mode.player; int index; - if(key >= keyNum) { + if(key >= keyNum || (mode.scratchKey.length != 0 && key == mode.scratchKey[0])) { return 0; } else if(key == -1){ // scratch if (mode.scratchKey.length == 0 || type != Random.RANDOM_EX){ // no scratch From 400071807a8eda0f4c07dd469f4807a915844fbc Mon Sep 17 00:00:00 2001 From: sr8e Date: Sun, 19 Nov 2023 09:53:27 +0900 Subject: [PATCH 15/74] fix NPE in replay mode by changing random option reference --- .../skin/property/IntegerPropertyFactory.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index abb42e55..1720f729 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -1268,8 +1268,9 @@ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ if (!(state instanceof MusicResult)){ return 0; } - PlayerConfig pc = state.resource.getPlayerConfig(); - Random type = Random.getRandom(is2PSide? pc.getRandom2(): pc.getRandom()); + + ReplayData rd = state.resource.getReplayData(); + Random type = Random.getRandom(is2PSide? rd.randomoption2: rd.randomoption); switch (type){ case RANDOM: @@ -1281,6 +1282,10 @@ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ return 0; } + if(rd.laneShufflePattern == null){ // patternModifyLogで再現されたリプレイの場合が該当 + return 0; + } + Mode mode = state.resource.getBMSModel().getMode(); if(mode.player == 1 && is2PSide){ return 0; @@ -1298,7 +1303,8 @@ private static IntegerProperty getAssignedLane(int key, boolean is2PSide){ } else { index = key; } - int[] pattern = state.resource.getReplayData().laneShufflePattern[is2PSide? 1 : 0]; + + int[] pattern = rd.laneShufflePattern[is2PSide? 1 : 0]; if (pattern == null){ return 0; } From 4bc6b1ac6cb09f5a854186b7175f4a23a21dadfa Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Fri, 24 Nov 2023 23:34:20 +0900 Subject: [PATCH 16/74] MusicSelector : fix course mode with chart option --- src/bms/player/beatoraja/select/MusicSelector.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bms/player/beatoraja/select/MusicSelector.java b/src/bms/player/beatoraja/select/MusicSelector.java index 9060a934..dee86b5b 100644 --- a/src/bms/player/beatoraja/select/MusicSelector.java +++ b/src/bms/player/beatoraja/select/MusicSelector.java @@ -139,14 +139,14 @@ protected void readScoreDatasFromSource(ScoreDataCollector collector, SongData[] public void setRival(PlayerInformation rival) { final RivalDataAccessor rivals = main.getRivalDataAccessor(); int index = -1; - for(int i = 0;i < rivals.getRivals().length;i++) { - if(rival == rivals.getRivals()[i]) { + for(int i = 0;i < rivals.getRivalCount();i++) { + if(rival == rivals.getRivalInformation(i)) { index = i; break; } } - this.rival = index != -1 ? rivals.getRivals()[index] : null; - rivalcache = index != -1 ? rivals.getRivalScoreDataCaches()[index] : null; + this.rival = index != -1 ? rivals.getRivalInformation(index) : null; + rivalcache = index != -1 ? rivals.getRivalScoreDataCache(index) : null; bar.updateBar(); Logger.getGlobal().info("Rival変更:" + (rival != null ? rival.getName() : "なし")); } @@ -283,6 +283,7 @@ public void render() { if (((SongBar) current).existsSong()) { resource.clear(); if (resource.setBMSFile(Paths.get(song.getPath()), play)) { + // TODO 重複コード final Queue dir = this.getBarRender().getDirectory(); if(dir.size > 0 && !(dir.last() instanceof SameFolderBar)) { Array urls = new Array(resource.getConfig().getTableURL()); @@ -302,6 +303,7 @@ public void render() { } } } + if(main.getIRStatus().length > 0 && currentir == null) { currentir = new RankingData(); main.getRankingDataCache().put(song, config.getLnmode(), currentir); @@ -324,6 +326,7 @@ public void render() { SongData song = ((ExecutableBar) current).getSongData(); resource.clear(); if (resource.setBMSFile(Paths.get(song.getPath()), play)) { + // TODO 重複コード final Queue dir = this.getBarRender().getDirectory(); if(dir.size > 0 && !(dir.last() instanceof SameFolderBar)) { Array urls = new Array(resource.getConfig().getTableURL()); @@ -343,6 +346,7 @@ public void render() { } } } + playedsong = song; changeState(MainStateType.DECIDE); } else { @@ -530,6 +534,7 @@ private boolean _readCourse(BMSPlayerMode mode, GradeBar gradeBar) { main.getRankingDataCache().put(songs[0], config.getLnmode(), songrank); } resource.setRankingData(songrank); + resource.setRivalScoreData(null); changeState(MainStateType.DECIDE); return true; From 7227b74e7e3e45234d0714ac6384effab68ce0f4 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Fri, 24 Nov 2023 23:45:34 +0900 Subject: [PATCH 17/74] MainController : move SystemSoundManager to new file --- src/bms/player/beatoraja/MainController.java | 74 +----------- .../player/beatoraja/SystemSoundManager.java | 110 ++++++++++++++++++ 2 files changed, 112 insertions(+), 72 deletions(-) create mode 100644 src/bms/player/beatoraja/SystemSoundManager.java diff --git a/src/bms/player/beatoraja/MainController.java b/src/bms/player/beatoraja/MainController.java index 19df414d..7f296db5 100644 --- a/src/bms/player/beatoraja/MainController.java +++ b/src/bms/player/beatoraja/MainController.java @@ -1,13 +1,9 @@ package bms.player.beatoraja; -import java.io.*; -import java.lang.reflect.Field; -import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.logging.Logger; -import java.util.stream.Stream; import org.lwjgl.input.Mouse; @@ -376,8 +372,8 @@ public void create() { }); polling.start(); - Array targetlist = new Array(player.getTargetlist()); - for(int i = 0;i < rivals.getRivals().length;i++) { + Array targetlist = new Array(player.getTargetlist()); + for(int i = 0;i < rivals.getRivalCount();i++) { targetlist.add("RIVAL_" + (i + 1)); } TargetProperty.setTargets(targetlist.toArray(String.class), this); @@ -834,72 +830,6 @@ public void run() { } } - /** - * BGM、効果音セット管理用クラス - * - * @author exch - */ - public static class SystemSoundManager { - /** - * 検出されたBGMセットのディレクトリパス - */ - private Array bgms = new Array(); - /** - * 現在のBGMセットのディレクトリパス - */ - private Path currentBGMPath; - /** - * 検出された効果音セットのディレクトリパス - */ - private Array sounds = new Array(); - /** - * 現在の効果音セットのディレクトリパス - */ - private Path currentSoundPath; - - public SystemSoundManager(Config config) { - if(config.getBgmpath() != null && config.getBgmpath().length() > 0) { - scan(Paths.get(config.getBgmpath()).toAbsolutePath(), bgms, "select.wav"); - } - if(config.getSoundpath() != null && config.getSoundpath().length() > 0) { - scan(Paths.get(config.getSoundpath()).toAbsolutePath(), sounds, "clear.wav"); - } - Logger.getGlobal().info("検出されたBGM Set : " + bgms.size + " Sound Set : " + sounds.size); - } - - public void shuffle() { - if(bgms.size > 0) { - currentBGMPath = bgms.get((int) (Math.random() * bgms.size)); - } - if(sounds.size > 0) { - currentSoundPath = sounds.get((int) (Math.random() * sounds.size)); - } - Logger.getGlobal().info("BGM Set : " + currentBGMPath + " Sound Set : " + currentSoundPath); - } - - public Path getBGMPath() { - return currentBGMPath; - } - - public Path getSoundPath() { - return currentSoundPath; - } - - private void scan(Path p, Array paths, String name) { - if (Files.isDirectory(p)) { - try (Stream sub = Files.list(p)) { - sub.forEach((t) -> { - scan(t, paths, name); - }); - if (AudioDriver.getPaths(p.resolve(name).toString()).length > 0) { - paths.add(p); - } - } catch (IOException e) { - } - } - } - } - public static class IRStatus { public final IRConfig config; diff --git a/src/bms/player/beatoraja/SystemSoundManager.java b/src/bms/player/beatoraja/SystemSoundManager.java new file mode 100644 index 00000000..dd9bbfcd --- /dev/null +++ b/src/bms/player/beatoraja/SystemSoundManager.java @@ -0,0 +1,110 @@ +package bms.player.beatoraja; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.logging.Logger; +import java.util.stream.Stream; + +import com.badlogic.gdx.utils.Array; + +import bms.player.beatoraja.audio.AudioDriver; + +/** + * BGM、効果音セット管理用クラス + * + * @author exch + */ +public class SystemSoundManager { + /** + * 検出されたBGMセットのディレクトリパス + */ + private Array bgms = new Array(); + /** + * 現在のBGMセットのディレクトリパス + */ + private Path currentBGMPath; + /** + * 検出された効果音セットのディレクトリパス + */ + private Array sounds = new Array(); + /** + * 現在の効果音セットのディレクトリパス + */ + private Path currentSoundPath; + + public SystemSoundManager(Config config) { + if(config.getBgmpath() != null && config.getBgmpath().length() > 0) { + scan(Paths.get(config.getBgmpath()).toAbsolutePath(), bgms, "select.wav"); + } + if(config.getSoundpath() != null && config.getSoundpath().length() > 0) { + scan(Paths.get(config.getSoundpath()).toAbsolutePath(), sounds, "clear.wav"); + } + Logger.getGlobal().info("検出されたBGM Set : " + bgms.size + " Sound Set : " + sounds.size); + } + + public void shuffle() { + if(bgms.size > 0) { + currentBGMPath = bgms.get((int) (Math.random() * bgms.size)); + } + if(sounds.size > 0) { + currentSoundPath = sounds.get((int) (Math.random() * sounds.size)); + } + Logger.getGlobal().info("BGM Set : " + currentBGMPath + " Sound Set : " + currentSoundPath); + } + + public Path getBGMPath() { + return currentBGMPath; + } + + public Path getSoundPath() { + return currentSoundPath; + } + + private void scan(Path p, Array paths, String name) { + if (Files.isDirectory(p)) { + try (Stream sub = Files.list(p)) { + sub.forEach((t) -> { + scan(t, paths, name); + }); + if (AudioDriver.getPaths(p.resolve(name).toString()).length > 0) { + paths.add(p); + } + } catch (IOException e) { + } + } + } + + public enum SoundType { + SCRATCH("scratch.wav"), + FOLDER_OPEN("f-open.wav"), + FOLDER_CLOSE("f-close.wav"), + OPTION_CHANGE("o-change.wav"), + OPTION_OPEN("o-open.wav"), + OPTION_CLOSE("o-close.wav"), + PLAY_READY("playready.wav"), + PLAY_STOP("playstop.wav"), + RESULT_CLEAR("clear.wav"), + RESULT_FAIL("fail.wav"), + RESULT_CLOSE("resultclose.wav"); + + public final String path; + + private SoundType(String path) { + this.path = path; + } + } + + public enum BGMType { + SELECT("select.wav"), + DECIDE("decide.wav"); + + public final String path; + + private BGMType(String path) { + this.path = path; + } + + } +} \ No newline at end of file From 6aae5e13f70bcabf2014b1945c56caece69b87a0 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sun, 26 Nov 2023 01:36:59 +0900 Subject: [PATCH 18/74] SystemSoundManager : add methods --- src/bms/player/beatoraja/MainController.java | 2 +- src/bms/player/beatoraja/MainState.java | 17 +++ .../player/beatoraja/SystemSoundManager.java | 100 +++++++++++++----- 3 files changed, 92 insertions(+), 27 deletions(-) diff --git a/src/bms/player/beatoraja/MainController.java b/src/bms/player/beatoraja/MainController.java index 7f296db5..a374e5b5 100644 --- a/src/bms/player/beatoraja/MainController.java +++ b/src/bms/player/beatoraja/MainController.java @@ -192,7 +192,7 @@ public MainController(Path f, Config config, PlayerConfig player, BMSPlayerMode } timer = new TimerManager(); - sound = new SystemSoundManager(config); + sound = new SystemSoundManager(this); if(config.isUseDiscordRPC()) { stateListener.add(new DiscordListener()); diff --git a/src/bms/player/beatoraja/MainState.java b/src/bms/player/beatoraja/MainState.java index a7c7b2f8..50279965 100644 --- a/src/bms/player/beatoraja/MainState.java +++ b/src/bms/player/beatoraja/MainState.java @@ -181,6 +181,7 @@ public enum SoundType { BGM, SOUND } + @Deprecated public void setSound(int id, String path, SoundType type, boolean loop) { for(Path p :getSoundPaths(path, type)) { String newpath = p.toString(); @@ -197,6 +198,7 @@ public void setSound(int id, String path, SoundType type, boolean loop) { } } + @Deprecated public Path[] getSoundPaths(String filename, SoundType type) { Path p = null; switch (type) { @@ -216,10 +218,12 @@ public Path[] getSoundPaths(String filename, SoundType type) { return paths.toArray(Path.class); } + @Deprecated public String getSound(int id) { return soundmap.get(id); } + @Deprecated public void play(int id) { final String path = soundmap.get(id); if (path != null) { @@ -228,6 +232,7 @@ public void play(int id) { } } + @Deprecated public void stop(int id) { final String path = soundmap.get(id); if (path != null) { @@ -235,6 +240,18 @@ public void stop(int id) { } } + public void play(SystemSoundManager.SoundType sound) { + play(sound, false); + } + + public void play(SystemSoundManager.SoundType sound, boolean loop) { + main.getSoundManager().play(sound, loop); + } + + public void stop(SystemSoundManager.SoundType sound) { + main.getSoundManager().stop(sound); + } + public enum MainStateType { MUSICSELECT,DECIDE,PLAY,RESULT,COURSERESULT,CONFIG,SKINCONFIG; } diff --git a/src/bms/player/beatoraja/SystemSoundManager.java b/src/bms/player/beatoraja/SystemSoundManager.java index dd9bbfcd..faf97c5c 100644 --- a/src/bms/player/beatoraja/SystemSoundManager.java +++ b/src/bms/player/beatoraja/SystemSoundManager.java @@ -8,6 +8,7 @@ import java.util.stream.Stream; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.ObjectMap; import bms.player.beatoraja.audio.AudioDriver; @@ -17,6 +18,8 @@ * @author exch */ public class SystemSoundManager { + + private final MainController main; /** * 検出されたBGMセットのディレクトリパス */ @@ -33,8 +36,12 @@ public class SystemSoundManager { * 現在の効果音セットのディレクトリパス */ private Path currentSoundPath; + + private ObjectMap soundmap = new ObjectMap<>(); - public SystemSoundManager(Config config) { + public SystemSoundManager(MainController main) { + this.main = main; + Config config = main.getConfig(); if(config.getBgmpath() != null && config.getBgmpath().length() > 0) { scan(Paths.get(config.getBgmpath()).toAbsolutePath(), bgms, "select.wav"); } @@ -52,6 +59,22 @@ public void shuffle() { currentSoundPath = sounds.get((int) (Math.random() * sounds.size)); } Logger.getGlobal().info("BGM Set : " + currentBGMPath + " Sound Set : " + currentSoundPath); + + for(SoundType sound : SoundType.values()) { + for(Path p :getSoundPaths(sound)) { + String newpath = p.toString(); + String oldpath = soundmap.get(sound); + if (newpath.equals(oldpath)) { + break; + } + if (oldpath != null) { + main.getAudioProcessor().dispose(oldpath); + } + soundmap.put(sound, newpath); + return; + } + + } } public Path getBGMPath() { @@ -65,9 +88,7 @@ public Path getSoundPath() { private void scan(Path p, Array paths, String name) { if (Files.isDirectory(p)) { try (Stream sub = Files.list(p)) { - sub.forEach((t) -> { - scan(t, paths, name); - }); + sub.forEach((t) -> scan(t, paths, name)); if (AudioDriver.getPaths(p.resolve(name).toString()).length > 0) { paths.add(p); } @@ -76,35 +97,62 @@ private void scan(Path p, Array paths, String name) { } } - public enum SoundType { - SCRATCH("scratch.wav"), - FOLDER_OPEN("f-open.wav"), - FOLDER_CLOSE("f-close.wav"), - OPTION_CHANGE("o-change.wav"), - OPTION_OPEN("o-open.wav"), - OPTION_CLOSE("o-close.wav"), - PLAY_READY("playready.wav"), - PLAY_STOP("playstop.wav"), - RESULT_CLEAR("clear.wav"), - RESULT_FAIL("fail.wav"), - RESULT_CLOSE("resultclose.wav"); + public Path[] getSoundPaths(SoundType type) { + Path p = type.isBGM ? currentBGMPath : currentSoundPath; - public final String path; - - private SoundType(String path) { - this.path = path; + Array paths = new Array(); + if(p != null) { + paths.addAll(AudioDriver.getPaths(p.resolve(type.path).toString())); } + paths.addAll(AudioDriver.getPaths(Paths.get("defaultsound").resolve(type.path).toString())); + return paths.toArray(Path.class); } - public enum BGMType { - SELECT("select.wav"), - DECIDE("decide.wav"); + public String getSound(SoundType sound) { + return soundmap.get(sound); + } + + public void play(SoundType sound, boolean loop) { + final String path = soundmap.get(sound); + if (path != null) { + main.getAudioProcessor().play(path, main.getConfig().getAudioConfig().getSystemvolume(), loop); + } + } + + public void stop(SoundType sound) { + final String path = soundmap.get(sound); + if (path != null) { + main.getAudioProcessor().stop(path); + } + } + + public enum SoundType { + SCRATCH("scratch.wav",false), + FOLDER_OPEN("f-open.wav",false), + FOLDER_CLOSE("f-close.wav",false), + OPTION_CHANGE("o-change.wav",false), + OPTION_OPEN("o-open.wav",false), + OPTION_CLOSE("o-close.wav",false), + PLAY_READY("playready.wav",false), + PLAY_STOP("playstop.wav",false), + RESULT_CLEAR("clear.wav",false), + RESULT_FAIL("fail.wav",false), + RESULT_CLOSE("resultclose.wav",false), + GUIDESE_PG("guide-pg.wav",false), + GUIDESE_GR("guide-gr.wav",false), + GUIDESE_GD("guide-gd.wav",false), + GUIDESE_BD("guide-bd.wav",false), + GUIDESE_PR("guide-pr.wav",false), + GUIDESE_MS("guide-ms.wav",false), + SELECT("select.wav",true), + DECIDE("decide.wav",true); + public final boolean isBGM; public final String path; - private BGMType(String path) { + private SoundType(String path, boolean isBGM) { this.path = path; + this.isBGM = isBGM; } - - } + } } \ No newline at end of file From 0cc3a62a62ca02c895cdf6638e98618593e7c5b0 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:40:23 +0900 Subject: [PATCH 19/74] EventFactory : refactor --- .../beatoraja/skin/property/EventFactory.java | 88 +++++++++---------- 1 file changed, 40 insertions(+), 48 deletions(-) diff --git a/src/bms/player/beatoraja/skin/property/EventFactory.java b/src/bms/player/beatoraja/skin/property/EventFactory.java index a5789acb..0e5ee3e1 100644 --- a/src/bms/player/beatoraja/skin/property/EventFactory.java +++ b/src/bms/player/beatoraja/skin/property/EventFactory.java @@ -1,28 +1,20 @@ package bms.player.beatoraja.skin.property; -import bms.player.beatoraja.MainState; -import bms.player.beatoraja.PlayConfig; -import bms.player.beatoraja.BMSPlayerMode; -import bms.player.beatoraja.PlayerConfig; -import bms.player.beatoraja.PlayerInformation; +import bms.player.beatoraja.*; import bms.player.beatoraja.config.KeyConfiguration; import bms.player.beatoraja.MainState.MainStateType; -import bms.player.beatoraja.ir.IRChartData; -import bms.player.beatoraja.ir.IRConnection; -import bms.player.beatoraja.ir.IRCourseData; +import bms.player.beatoraja.ir.*; import bms.player.beatoraja.play.JudgeAlgorithm; import bms.player.beatoraja.play.TargetProperty; import bms.player.beatoraja.result.*; import bms.player.beatoraja.select.BarSorter; import bms.player.beatoraja.select.MusicSelector; -import bms.player.beatoraja.select.bar.Bar; -import bms.player.beatoraja.select.bar.GradeBar; -import bms.player.beatoraja.select.bar.SongBar; +import bms.player.beatoraja.select.bar.*; import bms.player.beatoraja.song.SongData; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.MathUtils; -import static bms.player.beatoraja.select.MusicSelector.SOUND_OPTIONCHANGE; +import static bms.player.beatoraja.SystemSoundManager.SoundType.OPTION_CHANGE; import java.awt.*; import java.io.IOException; @@ -86,7 +78,7 @@ public enum EventType { for(;mode < MusicSelector.MODE.length && MusicSelector.MODE[mode] != config.getMode();mode++); config.setMode(MusicSelector.MODE[(mode + (arg1 >= 0 ? 1 : MusicSelector.MODE.length - 1)) % MusicSelector.MODE.length]); selector.getBarRender().updateBar(); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), /** @@ -97,7 +89,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; selector.setSort((selector.getSort() + (arg1 >= 0 ? 1 : BarSorter.values().length - 1)) % BarSorter.values().length); selector.getBarRender().updateBar(); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), /** @@ -165,7 +157,7 @@ public enum EventType { if(state instanceof MusicSelector) { PlayerConfig config = state.resource.getPlayerConfig(); config.setGauge((config.getGauge() + (arg1 >= 0 ? 1 : 5)) % 6); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), /** @@ -175,7 +167,7 @@ public enum EventType { if(state instanceof MusicSelector) { PlayerConfig config = state.resource.getPlayerConfig(); config.setRandom((config.getRandom() + (arg1 >= 0 ? 1 : 9)) % 10); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), /** @@ -185,7 +177,7 @@ public enum EventType { if(state instanceof MusicSelector) { PlayerConfig config = state.resource.getPlayerConfig(); config.setRandom2((config.getRandom2() + (arg1 >= 0 ? 1 : 9)) % 10); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), /** @@ -195,7 +187,7 @@ public enum EventType { if(state instanceof MusicSelector) { PlayerConfig config = state.resource.getPlayerConfig(); config.setDoubleoption((config.getDoubleoption() + (arg1 >= 0 ? 1 : 3)) % 4); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), /** @@ -206,7 +198,7 @@ public enum EventType { PlayConfig pc = ((MusicSelector)state).getSelectedBarPlayConfig(); if (pc != null) { pc.setFixhispeed((pc.getFixhispeed() + (arg1 >= 0 ? 1 : 4)) % 5); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -221,7 +213,7 @@ public enum EventType { hispeed = MathUtils.clamp(hispeed, PlayConfig.HISPEED_MIN, PlayConfig.HISPEED_MAX); if(hispeed != pc.getHispeed()) { pc.setHispeed(hispeed); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -237,7 +229,7 @@ public enum EventType { duration = MathUtils.clamp(duration, PlayConfig.DURATION_MIN, PlayConfig.DURATION_MAX); if(duration != pc.getDuration()) { pc.setDuration(duration); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -246,7 +238,7 @@ public enum EventType { PlayConfig pc = ((MusicSelector)state).getSelectedBarPlayConfig(); if (pc != null) { pc.setHispeedAutoAdjust(!pc.isEnableHispeedAutoAdjust()); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -288,13 +280,13 @@ public enum EventType { bga(72, (state, arg1) -> { if(state instanceof MusicSelector) { state.main.getConfig().setBga((state.resource.getConfig().getBga() + (arg1 >= 0 ? 1 : 2)) % 3); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), bgaexpand(73, (state, arg1) -> { if(state instanceof MusicSelector) { state.main.getConfig().setBgaExpand((state.resource.getConfig().getBgaExpand() + (arg1 >= 0 ? 1 : 2)) % 3); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), notesdisplaytiming(74, (state, arg1) -> { @@ -306,7 +298,7 @@ public enum EventType { if(inc != 0) { config.setJudgetiming(config.getJudgetiming() + inc); if(state instanceof MusicSelector) { - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -314,7 +306,7 @@ public enum EventType { final PlayerConfig config = state.resource.getPlayerConfig(); config.setNotesDisplayTimingAutoAdjust(!config.isNotesDisplayTimingAutoAdjust()); if(state instanceof MusicSelector) { - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } }), target(77, (state, arg1) -> { @@ -335,7 +327,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; final int gaslength = 5; selector.resource.getPlayerConfig().setGaugeAutoShift((selector.resource.getPlayerConfig().getGaugeAutoShift() + (arg1 >= 0 ?1 : gaslength - 1)) % gaslength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), bottomshiftablegauge(341, (state, arg1) -> { @@ -343,7 +335,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; final int gaugelength = 3; selector.resource.getPlayerConfig().setBottomShiftableGauge((selector.resource.getPlayerConfig().getBottomShiftableGauge() + (arg1 >= 0 ? 1 : gaugelength - 1)) % gaugelength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), /** @@ -352,17 +344,17 @@ public enum EventType { rival(79, (state, arg1) -> { if(state instanceof MusicSelector) { final MusicSelector selector = (MusicSelector) state; - PlayerInformation[] rivals = state.main.getRivalDataAccessor().getRivals(); + final RivalDataAccessor rivals = state.main.getRivalDataAccessor(); int index = -1; - for(int i = 0;i < rivals.length;i++) { - if(selector.getRival() == rivals[i]) { + for(int i = 0;i < rivals.getRivalCount();i++) { + if(selector.getRival() == rivals.getRivalInformation(i)) { index = i; break; } } - index = (index + (arg1 >= 0 ? 2 : rivals.length + 1)) % (rivals.length + 1) - 1; - selector.setRival(index != -1 ? rivals[index] : null); - selector.play(SOUND_OPTIONCHANGE); + index = (index + (arg1 >= 0 ? 2 : rivals.getRivalCount() + 1)) % (rivals.getRivalCount() + 1) - 1; + selector.setRival(index != -1 ? rivals.getRivalInformation(index) : null); + selector.play(OPTION_CHANGE); } }), favorite_chart(90, (state, arg1) -> { @@ -409,7 +401,7 @@ public enum EventType { selector.main.getMessageRenderer().addMessage(message, 1200, Color.GREEN, 1); selector.getBarRender().updateBar(); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } } } @@ -465,7 +457,7 @@ public enum EventType { changeFav.accept(sd); selector.main.getMessageRenderer().addMessage(message, 1200, Color.GREEN, 1); selector.getBarRender().updateBar(); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } } } @@ -541,7 +533,7 @@ public enum EventType { PlayerConfig config = selector.resource.getPlayerConfig(); config.setLnmode((config.getLnmode() + (arg1 >= 0 ? 1 : lnmodelength - 1)) % lnmodelength); selector.getBarRender().updateBar(); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), autosavereplay1(321, changeAutoSaveReplay(0)), @@ -553,7 +545,7 @@ public enum EventType { PlayConfig pc = ((MusicSelector)state).getSelectedBarPlayConfig(); if (pc != null) { pc.setEnablelanecover(!pc.isEnablelanecover()); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -562,7 +554,7 @@ public enum EventType { PlayConfig pc = ((MusicSelector)state).getSelectedBarPlayConfig(); if (pc != null) { pc.setEnablelift(!pc.isEnablelift()); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -571,7 +563,7 @@ public enum EventType { PlayConfig pc = ((MusicSelector)state).getSelectedBarPlayConfig(); if (pc != null) { pc.setEnablehidden(!pc.isEnablehidden()); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } }), @@ -586,7 +578,7 @@ public enum EventType { for (int i = 0; i < algorithms.length; i++) { if (jt.equals(algorithms[i])) { pc.setJudgetype(algorithms[(arg1 >= 0 ? i + 1 : i + algorithms.length - 1) % algorithms.length]); - state.play(SOUND_OPTIONCHANGE); + state.play(OPTION_CHANGE); } } } @@ -597,7 +589,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setExtranoteDepth((config.getExtranoteDepth() + (arg1 >= 0 ? 1 : depthlength - 1)) % depthlength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), minemode(351, (state, arg1) -> { @@ -606,7 +598,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setMineMode((config.getMineMode() + (arg1 >= 0 ? 1 : modelength - 1)) % modelength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), scrollmode(352, (state, arg1) -> { @@ -615,7 +607,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setScrollMode((config.getScrollMode() + (arg1 >= 0 ? 1 : modelength - 1)) % modelength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), longnotemode(353, (state, arg1) -> { @@ -624,7 +616,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setLongnoteMode((config.getLongnoteMode() + (arg1 >= 0 ? 1 : modelength - 1)) % modelength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), seventonine_pattern(360, (state, arg1) -> { @@ -633,7 +625,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setSevenToNinePattern((config.getSevenToNinePattern() + (arg1 >= 0 ? 1 : patternlength - 1)) % patternlength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), seventonine_type(361, (state, arg1) -> { @@ -642,7 +634,7 @@ public enum EventType { final MusicSelector selector = (MusicSelector) state; PlayerConfig config = selector.resource.getPlayerConfig(); config.setSevenToNineType((config.getSevenToNineType() + (arg1 >= 0 ? 1 : typelength - 1)) % typelength); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }), ; @@ -679,7 +671,7 @@ private static BiConsumer changeAutoSaveReplay(final int ind final int length = AbstractResult.ReplayAutoSaveConstraint.values().length; asr[index] = (asr[index] + (arg1 >= 0 ? 1 : length - 1)) % length; selector.resource.getPlayerConfig().setAutoSaveReplay(asr); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); } }; } From e57f1991665a87e14b83dc53583073f71fe4f507 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:41:01 +0900 Subject: [PATCH 20/74] MusicDecide : refactor --- src/bms/player/beatoraja/decide/MusicDecide.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bms/player/beatoraja/decide/MusicDecide.java b/src/bms/player/beatoraja/decide/MusicDecide.java index fd6bcab5..6cb7d11b 100644 --- a/src/bms/player/beatoraja/decide/MusicDecide.java +++ b/src/bms/player/beatoraja/decide/MusicDecide.java @@ -6,6 +6,7 @@ import bms.player.beatoraja.skin.*; import static bms.player.beatoraja.skin.SkinProperty.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; /** * 曲決定部分。 @@ -16,8 +17,6 @@ public class MusicDecide extends MainState { private boolean cancel; - public static final int SOUND_DECIDE = 0; - public MusicDecide(MainController main) { super(main); } @@ -32,8 +31,7 @@ public void create() { public void prepare() { super.prepare(); - setSound(SOUND_DECIDE, "decide.wav", SoundType.BGM, false); - play(SOUND_DECIDE); + play(DECIDE); } public void render() { From 8233f15624835ec8ffd41bf3697bd8005db32818 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:46:46 +0900 Subject: [PATCH 21/74] BMSPlayer : refactor --- src/bms/player/beatoraja/play/BMSPlayer.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index 3713d0c5..de482291 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -2,6 +2,7 @@ import static bms.player.beatoraja.CourseData.CourseDataConstraint.*; import static bms.player.beatoraja.skin.SkinProperty.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import java.nio.file.Path; import java.util.*; @@ -423,13 +424,10 @@ public void create() { loadSkin(getSkinType()); - setSound(SOUND_READY, "playready.wav", SoundType.SOUND, false); - setSound(SOUND_PLAYSTOP, "playstop.wav", SoundType.SOUND, false); - - final String[] guideses = {"guide-pg.wav","guide-gr.wav","guide-gd.wav","guide-bd.wav","guide-pr.wav","guide-ms.wav"}; + final SystemSoundManager.SoundType[] guideses = {GUIDESE_PG,GUIDESE_GR,GUIDESE_GD,GUIDESE_BD,GUIDESE_PR,GUIDESE_MS}; for(int i = 0;i < 6;i++) { if(config.isGuideSE()) { - Path[] paths = getSoundPaths(guideses[i], SoundType.SOUND); + Path[] paths = main.getSoundManager().getSoundPaths(guideses[i]); if(paths.length > 0) { main.getAudioProcessor().setAdditionalKeySound(i, true, paths[0].toString()); main.getAudioProcessor().setAdditionalKeySound(i, false, paths[0].toString()); @@ -530,7 +528,7 @@ public void render() { + ((cmem - mem) / (1024 * 1024)) + "MB"); state = STATE_READY; timer.setTimerOn(TIMER_READY); - play(SOUND_READY); + play(PLAY_READY); Logger.getGlobal().info("STATE_READYに移行"); } if(!timer.isTimerOn(TIMER_PM_CHARA_1P_NEUTRAL) || !timer.isTimerOn(TIMER_PM_CHARA_2P_NEUTRAL)){ @@ -597,7 +595,7 @@ public void render() { bga.prepare(this); state = STATE_READY; timer.setTimerOn(TIMER_READY); - play(SOUND_READY); + play(PLAY_READY); Logger.getGlobal().info("STATE_READYに移行"); } break; @@ -708,7 +706,7 @@ public void render() { if (resource.mediaLoadFinished()) { main.getAudioProcessor().stop((Note) null); } - play(SOUND_PLAYSTOP); + play(PLAY_STOP); Logger.getGlobal().info("STATE_FAILEDに移行"); break; case PlayerConfig.GAUGEAUTOSHIFT_CONTINUE: @@ -978,7 +976,7 @@ public void stopPlay() { if (resource.mediaLoadFinished()) { main.getAudioProcessor().stop((Note) null); } - play(SOUND_PLAYSTOP); + play(PLAY_STOP); Logger.getGlobal().info("STATE_FAILEDに移行"); } } From 863da76be1c46785a8da31b99a6ddaaa260c0274 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:47:47 +0900 Subject: [PATCH 22/74] MusicResult : refactor --- src/bms/player/beatoraja/MainState.java | 4 +++ .../player/beatoraja/result/MusicResult.java | 33 +++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/bms/player/beatoraja/MainState.java b/src/bms/player/beatoraja/MainState.java index 50279965..6857ff11 100644 --- a/src/bms/player/beatoraja/MainState.java +++ b/src/bms/player/beatoraja/MainState.java @@ -240,6 +240,10 @@ public void stop(int id) { } } + public String getSound(SystemSoundManager.SoundType sound) { + return main.getSoundManager().getSound(sound); + } + public void play(SystemSoundManager.SoundType sound) { play(sound, false); } diff --git a/src/bms/player/beatoraja/result/MusicResult.java b/src/bms/player/beatoraja/result/MusicResult.java index 6042f678..64630c5b 100755 --- a/src/bms/player/beatoraja/result/MusicResult.java +++ b/src/bms/player/beatoraja/result/MusicResult.java @@ -2,6 +2,7 @@ import static bms.player.beatoraja.ClearType.*; import static bms.player.beatoraja.skin.SkinProperty.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import java.util.*; import java.util.logging.Logger; @@ -43,11 +44,6 @@ public void create() { resource.getPlayerConfig().getLnmode(), i) ? ReplayStatus.EXIST : ReplayStatus.NOT_EXIST ; } - final boolean isLoopSound = resource.getConfig().getAudioConfig().isLoopResultSound(); - setSound(SOUND_CLEAR, "clear.wav", SoundType.SOUND, isLoopSound); - setSound(SOUND_FAIL, "fail.wav", SoundType.SOUND, isLoopSound); - setSound(SOUND_CLOSE, "resultclose.wav", SoundType.SOUND, false); - property = ResultKeyProperty.get(resource.getBMSModel().getMode()); if (property == null) { property = ResultKeyProperty.BEAT_7K; @@ -145,13 +141,14 @@ public void prepare() { } final ScoreData cscore = resource.getCourseScoreData(); - play(newscore.getClear() != Failed.id && (cscore == null || cscore.getClear() != Failed.id) ? SOUND_CLEAR : SOUND_FAIL); + play(newscore.getClear() != Failed.id && (cscore == null || cscore.getClear() != Failed.id) ? RESULT_CLEAR : RESULT_FAIL + ,resource.getConfig().getAudioConfig().isLoopResultSound()); } public void shutdown() { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - stop(SOUND_CLOSE); + stop(RESULT_CLEAR); + stop(RESULT_FAIL); + stop(RESULT_CLOSE); } public void render() { @@ -246,10 +243,10 @@ public void render() { } else { if (time > getSkin().getScene()) { timer.switchTimer(TIMER_FADEOUT, true); - if (getSound(SOUND_CLOSE) != null) { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - play(SOUND_CLOSE); + if (getSound(RESULT_CLOSE) != null) { + stop(RESULT_CLEAR); + stop(RESULT_FAIL); + play(RESULT_CLOSE); } } } @@ -286,10 +283,10 @@ public void input() { timer.switchTimer(TIMER_RESULT_UPDATESCORE, true); } else if (state == STATE_OFFLINE || state == STATE_IR_FINISHED) { timer.switchTimer(TIMER_FADEOUT, true); - if (getSound(SOUND_CLOSE) != null) { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - play(SOUND_CLOSE); + if (getSound(RESULT_CLOSE) != null) { + stop(RESULT_CLEAR); + stop(RESULT_FAIL); + play(RESULT_CLOSE); } } } @@ -337,7 +334,7 @@ private void updateScoreDatabase() { resource.getPlayerConfig().getLnmode()); oldscore = oldsc != null ? oldsc : new ScoreData(); - getScoreDataProperty().setTargetScore(oldscore.getExscore(), resource.getRivalScoreData() != null ? resource.getRivalScoreData().getExscore() : 0, resource.getBMSModel().getTotalNotes()); + getScoreDataProperty().setTargetScore(oldscore.getExscore(), resource.getTargetScoreData() != null ? resource.getTargetScoreData().getExscore() : 0, resource.getBMSModel().getTotalNotes()); getScoreDataProperty().update(newscore); // duration average int count = 0; From f27eda58d856325148d564826eb7ca60850ebd2e Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:48:50 +0900 Subject: [PATCH 23/74] CourseResult : refactor, use MusicResult sounds if CourseResult sounds don't exist --- .../beatoraja/result/AbstractResult.java | 4 --- .../player/beatoraja/result/CourseResult.java | 34 ++++++++----------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/bms/player/beatoraja/result/AbstractResult.java b/src/bms/player/beatoraja/result/AbstractResult.java index bb7e507d..5527c602 100644 --- a/src/bms/player/beatoraja/result/AbstractResult.java +++ b/src/bms/player/beatoraja/result/AbstractResult.java @@ -56,10 +56,6 @@ public abstract class AbstractResult extends MainState { protected ReplayStatus[] saveReplay = new ReplayStatus[REPLAY_SIZE]; protected static final int REPLAY_SIZE = 4; - public static final int SOUND_CLEAR = 0; - public static final int SOUND_FAIL = 1; - public static final int SOUND_CLOSE = 2; - protected int gaugeType; /** diff --git a/src/bms/player/beatoraja/result/CourseResult.java b/src/bms/player/beatoraja/result/CourseResult.java index e4d4af3d..dd9c0bf5 100644 --- a/src/bms/player/beatoraja/result/CourseResult.java +++ b/src/bms/player/beatoraja/result/CourseResult.java @@ -2,6 +2,7 @@ import static bms.player.beatoraja.ClearType.*; import static bms.player.beatoraja.skin.SkinProperty.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import java.util.*; import java.util.logging.Logger; @@ -15,7 +16,6 @@ import bms.player.beatoraja.input.BMSPlayerInputProcessor; import bms.player.beatoraja.input.KeyBoardInputProcesseor.ControlKeys; import bms.player.beatoraja.ir.*; -import bms.player.beatoraja.select.MusicSelector; import bms.player.beatoraja.skin.SkinType; import bms.player.beatoraja.skin.property.EventFactory.EventType; @@ -40,11 +40,6 @@ public void create() { resource.getPlayerConfig().getLnmode(), i ,resource.getConstraint()) ? ReplayStatus.EXIST : ReplayStatus.NOT_EXIST ; } - final boolean isLoopSound = resource.getConfig().getAudioConfig().isLoopCourseResultSound(); - setSound(SOUND_CLEAR, "course_clear.wav", SoundType.SOUND, isLoopSound); - setSound(SOUND_FAIL, "course_fail.wav", SoundType.SOUND, isLoopSound); - setSound(SOUND_CLOSE, "course_close.wav", SoundType.SOUND, false); - for(int i = resource.getCourseGauge().size;i < resource.getCourseBMSModels().length;i++) { FloatArray[] list = new FloatArray[resource.getGrooveGauge().getGaugeTypeLength()]; for(int type = 0; type < list.length; type++) { @@ -156,13 +151,14 @@ public void prepare() { irprocess.start(); } - play(newscore.getClear() != Failed.id ? SOUND_CLEAR : SOUND_FAIL); + play(newscore.getClear() != Failed.id ? (getSound(COURSE_CLEAR) != null ? COURSE_CLEAR : RESULT_CLEAR) + : (getSound(COURSE_FAIL) != null ? COURSE_FAIL : RESULT_FAIL), resource.getConfig().getAudioConfig().isLoopCourseResultSound()); } public void shutdown() { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - stop(SOUND_CLOSE); + stop(getSound(COURSE_CLEAR) != null ? COURSE_CLEAR : RESULT_CLEAR); + stop(getSound(COURSE_FAIL) != null ? COURSE_FAIL : RESULT_FAIL); + stop(getSound(COURSE_CLOSE) != null ? COURSE_CLOSE : RESULT_CLOSE); } public void render() { @@ -182,10 +178,10 @@ public void render() { } } else if (time > getSkin().getScene()) { timer.switchTimer(TIMER_FADEOUT, true); - if(getSound(SOUND_CLOSE) != null) { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - play(SOUND_CLOSE); + if(getSound(COURSE_CLOSE) != null || getSound(RESULT_CLOSE) != null) { + stop(getSound(COURSE_CLEAR) != null ? COURSE_CLEAR : RESULT_CLEAR); + stop(getSound(COURSE_FAIL) != null ? COURSE_FAIL : RESULT_FAIL); + play(getSound(COURSE_CLOSE) != null ? COURSE_CLOSE : RESULT_CLOSE); } } @@ -214,10 +210,10 @@ public void input() { timer.switchTimer(TIMER_RESULT_UPDATESCORE, true); } else if (state == STATE_OFFLINE || state == STATE_IR_FINISHED){ timer.switchTimer(TIMER_FADEOUT, true); - if(getSound(SOUND_CLOSE) != null) { - stop(SOUND_CLEAR); - stop(SOUND_FAIL); - play(SOUND_CLOSE); + if(getSound(COURSE_CLOSE) != null || getSound(RESULT_CLOSE) != null) { + stop(getSound(COURSE_CLEAR) != null ? COURSE_CLEAR : RESULT_CLEAR); + stop(getSound(COURSE_FAIL) != null ? COURSE_FAIL : RESULT_FAIL); + play(getSound(COURSE_CLOSE) != null ? COURSE_CLOSE : RESULT_CLOSE); } } } @@ -264,7 +260,7 @@ public void updateScoreDatabase() { config.getLnmode(), random, resource.getConstraint()); oldscore = score != null ? score : new ScoreData(); - getScoreDataProperty().setTargetScore(oldscore.getExscore(), resource.getRivalScoreData() != null ? resource.getRivalScoreData().getExscore() : 0, + getScoreDataProperty().setTargetScore(oldscore.getExscore(), resource.getTargetScoreData() != null ? resource.getTargetScoreData().getExscore() : 0, Arrays.asList(resource.getCourseData().getSong()).stream().mapToInt(sd -> sd.getNotes()).sum()); getScoreDataProperty().update(newscore); From 33a17d3bfbdf7fa91f108f12a137d1e66dda1831 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Mon, 27 Nov 2023 20:50:32 +0900 Subject: [PATCH 24/74] MusicSelector : refactor --- .../player/beatoraja/SystemSoundManager.java | 5 ++- .../player/beatoraja/select/BarRenderer.java | 8 +++-- .../beatoraja/select/MusicSelectCommand.java | 13 +++---- .../select/MusicSelectInputProcessor.java | 35 ++++++++++--------- .../beatoraja/select/MusicSelector.java | 12 ++----- 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/bms/player/beatoraja/SystemSoundManager.java b/src/bms/player/beatoraja/SystemSoundManager.java index faf97c5c..a159a11b 100644 --- a/src/bms/player/beatoraja/SystemSoundManager.java +++ b/src/bms/player/beatoraja/SystemSoundManager.java @@ -71,7 +71,7 @@ public void shuffle() { main.getAudioProcessor().dispose(oldpath); } soundmap.put(sound, newpath); - return; + break; } } @@ -138,6 +138,9 @@ public enum SoundType { RESULT_CLEAR("clear.wav",false), RESULT_FAIL("fail.wav",false), RESULT_CLOSE("resultclose.wav",false), + COURSE_CLEAR("course_clear.wav",false), + COURSE_FAIL("course_fail.wav",false), + COURSE_CLOSE("course_close.wav",false), GUIDESE_PG("guide-pg.wav",false), GUIDESE_GR("guide-gr.wav",false), GUIDESE_GD("guide-gd.wav",false), diff --git a/src/bms/player/beatoraja/select/BarRenderer.java b/src/bms/player/beatoraja/select/BarRenderer.java index 92b15cd5..e14b2fa9 100644 --- a/src/bms/player/beatoraja/select/BarRenderer.java +++ b/src/bms/player/beatoraja/select/BarRenderer.java @@ -1,5 +1,7 @@ package bms.player.beatoraja.select; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; + import java.io.BufferedInputStream; import java.lang.reflect.Method; import java.nio.file.*; @@ -461,7 +463,7 @@ public void close() { final DirectoryBar parent = dir.size > 0 ? dir.last() : null; dir.addLast(current); updateBar(parent); - select.play(MusicSelector.SOUND_FOLDERCLOSE); + select.play(FOLDER_CLOSE); } public void addSearch(SearchWordBar bar) { @@ -866,12 +868,12 @@ public void input() { } while(mov > 0) { move(true); - select.play(MusicSelector.SOUND_SCRATCH); + select.play(SCRATCH); mov--; } while(mov < 0) { move(false); - select.play(MusicSelector.SOUND_SCRATCH); + select.play(SCRATCH); mov++; } } diff --git a/src/bms/player/beatoraja/select/MusicSelectCommand.java b/src/bms/player/beatoraja/select/MusicSelectCommand.java index 7e4904b1..31da7f30 100644 --- a/src/bms/player/beatoraja/select/MusicSelectCommand.java +++ b/src/bms/player/beatoraja/select/MusicSelectCommand.java @@ -1,6 +1,6 @@ package bms.player.beatoraja.select; -import static bms.player.beatoraja.select.MusicSelector.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import java.awt.Desktop; import java.io.IOException; @@ -13,9 +13,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import bms.player.beatoraja.PlayConfig; -import bms.player.beatoraja.PlayerConfig; -import bms.player.beatoraja.PlayerInformation; import bms.player.beatoraja.select.bar.*; import bms.player.beatoraja.song.SongData; @@ -53,7 +50,7 @@ public void execute(MusicSelector selector) { final int selectedreplay = selector.getSelectedReplay(); if (replays[(i + selectedreplay) % replays.length]) { selector.setSelectedReplay((i + selectedreplay) % replays.length); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); break; } } @@ -70,7 +67,7 @@ public void execute(MusicSelector selector) { final int selectedreplay = selector.getSelectedReplay(); if (replays[(selectedreplay + replays.length - i) % replays.length]) { selector.setSelectedReplay((selectedreplay + replays.length - i) % replays.length); - selector.play(SOUND_OPTIONCHANGE); + selector.play(OPTION_CHANGE); break; } } @@ -261,14 +258,14 @@ public void execute(MusicSelector selector) { (bar.getDirectory().size == 0 || !(bar.getDirectory().last() instanceof SameFolderBar))) { SongData sd = ((SongBar) current).getSongData(); bar.updateBar(new SameFolderBar(selector, sd.getFullTitle(), sd.getFolder())); - selector.play(SOUND_FOLDEROPEN); + selector.play(FOLDER_OPEN); } else if (current instanceof GradeBar) { List songbars = Arrays.asList(((GradeBar) current).getSongDatas()).stream() .distinct() .map(SongBar::new) .collect(Collectors.toList()); bar.updateBar(new ContainerBar(current.getTitle(), songbars.toArray(new Bar[songbars.size()]))); - selector.play(SOUND_FOLDEROPEN); + selector.play(FOLDER_OPEN); } } } diff --git a/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java b/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java index e949be8f..8cd74db6 100644 --- a/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java +++ b/src/bms/player/beatoraja/select/MusicSelectInputProcessor.java @@ -1,6 +1,7 @@ package bms.player.beatoraja.select; import bms.player.beatoraja.*; +import bms.player.beatoraja.SystemSoundManager.SoundType; import bms.player.beatoraja.input.BMSPlayerInputProcessor; import bms.player.beatoraja.input.KeyCommand; import bms.player.beatoraja.input.KeyBoardInputProcesseor.ControlKeys; @@ -10,7 +11,7 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; -import static bms.player.beatoraja.select.MusicSelector.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import static bms.player.beatoraja.skin.SkinProperty.*; import static bms.player.beatoraja.select.MusicSelectKeyProperty.MusicSelectKey.*; @@ -103,7 +104,7 @@ public void canceled() { isOptionKeyReleased = true; if(isOptionKeyPressed) { isOptionKeyPressed = false; - select.play(SOUND_OPTIONCLOSE); + select.play(OPTION_CLOSE); } } @@ -119,7 +120,7 @@ public void canceled() { if(isOptionKeyReleased) { isOptionKeyPressed = true; isOptionKeyReleased = false; - select.play(SOUND_OPTIONOPEN); + select.play(OPTION_OPEN); } if (property.isPressed(input, OPTION1_DOWN, true)) { select.executeEvent(EventType.option1p, 1); @@ -194,12 +195,12 @@ public void canceled() { while(mov > 0) { select.executeEvent(EventType.target, -1); - select.play(SOUND_SCRATCH); + select.play(SCRATCH); mov--; } while(mov < 0) { select.executeEvent(EventType.target, 1); - select.play(SOUND_SCRATCH); + select.play(SCRATCH); mov++; } } else if (input.isSelectPressed() && !input.startPressed()) { @@ -209,35 +210,35 @@ public void canceled() { if(isOptionKeyReleased) { isOptionKeyPressed = true; isOptionKeyReleased = false; - select.play(SOUND_OPTIONOPEN); + select.play(OPTION_OPEN); } if (property.isPressed(input, JUDGEWINDOW_UP, true)) { config.setCustomJudge(!config.isCustomJudge()); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, CONSTANT, true)) { config.setScrollMode(config.getScrollMode() == 1 ? 0 : 1); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, JUDGEAREA, true)) { config.setShowjudgearea(!config.isShowjudgearea()); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, LEGACYNOTE, true)) { config.setLongnoteMode(config.getLongnoteMode() == 1 ? 0 : 1); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, MARKNOTE, true)) { config.setMarkprocessednote(!config.isMarkprocessednote()); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, BPMGUIDE, true)) { config.setBpmguide(!config.isBpmguide()); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } if (property.isPressed(input, NOMINE, true)) { config.setMineMode(config.getMineMode() == 1 ? 0 : 1); - select.play(SOUND_OPTIONCHANGE); + select.play(OPTION_CHANGE); } } else if (input.getControlKeyState(ControlKeys.NUM5) || (input.startPressed() && input.isSelectPressed())) { bar.resetInput(); @@ -246,7 +247,7 @@ public void canceled() { if(isOptionKeyReleased) { isOptionKeyPressed = true; isOptionKeyReleased = false; - select.play(SOUND_OPTIONOPEN); + select.play(OPTION_OPEN); } if (property.isPressed(input, BGA_DOWN, true)) { select.executeEvent(EventType.bga); @@ -306,10 +307,10 @@ public void canceled() { select.selectSong(config.isEventMode() ? BMSPlayerMode.PLAY : ((select.getSelectedReplay() >= 0) ? BMSPlayerMode.getReplayMode(select.getSelectedReplay()) : BMSPlayerMode.PLAY)); } } else { - if (property.isPressed(input, FOLDER_OPEN, true) || input.isControlKeyPressed(ControlKeys.RIGHT) || input.isControlKeyPressed(ControlKeys.ENTER)) { + if (property.isPressed(input, MusicSelectKey.FOLDER_OPEN, true) || input.isControlKeyPressed(ControlKeys.RIGHT) || input.isControlKeyPressed(ControlKeys.ENTER)) { // open folder if (bar.updateBar(current)) { - select.play(SOUND_FOLDEROPEN); + select.play(SoundType.FOLDER_OPEN); } } } @@ -324,7 +325,7 @@ public void canceled() { select.executeEvent(EventType.open_document); } // close folder - if (property.isPressed(input, FOLDER_CLOSE, true) || input.isControlKeyPressed(ControlKeys.LEFT)) { + if (property.isPressed(input, MusicSelectKey.FOLDER_CLOSE, true) || input.isControlKeyPressed(ControlKeys.LEFT)) { input.resetKeyChangedTime(1); bar.close(); } diff --git a/src/bms/player/beatoraja/select/MusicSelector.java b/src/bms/player/beatoraja/select/MusicSelector.java index dee86b5b..947a4ccf 100644 --- a/src/bms/player/beatoraja/select/MusicSelector.java +++ b/src/bms/player/beatoraja/select/MusicSelector.java @@ -1,6 +1,7 @@ package bms.player.beatoraja.select; import static bms.player.beatoraja.skin.SkinProperty.*; +import static bms.player.beatoraja.SystemSoundManager.SoundType.*; import java.nio.file.*; import java.util.logging.Logger; @@ -165,13 +166,6 @@ public ScoreDataCache getRivalScoreDataCache() { 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); play = null; showNoteGraph = false; @@ -188,7 +182,7 @@ public void create() { } preview = new PreviewMusicProcessor(main.getAudioProcessor(), resource.getConfig()); - preview.setDefault(getSound(SOUND_BGM)); + preview.setDefault(getSound(SELECT)); final BMSPlayerInputProcessor input = main.getInputProcessor(); PlayModeConfig pc = (config.getMusicselectinput() == 0 ? config.getMode7() @@ -411,7 +405,7 @@ public void changeState(MainStateType type) { public void select(Bar current) { if (current instanceof DirectoryBar) { if (bar.updateBar(current)) { - play(SOUND_FOLDEROPEN); + play(FOLDER_OPEN); } execute(MusicSelectCommand.RESET_REPLAY); } else { From 3fef50cd3a0e014f12f72c221523324c144ed067 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Tue, 28 Nov 2023 02:22:18 +0900 Subject: [PATCH 25/74] MainState : remove unused methods --- src/bms/player/beatoraja/MainState.java | 59 ------------------------- 1 file changed, 59 deletions(-) diff --git a/src/bms/player/beatoraja/MainState.java b/src/bms/player/beatoraja/MainState.java index 6857ff11..84e5d1c5 100644 --- a/src/bms/player/beatoraja/MainState.java +++ b/src/bms/player/beatoraja/MainState.java @@ -181,65 +181,6 @@ public enum SoundType { BGM, SOUND } - @Deprecated - public void setSound(int id, String path, SoundType type, boolean loop) { - for(Path p :getSoundPaths(path, type)) { - String newpath = p.toString(); - String oldpath = soundmap.get(id); - if (newpath.equals(oldpath)) { - return; - } - if (oldpath != null) { - main.getAudioProcessor().dispose(oldpath); - } - soundmap.put(id, newpath); - soundloop.put(id, loop); - return; - } - } - - @Deprecated - public Path[] getSoundPaths(String filename, SoundType type) { - Path p = null; - switch (type) { - case BGM: - p = main.getSoundManager().getBGMPath(); - break; - case SOUND: - p = main.getSoundManager().getSoundPath(); - break; - } - - Array paths = new Array(); - if(p != null) { - paths.addAll(AudioDriver.getPaths(p.resolve(filename).toString())); - } - paths.addAll(AudioDriver.getPaths("defaultsound/" + filename.substring(filename.contains("/") || filename.contains("\\") ? Math.max(filename.lastIndexOf('/'),filename.lastIndexOf('\\')) + 1 : 0))); - return paths.toArray(Path.class); - } - - @Deprecated - public String getSound(int id) { - return soundmap.get(id); - } - - @Deprecated - public void play(int id) { - final String path = soundmap.get(id); - if (path != null) { - main.getAudioProcessor().play(path, resource.getConfig().getAudioConfig().getSystemvolume(), - soundloop.get(id)); - } - } - - @Deprecated - public void stop(int id) { - final String path = soundmap.get(id); - if (path != null) { - main.getAudioProcessor().stop(path); - } - } - public String getSound(SystemSoundManager.SoundType sound) { return main.getSoundManager().getSound(sound); } From 036c9353e52349194e4d8208611eb55d9cfc084c Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sat, 2 Dec 2023 03:55:23 +0900 Subject: [PATCH 26/74] IntegerPropertyFactory : fix option_1p/option_2p/option_dp --- src/bms/player/beatoraja/play/BMSPlayer.java | 4 +++ .../skin/property/IntegerPropertyFactory.java | 27 ++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/bms/player/beatoraja/play/BMSPlayer.java b/src/bms/player/beatoraja/play/BMSPlayer.java index 2468b4f3..27afc737 100755 --- a/src/bms/player/beatoraja/play/BMSPlayer.java +++ b/src/bms/player/beatoraja/play/BMSPlayer.java @@ -1010,6 +1010,10 @@ public int getJudgeCount(int judge, boolean fast) { public JudgeManager getJudgeManager() { return judge; } + + public ReplayData getOptionInformation() { + return playinfo; + } public void update(int judge, long time) { notes = this.judge.getPastNotes(); diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index 1720f729..cb3e2f83 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -1030,9 +1030,30 @@ public enum IndexType { }), sort(12, (state) -> ((state instanceof MusicSelector) ? ((MusicSelector) state).getSort() : Integer.MIN_VALUE)), gaugetype_1p(40, (state) -> (state.resource.getPlayerConfig().getGauge())), - option_1p(42, (state) -> (state.resource.getPlayerConfig().getRandom())), - option_2p(43, (state) -> (state.resource.getPlayerConfig().getRandom2())), - option_dp(54, (state) -> (state.resource.getPlayerConfig().getDoubleoption())), + option_1p(42, (state) -> { + if(state instanceof BMSPlayer) { + return ((BMSPlayer)state).getOptionInformation().randomoption; + } else if(state instanceof AbstractResult) { + return state.resource.getReplayData().randomoption; + } + return state.resource.getPlayerConfig().getRandom(); + }), + option_2p(43, (state) -> { + if(state instanceof BMSPlayer) { + return ((BMSPlayer)state).getOptionInformation().randomoption2; + } else if(state instanceof AbstractResult) { + return state.resource.getReplayData().randomoption2; + } + return state.resource.getPlayerConfig().getRandom2(); + }), + option_dp(54, (state) -> { + if(state instanceof BMSPlayer) { + return ((BMSPlayer)state).getOptionInformation().doubleoption; + } else if(state instanceof AbstractResult) { + return state.resource.getReplayData().doubleoption; + } + return state.resource.getPlayerConfig().getDoubleoption(); + }), hsfix(55, (state) -> { if (state.resource.getSongdata() != null) { From b324748198bea36360b5a4483d3b27589df6dd97 Mon Sep 17 00:00:00 2001 From: exch-bms2 Date: Sat, 2 Dec 2023 03:58:09 +0900 Subject: [PATCH 27/74] IntegerPropertyFactory : add option_target1_1p/2p/dp --- .../skin/property/IntegerPropertyFactory.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java index cb3e2f83..c5edd7d9 100644 --- a/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java +++ b/src/bms/player/beatoraja/skin/property/IntegerPropertyFactory.java @@ -1083,6 +1083,33 @@ public enum IndexType { } return Integer.MIN_VALUE; }), + + option_target1_1p(61, (state) -> { + final ScoreData rival = (state instanceof BMSPlayer || state instanceof AbstractResult) + ? state.main.getPlayerResource().getTargetScoreData() : state.getScoreDataProperty().getRivalScoreData(); + if(rival != null && rival.getOption() >= 0) { + return rival.getOption() % 10; + } + return Integer.MIN_VALUE; + }), + option_target1_2p(62, (state) -> { + final ScoreData rival = (state instanceof BMSPlayer || state instanceof AbstractResult) + ? state.main.getPlayerResource().getTargetScoreData() : state.getScoreDataProperty().getRivalScoreData(); + if(rival != null && rival.getOption() >= 0) { + return (rival.getOption() / 10) % 10; + } + return Integer.MIN_VALUE; + }), + option_target1_dp(63, (state) -> { + final ScoreData rival = (state instanceof BMSPlayer || state instanceof AbstractResult) + ? state.main.getPlayerResource().getTargetScoreData() : state.getScoreDataProperty().getRivalScoreData(); + if(rival != null && rival.getOption() >= 0) { + return (rival.getOption() / 100) % 10; + } + return Integer.MIN_VALUE; + }), + // TODO 64-69はtarget2, target3に割り当てたい + hispeedautoadjust(342, (state) -> { PlayConfig pc = null; if(state instanceof MusicSelector) { From a1156480aca4bf488f4aeef0bc245def0fc73b6f Mon Sep 17 00:00:00 2001 From: SackMagiclight <20876249+SackMagiclight@users.noreply.github.com> Date: Sun, 3 Dec 2023 18:32:57 +0900 Subject: [PATCH 28/74] copy clipboard when screenshot --- src/bms/player/beatoraja/Config.java | 9 +++ .../external/ScreenShotFileExporter.java | 72 ++++++++++++++++++- .../launcher/PlayConfigurationView.fxml | 1 + .../launcher/PlayConfigurationView.java | 5 ++ src/resources/UIResources.properties | 3 +- src/resources/UIResources_ja_JP.properties | 11 +-- 6 files changed, 93 insertions(+), 8 deletions(-) diff --git a/src/bms/player/beatoraja/Config.java b/src/bms/player/beatoraja/Config.java index 3f4d92fe..b4bb4ccc 100644 --- a/src/bms/player/beatoraja/Config.java +++ b/src/bms/player/beatoraja/Config.java @@ -154,6 +154,7 @@ public class Config implements Validatable { private int irSendCount = 5; private boolean useDiscordRPC = false; + private boolean setClipboardScreenshot = false; private static final String[] DEFAULT_TABLEURL = { "http://bmsnormal2.syuriken.jp/table.html", "http://bmsnormal2.syuriken.jp/table_insane.html", @@ -375,6 +376,14 @@ public boolean isUseDiscordRPC() { public void setUseDiscordRPC(boolean useDiscordRPC) { this.useDiscordRPC = useDiscordRPC; } + + public boolean isSetClipboardWhenScreenshot() { + return setClipboardScreenshot; + } + + public void setClipboardWhenScreenshot(boolean setClipboardScreenshot) { + this.setClipboardScreenshot = setClipboardScreenshot; + } public boolean isUpdatesong() { return updatesong; diff --git a/src/bms/player/beatoraja/external/ScreenShotFileExporter.java b/src/bms/player/beatoraja/external/ScreenShotFileExporter.java index 01a64f9a..092e15e2 100644 --- a/src/bms/player/beatoraja/external/ScreenShotFileExporter.java +++ b/src/bms/player/beatoraja/external/ScreenShotFileExporter.java @@ -2,13 +2,21 @@ import static bms.player.beatoraja.skin.SkinProperty.*; +import java.awt.Image; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.logging.Logger; +import javax.imageio.ImageIO; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; @@ -75,6 +83,8 @@ public boolean send(MainState currentState, byte[] pixels) { Logger.getGlobal().info("スクリーンショット保存:" + path); pixmap.dispose(); currentState.main.getMessageRenderer().addMessage("Screen shot saved : " + path, 2000, Color.GOLD, 0); + + this.sendClipboard(currentState, path); return true; } catch (Exception e) { e.printStackTrace(); @@ -82,5 +92,63 @@ public boolean send(MainState currentState, byte[] pixels) { pixmap.dispose(); return false; } + + private void sendClipboard(MainState currentState, String path) { + if (!currentState.resource.getConfig().isSetClipboardWhenScreenshot()) { + // スクショのクリップボードコピーが有効でないなら終わる + return; + } + try { + // バイナリ一致させるためにファイルからデータ取得 + BufferedImage image = ImageIO.read(new File(path)); + + // ARGBからRGBへ + int width = image.getWidth(); + int height = image.getHeight(); + BufferedImage output = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR); + int px[] = new int[width * height]; + image.getRGB(0, 0, width, height, px, 0, width); + output.setRGB(0, 0, width, height, px, 0, width); + + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + ImageTransferable imageTransferable = new ImageTransferable(output); + clipboard.setContents(imageTransferable, null); + Logger.getGlobal().info("スクリーンショット保存: Clipboard"); + currentState.main.getMessageRenderer().addMessage("Screen shot saved : Clipboard", 2000, Color.GOLD, 0); + } catch (Exception e) { + e.printStackTrace(); + } + } +} + +class ImageTransferable implements Transferable { + private Image image; + + public ImageTransferable(Image image) { + this.image = image; + } + @Override + public boolean isDataFlavorSupported(DataFlavor flavor) { + for (DataFlavor f : getTransferDataFlavors()) { + if (f.equals(flavor)) { + return true; + } + } + return false; + } + + @Override + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + if (flavor.equals(DataFlavor.imageFlavor)) { + return image; + } + throw new UnsupportedFlavorException(flavor); + } + + @Override + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] { DataFlavor.imageFlavor }; + } } diff --git a/src/bms/player/beatoraja/launcher/PlayConfigurationView.fxml b/src/bms/player/beatoraja/launcher/PlayConfigurationView.fxml index 9d72180c..d588ee27 100644 --- a/src/bms/player/beatoraja/launcher/PlayConfigurationView.fxml +++ b/src/bms/player/beatoraja/launcher/PlayConfigurationView.fxml @@ -383,6 +383,7 @@ +