-
Notifications
You must be signed in to change notification settings - Fork 12
Rework and fix InstallChecker #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DaRealCodeWritten
wants to merge
3
commits into
Gameslinx:master
Choose a base branch
from
DaRealCodeWritten:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
369 changes: 179 additions & 190 deletions
369
GameData/BeyondHome/BeyondHome_InstallChecker-SOURCE.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -1,191 +1,180 @@ | ||
|
|
||
|
|
||
| //As with KSP rules apparently I have to include my source code here | ||
| //Screw you Squad/T2, you don't even let us decompile your DLLs AND you have a history of potentially MALICIOUS code | ||
| //I can do whatever I damn well please. But, here's my source code :DDDDDDDD | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using UnityEngine; | ||
| using UnityEngine.UI; | ||
|
|
||
| namespace BeyondHomeInstallationChecker | ||
| { | ||
| [KSPAddon(KSPAddon.Startup.Instantly, false)] | ||
| public class BICH : MonoBehaviour | ||
| { | ||
| public void Start() | ||
| { | ||
| int memorysize = (SystemInfo.systemMemorySize / 1000); | ||
| int gpumemorysize = SystemInfo.graphicsMemorySize / 1000; | ||
| int errorcount = 0; | ||
| string errors = ""; | ||
| Debug.Log("----------------------------------------------------------------------------------"); | ||
| Debug.Log(""); | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Starting up! - Beyond Home by Gameslinx - ARR"); //Beyondhome Installation Checker. Calm down, calm down. | ||
| DoLogThingsForMe("BICH stands for Beyondhome Installation Checker. If you're reading this, you're evaluating what went wrong or stumbled across it when something else went wrong."); | ||
| DoLogThingsForMe("Thank you for using Beyond Home. Below you can find out what went wrong (or right!)"); | ||
| string path = Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "GameData/"; | ||
| DoLogThingsForMe("GameData directory is " + path); //Well, I sure hope so | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Displaying errors, warnings and notices below:"); | ||
| if (memorysize > 4.9) | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended RAM: 5GB - Installed RAM: " + memorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - RAM meets or exceeds requirement"); | ||
| } | ||
| else | ||
| { | ||
| errors = errors + ("<color=#EF0013>Recommended RAM: 5GB - Installed RAM: " + memorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - RAM does not meet the requirement"); | ||
| } | ||
| if (gpumemorysize > 1) | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended VRAM: 1GB - Installed VRAM: " + gpumemorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - VRAM meets or exceeds the requirement"); | ||
| } | ||
| else | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended VRAM: 1GB - Installed VRAM: " + gpumemorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - VRAM does not meet the requirement"); | ||
| } | ||
|
|
||
| if (System.IO.File.Exists(path + "BeyondHome/BeyondHome_LICENSE.txt") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Beyond Home is not installed!</color>\n"; //Nobody goes into the mod folder and removes the license file, so this indicates a bad install | ||
| DoLogThingsForMe(" - Beyond Home is not even installed...?"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "Kopernicus/Plugins/Kopernicus.dll") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Kopernicus is not installed!</color>\n"; | ||
| DoLogThingsForMe(" - Kopernicus is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "ModularFlightIntegrator/ModularFlightIntegrator.dll") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Modular Flight Integrator is not installed!</color>\n"; | ||
| DoLogThingsForMe(" - MFI is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "Sigma/Replacements/SkyBox/Plugins/SigmaReplacementsSkyBox.dll") == true) | ||
| { | ||
| errors = errors + "<color=#FF7200>WARNING: Sigma Replacements: Skybox is not installed!</color>\n"; //SR:S is not on CKAN, so this is the only way to get the inferior people who actually use CKAN to install the damn dependencies | ||
| DoLogThingsForMe(" - SR:S is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "AstronomersVisualPack/AstronomersVisualPack.version") == true) | ||
| { | ||
| errors = errors + "<color=#FF7200>WARNING: Astronomer's Visual Pack is not supported! Beyond Home adds its own visuals</color>\n"; | ||
| DoLogThingsForMe(" - AVP is installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "StockVisualEnhancements/StockVisualEnhancements.version") == true) | ||
| { | ||
| errors = errors + "<color=#FF7200>WARNING: Stock Visual Enhancements is not supported! Beyond Home adds its own visuals</color>\n"; | ||
| DoLogThingsForMe(" - SVE is installed"); | ||
| errorcount++; | ||
| } | ||
|
|
||
| if (System.IO.File.Exists(path + "scatterer/scatterer.dll") == false) | ||
| { | ||
| errors = errors + "NOTICE: Scatterer is not installed!\n"; | ||
| DoLogThingsForMe(" - Scatterer is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "EnvironmentalVisualEnhancements/License.txt") == false) | ||
| { | ||
| errors = errors + "NOTICE: Environmental Visual Enhancements is not installed!\n"; | ||
| DoLogThingsForMe(" - EVE is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (GameSettings.PLANET_SCATTER == false) | ||
| { | ||
| errors += "NOTICE: Terrain Scatters are not enabled!\n"; | ||
| DoLogThingsForMe(" - Scatters not enabled"); | ||
| errorcount++; | ||
| } | ||
| if (GameSettings.PLANET_SCATTER_FACTOR < 1) | ||
| { | ||
| errors += "NOTICE: Terrain Scatter density must be 100%\n"; | ||
| DoLogThingsForMe(" - Scatters not 100% density"); | ||
| errorcount++; | ||
| } | ||
| if (errorcount == 0) | ||
| { | ||
| errors += "Beyond Home seems to be installed correctly! Thank you, and enjoy!\n\nAny issues? Contact me on the forums or discord (Gameslinx#0544)\n"; | ||
| DoLogThingsForMe(" - No file path errors detected!"); | ||
| } | ||
|
|
||
| BeyondHomePostMessage(errors); | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Checking for Kopernicus and KSP version match..."); | ||
| Debug.Log(""); | ||
| if (errorcount > 0) | ||
| { | ||
| DoLogThingsForMe("Exception: There were the following errors in the Beyond Home installation:"); | ||
| } | ||
| try | ||
| { | ||
| string[] validation = InstallCheckerGetKop(); | ||
| if (validation[0] != validation[1]) | ||
| { | ||
| ScreenMessages.PostScreenMessage("\n\n\n\n\n\n\n\n\n<color=#FF3F00>Your Kopernicus version does not match the KSP version!</color>"); | ||
| DoLogThingsForMe(" - Kopernicus and KSP version mismatch!"); | ||
| } | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| DoLogThingsForMe("Couldn't find either Kopernicus or the KSP readme.txt"); | ||
| Debug.Log(e.ToString()); | ||
| ScreenMessages.PostScreenMessage("\n\n\n\n\n\n\n\n\nUnable to detect KSP / Kopernicus version"); | ||
| } | ||
| DoLogThingsForMe("Shutting down InstallationChecker, its task is done! �Not all those who wander are lost...�"); | ||
| Debug.Log(""); | ||
| Debug.Log(""); | ||
| Debug.Log("----------------------------------------------------------------------------------"); | ||
| } | ||
| public string[] InstallCheckerGetKop() | ||
| { | ||
| string output = ""; | ||
| string KSPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "readme.txt"); //Locate KSP directory readme | ||
| string KOPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "GameData/Kopernicus/Plugins/Kopernicus.version"); //Locate kopernicus readme if it exists | ||
| DoLogThingsForMe("Detected KSP validation path as " + KSPpath); | ||
| DoLogThingsForMe("Detected Kopernicus validation path as " + KOPpath); | ||
| string KSPreadme = File.ReadAllLines(KSPpath).Skip(14).Take(1).First(); | ||
| string major = File.ReadLines(KOPpath).Skip(7).Take(1).First(); | ||
| string minor = File.ReadLines(KOPpath).Skip(8).Take(1).First(); | ||
| string patch = File.ReadLines(KOPpath).Skip(9).Take(1).First(); | ||
| string temp = major + "\n" + minor + "\n" + patch; | ||
| int counter = 0; | ||
| foreach (char c in temp) | ||
| { | ||
| if (Char.IsDigit(c) == true) | ||
| { | ||
| output += c; | ||
| counter++; | ||
| if (counter < 3) | ||
| { | ||
| output += '.'; | ||
| } | ||
| } | ||
| } | ||
| string[] outputarray = new string[2]; //Kop version is index 0, ksp version is index 1 | ||
| outputarray[0] = "Version " + output; | ||
| outputarray[1] = KSPreadme; | ||
| DoLogThingsForMe("Line of Kopernicus readme: " + outputarray[0]); | ||
| DoLogThingsForMe("Line of KSP readme: " + outputarray[1]); | ||
| return outputarray; | ||
| } | ||
| public void BeyondHomePostMessage(string input) | ||
| { | ||
| ScreenMessages.PostScreenMessage(input); | ||
| } | ||
| public void DoLogThingsForMe(string input) | ||
| { | ||
| Debug.Log("[BICH] " + input); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| //As with KSP rules apparently I have to include my source code here | ||
| //Screw you Squad/T2, you don't even let us decompile your DLLs AND you have a history of potentially MALICIOUS code | ||
| //I can do whatever I damn well please. But, here's my source code :DDDDDDDD | ||
| //Lmao, it's too funny asking for transparency when you won't give it yourself: FOR[T2/Skwod] | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using UnityEngine; | ||
| using UnityEngine.UI; | ||
| using Kopernicus; | ||
| using Kopernicus.Constants; | ||
|
|
||
| namespace BeyondHomeInstallationChecker | ||
| { | ||
| [KSPAddon(KSPAddon.Startup.Instantly, false)] | ||
| public class BICH : MonoBehaviour | ||
| { | ||
| public void Start() | ||
| { | ||
| int memorysize = (SystemInfo.systemMemorySize / 1000); | ||
| int gpumemorysize = SystemInfo.graphicsMemorySize / 1000; | ||
| int errorcount = 0; | ||
| string errors = ""; | ||
| Debug.Log("----------------------------------------------------------------------------------"); | ||
| Debug.Log(""); | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Starting up! - Beyond Home by Gameslinx - ARR"); //Beyondhome Installation Checker. Calm down, calm down. | ||
| DoLogThingsForMe("BICH stands for Beyondhome Installation Checker. If you're reading this, you're evaluating what went wrong or stumbled across it when something else went wrong."); | ||
| DoLogThingsForMe("Thank you for using Beyond Home. Below you can find out what went wrong (or right!)"); | ||
| string path = Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "GameData/"; | ||
| DoLogThingsForMe("GameData directory is " + path); //Well, I sure hope so | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Displaying errors, warnings and notices below:"); | ||
| if (memorysize > 4.9) | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended RAM: 5GB - Installed RAM: " + memorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - RAM meets or exceeds requirement"); | ||
| } | ||
| else | ||
| { | ||
| errors = errors + ("<color=#EF0013>Recommended RAM: 5GB - Installed RAM: " + memorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - RAM does not meet the requirement"); | ||
| } | ||
| if (gpumemorysize > 1) | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended VRAM: 1GB - Installed VRAM: " + gpumemorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - VRAM meets or exceeds the requirement"); | ||
| } | ||
| else | ||
| { | ||
| errors = errors + ("<color=#00F200>Recommended VRAM: 1GB - Installed VRAM: " + gpumemorysize.ToString() + "\n"); | ||
| DoLogThingsForMe(" - VRAM does not meet the requirement"); | ||
| } | ||
|
|
||
| if (System.IO.File.Exists(path + "BeyondHome/BeyondHome_LICENSE.txt") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Beyond Home is not installed!</color>\n"; //Nobody goes into the mod folder and removes the license file, so this indicates a bad install | ||
| DoLogThingsForMe(" - Beyond Home is not even installed...?"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "Kopernicus/Plugins/Kopernicus.dll") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Kopernicus is not installed!</color>\n"; | ||
| DoLogThingsForMe(" - Kopernicus is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "ModularFlightIntegrator/ModularFlightIntegrator.dll") == false) | ||
| { | ||
| errors = errors + "<color=#FF3F00>ERROR: Modular Flight Integrator is not installed!</color>\n"; | ||
| DoLogThingsForMe(" - MFI is not installed"); | ||
| errorcount++; | ||
| } | ||
| // if (System.IO.File.Exists(path + "Sigma/Replacements/SkyBox/Plugins/SigmaReplacementsSkyBox.dll") == true) | ||
| // { | ||
| // errors = errors + "<color=#FF7200>WARNING: Sigma Replacements: Skybox is not installed!</color>\n"; //SR:S is not on CKAN, so this is the only way to get the inferior people who actually use CKAN to install the damn dependencies | ||
| // DoLogThingsForMe(" - SR:S is not installed"); | ||
| // errorcount++; | ||
| // } | ||
| if (System.IO.File.Exists(path + "AstronomersVisualPack/AstronomersVisualPack.version") == true) | ||
| { | ||
| errors = errors + "<color=#FF7200>WARNING: Astronomer's Visual Pack is not supported! Beyond Home adds its own visuals</color>\n"; | ||
| DoLogThingsForMe(" - AVP is installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "StockVisualEnhancements/StockVisualEnhancements.version") == true) | ||
| { | ||
| errors = errors + "<color=#FF7200>WARNING: Stock Visual Enhancements is not supported! Beyond Home adds its own visuals</color>\n"; | ||
| DoLogThingsForMe(" - SVE is installed"); | ||
| errorcount++; | ||
| } | ||
|
|
||
| if (System.IO.File.Exists(path + "scatterer/scatterer.dll") == false) | ||
| { | ||
| errors = errors + "NOTICE: Scatterer is not installed!\n"; | ||
| DoLogThingsForMe(" - Scatterer is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (System.IO.File.Exists(path + "EnvironmentalVisualEnhancements/License.txt") == false) | ||
| { | ||
| errors = errors + "NOTICE: Environmental Visual Enhancements is not installed!\n"; | ||
| DoLogThingsForMe(" - EVE is not installed"); | ||
| errorcount++; | ||
| } | ||
| if (GameSettings.PLANET_SCATTER == false) | ||
| { | ||
| errors += "NOTICE: Terrain Scatters are not enabled!\n"; | ||
| DoLogThingsForMe(" - Scatters not enabled"); | ||
| errorcount++; | ||
| } | ||
| if (GameSettings.PLANET_SCATTER_FACTOR < 1) | ||
| { | ||
| errors += "NOTICE: Terrain Scatter density must be 100%\n"; | ||
| DoLogThingsForMe(" - Scatters not 100% density"); | ||
| errorcount++; | ||
| } | ||
| if (errorcount == 0) | ||
| { | ||
| errors += "Beyond Home seems to be installed correctly! Thank you, and enjoy!\n\nAny issues? Contact me on the forums or discord (Gameslinx#0544)\n"; | ||
| DoLogThingsForMe(" - No file path errors detected!"); | ||
| } | ||
|
|
||
| BeyondHomePostMessage(errors); | ||
| Debug.Log(""); | ||
| DoLogThingsForMe("Checking for Kopernicus and KSP version match..."); | ||
| Debug.Log(""); | ||
| if (errorcount > 0) | ||
| { | ||
| DoLogThingsForMe("Exception: There were the following errors in the Beyond Home installation:"); | ||
| DoLogThingsForMe(errors); | ||
| } | ||
| try | ||
| { | ||
| bool validation = InstallCheckerGetKop(); | ||
| if (validation is false) | ||
| { | ||
| ScreenMessages.PostScreenMessage("\n\n\n\n\n\n\n\n\n<color=#FF3F00>Your Kopernicus version does not match the KSP version!</color>"); | ||
| DoLogThingsForMe(" - Kopernicus and KSP version mismatch!"); | ||
| } | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| DoLogThingsForMe("Couldn't find either Kopernicus or the KSP readme.txt"); | ||
| Debug.Log(e.ToString()); | ||
| DoLogThingsForMe(e.ToString()); | ||
| ScreenMessages.PostScreenMessage("\n\n\n\n\n\n\n\n\nUnable to detect KSP / Kopernicus version"); | ||
| } | ||
| DoLogThingsForMe("Shutting down InstallationChecker, its task is done! �Not all those who wander are lost...�"); | ||
| Debug.Log(""); | ||
| Debug.Log(""); | ||
| Debug.Log("----------------------------------------------------------------------------------"); | ||
| } | ||
| public bool InstallCheckerGetKop() | ||
| { | ||
| string KSPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "readme.txt"); //Locate KSP directory readme | ||
| string KOPpath = (Application.dataPath.Remove(Application.dataPath.Length - 12, 12) + "GameData/Kopernicus/Plugins/Kopernicus.version"); //Locate kopernicus readme if it exists | ||
| DoLogThingsForMe("Detected KSP validation path as " + KSPpath); | ||
| DoLogThingsForMe("Detected Kopernicus validation path as " + KOPpath); | ||
| bool x = CompatibilityChecker.IsCompatible(); | ||
| if (x is true) | ||
| { | ||
| return true; | ||
| } | ||
| else | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| public void BeyondHomePostMessage(string input) | ||
| { | ||
| ScreenMessages.PostScreenMessage(input); | ||
| } | ||
| public void DoLogThingsForMe(string input) | ||
| { | ||
| Debug.Log("[BICH] " + input); | ||
| } | ||
| } | ||
| } | ||
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.