本文整理汇总了C#中Widget.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.AddChild方法的具体用法?C# Widget.AddChild怎么用?C# Widget.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget.AddChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LayoutDialog
void LayoutDialog(Widget bg)
{
bg.Children.RemoveAll(w => controls.Contains(w));
controls.Clear();
var y = 50;
var margin = 20;
var labelWidth = (bg.Bounds.Width - 3 * margin) / 3;
var ts = new LabelWidget
{
Bold = true,
Bounds = new Rectangle(margin + labelWidth + 10, y, labelWidth, 25),
Text = "Their Stance",
Align = LabelWidget.TextAlign.Left,
};
bg.AddChild(ts);
controls.Add(ts);
var ms = new LabelWidget
{
Bold = true,
Bounds = new Rectangle(margin + 2 * labelWidth + 20, y, labelWidth, 25),
Text = "My Stance",
Align = LabelWidget.TextAlign.Left,
};
bg.AddChild(ms);
controls.Add(ms);
y += 35;
foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
{
var pp = p;
var label = new LabelWidget
{
Bounds = new Rectangle(margin, y, labelWidth, 25),
Id = "DIPLOMACY_PLAYER_LABEL_{0}".F(p.Index),
Text = p.PlayerName,
Align = LabelWidget.TextAlign.Left,
Bold = true,
};
bg.AddChild(label);
controls.Add(label);
var theirStance = new LabelWidget
{
Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
Id = "DIPLOMACY_PLAYER_LABEL_THEIR_{0}".F(p.Index),
Text = p.PlayerName,
Align = LabelWidget.TextAlign.Left,
Bold = false,
GetText = () => pp.Stances[ world.LocalPlayer ].ToString(),
};
bg.AddChild(theirStance);
controls.Add(theirStance);
var myStance = new ButtonWidget
{
Bounds = new Rectangle( margin + 2 * labelWidth + 20, y, labelWidth, 25),
Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index),
Text = world.LocalPlayer.Stances[ pp ].ToString(),
};
myStance.OnMouseUp = mi => { CycleStance(pp, myStance); return true; };
bg.AddChild(myStance);
controls.Add(myStance);
y += 35;
}
}