Skip to content

Commit

Permalink
Music Select : implements skin (in progress)
Browse files Browse the repository at this point in the history
  • Loading branch information
exch-bms2 committed Nov 2, 2016
1 parent 808cc2a commit 3e65c98
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/bms/player/beatoraja/select/BarRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void render(SpriteBatch sprite, ShapeRenderer shape, MusicSelectSkin skin
sprite.begin();
float y = h - i * barh;

Sprite barimage = skin.getBar()[0];
SkinImage barimage = skin.getBar()[0];
if (duration != 0) {
float dy = barh * (Math.abs(angle) - duration + System.currentTimeMillis()) / angle
+ (angle >= 0 ? -1 : 1) * barh;
Expand Down Expand Up @@ -179,7 +179,7 @@ public void render(SpriteBatch sprite, ShapeRenderer shape, MusicSelectSkin skin
barimage = skin.getBar()[5];
}

sprite.draw(barimage, x, y, w * 2 / 5, barh);
sprite.draw(barimage.getImage(time, select), x, y, w * 2 / 5, barh);
titlefont.setColor(Color.BLACK);
titlefont.draw(sprite, sd.getTitle(), x + 62, y + barh - 8);
titlefont.setColor(Color.WHITE);
Expand All @@ -201,7 +201,7 @@ public void render(SpriteBatch sprite, ShapeRenderer shape, MusicSelectSkin skin
for (int j = 0; j < TROPHY.length; j++) {
if (TROPHY[j].equals(trophy.getName()) && skin.getTrophy()[j] != null) {
sprite.begin();
sprite.draw(skin.getTrophy()[j], x + 20, y + 4);
sprite.draw(skin.getTrophy()[j].getImage(time, select), x + 20, y + 4);
sprite.end();
break;
}
Expand Down
34 changes: 24 additions & 10 deletions src/bms/player/beatoraja/select/MusicSelectSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public class MusicSelectSkin extends Skin {
/**
* 楽曲バー画像
*/
private Sprite[] bar = new Sprite[10];
private SkinImage[] bar = new SkinImage[10];
/**
* ランプ画像
*/
private SkinImage[] lamp = new SkinImage[11];

private Sprite[] trophy = new Sprite[3];
private SkinImage[] trophy = new SkinImage[3];

private int centerBar;
private int[] clickableBar = new int[0];
Expand All @@ -43,18 +43,20 @@ public MusicSelectSkin(Rectangle r) {

Texture bart = new Texture("skin/songbar.png");
for (int i = 0; i < bar.length; i++) {
bar[i] = new Sprite(bart, 0, i * 30, 500, 30);
bar[i] = new SkinImage(new TextureRegion(bart, 0, i * 30, 500, 30));
}
TextureRegion[][] lampt = TextureRegion.split(new Texture("skin/lamp.png"), 15, 30);
for (int i = 0; i < lamp.length; i++) {
lamp[i] = new SkinImage(lampt[i], 100);
setDestination(lamp[i], 0, 0, 2, 15, 34, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0);
// TODO ソングバーのスケーリング実装時点で切り替え
// setDestination(lamp[i], 0, 0, 2, 15, 34, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0);
lamp[i].setDestination(0, 0, 2, 15, 34, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

TextureRegion[][] ttrophy = TextureRegion.split(new Texture("skin/trophy.png"), 32, 32);
trophy[0] = new Sprite(ttrophy[0][10]);
trophy[1] = new Sprite(ttrophy[0][11]);
trophy[2] = new Sprite(ttrophy[0][12]);
trophy[0] = new SkinImage(ttrophy[0][10]);
trophy[1] = new SkinImage(ttrophy[0][11]);
trophy[2] = new SkinImage(ttrophy[0][12]);

SkinText dir = new SkinText("skin/VL-Gothic-Regular.ttf", 0, 24, 2);
dir.setReferenceID(STRING_DIRECTORY);
Expand Down Expand Up @@ -332,11 +334,11 @@ public MusicSelectSkin(Rectangle r) {
255, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

public Sprite[] getBar() {
public SkinImage[] getBar() {
return bar;
}

public void setBar(Sprite[] bar) {
public void setBar(SkinImage[] bar) {
this.bar = bar;
}

Expand All @@ -348,7 +350,7 @@ public void setLamp(SkinImage[] lamp) {
this.lamp = lamp;
}

public Sprite[] getTrophy() {
public SkinImage[] getTrophy() {
return trophy;
}

Expand All @@ -370,6 +372,18 @@ public void setCenterBar(int centerBar) {

public static class SkinBarObject extends SkinObject {

private SkinImage[] barimage = new SkinImage[30];

public void setImage(TextureRegion[][] images, int cycle) {
for(int i = 0;i < barimage.length;i++) {
barimage[i] = new SkinImage(images, cycle);
}
}

public SkinImage[] getBarImages() {
return barimage;
}

@Override
public void draw(SpriteBatch sprite, long time, MainState state) {
((MusicSelector)state).renderBar((int)time);
Expand Down
19 changes: 6 additions & 13 deletions src/bms/player/beatoraja/skin/LR2SelectSkinLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ public class LR2SelectSkinLoader extends LR2SkinCSVLoader {

private MusicSelectSkin skin;

private Sprite[] bar = new Sprite[10];

private SkinImage[] lamp = new SkinImage[11];

private SkinBarObject skinbar;

private SkinNumber[] levels = new SkinNumber[7];
Expand All @@ -40,9 +36,9 @@ public void execute(String[] str) {
int gr = Integer.parseInt(str[2]);
if (gr < imagelist.size() && imagelist.get(gr) != null) {
try {
bar[Integer.parseInt(str[1])] = new Sprite(imagelist.get(Integer.parseInt(str[2])),
skin.getBar()[Integer.parseInt(str[1])] = new SkinImage(new TextureRegion(imagelist.get(Integer.parseInt(str[2])),
Integer.parseInt(str[3]), Integer.parseInt(str[4]), Integer.parseInt(str[5]),
Integer.parseInt(str[6]));
Integer.parseInt(str[6])));
} catch (NumberFormatException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -167,8 +163,8 @@ public void execute(String[] str) {
if (images != null) {
int[] lamps = lampg[values[1]];
for(int i = 0; i < lamps.length;i++) {
lamp[lamps[i]] = new SkinImage(images, values[9]);
lamp[lamps[i]].setTimer(values[10]);
skin.getLamp()[lamps[i]] = new SkinImage(images, values[9]);
skin.getLamp()[lamps[i]].setTimer(values[10]);
}
// System.out.println("Nowjudge Added - " + (5 -
// values[1]));
Expand All @@ -184,7 +180,7 @@ public void execute(String[] str) {
int[] values = parseInt(str);
int[] lamps = lampg[values[1]];
for(int i = 0; i < lamps.length;i++) {
if (lamp[lamps[i]] != null) {
if (skin.getLamp()[lamps[i]] != null) {
try {
if (values[5] < 0) {
values[3] += values[5];
Expand All @@ -194,7 +190,7 @@ public void execute(String[] str) {
values[4] += values[6];
values[6] = -values[6];
}
lamp[lamps[i]].setDestination(values[2], values[3] * dstw / srcw, dsth
skin.getLamp()[lamps[i]].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], values[19],
Expand Down Expand Up @@ -244,9 +240,6 @@ public MusicSelectSkin loadSelectSkin(File f, MusicSelector selector, LR2SkinHea

this.loadSkin(skin, f, selector, header, option, property);

skin.setBar(bar);
skin.setLamp(lamp);

return skin;
}
}
4 changes: 4 additions & 0 deletions src/bms/player/beatoraja/skin/SkinImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public SkinImage(int imageid) {
setImageID(imageid);
}

public SkinImage(TextureRegion image) {
setImage(new TextureRegion[]{image}, 0);
}

public SkinImage(TextureRegion[] image, int cycle) {
setImage(image, cycle);
}
Expand Down

0 comments on commit 3e65c98

Please sign in to comment.