-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.gd
82 lines (69 loc) · 2.71 KB
/
main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
extends Control
var SurfaceScene = preload("res://surface_exploration.tscn")
var surfaceScene
var hud_mode = true
func _ready():
get_viewport().connect("size_changed", _on_resize)
_on_resize()
set_process_unhandled_input(true)
Globals.ui_mode_changed.connect(ui_mode_changed)
Globals.vimana_status_change.connect(vimana_status_change)
Globals.initiate_landing_sequence.connect(initiate_landing_sequence)
Globals.initiate_return_sequence.connect(initiate_return_sequence)
func vimana_status_change(status):
pass
func _on_resize():
printt("Root viewport size changed", get_viewport().size)
var size_x = get_viewport().size.x
var size_y = get_viewport().size.y
for viewport in get_tree().get_nodes_in_group("subviewports"):
viewport.size.x = size_x
viewport.size.y = size_y
viewport.notification(NOTIFICATION_VP_MOUSE_ENTER) # workaround for https://github.com/godotengine/godot/issues/89757
$Background.size.x = size_x
$Background.size.y = size_y
func _unhandled_input(event):
var evt1 = event.duplicate()
$SubViewportContainer_SpaceRemote/SubViewport.push_input(evt1, false) # is this still needed?
func ui_mode_changed(ui_mode):
if ui_mode == Globals.UI_MODE.SET_REMOTE_TARGET:
$SubViewportContainer_SpaceLocal.z_index = 1
$SubViewportContainer_SpaceNear.z_index = 2
$SubViewportContainer_SpaceRemote.z_index = 3
elif ui_mode == Globals.UI_MODE.SET_LOCAL_TARGET:
$SubViewportContainer_SpaceRemote.z_index = 1
$SubViewportContainer_SpaceNear.z_index = 2
$SubViewportContainer_SpaceLocal.z_index = 3
elif ui_mode == Globals.UI_MODE.NONE:
$SubViewportContainer_SpaceRemote.z_index = 0
$SubViewportContainer_SpaceLocal.z_index = 1
$SubViewportContainer_SpaceNear.z_index = 2
func initiate_landing_sequence():
%SpaceNear.process_mode = Node.PROCESS_MODE_DISABLED
surfaceScene = SurfaceScene.instantiate(PackedScene.GEN_EDIT_STATE_DISABLED)
$SubViewportContainer_SpaceNear/SubViewport.add_child(surfaceScene)
Globals.gameplay_mode = Globals.GAMEPLAY_MODE.SURFACE
func initiate_return_sequence():
%SpaceNear.process_mode = Node.PROCESS_MODE_INHERIT
$SubViewportContainer_SpaceNear/SubViewport.remove_child(surfaceScene)
surfaceScene.queue_free()
Globals.gameplay_mode = Globals.GAMEPLAY_MODE.SPACE
func _input(event):
if event.is_action_pressed("toggle_crt"):
if $CRTCanvasLayer.visible:
$CRTCanvasLayer.hide()
else:
$CRTCanvasLayer.show()
if event.is_action_pressed("toggle_hud"):
hud_mode = !hud_mode
if hud_mode:
%HUD.show_detail()
else:
%HUD.hide_detail()
if event.is_action_pressed("toggle_help"):
if %HUD/Help.visible:
%HUD/Help.hide()
else:
%HUD/Help.show()
if event.is_action_pressed("toggle_y_axis_inversion"):
Globals.camera_inverted = !Globals.camera_inverted