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;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.SlickException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Game images.
|
|
|
|
*/
|
|
|
|
public enum GameImage {
|
2015-01-25 04:23:49 +01:00
|
|
|
// Cursor
|
|
|
|
CURSOR ("cursor", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(1 + ((h - 600) / 1000f));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CURSOR_MIDDLE ("cursormiddle", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(1 + ((h - 600) / 1000f));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CURSOR_TRAIL ("cursortrail", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(1 + ((h - 600) / 1000f));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CURSOR_OLD ("cursor2", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(1 + ((h - 600) / 1000f));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CURSOR_TRAIL_OLD ("cursortrail2", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(1 + ((h - 600) / 1000f));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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"),
|
|
|
|
SKIP ("play-skip", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.1f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
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) {
|
|
|
|
return img.getScaledCopy((h / 3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
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) {
|
|
|
|
return img.getScaledCopy((h / 3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
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) {
|
|
|
|
return img.getScaledCopy((h / 3f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
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-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"),
|
|
|
|
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-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-01-22 00:56:53 +01:00
|
|
|
SPINNER_CIRCLE ("spinner-circle", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(h * 9 / 10, h * 9 / 10);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SPINNER_APPROACHCIRCLE ("spinner-approachcircle", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(h * 9 / 10, h * 9 / 10);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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"),
|
2014-07-04 22:41:52 +02:00
|
|
|
|
2015-01-28 09:47:24 +01:00
|
|
|
// Score Data
|
2015-01-21 23:10:31 +01:00
|
|
|
COMBO_BURST ("comboburst", "comboburst-%d", "png"),
|
2015-01-16 00:16:46 +01:00
|
|
|
SCOREBAR_BG ("scorebar-bg", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-01-26 00:36:54 +01:00
|
|
|
return img.getScaledCopy((w * 0.565f) / img.getWidth());
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
|
|
|
},
|
2015-01-26 00:36:54 +01:00
|
|
|
SCOREBAR_COLOUR ("scorebar-colour", "scorebar-colour-%d", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
2015-01-26 00:36:54 +01:00
|
|
|
return img.getScaledCopy((w * 0.521f) / img.getWidth());
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
|
|
|
},
|
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"),
|
|
|
|
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"),
|
|
|
|
HIT_SLIDER10 ("sliderpoint10", "png"),
|
|
|
|
HIT_SLIDER30 ("sliderpoint30", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_SS ("ranking-X", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SS_SMALL ("ranking-X-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_SSH ("ranking-XH", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SSH_SMALL ("ranking-XH-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_S ("ranking-S", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_S_SMALL ("ranking-S-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_SH ("ranking-SH", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_SH_SMALL ("ranking-SH-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_A ("ranking-A", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_A_SMALL ("ranking-A-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_B ("ranking-B", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_B_SMALL ("ranking-B-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_C ("ranking-C", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_C_SMALL ("ranking-C-small", "png"),
|
2015-01-29 07:50:26 +01:00
|
|
|
RANKING_D ("ranking-D", "png") {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h / 2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_D_SMALL ("ranking-D-small", "png"),
|
|
|
|
RANKING_PANEL ("ranking-panel", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.63f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_PERFECT ("ranking-perfect", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.16f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_TITLE ("ranking-title", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.15f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_MAXCOMBO ("ranking-maxcombo", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.05f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
RANKING_ACCURACY ("ranking-accuracy", "png") {
|
2015-01-08 04:36:39 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.05f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-16 00:16:46 +01:00
|
|
|
DEFAULT_0 ("default-0", "png"),
|
|
|
|
DEFAULT_1 ("default-1", "png"),
|
|
|
|
DEFAULT_2 ("default-2", "png"),
|
|
|
|
DEFAULT_3 ("default-3", "png"),
|
|
|
|
DEFAULT_4 ("default-4", "png"),
|
|
|
|
DEFAULT_5 ("default-5", "png"),
|
|
|
|
DEFAULT_6 ("default-6", "png"),
|
|
|
|
DEFAULT_7 ("default-7", "png"),
|
|
|
|
DEFAULT_8 ("default-8", "png"),
|
|
|
|
DEFAULT_9 ("default-9", "png"),
|
|
|
|
SCORE_0 ("score-0", "png"),
|
|
|
|
SCORE_1 ("score-1", "png"),
|
|
|
|
SCORE_2 ("score-2", "png"),
|
|
|
|
SCORE_3 ("score-3", "png"),
|
|
|
|
SCORE_4 ("score-4", "png"),
|
|
|
|
SCORE_5 ("score-5", "png"),
|
|
|
|
SCORE_6 ("score-6", "png"),
|
|
|
|
SCORE_7 ("score-7", "png"),
|
|
|
|
SCORE_8 ("score-8", "png"),
|
|
|
|
SCORE_9 ("score-9", "png"),
|
|
|
|
SCORE_COMMA ("score-comma", "png"),
|
|
|
|
SCORE_DOT ("score-dot", "png"),
|
|
|
|
SCORE_PERCENT ("score-percent", "png"),
|
|
|
|
SCORE_X ("score-x", "png"),
|
2015-01-21 01:01:18 +01:00
|
|
|
LIGHTING ("lighting", "png"),
|
|
|
|
LIGHTING1 ("lighting1", "png"),
|
|
|
|
|
|
|
|
// Game Mods
|
|
|
|
MOD_EASY ("selection-mod-easy", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_NO_FAIL ("selection-mod-nofail", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_HARD_ROCK ("selection-mod-hardrock", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_SUDDEN_DEATH ("selection-mod-suddendeath", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_SPUN_OUT ("selection-mod-spunout", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_AUTO ("selection-mod-autoplay", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_HALF_TIME ("selection-mod-halftime", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_DOUBLE_TIME ("selection-mod-doubletime", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_HIDDEN ("selection-mod-hidden", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
|
|
|
MOD_FLASHLIGHT ("selection-mod-flashlight", "png", false, false) {
|
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.12f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-08 05:45:21 +01:00
|
|
|
|
|
|
|
// Non-Game Components
|
2015-01-20 20:52:02 +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-01-18 23:01:13 +01:00
|
|
|
MENU_BACK ("menu-back", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.1f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_BUTTON_BG ("menu-button-background", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(w / 2, h / 6);
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_TAB ("selection-tab", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.033f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_SEARCH ("search", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(Utils.FONT_BOLD.getLineHeight() * 2f / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_OPTIONS ("options", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(Utils.FONT_BOLD.getLineHeight() * 2f / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
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) {
|
|
|
|
int r = (int) (Utils.FONT_LARGE.getLineHeight() * 0.75f + Utils.FONT_DEFAULT.getLineHeight());
|
|
|
|
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) {
|
|
|
|
int r = (int) (Utils.FONT_LARGE.getLineHeight() * 0.75f + Utils.FONT_DEFAULT.getLineHeight());
|
|
|
|
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) {
|
|
|
|
return img.getScaledCopy((h / 1.2f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +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) {
|
|
|
|
return img.getScaledCopy(MENU_LOGO.getImage().getWidth() * 0.83f / img.getWidth());
|
|
|
|
}
|
|
|
|
},
|
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) {
|
|
|
|
return img.getScaledCopy(MENU_LOGO.getImage().getWidth() * 0.66f / img.getWidth());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_BUTTON_MID ("button-middle", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy(w / 2, img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
MENU_BUTTON_LEFT ("button-left", "png", false, false),
|
|
|
|
MENU_BUTTON_RIGHT ("button-right", "png", false, false),
|
|
|
|
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),
|
|
|
|
RANKING_RETRY ("ranking-retry", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.15f) / img.getHeight());
|
|
|
|
}
|
|
|
|
},
|
2015-01-18 23:01:13 +01:00
|
|
|
RANKING_EXIT ("ranking-back", "png", false, false) {
|
2015-01-08 05:45:21 +01:00
|
|
|
@Override
|
|
|
|
protected Image process_sub(Image img, int w, int h) {
|
|
|
|
return img.getScaledCopy((h * 0.15f) / img.getHeight());
|
|
|
|
}
|
2015-01-16 19:42:54 +01:00
|
|
|
},
|
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-01-08 05:45:21 +01:00
|
|
|
};
|
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. */
|
2014-07-04 22:41:52 +02:00
|
|
|
private String filename;
|
|
|
|
|
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-01-16 00:16:46 +01:00
|
|
|
private byte type;
|
|
|
|
|
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-01-18 23:01:13 +01:00
|
|
|
private boolean skinnable;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Whether or not to preload the image when the program starts. */
|
2015-01-18 23:01:13 +01:00
|
|
|
private 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-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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
|
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-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
|
|
|
/**
|
|
|
|
* Returns a list of possible filenames (with extensions).
|
|
|
|
* @return filename list
|
|
|
|
*/
|
|
|
|
private static List<String> getFileNames(String filename, byte type) {
|
|
|
|
List<String> list = new ArrayList<String>(2);
|
|
|
|
if ((type & IMG_PNG) != 0)
|
|
|
|
list.add(String.format("%s.png", filename));
|
|
|
|
if ((type & IMG_JPG) != 0)
|
|
|
|
list.add(String.format("%s.jpg", filename));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
2015-01-18 23:01:13 +01:00
|
|
|
* Constructor for game-related images (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) {
|
2014-07-04 22:41:52 +02:00
|
|
|
this.filename = filename;
|
2015-01-16 00:16:46 +01:00
|
|
|
this.type = getType(type);
|
2015-01-18 23:01:13 +01:00
|
|
|
this.skinnable = true;
|
|
|
|
this.preload = true;
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
/**
|
|
|
|
* Constructor for an array of game-related images (skinnable and preloaded).
|
|
|
|
* @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) {
|
|
|
|
this.filename = filename;
|
|
|
|
this.filenameFormat = filenameFormat;
|
|
|
|
this.type = getType(type);
|
|
|
|
this.skinnable = true;
|
|
|
|
this.preload = true;
|
|
|
|
}
|
|
|
|
|
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-01-18 23:01:13 +01:00
|
|
|
* @param skinnable whether or not the image is skinnable
|
|
|
|
* @param preload whether or not to preload the image
|
2015-01-08 05:45:21 +01:00
|
|
|
*/
|
2015-01-18 23:01:13 +01:00
|
|
|
GameImage(String filename, String type, boolean skinnable, 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-01-18 23:01:13 +01:00
|
|
|
this.skinnable = skinnable;
|
|
|
|
this.preload = preload;
|
2015-01-08 05:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-01-18 23:01:13 +01:00
|
|
|
* Returns whether or not the image is skinnable.
|
|
|
|
* @return true if skinnable
|
|
|
|
*/
|
|
|
|
public boolean isSkinnable() { return skinnable; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* The 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-01-21 23:10:31 +01:00
|
|
|
/**
|
|
|
|
* Returns the image array associated with this resource.
|
|
|
|
* The skin images takes priority over the default images.
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
* The skin image takes priority over the default image.
|
|
|
|
*/
|
|
|
|
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.
|
|
|
|
* The skin image takes priority over the default image.
|
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-01-21 23:10:31 +01:00
|
|
|
|
|
|
|
// load image array
|
|
|
|
if (filenameFormat != null) {
|
|
|
|
List<Image> list = new ArrayList<Image>();
|
|
|
|
int i = 0;
|
|
|
|
boolean loaded;
|
|
|
|
do {
|
|
|
|
loaded = false;
|
|
|
|
for (String name : getFileNames(String.format(filenameFormat, i), type)) {
|
|
|
|
try {
|
|
|
|
// try loading the image
|
|
|
|
Image img = new Image(name);
|
2015-01-22 06:44:45 +01:00
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
// image successfully loaded
|
|
|
|
list.add(img);
|
|
|
|
loaded = true;
|
|
|
|
break;
|
|
|
|
} catch (SlickException | RuntimeException e) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while (loaded);
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
this.defaultImages = list.toArray(new Image[list.size()]);
|
|
|
|
process();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// load single image
|
|
|
|
for (String name : getFileNames(filename, type)) {
|
2015-01-16 00:16:46 +01:00
|
|
|
try {
|
|
|
|
// try loading the image
|
|
|
|
Image img = new Image(name);
|
|
|
|
|
|
|
|
// image successfully loaded
|
|
|
|
this.defaultImage = img;
|
|
|
|
process();
|
|
|
|
return;
|
|
|
|
} catch (SlickException | RuntimeException e) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-05 01:59:57 +02:00
|
|
|
}
|
2015-01-16 03:55:26 +01:00
|
|
|
ErrorHandler.error(String.format("Failed to set default image '%s'.", filename), null, false);
|
2014-07-05 01:59:57 +02:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-05 01:59:57 +02:00
|
|
|
* Sets the associated skin image.
|
|
|
|
* If the path does not contain the image, the default image is used.
|
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-01-08 04:36:39 +01:00
|
|
|
public boolean setSkinImage(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-01-15 05:10:19 +01:00
|
|
|
destroySkinImage();
|
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-01-21 23:10:31 +01:00
|
|
|
// look for multiple skin images
|
|
|
|
if (filenameFormat != null) {
|
|
|
|
List<Image> list = new ArrayList<Image>();
|
|
|
|
int i = 0;
|
|
|
|
boolean loaded;
|
|
|
|
do {
|
|
|
|
loaded = false;
|
|
|
|
for (String name : getFileNames(String.format(filenameFormat, i), type)) {
|
|
|
|
File file = new File(dir, name);
|
|
|
|
if (!file.isFile())
|
|
|
|
continue;
|
|
|
|
try {
|
|
|
|
// try loading the image
|
|
|
|
Image img = new Image(file.getAbsolutePath());
|
2015-01-22 06:44:45 +01:00
|
|
|
|
2015-01-21 23:10:31 +01:00
|
|
|
// image successfully loaded
|
|
|
|
list.add(img);
|
|
|
|
loaded = true;
|
|
|
|
break;
|
|
|
|
} catch (SlickException | RuntimeException e) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
} while (loaded);
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
this.skinImages = list.toArray(new Image[list.size()]);
|
|
|
|
process();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
// look for a skin image
|
|
|
|
String errorFile = null;
|
2015-01-21 23:10:31 +01:00
|
|
|
for (String name : getFileNames(filename, type)) {
|
2015-01-16 00:16:46 +01:00
|
|
|
File file = new File(dir, name);
|
|
|
|
if (!file.isFile())
|
|
|
|
continue;
|
|
|
|
try {
|
|
|
|
// try loading the image
|
|
|
|
Image img = new Image(file.getAbsolutePath());
|
|
|
|
|
|
|
|
// image successfully loaded
|
|
|
|
this.skinImage = img;
|
2015-01-15 05:10:19 +01:00
|
|
|
process();
|
2015-01-08 04:36:39 +01:00
|
|
|
return true;
|
2015-01-16 00:16:46 +01:00
|
|
|
} catch (SlickException | RuntimeException e) {
|
|
|
|
errorFile = file.getAbsolutePath();
|
|
|
|
continue;
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
2015-01-16 00:16:46 +01:00
|
|
|
skinImage = null;
|
|
|
|
if (errorFile != null)
|
2015-01-16 03:55:26 +01:00
|
|
|
ErrorHandler.error(String.format("Failed to set skin image '%s'.", errorFile), null, false);
|
2015-01-16 00:16:46 +01:00
|
|
|
return false;
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|
2014-07-05 01:59:57 +02:00
|
|
|
|
2015-01-16 00:16:46 +01:00
|
|
|
/**
|
|
|
|
* Returns whether a skin image is currently loaded.
|
|
|
|
* @return true if skin image exists
|
|
|
|
*/
|
|
|
|
public boolean hasSkinImage() { return (skinImage != null && !skinImage.isDestroyed()); }
|
|
|
|
|
2015-01-15 05:10:19 +01:00
|
|
|
/**
|
2015-01-21 23:10:31 +01:00
|
|
|
* Returns whether skin images are currently loaded.
|
|
|
|
* @return true if any skin image exists
|
|
|
|
*/
|
|
|
|
public boolean hasSkinImages() { return (skinImages != null); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys the associated skin image(s), if any.
|
2015-01-15 05:10:19 +01:00
|
|
|
*/
|
2015-01-25 04:23:49 +01:00
|
|
|
public void destroySkinImage() {
|
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-01-21 23:10:31 +01:00
|
|
|
ErrorHandler.error(String.format("Failed to destroy 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-01-08 04:36:39 +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-01-21 23:10:31 +01:00
|
|
|
if (skinImages != null) {
|
|
|
|
for (int i = 0; i < skinImages.length; i++)
|
|
|
|
setImage(process_sub(getImages()[i], containerWidth, containerHeight), i);
|
|
|
|
} else if (defaultImages != null && skinImage == null) {
|
|
|
|
for (int i = 0; i < defaultImages.length; i++)
|
|
|
|
setImage(process_sub(getImages()[i], containerWidth, containerHeight), i);
|
|
|
|
} else
|
|
|
|
setImage(process_sub(getImage(), containerWidth, containerHeight));
|
2015-01-08 04:36:39 +01:00
|
|
|
}
|
2014-07-04 22:41:52 +02:00
|
|
|
}
|