-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
epic: continue launcher clean-up (#619)
- Loading branch information
1 parent
52ef300
commit 0ca6912
Showing
27 changed files
with
94 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/org/terasology/launcher/model/LauncherVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.launcher.model; | ||
|
||
import com.google.common.io.Resources; | ||
import com.vdurmont.semver4j.Semver; | ||
import com.vdurmont.semver4j.SemverException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Optional; | ||
|
||
public final class LauncherVersion { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(LauncherVersion.class); | ||
private static final String VERSION_INFO_FILE = "/org/terasology/launcher/version.txt"; | ||
private static LauncherVersion instance; | ||
|
||
private final Semver semver; | ||
|
||
private LauncherVersion(Semver semver) { | ||
this.semver = semver; | ||
} | ||
|
||
//TODO: Should this be instantiated once at startup and then passed to respective classes? Prepare for dependency injection | ||
public static synchronized LauncherVersion getInstance() { | ||
if (instance == null) { | ||
String version = ""; | ||
Semver semver = null; | ||
try { | ||
version = Resources.toString(Resources.getResource(LauncherVersion.class, VERSION_INFO_FILE), StandardCharsets.UTF_8); | ||
semver = new Semver(version); | ||
} catch (SemverException e) { | ||
logger.error("Failed to load launcher version info from '{}': Invalid semver '{}'.", VERSION_INFO_FILE, version, e); | ||
} catch (IOException e) { | ||
logger.error("Loading launcher version info from '{}' failed.", VERSION_INFO_FILE, e); | ||
} | ||
instance = new LauncherVersion(semver); | ||
} | ||
return instance; | ||
} | ||
|
||
public String getDisplayName() { | ||
return Optional.ofNullable(semver).map(Semver::getValue).orElse("n/a"); | ||
} | ||
|
||
public Semver getSemver() { | ||
return semver; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getDisplayName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ncher/gui/javafx/AboutViewController.java → ...logy/launcher/ui/AboutViewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...her/gui/javafx/ApplicationController.java → ...gy/launcher/ui/ApplicationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/gui/javafx/ChangelogViewController.java → .../launcher/ui/ChangelogViewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rasology/launcher/gui/javafx/Dialogs.java → ...a/org/terasology/launcher/ui/Dialogs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rasology/launcher/gui/javafx/Effects.java → ...a/org/terasology/launcher/ui/Effects.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.