Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
EditPistonDialog.cs
浏览该文件的文档.
1using System.Xml.Linq;
2
3namespace Game {
4 public class EditPistonDialog : Dialog {
12
13 public Action<int> m_handler;
14 public int m_data;
16 public int m_maxExtension;
17 public int m_pullCount;
18 public int m_speed;
19 public const string fName = "EditPistonDialog";
20
21 public EditPistonDialog(int data, Action<int> handler) {
22 XElement node = ContentManager.Get<XElement>("Dialogs/EditPistonDialog");
23 LoadContents(this, node);
24 m_title = Children.Find<LabelWidget>("EditPistonDialog.Title");
25 m_slider1 = Children.Find<SliderWidget>("EditPistonDialog.Slider1");
26 m_panel2 = Children.Find<ContainerWidget>("EditPistonDialog.Panel2");
27 m_slider2 = Children.Find<SliderWidget>("EditPistonDialog.Slider2");
28 m_slider3 = Children.Find<SliderWidget>("EditPistonDialog.Slider3");
29 m_okButton = Children.Find<ButtonWidget>("EditPistonDialog.OK");
30 m_cancelButton = Children.Find<ButtonWidget>("EditPistonDialog.Cancel");
31 m_handler = handler;
32 m_data = data;
37 m_title.Text = BlocksManager.Blocks[237].GetDisplayName(null, Terrain.MakeBlockValue(237, 0, data));
38 m_slider1.Granularity = 1f;
39 m_slider1.MinValue = 1f;
40 m_slider1.MaxValue = 8f;
41 m_slider2.Granularity = 1f;
42 m_slider2.MinValue = 1f;
43 m_slider2.MaxValue = 8f;
44 m_slider3.Granularity = 1f;
45 m_slider3.MinValue = 0f;
46 m_slider3.MaxValue = 3f;
47 m_panel2.IsVisible = m_mode != PistonMode.Pushing;
49 }
50
51 public override void Update() {
52 if (m_slider1.IsSliding) {
53 m_maxExtension = (int)m_slider1.Value - 1;
54 }
55 if (m_slider2.IsSliding) {
56 m_pullCount = (int)m_slider2.Value - 1;
57 }
58 if (m_slider3.IsSliding) {
59 m_speed = (int)m_slider3.Value;
60 }
61 if (m_okButton.IsClicked) {
63 Dismiss(value);
64 }
65 if (Input.Cancel
66 || m_cancelButton.IsClicked) {
67 Dismiss(null);
68 }
70 }
71
72 public virtual void UpdateControls() {
73 m_slider1.Value = m_maxExtension + 1;
74 m_slider1.Text = string.Format(LanguageControl.Get(fName, 1), m_maxExtension + 1);
75 m_slider2.Value = m_pullCount + 1;
76 m_slider2.Text = string.Format(LanguageControl.Get(fName, 1), m_pullCount + 1);
77 m_slider3.Value = m_speed;
78 m_slider3.Text = LanguageControl.Get(fName, "Speed", m_speed.ToString());
79 }
80
81 public void Dismiss(int? result) {
83 if (m_handler != null
84 && result.HasValue) {
85 m_handler(result.Value);
86 }
87 }
88 }
89}
virtual string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
readonly WidgetsList Children
static object Get(Type type, string name)
static void HideDialog(Dialog dialog)
EditPistonDialog(int data, Action< int > handler)
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static int SetPullCount(int data, int pullCount)
static PistonMode GetMode(int data)
static int GetPullCount(int data)
static int SetMaxExtension(int data, int maxExtension)
static int GetMaxExtension(int data)
static int SetSpeed(int data, int speed)
static int GetSpeed(int data)
static int MakeBlockValue(int contents)
virtual void LoadContents(object eventsTarget, XElement node)