This commit is contained in:
Sofia 2026-07-16 17:15:07 +03:00
parent 9564b778fb
commit b93eded960
3 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,8 @@
[gd_scene format=3 uid="uid://bsb6asp5o35w3"]
[node name="command_line_panel" type="CommandLinePanel" unique_id=2077938969 node_paths=PackedStringArray("input_field", "text_field", "scroll_container")]
[node name="canvas_layer" type="CanvasLayer" unique_id=1517655401]
[node name="command_line_panel" type="CommandLinePanel" parent="." unique_id=2077938969 node_paths=PackedStringArray("input_field", "text_field", "scroll_container")]
input_field = NodePath("input_field")
text_field = NodePath("scroll_container/text_field")
scroll_container = NodePath("scroll_container")
@ -9,7 +11,7 @@ anchor_right = 1.0
offset_bottom = 307.0
grow_horizontal = 2
[node name="input_field" type="TextEdit" parent="." unique_id=2095748573]
[node name="input_field" type="TextEdit" parent="command_line_panel" unique_id=2095748573]
layout_mode = 1
anchors_preset = 10
anchor_right = 1.0
@ -17,7 +19,7 @@ offset_top = 307.0
offset_bottom = 342.0
grow_horizontal = 2
[node name="scroll_container" type="ScrollContainer" parent="." unique_id=1922272461]
[node name="scroll_container" type="ScrollContainer" parent="command_line_panel" unique_id=1922272461]
custom_minimum_size = Vector2(-1, 0)
layout_mode = 1
anchors_preset = 10
@ -27,7 +29,7 @@ offset_right = -1.0
offset_bottom = 292.0
grow_horizontal = 2
[node name="text_field" type="RichTextLabel" parent="scroll_container" unique_id=591332585]
[node name="text_field" type="RichTextLabel" parent="command_line_panel/scroll_container" unique_id=591332585]
custom_minimum_size = Vector2(-1, -1)
layout_mode = 2
bbcode_enabled = true

View File

@ -10,7 +10,7 @@ use teanet::{Peer, PeerConfig, PeerMessage};
use crate::{
game_manager::{Game, GameManager, Player},
net::net_stats::Stats,
ui::cli::{CLI_GLOBAL_NAME, CliColor, CommandLinePanel},
ui::cli::{CliColor, CommandLinePanel},
};
#[derive(GodotClass)]
@ -45,7 +45,7 @@ impl INode for NetworkManager {
}
fn ready(&mut self) {
let mut cli = get_autoload_by_name::<CommandLinePanel>(CLI_GLOBAL_NAME);
let mut cli = CommandLinePanel::singleton();
cli.bind_mut()
.signals()

View File

@ -3,7 +3,9 @@ use std::net::SocketAddr;
use std::ops::DerefMut;
use std::rc::Rc;
use godot::classes::{Engine, IPanel, Panel, RichTextLabel, ScrollContainer, TextEdit};
use godot::classes::{
CanvasLayer, Engine, IPanel, Panel, RichTextLabel, ScrollContainer, TextEdit,
};
use godot::prelude::*;
use godot::tools::get_autoload_by_name;
@ -94,7 +96,10 @@ impl CommandLinePanel {
pub fn on_disconnect();
pub fn singleton() -> Gd<CommandLinePanel> {
get_autoload_by_name::<CommandLinePanel>(CLI_GLOBAL_NAME)
get_autoload_by_name::<CanvasLayer>(CLI_GLOBAL_NAME)
.get_child(0)
.unwrap()
.cast()
}
pub fn input_command(&mut self, command: String) {