Skip to content

Commit

Permalink
Merge pull request #145 from Feodor0090/skin-more
Browse files Browse the repository at this point in the history
Raster judgments & borders skinning
  • Loading branch information
Feodor0090 authored May 14, 2023
2 parents 01fdbed + 2a1ec19 commit ac74268
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/nmania/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ public Player(Beatmap map, PlayerBootstrapData opts, Skin s, ILogger log, Displa
{
columnsBg = s.GetColumnsBackground(columnsCount);
}
// border
{
bordersColor = s.GetBordersColor();
}
}
if (bg == null) {
Image tmp = Image.createImage(fillScoreW, fillCountersH);
Expand Down Expand Up @@ -397,6 +401,7 @@ private final void UpdateHealthX() {
private final int[] holdsBodyColors;
private final Image[] keysSprites, holdKeysSprites;
private final int[][] keysColors, holdKeysColors;
private final int bordersColor;
private final char[] accText;
private static final char[] hudCache = new char[16];
private final int kbH, kbY, colW, colWp1;
Expand Down Expand Up @@ -1214,6 +1219,8 @@ private final void Redraw(boolean flushAll) {
g.setClip(0, 0, scrW, kbY);
RedrawNotes();
g.setClip(0, 0, scrW, scrH);
if (Settings.redrawBorders)
DrawBorders();
RedrawAllHUD();

if (Settings.fullScreenFlush || flushAll) {
Expand Down Expand Up @@ -1446,7 +1453,7 @@ private final void FillBg() {
* Draws borders around columns.
*/
private final void DrawBorders() {
g.setColor(-1);
g.setColor(bordersColor);
int x = leftOffset;
for (int i = 0; i <= columnsCount; i++) {
g.drawLine(x, 0, x, scrH);
Expand Down
4 changes: 4 additions & 0 deletions src/nmania/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ else if (dir.charAt(dir.length() - 1) != '/')

public static boolean rasterSkin;

public static boolean redrawBorders;

public static String GetLastDir() {
int i = workingFolder.lastIndexOf('/', workingFolder.length() - 2);
if (i == -1)
Expand Down Expand Up @@ -162,6 +164,7 @@ public static final String Serialize() {
j.accumulate("mods", new Integer(defaultMods));
j.accumulate("osr", new Boolean(encodeOsr));
j.accumulate("raster", new Boolean(rasterSkin));
j.put("borders", redrawBorders);

return j.toString();
}
Expand Down Expand Up @@ -229,6 +232,7 @@ public static final void Load() {
defaultMods = j.optInt("mods");
encodeOsr = j.optBoolean("osr", false);
rasterSkin = j.optBoolean("raster", false);
redrawBorders = j.optBoolean("borders");
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
23 changes: 23 additions & 0 deletions src/nmania/skin/RasterSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public RasterSkin() {
public Image[] holds;
public int[] holdBodies = new int[3];
public Image[] hud;
public Image[] judgs;
public int bordersColor;

public int GetLeftOffset() {
return leftOffset;
Expand Down Expand Up @@ -89,13 +91,19 @@ public Object GetNumericHUD() {
}

public Image[] GetJudgments() {
if (VerifyJudgs() == null)
return judgs;
return null;
}

public int[] GetColumnsBackground(int columns) {
return Pack(background, columns);
}

public int GetBordersColor() {
return bordersColor;
}

public Skin Read(JSONObject j) {
final String base = "file:///" + Settings.workingFolder + "_skin/";
final String png = ".png";
Expand All @@ -104,6 +112,7 @@ public Skin Read(JSONObject j) {
notes = new Image[3];
holds = new Image[3];
hud = new Image[12];
judgs = new Image[6];
// files
try {
for (int i = 0; i < 3; i++) {
Expand All @@ -118,18 +127,23 @@ public Skin Read(JSONObject j) {
}
hud[10] = BeatmapManager.getImgFromFS(base + "hud," + png);
hud[10] = BeatmapManager.getImgFromFS(base + "hud%" + png);
for (int i = 0; i < 6; i++) {
judgs[i] = BeatmapManager.getImgFromFS(base + "judg" + i + png);
}
} catch (Exception e) {
}
if (j == null) {
leftOffset = 30;
holdWidth = 20;
background = new int[] { 0x002200, 0x220000, 0x000022 };
holdBodies = new int[] { 0x007700, 0x770000, 0x000077 };
bordersColor = -1;
return this;
}
// json
leftOffset = j.optInt("left_offset", 30);
holdWidth = j.optInt("hold_width", 20);
bordersColor = j.optInt("borders_color", -1);

background = SNUtils.json2intArray(j.optJSONArray("background"));
if (background == null || background.length < 3)
Expand All @@ -149,6 +163,7 @@ public JSONObject Write() {
j.put("hold_width", holdWidth);
j.put("background", ToVector(background));
j.put("hold_bodies", ToVector(holdBodies));
j.put("borders_color", bordersColor);

return j;
}
Expand Down Expand Up @@ -232,4 +247,12 @@ public String VerifyHud() {
return null;
}

public String VerifyJudgs() {
for (int i = 0; i < 6; i++) {
if (judgs[i] == null)
return "File \"judg" + i + ".png\" is missing";
}
return null;
}

}
2 changes: 2 additions & 0 deletions src/nmania/skin/Skin.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public abstract class Skin {
*/
public abstract int[] GetColumnsBackground(int columns);

public abstract int GetBordersColor();

public abstract Skin Read(JSONObject j);

public abstract JSONObject Write();
Expand Down
7 changes: 7 additions & 0 deletions src/nmania/skin/VectorSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public int GetKeyboardHeight() {
public int[] holds = new int[6];
public int[] holdBodies = new int[3];
public int hudColor;
public int bordersColor;

public Object GetKeyboardLook(int columns) {
return Pack(keyboard, columns, GetKeyboardHeight());
Expand Down Expand Up @@ -78,6 +79,10 @@ public int[] GetColumnsBackground(int columns) {
return Pack(background, columns);
}

public int GetBordersColor() {
return bordersColor;
}

public Skin Read(JSONObject j) {
if (j == null)
j = new JSONObject();
Expand All @@ -88,6 +93,7 @@ public Skin Read(JSONObject j) {
holdWidth = j.optInt("hold_width", 20);
keyboardHeight = j.optInt("keyboard_height", keyboardHeight);
hudColor = j.optInt("hud_color", -1);
bordersColor = j.optInt("borders_color", -1);

// palletes
background = SNUtils.json2intArray(j.optJSONArray("background"));
Expand Down Expand Up @@ -129,6 +135,7 @@ public JSONObject Write() {
j.put("hold_width", holdWidth);
j.put("keyboard_height", keyboardHeight);
j.put("hud_color", hudColor);
j.put("borders_color", bordersColor);

// palletes
j.put("background", ToVector(background));
Expand Down
24 changes: 20 additions & 4 deletions src/nmania/ui/ng/RasterSkinSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public RasterSkinSettings() {
left = new DataItem(1, "Offset from left", this, skin.leftOffset + "px");
holdW = new DataItem(2, "Holds width", this, skin.holdWidth + "px");
SetItems(new ListItem[] { new ListItem(0, "General info", this), left, holdW,
new ListItem(3, "Hold bodies color", this),
new ListItem(3, "Hold bodies color", this), new ListItem(9, "Column borders color", this),
new ListItem(10, "Columns fill color", this),
new CheckItem(4, "Keyboard sprites", this, skin.VerifyKb() == null),
new CheckItem(5, "Note sprites", this, skin.VerifyNotes() == null),
new CheckItem(6, "HUD sprites", this, skin.VerifyHud() == null),
new CheckItem(7, "Sizes consistency", this, skin.VerifyWidth() == null), });
new CheckItem(7, "Sizes consistency", this, skin.VerifyWidth() == null),
new CheckItem(8, "Judgment sprites", this, skin.VerifyJudgs() == null), });
}

public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
Expand All @@ -41,8 +43,9 @@ public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
+ "Create \"_skin\" folder in your folder with songs (\"file:///" + Settings.workingFolder
+ "_skin/\") and place your images there. "
+ "Create 3 images (\"1\", \"2\", \"3\" for non-odd, odd and center columns) "
+ "for keyboard (\"kbX.png\" and \"kbhX.png\" where X is number) and notes (\"noteX.png\" and \"holdX.png\") "
+ "and 12 images for numbers (\"hudX.png\" where X is 0-9, \",\" and \"%\"). "
+ "for keyboard (\"kbX.png\" and \"kbhX.png\" where X is number) and notes (\"noteX.png\" and \"holdX.png\"), "
+ "12 images for numbers (\"hudX.png\" where X is 0-9, \",\" and \"%\") and 6 images for judgments "
+ "(\"judgX.png\" where X is 0-5 for miss, meh, ok, good, great, perfect). "
+ "All images in one category must have equal sizes. Notes and keyboard must have equal width. "
+ "Refer to checks below to learn what to fix."));
break;
Expand Down Expand Up @@ -71,6 +74,16 @@ public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
check = skin.VerifyWidth();
display.Push(new Alert(item.text, check == null ? "Sprite sizes are okay!" : check));
break;
case 8:
check = skin.VerifyJudgs();
display.Push(new Alert(item.text, check == null ? "Judgs sprites are okay!" : check));
break;
case 9:
display.Push(new ColorBox(item.text, 13, this, skin.bordersColor));
break;
case 10:
display.Push(new PalleteBox(item.text, skin.background, pal3));
break;
}
}

Expand All @@ -93,6 +106,9 @@ public void OnNumberEntered(int UUID, int newNumber, IDisplay d) {
skin.holdWidth = newNumber;
holdW.data = String.valueOf(newNumber) + "px";
break;
case 13:
skin.bordersColor = newNumber;
break;
}

d.Back();
Expand Down
5 changes: 3 additions & 2 deletions src/nmania/ui/ng/SystemSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public SystemSettings() {
new SwitchItem(6, "High priority", this, Settings.maxPriority),
new SwitchItem(7, "Switch threads", this, Settings.forceThreadSwitch),
new SwitchItem(8, "Analyze beatmaps", this, Settings.analyzeMaps), // ?full
});
new SwitchItem(9, "Redraw column borders", this, Settings.redrawBorders), });
}

public String GetTitle() {
Expand Down Expand Up @@ -54,7 +54,8 @@ public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
case 8:
Settings.analyzeMaps = !Settings.analyzeMaps;
break;
default:
case 9:
Settings.redrawBorders = !Settings.redrawBorders;
break;
}

Expand Down
11 changes: 9 additions & 2 deletions src/nmania/ui/ng/VectorSkinSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class VectorSkinSettings extends SkinSettings implements IListSelectHandl

private final VectorSkin skin;
private final DataItem left, colW, noteH, holdW, kbH;
private final ListItem hudC, bgC, kbC, kbHC, noteC, holdC, holdBC;
private final ListItem hudC, bgC, kbC, kbHC, noteC, holdC, holdBC, bordC;

private final String[] pal3 = new String[] { "Non-odd column", "Odd column", "Center column" };
private final String[] pal6 = new String[] { "Non-odd column (top)", "Non-odd column (bottom)", "Odd column (top)",
Expand All @@ -33,8 +33,9 @@ public VectorSkinSettings() {
noteC = new ListItem(10, "Notes color", this);
holdC = new ListItem(11, "Hold heads color", this);
holdBC = new ListItem(12, "Hold bodies color", this);
bordC = new ListItem(13, "Column borders color", this);

SetItems(new ListItem[] { left, colW, noteH, holdW, kbH, hudC, bgC, kbC, kbHC, noteC, holdC, holdBC });
SetItems(new ListItem[] { left, colW, noteH, holdW, kbH, hudC, bgC, kbC, kbHC, noteC, holdC, holdBC, bordC });
}

public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
Expand Down Expand Up @@ -75,6 +76,9 @@ public void OnSelect(ListItem item, ListScreen screen, IDisplay display) {
case 12:
display.Push(new PalleteBox(item.text, skin.holdBodies, pal3));
break;
case 13:
display.Push(new ColorBox(item.text, 13, this, skin.bordersColor));
break;
}
}

Expand Down Expand Up @@ -118,6 +122,9 @@ public void OnNumberEntered(int UUID, int newNumber, IDisplay d) {
case 6:
skin.hudColor = newNumber;
break;
case 13:
skin.bordersColor = newNumber;
break;
}

d.Back();
Expand Down

0 comments on commit ac74268

Please sign in to comment.