move bubble notification colors to Colors file

This commit is contained in:
yugecin 2017-05-26 21:44:23 +02:00
parent 1df25520e4
commit 42bc11ef75
20 changed files with 54 additions and 56 deletions

View File

@ -18,6 +18,7 @@
package itdelatrisu.opsu;
import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.Fonts;
import java.io.File;
@ -732,7 +733,7 @@ public enum GameImage {
String err = String.format("Could not find default image '%s'.", filename);
Log.warn(err);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
/**
@ -796,8 +797,7 @@ public enum GameImage {
list.add(img);
} catch (SlickException e) {
BubNotifListener.EVENT.make().onBubNotif(
String.format("Failed to set image '%s'.", name),
BubNotifListener.COMMONCOLOR_RED);
String.format("Failed to set image '%s'.", name), Colors.BUB_RED);
break;
}
}
@ -825,8 +825,7 @@ public enum GameImage {
return img;
} catch (SlickException e) {
BubNotifListener.EVENT.make().onBubNotif(
String.format("Failed to set image '%s'.", filename),
BubNotifListener.COMMONCOLOR_RED);
String.format("Failed to set image '%s'.", filename), Colors.BUB_RED);
}
}
return null;

View File

@ -33,6 +33,7 @@ import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import itdelatrisu.opsu.ui.Colors;
import org.lwjgl.BufferUtils;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;
@ -158,7 +159,7 @@ public class MusicController {
} catch (Exception e) {
String err = String.format("Could not play track '%s'.", file.getName());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
}

View File

@ -36,6 +36,7 @@ import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.LineUnavailableException;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
@ -220,8 +221,7 @@ public class SoundController {
for (SoundEffect s : SoundEffect.values()) {
if ((currentFileName = getSoundFileName(s.getFileName())) == null) {
BubNotifListener.EVENT.make().onBubNotif(
"Could not find sound file " + s.getFileName(),
BubNotifListener.COLOR_ORANGE);
"Could not find sound file " + s.getFileName(), Colors.BUB_ORANGE);
continue;
}
MultiClip newClip = loadClip(currentFileName, currentFileName.endsWith(".mp3"));
@ -241,8 +241,7 @@ public class SoundController {
String filename = String.format("%s-%s", ss.getName(), s.getFileName());
if ((currentFileName = getSoundFileName(filename)) == null) {
BubNotifListener.EVENT.make().onBubNotif(
"Could not find hit sound file " + filename,
BubNotifListener.COLOR_ORANGE);
"Could not find hit sound file " + filename, Colors.BUB_ORANGE);
continue;
}
MultiClip newClip = loadClip(currentFileName, false);

View File

@ -31,6 +31,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.Nullable;
@ -888,7 +889,7 @@ public class BeatmapParser {
private static void logAndShowErrorNotification(Exception e, String message, Object... formatArgs) {
message = String.format(message, formatArgs);
Log.error(message, e);
BubNotifListener.EVENT.make().onBubNotif(message, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(message, Colors.BUB_RED);
}
}

View File

@ -21,6 +21,7 @@ package itdelatrisu.opsu.beatmap;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.audio.MusicController;
import itdelatrisu.opsu.db.BeatmapDB;
import itdelatrisu.opsu.ui.Colors;
import yugecin.opsudance.events.BubNotifListener;
import java.io.File;
@ -214,8 +215,7 @@ public class BeatmapSetList {
try {
Utils.deleteToTrash(dir);
} catch (IOException e) {
BubNotifListener.EVENT.make().onBubNotif("Could not delete song group",
BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif("Could not delete song group", Colors.BUB_ORANGE);
}
if (ws != null)
ws.resume();
@ -271,7 +271,7 @@ public class BeatmapSetList {
try {
Utils.deleteToTrash(file);
} catch (IOException e) {
BubNotifListener.EVENT.make().onBubNotif("Could not delete song", BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif("Could not delete song", Colors.BUB_ORANGE);
}
if (ws != null)
ws.resume();

View File

@ -38,6 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BarNotifListener;
import yugecin.opsudance.events.BubNotifListener;
@ -100,8 +101,7 @@ public class BeatmapWatchService {
ws.register(config.beatmapDir.toPath());
} catch (IOException e) {
Log.error("Could not create watch service", e);
BubNotifListener.EVENT.make().onBubNotif("Could not create watch service",
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif("Could not create watch service", Colors.BUB_RED);
return;
}

View File

@ -23,6 +23,7 @@ import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import itdelatrisu.opsu.ui.Colors;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.newdawn.slick.util.Log;
@ -96,7 +97,7 @@ public class OszUnpacker {
} catch (ZipException e) {
String err = String.format("Failed to unzip file %s to dest %s.", file.getAbsolutePath(), dest.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
}

View File

@ -33,6 +33,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.events.BubNotifListener;
@ -218,7 +219,7 @@ public class Download {
else if (redirectCount > MAX_REDIRECTS)
error = String.format("Download for URL '%s' is attempting too many redirects (over %d).", base.toString(), MAX_REDIRECTS);
if (error != null) {
BubNotifListener.EVENT.make().onBubNotif(error, BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif(error, Colors.BUB_ORANGE);
throw new IOException();
}

View File

@ -411,7 +411,7 @@ public class DownloadNode {
if (download == null) {
BubNotifListener.EVENT.make().onBubNotif(
"Trying to draw download information for button without Download object",
BubNotifListener.COLOR_ORANGE);
Colors.BUB_ORANGE);
return;
}

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import itdelatrisu.opsu.ui.Colors;
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
import org.newdawn.slick.util.Log;
@ -274,7 +275,7 @@ public class Replay {
public void save() {
// create replay directory
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
BubNotifListener.EVENT.make().onBubNotif("Failed to create replay directory", BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif("Failed to create replay directory", Colors.BUB_RED);
return;
}

View File

@ -28,6 +28,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
@ -68,7 +69,7 @@ public class ReplayImporter {
if (!config.replayDir.isDirectory() && !config.replayDir.mkdir()) {
String err = String.format("Failed to create replay directory '%s'.", config.replayDir.getAbsolutePath());
Log.error(err);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
return;
}
@ -82,8 +83,7 @@ public class ReplayImporter {
moveToFailedDirectory(file);
String err = String.format("Failed to import replay '%s'. The replay file could not be parsed.", file.getName());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err,
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
continue;
}
Beatmap beatmap = BeatmapSetList.get().getBeatmapFromHash(r.beatmapHash);
@ -102,7 +102,7 @@ public class ReplayImporter {
moveToFailedDirectory(file);
String err = String.format("Failed to import replay '%s'. The associated beatmap could not be found.", file.getName());
Log.error(err);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
}

View File

@ -29,6 +29,7 @@ import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.Color;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
@ -292,8 +293,7 @@ public class SkinLoader {
} catch (IOException e) {
String err = String.format("Failed to read file '%s'.", skinFile.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err,
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
return skin;

View File

@ -336,7 +336,7 @@ public class Game extends ComplexOpsuState {
Log.error("could not create offscreen graphics", e);
BubNotifListener.EVENT.make().onBubNotif(
"Exception while creating offscreen graphics. See logfile for details.",
BubNotifListener.COMMONCOLOR_RED);
Colors.BUB_RED);
}
// initialize music position bar location
@ -1453,8 +1453,7 @@ public class Game extends ComplexOpsuState {
}
if (beatmap == null || beatmap.objects == null) {
BubNotifListener.EVENT.make().onBubNotif("Game was running without a beatmap",
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif("Game was running without a beatmap", Colors.BUB_RED);
displayContainer.switchStateInstantly(songMenuState);
}
@ -1561,8 +1560,7 @@ public class Game extends ComplexOpsuState {
} catch (Exception e) {
String message = String.format("Failed to create %s at index %d:\n%s", hitObject.getTypeName(), i, hitObject.toString());
Log.error(message, e);
BubNotifListener.EVENT.make().onBubNotif(message,
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(message, Colors.BUB_RED);
gameObjects[i] = new DummyObject(hitObject);
}
}
@ -2149,7 +2147,7 @@ public class Game extends ComplexOpsuState {
} else {
if (replay.frames == null) {
BubNotifListener.EVENT.make().onBubNotif("Attempting to set a replay with no frames.",
BubNotifListener.COLOR_ORANGE);
Colors.BUB_ORANGE);
return;
}
this.isReplay = true;

View File

@ -570,8 +570,7 @@ public class MainMenu extends BaseOpsuState {
"The repository web page could not be opened.");
} catch (IOException e) {
Log.error("could not browse to repo", e);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo",
BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo", Colors.BUB_ORANGE);
}
return true;
}
@ -584,8 +583,7 @@ public class MainMenu extends BaseOpsuState {
"The repository web page could not be opened.");
} catch (IOException e) {
Log.error("could not browse to repo", e);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo",
BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif("Could not browse to repo", Colors.BUB_ORANGE);
}
return true;
}

View File

@ -49,6 +49,11 @@ public class Colors {
BLACK_BG_NORMAL = new Color(0, 0, 0, 0.25f),
BLACK_BG_HOVER = new Color(0, 0, 0, 0.5f),
BLACK_BG_FOCUS = new Color(0, 0, 0, 0.75f),
BUB_GREEN = new Color(98, 131, 59),
BUB_WHITE = new Color(220, 220, 220),
BUB_PURPLE = new Color(94, 46, 149),
BUB_RED = new Color(141, 49, 16),
BUB_ORANGE = new Color(138, 72, 51),
GHOST_LOGO = new Color(1.0f, 1.0f, 1.0f, 0.25f);
// This class should not be instantiated.

View File

@ -26,6 +26,7 @@ import itdelatrisu.opsu.downloads.DownloadNode;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.render.CurveRenderState;
import itdelatrisu.opsu.replay.PlaybackSpeed;
import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.Cursor;
import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.UI;
@ -340,15 +341,13 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
return true;
}
if (DownloadList.get().hasActiveDownloads()) {
BubNotifListener.EVENT.make().onBubNotif(DownloadList.EXIT_CONFIRMATION,
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(DownloadList.EXIT_CONFIRMATION, Colors.BUB_RED);
exitRequested = false;
exitconfirmation = System.currentTimeMillis();
return false;
}
if (updater.getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
BubNotifListener.EVENT.make().onBubNotif(Updater.EXIT_CONFIRMATION,
BubNotifListener.COMMONCOLOR_PURPLE);
BubNotifListener.EVENT.make().onBubNotif(Updater.EXIT_CONFIRMATION, Colors.BUB_PURPLE);
exitRequested = false;
exitconfirmation = System.currentTimeMillis();
return false;
@ -387,8 +386,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
try {
setDisplayMode(width, height, OPTION_FULLSCREEN.state);
} catch (Exception e) {
BubNotifListener.EVENT.make().onBubNotif("Failed to change resolution",
BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif("Failed to change resolution", Colors.BUB_RED);
Log.error("Failed to set display mode.", e);
}
}
@ -410,7 +408,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
fullscreen = false;
String msg = String.format("Fullscreen mode is not supported for %sx%s", width, height);
Log.warn(msg);
BubNotifListener.EVENT.make().onBubNotif(msg, BubNotifListener.COLOR_ORANGE);
BubNotifListener.EVENT.make().onBubNotif(msg, Colors.BUB_ORANGE);
}
}

View File

@ -25,12 +25,6 @@ public interface BubNotifListener {
Event<BubNotifListener> EVENT = new Event<>(BubNotifListener.class);
public static final Color COMMONCOLOR_GREEN = new Color(98, 131, 59);
public static final Color COMMONCOLOR_WHITE = new Color(220, 220, 220);
public static final Color COMMONCOLOR_PURPLE = new Color(94, 46, 149);
public static final Color COMMONCOLOR_RED = new Color(141, 49, 16);
public static final Color COLOR_ORANGE = new Color(138, 72, 51);
void onBubNotif(String message, Color borderColor);
}

View File

@ -24,6 +24,7 @@ import itdelatrisu.opsu.audio.SoundController;
import itdelatrisu.opsu.audio.SoundEffect;
import itdelatrisu.opsu.beatmap.Beatmap;
import itdelatrisu.opsu.beatmap.TimingPoint;
import itdelatrisu.opsu.ui.Colors;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
@ -153,7 +154,7 @@ public class Configuration {
}
if (!defaultDir.isDirectory() && !defaultDir.mkdir()) {
String msg = String.format("Failed to create %s directory at '%s'.", kind, defaultDir.getAbsolutePath());
BubNotifListener.EVENT.make().onBubNotif(msg, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(msg, Colors.BUB_RED);
}
return defaultDir;
}
@ -214,8 +215,7 @@ public class Configuration {
if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) {
BubNotifListener.EVENT.make().onBubNotif(
String.format( "Failed to create screenshot directory at '%s'.",
screenshotDir.getAbsolutePath()),
BubNotifListener.COMMONCOLOR_RED);
screenshotDir.getAbsolutePath()), Colors.BUB_RED);
return;
}
@ -250,7 +250,7 @@ public class Configuration {
}
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
BubNotifListener.COMMONCOLOR_PURPLE);
Colors.BUB_PURPLE);
} catch (Exception e) {
ErrorHandler.error("Failed to take a screenshot.", e).show();
}

View File

@ -18,6 +18,7 @@
package yugecin.opsudance.options;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.ui.Colors;
import yugecin.opsudance.events.BubNotifListener;
public class NumericOption extends Option {
@ -53,7 +54,7 @@ public class NumericOption extends Option {
val = Utils.clamp(Integer.parseInt(s), min, max);
} catch (Exception ignored) {
BubNotifListener.EVENT.make().onBubNotif("Failed to parse " + configurationName + " option",
BubNotifListener.COMMONCOLOR_RED);
Colors.BUB_RED);
}
}

View File

@ -17,6 +17,7 @@
*/
package yugecin.opsudance.options;
import itdelatrisu.opsu.ui.Colors;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.events.BubNotifListener;
@ -79,7 +80,7 @@ public class OptionsService {
} catch (IOException e) {
String err = String.format("Failed to read option file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
config.loadDirectories();
}
@ -108,7 +109,7 @@ public class OptionsService {
} catch (IOException e) {
String err = String.format("Failed to write to file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
Log.error(err, e);
BubNotifListener.EVENT.make().onBubNotif(err, BubNotifListener.COMMONCOLOR_RED);
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
}
}