Change a bunch of TextEdits into LineEdits
This commit is contained in:
parent
3db08f6c86
commit
a29273bced
@ -11,7 +11,7 @@ bg_color = Color(0.30692267, 0.3069227, 0.30692264, 1)
|
||||
|
||||
[node name="lobby" type="LobbyPanel" unique_id=915192272 node_paths=PackedStringArray("players_list", "name_field", "ready_button", "map_selection", "options_panel", "options_grid")]
|
||||
players_list = NodePath("v_box_container/players_list")
|
||||
name_field = NodePath("v_box_container/h_box_container/text_edit")
|
||||
name_field = NodePath("")
|
||||
player_listing_prefab = ExtResource("1_o1atq")
|
||||
ready_button = NodePath("v_box_container3/ready_button")
|
||||
map_selection = NodePath("v_box_container2/option_button")
|
||||
@ -50,7 +50,7 @@ metadata/_edit_lock_ = true
|
||||
layout_mode = 2
|
||||
text = "Name:"
|
||||
|
||||
[node name="text_edit" type="TextEdit" parent="v_box_container/h_box_container" unique_id=683714912]
|
||||
[node name="text_edit" type="LineEdit" parent="v_box_container/h_box_container" unique_id=284528736]
|
||||
custom_minimum_size = Vector2(150, 0)
|
||||
layout_mode = 2
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ layout_mode = 2
|
||||
text = "Address"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="address_text" type="TextEdit" parent="join_panel/v_box_container" unique_id=584304528]
|
||||
[node name="address_text" type="LineEdit" parent="join_panel/v_box_container" unique_id=672176728]
|
||||
custom_minimum_size = Vector2(150, 30)
|
||||
layout_mode = 2
|
||||
text = "127.0.0.1:8080"
|
||||
|
||||
@ -15,7 +15,7 @@ offset_right = 1.0
|
||||
offset_bottom = -233.0
|
||||
grow_horizontal = 2
|
||||
|
||||
[node name="input_field" type="TextEdit" parent="command_line_panel" unique_id=2095748573]
|
||||
[node name="input_field" type="LineEdit" parent="command_line_panel" unique_id=33075135]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
|
||||
@ -3,7 +3,7 @@ use std::i32;
|
||||
use godot::{
|
||||
classes::{
|
||||
Engine, IVBoxContainer, InputEvent, LineEdit, Panel, RichTextLabel, ScrollContainer,
|
||||
TextEdit, VBoxContainer,
|
||||
VBoxContainer,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@ use std::net::SocketAddr;
|
||||
use std::rc::Rc;
|
||||
|
||||
use godot::classes::{
|
||||
CanvasLayer, IPanel, InputEvent, Panel, RichTextLabel, ScrollContainer, TextEdit,
|
||||
CanvasLayer, IPanel, InputEvent, LineEdit, Panel, RichTextLabel, ScrollContainer,
|
||||
};
|
||||
use godot::prelude::*;
|
||||
use godot::tools::get_autoload_by_name;
|
||||
@ -32,7 +32,7 @@ pub const CLI_GLOBAL_NAME: &str = "CommandLinePanelGlobal";
|
||||
#[class(base=Panel)]
|
||||
pub struct CommandLinePanel {
|
||||
#[export]
|
||||
pub input_field: Option<Gd<TextEdit>>,
|
||||
pub input_field: Option<Gd<LineEdit>>,
|
||||
#[export]
|
||||
pub text_field: Option<Gd<RichTextLabel>>,
|
||||
#[export]
|
||||
@ -74,6 +74,13 @@ impl IPanel for CommandLinePanel {
|
||||
}
|
||||
|
||||
fn ready(&mut self) {
|
||||
if let Some(input_field) = self.input_field.clone() {
|
||||
input_field
|
||||
.signals()
|
||||
.text_submitted()
|
||||
.connect_other(self, |s, value| s.input_command(value.to_string()));
|
||||
}
|
||||
|
||||
self.idle_y = self.base().get_position().y;
|
||||
}
|
||||
|
||||
@ -85,15 +92,6 @@ impl IPanel for CommandLinePanel {
|
||||
self.scroll_next_update = false;
|
||||
}
|
||||
|
||||
if let Some(input) = self.input_field.clone() {
|
||||
let text = input.get_text();
|
||||
if text.contains("\n") {
|
||||
let parts = text.split("\n");
|
||||
let first = parts.get(0).unwrap();
|
||||
self.input_command(first.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
let old_pos = self.base().get_position();
|
||||
let mut target_pos = self.base().get_position();
|
||||
if self.opened {
|
||||
|
||||
@ -2,8 +2,8 @@ use std::collections::HashMap;
|
||||
|
||||
use godot::{
|
||||
classes::{
|
||||
Button, CheckBox, Control, GridContainer, IPanel, Label, OptionButton, Panel, SpinBox,
|
||||
TextEdit, VBoxContainer,
|
||||
Button, CheckBox, Control, GridContainer, IPanel, Label, LineEdit, OptionButton, Panel,
|
||||
SpinBox, VBoxContainer,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
@ -20,7 +20,7 @@ pub struct LobbyPanel {
|
||||
#[export]
|
||||
players_list: Option<Gd<VBoxContainer>>,
|
||||
#[export]
|
||||
name_field: Option<Gd<TextEdit>>,
|
||||
name_field: Option<Gd<LineEdit>>,
|
||||
#[export]
|
||||
player_listing_prefab: Option<Gd<PackedScene>>,
|
||||
#[export]
|
||||
@ -108,22 +108,18 @@ impl IPanel for LobbyPanel {
|
||||
name_field
|
||||
.signals()
|
||||
.text_changed()
|
||||
.connect_other(self, |s| {
|
||||
if let Some(name_field) = &s.name_field {
|
||||
.connect_other(self, |_, value| {
|
||||
if let Some(game) = &mut Game::singleton() {
|
||||
let player_id = game.bind().self_id;
|
||||
if let Some(player_id) = player_id {
|
||||
game.bind_mut().update_player_nick(
|
||||
player_id,
|
||||
name_field.get_text().to_string(),
|
||||
);
|
||||
game.bind_mut()
|
||||
.update_player_nick(player_id, value.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
NetworkManager::singleton()
|
||||
.bind_mut()
|
||||
.update_nick(name_field.get_text().to_string());
|
||||
}
|
||||
.update_nick(value.to_string());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use godot::{
|
||||
classes::{Button, Camera3D, Label, Panel, SpinBox, TextEdit},
|
||||
classes::{Button, Camera3D, Label, LineEdit, Panel, SpinBox},
|
||||
prelude::*,
|
||||
register::property::SimpleVar,
|
||||
};
|
||||
@ -41,7 +41,7 @@ pub struct MainMenu {
|
||||
#[export]
|
||||
host_port: Option<Gd<SpinBox>>,
|
||||
#[export]
|
||||
join_addr: Option<Gd<TextEdit>>,
|
||||
join_addr: Option<Gd<LineEdit>>,
|
||||
|
||||
#[export]
|
||||
popup_panel: Option<Gd<Panel>>,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use godot::{
|
||||
classes::{Control, GridContainer, IPanel, Label, Panel, TextEdit, control::SizeFlags},
|
||||
classes::{Control, GridContainer, IPanel, Label, LineEdit, Panel, control::SizeFlags},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@ -103,22 +103,16 @@ impl IPanel for SettingsPanel {
|
||||
slider.upcast::<Control>()
|
||||
}
|
||||
SettingValue::String(value) => {
|
||||
let mut text_edit = TextEdit::new_alloc();
|
||||
let mut text_edit = LineEdit::new_alloc();
|
||||
text_edit.set_custom_minimum_size(Vector2::new(100., -1.));
|
||||
text_edit.set_text(value);
|
||||
|
||||
let setting_clone = setting.clone();
|
||||
let text_edit_clone = text_edit.clone();
|
||||
text_edit
|
||||
.signals()
|
||||
.text_changed()
|
||||
.connect_other(self, move |s| {
|
||||
s.on_change(
|
||||
setting_clone,
|
||||
SettingValue::String(
|
||||
text_edit_clone.get_text().to_string(),
|
||||
),
|
||||
);
|
||||
.connect_other(self, move |s, v| {
|
||||
s.on_change(setting_clone, SettingValue::String(v.to_string()));
|
||||
});
|
||||
|
||||
text_edit.upcast()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user