remove XDG stuff and some dependency
This commit is contained in:
parent
2dc3db93de
commit
677de45366
7
pom.xml
7
pom.xml
|
@ -14,7 +14,6 @@
|
|||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
|
||||
<mainClassName>yugecin.opsudance.core.Entrypoint</mainClassName>
|
||||
<XDG>false</XDG>
|
||||
</properties>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
|
@ -148,7 +147,6 @@
|
|||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<manifestEntries>
|
||||
<Main-Class>${mainClassName}</Main-Class>
|
||||
<Use-XDG>${XDG}</Use-XDG>
|
||||
</manifestEntries>
|
||||
</transformer>
|
||||
</transformers>
|
||||
|
@ -234,11 +232,6 @@
|
|||
<artifactId>jna-platform</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
|
|
|
@ -32,10 +32,10 @@ import java.util.Date;
|
|||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import org.newdawn.slick.util.ResourceLoader;
|
||||
import yugecin.opsudance.core.Constants;
|
||||
import yugecin.opsudance.utils.SimpleVersion;
|
||||
|
||||
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
@ -91,7 +91,7 @@ public class Updater {
|
|||
private Status status;
|
||||
|
||||
/** The current and latest versions. */
|
||||
private DefaultArtifactVersion currentVersion, latestVersion;
|
||||
private SimpleVersion currentVersion, latestVersion;
|
||||
|
||||
/** The version information if the program was just updated. */
|
||||
private String updatedFromVersion, updatedToVersion;
|
||||
|
@ -106,7 +106,7 @@ public class Updater {
|
|||
if (currentVersion == null) {
|
||||
return "unknown version";
|
||||
}
|
||||
return currentVersion.getMajorVersion() + "." + currentVersion.getMinorVersion() + "." + currentVersion.getIncrementalVersion();
|
||||
return currentVersion.toString();
|
||||
}
|
||||
|
||||
public Updater() {
|
||||
|
@ -181,13 +181,13 @@ public class Updater {
|
|||
* @param props the set of properties
|
||||
* @return the version, or null if not found
|
||||
*/
|
||||
private DefaultArtifactVersion getVersion(Properties props) {
|
||||
String version = props.getProperty("version");
|
||||
if (version == null || version.equals("${pom.version}")) {
|
||||
status = Status.INTERNAL_ERROR;
|
||||
private SimpleVersion getVersion(Properties props) {
|
||||
final String version = props.getProperty("version");
|
||||
if (version != null && !version.equals("${pom.version}")) {
|
||||
return SimpleVersion.parse(version);
|
||||
}
|
||||
this.status = Status.INTERNAL_ERROR;
|
||||
return null;
|
||||
} else
|
||||
return new DefaultArtifactVersion(version);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +195,7 @@ public class Updater {
|
|||
* @throws IOException if an I/O exception occurs
|
||||
*/
|
||||
public void checkForUpdates() throws IOException {
|
||||
if (status != Status.INITIAL || config.USE_XDG)
|
||||
if (status != Status.INITIAL)
|
||||
return;
|
||||
|
||||
status = Status.CHECKING;
|
||||
|
|
|
@ -37,7 +37,6 @@ import yugecin.opsudance.render.GameObjectRenderer;
|
|||
import yugecin.opsudance.skinning.SkinService;
|
||||
import yugecin.opsudance.ui.BackButton;
|
||||
import yugecin.opsudance.ui.OptionsOverlay;
|
||||
import yugecin.opsudance.utils.ManifestWrapper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -88,8 +87,7 @@ public class InstanceContainer {
|
|||
env = new Environment();
|
||||
|
||||
JarFile jarfile = getJarfile();
|
||||
ManifestWrapper manifest = new ManifestWrapper(getJarManifest(jarfile));
|
||||
config = new Configuration(manifest);
|
||||
config = new Configuration();
|
||||
if (jarfile != null) {
|
||||
try {
|
||||
NativeLoader.loadNatives(jarfile);
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.lwjgl.BufferUtils;
|
|||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import yugecin.opsudance.utils.ManifestWrapper;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -41,13 +40,11 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import static itdelatrisu.opsu.ui.Colors.*;
|
||||
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public class Configuration {
|
||||
|
||||
public final boolean USE_XDG;
|
||||
public final File CONFIG_DIR;
|
||||
public final File DATA_DIR;
|
||||
public final File CACHE_DIR;
|
||||
|
@ -72,12 +69,10 @@ public class Configuration {
|
|||
public File replayImportDir;
|
||||
public File skinRootDir;
|
||||
|
||||
public Configuration(ManifestWrapper jarmanifest) {
|
||||
USE_XDG = jarmanifest.valueOrDefault(null, "Use-XDG", "").equalsIgnoreCase("true");
|
||||
|
||||
CONFIG_DIR = getXDGBaseDir("XDG_CONFIG_HOME", ".config");
|
||||
DATA_DIR = getXDGBaseDir("XDG_DATA_HOME", ".local/share");
|
||||
CACHE_DIR = getXDGBaseDir("XDG_CACHE_HOME", ".cache");
|
||||
public Configuration() {
|
||||
CONFIG_DIR = env.workingdir;
|
||||
DATA_DIR = env.workingdir;
|
||||
CACHE_DIR = env.workingdir;
|
||||
|
||||
BEATMAP_DIR = new File(DATA_DIR, "Songs/");
|
||||
SKIN_ROOT_DIR = new File(DATA_DIR, "Skins/");
|
||||
|
@ -174,39 +169,6 @@ public class Configuration {
|
|||
return loadDirectory(dir, defaultDir, kind);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory based on the XDG base directory specification for
|
||||
* Unix-like operating systems, only if the "XDG" flag is enabled.
|
||||
* @param envvar the environment variable to check (XDG_*_*)
|
||||
* @param fallback the fallback directory relative to ~home
|
||||
* @return the XDG base directory, or the working directory if unavailable
|
||||
*/
|
||||
private File getXDGBaseDir(String envvar, String fallback) {
|
||||
if (!USE_XDG) {
|
||||
return env.workingdir;
|
||||
}
|
||||
|
||||
String OS = System.getProperty("os.name").toLowerCase();
|
||||
if (OS.indexOf("nix") == -1 && OS.indexOf("nux") == -1 && OS.indexOf("aix") == -1){
|
||||
return env.workingdir;
|
||||
}
|
||||
|
||||
String rootPath = System.getenv(envvar);
|
||||
if (rootPath == null) {
|
||||
String home = System.getProperty("user.home");
|
||||
if (home == null) {
|
||||
return new File("./");
|
||||
}
|
||||
rootPath = String.format("%s/%s", home, fallback);
|
||||
}
|
||||
File dir = new File(rootPath, "opsu");
|
||||
if (!dir.isDirectory() && !dir.mkdir()) {
|
||||
explode(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath),
|
||||
new Exception("empty"), PREVENT_REPORT);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @author http://wiki.lwjgl.org/index.php?title=Taking_Screen_Shots
|
||||
*/
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* opsu!dance - fork of opsu! with cursordance auto
|
||||
* Copyright (C) 2017 yugecin
|
||||
*
|
||||
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package yugecin.opsudance.utils;
|
||||
|
||||
import yugecin.opsudance.core.NotNull;
|
||||
import yugecin.opsudance.core.Nullable;
|
||||
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class ManifestWrapper {
|
||||
|
||||
@Nullable
|
||||
public final Manifest manifest;
|
||||
|
||||
public ManifestWrapper(@Nullable Manifest manifest) {
|
||||
this.manifest = manifest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attribute attribute in jarfile or null for default attributes
|
||||
*/
|
||||
public String valueOrDefault(@Nullable String attribute, @NotNull String key, @Nullable String dfault) {
|
||||
if (manifest == null) {
|
||||
return dfault;
|
||||
}
|
||||
Attributes attributes =
|
||||
attribute == null ? manifest.getMainAttributes() : manifest.getAttributes(attribute);
|
||||
if (attributes == null) {
|
||||
return dfault;
|
||||
}
|
||||
String val = attributes.getValue(key);
|
||||
if (val == null) {
|
||||
return dfault;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
}
|
67
src/yugecin/opsudance/utils/SimpleVersion.java
Normal file
67
src/yugecin/opsudance/utils/SimpleVersion.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* opsu!dance - fork of opsu! with cursordance auto
|
||||
* Copyright (C) 2018 yugecin
|
||||
*
|
||||
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package yugecin.opsudance.utils;
|
||||
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import yugecin.opsudance.core.NotNull;
|
||||
import yugecin.opsudance.core.Nullable;
|
||||
|
||||
public class SimpleVersion implements Comparable<SimpleVersion> {
|
||||
|
||||
@Nullable
|
||||
public static SimpleVersion parse(@NotNull String version) {
|
||||
int dashpos = version.indexOf('-');
|
||||
if (dashpos != -1) {
|
||||
version = version.substring(0, dashpos);
|
||||
}
|
||||
final String[] parts = version.split("\\.");
|
||||
if (parts.length < 3) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new SimpleVersion(
|
||||
Integer.parseInt(parts[0]),
|
||||
Integer.parseInt(parts[1]),
|
||||
Integer.parseInt(parts[2])
|
||||
);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final int major, minor, incremental;
|
||||
|
||||
public SimpleVersion(int major, int minor, int incremental) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.incremental = incremental;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull SimpleVersion o) {
|
||||
return
|
||||
Utils.clamp(Integer.compare(major, o.major), -1, 1) * 100 +
|
||||
Utils.clamp(Integer.compare(minor, o.minor), -1, 1) * 10 +
|
||||
Utils.clamp(Integer.compare(incremental, o.incremental), -1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "" + major + '.' + minor + '.' + incremental;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user