BallanceStalker/scripts/GameRoot.cs

53 lines
1.8 KiB
C#
Raw Normal View History

2022-07-02 21:23:45 +08:00
using Godot;
using System;
public class GameRoot : Node {
MenuManager mMenuManager;
StalkerCore mStalkerCore;
public override void _Ready() {
mMenuManager = GetNode<MenuManager>("MenuManager");
2022-07-02 21:23:45 +08:00
mStalkerCore = GetNode<StalkerCore>("StalkerCore");
//mMenuManager.Connect(nameof(MenuManager.SetMouseCapture), this, nameof(Proc_MenuManager_SetMouseCapture));
2022-07-02 21:23:45 +08:00
mMenuManager.Connect(nameof(MenuManager.ExitGame), this, nameof(Proc_MenuManager_ExitGame));
//// raw executing this func
//// to set proper status
//Proc_MenuManager_SetMouseCapture();
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.None);
}
private void Proc_StalkerManager_EventControllerChanged(BallanceStalkerCore.EventControllerSource obj) {
switch (obj) {
case BallanceStalkerCore.EventControllerSource.None:
Input.SetMouseMode(Input.MouseMode.Captured);
break;
case BallanceStalkerCore.EventControllerSource.Menu:
case BallanceStalkerCore.EventControllerSource.Console:
case BallanceStalkerCore.EventControllerSource.Chat:
Input.SetMouseMode(Input.MouseMode.Visible);
break;
}
2022-07-02 21:23:45 +08:00
}
public override void _Input(InputEvent @event) {
}
//private void Proc_MenuManager_SetMouseCapture() {
// if (mMenuManager.Visible) {
// Input.SetMouseMode(Input.MouseMode.Visible);
// } else {
// Input.SetMouseMode(Input.MouseMode.Captured);
// }
//}
2022-07-02 21:23:45 +08:00
private void Proc_MenuManager_ExitGame() {
GetTree().Notification(MainLoop.NotificationWmQuitRequest);
}
}