Skip to content

Commit

Permalink
Merge pull request #64 from excln/extend-skin-property
Browse files Browse the repository at this point in the history
Extend skin property and refactor JudgeManager and KeyInputProcessor for extension
  • Loading branch information
exch-bms2 authored Jul 25, 2017
2 parents f339803 + 316ac80 commit 6f197f2
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 94 deletions.
3 changes: 2 additions & 1 deletion src/bms/player/beatoraja/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public class MainController extends ApplicationAdapter {

private ScreenShotThread screenshot;

private long[] timer = new long[256];
public static final int timerCount = 2048;
private long[] timer = new long[timerCount];

public MainController(Path f, Config config, int auto, boolean songUpdated) {
this.auto = auto;
Expand Down
10 changes: 8 additions & 2 deletions src/bms/player/beatoraja/play/BMSPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class BMSPlayer extends MainState {
private BMSModel model;

private LaneRenderer lanerender;
private LaneProperty laneProperty;
private JudgeManager judge;

private BGAProcessor bga;
Expand Down Expand Up @@ -231,6 +232,7 @@ private SkinType getSkinType() {
public void create() {
final MainController main = getMainController();
final PlayerResource resource = main.getPlayerResource();
laneProperty = new LaneProperty(model.getMode());
judge = new JudgeManager(this);
control = new ControlInputProcessor(this, autoplay);
keyinput = new KeyInputProccessor(this, model.getMode());
Expand Down Expand Up @@ -536,6 +538,10 @@ public LaneRenderer getLanerender() {
return lanerender;
}

public LaneProperty getLaneProperty() {
return laneProperty;
}

private void saveConfig() {
final PlayerResource resource = getMainController().getPlayerResource();
for (CourseData.CourseDataConstraint c : resource.getConstraint()) {
Expand Down Expand Up @@ -790,8 +796,8 @@ public int getNumberValue(int id) {
case VALUE_JUDGE_3P_DURATION:
return judge.getRecentJudgeTiming();
}
if (id >= VALUE_JUDGE_1P_SCRATCH && id < VALUE_JUDGE_1P_SCRATCH + 20) {
return judge.getJudge()[id - VALUE_JUDGE_1P_SCRATCH];
if (SkinPropertyMapper.isKeyJudgeValueId(id)) {
return judge.getJudge(id);
}
return super.getNumberValue(id);
}
Expand Down
61 changes: 20 additions & 41 deletions src/bms/player/beatoraja/play/JudgeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Arrays;

import bms.player.beatoraja.*;
import bms.player.beatoraja.skin.SkinPropertyMapper;
import com.badlogic.gdx.utils.FloatArray;

import bms.model.*;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class JudgeManager {
/**
* ボムの表示開始時間
*/
private int[] judge;
private int[][] judge;
/**
* 現在表示中の判定
*/
Expand Down Expand Up @@ -76,6 +77,7 @@ public class JudgeManager {
private int[] sckeyassign;
private int[] sckey;
private int[] offset;
private int[] player;
/**
* HCNの増減間隔(ms)
*/
Expand Down Expand Up @@ -111,7 +113,6 @@ public JudgeManager(BMSPlayer main) {

public void init(BMSModel model, PlayerResource resource) {
prevtime = 0;
judge = new int[20];
judgenow = new int[((PlaySkin) main.getSkin()).getJudgeregion()];
judgecombo = new int[((PlaySkin) main.getSkin()).getJudgeregion()];
score = new IRScoreData(model.getMode());
Expand All @@ -124,40 +125,13 @@ public void init(BMSModel model, PlayerResource resource) {
JudgeProperty rule = BMSPlayerRule.getBMSPlayerRule(model.getMode()).judge;
pmsjudge = rule.pms;

switch (model.getMode()) {
case BEAT_5K:
keyassign = new int[] { 0, 1, 2, 3, 4, -1, -1, 5, 5 };
break;
case BEAT_7K:
keyassign = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 7 };
break;
case BEAT_10K:
keyassign = new int[] { 0, 1, 2, 3, 4, -1, -1, 5, 5, 6, 7, 8, 9, 10, -1, -1, 11, 11 };
break;
case BEAT_14K:
keyassign = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15 };
break;
case POPN_9K:
keyassign = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
break;
default:
keyassign = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 7 };
break;
}
offset = new int[model.getMode().key];
sckeyassign = new int[model.getMode().key];
keyassign = main.getLaneProperty().getKeyLaneAssign();
offset = main.getLaneProperty().getLaneSkinOffset();
player = main.getLaneProperty().getLanePlayer();
sckeyassign = main.getLaneProperty().getLaneScratchAssign();
sckey = new int[model.getMode().scratchKey.length];
for(int i = 0, sc = 0;i < offset.length;i++) {
if(model.getMode().isScratchKey(i)) {
sckeyassign[i] = sc;
offset[i] = sc * 10;
sc++;
} else {
sckeyassign[i] = -1;
offset[i] = (i / (model.getMode().key / model.getMode().player)) * 10 + i % (model.getMode().key / model.getMode().player) + 1;
}
}

judge = new int[model.getMode().player][model.getMode().key / model.getMode().player + 1];
processing = new LongNote[sckeyassign.length];
passing = new LongNote[sckeyassign.length];
passingcount = new int[sckeyassign.length];
Expand Down Expand Up @@ -487,12 +461,13 @@ public void update(final int time) {
// LN処理タイマー
// TODO processing値の変化のときのみ実行したい
// TODO HCNは別タイマーにするかも
int timerId = SkinPropertyMapper.holdTimerId(player[lane], offset[lane]);
if (processing[lane] != null || (passing[lane] != null && inclease[lane])) {
if (main.getTimer()[TIMER_HOLD_1P_SCRATCH + offset[lane]] == Long.MIN_VALUE) {
main.getTimer()[TIMER_HOLD_1P_SCRATCH + offset[lane]] = main.getNowTime();
if (main.getTimer()[timerId] == Long.MIN_VALUE) {
main.getTimer()[timerId] = main.getNowTime();
}
} else {
main.getTimer()[TIMER_HOLD_1P_SCRATCH + offset[lane]] = Long.MIN_VALUE;
main.getTimer()[timerId] = Long.MIN_VALUE;
}
}
}
Expand All @@ -517,9 +492,9 @@ private void update(int lane, Note n, int time, int judge, int fast) {
coursecombo = 0;
}

this.judge[offset[lane]] = judge == 0 ? 1 : judge * 2 + (fast > 0 ? 0 : 1);
this.judge[player[lane]][offset[lane]] = judge == 0 ? 1 : judge * 2 + (fast > 0 ? 0 : 1);
if (judge < 2) {
main.getTimer()[TIMER_BOMB_1P_SCRATCH + offset[lane]] = main.getNowTime();
main.getTimer()[SkinPropertyMapper.bombTimerId(player[lane], offset[lane])] = main.getNowTime();
}

final int lanelength = sckeyassign.length;
Expand Down Expand Up @@ -613,8 +588,12 @@ public int getJudgeCount(int judge, boolean fast) {
return score.getJudgeCount(judge, fast);
}

public int[] getJudge() {
return judge;
public int getJudge(int timerId) {
int player = SkinPropertyMapper.getKeyJudgeValuePlayer(timerId);
int offset = SkinPropertyMapper.getKeyJudgeValueOffset(timerId);
if (player >= judge.length || offset >= judge[player].length)
return -1;
return judge[player][offset];
}

public int[] getNowJudge() {
Expand Down
80 changes: 32 additions & 48 deletions src/bms/player/beatoraja/play/KeyInputProccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import bms.model.TimeLine;
import bms.player.beatoraja.input.BMSPlayerInputProcessor;
import bms.player.beatoraja.input.KeyInputLog;
import bms.player.beatoraja.skin.SkinPropertyMapper;

/**
* キー入力処理用スレッド
Expand All @@ -20,19 +21,15 @@
class KeyInputProccessor {

private final BMSPlayer player;
private final boolean ispms;

private final int[] key_offset = { 1, 2, 3, 4, 5, 6, 7, 0, 11, 12, 13, 14, 15, 16, 17, 10 };

private JudgeThread judge;

private int prevtime = -1;
private int scratch1;
private int scratch2;
private int[] scratch;

public KeyInputProccessor(BMSPlayer player, Mode mode) {
this.player = player;
ispms = mode == Mode.POPN_5K || mode == Mode.POPN_9K;
this.scratch = new int[2];
}

public void startJudge(BMSModel model, List<KeyInputLog> keylog) {
Expand All @@ -47,64 +44,51 @@ public void input() {
final JudgeManager judge = player.getJudgeManager();
final boolean[] keystate = player.getMainController().getInputProcessor().getKeystate();

for (int lane = 0; lane < 16; lane++) {
for (int lane = 0; lane < player.getLaneProperty().getLaneSkinOffset().length; lane++) {
// キービームフラグON/OFF
if (ispms) {
if (keystate[lane]) {
if (timer[TIMER_KEYON_1P_KEY1 + lane] == Long.MIN_VALUE) {
timer[TIMER_KEYON_1P_KEY1 + lane] = now;
timer[TIMER_KEYOFF_1P_KEY1 + lane] = Long.MIN_VALUE;
}
} else {
if (timer[TIMER_KEYOFF_1P_KEY1 + lane] == Long.MIN_VALUE) {
timer[TIMER_KEYOFF_1P_KEY1 + lane] = now;
timer[TIMER_KEYON_1P_KEY1 + lane] = Long.MIN_VALUE;
}
final int offset = player.getLaneProperty().getLaneSkinOffset()[lane];
boolean pressed = false;
for (int i = 0; i < player.getLaneProperty().getLaneKeyAssign()[lane].length; i++) {
int key = player.getLaneProperty().getLaneKeyAssign()[lane][i];
if (key >= 0 && keystate[key]) {
pressed = true;
break;
}
}
final int timerOn = SkinPropertyMapper.keyOnTimerId(player.getLaneProperty().getLanePlayer()[lane], offset);
final int timerOff = SkinPropertyMapper.keyOffTimerId(player.getLaneProperty().getLanePlayer()[lane], offset);
if (pressed) {
if (timer[timerOn] == Long.MIN_VALUE) {
timer[timerOn] = now;
timer[timerOff] = Long.MIN_VALUE;
}
} else {
final int key = lane >= 8 ? lane + 1 : lane;
final int offset = key_offset[lane];
if (keystate[key] || (key == 7 && keystate[8]) || (key == 16 && keystate[17])) {
if (timer[TIMER_KEYON_1P_SCRATCH + offset] == Long.MIN_VALUE) {
timer[TIMER_KEYON_1P_SCRATCH + offset] = now;
timer[TIMER_KEYOFF_1P_SCRATCH + offset] = Long.MIN_VALUE;
}
} else {
if (timer[TIMER_KEYOFF_1P_SCRATCH + offset] == Long.MIN_VALUE) {
timer[TIMER_KEYOFF_1P_SCRATCH + offset] = now;
timer[TIMER_KEYON_1P_SCRATCH + offset] = Long.MIN_VALUE;
}
if (timer[timerOff] == Long.MIN_VALUE) {
timer[timerOff] = now;
timer[timerOn] = Long.MIN_VALUE;
}
}
}

if(prevtime >= 0) {
final int deltatime = now - prevtime;
scratch1 += 2160 - deltatime;
scratch2 += deltatime;
if (!ispms) {
if (keystate[7]) {
scratch1 += deltatime * 2;
} else if (keystate[8]) {
scratch1 += 2160 - deltatime * 2;
}
if (keystate[16]) {
scratch2 += deltatime * 2;
} else if (keystate[17]) {
scratch2 += 2160 - deltatime * 2;
for (int s = 0; s < scratch.length; s++) {
scratch[s] += s % 2 == 0 ? 2160 - deltatime : deltatime;
if (s < player.getLaneProperty().getScratchKeyAssign().length) {
if (keystate[player.getLaneProperty().getScratchKeyAssign()[s][0]]) {
scratch[s] += deltatime * 2;
} else if (keystate[player.getLaneProperty().getScratchKeyAssign()[s][1]]) {
scratch[s] += 2160 - deltatime * 2;
}
}
scratch[s] %= 2160;
}
scratch1 %= 2160;
scratch2 %= 2160;
}
prevtime = now;
}

public int getScratchState(int i) {
if(i == 0) {
return scratch1 / 6;
}
return scratch2 / 6;
return scratch[i] / 6;
}

public void stopJudge() {
Expand Down
Loading

0 comments on commit 6f197f2

Please sign in to comment.