Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditVoltageLevelDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2
3namespace Game {
5 public Action<int> m_handler;
6
8
10
12
13 public int m_voltageLevel;
14
15 public EditVoltageLevelDialog(int voltageLevel, Action<int> handler) {
16 XElement node = ContentManager.Get<XElement>("Dialogs/EditVoltageLevelDialog");
17 LoadContents(this, node);
18 m_okButton = Children.Find<ButtonWidget>("EditVoltageLevelDialog.OK");
19 m_cancelButton = Children.Find<ButtonWidget>("EditVoltageLevelDialog.Cancel");
20 m_voltageSlider = Children.Find<SliderWidget>("EditVoltageLevelDialog.VoltageSlider");
21 m_handler = handler;
22 m_voltageLevel = voltageLevel;
24 }
25
26 public override void Update() {
27 if (m_voltageSlider.IsSliding) {
29 }
30 if (m_okButton.IsClicked) {
32 }
33 if (Input.Cancel
34 || m_cancelButton.IsClicked) {
35 Dismiss(null);
36 }
38 }
39
40 public virtual void UpdateControls() {
41 m_voltageSlider.Text =
42 $"{1.5f * m_voltageLevel / 15f:0.0}V ({(m_voltageLevel < 8 ? LanguageControl.Get("EditBatteryDialog", 1) : LanguageControl.Get("EditBatteryDialog", 2))})";
43 m_voltageSlider.Value = m_voltageLevel;
44 }
45
46 public void Dismiss(int? result) {
48 if (m_handler != null
49 && result.HasValue) {
50 m_handler(result.Value);
51 }
52 }
53 }
54}
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
EditVoltageLevelDialog(int voltageLevel, Action< int > handler)
virtual void LoadContents(object eventsTarget, XElement node)