Added a button to link to GitHub repository in main menu.
GitHub "mark" image is from: https://github.com/logos Also changed default screen resolution to 1024x768 since it's more likely to be supported. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
b54eb95747
commit
09a5979475
BIN
res/repo.png
Normal file
BIN
res/repo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
|
@ -24,8 +24,6 @@ import java.awt.Cursor;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
@ -81,18 +79,6 @@ public class ErrorHandler {
|
||||||
message = { desc, scroll },
|
message = { desc, scroll },
|
||||||
messageR = { descR, scroll };
|
messageR = { descR, scroll };
|
||||||
|
|
||||||
/**
|
|
||||||
* Address to report issues.
|
|
||||||
*/
|
|
||||||
private static URI uri;
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
uri = new URI("https://github.com/itdelatrisu/opsu/issues/new");
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
Log.error("Problem with error URI.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This class should not be instantiated.
|
// This class should not be instantiated.
|
||||||
private ErrorHandler() {}
|
private ErrorHandler() {}
|
||||||
|
|
||||||
|
@ -137,7 +123,7 @@ public class ErrorHandler {
|
||||||
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE,
|
||||||
null, optionsR, optionsR[2]);
|
null, optionsR, optionsR[2]);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
Desktop.getDesktop().browse(uri);
|
Desktop.getDesktop().browse(Options.ISSUES_URI);
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||||
} else if (n == 1)
|
} else if (n == 1)
|
||||||
Desktop.getDesktop().open(Options.LOG_FILE);
|
Desktop.getDesktop().open(Options.LOG_FILE);
|
||||||
|
|
|
@ -302,6 +302,13 @@ public enum GameImage {
|
||||||
protected Image process_sub(Image img, int w, int h) {
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
return img.getScaledCopy((h * 0.15f) / img.getHeight());
|
return img.getScaledCopy((h * 0.15f) / img.getHeight());
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
REPOSITORY ("repo", "png", false) {
|
||||||
|
@Override
|
||||||
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
|
return img.getScaledCopy((h / 17f) / img.getHeight());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package itdelatrisu.opsu.states;
|
package itdelatrisu.opsu.states;
|
||||||
|
|
||||||
|
import itdelatrisu.opsu.ErrorHandler;
|
||||||
import itdelatrisu.opsu.GameImage;
|
import itdelatrisu.opsu.GameImage;
|
||||||
import itdelatrisu.opsu.MenuButton;
|
import itdelatrisu.opsu.MenuButton;
|
||||||
import itdelatrisu.opsu.Opsu;
|
import itdelatrisu.opsu.Opsu;
|
||||||
|
@ -29,6 +30,8 @@ import itdelatrisu.opsu.audio.MusicController;
|
||||||
import itdelatrisu.opsu.audio.SoundController;
|
import itdelatrisu.opsu.audio.SoundController;
|
||||||
import itdelatrisu.opsu.audio.SoundEffect;
|
import itdelatrisu.opsu.audio.SoundEffect;
|
||||||
|
|
||||||
|
import java.awt.Desktop;
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
@ -83,6 +86,11 @@ public class MainMenu extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
private MenuButton musicPlay, musicPause, musicNext, musicPrevious;
|
private MenuButton musicPlay, musicPause, musicNext, musicPrevious;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button linking to repository.
|
||||||
|
*/
|
||||||
|
private MenuButton repoButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application start time, for drawing the total running time.
|
* Application start time, for drawing the total running time.
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +134,7 @@ public class MainMenu extends BasicGameState {
|
||||||
int width = container.getWidth();
|
int width = container.getWidth();
|
||||||
int height = container.getHeight();
|
int height = container.getHeight();
|
||||||
|
|
||||||
// initialize buttons
|
// initialize menu buttons
|
||||||
Image logoImg = GameImage.MENU_LOGO.getImage();
|
Image logoImg = GameImage.MENU_LOGO.getImage();
|
||||||
Image playImg = GameImage.MENU_PlAY.getImage();
|
Image playImg = GameImage.MENU_PlAY.getImage();
|
||||||
Image exitImg = GameImage.MENU_EXIT.getImage();
|
Image exitImg = GameImage.MENU_EXIT.getImage();
|
||||||
|
@ -154,6 +162,14 @@ public class MainMenu extends BasicGameState {
|
||||||
musicNext.setHoverScale(1.5f);
|
musicNext.setHoverScale(1.5f);
|
||||||
musicPrevious.setHoverScale(1.5f);
|
musicPrevious.setHoverScale(1.5f);
|
||||||
|
|
||||||
|
// initialize repository button
|
||||||
|
if (Desktop.isDesktopSupported()) { // only if a webpage can be opened
|
||||||
|
Image repoImg = GameImage.REPOSITORY.getImage();
|
||||||
|
repoButton = new MenuButton(repoImg,
|
||||||
|
(width * 0.995f) - repoImg.getWidth(), (height * 0.995f) - repoImg.getHeight()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,6 +211,10 @@ public class MainMenu extends BasicGameState {
|
||||||
g.fillRoundRect(width - 168, 54,
|
g.fillRoundRect(width - 168, 54,
|
||||||
148f * MusicController.getPosition() / osu.endTime, 5, 4);
|
148f * MusicController.getPosition() / osu.endTime, 5, 4);
|
||||||
|
|
||||||
|
// draw repository button
|
||||||
|
if (repoButton != null)
|
||||||
|
repoButton.draw();
|
||||||
|
|
||||||
// draw text
|
// draw text
|
||||||
g.setFont(Utils.FONT_MEDIUM);
|
g.setFont(Utils.FONT_MEDIUM);
|
||||||
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
||||||
|
@ -235,6 +255,8 @@ public class MainMenu extends BasicGameState {
|
||||||
musicPause.hoverUpdate(delta, mouseX, mouseY);
|
musicPause.hoverUpdate(delta, mouseX, mouseY);
|
||||||
musicNext.hoverUpdate(delta, mouseX, mouseY);
|
musicNext.hoverUpdate(delta, mouseX, mouseY);
|
||||||
musicPrevious.hoverUpdate(delta, mouseX, mouseY);
|
musicPrevious.hoverUpdate(delta, mouseX, mouseY);
|
||||||
|
if (repoButton != null)
|
||||||
|
repoButton.hoverUpdate(delta, mouseX, mouseY);
|
||||||
|
|
||||||
// window focus change: increase/decrease theme song volume
|
// window focus change: increase/decrease theme song volume
|
||||||
if (MusicController.isThemePlaying()) {
|
if (MusicController.isThemePlaying()) {
|
||||||
|
@ -314,6 +336,8 @@ public class MainMenu extends BasicGameState {
|
||||||
musicNext.setScale(1f);
|
musicNext.setScale(1f);
|
||||||
if (!musicPrevious.contains(mouseX, mouseY))
|
if (!musicPrevious.contains(mouseX, mouseY))
|
||||||
musicPrevious.setScale(1f);
|
musicPrevious.setScale(1f);
|
||||||
|
if (repoButton != null && !repoButton.contains(mouseX, mouseY))
|
||||||
|
repoButton.setScale(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -350,6 +374,15 @@ public class MainMenu extends BasicGameState {
|
||||||
MusicController.setPosition(0);
|
MusicController.setPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// repository button actions
|
||||||
|
else if (repoButton != null && repoButton.contains(x, y)) {
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().browse(Options.REPOSITORY_URI);
|
||||||
|
} catch (IOException e) {
|
||||||
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// start moving logo (if clicked)
|
// start moving logo (if clicked)
|
||||||
else if (!logoClicked) {
|
else if (!logoClicked) {
|
||||||
if (logo.contains(x, y)) {
|
if (logo.contains(x, y)) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -87,6 +89,25 @@ public class Options extends BasicGameState {
|
||||||
*/
|
*/
|
||||||
public static final String FONT_NAME = "kochi-gothic.ttf";
|
public static final String FONT_NAME = "kochi-gothic.ttf";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repository address.
|
||||||
|
*/
|
||||||
|
public static URI REPOSITORY_URI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue reporting address.
|
||||||
|
*/
|
||||||
|
public static URI ISSUES_URI;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
REPOSITORY_URI = new URI("https://github.com/itdelatrisu/opsu");
|
||||||
|
ISSUES_URI = new URI("https://github.com/itdelatrisu/opsu/issues/new");
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
Log.error("Problem loading URIs.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The beatmap directory.
|
* The beatmap directory.
|
||||||
*/
|
*/
|
||||||
|
@ -559,7 +580,7 @@ public class Options extends BasicGameState {
|
||||||
/**
|
/**
|
||||||
* Index (row) in resolutions[][] array.
|
* Index (row) in resolutions[][] array.
|
||||||
*/
|
*/
|
||||||
private static Resolution resolution = Resolution.RES_1280_800;
|
private static Resolution resolution = Resolution.RES_1024_768;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Whether or not the game should run in fullscreen mode.
|
// * Whether or not the game should run in fullscreen mode.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user