Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a warning window for incorrect installs.
- Loading branch information
1 parent
860c350
commit e3a341c
Showing
3 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace DarkMultiPlayer | ||
{ | ||
public class IncorrectInstallWindow | ||
{ | ||
public static IncorrectInstallWindow singleton; | ||
|
||
private const int WINDOW_WIDTH = 600; | ||
private const int WINDOW_HEIGHT = 200; | ||
private Rect windowRect; | ||
private Rect moveRect; | ||
private bool initialized; | ||
private bool display; | ||
private GUILayoutOption[] layoutOptions; | ||
|
||
|
||
public static IncorrectInstallWindow fetch | ||
{ | ||
get | ||
{ | ||
return singleton; | ||
} | ||
} | ||
|
||
private void InitGUI() | ||
{ | ||
//Setup GUI stuff | ||
windowRect = new Rect((Screen.width / 2f) - (WINDOW_WIDTH / 2), (Screen.height / 2f) - (WINDOW_HEIGHT / 2f), WINDOW_WIDTH, WINDOW_HEIGHT); | ||
moveRect = new Rect(0, 0, 10000, 20); | ||
|
||
layoutOptions = new GUILayoutOption[2]; | ||
layoutOptions[0] = GUILayout.ExpandWidth(true); | ||
layoutOptions[1] = GUILayout.ExpandHeight(true); | ||
} | ||
|
||
private void Draw() | ||
{ | ||
if (!initialized) | ||
{ | ||
initialized = true; | ||
InitGUI(); | ||
} | ||
if (display) | ||
{ | ||
windowRect = GUILayout.Window(GUIUtility.GetControlID(6705, FocusType.Passive), windowRect, DrawContent, "DarkMultiPlayer", layoutOptions); | ||
} | ||
} | ||
|
||
private void DrawContent(int windowID) | ||
{ | ||
GUILayout.BeginVertical(); | ||
GUI.DragWindow(moveRect); | ||
GUILayout.Label("DMP is not correctly installed"); | ||
GUILayout.Label("Current location: " + Client.fetch.assemblyPath); | ||
GUILayout.Label("Correct location: " + Client.fetch.assemblyShouldBeInstalledAt); | ||
GUILayout.FlexibleSpace(); | ||
if (GUILayout.Button("Close")) | ||
{ | ||
display = false; | ||
} | ||
GUILayout.EndVertical(); | ||
} | ||
|
||
public static void Enable() | ||
{ | ||
singleton = new IncorrectInstallWindow(); | ||
lock (Client.eventLock) { | ||
Client.drawEvent.Add(singleton.Draw); | ||
} | ||
singleton.display = true; | ||
} | ||
} | ||
} | ||
|
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
e3a341c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure what the consequences would be for an incorrect installation. I mean, what if you just put it in a
Mods
subdirectory? Doesn't look like it would do any harm.e3a341c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DMP has some hard-coded paths, this could probably be avoided by using the assembly location, but someone will eventually put 2 copies of DMP into gamedata and things will go pear shaped :-/
e3a341c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inevitably so. A simple check could be made to see if the assembly has already been loaded, but it would be a bit of a hacky solution. 😐