add console panel, still have scroll problem

This commit is contained in:
2022-07-21 00:23:20 +08:00
parent 7cdcaf1e2f
commit 2040afa34a
22 changed files with 558 additions and 119 deletions

View 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)
// {
//
// }
}