Earlier version and logging initialization
This commit is contained in:
@@ -441,8 +441,18 @@ public class Vars implements Loadable{
|
|||||||
|
|
||||||
settings.setAppName(appName);
|
settings.setAppName(appName);
|
||||||
|
|
||||||
|
loadFileLogger(settings.getDataDirectory().child("last_log.txt"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadFileLogger(Fi file){
|
||||||
|
if(loadedFileLogger) return;
|
||||||
|
|
||||||
|
if(!file.parent().exists()){
|
||||||
|
file.parent().mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
Writer writer = settings.getDataDirectory().child("last_log.txt").writer(false);
|
Writer writer = file.writer(false);
|
||||||
LogHandler log = Log.logger;
|
LogHandler log = Log.logger;
|
||||||
Log.logger = (level, text) -> {
|
Log.logger = (level, text) -> {
|
||||||
log.log(level, text);
|
log.log(level, text);
|
||||||
@@ -467,7 +477,7 @@ public class Vars implements Loadable{
|
|||||||
settings.setJson(JsonIO.json);
|
settings.setJson(JsonIO.json);
|
||||||
settings.setAppName(appName);
|
settings.setAppName(appName);
|
||||||
|
|
||||||
if(steam || (Version.modifier != null && Version.modifier.contains("steam"))){
|
if(steam || Version.isSteam){
|
||||||
settings.setDataDirectory(Core.files.local("saves/"));
|
settings.setDataDirectory(Core.files.local("saves/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public class Version{
|
|||||||
public static int build = 0;
|
public static int build = 0;
|
||||||
/** Revision number. Used for hotfixes. Does not affect server compatibility. */
|
/** Revision number. Used for hotfixes. Does not affect server compatibility. */
|
||||||
public static int revision = 0;
|
public static int revision = 0;
|
||||||
|
/** Whether the Steam version of the game is requested. This is different from Vars.steam (Steam initialization can fail) */
|
||||||
|
public static boolean isSteam = false;
|
||||||
/** Whether version loading is enabled. */
|
/** Whether version loading is enabled. */
|
||||||
public static boolean enabled = true;
|
public static boolean enabled = true;
|
||||||
|
|
||||||
@@ -38,6 +40,7 @@ public class Version{
|
|||||||
modifier = map.get("modifier");
|
modifier = map.get("modifier");
|
||||||
commitHash = map.get("commitHash", "unknown");
|
commitHash = map.get("commitHash", "unknown");
|
||||||
buildDate = map.get("buildDate", "unknown");
|
buildDate = map.get("buildDate", "unknown");
|
||||||
|
isSteam = modifier.contains("steam");
|
||||||
if(map.get("build").contains(".")){
|
if(map.get("build").contains(".")){
|
||||||
String[] split = map.get("build").split("\\.");
|
String[] split = map.get("build").split("\\.");
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -42,10 +42,11 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
|
|
||||||
public static void main(String[] arg){
|
public static void main(String[] arg){
|
||||||
try{
|
try{
|
||||||
|
Version.init();
|
||||||
Vars.loadLogger();
|
Vars.loadLogger();
|
||||||
|
Vars.loadFileLogger(new Fi(Version.isSteam ? "saves" : OS.getAppDataDirectoryString(appName)).child("last_log.txt"));
|
||||||
|
|
||||||
check32Bit();
|
check32Bit();
|
||||||
|
|
||||||
checkJavaVersion();
|
checkJavaVersion();
|
||||||
|
|
||||||
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
|
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
|
||||||
@@ -129,15 +130,9 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
|
|
||||||
static void check32Bit(){
|
static void check32Bit(){
|
||||||
if(OS.isWindows && !OS.is64Bit){
|
if(OS.isWindows && !OS.is64Bit){
|
||||||
try{
|
|
||||||
Version.init();
|
|
||||||
}catch(Throwable ignored){
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean steam = Version.modifier != null && Version.modifier.contains("steam");
|
|
||||||
String versionWarning = "";
|
String versionWarning = "";
|
||||||
|
|
||||||
if(steam){
|
if(Version.isSteam){
|
||||||
versionWarning = "\n\nIf you are unable to upgrade, consider switching to the legacy v7 branch on Steam, which is the last release that supported 32-bit windows:\n(properties -> betas -> select version-7.0 in the drop-down box).";
|
versionWarning = "\n\nIf you are unable to upgrade, consider switching to the legacy v7 branch on Steam, which is the last release that supported 32-bit windows:\n(properties -> betas -> select version-7.0 in the drop-down box).";
|
||||||
}else if(OS.javaVersion.equals("1.8.0_151-1-ojdkbuild")){ //version string of JVM packaged with the 32-bit version of the game on itch/steam
|
}else if(OS.javaVersion.equals("1.8.0_151-1-ojdkbuild")){ //version string of JVM packaged with the 32-bit version of the game on itch/steam
|
||||||
versionWarning = "\n\nMake sure you have downloaded the 64-bit version of the game, not the 32-bit one.";
|
versionWarning = "\n\nMake sure you have downloaded the 64-bit version of the game, not the 32-bit one.";
|
||||||
@@ -153,9 +148,6 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
public DesktopLauncher(String[] args){
|
public DesktopLauncher(String[] args){
|
||||||
this.args = args;
|
this.args = args;
|
||||||
|
|
||||||
Version.init();
|
|
||||||
boolean useSteam = Version.modifier.contains("steam");
|
|
||||||
|
|
||||||
if(useDiscord){
|
if(useDiscord){
|
||||||
Threads.daemon(() -> {
|
Threads.daemon(() -> {
|
||||||
try{
|
try{
|
||||||
@@ -172,8 +164,7 @@ public class DesktopLauncher extends ClientLauncher{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(useSteam){
|
if(Version.isSteam){
|
||||||
|
|
||||||
Events.on(ClientLoadEvent.class, event -> {
|
Events.on(ClientLoadEvent.class, event -> {
|
||||||
if(steamError != null){
|
if(steamError != null){
|
||||||
Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> {
|
Core.app.post(() -> Core.app.post(() -> Core.app.post(() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user