-
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.
Finally restored what we had working two days ago.
Got caught in godotengine/godot#17326, had to stop using ViewportContainer entirely. Means other hacks (mainly size/positioning in code) but it works
- Loading branch information
Showing
14 changed files
with
142 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extends CenterContainer | ||
|
||
|
||
# Declare member variables here. Examples: | ||
# var a = 2 | ||
# var b = "text" | ||
|
||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
#func _process(delta): | ||
# pass | ||
|
||
|
||
func _on_CenterContainer_mouse_entered(): | ||
print("_on_CenterContainer_mouse_entered") |
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
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,4 +1,4 @@ | ||
extends Control | ||
extends Node2D | ||
|
||
signal open_student | ||
|
||
|
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,37 +1,47 @@ | ||
extends Control | ||
extends Node2D | ||
|
||
export (PackedScene) var Student | ||
|
||
var HUD | ||
var message_has_mouse = false | ||
|
||
func _ready(): | ||
HUD = $CenterContainer/MarginContainer/HUD | ||
|
||
$HUD/StarMessage.rect_size = Vector2(1024, 128) | ||
$HUD/StarMessage.rect_position = Vector2(0, 768 - $HUD/StarMessage.rect_size.y) | ||
|
||
func _process(_delta): | ||
if Input.is_action_pressed("ui_cancel"): | ||
get_tree().quit() | ||
if Input.is_action_just_pressed("ui_accept"): | ||
if not HUD.message_has_mouse: | ||
if not message_has_mouse: | ||
show_message("") | ||
|
||
if Input.is_action_just_pressed("ui_right"): | ||
open_student() | ||
|
||
func _on_Sky_star_message(message): | ||
print("_on_Star_send_message", message) | ||
# if obscured: | ||
# return | ||
show_message(message) | ||
|
||
func show_message(msg): | ||
HUD.show_message(msg) | ||
|
||
func _on_HUD_open_student(): | ||
func open_student(): | ||
print("_on_HUD_open_student") | ||
# obscured = true | ||
show_message("") | ||
var student = Student.instance() | ||
add_child(student) | ||
student.rect_size = Vector2(1024, 768) | ||
student.connect("close", self, "_on_Student_close") | ||
|
||
func _on_Student_close(): | ||
print("_on_Student_close") | ||
remove_child($Student) | ||
# obscured = false | ||
|
||
func show_message(msg): | ||
$HUD/StarMessage.scroll_to_line(0) | ||
$HUD/StarMessage.text = "" | ||
$HUD/StarMessage.append_bbcode("[center]" + msg + "[/center]") | ||
|
||
func _on_StarMessage_mouse_entered(): | ||
message_has_mouse = true | ||
|
||
func _on_StarMessage_mouse_exited(): | ||
message_has_mouse = false |
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,47 +1,36 @@ | ||
[gd_scene load_steps=4 format=2] | ||
[gd_scene load_steps=6 format=2] | ||
|
||
[ext_resource path="res://Sky.tscn" type="PackedScene" id=1] | ||
[ext_resource path="res://HUD.tscn" type="PackedScene" id=2] | ||
[ext_resource path="res://assets/ilsscrp.ttf" type="DynamicFontData" id=2] | ||
[ext_resource path="res://Main.gd" type="Script" id=3] | ||
[ext_resource path="res://Student.tscn" type="PackedScene" id=4] | ||
|
||
[node name="Main" type="Control"] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
mouse_filter = 2 | ||
[sub_resource type="DynamicFont" id=1] | ||
size = 40 | ||
outline_color = Color( 0, 0, 0, 1 ) | ||
font_data = ExtResource( 2 ) | ||
|
||
[node name="Main" type="Node2D"] | ||
script = ExtResource( 3 ) | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
Student = ExtResource( 4 ) | ||
|
||
[node name="Sky" parent="." instance=ExtResource( 1 )] | ||
|
||
[node name="HUD" type="Node2D" parent="."] | ||
|
||
[node name="CenterContainer" type="CenterContainer" parent="."] | ||
margin_right = 40.0 | ||
margin_bottom = 40.0 | ||
mouse_filter = 2 | ||
[node name="StarMessage" type="RichTextLabel" parent="HUD"] | ||
light_mask = 2 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
focus_mode = 2 | ||
custom_fonts/normal_font = SubResource( 1 ) | ||
custom_colors/default_color = Color( 1, 1, 1, 1 ) | ||
custom_colors/selection_color = Color( 1, 1, 0.466667, 1 ) | ||
selection_enabled = true | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="ViewportContainer" type="ViewportContainer" parent="CenterContainer"] | ||
margin_right = 1024.0 | ||
margin_bottom = 768.0 | ||
mouse_filter = 1 | ||
|
||
[node name="Viewport" type="Viewport" parent="CenterContainer/ViewportContainer"] | ||
size = Vector2( 1024, 768 ) | ||
handle_input_locally = false | ||
render_target_update_mode = 3 | ||
|
||
[node name="Sky" parent="CenterContainer/ViewportContainer/Viewport" instance=ExtResource( 1 )] | ||
|
||
[node name="MarginContainer" type="MarginContainer" parent="CenterContainer"] | ||
margin_left = 512.0 | ||
margin_top = 384.0 | ||
margin_right = 512.0 | ||
margin_bottom = 384.0 | ||
mouse_filter = 2 | ||
|
||
[node name="HUD" parent="CenterContainer/MarginContainer" instance=ExtResource( 2 )] | ||
anchor_right = 0.0 | ||
anchor_bottom = 0.0 | ||
mouse_filter = 2 | ||
[connection signal="star_message" from="CenterContainer/ViewportContainer/Viewport/Sky" to="." method="_on_Sky_star_message"] | ||
[connection signal="star_message" from="Sky" to="." method="_on_Sky_star_message"] | ||
[connection signal="mouse_entered" from="HUD/StarMessage" to="." method="_on_StarMessage_mouse_entered"] | ||
[connection signal="mouse_exited" from="HUD/StarMessage" to="." method="_on_StarMessage_mouse_exited"] |
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,14 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://Viewport.gd" type="Script" id=1] | ||
[ext_resource path="res://Sky.tscn" type="PackedScene" id=3] | ||
|
||
[node name="Viewport" type="Viewport"] | ||
size = Vector2( 1024, 768 ) | ||
handle_input_locally = false | ||
render_target_update_mode = 3 | ||
physics_object_picking = true | ||
gui_disable_input = true | ||
script = ExtResource( 1 ) | ||
|
||
[node name="Sky" parent="." instance=ExtResource( 3 )] |
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 |
---|---|---|
|
@@ -7,4 +7,3 @@ func _ready(): | |
|
||
func _on_Star_send_message(star): | ||
emit_signal("star_message", star.message) | ||
|
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
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,12 @@ | ||
extends Viewport | ||
|
||
|
||
# Declare member variables here. Examples: | ||
# var a = 2 | ||
# var b = "text" | ||
|
||
func _ready(): | ||
pass | ||
# set_process_input(true) | ||
# set_process_unhandled_input(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends ViewportContainer | ||
|
||
|
||
# Declare member variables here. Examples: | ||
# var a = 2 | ||
# var b = "text" | ||
|
||
func _on_ViewportContainer_mouse_entered(): | ||
print("_on_ViewportContainer_mouse_entered") | ||
|
||
func _input( event ): | ||
if event is InputEventMouse: | ||
var mouseEvent = event.duplicate() | ||
mouseEvent.position = get_global_transform().xform_inv(event.global_position) | ||
$Viewport.unhandled_input(mouseEvent) | ||
else: | ||
$Viewport.unhandled_input(event) |