Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CancellableBusyDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2using Engine;
3
4namespace Game {
7
9
11
13
14 public bool m_autoHideOnCancel;
15
16 public CancellableProgress Progress { get; set; }
17
18 public string LargeMessage {
19 get => m_largeLabelWidget.Text;
20 set {
21 m_largeLabelWidget.Text = value ?? string.Empty;
22 m_largeLabelWidget.IsVisible = !string.IsNullOrEmpty(value);
23 }
24 }
25
26 public string SmallMessage {
27 get => m_smallLabelWidget.Text;
28 set => m_smallLabelWidget.Text = value ?? string.Empty;
29 }
30
32 get => m_cancelButtonWidget.IsEnabled;
33 set => m_cancelButtonWidget.IsEnabled = value;
34 }
35
36 public bool ShowProgressMessage { get; set; }
37
38 public CancellableBusyDialog(string largeMessage, bool autoHideOnCancel) {
39 XElement node = ContentManager.Get<XElement>("Dialogs/CancellableBusyDialog");
40 LoadContents(this, node);
41 m_largeLabelWidget = Children.Find<LabelWidget>("CancellableBusyDialog.LargeLabel");
42 m_smallLabelWidget = Children.Find<LabelWidget>("CancellableBusyDialog.SmallLabel");
43 m_cancelButtonWidget = Children.Find<ButtonWidget>("CancellableBusyDialog.CancelButton");
44 m_hideButtonWidget = Children.Find<ButtonWidget>("CancellableBusyDialog.HideButton");
45 m_hideButtonWidget.IsVisible = false;
47 m_autoHideOnCancel = autoHideOnCancel;
48 LargeMessage = largeMessage;
50 }
51
52 public CancellableBusyDialog(string largeMessage, string hideButtonName, bool autoHideOnCancel) {
53 XElement node = ContentManager.Get<XElement>("Dialogs/CancellableBusyDialog");
54 LoadContents(this, node);
55 m_largeLabelWidget = Children.Find<LabelWidget>("CancellableBusyDialog.LargeLabel");
56 m_smallLabelWidget = Children.Find<LabelWidget>("CancellableBusyDialog.SmallLabel");
57 m_cancelButtonWidget = Children.Find<ButtonWidget>("CancellableBusyDialog.CancelButton");
58 m_hideButtonWidget = Children.Find<ButtonWidget>("CancellableBusyDialog.HideButton");
59 m_hideButtonWidget.IsVisible = true;
60 m_hideButtonWidget.Text = hideButtonName;
61 m_cancelButtonWidget.Size = new Vector2(160, 60);
62 m_hideButtonWidget.Size = new Vector2(160, 60);
64 m_autoHideOnCancel = autoHideOnCancel;
65 LargeMessage = largeMessage;
67 }
68
69 public override void Update() {
71 SmallMessage = Progress.Completed > 0f && Progress.Total > 0f ? $"{Progress.Completed / Progress.Total * 100f:0}%" : string.Empty;
72 }
73 if (m_cancelButtonWidget.IsClicked) {
74 Progress.Cancel();
77 }
78 }
79 if (m_hideButtonWidget.IsClicked) {
81 }
82 if (Input.Cancel) {
83 Input.Clear();
84 }
85 }
86 }
87}
CancellableBusyDialog(string largeMessage, string hideButtonName, bool autoHideOnCancel)
CancellableBusyDialog(string largeMessage, bool autoHideOnCancel)
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
virtual void LoadContents(object eventsTarget, XElement node)