void AddReplay(ScrollPanelWidget list, string filename, ScrollItemWidget template) { var item = ScrollItemWidget.Setup(template, () => currentReplay != null && currentReplay.Filename == filename, () => SelectReplay(filename)); var f = Path.GetFileName(filename); item.Get<LabelWidget>("TITLE").GetText = () => f; list.AddChild(item); }
void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template) { parent.RemoveChildren(); foreach (var o in mo.Objectives.OrderBy(o => o.Type)) { var objective = o; // Work around the loop closure issue in older versions of C# var widget = template.Clone(); var label = widget.Get<LabelWidget>("OBJECTIVE_TYPE"); label.GetText = () => objective.Type == ObjectiveType.Primary ? "Primary" : "Secondary"; var checkbox = widget.Get<CheckboxWidget>("OBJECTIVE_STATUS"); checkbox.IsChecked = () => objective.State != ObjectiveState.Incomplete; checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed"; checkbox.GetText = () => objective.Description; parent.AddChild(widget); } }
void AddAsset(ScrollPanelWidget list, string filepath, ScrollItemWidget template) { var filename = Path.GetFileName(filepath); var item = ScrollItemWidget.Setup(template, () => currentFilename == filename, () => { LoadAsset(filename); }); item.Get<LabelWidget>("TITLE").GetText = () => filepath; item.IsVisible = () => { bool visible; if (assetVisByName.TryGetValue(filepath, out visible)) return visible; visible = FilterAsset(filepath); assetVisByName.Add(filepath, visible); return visible; }; list.AddChild(item); }
void AddAsset(ScrollPanelWidget list, string filepath, ScrollItemWidget template) { var sprite = Path.GetFileNameWithoutExtension(filepath); var item = ScrollItemWidget.Setup(template, () => spriteImage.Image == sprite, () => LoadAsset(sprite)); item.Get<LabelWidget>("TITLE").GetText = () => filepath; list.AddChild(item); }
void AddReplay(ScrollPanelWidget list, string filename, LabelWidget template) { var entry = template.Clone() as LabelWidget; entry.Id = "REPLAY_"; entry.GetText = () => " {0}".F(Path.GetFileName(filename)); entry.GetBackground = () => (CurrentReplay == filename) ? "dialog2" : null; entry.OnMouseDown = mi => { if (mi.Button != MouseButton.Left) return false; CurrentReplay = filename; return true; }; entry.IsVisible = () => true; list.AddChild(entry); }
void AddAsset(ScrollPanelWidget list, string filepath, ScrollItemWidget template) { var filename = Path.GetFileName(filepath); var item = ScrollItemWidget.Setup(template, () => spriteWidget.Image == filename, () => { filenameInput.Text = filename; LoadAsset(filename); }); item.Get<LabelWidget>("TITLE").GetText = () => filepath; list.AddChild(item); }