private void DoScenarioListEntry(Rect rect, Scenario scen) { bool flag = this.curScen == scen; Widgets.DrawOptionBackground(rect, flag); MouseoverSounds.DoRegion(rect); Rect rect2 = rect.ContractedBy(4f); Text.Font = GameFont.Small; Rect rect3 = rect2; rect3.height = Text.CalcHeight(scen.name, rect3.width); Widgets.Label(rect3, scen.name); Text.Font = GameFont.Tiny; Rect rect4 = rect2; rect4.yMin = rect3.yMax; Widgets.Label(rect4, scen.GetSummary()); if (scen.enabled) { WidgetRow widgetRow = new WidgetRow(rect.xMax, rect.y, UIDirection.LeftThenDown, 99999f, 4f); if (scen.Category == ScenarioCategory.CustomLocal && widgetRow.ButtonIcon(TexButton.DeleteX, "Delete".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmDelete".Translate(scen.File.Name), delegate { scen.File.Delete(); ScenarioLister.MarkDirty(); }, true, null)); } if (scen.Category == ScenarioCategory.SteamWorkshop && widgetRow.ButtonIcon(TexButton.DeleteX, "Unsubscribe".Translate(), new Color?(GenUI.SubtleMouseoverColor))) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmUnsubscribe".Translate(scen.File.Name), delegate { scen.enabled = false; if (this.curScen == scen) { this.curScen = null; this.EnsureValidSelection(); } Workshop.Unsubscribe(scen); }, true, null)); } if (scen.GetPublishedFileId() != PublishedFileId_t.Invalid) { if (widgetRow.ButtonIcon(ContentSource.SteamWorkshop.GetIcon(), "WorkshopPage".Translate(), null)) { SteamUtility.OpenWorkshopPage(scen.GetPublishedFileId()); } if (scen.CanToUploadToWorkshop()) { widgetRow.Icon(Page_SelectScenario.CanUploadIcon, "CanBeUpdatedOnWorkshop".Translate()); } } if (!flag && Widgets.ButtonInvisible(rect, false)) { this.curScen = scen; SoundDefOf.Click.PlayOneShotOnCamera(null); } } }
internal void Notify_ScenarioListChanged() { PublishedFileId_t selModId = curScen.GetPublishedFileId(); curScen = ScenarioLister.AllScenarios().FirstOrDefault((Scenario sc) => sc.GetPublishedFileId() == selModId); EnsureValidSelection(); }
private void DoConfigControls(Rect rect) { Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.ColumnWidth = 200f; listing_Standard.Begin(rect); if (listing_Standard.ButtonText("Load".Translate())) { Find.WindowStack.Add(new Dialog_ScenarioList_Load(delegate(Scenario loadedScen) { curScen = loadedScen; seedIsValid = false; })); } if (listing_Standard.ButtonText("Save".Translate()) && CheckAllPartsCompatible(curScen)) { Find.WindowStack.Add(new Dialog_ScenarioList_Save(curScen)); } if (listing_Standard.ButtonText("RandomizeSeed".Translate())) { SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(); RandomizeSeedAndScenario(); seedIsValid = true; } if (seedIsValid) { listing_Standard.Label("Seed".Translate().CapitalizeFirst()); string a = listing_Standard.TextEntry(seed); if (a != seed) { seed = a; curScen = ScenarioMaker.GenerateNewRandomScenario(seed); } } else { listing_Standard.Gap(Text.LineHeight + Text.LineHeight + 2f); } listing_Standard.CheckboxLabeled("EditMode".Translate().CapitalizeFirst(), ref editMode); if (editMode) { seedIsValid = false; if (listing_Standard.ButtonText("AddPart".Translate())) { OpenAddScenPartMenu(); } if (SteamManager.Initialized && (curScen.Category == ScenarioCategory.CustomLocal || curScen.Category == ScenarioCategory.SteamWorkshop) && listing_Standard.ButtonText(Workshop.UploadButtonLabel(curScen.GetPublishedFileId())) && CheckAllPartsCompatible(curScen)) { AcceptanceReport acceptanceReport = curScen.TryUploadReport(); if (!acceptanceReport.Accepted) { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, historical: false); } else { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSteamWorkshopUpload".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmContentAuthor".Translate(), delegate { SoundDefOf.Tick_High.PlayOneShotOnCamera(); Workshop.Upload(curScen); }, destructive: true)); }, destructive: true)); } } } listing_Standard.End(); }