Skip to content

Commit

Permalink
SkinJudge : refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
exch-bms2 committed Jan 26, 2024
1 parent 2654e75 commit 1175d99
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
64 changes: 33 additions & 31 deletions src/bms/player/beatoraja/play/SkinJudge.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

import java.util.Arrays;

import com.badlogic.gdx.math.Rectangle;

/**
* 判定オブジェクト
*
* @author exch
*/
public class SkinJudge extends SkinObject {
public final class SkinJudge extends SkinObject {

/**
* 文字イメージ
Expand All @@ -24,8 +22,8 @@ public class SkinJudge extends SkinObject {
* 数字イメージ
*/
private final SkinNumber[] count = new SkinNumber[7];
private int index;
private boolean shift;
private final int player;
private final boolean shift;

private SkinImage nowJudge;
private SkinNumber nowCount;
Expand All @@ -34,50 +32,54 @@ public SkinJudge(int index, boolean shift) {
this(null, null, index, shift);
}

public SkinJudge(SkinImage[] judge, SkinNumber[] count, int index, boolean shift) {
setJudge(judge);
setJudgeCount(count);
this.index = index;
this.shift = shift;

this.setDestination(0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, new int[0]);
}

public void setJudge(SkinImage[] judge) {
public SkinJudge(SkinImage[] judge, SkinNumber[] count, int player, boolean shift) {
if(judge == null) {
Arrays.fill(this.judge, null);
return;
} else {
for(int i = 0; i < this.judge.length && i < judge.length;i++) {
this.judge[i] = judge[i];
}
}
for(int i = 0; i < this.judge.length && i < judge.length;i++) {
this.judge[i] = judge[i];
if(count == null) {
Arrays.fill(this.count, null);
} else {
for(int i = 0; i < this.count.length && i < count.length;i++) {
this.count[i] = count[i];
}
}
this.player = player;
this.shift = shift;

this.setDestination(0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, new int[0]);
}

public SkinImage[] getJudge() {
return judge;
public SkinImage getJudge(int index) {
return index >= 0 && index < judge.length ? judge[index] : null;
}

public void setJudgeCount(SkinNumber[] count) {
if(count == null) {
Arrays.fill(this.count, null);
return;
}
for(int i = 0; i < this.count.length && i < count.length;i++) {
this.count[i] = count[i];
public void setJudge(int index, SkinImage judge) {
if(index >= 0 && index < this.judge.length) {
this.judge[index] = judge;
}
}

public SkinNumber[] getJudgeCount() {
return count;
public SkinNumber getJudgeCount(int index) {
return index >= 0 && index < count.length ? count[index] : null;
}

public void setJudgeCount(int index, SkinNumber count) {
if(index >= 0 && index < this.count.length) {
this.count[index] = count;
}
}

public boolean isShift() {
return shift;
}

@Override
public void prepare(long time, MainState state) {
int judgenow = ((BMSPlayer)state).getJudgeManager().getNowJudge(index) - 1;
final int judgenow = ((BMSPlayer)state).getJudgeManager().getNowJudge(player) - 1;
if(judgenow < 0) {
draw = false;
return;
Expand All @@ -103,7 +105,7 @@ public void prepare(long time, MainState state) {

if(nowJudge.draw) {
if(nowCount != null) {
nowCount.prepare(time, state, ((BMSPlayer)state).getJudgeManager().getNowCombo(index), nowJudge.region.x, nowJudge.region.y);
nowCount.prepare(time, state, ((BMSPlayer)state).getJudgeManager().getNowCombo(player), nowJudge.region.x, nowJudge.region.y);
nowJudge.region.x += shift ? -nowCount.getLength() / 2 : 0;
}
} else {
Expand Down
34 changes: 17 additions & 17 deletions src/bms/player/beatoraja/skin/lr2/LR2PlaySkinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public void execute(String[] str) {
judge[0] = new SkinJudge(0, (values[11] != 1));
skin.add(judge[0]);
}
judge[0].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]] = new SkinImage(images, values[10], values[9]);
judge[0].setJudge(values[1] <= 5 ? (5 - values[1]) : values[1], new SkinImage(images, values[10], values[9]));
// System.out.println("Nowjudge Added - " + (5 -
// values[1]));
}
Expand All @@ -336,7 +336,7 @@ public void execute(String[] str) {

@Override
public void execute(String[] str) {
if (judge[0] != null && judge[0].getJudge()[Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])] != null) {
if (judge[0] != null && judge[0].getJudge(Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])) != null) {
try {
int[] values = parseInt(str);
if (values[5] < 0) {
Expand All @@ -347,7 +347,7 @@ public void execute(String[] str) {
values[4] += values[6];
values[6] = -values[6];
}
judge[0].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]].setDestination(values[2], values[3] * dstw / srcw,
judge[0].getJudge(values[1] <= 5 ? (5 - values[1]) : values[1]).setDestination(values[2], values[3] * dstw / srcw,
dsth - (values[4] + values[6]) * dsth / srch, values[5] * dstw / srcw,
values[6] * dsth / srch, values[7], values[8], values[9], values[10], values[11],
values[12], values[13], values[14], values[15], values[16], values[17], values[18],
Expand Down Expand Up @@ -375,7 +375,7 @@ public void execute(String[] str) {
judge[1] = new SkinJudge(1, (values[11] != 1));
skin.add(judge[1]);
}
judge[1].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]] = new SkinImage(images, values[10], values[9]);
judge[1].setJudge(values[1] <= 5 ? (5 - values[1]) : values[1], new SkinImage(images, values[10], values[9]));
// System.out.println("Nowjudge Added - " + (5 -
// values[1]));
}
Expand All @@ -388,7 +388,7 @@ public void execute(String[] str) {

@Override
public void execute(String[] str) {
if (judge[1] != null && judge[1].getJudge()[Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])] != null) {
if (judge[1] != null && judge[1].getJudge(Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])) != null) {
try {
int[] values = parseInt(str);
if (values[5] < 0) {
Expand All @@ -399,7 +399,7 @@ public void execute(String[] str) {
values[4] += values[6];
values[6] = -values[6];
}
judge[1].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]].setDestination(values[2], values[3] * dstw / srcw,
judge[1].getJudge(values[1] <= 5 ? (5 - values[1]) : values[1]).setDestination(values[2], values[3] * dstw / srcw,
dsth - (values[4] + values[6]) * dsth / srch, values[5] * dstw / srcw,
values[6] * dsth / srch, values[7], values[8], values[9], values[10], values[11],
values[12], values[13], values[14], values[15], values[16], values[17], values[18],
Expand All @@ -426,7 +426,7 @@ public void execute(String[] str) {
judge[2] = new SkinJudge(2, (values[11] != 1));
skin.add(judge[2]);
}
judge[2].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]] = new SkinImage(images, values[10], values[9]);
judge[2].setJudge(values[1] <= 5 ? (5 - values[1]) : values[1], new SkinImage(images, values[10], values[9]));
// System.out.println("Nowjudge Added - " + (5 -
// values[1]));
}
Expand All @@ -439,7 +439,7 @@ public void execute(String[] str) {

@Override
public void execute(String[] str) {
if (judge[2] != null && judge[2].getJudge()[Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])] != null) {
if (judge[2] != null && judge[2].getJudge(Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])) != null) {
try {
int[] values = parseInt(str);
if (values[5] < 0) {
Expand All @@ -450,7 +450,7 @@ public void execute(String[] str) {
values[4] += values[6];
values[6] = -values[6];
}
judge[2].getJudge()[values[1] <= 5 ? (5 - values[1]) : values[1]].setDestination(values[2], values[3] * dstw / srcw,
judge[2].getJudge(values[1] <= 5 ? (5 - values[1]) : values[1]).setDestination(values[2], values[3] * dstw / srcw,
dsth - (values[4] + values[6]) * dsth / srch, values[5] * dstw / srcw,
values[6] * dsth / srch, values[7], values[8], values[9], values[10], values[11],
values[12], values[13], values[14], values[15], values[16], values[17], values[18],
Expand Down Expand Up @@ -763,24 +763,24 @@ private void setSrcNowCombo(int index, String[] str) {
}
}

judge[index].getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]] = new SkinNumber(images, values[10], values[9], values[13],
images.length > 10 ? 2 : 0, values[15], values[11]);
judge[index].getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]].setAlign(values[12] == 1 ? 2 : values[12]);
judge[index].setJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1], new SkinNumber(images, values[10], values[9], values[13],
images.length > 10 ? 2 : 0, values[15], values[11]));
judge[index].getJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1]).setAlign(values[12] == 1 ? 2 : values[12]);
// System.out.println("Number Added - " +
// (num.getId()));
}
}

private void setDstNowCombo(int index, String[] str, int[] offset) {
final SkinJudge sj = judge[index];
if (sj != null && sj.getJudgeCount()[Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])] != null) {
if (sj != null && sj.getJudgeCount(Integer.parseInt(str[1]) <= 5 ? (5 - Integer.parseInt(str[1])) : Integer.parseInt(str[1])) != null) {
int[] values = parseInt(str);
sj.getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]].setRelative(true);
sj.getJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1]).setRelative(true);
float x = values[3];
if(sj.getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]].getAlign() == 2) {
x -= sj.getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]].getKeta() * values[5] / 2;
if(sj.getJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1]).getAlign() == 2) {
x -= sj.getJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1]).getKeta() * values[5] / 2;
}
sj.getJudgeCount()[values[1] <= 5 ? (5 - values[1]) : values[1]].setDestination(values[2], x * dstw / srcw,
sj.getJudgeCount(values[1] <= 5 ? (5 - values[1]) : values[1]).setDestination(values[2], x * dstw / srcw,
-values[4] * dsth / srch, values[5] * dstw / srcw, values[6] * dsth / srch, values[7],
values[8], values[9], values[10], values[11], values[12], values[13], values[14],
values[15], values[16], values[17], values[18], values[19], values[20], offset);
Expand Down

0 comments on commit 1175d99

Please sign in to comment.