Show option to download Steam if it is not installed

This commit is contained in:
kuroppoi 2023-01-18 17:47:21 +01:00
parent 8b50677722
commit 9061c47c76
2 changed files with 19 additions and 12 deletions

View file

@ -1,10 +1,12 @@
package brainwine.gui;
import static brainwine.gui.GuiConstants.COMMUNITY_HUB_URL;
import static brainwine.gui.GuiConstants.DEEPWORLD_ASSEMBLY_PATH;
import static brainwine.gui.GuiConstants.DEEPWORLD_PLAYERPREFS;
import static brainwine.gui.GuiConstants.RUN_GAME_URL;
import static brainwine.gui.GuiConstants.HTTP_COMMUNITY_HUB_URL;
import static brainwine.gui.GuiConstants.HTTP_STEAM_DOWNLOAD_URL;
import static brainwine.gui.GuiConstants.STEAM_COMMUNITY_HUB_URL;
import static brainwine.gui.GuiConstants.STEAM_REGISTRY_LOCATION;
import static brainwine.gui.GuiConstants.STEAM_RUN_GAME_URL;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
@ -53,9 +55,13 @@ public class GamePanel extends JPanel {
}
private void startGame() {
// Check if steam is installed
// Show option to download Steam if it is not installed
if(!isSteamInstalled()) {
JOptionPane.showMessageDialog(getRootPane(), "Steam is required for this action.", "Attention", JOptionPane.WARNING_MESSAGE);
if(JOptionPane.showConfirmDialog(getRootPane(), "You need the Steam desktop application to play Deepworld on Windows.\n"
+ "Would you like to go to the download page?", "Attention", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
DesktopUtils.browseUrl(HTTP_STEAM_DOWNLOAD_URL);
}
return;
}
@ -80,18 +86,18 @@ public class GamePanel extends JPanel {
}
// Start the game!
DesktopUtils.browseUrl(RUN_GAME_URL);
DesktopUtils.browseUrl(STEAM_RUN_GAME_URL);
}
private void openCommunityHub() {
// Check if steam is installed
// If Steam is not installed, open the community hub in a web browser
if(!isSteamInstalled()) {
JOptionPane.showMessageDialog(getRootPane(), "Steam is required for this action.", "Attention", JOptionPane.WARNING_MESSAGE);
DesktopUtils.browseUrl(HTTP_COMMUNITY_HUB_URL);
return;
}
// Open the community hub!
DesktopUtils.browseUrl(COMMUNITY_HUB_URL);
// Otherwise, open it through Steam!
DesktopUtils.browseUrl(STEAM_COMMUNITY_HUB_URL);
}
private boolean isSteamInstalled() {

View file

@ -12,9 +12,10 @@ public class GuiConstants {
public static final String DEEPWORLD_PLAYERPREFS = "HKCU\\SOFTWARE\\Bytebin LLC\\Deepworld";
public static final String DEEPWORLD_STEAM_ID = "340810";
public static final String DEEPWORLD_ASSEMBLY_PATH = "/steamapps/common/Deepworld/Deepworld_Data/Managed/Assembly-CSharp.dll";
public static final String RUN_GAME_URL = String.format("steam://rungameid/%s", DEEPWORLD_STEAM_ID);
public static final String STORE_PAGE_URL = String.format("steam://store/%s", DEEPWORLD_STEAM_ID);
public static final String COMMUNITY_HUB_URL = String.format("steam://url/GameHub/%s", DEEPWORLD_STEAM_ID);
public static final String STEAM_RUN_GAME_URL = String.format("steam://rungameid/%s", DEEPWORLD_STEAM_ID);
public static final String STEAM_COMMUNITY_HUB_URL = String.format("steam://url/GameHub/%s", DEEPWORLD_STEAM_ID);
public static final String HTTP_STEAM_DOWNLOAD_URL = "https://store.steampowered.com/about";
public static final String HTTP_COMMUNITY_HUB_URL = String.format("https://steamcommunity.com/app/%s", DEEPWORLD_STEAM_ID);
public static final Color ERROR_COLOR = Color.RED.darker();
public static final Color WARNING_COLOR = Color.YELLOW.darker();
public static final Color INFO_COLOR = Color.WHITE.darker();