add console panel, still have scroll problem
This commit is contained in:
parent
7cdcaf1e2f
commit
2040afa34a
|
@ -1116,6 +1116,16 @@ ballance_esc={
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
ballance_cmd={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":47,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
ballance_chat={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":84,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://resources/user_interface/textures/lineedit_borderless_deselect.png" type="Texture" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
region_rect = Rect2( 0, 0, 64, 32 )
|
||||||
|
margin_left = 14.1409
|
||||||
|
margin_right = 12.785
|
||||||
|
margin_top = 13.5598
|
||||||
|
margin_bottom = 13.3661
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_resource type="StyleBoxTexture" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://resources/user_interface/textures/lineedit_borderless_select.png" type="Texture" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
region_rect = Rect2( 0, 0, 64, 32 )
|
||||||
|
margin_left = 14.1409
|
||||||
|
margin_right = 12.785
|
||||||
|
margin_top = 13.5598
|
||||||
|
margin_bottom = 13.3661
|
Binary file not shown.
After Width: | Height: | Size: 165 B |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/lineedit_borderless_deselect.png-5a57d2f0a83a0ea3163638365fbb072b.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/user_interface/textures/lineedit_borderless_deselect.png"
|
||||||
|
dest_files=[ "res://.import/lineedit_borderless_deselect.png-5a57d2f0a83a0ea3163638365fbb072b.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
resources/user_interface/textures/lineedit_borderless_select.png
Normal file
BIN
resources/user_interface/textures/lineedit_borderless_select.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 B |
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/lineedit_borderless_select.png-4aee58b7e500decf6960fa056582c12d.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/user_interface/textures/lineedit_borderless_select.png"
|
||||||
|
dest_files=[ "res://.import/lineedit_borderless_select.png-4aee58b7e500decf6960fa056582c12d.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
|
@ -3,15 +3,15 @@
|
||||||
[ext_resource path="res://scenes/stages/MenuManager.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/stages/MenuManager.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://scenes/stages/StalkerCore.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://scenes/stages/StalkerCore.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://scripts/GameRoot.cs" type="Script" id=3]
|
[ext_resource path="res://scripts/GameRoot.cs" type="Script" id=3]
|
||||||
[ext_resource path="res://scenes/stages/ShadowBallManager.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://scenes/stages/ConsolePanel.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[node name="GameRoot" type="Node"]
|
[node name="GameRoot" type="Node"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
[node name="ConsolePanel" parent="." instance=ExtResource( 4 )]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="MenuManager" parent="UILayer" instance=ExtResource( 1 )]
|
[node name="MenuManager" parent="." instance=ExtResource( 1 )]
|
||||||
|
visible = false
|
||||||
|
|
||||||
[node name="StalkerCore" parent="." instance=ExtResource( 2 )]
|
[node name="StalkerCore" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
[node name="ShadowBallManager" parent="." instance=ExtResource( 4 )]
|
|
||||||
|
|
46
scenes/stages/ConsolePanel.tscn
Normal file
46
scenes/stages/ConsolePanel.tscn
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://scenes/user_interface/LineEditBorderless.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://scripts/stages/ConsolePanel.cs" type="Script" id=2]
|
||||||
|
[ext_resource path="res://resources/user_interface/default_theme.tres" type="Theme" id=3]
|
||||||
|
|
||||||
|
[node name="ConsolePanel" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
theme = ExtResource( 3 )
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CommandInput" parent="." instance=ExtResource( 1 )]
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = -44.0
|
||||||
|
margin_right = 0.0
|
||||||
|
margin_bottom = 0.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
placeholder_text = "Input your command here..."
|
||||||
|
placeholder_alpha = 0.3
|
||||||
|
caret_blink = true
|
||||||
|
|
||||||
|
[node name="ScrollSet" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = 24.0
|
||||||
|
margin_right = -48.0
|
||||||
|
margin_bottom = -64.0
|
||||||
|
|
||||||
|
[node name="ScrollBackground" type="ColorRect" parent="ScrollSet"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0, 0, 0, 0.498039 )
|
||||||
|
|
||||||
|
[node name="Scrollbar" type="ScrollContainer" parent="ScrollSet"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
scroll_horizontal_enabled = false
|
||||||
|
|
||||||
|
[node name="MessageContainer" type="VBoxContainer" parent="ScrollSet/Scrollbar"]
|
||||||
|
margin_right = 976.0
|
||||||
|
margin_bottom = 680.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
|
@ -3,7 +3,7 @@
|
||||||
[ext_resource path="res://resources/textures/Ball_Paper.bmp" type="Texture" id=1]
|
[ext_resource path="res://resources/textures/Ball_Paper.bmp" type="Texture" id=1]
|
||||||
[ext_resource path="res://resources/textures/Ball_Stone.bmp" type="Texture" id=2]
|
[ext_resource path="res://resources/textures/Ball_Stone.bmp" type="Texture" id=2]
|
||||||
[ext_resource path="res://resources/textures/Ball_Wood.bmp" type="Texture" id=3]
|
[ext_resource path="res://resources/textures/Ball_Wood.bmp" type="Texture" id=3]
|
||||||
[ext_resource path="res://scripts/stages/PlayerBall.cs" type="Script" id=4]
|
[ext_resource path="res://scripts/stages/ShadowBall.cs" type="Script" id=4]
|
||||||
[ext_resource path="res://scenes/user_interface/LabelNormal.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://scenes/user_interface/LabelNormal.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://resources/user_interface/player_pointer.png" type="Texture" id=6]
|
[ext_resource path="res://resources/user_interface/player_pointer.png" type="Texture" id=6]
|
||||||
|
|
||||||
|
@ -112,16 +112,21 @@ margin_bottom = 16.0
|
||||||
rect_pivot_offset = Vector2( 16, 16 )
|
rect_pivot_offset = Vector2( 16, 16 )
|
||||||
texture = ExtResource( 6 )
|
texture = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="Ball_Paper" type="MeshInstance" parent="."]
|
[node name="ModelArchor" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="Ball_Paper" type="MeshInstance" parent="ModelArchor"]
|
||||||
visible = false
|
visible = false
|
||||||
mesh = SubResource( 4 )
|
mesh = SubResource( 4 )
|
||||||
|
skeleton = NodePath("../..")
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
[node name="Ball_Stone" type="MeshInstance" parent="."]
|
[node name="Ball_Stone" type="MeshInstance" parent="ModelArchor"]
|
||||||
visible = false
|
visible = false
|
||||||
mesh = SubResource( 5 )
|
mesh = SubResource( 5 )
|
||||||
|
skeleton = NodePath("../..")
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
[node name="Ball_Wood" type="MeshInstance" parent="."]
|
[node name="Ball_Wood" type="MeshInstance" parent="ModelArchor"]
|
||||||
mesh = SubResource( 6 )
|
mesh = SubResource( 6 )
|
||||||
|
skeleton = NodePath("../..")
|
||||||
material/0 = null
|
material/0 = null
|
|
@ -8,7 +8,10 @@ script = ExtResource( 1 )
|
||||||
[node name="FreeCamOrigin" type="Spatial" parent="."]
|
[node name="FreeCamOrigin" type="Spatial" parent="."]
|
||||||
|
|
||||||
[node name="FreeCam" type="Camera" parent="."]
|
[node name="FreeCam" type="Camera" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
|
|
||||||
fov = 58.0
|
fov = 58.0
|
||||||
near = 3.0
|
near = 3.0
|
||||||
far = 1200.0
|
far = 1200.0
|
||||||
|
|
||||||
|
[node name="StaticCamOrigin" type="Spatial" parent="."]
|
||||||
|
|
||||||
|
[node name="StaticCamTracking" type="Spatial" parent="StaticCamOrigin"]
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
[gd_scene load_steps=4 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://scenes/levels/test.escn" type="PackedScene" id=1]
|
[ext_resource path="res://scenes/levels/test.escn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://scripts/stages/StalkerCore.cs" type="Script" id=2]
|
[ext_resource path="res://scripts/stages/StalkerCore.cs" type="Script" id=2]
|
||||||
[ext_resource path="res://scenes/stages/StalkerCamera.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://scenes/stages/StalkerCamera.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://scenes/stages/ShadowBallManager.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[node name="StalkerCore" type="Spatial"]
|
[node name="StalkerCore" type="Spatial"]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
@ -12,4 +13,6 @@ transform = Transform( 0.920545, 0.275714, -0.276729, 0.0231072, 0.668731, 0.743
|
||||||
|
|
||||||
[node name="StalkerCamera" parent="." instance=ExtResource( 3 )]
|
[node name="StalkerCamera" parent="." instance=ExtResource( 3 )]
|
||||||
|
|
||||||
|
[node name="ShadowBallManager" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
||||||
[node name="test" parent="." instance=ExtResource( 1 )]
|
[node name="test" parent="." instance=ExtResource( 1 )]
|
||||||
|
|
14
scenes/user_interface/LabelConsole.tscn
Normal file
14
scenes/user_interface/LabelConsole.tscn
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://resources/fonts/fontstyle_normal.tres" type="DynamicFont" id=1]
|
||||||
|
[ext_resource path="res://scripts/user_interface/LabelConsole.cs" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="LabelConsole" type="Control"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="RealLabel" type="Label" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_right = -12.0
|
||||||
|
custom_fonts/font = ExtResource( 1 )
|
||||||
|
autowrap = true
|
13
scenes/user_interface/LineEditBorderless.tscn
Normal file
13
scenes/user_interface/LineEditBorderless.tscn
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://resources/user_interface/styles/lineedit_borderless_style_select.tres" type="StyleBox" id=1]
|
||||||
|
[ext_resource path="res://resources/user_interface/styles/lineedit_borderless_style_deselect.tres" type="StyleBox" id=2]
|
||||||
|
[ext_resource path="res://resources/fonts/fontstyle_normal.tres" type="DynamicFont" id=3]
|
||||||
|
|
||||||
|
[node name="LineEditBorderless" type="LineEdit"]
|
||||||
|
margin_right = 58.0
|
||||||
|
margin_bottom = 24.0
|
||||||
|
custom_fonts/font = ExtResource( 3 )
|
||||||
|
custom_styles/read_only = ExtResource( 2 )
|
||||||
|
custom_styles/focus = ExtResource( 1 )
|
||||||
|
custom_styles/normal = ExtResource( 2 )
|
|
@ -7,28 +7,43 @@ public class GameRoot : Node {
|
||||||
StalkerCore mStalkerCore;
|
StalkerCore mStalkerCore;
|
||||||
|
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
mMenuManager = GetNode<MenuManager>("UILayer/MenuManager");
|
mMenuManager = GetNode<MenuManager>("MenuManager");
|
||||||
mStalkerCore = GetNode<StalkerCore>("StalkerCore");
|
mStalkerCore = GetNode<StalkerCore>("StalkerCore");
|
||||||
|
|
||||||
mMenuManager.Connect(nameof(MenuManager.SetMouseCapture), this, nameof(Proc_MenuManager_SetMouseCapture));
|
//mMenuManager.Connect(nameof(MenuManager.SetMouseCapture), this, nameof(Proc_MenuManager_SetMouseCapture));
|
||||||
mMenuManager.Connect(nameof(MenuManager.ExitGame), this, nameof(Proc_MenuManager_ExitGame));
|
mMenuManager.Connect(nameof(MenuManager.ExitGame), this, nameof(Proc_MenuManager_ExitGame));
|
||||||
|
|
||||||
// raw executing this func
|
//// raw executing this func
|
||||||
// to set proper status
|
//// to set proper status
|
||||||
Proc_MenuManager_SetMouseCapture();
|
//Proc_MenuManager_SetMouseCapture();
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_StalkerManager_EventControllerChanged(BallanceStalkerCore.EventControllerSource obj) {
|
||||||
|
switch (obj) {
|
||||||
|
case BallanceStalkerCore.EventControllerSource.None:
|
||||||
|
Input.SetMouseMode(Input.MouseMode.Captured);
|
||||||
|
break;
|
||||||
|
case BallanceStalkerCore.EventControllerSource.Menu:
|
||||||
|
case BallanceStalkerCore.EventControllerSource.Console:
|
||||||
|
case BallanceStalkerCore.EventControllerSource.Chat:
|
||||||
|
Input.SetMouseMode(Input.MouseMode.Visible);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event) {
|
public override void _Input(InputEvent @event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Proc_MenuManager_SetMouseCapture() {
|
//private void Proc_MenuManager_SetMouseCapture() {
|
||||||
if (mMenuManager.Visible) {
|
// if (mMenuManager.Visible) {
|
||||||
Input.SetMouseMode(Input.MouseMode.Visible);
|
// Input.SetMouseMode(Input.MouseMode.Visible);
|
||||||
} else {
|
// } else {
|
||||||
Input.SetMouseMode(Input.MouseMode.Captured);
|
// Input.SetMouseMode(Input.MouseMode.Captured);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
private void Proc_MenuManager_ExitGame() {
|
private void Proc_MenuManager_ExitGame() {
|
||||||
GetTree().Notification(MainLoop.NotificationWmQuitRequest);
|
GetTree().Notification(MainLoop.NotificationWmQuitRequest);
|
||||||
}
|
}
|
||||||
|
|
98
scripts/stages/ConsolePanel.cs
Normal file
98
scripts/stages/ConsolePanel.cs
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public enum LabelConsoleMessageType {
|
||||||
|
Normal,
|
||||||
|
Highlight,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ConsolePanel : Control {
|
||||||
|
private LineEdit mCmdInput;
|
||||||
|
private ScrollContainer mScrollbar;
|
||||||
|
private VBoxContainer mMessageContainer;
|
||||||
|
private PackedScene mTemplateLabelConsole;
|
||||||
|
private Queue<LabelConsole> mMessageQueue = new Queue<LabelConsole>();
|
||||||
|
private readonly int QUEUE_MAX_SIZE = 100;
|
||||||
|
|
||||||
|
public override void _Ready() {
|
||||||
|
mTemplateLabelConsole = ResourceLoader.Load<PackedScene>("res://scenes/user_interface/LabelConsole.tscn");
|
||||||
|
|
||||||
|
mCmdInput = GetNode<LineEdit>("CommandInput");
|
||||||
|
mScrollbar = GetNode<ScrollContainer>("ScrollSet/Scrollbar");
|
||||||
|
mMessageContainer = GetNode<VBoxContainer>("ScrollSet/Scrollbar/MessageContainer");
|
||||||
|
mCmdInput.Connect("text_entered", this, nameof(Proc_LineEdit_TextEntered));
|
||||||
|
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_StalkerManager_EventControllerChanged(BallanceStalkerCore.EventControllerSource obj) {
|
||||||
|
if (obj == BallanceStalkerCore.EventControllerSource.Chat) {
|
||||||
|
this.Visible = true;
|
||||||
|
mCmdInput.GrabFocus();
|
||||||
|
} else if (obj == BallanceStalkerCore.EventControllerSource.Console) {
|
||||||
|
// same process of chat
|
||||||
|
// but only add a extra preset charcater in cmd input
|
||||||
|
this.Visible = true;
|
||||||
|
mCmdInput.Text = "/";
|
||||||
|
mCmdInput.CaretPosition = 1;
|
||||||
|
mCmdInput.GrabFocus();
|
||||||
|
} else {
|
||||||
|
this.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Input(InputEvent @event) {
|
||||||
|
if (!this.Visible) return;
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("ballance_esc")) {
|
||||||
|
// clean input
|
||||||
|
mCmdInput.Text = "";
|
||||||
|
// back to camera
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.None);
|
||||||
|
// mark handled to prevent loop call
|
||||||
|
GetTree().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddMessage(string strl, LabelConsoleMessageType t) {
|
||||||
|
LabelConsole target;
|
||||||
|
if (mMessageQueue.Count > QUEUE_MAX_SIZE) {
|
||||||
|
// popup last item and remove it from scene first
|
||||||
|
target = mMessageQueue.Dequeue();
|
||||||
|
mMessageContainer.RemoveChild(target);
|
||||||
|
} else {
|
||||||
|
target = mTemplateLabelConsole.Instance<LabelConsole>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add into scene and queue
|
||||||
|
mMessageQueue.Enqueue(target);
|
||||||
|
mMessageContainer.AddChild(target);
|
||||||
|
|
||||||
|
// set text
|
||||||
|
target.SetText(strl, t);
|
||||||
|
|
||||||
|
// scroll to bottom
|
||||||
|
//var bar = mScrollbar.GetVScrollbar();
|
||||||
|
//bar.Value = bar.MaxValue;
|
||||||
|
mScrollbar.ScrollVertical = (int)mScrollbar.GetVScrollbar().MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_LineEdit_TextEntered(string new_strl) {
|
||||||
|
if (new_strl != string.Empty) {
|
||||||
|
// todo: finish cmd parse
|
||||||
|
if (new_strl.StartsWith("/")) {
|
||||||
|
AddMessage(new_strl, LabelConsoleMessageType.Highlight);
|
||||||
|
} else if (new_strl.StartsWith("!")) {
|
||||||
|
AddMessage(new_strl, LabelConsoleMessageType.Error);
|
||||||
|
} else {
|
||||||
|
AddMessage(new_strl, LabelConsoleMessageType.Normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean cmd
|
||||||
|
mCmdInput.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,8 +12,8 @@ public class MenuManager : Control {
|
||||||
About
|
About
|
||||||
}
|
}
|
||||||
|
|
||||||
[Signal]
|
//[Signal]
|
||||||
public delegate void SetMouseCapture();
|
//public delegate void SetMouseCapture();
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void ExitGame();
|
public delegate void ExitGame();
|
||||||
|
|
||||||
|
@ -28,18 +28,31 @@ public class MenuManager : Control {
|
||||||
mMenuMain.Connect(nameof(MenuMain.MenuMain_GotoPage), this, nameof(Proc_MenuMain_GotoPage));
|
mMenuMain.Connect(nameof(MenuMain.MenuMain_GotoPage), this, nameof(Proc_MenuMain_GotoPage));
|
||||||
mMenuMain.Connect(nameof(MenuMain.MenuMain_Back), this, nameof(Proc_MenuMain_Back));
|
mMenuMain.Connect(nameof(MenuMain.MenuMain_Back), this, nameof(Proc_MenuMain_Back));
|
||||||
mMenuMain.Connect(nameof(MenuMain.MenuMain_Exit), this, nameof(Proc_MenuMain_Exit));
|
mMenuMain.Connect(nameof(MenuMain.MenuMain_Exit), this, nameof(Proc_MenuMain_Exit));
|
||||||
|
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_StalkerManager_EventControllerChanged(BallanceStalkerCore.EventControllerSource obj) {
|
||||||
|
if (obj == BallanceStalkerCore.EventControllerSource.Menu) {
|
||||||
|
this.Visible = true;
|
||||||
|
} else {
|
||||||
|
this.Visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event) {
|
public override void _Input(InputEvent @event) {
|
||||||
if (Input.IsActionJustPressed("ballance_esc")) {
|
if (!this.Visible) return;
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("ballance_esc")) {
|
||||||
if (mCurrentPage == MenuPage.Main) {
|
if (mCurrentPage == MenuPage.Main) {
|
||||||
// we are in main menu, we need switch visible
|
// we are in main menu, we need switch visible
|
||||||
this.Visible = !this.Visible;
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.None);
|
||||||
EmitSignal(nameof(SetMouseCapture));
|
|
||||||
} else {
|
} else {
|
||||||
// otherwise, back from sub menu
|
// otherwise, back from sub menu
|
||||||
RefreshMenuPage(MenuPage.Main);
|
RefreshMenuPage(MenuPage.Main);
|
||||||
}
|
}
|
||||||
|
// mark handled to prevent loop call
|
||||||
|
GetTree().SetInputAsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,8 +65,7 @@ public class MenuManager : Control {
|
||||||
RefreshMenuPage(menu_type);
|
RefreshMenuPage(menu_type);
|
||||||
}
|
}
|
||||||
private void Proc_MenuMain_Back() {
|
private void Proc_MenuMain_Back() {
|
||||||
this.Visible = false;
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.None);
|
||||||
EmitSignal(nameof(SetMouseCapture));
|
|
||||||
}
|
}
|
||||||
private void Proc_MenuMain_Exit() {
|
private void Proc_MenuMain_Exit() {
|
||||||
EmitSignal(nameof(ExitGame));
|
EmitSignal(nameof(ExitGame));
|
||||||
|
|
|
@ -3,22 +3,26 @@ using System;
|
||||||
|
|
||||||
// Reference: https://github.com/godotengine/godot-demo-projects/blob/master/3d/waypoints
|
// Reference: https://github.com/godotengine/godot-demo-projects/blob/master/3d/waypoints
|
||||||
|
|
||||||
public class PlayerBall : Spatial {
|
public enum ShadowBallType : UInt32 {
|
||||||
|
Stone,
|
||||||
|
Wood,
|
||||||
|
Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ShadowBall : Spatial {
|
||||||
|
|
||||||
static readonly float MARGIN = 16f; // set it as half of arrow image
|
static readonly float MARGIN = 16f; // set it as half of arrow image
|
||||||
static readonly float TEXT_RADIUS = MARGIN + 16f;
|
static readonly float TEXT_RADIUS = MARGIN + 16f;
|
||||||
|
|
||||||
public string Playername {
|
private bool mAlwaysTracking = true;
|
||||||
get { return mPlayername.Text; }
|
|
||||||
set { mPlayername.Text = value; }
|
|
||||||
}
|
|
||||||
public bool AlwaysTracking { get; set; }
|
|
||||||
|
|
||||||
Control mCtl2D;
|
Control mCtl2D;
|
||||||
Spatial mTextArchor;
|
Spatial mTextArchor, mModelArchor;
|
||||||
TextureRect mPlayerArrow;
|
TextureRect mPlayerArrow;
|
||||||
Label mPlayername;
|
Label mPlayername;
|
||||||
Camera mSpectatorCamera = null;
|
Camera mSpectatorCamera = null;
|
||||||
|
MeshInstance mMeshWood, mMeshStone, mMeshPaper;
|
||||||
|
ShadowBallType mOldState = ShadowBallType.Wood;
|
||||||
|
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
mCtl2D = GetNode<Control>("TextArchor/Ctl2D");
|
mCtl2D = GetNode<Control>("TextArchor/Ctl2D");
|
||||||
|
@ -26,8 +30,45 @@ public class PlayerBall : Spatial {
|
||||||
mPlayerArrow = GetNode<TextureRect>("TextArchor/Ctl2D/PlayerArrow");
|
mPlayerArrow = GetNode<TextureRect>("TextArchor/Ctl2D/PlayerArrow");
|
||||||
mPlayername = GetNode<Label>("TextArchor/Ctl2D/Playername");
|
mPlayername = GetNode<Label>("TextArchor/Ctl2D/Playername");
|
||||||
|
|
||||||
AlwaysTracking = true;
|
mModelArchor = GetNode<Spatial>("ModelArchor");
|
||||||
Playername = "";
|
mMeshWood = GetNode<MeshInstance>("ModelArchor/Ball_Wood");
|
||||||
|
mMeshStone = GetNode<MeshInstance>("ModelArchor/Ball_Stone");
|
||||||
|
mMeshPaper = GetNode<MeshInstance>("ModelArchor/Ball_Paper");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPlayerName(string new_name) {
|
||||||
|
mPlayername.Text = new_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetBallState(Vector3 pos, Quat quad, ShadowBallType btype) {
|
||||||
|
this.Translation = pos;
|
||||||
|
mModelArchor.Rotation = quad.GetEuler();
|
||||||
|
|
||||||
|
if (mOldState != btype) {
|
||||||
|
switch (mOldState) {
|
||||||
|
case ShadowBallType.Stone:
|
||||||
|
mMeshStone.Visible = false;
|
||||||
|
break;
|
||||||
|
case ShadowBallType.Wood:
|
||||||
|
mMeshWood.Visible = false;
|
||||||
|
break;
|
||||||
|
case ShadowBallType.Paper:
|
||||||
|
mMeshPaper.Visible = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (btype) {
|
||||||
|
case ShadowBallType.Stone:
|
||||||
|
mMeshStone.Visible = true;
|
||||||
|
break;
|
||||||
|
case ShadowBallType.Wood:
|
||||||
|
mMeshWood.Visible = true;
|
||||||
|
break;
|
||||||
|
case ShadowBallType.Paper:
|
||||||
|
mMeshPaper.Visible = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mOldState = btype;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(float delta) {
|
public override void _Process(float delta) {
|
||||||
|
@ -63,7 +104,7 @@ public class PlayerBall : Spatial {
|
||||||
//var distance = camera_translation.DistanceTo(parent_translation);
|
//var distance = camera_translation.DistanceTo(parent_translation);
|
||||||
//mCtl2D.Modulate.a = Godot.Mathf.Clamp(RangeLerp range_lerp(distance, 0, 2, 0, 1), 0, 1);
|
//mCtl2D.Modulate.a = Godot.Mathf.Clamp(RangeLerp range_lerp(distance, 0, 2, 0, 1), 0, 1);
|
||||||
|
|
||||||
if (!AlwaysTracking) {
|
if (!mAlwaysTracking) {
|
||||||
// For non-sticky waypoints, we don't need to clamp and calculate
|
// For non-sticky waypoints, we don't need to clamp and calculate
|
||||||
// the position if the waypoint goes off screen.
|
// the position if the waypoint goes off screen.
|
||||||
mCtl2D.RectPosition = unprojected_position;
|
mCtl2D.RectPosition = unprojected_position;
|
||||||
|
@ -182,11 +223,6 @@ public class PlayerBall : Spatial {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//private static float AngelDiff(float from, float to) {
|
|
||||||
// var diff = (to - from) % Mathf.Tau;
|
|
||||||
// return ((2.0f * diff) % Mathf.Tau) - diff;
|
|
||||||
//}
|
|
||||||
|
|
||||||
private static float RangeLerp(float value, float istart, float istop, float ostart, float ostop) {
|
private static float RangeLerp(float value, float istart, float istop, float ostart, float ostop) {
|
||||||
return ostart + (ostop - ostart) * (value - istart) / (istop - istart);
|
return ostart + (ostop - ostart) * (value - istart) / (istop - istart);
|
||||||
}
|
}
|
|
@ -2,70 +2,43 @@ using Godot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class ShadowBall {
|
|
||||||
public UInt32 mIdentifier;
|
|
||||||
public string mName;
|
|
||||||
public PlayerBall mGodotNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ShadowBallManager : Spatial {
|
public class ShadowBallManager : Spatial {
|
||||||
private Dictionary<UInt32, ShadowBall> mBallDict = new Dictionary<UInt32, ShadowBall>();
|
private Dictionary<Guid, ShadowBall> mBallDict = new Dictionary<Guid, ShadowBall>();
|
||||||
private PackedScene mTemplateShadowBall;
|
private PackedScene mTemplateShadowBall;
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
mTemplateShadowBall = ResourceLoader.Load<PackedScene>("res://scenes/stages/PlayerBall.tscn");
|
mTemplateShadowBall = ResourceLoader.Load<PackedScene>("res://scenes/stages/ShadowBall.tscn");
|
||||||
|
|
||||||
int len = 10;
|
}
|
||||||
Quat quad = Quat.Identity;
|
|
||||||
Vector3 vec = new Vector3(0, 0, 0);
|
public Guid AddBall() {
|
||||||
for (int x = 0; x < len; x++) {
|
var guid = Guid.NewGuid();
|
||||||
for (int y = 0; y < len; y++) {
|
var instance = mTemplateShadowBall.Instance<ShadowBall>();
|
||||||
AddBall((uint)(x * len + y), $"Swung0x{x * len + y}");
|
|
||||||
vec.x = x * 50;
|
AddChild(instance);
|
||||||
vec.z = y * 50;
|
mBallDict.Add(guid, instance);
|
||||||
SetBallState((uint)(x * len + y), vec, quad);
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetBallName(Guid ballid, string new_name) {
|
||||||
|
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
||||||
|
entity.SetPlayerName(new_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Called every frame. 'delta' is the elapsed time since the previous frame.
|
public void SetBallState(Guid ballid, Vector3 pos, Quat quad, ShadowBallType btype) {
|
||||||
// public override void _Process(float delta)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void AddBall(UInt32 ballid, string name) {
|
|
||||||
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
||||||
// update old entity for alternative
|
entity.SetBallState(pos, quad, btype);
|
||||||
entity.mName = name;
|
|
||||||
entity.mGodotNode.Playername = name;
|
|
||||||
} else {
|
|
||||||
entity = new ShadowBall() {
|
|
||||||
mIdentifier = ballid,
|
|
||||||
mName = name,
|
|
||||||
mGodotNode = mTemplateShadowBall.Instance<PlayerBall>()
|
|
||||||
};
|
|
||||||
mBallDict.Add(ballid, entity);
|
|
||||||
AddChild(entity.mGodotNode);
|
|
||||||
entity.mGodotNode.Playername = entity.mName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBallState(UInt32 ballid, Vector3 pos, Quat quad) {
|
public void RemoveBall(Guid ballid) {
|
||||||
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
||||||
entity.mGodotNode.Translation = pos;
|
RemoveChild(entity);
|
||||||
entity.mGodotNode.Rotation = quad.GetEuler();
|
entity.QueueFree();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveBall(UInt32 ballid) {
|
|
||||||
if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) {
|
|
||||||
RemoveChild(entity.mGodotNode);
|
|
||||||
entity.mGodotNode.QueueFree();
|
|
||||||
mBallDict.Remove(ballid);
|
mBallDict.Remove(ballid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,49 +1,85 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class StalkerCamera : Spatial
|
public class StalkerCamera : Spatial {
|
||||||
{
|
Spatial mFreeCamOrigin = null, mSpecCam = null, mStaticCameraOrigin = null, mStaticCameraTracking = null;
|
||||||
Spatial originFreeCam;
|
Camera mFreeCam;
|
||||||
Camera freeCam;
|
|
||||||
|
|
||||||
private static float BASIC_MOVEMENT = 0.2f;
|
private static float BASIC_MOVEMENT = 0.2f;
|
||||||
|
private static float STATIC_MOVEMENT = 10f;
|
||||||
|
|
||||||
|
bool mEnableCamera = false;
|
||||||
object lockMotionMouse = new object();
|
object lockMotionMouse = new object();
|
||||||
Vector2 motionMouse = new Vector2(0, 0);
|
Vector2 motionMouse = new Vector2(0, 0);
|
||||||
int movementScale = 1;
|
int movementScale = 1;
|
||||||
|
|
||||||
public override void _Ready() {
|
public override void _Ready() {
|
||||||
freeCam = GetNode<Camera>("FreeCam");
|
mFreeCam = GetNode<Camera>("FreeCam");
|
||||||
originFreeCam = GetNode<Spatial>("FreeCamOrigin");
|
mFreeCamOrigin = GetNode<Spatial>("FreeCamOrigin");
|
||||||
|
mStaticCameraOrigin = GetNode<Spatial>("StaticCamOrigin");
|
||||||
|
mStaticCameraTracking = GetNode<Spatial>("StaticCamOrigin/StaticCamTracking");
|
||||||
|
mSpecCam = null;
|
||||||
//Input.SetMouseMode(Input.MouseMode.Captured);
|
//Input.SetMouseMode(Input.MouseMode.Captured);
|
||||||
|
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_StalkerManager_EventControllerChanged(BallanceStalkerCore.EventControllerSource obj) {
|
||||||
|
mEnableCamera = obj == BallanceStalkerCore.EventControllerSource.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(float delta) {
|
public override void _Process(float delta) {
|
||||||
if (Input.GetMouseMode() != Input.MouseMode.Captured) return;
|
if (!mEnableCamera) return;
|
||||||
|
|
||||||
Vector3 motion3d = new Vector3(0, 0, 0);
|
if (mSpecCam is null) {
|
||||||
if (Input.IsActionPressed("ballance_forward")) motion3d.z -= 1f;
|
Vector3 motion3d = new Vector3(0, 0, 0);
|
||||||
if (Input.IsActionPressed("ballance_backward")) motion3d.z += 1f;
|
if (Input.IsActionPressed("ballance_forward")) motion3d.z -= 1f;
|
||||||
if (Input.IsActionPressed("ballance_left")) motion3d.x -= 1f;
|
if (Input.IsActionPressed("ballance_backward")) motion3d.z += 1f;
|
||||||
if (Input.IsActionPressed("ballance_right")) motion3d.x += 1f;
|
if (Input.IsActionPressed("ballance_left")) motion3d.x -= 1f;
|
||||||
if (Input.IsActionPressed("ballance_down")) motion3d.y -= 1f;
|
if (Input.IsActionPressed("ballance_right")) motion3d.x += 1f;
|
||||||
if (Input.IsActionPressed("ballance_up")) motion3d.y += 1f;
|
if (Input.IsActionPressed("ballance_down")) motion3d.y -= 1f;
|
||||||
freeCam.Translate(motion3d * (BASIC_MOVEMENT * movementScale));
|
if (Input.IsActionPressed("ballance_up")) motion3d.y += 1f;
|
||||||
|
|
||||||
Vector2 copiedMotion2d;
|
mFreeCam.Translate(motion3d * (BASIC_MOVEMENT * movementScale));
|
||||||
lock (lockMotionMouse) {
|
|
||||||
copiedMotion2d = motionMouse;
|
Vector2 copiedMotion2d;
|
||||||
motionMouse = new Vector2(0, 0);
|
lock (lockMotionMouse) {
|
||||||
|
copiedMotion2d = motionMouse;
|
||||||
|
motionMouse = new Vector2(0, 0);
|
||||||
|
}
|
||||||
|
var viewport_base_size = GetViewport().GetSizeOverride() > Vector2.Zero ? GetViewport().GetSizeOverride() : GetViewport().Size;
|
||||||
|
float window_x = viewport_base_size.x;
|
||||||
|
Vector3 camRot = mFreeCam.Rotation;
|
||||||
|
camRot.x = Mathf.Clamp(camRot.x - copiedMotion2d.y * 2 / window_x, -90f, 90f);
|
||||||
|
camRot.y = camRot.y - copiedMotion2d.x * 2 / window_x;
|
||||||
|
camRot.z = 0;
|
||||||
|
mFreeCam.Rotation = camRot;
|
||||||
|
} else {
|
||||||
|
mStaticCameraOrigin.Translation = mSpecCam.Translation;
|
||||||
|
mFreeCam.Transform = mFreeCam.Transform.InterpolateWith(mStaticCameraTracking.Transform, STATIC_MOVEMENT);
|
||||||
}
|
}
|
||||||
float window_x = GetViewport().GetVisibleRect().Size.x;
|
|
||||||
Vector3 camRot = freeCam.Rotation;
|
|
||||||
camRot.x = Mathf.Clamp(camRot.x - copiedMotion2d.y * 2 / window_x, -90f, 90f);
|
|
||||||
camRot.y = camRot.y - copiedMotion2d.x * 2 / window_x;
|
|
||||||
camRot.z = 0;
|
|
||||||
freeCam.Rotation = camRot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Input(InputEvent @event) {
|
public override void _Input(InputEvent @event) {
|
||||||
if (Input.GetMouseMode() != Input.MouseMode.Captured) return;
|
if (!mEnableCamera) return;
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("ballance_esc")) {
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.Menu);
|
||||||
|
// mark handled to prevent loop call
|
||||||
|
GetTree().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (@event.IsActionPressed("ballance_cmd")) {
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.Console);
|
||||||
|
// mark handled to prevent loop call
|
||||||
|
GetTree().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
if (@event.IsActionPressed("ballance_chat")) {
|
||||||
|
BallanceStalkerCore.StalkerManager.Singleton.SetEventController(BallanceStalkerCore.EventControllerSource.Chat);
|
||||||
|
// mark handled to prevent loop call
|
||||||
|
GetTree().SetInputAsHandled();
|
||||||
|
}
|
||||||
|
|
||||||
// mouse wheel
|
// mouse wheel
|
||||||
if (@event is InputEventMouseButton) {
|
if (@event is InputEventMouseButton) {
|
||||||
|
@ -67,4 +103,15 @@ public class StalkerCamera : Spatial
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetTrackingTarget(Spatial target) {
|
||||||
|
if (target is null) {
|
||||||
|
if (!(mSpecCam is null)) {
|
||||||
|
// shift off from a player archor, we need move free cam origin to target
|
||||||
|
mFreeCamOrigin.Translation = mSpecCam.Translation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set cam origin
|
||||||
|
mSpecCam = target;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,49 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BallanceStalkerCore {
|
namespace BallanceStalkerCore {
|
||||||
|
|
||||||
|
public enum EventControllerSource {
|
||||||
|
/// <summary>
|
||||||
|
/// Default statue. It mean that we are now in camera mode.
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
/// <summary>
|
||||||
|
/// Menu take control of event input
|
||||||
|
/// </summary>
|
||||||
|
Menu,
|
||||||
|
/// <summary>
|
||||||
|
/// Console panel now take control of event input.
|
||||||
|
/// </summary>
|
||||||
|
Console,
|
||||||
|
/// <summary>
|
||||||
|
/// it is same as console, the only different is preset character
|
||||||
|
/// </summary>
|
||||||
|
Chat
|
||||||
|
}
|
||||||
|
|
||||||
public class StalkerManager {
|
public class StalkerManager {
|
||||||
public static StalkerManager Singleton = new StalkerManager();
|
public static StalkerManager Singleton = new StalkerManager();
|
||||||
private StalkerManager() {
|
private StalkerManager() {
|
||||||
|
mEventController = EventControllerSource.None;
|
||||||
|
|
||||||
|
mLogger = new LogManager();
|
||||||
|
mBmmoClient = new BmmoClient(mLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event Action<EventControllerSource> EventControllerChanged;
|
||||||
|
private EventControllerSource mEventController;
|
||||||
public BmmoClient mBmmoClient;
|
public BmmoClient mBmmoClient;
|
||||||
public LogManager mLogger;
|
public LogManager mLogger;
|
||||||
|
|
||||||
|
public void SetEventController(EventControllerSource src) {
|
||||||
|
if (mEventController != src) {
|
||||||
|
mEventController = src;
|
||||||
|
}
|
||||||
|
EventControllerChanged?.Invoke(src);
|
||||||
|
}
|
||||||
|
public EventControllerSource GetEventController() {
|
||||||
|
return mEventController;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
38
scripts/user_interface/LabelConsole.cs
Normal file
38
scripts/user_interface/LabelConsole.cs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class LabelConsole : Control {
|
||||||
|
|
||||||
|
Label mRealLabel;
|
||||||
|
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready() {
|
||||||
|
mRealLabel = GetNode<Label>("RealLabel");
|
||||||
|
mRealLabel.Connect("item_rect_changed", this, nameof(Proc_Label_ItemRectChanged));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetText(string strl, LabelConsoleMessageType t) {
|
||||||
|
mRealLabel.Text = strl;
|
||||||
|
switch (t) {
|
||||||
|
case LabelConsoleMessageType.Normal:
|
||||||
|
mRealLabel.Modulate = Colors.White;
|
||||||
|
break;
|
||||||
|
case LabelConsoleMessageType.Highlight:
|
||||||
|
mRealLabel.Modulate = Colors.Yellow;
|
||||||
|
break;
|
||||||
|
case LabelConsoleMessageType.Error:
|
||||||
|
mRealLabel.Modulate = Colors.OrangeRed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Proc_Label_ItemRectChanged() {
|
||||||
|
this.RectMinSize = new Vector2(0, (mRealLabel.GetLineHeight() + mRealLabel.GetConstant("line_spacing")) * mRealLabel.GetLineCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
// // Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
// public override void _Process(float delta)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user