public static string Show() { GameManager.Instance.PushGameView("QudUX:BuildLibrary"); int currentIndex = 0; int scrollOffset = 0; int startX = 2; int startY = 2; int scrollHeight = 21; int infoboxStartX = 47; int infoboxStartY = 2; int infoboxEndY = 22; int infoboxHeight = infoboxEndY - infoboxStartY + 1; List <string> buildInfo = new List <string>(); while (true) { int infoboxOffset = 0; string lastBuiltCode = ""; buildInfo.Clear(); BuildLibrary.Init(); List <BuildEntry> buildEntries = BuildLibrary.BuildEntries; if (buildEntries == null) { buildEntries = new List <BuildEntry>(); } if (currentIndex >= buildEntries.Count) { currentIndex = buildEntries.Count - 1; } if (scrollOffset < (currentIndex - scrollHeight + 1)) { scrollOffset = currentIndex - scrollHeight + 1; } while (true) { Event.ResetPool(); ScrapBuffer.Clear(); ScrapBuffer.SingleBox(0, 0, 79, 24, ColorUtility.MakeColor(TextColor.Grey, TextColor.Black)); if (buildEntries.Count > 0) { ScrapBuffer.SingleBox(infoboxStartX - 2, 0, 79, 24, ColorUtility.MakeColor(TextColor.Grey, TextColor.Black)); } ScrapBuffer.Goto(32, 0); ScrapBuffer.Write("{{y|[ {{W|Build Library}} ]}}"); ScrapBuffer.Goto(60, 0); ScrapBuffer.Write("{{y| {{W|ESC}} or {{W|5}} to exit }}"); for (int i = scrollOffset; i < scrollOffset + scrollHeight && i < buildEntries.Count; i++) { int y = (i - scrollOffset) + startY; ScrapBuffer.Goto(startX, y); string prefix = (currentIndex == i) ? "{{Y|> }}{{W|" : " {{w|"; string postfix = "}}"; int maxNameWidth = infoboxStartX - startX - 4; string buildName = buildEntries[i].Name; if (ColorUtility.StripFormatting(buildName).Length > maxNameWidth) { buildName = ColorUtility.StripFormatting(buildName); buildName = buildName.Substring(0, maxNameWidth - 3) + "{{K|...}}"; } ScrapBuffer.Write($"{{{{y|{prefix}{buildName}{postfix}}}}}"); } string currentBuildCode = null; if (buildEntries.Count <= 0) { string[] array = StringFormat.ClipText("You don't have any character builds in your library. You can save a build after you create a character, or you can find builds online and import their codes.", 70).Split('\n'); for (int j = 0; j < array.Length; j++) { ScrapBuffer.Goto(5, 4 + j); ScrapBuffer.Write(array[j]); } } else { currentBuildCode = buildEntries[currentIndex].Code; if (currentBuildCode != lastBuiltCode) { lastBuiltCode = currentBuildCode; MakeBody(currentBuildCode); buildInfo = GetBuildSidebarInfo(); } } bool hasScrollableBuildInfo = buildInfo.Count > infoboxHeight; for (int row = infoboxStartY; row <= infoboxEndY; row++) { int index = row - infoboxStartY + infoboxOffset; if (index >= buildInfo.Count) { break; } ScrapBuffer.Goto(infoboxStartX, row); ScrapBuffer.Write(buildInfo[index]); } if (hasScrollableBuildInfo) { if (buildInfo.Count > infoboxOffset + infoboxHeight) { ScrapBuffer.Goto(infoboxStartX, infoboxEndY); ScrapBuffer.Write("{{W|<More... {{y|use}} + {{y|to scroll down}}>}}"); } if (infoboxOffset > 0) { ScrapBuffer.Goto(infoboxStartX, infoboxStartY); ScrapBuffer.Write("{{W|<More... {{y|use}} - {{y|to scroll up}}>}}"); } } ScrapBuffer.Goto(1, 24); ScrapBuffer.Write(" &WSpace&y-Select &WT&y-Tweet &WR&y-Rename &WC&y-Copy Code &WE&y-Enter Code &WP&y-Paste Code &WD&y-Delete "); Console.DrawBuffer(ScrapBuffer); Keys keys = Keyboard.getvk(Options.MapDirectionsToKeypad); if (keys == Keys.Escape || keys == Keys.NumPad5) { GameManager.Instance.PopGameView(); return(null); } if (keys == Keys.NumPad8) { if (currentIndex > 0) { currentIndex--; if (currentIndex < scrollOffset) { scrollOffset--; } } //break; continue; } if (keys == Keys.NumPad2) { if (currentIndex < buildEntries.Count - 1) { currentIndex++; if (currentIndex - scrollOffset >= scrollHeight) { scrollOffset++; } } } if (keys == Keys.E) { string code = Popup.AskString("Enter a character build code.", "", 60); if (!CreateCharacter.IsValidCode(code)) { Popup.Show("That's an invalid code."); continue; } if (BuildLibrary.HasBuild(code)) { Popup.Show("That character build is already in your library."); continue; } string name = Popup.AskString("Give this build a name.", "", 60); BuildLibrary.AddBuild(code, name); currentIndex = buildEntries.Count; break; } if (keys == Keys.Add || keys == Keys.Oemplus) { if (hasScrollableBuildInfo) { if (buildInfo.Count > infoboxOffset + infoboxHeight) { infoboxOffset++; } } } if (keys == Keys.Subtract || keys == Keys.OemMinus) { if (hasScrollableBuildInfo) { if (infoboxOffset > 0) { infoboxOffset--; } } } if (keys == Keys.P || keys == Keys.Insert || keys == Keys.V || keys == (Keys.Control | Keys.V)) { string text = CreateCharacter.ClipboardHelper.GetClipboardData(); if (!CreateCharacter.IsValidCode(text)) { if (text == null) { text = ""; } Popup.Show("The code you pasted is invalid.\n\n" + text); continue; } else if (BuildLibrary.HasBuild(text)) { Popup.Show("That character build is already in your library."); continue; } else { string name2 = Popup.AskString("Give this build a name.", "", 60); BuildLibrary.AddBuild(text, name2); currentIndex = buildEntries.Count; break; } } if (keys == Keys.MouseEvent && Keyboard.CurrentMouseEvent.Event.StartsWith("Choice:")) { //mouse input not supported in QudUX version of build library } //remaining options require at least one entry if (buildEntries.Count <= 0) { continue; } if (keys == Keys.Enter || keys == Keys.Space) { if (!CreateCharacter.IsValidCode(currentBuildCode)) { Popup.Show("This build's build code is no longer valid. It may be from an outdated version of the game."); continue; } MetricsManager.LogEvent("Chargen:Library:" + currentBuildCode); GameManager.Instance.PopGameView(); return(currentBuildCode); } if (keys == Keys.C || keys == (Keys.Control | Keys.C)) { CreateCharacter.ClipboardHelper.SetClipboardData(currentBuildCode.ToUpper()); } if (keys == Keys.R && buildEntries.Count > 0) { string text2 = Popup.AskString("Give this build a new name.", "", 60); if (!string.IsNullOrEmpty(text2)) { buildEntries[currentIndex].Name = text2; BuildLibrary.UpdateBuild(buildEntries[currentIndex]); break; } } if (keys == Keys.T && buildEntries.Count > 0) { CreateCharacter.ShareToTwitter("HEY! Try my Caves of Qud character build. I call it, \"" + buildEntries[currentIndex].Name + "\".\n" + currentBuildCode.ToUpper()); } if (keys == Keys.Delete || keys == Keys.D) { if (Popup.ShowYesNoCancel("Are you sure you want to delete this character build?") == DialogResult.Yes) { BuildLibrary.DeleteBuild(currentBuildCode); break; } } } } }