Skip to content

Commit

Permalink
Merge pull request #214 from worron/screen_notify_fixes
Browse files Browse the repository at this point in the history
Few tweaks in screen notifier mechanics
  • Loading branch information
worron authored Dec 11, 2024
2 parents a4fd53c + 717004e commit bdf0ada
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const TEXT_LABEL_MIN_X = 120

@export var container:VBoxContainer

var console: PankuConsole
var objects := []
var rows_need_update:Array = []
var row_objects:Array[Object] = []
Expand Down Expand Up @@ -99,7 +100,7 @@ func init():
for child in container.get_children():
container.remove_child(child)
child.queue_free()

for i in range(objects.size()):
create_rows_from_object(i)

Expand Down Expand Up @@ -188,8 +189,9 @@ func create_ui_row_read_only(property:Dictionary) -> Control:
return init_ui_row(ui_row, property)

func create_ui_row_comment(comment:String) -> Control:
var ui_row = preload("./row_comment.tscn").instantiate()
ui_row.label.text = comment
var ui_row: PankuCommentRow = preload("./row_comment.tscn").instantiate()
ui_row.console = console
ui_row.button.label.text = comment
return ui_row

func create_ui_row_func_button(property:Dictionary, object:Object) -> Control:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
[ext_resource type="PackedScene" uid="uid://drn5t13m088fb" path="res://addons/panku_console/common/panku_button.tscn" id="3_wi42w"]
[ext_resource type="Texture2D" uid="uid://b6jt0ggmuoyeb" path="res://addons/panku_console/res/icons2/info2.svg" id="4_o8r6v"]

[node name="RowComment" type="HBoxContainer" node_paths=PackedStringArray("label")]
[node name="RowComment" type="HBoxContainer" node_paths=PackedStringArray("button")]
custom_minimum_size = Vector2(20, 20)
offset_right = 148.0
offset_bottom = 31.0
size_flags_horizontal = 3
theme = ExtResource("1_wu8ma")
script = ExtResource("1_dvooy")
label = NodePath("PankuButton/HBoxContainer/Label")
button = NodePath("PankuButton")

[node name="PankuButton" parent="." instance=ExtResource("3_wi42w")]
layout_mode = 2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
class_name PankuCommentRow
extends HBoxContainer

@export var label:Label
@export var button: PankuButton

var console: PankuConsole


func _ready():
$PankuButton.pressed.connect(
func():
Panku.notify(label.text)
)
button.pressed.connect(_send_notify)


func _send_notify() -> void:
if console:
console.notify(button.label.text)
1 change: 1 addition & 0 deletions addons/panku_console/modules/data_controller/module.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func init_module():

func add_data_controller_window(objs:Array) -> PankuLynxWindow:
var data_controller = exporter_prefab.instantiate()
data_controller.console = core
data_controller.objects = objs
var new_window:PankuLynxWindow = core.windows_manager.create_window(data_controller)
new_window.position = new_window.get_layout_position(Control.PRESET_BOTTOM_RIGHT)
Expand Down
6 changes: 3 additions & 3 deletions addons/panku_console/modules/general_settings/opt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ extends ModuleOptions
_module.core.windows_manager.set_os_window_bg_color(v)
get:
return _module.core.windows_manager.os_window_bg_color

@export var global_font_size:int:
set(v):
Panku.windows_manager.theme.default_font_size = v
_module.core.windows_manager.theme.default_font_size = v
get:
return Panku.windows_manager.theme.default_font_size
return _module.core.windows_manager.theme.default_font_size

@export var export_comment_auto_global_font_size = (
"Adjust global font size automatically according to your device DPI"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ extends Control
signal key_binding_added(key: InputEventKey, expression: String)
signal key_binding_changed(key: InputEventKey, expression: String)

var console:PankuConsole

const INFO_STRING := "Yes, I know it."
const exp_key_item := preload("./exp_key_item.tscn")

@export var add_btn:Button
@export var container:VBoxContainer
var console: PankuConsole

@export var add_btn: Button
@export var container: VBoxContainer

var mapping_data = []

@onready var info_btn: Button = %InfoButton


func _ready():
info_btn.pressed.connect(_console_notify.bind(INFO_STRING))

#when clicking the button, add a new exp key mapping item
add_btn.pressed.connect(
func():
Expand All @@ -22,6 +28,12 @@ func _ready():
mapping_data.push_back([default_exp, default_event])
)


func _console_notify(txt: String) -> void:
if console:
console.notify(txt)


#handle input here.
func _unhandled_input(e):
if e is InputEventKey:
Expand All @@ -34,19 +46,20 @@ func _unhandled_input(e):
#execute the exp
var result = console.gd_exprenv.execute(exp)
if result.failed:
console.notify("[color=red]%s[/color]" % result.result)
_console_notify("[color=red]%s[/color]" % result.result)
else:
#ignore null result
if result.result:
console.notify(str(result.result))
_console_notify(str(result.result))


func add_item(exp:String, event:InputEventKey):
var item = exp_key_item.instantiate()
container.add_child(item)
container.move_child(item, container.get_child_count() - 2)
item.exp_edit.text = exp
item.remap_button.key_event = event

item.exp_edit_submitted.connect(
func(new_exp:String):
mapping_data[item.get_index()][0] = new_exp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://c6hm8vweq0j4f"]
[gd_scene load_steps=6 format=3 uid="uid://c6hm8vweq0j4f"]

[ext_resource type="Theme" uid="uid://bk18yfu0d77wk" path="res://addons/panku_console/res/panku_console_theme.tres" id="1_0xd5p"]
[ext_resource type="Script" path="res://addons/panku_console/modules/keyboard_shortcuts/exp_key_mapper_2.gd" id="2_vxcow"]
Expand All @@ -11,16 +11,6 @@ content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0

[sub_resource type="GDScript" id="GDScript_xeow3"]
script/source = "extends Button

func _ready():
pressed.connect(
func():
Panku.notify(\"Yes, I know it.\")
)
"
[node name="ExpKeyMapper" type="Control" node_paths=PackedStringArray("add_btn", "container")]
clip_contents = true
layout_mode = 3
Expand Down Expand Up @@ -52,13 +42,13 @@ theme_override_styles/panel = SubResource("StyleBoxEmpty_i7jk5")
[node name="VBoxContainer2" type="VBoxContainer" parent="ScrollContainer/PanelContainer"]
layout_mode = 2

[node name="Button" type="Button" parent="ScrollContainer/PanelContainer/VBoxContainer2"]
[node name="InfoButton" type="Button" parent="ScrollContainer/PanelContainer/VBoxContainer2"]
unique_name_in_owner = true
layout_mode = 2
text = "Edit expression key bindings here."
icon = ExtResource("3_ofrgs")
alignment = 0
expand_icon = true
script = SubResource("GDScript_xeow3")

[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer/PanelContainer/VBoxContainer2"]
layout_mode = 2
Expand Down
2 changes: 0 additions & 2 deletions addons/panku_console/modules/screen_notifier/resident_logs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ var prev_log = ""
# logs whose id >= 0
var named_logs := {}

func _ready():
$ResidentLogs.size = get_viewport().size * 0.5

func add_log(bbcode:String, id:=-1):
# logs whose id>=0 will be fixed to the bottom of the log list
Expand Down
26 changes: 6 additions & 20 deletions addons/panku_console/modules/screen_notifier/resident_logs.tscn
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://ccr06ddwa73ca"]
[gd_scene load_steps=3 format=3 uid="uid://ccr06ddwa73ca"]

[ext_resource type="Script" path="res://addons/panku_console/modules/screen_notifier/resident_logs.gd" id="1_uq2bh"]
[ext_resource type="Theme" uid="uid://bk18yfu0d77wk" path="res://addons/panku_console/res/panku_console_theme.tres" id="2_npyp1"]

[sub_resource type="GDScript" id="GDScript_p8loh"]
script/source = "extends ColorRect

func _ready():
queue_free()
"

[node name="ScreenNotifier" type="CanvasLayer" node_paths=PackedStringArray("named_container", "unnamed_container")]
script = ExtResource("1_uq2bh")
named_container = NodePath("ResidentLogs/Named")
unnamed_container = NodePath("ResidentLogs/Unnamed")

[node name="ResidentLogs" type="VBoxContainer" parent="."]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -193.0
offset_right = 244.0
offset_bottom = 193.0
anchors_preset = -1
anchor_top = 0.25
anchor_right = 0.5
anchor_bottom = 0.75
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
theme = ExtResource("2_npyp1")
alignment = 2

[node name="Indicator" type="ColorRect" parent="ResidentLogs"]
layout_mode = 2
size_flags_vertical = 3
color = Color(1, 0.345098, 0.34902, 1)
script = SubResource("GDScript_p8loh")

[node name="Unnamed" type="VBoxContainer" parent="ResidentLogs"]
layout_mode = 2
mouse_filter = 2
Expand Down

0 comments on commit bdf0ada

Please sign in to comment.