|
@@ -1,27 +1,27 @@
|
|
|
extends Control
|
|
|
|
|
|
-# Member variables
|
|
|
var mousepos
|
|
|
|
|
|
onready var observer = $"../Observer"
|
|
|
|
|
|
+func _ready():
|
|
|
+ if not check_wm_api():
|
|
|
+ set_physics_process(false)
|
|
|
+ set_process_input(false)
|
|
|
+
|
|
|
+
|
|
|
func _physics_process(_delta):
|
|
|
var modetext = "Mode:\n"
|
|
|
-
|
|
|
if OS.is_window_fullscreen():
|
|
|
modetext += "Fullscreen\n"
|
|
|
else:
|
|
|
modetext += "Windowed\n"
|
|
|
-
|
|
|
if !OS.is_window_resizable():
|
|
|
modetext += "FixedSize\n"
|
|
|
-
|
|
|
if OS.is_window_minimized():
|
|
|
modetext += "Minimized\n"
|
|
|
-
|
|
|
if OS.is_window_maximized():
|
|
|
modetext += "Maximized\n"
|
|
|
-
|
|
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
|
|
modetext += "MouseGrab\n"
|
|
|
$Label_MouseModeCaptured_KeyInfo.show()
|
|
@@ -63,56 +63,57 @@ func _physics_process(_delta):
|
|
|
$Button_MouseModeCaptured.set_pressed(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED)
|
|
|
|
|
|
|
|
|
+func _input(event):
|
|
|
+ if event is InputEventMouseMotion:
|
|
|
+ mousepos = event.position
|
|
|
+
|
|
|
+ if event is InputEventKey:
|
|
|
+ if Input.is_action_pressed("mouse_mode_visible"):
|
|
|
+ observer.state = observer.STATE_MENU
|
|
|
+ _on_Button_MouseModeVisible_pressed()
|
|
|
+
|
|
|
+ if Input.is_action_pressed("mouse_mode_hidden"):
|
|
|
+ observer.state = observer.STATE_MENU
|
|
|
+ _on_Button_MouseModeHidden_pressed()
|
|
|
+
|
|
|
+ if Input.is_action_pressed("mouse_mode_captured"):
|
|
|
+ _on_Button_MouseModeCaptured_pressed()
|
|
|
+
|
|
|
+
|
|
|
func check_wm_api():
|
|
|
var s = ""
|
|
|
if !OS.has_method("get_screen_count"):
|
|
|
s += " - get_screen_count()\n"
|
|
|
-
|
|
|
if !OS.has_method("get_current_screen"):
|
|
|
s += " - get_current_screen()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_current_screen"):
|
|
|
s += " - set_current_screen()\n"
|
|
|
-
|
|
|
if !OS.has_method("get_screen_position"):
|
|
|
s += " - get_screen_position()\n"
|
|
|
-
|
|
|
if !OS.has_method("get_screen_size"):
|
|
|
s += " - get_screen_size()\n"
|
|
|
-
|
|
|
if !OS.has_method("get_window_position"):
|
|
|
s += " - get_window_position()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_position"):
|
|
|
s += " - set_window_position()\n"
|
|
|
-
|
|
|
if !OS.has_method("get_window_size"):
|
|
|
s += " - get_window_size()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_size"):
|
|
|
s += " - set_window_size()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_fullscreen"):
|
|
|
s += " - set_window_fullscreen()\n"
|
|
|
-
|
|
|
if !OS.has_method("is_window_fullscreen"):
|
|
|
s += " - is_window_fullscreen()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_resizable"):
|
|
|
s += " - set_window_resizable()\n"
|
|
|
-
|
|
|
if !OS.has_method("is_window_resizable"):
|
|
|
s += " - is_window_resizable()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_minimized"):
|
|
|
s += " - set_window_minimized()\n"
|
|
|
-
|
|
|
if !OS.has_method("is_window_minimized"):
|
|
|
s += " - is_window_minimized()\n"
|
|
|
-
|
|
|
if !OS.has_method("set_window_maximized"):
|
|
|
s += " - set_window_maximized()\n"
|
|
|
-
|
|
|
if !OS.has_method("is_window_maximized"):
|
|
|
s += " - is_window_maximized()\n"
|
|
|
|
|
@@ -124,29 +125,6 @@ func check_wm_api():
|
|
|
return false
|
|
|
|
|
|
|
|
|
-func _ready():
|
|
|
- if not check_wm_api():
|
|
|
- set_physics_process(false)
|
|
|
- set_process_input(false)
|
|
|
-
|
|
|
-
|
|
|
-func _input(event):
|
|
|
- if event is InputEventMouseMotion:
|
|
|
- mousepos = event.position
|
|
|
-
|
|
|
- if event is InputEventKey:
|
|
|
- if Input.is_action_pressed("mouse_mode_visible"):
|
|
|
- observer.state = observer.STATE_MENU
|
|
|
- _on_Button_MouseModeVisible_pressed()
|
|
|
-
|
|
|
- if Input.is_action_pressed("mouse_mode_hidden"):
|
|
|
- observer.state = observer.STATE_MENU
|
|
|
- _on_Button_MouseModeHidden_pressed()
|
|
|
-
|
|
|
- if Input.is_action_pressed("mouse_mode_captured"):
|
|
|
- _on_Button_MouseModeCaptured_pressed()
|
|
|
-
|
|
|
-
|
|
|
func _on_Button_MoveTo_pressed():
|
|
|
OS.set_window_position(Vector2(100, 100))
|
|
|
|
|
@@ -200,4 +178,5 @@ func _on_Button_MouseModeHidden_pressed():
|
|
|
|
|
|
|
|
|
func _on_Button_MouseModeCaptured_pressed():
|
|
|
+ Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
|
observer.state = observer.STATE_GRAB
|