This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
8 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 |
---|---|---|
@@ -1,34 +1,62 @@ | ||
| ||
using SFS.Input; | ||
using SFS.Parts.Modules; | ||
using SFS.World; | ||
using System; | ||
using UnityEngine; | ||
using static UnityEngine.GUI; | ||
|
||
namespace RefillMod | ||
{ | ||
class Menu : MonoBehaviour | ||
{ | ||
|
||
private const float MENU_HEIGHT =90f; | ||
private const float MENU_WIDTH = 200f; | ||
|
||
public static Rocket playerRocket; | ||
|
||
public Rect windowRect = new Rect((float)Screen.width * 0.05f, (float)Screen.height * 0.05f, 200f, 200f); | ||
public Rect windowRect = new Rect((float)Screen.width * 0.2f, (float)Screen.height * 0.05f, MENU_WIDTH, MENU_HEIGHT); | ||
|
||
private bool isVisible; | ||
private WindowFunction windosDraw; | ||
|
||
private void Start() | ||
{ | ||
KeysNode keysNode = GameManager.main.world_Input.keysNode; | ||
KeybindingsPC.Key menuAction = KeyCode.O; | ||
keysNode.AddOnKeyDown(menuAction, new Action(this.toggleMenu)); | ||
this.isVisible = true; | ||
this.windosDraw = new GUI.WindowFunction(this.windowFunc); | ||
} | ||
|
||
public void toggleMenu() | ||
{ | ||
this.isVisible = !this.isVisible; | ||
} | ||
|
||
public void OnGUI() | ||
{ | ||
windowRect = GUI.Window(0, windowRect, new GUI.WindowFunction(this.windowFunc), "Menu"); | ||
if (this.isVisible) | ||
{ | ||
windowRect = GUI.Window(GUIUtility.GetControlID(FocusType.Passive), windowRect, this.windosDraw, "RefillMod(Beta)"); | ||
} | ||
} | ||
|
||
public void windowFunc(int windowID) | ||
{ | ||
if (GUI.Button(new Rect(10f, 20f, 190f, 20f), " Refill tanks")) | ||
GUI.Label(new Rect(10f, 20f, MENU_WIDTH - 10f, 20f), "Hide this: Press 'O'"); | ||
if (GUI.Button(new Rect(10f, 50f, MENU_WIDTH - 20f, 20f), "Refill tanks")) | ||
{ | ||
|
||
foreach (ResourceModule tank in Menu.playerRocket.partHolder.GetModules<ResourceModule>()) | ||
{ | ||
tank.AddResource(1000f); | ||
} | ||
|
||
} | ||
GUI.DragWindow(); | ||
} | ||
|
||
} | ||
|
||
|
||
} |
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