本文整理匯總了C#中OpenRA.Widgets.Widget.GetWidget方法的典型用法代碼示例。如果您正苦於以下問題:C# Widget.GetWidget方法的具體用法?C# Widget.GetWidget怎麽用?C# Widget.GetWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenRA.Widgets.Widget
的用法示例。
在下文中一共展示了Widget.GetWidget方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ReplayBrowserLogic
public ReplayBrowserLogic(Widget widget, Action onExit, Action onStart)
{
panel = widget;
panel.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
var rl = panel.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
var template = panel.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
rl.RemoveChildren();
if (Directory.Exists(replayDir))
{
var files = Directory.GetFiles(replayDir, "*.rep").Reverse();
foreach (var replayFile in files)
AddReplay(rl, replayFile, template);
SelectReplay(files.FirstOrDefault());
}
var watch = panel.GetWidget<ButtonWidget>("WATCH_BUTTON");
watch.IsDisabled = () => currentReplay == null || currentMap == null || currentReplay.Duration == 0;
watch.OnClick = () =>
{
if (currentReplay != null)
{
Game.JoinReplay(currentReplay.Filename);
Ui.CloseWindow();
onStart();
}
};
panel.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
}
示例2: ReplayBrowserDelegate
public ReplayBrowserDelegate( [ObjectCreator.Param] Widget widget )
{
this.widget = widget;
widget.GetWidget("CANCEL_BUTTON").OnMouseUp = mi =>
{
Widget.CloseWindow();
return true;
};
/* find some replays? */
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var replayDir = Path.Combine(Game.SupportDir, "Replays");
var template = widget.GetWidget<LabelWidget>("REPLAY_TEMPLATE");
CurrentReplay = null;
rl.RemoveChildren();
foreach (var replayFile in Directory.GetFiles(replayDir, "*.rep").Reverse())
AddReplay(rl, replayFile, template);
widget.GetWidget("WATCH_BUTTON").OnMouseUp = mi =>
{
if (currentReplay != null)
{
Widget.CloseWindow();
Game.JoinReplay(CurrentReplay);
}
return true;
};
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
}
示例3: ReplayBrowserLogic
public ReplayBrowserLogic( [ObjectCreator.Param] Widget widget )
{
this.widget = widget;
widget.GetWidget<ButtonWidget>("CANCEL_BUTTON").OnClick = () => Widget.CloseWindow();
/* find some replays? */
var rl = widget.GetWidget<ScrollPanelWidget>("REPLAY_LIST");
var replayDir = Path.Combine(Platform.SupportDir, "Replays");
var template = widget.GetWidget<ScrollItemWidget>("REPLAY_TEMPLATE");
CurrentReplay = null;
rl.RemoveChildren();
if (Directory.Exists(replayDir))
foreach (var replayFile in Directory.GetFiles(replayDir, "*.rep").Reverse())
AddReplay(rl, replayFile, template);
widget.GetWidget<ButtonWidget>("WATCH_BUTTON").OnClick = () =>
{
if (currentReplay != null)
{
Widget.CloseWindow();
Game.JoinReplay(CurrentReplay);
}
};
widget.GetWidget("REPLAY_INFO").IsVisible = () => currentReplay != null;
}
示例4: ProductionTooltipLogic
public ProductionTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, ProductionPaletteWidget palette)
{
var pm = palette.world.LocalPlayer.PlayerActor.Trait<PowerManager>();
var pr = palette.world.LocalPlayer.PlayerActor.Trait<PlayerResources>();
widget.IsVisible = () => palette.TooltipActor != null;
var nameLabel = widget.GetWidget<LabelWidget>("NAME");
var requiresLabel = widget.GetWidget<LabelWidget>("REQUIRES");
var powerLabel = widget.GetWidget<LabelWidget>("POWER");
var timeLabel = widget.GetWidget<LabelWidget>("TIME");
var costLabel = widget.GetWidget<LabelWidget>("COST");
var font = Game.Renderer.Fonts[nameLabel.Font];
var requiresFont = Game.Renderer.Fonts[requiresLabel.Font];
string lastActor = null;
tooltipContainer.BeforeRender = () =>
{
var actor = palette.TooltipActor;
if (actor == null || actor == lastActor)
return;
var info = Rules.Info[actor];
var tooltip = info.Traits.Get<TooltipInfo>();
var buildable = info.Traits.Get<BuildableInfo>();
var cost = info.Traits.Get<ValuedInfo>().Cost;
var bi = info.Traits.GetOrDefault<BuildingInfo>();
nameLabel.GetText = () => tooltip.Name;
var prereqs = buildable.Prerequisites.Select(a => ActorName(a));
var requiresString = prereqs.Any() ? "Requires {0}".F(prereqs.JoinWith(", ")) : "";
requiresLabel.GetText = () => requiresString;
var power = bi != null ? bi.Power : 0;
var powerString = "P: {0}".F(power);
powerLabel.GetText = () => powerString;
powerLabel.GetColor = () => ((pm.PowerProvided - pm.PowerDrained) >= -power || power > 0)
? Color.White : Color.Red;
powerLabel.IsVisible = () => power != 0;
var timeString = "T: {0}".F(WidgetUtils.FormatTime(palette.CurrentQueue.GetBuildTime(actor)));
timeLabel.GetText = () => timeString;
var costString = "$: {0}".F(cost);
costLabel.GetText = () => costString;
costLabel.GetColor = () => pr.DisplayCash + pr.DisplayOre >= cost
? Color.White : Color.Red;
var leftWidth = Math.Max(font.Measure(tooltip.Name).X, requiresFont.Measure(requiresString).X);
var rightWidth = new [] {font.Measure(powerString).X, font.Measure(timeString).X, font.Measure(costString).X}.Aggregate(Math.Max);
timeLabel.Bounds.X = powerLabel.Bounds.X = costLabel.Bounds.X = leftWidth + 2*nameLabel.Bounds.X;
widget.Bounds.Width = leftWidth + rightWidth + 3*nameLabel.Bounds.X;
widget.Bounds.Height = power != 0 ? 65 : 45;
lastActor = actor;
};
}
示例5: WorldTooltipLogic
public WorldTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, CncWorldInteractionControllerWidget wic)
{
widget.IsVisible = () => wic.TooltipType != WorldTooltipType.None;
var label = widget.GetWidget<LabelWidget>("LABEL");
var flag = widget.GetWidget<ImageWidget>("FLAG");
var owner = widget.GetWidget<LabelWidget>("OWNER");
var font = Game.Renderer.Fonts[label.Font];
var ownerFont = Game.Renderer.Fonts[owner.Font];
var cachedWidth = 0;
var labelText = "";
var showOwner = false;
var flagRace = "";
var ownerName = "";
var ownerColor = Color.White;
var doubleHeight = 45;
var singleHeight = 25;
tooltipContainer.BeforeRender = () =>
{
if (wic == null || wic.TooltipType == WorldTooltipType.None)
return;
labelText = wic.TooltipType == WorldTooltipType.Unexplored ? "Unexplored Terrain" :
wic.ActorTooltip.Name();
var textWidth = font.Measure(labelText).X;
if (textWidth != cachedWidth)
{
label.Bounds.Width = textWidth;
widget.Bounds.Width = 2*label.Bounds.X + textWidth;
}
var o = wic.ActorTooltip != null ? wic.ActorTooltip.Owner() : null;
showOwner = wic.TooltipType == WorldTooltipType.Actor && o != null && !o.NonCombatant;
if (showOwner)
{
flagRace = o.Country.Race;
ownerName = o.PlayerName;
ownerColor = o.ColorRamp.GetColor(0);
widget.Bounds.Height = doubleHeight;
widget.Bounds.Width = Math.Max(widget.Bounds.Width,
owner.Bounds.X + ownerFont.Measure(ownerName).X + 5);
}
else
widget.Bounds.Height = singleHeight;
};
label.GetText = () => labelText;
flag.IsVisible = () => showOwner;
flag.GetImageCollection = () => "flags";
flag.GetImageName = () => flagRace;
owner.IsVisible = () => showOwner;
owner.GetText = () => ownerName;
owner.GetColor = () => ownerColor;
}
示例6: DownloadPackagesLogic
public DownloadPackagesLogic(Widget widget, Dictionary<string,string> installData, Action afterInstall)
{
this.installData = installData;
this.afterInstall = afterInstall;
panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.GetWidget<ProgressBarWidget>("PROGRESS_BAR");
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
ShowDownloadDialog();
}
示例7: CncDownloadPackagesLogic
public CncDownloadPackagesLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
{
this.installData = installData;
this.continueLoading = continueLoading;
panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.GetWidget<ProgressBarWidget>("PROGRESS_BAR");
statusLabel = panel.GetWidget<LabelWidget>("STATUS_LABEL");
ShowDownloadDialog();
}
示例8: MainMenuButtonsLogic
public MainMenuButtonsLogic(Widget widget)
{
rootMenu = widget;
Game.modData.WidgetLoader.LoadWidget( new WidgetArgs(), Ui.Root, "PERF_BG" );
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_JOIN").OnClick = () => OpenGamePanel("JOINSERVER_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_CREATE").OnClick = () => OpenGamePanel("CREATESERVER_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_DIRECTCONNECT").OnClick = () => OpenGamePanel("DIRECTCONNECT_BG");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_MODS").OnClick = () =>
Ui.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => {} },
{ "onSwitch", RemoveShellmapUI }
});
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_REPLAY_VIEWER").OnClick = () =>
Ui.OpenWindow("REPLAYBROWSER_BG", new WidgetArgs()
{
{ "onExit", () => {} },
{ "onStart", RemoveShellmapUI }
});
widget.GetWidget<ButtonWidget>("MAINMENU_BUTTON_QUIT").OnClick = () => Game.Exit();
}
示例9: IngameChromeLogic
public IngameChromeLogic(World world)
{
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Ui.Root;
gameRoot = r.GetWidget("INGAME_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnClick = () =>
optionsBG.Visible = !optionsBG.Visible;
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () => LeaveGame(optionsBG);
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Ui.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Ui.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnClick = () =>
{
optionsBG.Visible = false;
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
};
optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined);
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
var postGameObserve = postgameBG.GetWidget<ButtonWidget>("POSTGAME_OBSERVE");
var postgameQuit = postgameBG.GetWidget<ButtonWidget>("POSTGAME_QUIT");
postgameQuit.OnClick = () => LeaveGame(postgameQuit);
postGameObserve.OnClick = () => postgameQuit.Visible = false;
postGameObserve.IsVisible = () => world.LocalPlayer.WinState != WinState.Won;
postgameBG.IsVisible = () =>
{
return postgameQuit.Visible && world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
};
postgameText.GetText = () =>
{
var state = world.LocalPlayer.WinState;
return state == WinState.Undefined ? "" :
(state == WinState.Lost ? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
};
}
示例10: CncInstallLogic
public CncInstallLogic(Widget widget, Dictionary<string,string> installData, Action continueLoading)
{
var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs()
{
{ "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } },
{ "installData", installData }
};
panel.GetWidget<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_DOWNLOAD_PANEL", args);
panel.GetWidget<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
Widget.OpenWindow("INSTALL_FROMCD_PANEL", new WidgetArgs(args)
{
{ "filesToCopy", new[] { "CONQUER.MIX", "DESERT.MIX", "SCORES.MIX",
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX" } },
{ "filesToExtract", new[] { "speech.mix", "tempicnh.mix", "transit.mix" } },
});
panel.GetWidget<ButtonWidget>("QUIT_BUTTON").OnClick = Game.Exit;
panel.GetWidget<ButtonWidget>("MODS_BUTTON").OnClick = () =>
{
Widget.OpenWindow("MODS_PANEL", new WidgetArgs()
{
{ "onExit", () => {} },
// Close this panel
{ "onSwitch", Widget.CloseWindow },
});
};
}
示例11: IngameObserverChromeLogic
public IngameObserverChromeLogic([ObjectCreator.Param] World world)
{
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Widget.RootWidget;
gameRoot = r.GetWidget("OBSERVER_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnClick = () =>
optionsBG.Visible = !optionsBG.Visible;
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () =>
{
optionsBG.Visible = false;
Game.Disconnect();
Game.LoadShellMap();
Widget.CloseWindow();
Widget.OpenWindow("MAINMENU_BG");
};
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").IsVisible = () => false;
}
示例12: ButtonTooltipLogic
public ButtonTooltipLogic(Widget widget, ToggleButtonWidget button)
{
var label = widget.GetWidget<LabelWidget>("LABEL");
var hotkey = widget.GetWidget<LabelWidget>("HOTKEY");
label.GetText = () => button.TooltipText;
var labelWidth = Game.Renderer.Fonts[label.Font].Measure(button.TooltipText).X;
label.Bounds.Width = labelWidth;
var hotkeyLabel = "({0})".F(button.Key.ToUpperInvariant());
hotkey.GetText = () => hotkeyLabel;
hotkey.Bounds.X = labelWidth + 2*label.Bounds.X;
var panelWidth = hotkey.Bounds.X + label.Bounds.X
+ Game.Renderer.Fonts[label.Font].Measure(hotkeyLabel).X;
widget.Bounds.Width = panelWidth;
}
示例13: ConnectionFailedLogic
public ConnectionFailedLogic(Widget widget, string host, int port, Action onRetry, Action onAbort)
{
var panel = widget;
panel.GetWidget<ButtonWidget>("ABORT_BUTTON").OnClick = () => { Widget.CloseWindow(); onAbort(); };
panel.GetWidget<ButtonWidget>("RETRY_BUTTON").OnClick = () => { Widget.CloseWindow(); onRetry(); };
widget.GetWidget<LabelWidget>("CONNECTING_DESC").GetText = () =>
"Could not connect to {0}:{1}".F(host, port);
}
示例14: IngameChromeLogic
public IngameChromeLogic( [ObjectCreator.Param] World world )
{
Game.AddChatLine += AddChatLine;
Game.BeforeGameStart += UnregisterEvents;
var r = Widget.RootWidget;
gameRoot = r.GetWidget("INGAME_ROOT");
var optionsBG = gameRoot.GetWidget("INGAME_OPTIONS_BG");
r.GetWidget<ButtonWidget>("INGAME_OPTIONS_BUTTON").OnClick = () =>
optionsBG.Visible = !optionsBG.Visible;
optionsBG.GetWidget<ButtonWidget>("DISCONNECT").OnClick = () =>
{
optionsBG.Visible = false;
Game.Disconnect();
Game.LoadShellMap();
Widget.CloseWindow();
Widget.OpenWindow("MAINMENU_BG");
};
optionsBG.GetWidget<ButtonWidget>("SETTINGS").OnClick = () => Widget.OpenWindow("SETTINGS_MENU");
optionsBG.GetWidget<ButtonWidget>("MUSIC").OnClick = () => Widget.OpenWindow("MUSIC_MENU");
optionsBG.GetWidget<ButtonWidget>("RESUME").OnClick = () => optionsBG.Visible = false;
optionsBG.GetWidget<ButtonWidget>("SURRENDER").OnClick = () =>
world.IssueOrder(new Order("Surrender", world.LocalPlayer.PlayerActor, false));
optionsBG.GetWidget("SURRENDER").IsVisible = () => (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Undefined);
var postgameBG = gameRoot.GetWidget("POSTGAME_BG");
var postgameText = postgameBG.GetWidget<LabelWidget>("TEXT");
postgameBG.IsVisible = () =>
{
return world.LocalPlayer != null && world.LocalPlayer.WinState != WinState.Undefined;
};
postgameText.GetText = () =>
{
var state = world.LocalPlayer.WinState;
return state == WinState.Undefined ? "" :
(state == WinState.Lost ? "YOU ARE DEFEATED" : "YOU ARE VICTORIOUS");
};
}
示例15: SupportPowerTooltipLogic
public SupportPowerTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, SupportPowersWidget palette)
{
widget.IsVisible = () => palette.TooltipPower != null;
var nameLabel = widget.GetWidget<LabelWidget>("NAME");
var timeLabel = widget.GetWidget<LabelWidget>("TIME");
var descLabel = widget.GetWidget<LabelWidget>("DESC");
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
var timeFont = Game.Renderer.Fonts[timeLabel.Font];
var descFont = Game.Renderer.Fonts[descLabel.Font];
var name = "";
var time = "";
var desc = "";
var baseHeight = widget.Bounds.Height;
var timeOffset = timeLabel.Bounds.X;
SupportPowerManager.SupportPowerInstance lastPower = null;
tooltipContainer.BeforeRender = () =>
{
var sp = palette.TooltipPower;
if (sp == null)
return;
time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime),
WidgetUtils.FormatTime(sp.Info.ChargeTime*25));
if (sp == lastPower)
return;
name = sp.Info.Description;
desc = sp.Info.LongDesc.Replace("\\n", "\n");
var timeWidth = timeFont.Measure(time).X;
var topWidth = nameFont.Measure(name).X + timeWidth + timeOffset;
var descSize = descFont.Measure(desc);
widget.Bounds.Width = 2*nameLabel.Bounds.X + Math.Max(topWidth, descSize.X);
widget.Bounds.Height = baseHeight + descSize.Y;
timeLabel.Bounds.X = widget.Bounds.Width - nameLabel.Bounds.X - timeWidth;
lastPower = sp;
};
nameLabel.GetText = () => name;
timeLabel.GetText = () => time;
descLabel.GetText = () => desc;
}