public bool YesOrNoPrompt(string s, bool easy_cancel) { player.Interrupt(); MouseUI.PushButtonMap(MouseMode.YesNoPrompt); MouseUI.CreateButton(ConsoleKey.Y, false, 2, Global.MAP_OFFSET_COLS + s.Length + 1, 1, 2); MouseUI.CreateButton(ConsoleKey.N, false, 2, Global.MAP_OFFSET_COLS + s.Length + 4, 1, 2); if (MouseUI.descend_hack && Actor.viewing_more_commands) { MouseUI.CreateStatsButton(ConsoleKey.N, false, 16, 1); MouseUI.descend_hack = false; } DisplayNow(s + " (y/n): "); Screen.CursorVisible = true; while (true) { switch (Global.ReadKey().KeyChar) { case 'y': case 'Y': MouseUI.PopButtonMap(); return(true); case 'n': case 'N': MouseUI.PopButtonMap(); return(false); default: if (easy_cancel) { MouseUI.PopButtonMap(); return(false); } break; } } }
public static void ShowKnownItems(Hash <ConsumableType> IDed) { MouseUI.PushButtonMap(); UI.draw_bottom_commands = false; UI.darken_status_bar = true; const int width = 25; List <ConsumableType> potion_order = new List <ConsumableType> { ConsumableType.STONEFORM, ConsumableType.CLOAKING, ConsumableType.VAMPIRISM, ConsumableType.HEALING, ConsumableType.MYSTIC_MIND, ConsumableType.SILENCE, ConsumableType.REGENERATION, ConsumableType.ROOTS, ConsumableType.BRUTISH_STRENGTH, ConsumableType.HASTE }; List <ConsumableType> scroll_order = new List <ConsumableType> { ConsumableType.SUNLIGHT, ConsumableType.DARKNESS, ConsumableType.BLINKING, ConsumableType.RENEWAL, ConsumableType.FIRE_RING, ConsumableType.CALLING, ConsumableType.KNOWLEDGE, ConsumableType.PASSAGE, ConsumableType.THUNDERCLAP, ConsumableType.RAGE, ConsumableType.ENCHANTMENT, ConsumableType.TIME, ConsumableType.TRAP_CLEARING }; List <ConsumableType> orb_order = new List <ConsumableType> { ConsumableType.BREACHING, ConsumableType.FREEZING, ConsumableType.SHIELDING, ConsumableType.BLADES, ConsumableType.CONFUSION, ConsumableType.FLAMES, ConsumableType.DETONATION, ConsumableType.PAIN, ConsumableType.TELEPORTAL, ConsumableType.FOG }; List <ConsumableType> wand_order = new List <ConsumableType> { ConsumableType.DUST_STORM, ConsumableType.SLUMBER, ConsumableType.TELEKINESIS, ConsumableType.REACH, ConsumableType.INVISIBILITY, ConsumableType.WEBS, ConsumableType.FLESH_TO_FIRE }; List <colorstring> potions = new List <colorstring>(); List <colorstring> scrolls = new List <colorstring>(); List <colorstring> orbs = new List <colorstring>(); List <colorstring> wands = new List <colorstring>(); List <List <colorstring> > string_lists = new List <List <colorstring> > { potions, scrolls, orbs, wands }; int list_idx = 0; foreach (List <ConsumableType> item_list in new List <List <ConsumableType> > { potion_order, scroll_order, orb_order, wand_order }) { int item_idx = 0; while (item_idx + 1 < item_list.Count) { ConsumableType[] ct = new ConsumableType[2]; string[] names = new string[2]; Color[] ided_color = new Color[2]; for (int i = 0; i < 2; ++i) { ct[i] = item_list[item_idx + i]; names[i] = ct[i].ToString()[0] + ct[i].ToString().Substring(1).ToLower(); names[i] = names[i].Replace('_', ' '); if (IDed[ct[i]]) { ided_color[i] = Color.Cyan; } else { ided_color[i] = Color.DarkGray; } } int num_spaces = width - (names[0].Length + names[1].Length); string_lists[list_idx].Add(new colorstring(names[0], ided_color[0], "".PadRight(num_spaces), Color.Black, names[1], ided_color[1])); item_idx += 2; } if (item_list.Count % 2 == 1) { ConsumableType ct = item_list.Last(); string n = (ct.ToString()[0] + ct.ToString().Substring(1).ToLower()).Replace('_', ' '); //name = name[i].Replace('_',' '); Color ided_color = Color.DarkGray; if (IDed[ct]) { ided_color = Color.Cyan; } int num_spaces = width - n.Length; string_lists[list_idx].Add(new colorstring(n, ided_color, "".PadRight(num_spaces), Color.Black)); } ++list_idx; } Screen.WriteMapString(0, 0, "".PadRight(COLS, '-')); for (int i = 1; i < ROWS + 2; ++i) { Screen.WriteMapString(i, 0, "".PadToMapSize()); } Screen.WriteMapString(ROWS + 2, 0, "".PadRight(COLS, '-')); const Color label_color = Color.Yellow; const int first_column_offset = 2; const int second_column_offset = first_column_offset + 35; const int first_item_row = 4; Screen.WriteMapString(first_item_row - 1, 8 + first_column_offset, "- Potions -", label_color); Screen.WriteMapString(first_item_row - 1, 7 + second_column_offset, "- Scrolls -", label_color); int line = first_item_row; foreach (colorstring s in potions) { Screen.WriteMapString(line, first_column_offset, s); ++line; } line = first_item_row; foreach (colorstring s in scrolls) { Screen.WriteMapString(line, second_column_offset, s); ++line; } const int second_item_row = first_item_row + 11; Screen.WriteMapString(second_item_row - 1, 9 + first_column_offset, "- Orbs -", label_color); Screen.WriteMapString(second_item_row - 1, 8 + second_column_offset, "- Wands -", label_color); line = second_item_row; foreach (colorstring s in orbs) { Screen.WriteMapString(line, first_column_offset, s); ++line; } line = second_item_row; foreach (colorstring s in wands) { Screen.WriteMapString(line, second_column_offset, s); ++line; } UI.Display("Discovered item types: "); Input.ReadKey(); MouseUI.PopButtonMap(); UI.draw_bottom_commands = true; UI.darken_status_bar = false; }
public static void ShowPreviousMessages(bool show_footsteps) { const int text_height = Global.ROWS + 1; List <string> messages = B.GetMessageLog(); MouseUI.PushButtonMap(MouseMode.ScrollableMenu); UI.draw_bottom_commands = false; UI.darken_status_bar = true; MouseUI.CreateMapButton(ConsoleKey.OemMinus, false, 0, 1); MouseUI.CreateMapButton(ConsoleKey.OemPlus, false, text_height + 1, 1); Screen.WriteMapString(0, 0, "".PadRight(COLS, '-')); Screen.WriteMapString(text_height + 1, 0, "".PadRight(COLS, '-')); ConsoleKeyInfo command; char ch; int startline = Math.Max(0, messages.Count - text_height); for (bool done = false; !done;) { if (startline > 0) { Screen.WriteMapString(0, COLS - 3, new colorstring("[", Color.Yellow, "-", Color.Cyan, "]", Color.Yellow)); } else { Screen.WriteMapString(0, COLS - 3, "---"); } bool more = false; if (startline + text_height < messages.Count) { more = true; } if (more) { Screen.WriteMapString(text_height + 1, COLS - 3, new colorstring("[", Color.Yellow, "+", Color.Cyan, "]", Color.Yellow)); } else { Screen.WriteMapString(text_height + 1, COLS - 3, "---"); } for (int i = 1; i <= text_height; ++i) { if (messages.Count - startline < i) { Screen.WriteMapString(i, 0, "".PadToMapSize()); } else { Screen.WriteMapString(i, 0, messages[i + startline - 1].PadToMapSize()); } } UI.Display("Previous messages: "); command = Input.ReadKey(); ConsoleKey ck = command.Key; switch (ck) { case ConsoleKey.Backspace: case ConsoleKey.PageUp: case ConsoleKey.NumPad9: ch = (char)8; break; case ConsoleKey.Enter: ch = ' '; //hackery ahoy - enter becomes space and pagedown becomes enter. break; case ConsoleKey.PageDown: case ConsoleKey.NumPad3: ch = (char)13; break; case ConsoleKey.Home: case ConsoleKey.NumPad7: ch = '['; break; case ConsoleKey.End: case ConsoleKey.NumPad1: ch = ']'; break; default: ch = command.GetCommandChar(); break; } switch (ch) { case ' ': case (char)27: done = true; break; case '8': case '-': case '_': if (startline > 0) { --startline; } break; case '2': case '+': case '=': if (more) { ++startline; } break; case (char)8: if (startline > 0) { startline -= text_height; if (startline < 0) { startline = 0; } } break; case (char)13: if (messages.Count > text_height) { startline += text_height; if (startline + text_height > messages.Count) { startline = messages.Count - text_height; } } break; case '[': startline = 0; break; case ']': startline = Math.Max(0, messages.Count - text_height); break; default: break; } } if (show_footsteps && player.HasAttr(AttrType.DETECTING_MOVEMENT) && Actor.previous_footsteps.Count > 0) { M.Draw(); Screen.AnimateMapCells(Actor.previous_footsteps, new colorchar('!', Color.Red), 150); } MouseUI.PopButtonMap(); UI.draw_bottom_commands = true; UI.darken_status_bar = false; }
public static void ShowPreviousMessages(bool show_footsteps) { List <string> messages = B.GetMessages(); MouseUI.PushButtonMap(MouseMode.ScrollableMenu); MouseUI.CreateMapButton(ConsoleKey.OemMinus, false, 3, 1); MouseUI.CreateMapButton(ConsoleKey.OemPlus, false, 24, 1); Screen.CursorVisible = false; //Screen.Blank(); Screen.WriteMapString(0, 0, "".PadRight(COLS, '-')); Screen.WriteMapString(21, 0, "".PadRight(COLS, '-')); ConsoleKeyInfo command2; char ch2; int startline = Math.Max(0, messages.Count - 20); for (bool done = false; !done;) { if (startline > 0) { Screen.WriteMapString(0, COLS - 3, new colorstring("[", Color.Yellow, "-", Color.Cyan, "]", Color.Yellow)); } else { Screen.WriteMapString(0, COLS - 3, "---"); } bool more = false; if (startline + 20 < messages.Count) { more = true; } if (more) { Screen.WriteMapString(ROWS - 1, COLS - 3, new colorstring("[", Color.Yellow, "+", Color.Cyan, "]", Color.Yellow)); } else { Screen.WriteMapString(ROWS - 1, COLS - 3, "---"); } for (int i = 1; i <= 20; ++i) { if (messages.Count - startline < i) { Screen.WriteMapString(i, 0, "".PadToMapSize()); } else { Screen.WriteMapString(i, 0, messages[i + startline - 1].PadToMapSize()); } } B.DisplayNow("Previous messages: "); Screen.CursorVisible = true; command2 = Global.ReadKey(); ConsoleKey ck = command2.Key; switch (ck) { case ConsoleKey.Backspace: case ConsoleKey.PageUp: case ConsoleKey.NumPad9: ch2 = (char)8; break; case ConsoleKey.Enter: ch2 = ' '; //hackery ahoy - enter becomes space and pagedown becomes enter. break; case ConsoleKey.PageDown: case ConsoleKey.NumPad3: ch2 = (char)13; break; case ConsoleKey.Home: case ConsoleKey.NumPad7: ch2 = '['; break; case ConsoleKey.End: case ConsoleKey.NumPad1: ch2 = ']'; break; default: ch2 = Actor.ConvertInput(command2); break; } switch (ch2) { case ' ': case (char)27: done = true; break; case '8': case '-': case '_': if (startline > 0) { --startline; } break; case '2': case '+': case '=': if (more) { ++startline; } break; case (char)8: if (startline > 0) { startline -= 20; if (startline < 0) { startline = 0; } } break; case (char)13: if (messages.Count > 20) { startline += 20; if (startline + 20 > messages.Count) { startline = messages.Count - 20; } } break; case '[': startline = 0; break; case ']': startline = Math.Max(0, messages.Count - 20); break; default: break; } } if (show_footsteps && player.HasAttr(AttrType.DETECTING_MOVEMENT) && Actor.previous_footsteps.Count > 0) { M.Draw(); Screen.AnimateMapCells(Actor.previous_footsteps, new colorchar('!', Color.Red), 150); } MouseUI.PopButtonMap(); }
public void Print(bool special_message) { Screen.CursorVisible = false; int idx = str.Count - 1; while (special_message && str[idx].Length > max_length - 7) { for (int i = max_length - 8; i >= 0; --i) { if (str[idx].Substring(i, 1) == " ") { overflow = str[idx].Substring(i + 1); str[idx] = str[idx].Substring(0, i + 1); break; } } if (overflow != "") { Screen.ResetColors(); Print(false); idx = str.Count - 1; } } foreach (string s in str) { if (s != "You regenerate. " && s != "You rest... " && s != "You breathe in the overwhelming scent of the poppies. " && s != "") //eventually this will become a list of ignored strings { if (!player.HasAttr(AttrType.RESTING)) { player.Interrupt(); } } } bool repeated_message = false; foreach (string s in str) { if (s != "") { int last = (position - 1).Modulo(log_length); //if(last == -1){ last = 19; } string prev = log[last]; string count = "1"; int pos = prev.LastIndexOf(" (x"); if (pos != -1) { count = prev.Substring(pos + 3); count = count.Substring(0, count.Length - 1); prev = prev.Substring(0, pos + 1); } bool too_long_if_repeated = false; if (prev.Length + 3 + (Convert.ToInt32(count) + 1).ToString().Length > max_length) { too_long_if_repeated = true; } if (prev == s && str.Count == 1 && !too_long_if_repeated) //trying this - only add the (x2) part if it's a single-line message, for ease of reading { if (s != "You can't move! " && s != "You're rooted to the ground! ") { log[last] = prev + "(x" + (Convert.ToInt32(count) + 1).ToString() + ")"; //the immobilization messages could be confusing when repeated } repeated_message = true; } else { log[position] = s; position = (position + 1).Modulo(log_length); if (num_messages < 1000) { ++num_messages; } //++position; //if(position == 20){ position = 0; } repeated_message = false; } } } int lines = str.Count; if (str.Last() == "") { --lines; } for (int i = 0; i < 3; ++i) { bool old_message = true; if (3 - i <= lines) { old_message = false; } if (old_message) { Screen.WriteMapString(i - 3, 0, PreviousMessage(3 - i).PadToMapSize(), Color.DarkGray); //Screen.ForegroundColor = ConsoleColor.Gray; } else { if (repeated_message) { int pos = PreviousMessage(3 - i).LastIndexOf(" (x"); if (pos != -1) { Screen.WriteMapString(i - 3, 0, PreviousMessage(3 - i).Substring(0, pos)); Screen.WriteMapString(i - 3, pos, PreviousMessage(3 - i).Substring(pos).PadToMapSize(), Color.DarkGray); //Screen.ForegroundColor = ConsoleColor.Gray; } else { Screen.WriteMapString(i - 3, 0, PreviousMessage(3 - i).PadToMapSize()); } } else { Screen.WriteMapString(i - 3, 0, PreviousMessage(3 - i).PadToMapSize()); } } } if (overflow != "" || special_message == true) { int cursor_col = str.Last().Length + Global.MAP_OFFSET_COLS; int cursor_row = Screen.CursorTop; if (cursor_row > 2) { cursor_row = 2; //hack - attempts a quick fix for the [more] appearing at the player's row } M.Draw(); Screen.WriteString(cursor_row, cursor_col, "[more]", Color.Yellow); MouseUI.PushButtonMap(); Screen.SetCursorPosition(cursor_col + 6, cursor_row); //Screen.ForegroundColor = ConsoleColor.Gray; Screen.CursorVisible = true; Global.ReadKey(); MouseUI.PopButtonMap(); } str.Clear(); str.Add(""); string temp = overflow; overflow = ""; AddToStr(temp); }
protected void DisplayLines(List <string> lines, bool morePrompt, bool addToLog) { for (int i = 0; i < lines.Count; ++i) { lines[i] = RemoveTrailingSpaces(lines[i]); } bool repeated = false; bool printCount = true; if (lines.Count == 1 && log.Count > 0) { string last = GetPreviousMessage(0); string lastWithoutCount = last; if (repetitionCount > 0) { int repIdx = last.LastIndexOf(" (x" + (repetitionCount + 1) + ")"); if (repIdx != -1) { lastWithoutCount = last.Substring(0, repIdx); } } if (lines[0] == lastWithoutCount) //if the new line matches the last one, verify that there's room for the (xN) { repeated = true; if (HideRepeatCountStrings.Contains(lastWithoutCount)) { printCount = false; } else { int max = MaxLength; if (morePrompt) { max -= more.Length; } if ((lastWithoutCount + " (x" + (repetitionCount + 2) + ")").Length > max) { repeated = false; } } } } int numPrev = NumLines - lines.Count; int prevStartIdx = numPrev - 1; if (repeated) { prevStartIdx++; } for (int i = 0; i < numPrev; ++i) { Screen.WriteString(i, Global.MAP_OFFSET_COLS, GetPreviousMessage(prevStartIdx - i).PadToMapSize(), Color.DarkGray); } if (lines.Count == 0) { return; } for (int i = 0; i < lines.Count; ++i) { Screen.WriteString(i + numPrev, Global.MAP_OFFSET_COLS, lines[i].PadToMapSize()); } int extraIdx = lines[lines.Count - 1].Length + Global.MAP_OFFSET_COLS; if (repeated) { if (printCount) { string xCount = " (x" + (repetitionCount + 2) + ")"; Screen.WriteString(NumLines - 1, extraIdx, xCount, Color.DarkGray); extraIdx += xCount.Length; if (addToLog) { log[log.Count - 1] = lines[lines.Count - 1] + xCount; } } if (addToLog) { ++repetitionCount; } } else { if (addToLog) { repetitionCount = 0; AddToLog(lines); } } if (morePrompt) { Screen.WriteString(NumLines - 1, extraIdx, more, Color.Yellow); MouseUI.PushButtonMap(); Screen.SetCursorPosition(extraIdx + more.Length - 1, NumLines - 1); Input.ReadKey(); MouseUI.PopButtonMap(); } }