本文整理汇总了C#中OpenRA.Widgets.Widget.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.AddChild方法的具体用法?C# Widget.AddChild怎么用?C# Widget.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenRA.Widgets.Widget
的用法示例。
在下文中一共展示了Widget.AddChild方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadWidget
public Widget LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node)
{
var widget = NewWidget(node.Key, args);
if (parent != null)
parent.AddChild( widget );
if (node.Key.Contains("@"))
FieldLoader.LoadField(widget, "Id", node.Key.Split('@')[1]);
foreach (var child in node.Value.Nodes)
if (child.Key != "Children")
FieldLoader.LoadField(widget, child.Key, child.Value.Value);
if (!args.ContainsKey("modRules"))
args = new WidgetArgs(args) { { "modRules", modData.DefaultRules } };
widget.Initialize(args);
foreach (var child in node.Value.Nodes)
if (child.Key == "Children")
foreach (var c in child.Value.Nodes)
LoadWidget( args, widget, c);
widget.PostInit(args);
return widget;
}
示例2: LoadWidget
public Widget LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node)
{
if (!args.ContainsKey("modData"))
args = new WidgetArgs(args) { { "modData", modData } };
var widget = NewWidget(node.Key, args);
if (parent != null)
parent.AddChild(widget);
if (node.Key.Contains("@"))
FieldLoader.LoadField(widget, "Id", node.Key.Split('@')[1]);
foreach (var child in node.Value.Nodes)
if (child.Key != "Children")
FieldLoader.LoadField(widget, child.Key, child.Value.Value);
widget.Initialize(args);
foreach (var child in node.Value.Nodes)
if (child.Key == "Children")
foreach (var c in child.Value.Nodes)
LoadWidget(args, widget, c);
var logicNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "Logic");
var logic = logicNode == null ? null : logicNode.Value.ToDictionary();
args.Add("logicArgs", logic);
widget.PostInit(args);
args.Remove("logicArgs");
return widget;
}
示例3: LoadWidget
public Widget LoadWidget( Dictionary<string, object> args, Widget parent, MiniYamlNode node)
{
var widget = NewWidget(node.Key, args);
parent.AddChild( widget );
foreach (var child in node.Value.Nodes)
if (child.Key != "Children")
FieldLoader.LoadField(widget, child.Key, child.Value.Value);
widget.Initialize();
foreach (var child in node.Value.Nodes)
if (child.Key == "Children")
foreach (var c in child.Value.Nodes)
LoadWidget( args, widget, c);
widget.PostInit( args );
return widget;
}
示例4: LoadWidget
public Widget LoadWidget( WidgetArgs args, Widget parent, MiniYamlNode node)
{
var widget = NewWidget(node.Key, args);
if (parent != null)
parent.AddChild( widget );
foreach (var child in node.Value.Nodes)
if (child.Key != "Children")
FieldLoader.LoadField(widget, child.Key, child.Value.Value);
widget.Initialize(args);
foreach (var child in node.Value.Nodes)
if (child.Key == "Children")
foreach (var c in child.Value.Nodes)
LoadWidget( args, widget, c);
widget.PostInit( args );
return widget;
}
示例5: SimpleTooltipLogic
public SimpleTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Func<string> getText)
{
var label = widget.Get<LabelWidget>("LABEL");
var spacing = widget.Get("LINE_HEIGHT");
widget.RemoveChildren();
var font = Game.Renderer.Fonts[label.Font];
var horizontalPadding = label.Bounds.Width - widget.Bounds.Width;
if (horizontalPadding <= 0)
horizontalPadding = 2 * label.Bounds.X;
var cachedText = "";
tooltipContainer.BeforeRender = () =>
{
var text = getText();
if (text == cachedText)
return;
var lines = text.Split('\n');
var textWidth = font.Measure(text).X;
// Set up label widgets
widget.RemoveChildren();
var bottom = 0;
for (var i = 0; i < lines.Length; i++)
{
var line = (LabelWidget)label.Clone();
var lineText = lines[i];
line.Bounds.Y += spacing.Bounds.Y + i * spacing.Bounds.Height;
line.Bounds.Width = textWidth;
line.GetText = () => lineText;
widget.AddChild(line);
bottom = line.Bounds.Y + line.Bounds.Height;
}
widget.Bounds.Width = horizontalPadding + textWidth;
widget.Bounds.Height = bottom + spacing.Bounds.Y;
cachedText = text;
};
}
示例6: LayoutDialog
// This is shit
void LayoutDialog(Widget bg)
{
foreach (var c in controls)
bg.RemoveChild(c);
controls.Clear();
var y = 50;
var margin = 20;
var labelWidth = (bg.Bounds.Width - 3 * margin) / 3;
var ts = new LabelWidget
{
Font = "Bold",
Bounds = new Rectangle(margin + labelWidth + 10, y, labelWidth, 25),
Text = "Their Stance",
Align = TextAlign.Left,
};
bg.AddChild(ts);
controls.Add(ts);
var ms = new LabelWidget
{
Font = "Bold",
Bounds = new Rectangle(margin + 2 * labelWidth + 20, y, labelWidth, 25),
Text = "My Stance",
Align = TextAlign.Left,
};
bg.AddChild(ms);
controls.Add(ms);
y += 35;
foreach (var p in world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant))
{
var pp = p;
var label = new LabelWidget
{
Bounds = new Rectangle(margin, y, labelWidth, 25),
Text = p.PlayerName,
Align = TextAlign.Left,
Font = "Bold",
Color = p.Color.RGB,
};
bg.AddChild(label);
controls.Add(label);
var theirStance = new LabelWidget
{
Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
Text = p.PlayerName,
Align = TextAlign.Left,
GetText = () => pp.Stances[ world.LocalPlayer ].ToString(),
};
bg.AddChild(theirStance);
controls.Add(theirStance);
var myStance = new DropDownButtonWidget
{
Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25),
GetText = () => world.LocalPlayer.Stances[ pp ].ToString(),
};
if (!p.World.LobbyInfo.GlobalSettings.FragileAlliances)
myStance.Disabled = true;
myStance.OnMouseDown = mi => ShowDropDown(pp, myStance);
bg.AddChild(myStance);
controls.Add(myStance);
y += 35;
}
}
示例7: BindHotkeyPref
static void BindHotkeyPref(KeyValuePair<string, string> kv, KeySettings ks, Widget template, Widget parent)
{
var key = template.Clone() as Widget;
key.Id = kv.Key;
key.IsVisible = () => true;
var field = ks.GetType().GetField(kv.Key);
if (field == null)
throw new InvalidOperationException("Game.Settings.Keys does not contain {1}".F(kv.Key));
key.Get<LabelWidget>("FUNCTION").GetText = () => kv.Value + ":";
var textBox = key.Get<HotkeyEntryWidget>("HOTKEY");
textBox.Key = (Hotkey)field.GetValue(ks);
textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key);
parent.AddChild(key);
}
示例8: BuildMusicTable
void BuildMusicTable(Widget list)
{
music = Rules.Music.Where(a => a.Value.Exists).Select(a => a.Value).ToArray();
random = music.Shuffle(Game.CosmeticRandom).ToArray();
list.RemoveChildren();
foreach (var s in music)
{
var song = s;
if (currentSong == null)
currentSong = song;
var item = ScrollItemWidget.Setup(itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); });
item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
list.AddChild(item);
}
}