Skip to content

Commit

Permalink
Add Skin Slider and BarGraph ReferenceNumberValue version
Browse files Browse the repository at this point in the history
  • Loading branch information
niente1899 committed Mar 14, 2018
1 parent 2bb76d8 commit 248e991
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/bms/player/beatoraja/skin/JSONSkinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ public Skin load(Path p, SkinType type, SkinConfig.Property property) {
img.timer, img.cycle, img.angle, (int) ((img.angle == 1 || img.angle == 3
? ((float)dstr.width / sk.w) : ((float)dstr.height / sk.h)) * img.range),
img.type);
((SkinSlider) obj).setRefNum(img.isRefNum);
((SkinSlider) obj).setMin(img.min);
((SkinSlider) obj).setMax(img.max);
break;
}
}
Expand Down Expand Up @@ -417,6 +420,9 @@ public Skin load(Path p, SkinType type, SkinConfig.Property property) {
img.timer, img.cycle);
((SkinGraph) obj).setDirection(img.angle);
((SkinGraph) obj).setReferenceID(img.type);
((SkinGraph) obj).setRefNum(img.isRefNum);
((SkinGraph) obj).setMin(img.min);
((SkinGraph) obj).setMax(img.max);
break;
}
}
Expand Down Expand Up @@ -1152,6 +1158,9 @@ public static class Slider {
public int angle;
public int range;
public int type;
public boolean isRefNum = false;
public int min = 0;
public int max = 0;
}

public static class Graph {
Expand All @@ -1167,6 +1176,9 @@ public static class Graph {
public int cycle;
public int angle = 1;
public int type;
public boolean isRefNum = false;
public int min = 0;
public int max = 0;
}

public static class GaugeGraph {
Expand Down
62 changes: 60 additions & 2 deletions src/bms/player/beatoraja/skin/SkinGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public class SkinGraph extends SkinObject {
* グラフの伸びる向き(1:下, それ以外:右)
*/
private int direction = 1;
/**
* NUMBER値参照かどうか
*/
private boolean isRefNum = false;
/**
* NUMBER値参照の場合の最小値
*/
private int min = 0;
/**
* NUMBER値参照の場合の最大値
*/
private int max = 0;

private final TextureRegion current = new TextureRegion();

Expand All @@ -44,7 +56,18 @@ public void draw(SkinObjectRenderer sprite, long time, MainState state) {
Rectangle r = this.getDestination(time, state);
TextureRegion image = state.getImage(getImageID());
if (r != null && image != null) {
final float value = id != -1 ? state.getSliderValue(id) : 0;
float value = id != -1 ? state.getSliderValue(id) : 0;
if(id != -1 && isRefNum && max != min) {
if(min < max) {
if(state.getNumberValue(id) > max) value = 1;
else if(state.getNumberValue(id) < min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(id) - min) / (max - min) );
} else {
if(state.getNumberValue(id) < max) value = 1;
else if(state.getNumberValue(id) > min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(id) - min) / (max - min) );
}
}
if (direction == 1) {
current.setRegion(image, 0,
image.getRegionY() + image.getRegionHeight() - (int) (image.getRegionHeight() * value),
Expand All @@ -59,7 +82,18 @@ public void draw(SkinObjectRenderer sprite, long time, MainState state) {
} else if (source != null) {
Rectangle r = this.getDestination(time, state);
if (r != null) {
final float value = id != -1 ? state.getSliderValue(id) : 0;
float value = id != -1 ? state.getSliderValue(id) : 0;
if(id != -1 && isRefNum && max != min) {
if(min < max) {
if(state.getNumberValue(id) > max) value = 1;
else if(state.getNumberValue(id) < min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(id) - min) / (max - min) );
} else {
if(state.getNumberValue(id) < max) value = 1;
else if(state.getNumberValue(id) > min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(id) - min) / (max - min) );
}
}
TextureRegion image = source.getImage(time, state);
if (direction == 1) {
current.setRegion(image, 0, image.getRegionHeight() - (int) (image.getRegionHeight() * value),
Expand Down Expand Up @@ -95,4 +129,28 @@ public int getDirection() {
public void setDirection(int direction) {
this.direction = direction;
}

public boolean isRefNum() {
return isRefNum;
}

public void setRefNum(boolean isRefNum) {
this.isRefNum = isRefNum;
}

public int getMin() {
return min;
}

public void setMin(int min) {
this.min = min;
}

public int getMax() {
return max;
}

public void setMax(int max) {
this.max = max;
}
}
52 changes: 50 additions & 2 deletions src/bms/player/beatoraja/skin/SkinSlider.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public class SkinSlider extends SkinObject {
* ユーザーによる値変更を受け付けるかどうか
*/
private boolean changable;
/**
* NUMBER値参照かどうか
*/
private boolean isRefNum = false;
/**
* NUMBER値参照の場合の最小値
*/
private int min = 0;
/**
* NUMBER値参照の場合の最大値
*/
private int max = 0;

public SkinSlider(TextureRegion[] image, int timer, int cycle, int angle, int range, int type) {
source = new SkinSourceImage(image, timer ,cycle);
Expand All @@ -45,9 +57,21 @@ public void draw(SkinObjectRenderer sprite, long time, MainState state) {
Rectangle r = this.getDestination(time,state);
if (r != null) {
TextureRegion image = source.getImage(time, state);
float value = type != -1 ? state.getSliderValue(type) : 0;
if(type != -1 && isRefNum && max != min) {
if(min < max) {
if(state.getNumberValue(type) > max) value = 1;
else if(state.getNumberValue(type) < min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(type) - min) / (max - min) );
} else {
if(state.getNumberValue(type) < max) value = 1;
else if(state.getNumberValue(type) > min) value = 0;
else value = Math.abs( ((float) state.getNumberValue(type) - min) / (max - min) );
}
}
draw(sprite, image, r.x
+ (direction == 1 ? state.getSliderValue(type) * range : (direction == 3 ? -state.getSliderValue(type) * range : 0)), r.y
+ (direction == 0 ? state.getSliderValue(type) * range : (direction == 2 ? -state.getSliderValue(type) * range : 0)),
+ (direction == 1 ? value * range : (direction == 3 ? -value * range : 0)), r.y
+ (direction == 0 ? value * range : (direction == 2 ? -value * range : 0)),
r.width, r.height);
}
}
Expand Down Expand Up @@ -113,4 +137,28 @@ public int getType() {
public int getSliderAngle() {
return direction;
}

public boolean isRefNum() {
return isRefNum;
}

public void setRefNum(boolean isRefNum) {
this.isRefNum = isRefNum;
}

public int getMin() {
return min;
}

public void setMin(int min) {
this.min = min;
}

public int getMax() {
return max;
}

public void setMax(int max) {
this.max = max;
}
}
55 changes: 55 additions & 0 deletions src/bms/player/beatoraja/skin/lr2/LR2SkinCSVLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,28 @@ public void execute(String[] str) {
}
}
});
addCommandWord(new CommandWord("SRC_SLIDER_REFNUMBER") {
//NUMBER値参照版
//#SRC_SLIDER_REFNUMBER,(NULL),gr,x,y,w,h,div_x,div_y,cycle,timer,muki,range,type,disable,min_value,max_value
@Override
public void execute(String[] str) {
slider = null;
int[] values = parseInt(str);
TextureRegion[] images = getSourceImage(values);
if (images != null) {
slider = new SkinSlider(images, values[10], values[9], values[11],
(int) (values[12] * (values[11] == 1 || values[11] == 3 ? (dstw / srcw) : (dsth / srch))),
values[13]);
slider.setChangable(values[14] == 0);
slider.setRefNum(true);
slider.setMin(values[15]);
slider.setMax(values[16]);
skin.add(slider);
// System.out.println("Object Added - " +
// (part.getTiming()));
}
}
});
addCommandWord(new CommandWord("DST_SLIDER") {
@Override
public void execute(String[] str) {
Expand Down Expand Up @@ -389,6 +411,39 @@ public void execute(String[] str) {
}
}
});
addCommandWord(new CommandWord("SRC_BARGRAPH_REFNUMBER") {
//NUMBER値参照版
//#SRC_BARGRAPH_REFNUMBER,(NULL),gr,x,y,w,h,div_x,div_y,cycle,timer,type,muki,min_value,max_value
@Override
public void execute(String[] str) {
bar = null;
int[] values = parseInt(str);
int gr = values[2];
if (gr >= 100) {
bar = new SkinGraph(gr);
bar.setReferenceID(values[11]);
bar.setDirection(values[12]);
bar.setRefNum(true);
bar.setMin(values[13]);
bar.setMax(values[14]);
} else {
TextureRegion[] images = getSourceImage(values);
if (images != null) {
bar = new SkinGraph(images, values[10], values[9]);
bar.setReferenceID(values[11]);
bar.setDirection(values[12]);
bar.setRefNum(true);
bar.setMin(values[13]);
bar.setMax(values[14]);
// System.out.println("Object Added - " +
// (part.getTiming()));
}
}
if (bar != null) {
skin.add(bar);
}
}
});
addCommandWord(new CommandWord("DST_BARGRAPH") {
@Override
public void execute(String[] str) {
Expand Down

0 comments on commit 248e991

Please sign in to comment.