-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added GUI with working FSD, added changelog, did many bugfixes
- Loading branch information
1 parent
5cb6b3e
commit 63f1548
Showing
19 changed files
with
917 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ Assembly-Csharp.dll | |
Assembly-Csharp-firstpass.dll | ||
UnityEngine.dll | ||
UnityEngine.UI.dll | ||
000_AT_Utils.dll |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,117 @@ | ||
using System; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
/* | ||
* Notes on usage of the changelog | ||
* | ||
* Changelog MUST be titled Changelog.cfg | ||
* Changelog MUST be in the following format: | ||
* | ||
* showChangelog = [true|false] | ||
* VERSION | ||
* { | ||
* version = 1.1 | ||
* change = Added new parts. | ||
* change = Removed most bugs. | ||
* } | ||
* VERSION | ||
* { | ||
* version = 1.0 | ||
* change = Release!!! | ||
* } | ||
* | ||
* Treat it with the same level of respect as you do regular config files. | ||
* When there is a new release, change showChangelog to true. | ||
* After the changelog is viewed in-game, the value will be automatically set to false. | ||
*/ | ||
|
||
namespace KerbalFuture.KFGUI | ||
{ | ||
[KSPAddon(KSPAddon.Startup.SpaceCentre, false)] | ||
public class Changelog : MonoBehaviour | ||
{ | ||
// No creating new instances of this | ||
private Changelog() | ||
{ | ||
|
||
} | ||
public string dllLoc { get; } = AssemblyLoader.GetPathByType(typeof(Changelog)).Replace("/PluginData/KerbalFuture", Path.DirectorySeparatorChar.ToString()); | ||
bool showChangelog; | ||
Rect changelogRect = new Rect(100, 100, 300, 400); | ||
Vector2 changelogScrollPos = new Vector2(); | ||
string changelog = string.Empty; | ||
|
||
private void Start() | ||
{ | ||
LoadChangelog(); | ||
Debug.Log("[KF] dllLoc = " + dllLoc); | ||
} | ||
private void OnGUI() | ||
{ | ||
if (showChangelog) | ||
{ | ||
changelogRect = GUILayout.Window(0, changelogRect, DrawChangelogWindow, "Kerbal Future Changelog", GUILayout.Width(300), GUILayout.Height(400)); | ||
} | ||
} | ||
private void DrawChangelogWindow(int id) | ||
{ | ||
GUI.DragWindow(new Rect(0, 0, 300, 20)); | ||
changelogScrollPos = GUILayout.BeginScrollView(changelogScrollPos); | ||
GUILayout.Label(changelog); | ||
if(GUILayout.Button("Close changelog")) | ||
{ | ||
showChangelog = false; | ||
} | ||
GUILayout.EndScrollView(); | ||
} | ||
private void LoadChangelog() | ||
{ | ||
Debug.Log("[KF] Loading changelog..."); | ||
ConfigNode versionCfg = ConfigNode.Load(Path.Combine(dllLoc, "Changelog.cfg")); | ||
if(!versionCfg.HasValue("showChangelog")) | ||
{ | ||
Debug.Log("[KF] Unable to find value showChangelog in Changelog.cfg"); | ||
return; | ||
} | ||
if(!versionCfg.TryGetValue("showChangelog", ref showChangelog)) | ||
{ | ||
Debug.Log("[KF] Unable to load value from 'showChangelog'."); | ||
return; | ||
} | ||
if(!versionCfg.SetValue("showChangelog", false)) | ||
{ | ||
Debug.Log("[KF] Unable to set value 'showChangelog'."); | ||
return; | ||
} | ||
versionCfg.Save(Path.Combine(dllLoc, "Changelog.cfg")); | ||
if(!showChangelog) | ||
{ | ||
Debug.Log("[KF] Changelog load aborted due to showChangelog being set to false."); | ||
} | ||
bool firstTimeThrough = true; | ||
foreach(ConfigNode cfg in versionCfg.GetNodes()) | ||
{ | ||
if(!firstTimeThrough) | ||
{ | ||
changelog += Environment.NewLine; | ||
} | ||
float version = 0; | ||
cfg.TryGetValue("version", ref version); | ||
if (firstTimeThrough) | ||
{ | ||
changelog = version.ToString(); | ||
} | ||
else | ||
{ | ||
changelog += Environment.NewLine + version; | ||
} | ||
foreach (string s in cfg.GetValues("change")) | ||
{ | ||
changelog += Environment.NewLine + s; | ||
} | ||
firstTimeThrough = false; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.