fix scrollcontainer keep bottom feature
This commit is contained in:
parent
2040afa34a
commit
449b95e036
|
@ -11,6 +11,7 @@ public enum LabelConsoleMessageType {
|
||||||
public class ConsolePanel : Control {
|
public class ConsolePanel : Control {
|
||||||
private LineEdit mCmdInput;
|
private LineEdit mCmdInput;
|
||||||
private ScrollContainer mScrollbar;
|
private ScrollContainer mScrollbar;
|
||||||
|
private VScrollBar mScrollbarVChild;
|
||||||
private VBoxContainer mMessageContainer;
|
private VBoxContainer mMessageContainer;
|
||||||
private PackedScene mTemplateLabelConsole;
|
private PackedScene mTemplateLabelConsole;
|
||||||
private Queue<LabelConsole> mMessageQueue = new Queue<LabelConsole>();
|
private Queue<LabelConsole> mMessageQueue = new Queue<LabelConsole>();
|
||||||
|
@ -21,8 +22,10 @@ public class ConsolePanel : Control {
|
||||||
|
|
||||||
mCmdInput = GetNode<LineEdit>("CommandInput");
|
mCmdInput = GetNode<LineEdit>("CommandInput");
|
||||||
mScrollbar = GetNode<ScrollContainer>("ScrollSet/Scrollbar");
|
mScrollbar = GetNode<ScrollContainer>("ScrollSet/Scrollbar");
|
||||||
|
mScrollbarVChild = mScrollbar.GetVScrollbar();
|
||||||
mMessageContainer = GetNode<VBoxContainer>("ScrollSet/Scrollbar/MessageContainer");
|
mMessageContainer = GetNode<VBoxContainer>("ScrollSet/Scrollbar/MessageContainer");
|
||||||
mCmdInput.Connect("text_entered", this, nameof(Proc_LineEdit_TextEntered));
|
mCmdInput.Connect("text_entered", this, nameof(Proc_LineEdit_TextEntered));
|
||||||
|
mScrollbarVChild.Connect("changed", this, nameof(Proc_ScrollbarVChild_Changed));
|
||||||
|
|
||||||
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
BallanceStalkerCore.StalkerManager.Singleton.EventControllerChanged += Proc_StalkerManager_EventControllerChanged;
|
||||||
}
|
}
|
||||||
|
@ -73,10 +76,6 @@ public class ConsolePanel : Control {
|
||||||
// set text
|
// set text
|
||||||
target.SetText(strl, t);
|
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) {
|
private void Proc_LineEdit_TextEntered(string new_strl) {
|
||||||
|
@ -95,4 +94,8 @@ public class ConsolePanel : Control {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Proc_ScrollbarVChild_Changed() {
|
||||||
|
mScrollbar.ScrollVertical = (int)mScrollbarVChild.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class LabelConsole : Control {
|
||||||
mRealLabel.Modulate = Colors.OrangeRed;
|
mRealLabel.Modulate = Colors.OrangeRed;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.RectMinSize = new Vector2(0, (mRealLabel.GetLineHeight() + mRealLabel.GetConstant("line_spacing")) * mRealLabel.GetLineCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Proc_Label_ItemRectChanged() {
|
private void Proc_Label_ItemRectChanged() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user