-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathEditorControl.cs
126 lines (107 loc) · 3.68 KB
/
EditorControl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TextAdventures.Quest
{
internal class EditorControl : IEditorControl
{
private WorldModel m_worldModel;
private string m_controlType;
private string m_caption;
private int? m_height = null;
private int? m_width = null;
private string m_attribute;
private bool m_expand = false;
private Element m_source;
private EditorVisibilityHelper m_visibilityHelper;
private EditorDefinition m_parent;
private string m_id;
public EditorControl(EditorDefinition parent, WorldModel worldModel, Element source)
{
m_parent = parent;
m_worldModel = worldModel;
m_source = source;
m_controlType = source.Fields.GetString("controltype");
m_caption = source.Fields.GetString("caption");
m_attribute = source.Fields.GetString("attribute");
if (source.Fields.HasType<int>("height")) m_height = source.Fields.GetAsType<int>("height");
if (source.Fields.HasType<int>("width")) m_width = source.Fields.GetAsType<int>("width");
if (source.Fields.HasType<bool>("expand")) m_expand = source.Fields.GetAsType<bool>("expand");
m_visibilityHelper = new EditorVisibilityHelper(parent, worldModel, source);
IsControlVisibleInSimpleMode = !source.Fields.GetAsType<bool>("advanced");
m_id = source.Name;
if (source.Fields.HasString("filtergroup"))
{
parent.RegisterFilter(source.Fields.GetString("filtergroup"), source.Fields.GetString("filter"), m_attribute);
}
}
public string ControlType
{
get { return m_controlType; }
}
public string Caption
{
get { return m_caption; }
}
public int? Height
{
get { return m_height; }
}
public int? Width
{
get { return m_width; }
}
public string Attribute
{
get { return m_attribute; }
}
public bool Expand
{
get { return m_expand; }
}
public string GetString(string tag)
{
return m_source.Fields.GetString(tag);
}
public IEnumerable<string> GetListString(string tag)
{
return m_source.Fields.GetAsType<QuestList<string>>(tag);
}
public IDictionary<string, string> GetDictionary(string tag)
{
return m_source.Fields.GetAsType<QuestDictionary<string>>(tag);
}
public bool GetBool(string tag)
{
return m_source.Fields.GetAsType<bool>(tag);
}
public int? GetInt(string tag)
{
if (!m_source.Fields.HasType<int>(tag)) return null;
return m_source.Fields.GetAsType<int>(tag);
}
public double? GetDouble(string tag)
{
if (!m_source.Fields.HasType<double>(tag)) return null;
return m_source.Fields.GetAsType<double>(tag);
}
public bool IsControlVisible(IEditorData data)
{
return m_visibilityHelper.IsVisible(data);
}
public IEditorDefinition Parent
{
get { return m_parent; }
}
public bool IsControlVisibleInSimpleMode
{
get;
private set;
}
public string Id
{
get { return m_id; }
}
}
}