2014-07-04 22:41:52 +02:00
|
|
|
/*
|
|
|
|
* opsu! - an open-source osu! client
|
2015-01-16 18:05:44 +01:00
|
|
|
* Copyright (C) 2014, 2015 Jeffrey Han
|
2014-07-04 22:41:52 +02:00
|
|
|
*
|
|
|
|
* opsu! is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* opsu! is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2014-07-16 22:01:36 +02:00
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
package itdelatrisu.opsu;
|
|
|
|
|
2015-08-21 03:40:07 +02:00
|
|
|
import itdelatrisu.opsu.ui.Fonts;
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
import java.io.File;
|
2015-01-16 00:16:46 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-02-18 04:03:11 +01:00
|
|
|
import org.newdawn.slick.Animation;
|
2014-07-04 22:41:52 +02:00
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.SlickException;
|
2015-02-21 17:40:25 +01:00
|
|
|
import org.newdawn.slick.util.ResourceLoader;
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Game images.
|
|
|
|
*/
|
|
|
|
public enum GameImage {
|
2015-01-25 04:23:49 +01:00
|
|
|
// Cursor
|
2015-02-16 17:34:35 +01:00
|
|
|
CURSOR ("cursor", "png"),
|
|
|
|
CURSOR_MIDDLE ("cursormiddle", "png"),
|
|
|
|
CURSOR_TRAIL ("cursortrail", "png"),
|
2015-08-24 03:41:09 +02:00
|
|
|
CURSOR_OLD ("cursor2", "png", false, false), // custom
|
|
|
|
CURSOR_TRAIL_OLD ("cursortrail2", "png", false, false), // custom
|
2015-01-25 04:23:49 +01:00
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
// Game
|
2015-01-16 00:16:46 +01:00
|
|
|
SECTION_PASS ("section-pass", "png"),
|
|
|
|
SECTION_FAIL ("section-fail", "png"),
|
|
|
|
WARNINGARROW ("play-warningarrow", "png"),
|
2015-02-19 01:35:26 +01:00
|
|
|
SKIP ("play-skip", "play-skip-%d", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
COUNTDOWN_READY ("ready", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
COUNTDOWN_3 ("count3", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-02-19 01:35:26 +01:00
|
|
|
return COUNTDOWN_READY.process_sub(img, w, h);
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
COUNTDOWN_2 ("count2", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-02-19 01:35:26 +01:00
|
|
|
return COUNTDOWN_READY.process_sub(img, w, h);
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
COUNTDOWN_1 ("count1", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-02-19 01:35:26 +01:00
|
|
|
return COUNTDOWN_READY.process_sub(img, w, h);
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
COUNTDOWN_GO ("go", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
HITCIRCLE_SELECT ("hitcircleselect", "png"),
|
|
|
|
UNRANKED ("play-unranked", "png"),
|
2015-03-19 03:20:37 +01:00
|
|
|
FOLLOWPOINT ("followpoint", "png"),
|
2015-01-21 01:01:18 +01:00
|
|
|
PLAYFIELD ("playfield", "png|jpg", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
img.setAlpha(0.7f);
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
// Game Pause/Fail
|
2015-01-16 00:16:46 +01:00
|
|
|
PAUSE_CONTINUE ("pause-continue", "png"),
|
|
|
|
PAUSE_RETRY ("pause-retry", "png"),
|
|
|
|
PAUSE_BACK ("pause-back", "png"),
|
2015-03-11 20:53:19 +01:00
|
|
|
PAUSE_REPLAY ("pause-replay", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
PAUSE_OVERLAY ("pause-overlay", "png|jpg") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
img.setAlpha(0.7f);
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
FAIL_BACKGROUND ("fail-background", "png|jpg") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
img.setAlpha(0.7f);
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
// Circle
|
2015-01-16 00:16:46 +01:00
|
|
|
HITCIRCLE ("hitcircle", "png"),
|
|
|
|
HITCIRCLE_OVERLAY ("hitcircleoverlay", "png"),
|
|
|
|
APPROACHCIRCLE ("approachcircle", "png"),
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
// Slider
|
2015-03-30 14:19:39 +02:00
|
|
|
SLIDER_GRADIENT ("slidergradient", "png"),
|
2015-01-21 23:10:31 +01:00
|
|
|
SLIDER_BALL ("sliderb", "sliderb%d", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
SLIDER_FOLLOWCIRCLE ("sliderfollowcircle", "png"),
|
|
|
|
REVERSEARROW ("reversearrow", "png"),
|
|
|
|
SLIDER_TICK ("sliderscorepoint", "png"),
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
// Spinner
|
2015-03-13 02:34:37 +01:00
|
|
|
SPINNER_CIRCLE ("spinner-circle", "png"),
|
2015-01-22 00:56:53 +01:00
|
|
|
SPINNER_APPROACHCIRCLE ("spinner-approachcircle", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-03-13 02:34:37 +01:00
|
|
|
return img.getScaledCopy(1.8f);
|
2015-01-22 00:56:53 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
SPINNER_METRE ("spinner-metre", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
SPINNER_SPIN ("spinner-spin", "png"),
|
|
|
|
SPINNER_CLEAR ("spinner-clear", "png"),
|
|
|
|
SPINNER_OSU ("spinner-osu", "png"),
|
2015-03-06 20:39:49 +01:00
|
|
|
SPINNER_RPM ("spinner-rpm", "png") {
|
2015-02-20 22:56:41 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-03-13 02:34:37 +01:00
|
|
|
return img.getScaledCopy(0.8f);
|
2015-02-20 22:56:41 +01:00
|
|
|
}
|
|
|
|
},
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-02-19 01:35:26 +01:00
|
|
|
// Game Data
|
2015-01-21 23:10:31 +01:00
|
|
|
COMBO_BURST ("comboburst", "comboburst-%d", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
SCOREBAR_BG ("scorebar-bg", "png"),
|
|
|
|
SCOREBAR_COLOUR ("scorebar-colour", "scorebar-colour-%d", "png"),
|
2015-02-18 04:03:11 +01:00
|
|
|
//TODO scorebar-marker?
|
2015-01-16 00:16:46 +01:00
|
|
|
SCOREBAR_KI ("scorebar-ki", "png"),
|
|
|
|
SCOREBAR_KI_DANGER ("scorebar-kidanger", "png"),
|
|
|
|
SCOREBAR_KI_DANGER2 ("scorebar-kidanger2", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
HIT_MISS ("hit0", "png"),
|
|
|
|
HIT_50 ("hit50", "png"),
|
|
|
|
HIT_100 ("hit100", "png"),
|
|
|
|
HIT_300 ("hit300", "png"),
|
|
|
|
HIT_100K ("hit100k", "png"),
|
|
|
|
HIT_300K ("hit300k", "png"),
|
|
|
|
HIT_300G ("hit300g", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
HIT_SLIDER10 ("sliderpoint10", "png"),
|
|
|
|
HIT_SLIDER30 ("sliderpoint30", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_SS ("ranking-X", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SS_SMALL ("ranking-X-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_SSH ("ranking-XH", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SSH_SMALL ("ranking-XH-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_S ("ranking-S", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_S_SMALL ("ranking-S-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_SH ("ranking-SH", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SH_SMALL ("ranking-SH-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_A ("ranking-A", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_A_SMALL ("ranking-A-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_B ("ranking-B", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_B_SMALL ("ranking-B-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_C ("ranking-C", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_C_SMALL ("ranking-C-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_D ("ranking-D", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_D_SMALL ("ranking-D-small", "png"),
|
2015-02-16 17:34:35 +01:00
|
|
|
RANKING_PANEL ("ranking-panel", "png"),
|
|
|
|
RANKING_PERFECT ("ranking-perfect", "png"),
|
|
|
|
RANKING_TITLE ("ranking-title", "png"),
|
|
|
|
RANKING_MAXCOMBO ("ranking-maxcombo", "png"),
|
|
|
|
RANKING_ACCURACY ("ranking-accuracy", "png"),
|
2016-09-30 15:54:07 +02:00
|
|
|
DEFAULT_0 ("default-0", "png", true, "0"),
|
|
|
|
DEFAULT_1 ("default-1", "png", true, "1"),
|
|
|
|
DEFAULT_2 ("default-2", "png", true, "2"),
|
|
|
|
DEFAULT_3 ("default-3", "png", true, "3"),
|
|
|
|
DEFAULT_4 ("default-4", "png", true, "4"),
|
|
|
|
DEFAULT_5 ("default-5", "png", true, "5"),
|
|
|
|
DEFAULT_6 ("default-6", "png", true, "6"),
|
|
|
|
DEFAULT_7 ("default-7", "png", true, "7"),
|
|
|
|
DEFAULT_8 ("default-8", "png", true, "8"),
|
|
|
|
DEFAULT_9 ("default-9", "png", true, "9"),
|
|
|
|
SCORE_0 ("score-0", "png", true, "0"),
|
|
|
|
SCORE_1 ("score-1", "png", true, "1"),
|
|
|
|
SCORE_2 ("score-2", "png", true, "2"),
|
|
|
|
SCORE_3 ("score-3", "png", true, "3"),
|
|
|
|
SCORE_4 ("score-4", "png", true, "4"),
|
|
|
|
SCORE_5 ("score-5", "png", true, "5"),
|
|
|
|
SCORE_6 ("score-6", "png", true, "6"),
|
|
|
|
SCORE_7 ("score-7", "png", true, "7"),
|
|
|
|
SCORE_8 ("score-8", "png", true, "8"),
|
|
|
|
SCORE_9 ("score-9", "png", true, "9"),
|
|
|
|
SCORE_COMMA ("score-comma", "png", true, "comma"),
|
|
|
|
SCORE_DOT ("score-dot", "png", true, "dot"),
|
|
|
|
SCORE_PERCENT ("score-percent", "png", true, "percent"),
|
|
|
|
SCORE_X ("score-x", "png", true, "x"),
|
|
|
|
LIGHTING ("lighting", "png", true, "0"),
|
2015-01-21 01:01:18 +01:00
|
|
|
|
|
|
|
// Game Mods
|
2015-03-13 02:34:37 +01:00
|
|
|
MOD_EASY ("selection-mod-easy", "png", false, false),
|
|
|
|
MOD_NO_FAIL ("selection-mod-nofail", "png", false, false),
|
|
|
|
MOD_HARD_ROCK ("selection-mod-hardrock", "png", false, false),
|
|
|
|
MOD_SUDDEN_DEATH ("selection-mod-suddendeath", "png", false, false),
|
|
|
|
MOD_SPUN_OUT ("selection-mod-spunout", "png", false, false),
|
|
|
|
MOD_AUTO ("selection-mod-autoplay", "png", false, false),
|
|
|
|
MOD_HALF_TIME ("selection-mod-halftime", "png", false, false),
|
|
|
|
MOD_DOUBLE_TIME ("selection-mod-doubletime", "png", false, false),
|
|
|
|
MOD_HIDDEN ("selection-mod-hidden", "png", false, false),
|
|
|
|
MOD_FLASHLIGHT ("selection-mod-flashlight", "png", false, false),
|
|
|
|
MOD_RELAX ("selection-mod-relax", "png", false, false),
|
|
|
|
MOD_AUTOPILOT ("selection-mod-relax2", "png", false, false),
|
2015-01-08 05:45:21 +01:00
|
|
|
|
2015-02-16 07:24:22 +01:00
|
|
|
// Selection Buttons
|
2015-03-13 02:34:37 +01:00
|
|
|
SELECTION_MODS ("selection-mods", "png", false, false),
|
|
|
|
SELECTION_MODS_OVERLAY ("selection-mods-over", "png", false, false),
|
|
|
|
SELECTION_RANDOM ("selection-random", "png", false, false),
|
|
|
|
SELECTION_RANDOM_OVERLAY ("selection-random-over", "png", false, false),
|
|
|
|
SELECTION_OPTIONS ("selection-options", "png", false, false),
|
|
|
|
SELECTION_OPTIONS_OVERLAY ("selection-options-over", "png", false, false),
|
|
|
|
SELECTION_OTHER_OPTIONS ("selection-selectoptions", "png", false, false),
|
|
|
|
SELECTION_OTHER_OPTIONS_OVERLAY ("selection-selectoptions-over", "png", false, false),
|
2015-02-16 07:24:22 +01:00
|
|
|
|
2015-04-04 00:08:35 +02:00
|
|
|
// Replay Speed Buttons
|
|
|
|
REPLAY_PLAYBACK_NORMAL ("playback-normal", "png", false, false),
|
|
|
|
REPLAY_PLAYBACK_DOUBLE ("playback-double", "png", false, false),
|
|
|
|
REPLAY_PLAYBACK_HALF ("playback-half", "png", false, false),
|
|
|
|
|
2015-02-16 07:24:22 +01:00
|
|
|
// Non-Game Components
|
2015-02-16 03:38:54 +01:00
|
|
|
VOLUME ("volume-bg", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-02-19 01:35:26 +01:00
|
|
|
MENU_BACK ("menu-back", "menu-back-%d", "png"),
|
2015-02-18 04:49:19 +01:00
|
|
|
MENU_BUTTON_BG ("menu-button-background", "png", false, false),
|
2015-02-16 03:38:54 +01:00
|
|
|
MENU_TAB ("selection-tab", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.033f) / img.getHeight());
|
2015-01-08 05:45:21 +01:00
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_MUSICNOTE ("music-note", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-08-21 03:40:07 +02:00
|
|
|
int r = (int) ((Fonts.LARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 8) / getUIscale());
|
2015-01-08 05:45:21 +01:00
|
|
|
return img.getScaledCopy(r, r);
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_LOADER ("loader", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-08-21 03:40:07 +02:00
|
|
|
int r = (int) ((Fonts.LARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() - 8) / getUIscale());
|
2015-01-08 05:45:21 +01:00
|
|
|
return img.getScaledCopy(r / 48f);
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_BG ("menu-background", "png|jpg", false, true) {
|
2015-01-16 00:16:46 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
img.setAlpha(0.9f);
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_LOGO ("logo", "png", false, true) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-03-13 02:34:37 +01:00
|
|
|
return img.getScaledCopy(0.8f);
|
2015-01-08 05:45:21 +01:00
|
|
|
}
|
|
|
|
},
|
2015-03-13 04:53:25 +01:00
|
|
|
MENU_PLAY ("menu-play", "png", false, false) {
|
2015-01-15 06:56:30 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-03-13 02:34:37 +01:00
|
|
|
return img.getScaledCopy(0.8f);
|
2015-03-13 04:53:25 +01:00
|
|
|
}
|
2015-01-15 06:56:30 +01:00
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_EXIT ("menu-exit", "png", false, false) {
|
2015-01-15 06:56:30 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-03-13 02:34:37 +01:00
|
|
|
return img.getScaledCopy(0.8f);
|
2015-01-15 06:56:30 +01:00
|
|
|
}
|
|
|
|
},
|
2015-02-02 06:15:16 +01:00
|
|
|
MENU_BUTTON_MID ("button-middle", "png", false, false),
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_BUTTON_LEFT ("button-left", "png", false, false),
|
|
|
|
MENU_BUTTON_RIGHT ("button-right", "png", false, false),
|
2015-09-03 06:10:31 +02:00
|
|
|
STAR ("star", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((MENU_BUTTON_BG.getImage().getHeight() * 0.16f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-09-05 05:36:25 +02:00
|
|
|
STAR2 ("star2", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((MENU_BUTTON_BG.getImage().getHeight() * 0.33f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-02-16 07:24:22 +01:00
|
|
|
|
|
|
|
// Music Player Buttons
|
2015-03-13 02:34:37 +01:00
|
|
|
MUSIC_PLAY ("music-play", "png", false, false),
|
|
|
|
MUSIC_PAUSE ("music-pause", "png", false, false),
|
|
|
|
MUSIC_NEXT ("music-next", "png", false, false),
|
|
|
|
MUSIC_PREVIOUS ("music-previous", "png", false, false),
|
2015-09-09 05:46:30 +02:00
|
|
|
|
2015-02-01 08:10:17 +01:00
|
|
|
DOWNLOADS ("downloads", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.45f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SEARCH_BG ("search-background", "png|jpg", false, true) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
img.setAlpha(0.8f);
|
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
DELETE ("delete", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-08-21 03:40:07 +02:00
|
|
|
int lineHeight = Fonts.DEFAULT.getLineHeight();
|
2015-02-01 08:10:17 +01:00
|
|
|
return img.getScaledCopy(lineHeight, lineHeight);
|
|
|
|
}
|
|
|
|
},
|
2015-01-29 09:05:09 +01:00
|
|
|
HISTORY ("history", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.0278f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
REPOSITORY ("repo", "png", false, false) {
|
2015-01-16 19:42:54 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 17f) / img.getHeight());
|
|
|
|
}
|
2015-03-07 10:17:19 +01:00
|
|
|
},
|
2015-08-13 02:06:58 +02:00
|
|
|
DOWNLOAD ("download", "png", false, false) {
|
2015-03-07 10:17:19 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-08-13 02:06:58 +02:00
|
|
|
return img.getScaledCopy((h / 14f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
UPDATE ("update", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 14f) / img.getHeight());
|
2015-03-07 10:17:19 +01:00
|
|
|
}
|
2015-03-15 20:38:04 +01:00
|
|
|
},
|
2015-05-16 23:46:23 +02:00
|
|
|
OPTIONS_BG ("options-background", "png|jpg", false, true) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-05-17 21:38:58 +02:00
|
|
|
img.setAlpha(0.7f);
|
2015-05-16 23:46:23 +02:00
|
|
|
return img.getScaledCopy(w, h);
|
|
|
|
}
|
|
|
|
},
|
2015-09-09 05:46:30 +02:00
|
|
|
CHEVRON_DOWN ("chevron-down", "png", false, false),
|
|
|
|
CHEVRON_RIGHT ("chevron-right", "png", false, false),
|
2015-05-16 23:46:23 +02:00
|
|
|
|
2015-03-15 20:38:04 +01:00
|
|
|
// TODO: ensure this image hasn't been modified (checksum?)
|
|
|
|
ALPHA_MAP ("alpha", "png", false, false);
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Image file types. */
|
2015-01-16 00:16:46 +01:00
|
|
|
private static final byte
|
|
|
|
IMG_PNG = 1,
|
|
|
|
IMG_JPG = 2;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The file name. */
|
2016-09-30 15:54:07 +02:00
|
|
|
private String filename;
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The formatted file name string (for loading multiple images). */
|
2015-01-21 23:10:31 +01:00
|
|
|
private String filenameFormat;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Image file type. */
|
2015-08-21 04:11:55 +02:00
|
|
|
private final byte type;
|
2015-01-16 00:16:46 +01:00
|
|
|
|
2015-01-08 05:45:21 +01:00
|
|
|
/**
|
2015-01-18 23:01:13 +01:00
|
|
|
* Whether or not the image is skinnable by a beatmap.
|
|
|
|
* These images are typically related to gameplay.
|
2015-01-08 05:45:21 +01:00
|
|
|
*/
|
2015-08-24 04:16:28 +02:00
|
|
|
private final boolean beatmapSkinnable;
|
2015-01-18 23:01:13 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Whether or not to preload the image when the program starts. */
|
2015-08-21 04:11:55 +02:00
|
|
|
private final boolean preload;
|
2015-01-08 05:45:21 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The default image. */
|
2014-07-05 01:59:57 +02:00
|
|
|
private Image defaultImage;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The default image array. */
|
2015-01-21 23:10:31 +01:00
|
|
|
private Image[] defaultImages;
|
|
|
|
|
2015-08-24 04:16:28 +02:00
|
|
|
/** Whether the image is currently skinned by a game skin. */
|
|
|
|
private boolean isSkinned = false;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The beatmap skin image (optional, temporary). */
|
2014-07-05 01:59:57 +02:00
|
|
|
private Image skinImage;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** The beatmap skin image array (optional, temporary). */
|
2015-01-21 23:10:31 +01:00
|
|
|
private Image[] skinImages;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Container dimensions. */
|
2015-01-08 04:36:39 +01:00
|
|
|
private static int containerWidth, containerHeight;
|
2015-02-19 01:35:26 +01:00
|
|
|
|
|
|
|
/** Value to scale UI components by. */
|
|
|
|
private static float uiscale;
|
|
|
|
|
|
|
|
/** The unscaled container height that uiscale is based on. */
|
|
|
|
private static final int UNSCALED_HEIGHT = 768;
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-05-29 12:06:37 +02:00
|
|
|
/** Filename suffix for HD images. */
|
2015-06-11 19:42:57 +02:00
|
|
|
public static final String HD_SUFFIX = "@2x";
|
2015-05-29 12:06:37 +02:00
|
|
|
|
2015-03-15 04:28:50 +01:00
|
|
|
/** Image HD/SD suffixes. */
|
|
|
|
private static final String[]
|
2015-05-29 12:06:37 +02:00
|
|
|
SUFFIXES_HD = new String[] { HD_SUFFIX, "" },
|
|
|
|
SUFFIXES_SD = new String[] { "" };
|
2015-01-08 04:36:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the GameImage class with container dimensions.
|
|
|
|
* @param width the container width
|
|
|
|
* @param height the container height
|
2014-07-05 01:59:57 +02:00
|
|
|
*/
|
2015-01-08 04:36:39 +01:00
|
|
|
public static void init(int width, int height) {
|
|
|
|
containerWidth = width;
|
|
|
|
containerHeight = height;
|
2015-02-19 01:35:26 +01:00
|
|
|
uiscale = (float) containerHeight / UNSCALED_HEIGHT;
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-02-19 01:35:26 +01:00
|
|
|
/**
|
|
|
|
* Returns the UI scale.
|
|
|
|
*/
|
|
|
|
public static float getUIscale() { return uiscale; }
|
|
|
|
|
2015-01-21 01:01:18 +01:00
|
|
|
/**
|
|
|
|
* Clears all image references.
|
|
|
|
* This does NOT destroy images, so be careful of memory leaks!
|
|
|
|
*/
|
|
|
|
public static void clearReferences() {
|
2015-01-21 23:10:31 +01:00
|
|
|
for (GameImage img : GameImage.values()) {
|
2015-01-21 01:01:18 +01:00
|
|
|
img.defaultImage = img.skinImage = null;
|
2015-01-21 23:10:31 +01:00
|
|
|
img.defaultImages = img.skinImages = null;
|
2015-08-24 04:16:28 +02:00
|
|
|
img.isSkinned = false;
|
2015-01-21 23:10:31 +01:00
|
|
|
}
|
2015-01-21 01:01:18 +01:00
|
|
|
}
|
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
/**
|
|
|
|
* Returns the bitmask image type from a type string.
|
|
|
|
* @param type the type string
|
|
|
|
* @return the byte bitmask
|
|
|
|
*/
|
|
|
|
private static byte getType(String type) {
|
|
|
|
byte b = 0;
|
|
|
|
String[] s = type.split("\\|");
|
|
|
|
for (int i = 0; i < s.length; i++) {
|
|
|
|
if (s[i].equals("png"))
|
|
|
|
b |= IMG_PNG;
|
|
|
|
else if (s[i].equals("jpg"))
|
|
|
|
b |= IMG_JPG;
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
/**
|
2015-02-21 17:40:25 +01:00
|
|
|
* Returns the image file name, with extension, by first looking through
|
|
|
|
* the given directory and then the default resource locations (unless
|
|
|
|
* dirOnly is true).
|
|
|
|
* @param filename the base file name
|
|
|
|
* @param dir the directory to search first (if non-null)
|
|
|
|
* @param type the file type bitmask (IMG_*)
|
|
|
|
* @param dirOnly if true and dir is non-null, will not search default resource locations
|
|
|
|
* @return the full file name, or null if no file found
|
2015-01-21 23:10:31 +01:00
|
|
|
*/
|
2015-02-21 17:40:25 +01:00
|
|
|
private static String getImageFileName(String filename, File dir, byte type, boolean dirOnly) {
|
|
|
|
ArrayList<String> names = new ArrayList<String>(2);
|
2015-01-21 23:10:31 +01:00
|
|
|
if ((type & IMG_PNG) != 0)
|
2015-02-21 17:40:25 +01:00
|
|
|
names.add(String.format("%s.png", filename));
|
2015-01-21 23:10:31 +01:00
|
|
|
if ((type & IMG_JPG) != 0)
|
2015-02-21 17:40:25 +01:00
|
|
|
names.add(String.format("%s.jpg", filename));
|
|
|
|
int size = names.size();
|
|
|
|
|
|
|
|
// look through directory
|
|
|
|
if (dir != null) {
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
File file = new File(dir, names.get(i));
|
|
|
|
if (file.isFile())
|
|
|
|
return file.getAbsolutePath();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// look through default resource path
|
|
|
|
if (!dirOnly || dir == null) {
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
if (ResourceLoader.resourceExists(names.get(i)))
|
|
|
|
return names.get(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2015-01-21 23:10:31 +01:00
|
|
|
}
|
|
|
|
|
2016-09-30 15:54:07 +02:00
|
|
|
/**
|
|
|
|
* used for when prefixes change
|
|
|
|
*/
|
|
|
|
public void update() { }
|
|
|
|
|
2015-03-15 04:28:50 +01:00
|
|
|
/**
|
|
|
|
* Returns an array of HD/SD file name suffixes based on the current options
|
|
|
|
* and UI scale.
|
|
|
|
*/
|
|
|
|
private static String[] getSuffixes() {
|
|
|
|
return (Options.loadHDImages() && uiscale >= 1) ? SUFFIXES_HD : SUFFIXES_SD;
|
|
|
|
}
|
|
|
|
|
2016-09-30 15:54:07 +02:00
|
|
|
|
|
|
|
private String suffix;
|
|
|
|
private boolean isPrefixable;
|
|
|
|
|
|
|
|
GameImage(String filename, String type, boolean isPrefixable, String suffix) {
|
|
|
|
this(filename, type, true, false);
|
|
|
|
this.isPrefixable = isPrefixable;
|
|
|
|
this.suffix = suffix;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updatePrefix(String prefix) {
|
|
|
|
if (isPrefixable) {
|
|
|
|
this.filename = prefix + "-" + suffix;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Constructor for game-related images (beatmap-skinnable and preloaded).
|
2014-07-16 22:01:36 +02:00
|
|
|
* @param filename the image file name
|
2015-01-16 00:16:46 +01:00
|
|
|
* @param type the file types (separated by '|')
|
2014-07-04 22:41:52 +02:00
|
|
|
*/
|
2015-01-16 00:16:46 +01:00
|
|
|
GameImage(String filename, String type) {
|
2015-03-06 20:39:49 +01:00
|
|
|
this(filename, type, true, false);
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Constructor for an array of game-related images (beatmap-skinnable and preloaded).
|
2015-01-21 23:10:31 +01:00
|
|
|
* @param filename the image file name
|
|
|
|
* @param filenameFormat the formatted file name string (for loading multiple images)
|
|
|
|
* @param type the file types (separated by '|')
|
|
|
|
*/
|
|
|
|
GameImage(String filename, String filenameFormat, String type) {
|
2015-03-06 20:39:49 +01:00
|
|
|
this(filename, type, true, false);
|
2015-01-21 23:10:31 +01:00
|
|
|
this.filenameFormat = filenameFormat;
|
|
|
|
}
|
|
|
|
|
2015-01-08 05:45:21 +01:00
|
|
|
/**
|
2015-01-18 23:01:13 +01:00
|
|
|
* Constructor for general images.
|
2015-01-08 05:45:21 +01:00
|
|
|
* @param filename the image file name
|
2015-01-16 00:16:46 +01:00
|
|
|
* @param type the file types (separated by '|')
|
2015-08-24 04:16:28 +02:00
|
|
|
* @param beatmapSkinnable whether or not the image is beatmap-skinnable
|
2015-01-18 23:01:13 +01:00
|
|
|
* @param preload whether or not to preload the image
|
2015-01-08 05:45:21 +01:00
|
|
|
*/
|
2015-08-24 04:16:28 +02:00
|
|
|
GameImage(String filename, String type, boolean beatmapSkinnable, boolean preload) {
|
2015-01-08 05:45:21 +01:00
|
|
|
this.filename = filename;
|
2015-01-16 00:16:46 +01:00
|
|
|
this.type = getType(type);
|
2015-08-24 04:16:28 +02:00
|
|
|
this.beatmapSkinnable = beatmapSkinnable;
|
2015-01-18 23:01:13 +01:00
|
|
|
this.preload = preload;
|
2015-01-08 05:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Returns whether or not the image is beatmap-skinnable.
|
2015-08-24 04:16:28 +02:00
|
|
|
* @return true if beatmap-skinnable
|
2015-01-18 23:01:13 +01:00
|
|
|
*/
|
2015-08-24 04:16:28 +02:00
|
|
|
public boolean isBeatmapSkinnable() { return beatmapSkinnable; }
|
2015-01-18 23:01:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not to preload the image when the program starts.
|
|
|
|
* @return true if preload
|
2015-01-08 05:45:21 +01:00
|
|
|
*/
|
2015-01-18 23:01:13 +01:00
|
|
|
public boolean isPreload() { return preload; }
|
2015-01-08 05:45:21 +01:00
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
2014-07-05 01:59:57 +02:00
|
|
|
* Returns the image associated with this resource.
|
2015-08-24 03:41:09 +02:00
|
|
|
* The beatmap skin image takes priority over the default image.
|
2014-07-04 22:41:52 +02:00
|
|
|
*/
|
2014-07-05 01:59:57 +02:00
|
|
|
public Image getImage() {
|
2015-01-21 23:10:31 +01:00
|
|
|
setDefaultImage();
|
2014-07-05 01:59:57 +02:00
|
|
|
return (skinImage != null) ? skinImage : defaultImage;
|
|
|
|
}
|
2015-02-19 01:35:26 +01:00
|
|
|
|
2015-02-18 04:03:11 +01:00
|
|
|
/**
|
|
|
|
* Returns an Animation based on the image array.
|
2015-02-19 01:35:26 +01:00
|
|
|
* If no image array exists, returns the single image as an animation.
|
|
|
|
* @param duration the duration to show each frame in the animation
|
2015-02-18 04:03:11 +01:00
|
|
|
*/
|
|
|
|
public Animation getAnimation(int duration){
|
|
|
|
Image[] images = getImages();
|
|
|
|
if (images == null)
|
2015-02-19 01:35:26 +01:00
|
|
|
images = new Image[] { getImage() };
|
2015-02-18 04:03:11 +01:00
|
|
|
return new Animation(images, duration);
|
|
|
|
}
|
2014-07-05 01:59:57 +02:00
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the image array associated with this resource.
|
2015-08-24 03:41:09 +02:00
|
|
|
* The beatmap skin images takes priority over the default images.
|
2015-01-21 23:10:31 +01:00
|
|
|
*/
|
|
|
|
public Image[] getImages() {
|
|
|
|
setDefaultImage();
|
|
|
|
return (skinImages != null) ? skinImages : defaultImages;
|
|
|
|
}
|
|
|
|
|
2014-07-05 01:59:57 +02:00
|
|
|
/**
|
|
|
|
* Sets the image associated with this resource to another image.
|
2015-08-24 03:41:09 +02:00
|
|
|
* The beatmap skin image takes priority over the default image.
|
2015-05-29 12:06:37 +02:00
|
|
|
* @param img the image to set
|
2014-07-05 01:59:57 +02:00
|
|
|
*/
|
|
|
|
public void setImage(Image img) {
|
|
|
|
if (skinImage != null)
|
|
|
|
this.skinImage = img;
|
|
|
|
else
|
|
|
|
this.defaultImage = img;
|
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
/**
|
2015-01-21 23:10:31 +01:00
|
|
|
* Sets an image associated with this resource to another image.
|
2015-08-24 03:41:09 +02:00
|
|
|
* The beatmap skin image takes priority over the default image.
|
2015-05-29 12:06:37 +02:00
|
|
|
* @param img the image to set
|
|
|
|
* @param index the index in the image array
|
2015-01-16 00:16:46 +01:00
|
|
|
*/
|
2015-01-21 23:10:31 +01:00
|
|
|
public void setImage(Image img, int index) {
|
|
|
|
if (skinImages != null) {
|
|
|
|
if (index < skinImages.length)
|
|
|
|
this.skinImages[index] = img;
|
|
|
|
} else {
|
|
|
|
if (index < defaultImages.length)
|
|
|
|
this.defaultImages[index] = img;
|
|
|
|
}
|
2015-01-16 00:16:46 +01:00
|
|
|
}
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
2014-07-05 01:59:57 +02:00
|
|
|
* Sets the default image for this resource.
|
2015-01-15 05:10:19 +01:00
|
|
|
* If the default image has already been loaded, this will do nothing.
|
2014-07-04 22:41:52 +02:00
|
|
|
*/
|
2014-07-05 01:59:57 +02:00
|
|
|
public void setDefaultImage() {
|
2015-01-21 23:10:31 +01:00
|
|
|
if (defaultImage != null || defaultImages != null)
|
2015-01-15 05:10:19 +01:00
|
|
|
return;
|
2015-03-15 04:28:50 +01:00
|
|
|
|
|
|
|
// try to load multiple images
|
2015-05-24 05:48:28 +02:00
|
|
|
File skinDir = Options.getSkin().getDirectory();
|
2015-01-21 23:10:31 +01:00
|
|
|
if (filenameFormat != null) {
|
2015-08-24 04:16:28 +02:00
|
|
|
if (skinDir != null && ((defaultImages = loadImageArray(skinDir)) != null)) {
|
|
|
|
isSkinned = true;
|
|
|
|
process();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((defaultImages = loadImageArray(null)) != null) {
|
|
|
|
isSkinned = false;
|
2015-01-21 23:10:31 +01:00
|
|
|
process();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
|
|
|
// try to load a single image
|
2015-08-24 04:16:28 +02:00
|
|
|
if (skinDir != null && ((defaultImage = loadImageSingle(skinDir)) != null)) {
|
|
|
|
isSkinned = true;
|
|
|
|
process();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((defaultImage = loadImageSingle(null)) != null) {
|
|
|
|
isSkinned = false;
|
2015-02-21 17:40:25 +01:00
|
|
|
process();
|
2015-03-14 13:11:33 +01:00
|
|
|
return;
|
2014-07-05 01:59:57 +02:00
|
|
|
}
|
2016-09-30 15:54:07 +02:00
|
|
|
String filenamebackup = filename;
|
|
|
|
filename = "dummy";
|
|
|
|
if ((defaultImage = loadImageSingle(null)) != null) {
|
|
|
|
isSkinned = false;
|
|
|
|
process();
|
|
|
|
filename = filenamebackup;
|
|
|
|
return;
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-03-14 13:11:33 +01:00
|
|
|
ErrorHandler.error(String.format("Could not find default image '%s'.", filename), null, false);
|
2014-07-05 01:59:57 +02:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Sets the associated beatmap skin image.
|
2014-07-05 01:59:57 +02:00
|
|
|
* If the path does not contain the image, the default image is used.
|
2015-05-29 12:06:37 +02:00
|
|
|
* @param dir the image directory to search
|
2015-01-08 04:36:39 +01:00
|
|
|
* @return true if a new skin image is loaded, false otherwise
|
2014-07-04 22:41:52 +02:00
|
|
|
*/
|
2015-08-24 03:41:09 +02:00
|
|
|
public boolean setBeatmapSkinImage(File dir) {
|
2015-01-15 05:10:19 +01:00
|
|
|
if (dir == null)
|
|
|
|
return false;
|
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
// destroy the existing images, if any
|
2015-08-24 03:41:09 +02:00
|
|
|
destroyBeatmapSkinImage();
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
// beatmap skins disabled
|
|
|
|
if (Options.isBeatmapSkinIgnored())
|
|
|
|
return false;
|
|
|
|
|
2015-03-15 04:28:50 +01:00
|
|
|
// try to load multiple images
|
|
|
|
if ((skinImages = loadImageArray(dir)) != null) {
|
2015-03-14 13:11:33 +01:00
|
|
|
process();
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
|
|
|
// try to load a single image
|
|
|
|
if ((skinImage = loadImageSingle(dir)) != null) {
|
2015-03-14 13:11:33 +01:00
|
|
|
process();
|
|
|
|
return true;
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-03-14 13:11:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-03-14 13:11:33 +01:00
|
|
|
/**
|
2015-03-15 04:28:50 +01:00
|
|
|
* Attempts to load multiple Images from the GameImage.
|
2015-05-29 12:06:37 +02:00
|
|
|
* @param dir the image directory to search, or null to use the default resource locations
|
2015-03-15 04:28:50 +01:00
|
|
|
* @return an array of the loaded images, or null if not found
|
2015-03-14 13:11:33 +01:00
|
|
|
*/
|
2015-03-15 04:28:50 +01:00
|
|
|
private Image[] loadImageArray(File dir) {
|
2015-01-21 23:10:31 +01:00
|
|
|
if (filenameFormat != null) {
|
2015-03-15 04:28:50 +01:00
|
|
|
for (String suffix : getSuffixes()) {
|
2015-03-14 13:11:33 +01:00
|
|
|
List<Image> list = new ArrayList<Image>();
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
// look for next image
|
2015-03-15 04:28:50 +01:00
|
|
|
String filenameFormatted = String.format(filenameFormat + suffix, i++);
|
2015-03-14 13:11:33 +01:00
|
|
|
String name = getImageFileName(filenameFormatted, dir, type, true);
|
|
|
|
if (name == null)
|
|
|
|
break;
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-03-14 13:11:33 +01:00
|
|
|
// add image to list
|
|
|
|
try {
|
|
|
|
Image img = new Image(name);
|
2015-05-29 12:06:37 +02:00
|
|
|
if (suffix.equals(HD_SUFFIX))
|
2015-03-14 13:11:33 +01:00
|
|
|
img = img.getScaledCopy(0.5f);
|
|
|
|
list.add(img);
|
|
|
|
} catch (SlickException e) {
|
|
|
|
ErrorHandler.error(String.format("Failed to set image '%s'.", name), null, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
if (!list.isEmpty())
|
2015-03-14 13:11:33 +01:00
|
|
|
return list.toArray(new Image[list.size()]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-03-15 04:28:50 +01:00
|
|
|
|
2015-03-14 13:11:33 +01:00
|
|
|
/**
|
2015-03-15 04:28:50 +01:00
|
|
|
* Attempts to load a single Image from the GameImage.
|
2015-05-29 12:06:37 +02:00
|
|
|
* @param dir the image directory to search, or null to use the default resource locations
|
2015-03-15 04:28:50 +01:00
|
|
|
* @return the loaded image, or null if not found
|
2015-03-14 13:11:33 +01:00
|
|
|
*/
|
2015-03-15 04:28:50 +01:00
|
|
|
private Image loadImageSingle(File dir) {
|
|
|
|
for (String suffix : getSuffixes()) {
|
|
|
|
String name = getImageFileName(filename + suffix, dir, type, true);
|
2015-03-14 13:11:33 +01:00
|
|
|
if (name != null) {
|
2015-02-21 17:40:25 +01:00
|
|
|
try {
|
|
|
|
Image img = new Image(name);
|
2015-05-29 12:06:37 +02:00
|
|
|
if (suffix.equals(HD_SUFFIX))
|
2015-03-14 13:11:33 +01:00
|
|
|
img = img.getScaledCopy(0.5f);
|
|
|
|
return img;
|
2015-02-21 17:40:25 +01:00
|
|
|
} catch (SlickException e) {
|
2015-03-14 13:11:33 +01:00
|
|
|
ErrorHandler.error(String.format("Failed to set image '%s'.", filename), null, false);
|
2015-01-21 23:10:31 +01:00
|
|
|
}
|
2015-02-21 17:40:25 +01:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
2015-03-14 13:11:33 +01:00
|
|
|
return null;
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
2014-07-05 01:59:57 +02:00
|
|
|
|
2015-08-24 04:16:28 +02:00
|
|
|
/**
|
|
|
|
* Returns whether the default image loaded is part of a game skin.
|
|
|
|
* @return true if a game skin image is loaded, false if the default image is loaded
|
|
|
|
*/
|
|
|
|
public boolean hasGameSkinImage() { return isSkinned; }
|
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Returns whether a beatmap skin image is currently loaded.
|
|
|
|
* @return true if a beatmap skin image exists
|
2015-01-16 00:16:46 +01:00
|
|
|
*/
|
2015-08-24 03:41:09 +02:00
|
|
|
public boolean hasBeatmapSkinImage() { return (skinImage != null && !skinImage.isDestroyed()); }
|
2015-01-16 00:16:46 +01:00
|
|
|
|
2015-01-15 05:10:19 +01:00
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Returns whether beatmap skin images are currently loaded.
|
|
|
|
* @return true if any beatmap skin image exists
|
2015-01-21 23:10:31 +01:00
|
|
|
*/
|
2015-08-24 03:41:09 +02:00
|
|
|
public boolean hasBeatmapSkinImages() { return (skinImages != null); }
|
2015-01-21 23:10:31 +01:00
|
|
|
|
|
|
|
/**
|
2015-08-24 03:41:09 +02:00
|
|
|
* Destroys the associated beatmap skin image(s), if any.
|
2015-01-15 05:10:19 +01:00
|
|
|
*/
|
2015-08-24 03:41:09 +02:00
|
|
|
public void destroyBeatmapSkinImage() {
|
2015-01-21 23:10:31 +01:00
|
|
|
if (skinImage == null && skinImages == null)
|
2015-01-15 05:10:19 +01:00
|
|
|
return;
|
|
|
|
try {
|
2015-01-21 23:10:31 +01:00
|
|
|
if (skinImage != null) {
|
|
|
|
if (!skinImage.isDestroyed())
|
|
|
|
skinImage.destroy();
|
|
|
|
skinImage = null;
|
|
|
|
}
|
|
|
|
if (skinImages != null) {
|
|
|
|
for (int i = 0; i < skinImages.length; i++) {
|
|
|
|
if (!skinImages[i].isDestroyed())
|
|
|
|
skinImages[i].destroy();
|
|
|
|
}
|
|
|
|
skinImages = null;
|
|
|
|
}
|
2015-01-15 05:10:19 +01:00
|
|
|
} catch (SlickException e) {
|
2015-08-24 03:41:09 +02:00
|
|
|
ErrorHandler.error(String.format("Failed to destroy beatmap skin images for '%s'.", this.name()), e, true);
|
2015-01-15 05:10:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-05 01:59:57 +02:00
|
|
|
/**
|
2015-01-08 04:36:39 +01:00
|
|
|
* Sub-method for image processing actions (via an override).
|
|
|
|
* @param img the image to process
|
|
|
|
* @param w the container width
|
|
|
|
* @param h the container height
|
|
|
|
* @return the processed image
|
2014-07-05 01:59:57 +02:00
|
|
|
*/
|
2015-03-15 04:28:50 +01:00
|
|
|
protected Image process_sub(Image img, int w, int h) { return img; }
|
2014-07-05 01:59:57 +02:00
|
|
|
|
|
|
|
/**
|
2015-01-08 04:36:39 +01:00
|
|
|
* Performs individual post-loading actions on the image.
|
2014-07-05 01:59:57 +02:00
|
|
|
*/
|
2015-01-15 05:10:19 +01:00
|
|
|
private void process() {
|
2015-02-19 01:35:26 +01:00
|
|
|
int unscaledWidth = UNSCALED_HEIGHT * containerWidth / containerHeight;
|
2015-01-21 23:10:31 +01:00
|
|
|
if (skinImages != null) {
|
|
|
|
for (int i = 0; i < skinImages.length; i++)
|
2015-02-19 01:35:26 +01:00
|
|
|
setImage(process_sub(getImages()[i], unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale()), i);
|
2015-01-21 23:10:31 +01:00
|
|
|
} else if (defaultImages != null && skinImage == null) {
|
|
|
|
for (int i = 0; i < defaultImages.length; i++)
|
2015-02-19 01:35:26 +01:00
|
|
|
setImage(process_sub(getImages()[i], unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale()), i);
|
2015-01-21 23:10:31 +01:00
|
|
|
} else
|
2015-02-19 01:35:26 +01:00
|
|
|
setImage(process_sub(getImage(), unscaledWidth, UNSCALED_HEIGHT).getScaledCopy(getUIscale()));
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|