public static void CreateStatsButtons() { switch (UI.viewing_commands_idx) { case 0: UI.status_row_cutoff = Global.SCREEN_H - 9; CreateStatsButton(ConsoleKey.Tab, false, Global.SCREEN_H - 8, 1); //look CreateStatsButton(ConsoleKey.P, false, Global.SCREEN_H - 7, 1); //previous messages CreateStatsButton(ConsoleKey.A, false, Global.SCREEN_H - 6, 1); //apply CreateStatsButton(ConsoleKey.G, false, Global.SCREEN_H - 5, 1); //get CreateStatsButton(ConsoleKey.F, false, Global.SCREEN_H - 4, 1); //fling CreateStatsButton(ConsoleKey.OemPeriod, false, Global.SCREEN_H - 3, 1); //wait [.] CreateStatsButton(ConsoleKey.Oem2, true, Global.SCREEN_H - 2, 1); //help [?] CreateStatsButton(ConsoleKey.V, false, Global.SCREEN_H - 1, 1); //view more break; case 1: UI.status_row_cutoff = Global.SCREEN_H - 9; CreateStatsButton(ConsoleKey.Oem5, false, Global.SCREEN_H - 8, 1); //known items [\] CreateStatsButton(ConsoleKey.O, false, Global.SCREEN_H - 7, 1); //operate CreateStatsButton(ConsoleKey.X, true, Global.SCREEN_H - 6, 1); //travel CreateStatsButton(ConsoleKey.OemPeriod, true, Global.SCREEN_H - 5, 1); //descend [>] CreateStatsButton(ConsoleKey.W, false, Global.SCREEN_H - 4, 1); //walk CreateStatsButton(ConsoleKey.OemPlus, false, Global.SCREEN_H - 3, 1); //options [=] CreateStatsButton(ConsoleKey.Q, false, Global.SCREEN_H - 2, 1); //quit CreateStatsButton(ConsoleKey.V, false, Global.SCREEN_H - 1, 1); //view more break; case 2: if (Global.Option(OptionType.HIDE_VIEW_MORE)) { UI.status_row_cutoff = Global.SCREEN_H - 1; } else { UI.status_row_cutoff = Global.SCREEN_H - 2; CreateStatsButton(ConsoleKey.V, false, Global.SCREEN_H - 1, 1); //view more } break; } CreateMapButton(ConsoleKey.P, false, -3, 3); CreatePlayerStatsButtons(); CreateButton(ConsoleKey.X, false, Global.SCREEN_H - 2, Global.MAP_OFFSET_COLS, 1, 9); //explore CreateButton(ConsoleKey.T, false, Global.SCREEN_H - 2, Global.MAP_OFFSET_COLS + 14, 1, 7); //torch CreateButton(ConsoleKey.S, false, Global.SCREEN_H - 2, Global.MAP_OFFSET_COLS + 26, 1, 11); //shoot bow CreateButton(ConsoleKey.R, false, Global.SCREEN_H - 2, Global.MAP_OFFSET_COLS + 41, 1, 6); //rest CreateButton(ConsoleKey.Z, false, Global.SCREEN_H - 2, Global.MAP_OFFSET_COLS + 52, 1, 14); //cast spell CreateButton(ConsoleKey.I, false, Global.SCREEN_H - 1, Global.MAP_OFFSET_COLS, 1, 11); //inventory CreateButton(ConsoleKey.E, false, Global.SCREEN_H - 1, Global.MAP_OFFSET_COLS + 14, 1, 11); //equipment CreateButton(ConsoleKey.C, false, Global.SCREEN_H - 1, Global.MAP_OFFSET_COLS + 26, 1, 11); //character CreateButton(ConsoleKey.M, false, Global.SCREEN_H - 1, Global.MAP_OFFSET_COLS + 41, 1, 5); //map CreateButton(ConsoleKey.F21, false, Global.SCREEN_H - 1, Global.MAP_OFFSET_COLS + 60, 1, 6); //menu }
public void DisplayNow() { //displays whatever is in the buffer. used before animations. Game.Console.CursorVisible = false; Screen.ResetColors(); /*int idx = 3-str.Count; * foreach(string s in str){ * //Game.Console.SetCursorPosition(Global.MAP_OFFSET_COLS,idx); * //Game.Console.Write(s.PadRight(Global.COLS)); * Screen.WriteMapString(idx-3,0,s.PadToMapSize()); ++idx; * }*/ if (Global.Option(OptionType.HIDE_OLD_MESSAGES)) { for (int i = 0; i < 3; ++i) { if (i < str.Count) { Screen.WriteMapString(i - 3, 0, str[i].PadToMapSize()); } else { Screen.WriteMapString(i - 3, 0, "".PadToMapSize()); } } } else { 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 + lines)).PadToMapSize(), Color.DarkGray); Screen.ForegroundColor = ConsoleColor.Gray; } else { Screen.WriteMapString(i - 3, 0, str[(i + lines) - 3].PadToMapSize()); } } } }
public static void LoadOptions() { if (!File.Exists("options.txt")) { return; } StreamReader file = new StreamReader("options.txt"); string s = ""; while (s.Length < 2 || s.Substring(0, 2) != "--") { s = file.ReadLine(); if (s.Length >= 2 && s.Substring(0, 2) == "--") { break; } string[] tokens = s.Split(' '); if (tokens[0].Length == 1) { char c = Char.ToUpper(tokens[0][0]); if (c == 'F' || c == 'T') { OptionType option = (OptionType)Enum.Parse(typeof(OptionType), tokens[1], true); if (c == 'F') { Options[option] = false; } else { Options[option] = true; } } } } s = ""; while (s.Length < 2 || s.Substring(0, 2) != "--") { s = file.ReadLine(); if (s.Length >= 2 && s.Substring(0, 2) == "--") { break; } string[] tokens = s.Split(' '); if (tokens[0].Length == 1) { char c = Char.ToUpper(tokens[0][0]); if (c == 'F' || c == 'T') { TutorialTopic topic = TutorialTopic.Movement; bool valid = true; try{ topic = (TutorialTopic)Enum.Parse(typeof(TutorialTopic), tokens[1], true); } catch (ArgumentException e) { valid = false; } if (valid) { if (c == 'F' || Global.Option(OptionType.ALWAYS_RESET_TIPS)) { Help.displayed[topic] = false; } else { Help.displayed[topic] = true; } } } } } }
public static async Task TutorialTip(TutorialTopic topic) { if (Global.Option(OptionType.NEVER_DISPLAY_TIPS) || displayed[topic]) { return; } Color box_edge_color = Color.Blue; Color box_corner_color = Color.Yellow; Color first_line_color = Color.Yellow; Color text_color = Color.Gray; string[] text = TutorialText(topic); int stringwidth = 27; // length of "[Press any key to continue]" foreach (string s in text) { if (s.Length > stringwidth) { stringwidth = s.Length; } } stringwidth += 4; //2 blanks on each side int boxwidth = stringwidth + 2; int boxheight = text.Length + 5; //for(bool done=false;!done;){ colorstring[] box = new colorstring[boxheight]; //maybe i should make this a list to match the others box[0] = new colorstring("+", box_corner_color, "".PadRight(stringwidth, '-'), box_edge_color, "+", box_corner_color); box[text.Length + 1] = new colorstring("|", box_edge_color, "".PadRight(stringwidth), Color.Gray, "|", box_edge_color); box[text.Length + 2] = new colorstring("|", box_edge_color) + ("[Press any key to continue]".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here box[text.Length + 3] = new colorstring("|", box_edge_color) + ("[=] Stop showing tips".PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here box[text.Length + 4] = new colorstring("+", box_corner_color, "".PadRight(stringwidth, '-'), box_edge_color, "+", box_corner_color); int pos = 1; foreach (string s in text) { box[pos] = new colorstring("|", box_edge_color) + (s.PadOuter(stringwidth).GetColorString(text_color)) + new colorstring("|", box_edge_color); //PadOuter originally here if (pos == 1) { box[pos] = new colorstring(); box[pos].strings.Add(new cstr("|", box_edge_color)); box[pos].strings.Add(new cstr(s.PadOuter(stringwidth), first_line_color)); //PadOuter originally here box[pos].strings.Add(new cstr("|", box_edge_color)); } ++pos; } int y = (Global.SCREEN_H - boxheight) / 2; int x = (Global.SCREEN_W - boxwidth) / 2; colorchar[,] memory = Screen.GetCurrentRect(y, x, boxheight, boxwidth); List <List <colorstring> > frames = new List <List <colorstring> >(); frames.Add(BoxAnimationFrame(boxheight - 2, FrameWidth(boxheight, boxwidth))); for (int i = boxheight - 4; i > 0; i -= 2) { frames.Add(BoxAnimationFrame(i, FrameWidth(frames.Last().Count, frames.Last()[0].Length()))); } for (int i = frames.Count - 1; i >= 0; --i) //since the frames are in reverse order { int y_offset = i + 1; int x_offset = (boxwidth - frames[i][0].Length()) / 2; Screen.WriteList(y + y_offset, x + x_offset, frames[i]); await Task.Delay(20); } foreach (colorstring s in box) { Screen.WriteString(y, x, s); ++y; } Actor.player.DisplayStats(false); if (topic != TutorialTopic.Feats) //hacky exception - don't get rid of the line that's already there. { Actor.B.DisplayNow(); } Game.Console.CursorVisible = false; await Task.Delay(500); Global.FlushInput(); /* switch(Game.Console.ReadKey(true).KeyChar){ * case 'q': * box_edge_color = NextColor(box_edge_color); * break; * case 'w': * box_corner_color = NextColor(box_corner_color); * break; * case 'e': * first_line_color = NextColor(first_line_color); * break; * case 'r': * text_color = NextColor(text_color); * break; * default: * done=true; * break; * } * }*/ if ((await Game.Console.ReadKey(true)).KeyChar == '=') { Global.Options[OptionType.NEVER_DISPLAY_TIPS] = true; } Screen.WriteArray((Global.SCREEN_H - boxheight) / 2, x, memory); if (topic != TutorialTopic.Feats) //another exception { Actor.player.DisplayStats(true); } displayed[topic] = true; Game.Console.CursorVisible = true; }
public static Color ResolveColor(Color c) { switch (c) { case Color.RandomFire: return(R.Choose(Color.Red, Color.DarkRed, Color.Yellow)); case Color.RandomIce: return(R.Choose(Color.White, Color.Cyan, Color.Blue, Color.DarkBlue)); case Color.RandomLightning: return(R.Choose(Color.White, Color.Yellow, Color.Yellow, Color.DarkYellow)); case Color.RandomBreached: if (R.OneIn(4)) { return(Color.DarkGreen); } return(Color.Green); case Color.RandomExplosion: if (R.OneIn(4)) { return(Color.Red); } return(Color.DarkRed); case Color.RandomGlowingFungus: if (R.OneIn(35)) { return(Color.DarkCyan); } return(Color.Cyan); case Color.RandomTorch: if (R.OneIn(8)) { if (R.CoinFlip()) { return(Color.White); } else { return(Color.Red); } } return(Color.Yellow); case Color.RandomDoom: if (R.OneIn(6)) { return(R.Choose(Color.DarkRed, Color.DarkGray)); } return(Color.DarkMagenta); //return R.Choose(Color.DarkGray,Color.DarkGray,Color.DarkRed,Color.DarkMagenta); case Color.RandomConfusion: if (R.OneIn(16)) { return(R.Choose(Color.Red, Color.Green, Color.Blue, Color.Cyan, Color.Yellow, Color.White)); } return(Color.Magenta); case Color.RandomDark: return(R.Choose(Color.DarkBlue, Color.DarkCyan, Color.DarkGray, Color.DarkGreen, Color.DarkMagenta, Color.DarkRed, Color.DarkYellow)); case Color.RandomBright: return(R.Choose(Color.Red, Color.Green, Color.Blue, Color.Cyan, Color.Yellow, Color.Magenta, Color.White, Color.Gray)); case Color.RandomRGB: return(R.Choose(Color.Red, Color.Green, Color.Blue)); case Color.RandomDRGB: return(R.Choose(Color.DarkRed, Color.DarkGreen, Color.DarkBlue)); case Color.RandomRGBW: return(R.Choose(Color.Red, Color.Green, Color.Blue, Color.White)); case Color.RandomCMY: return(R.Choose(Color.Cyan, Color.Magenta, Color.Yellow)); case Color.RandomDCMY: return(R.Choose(Color.DarkCyan, Color.DarkMagenta, Color.DarkYellow)); case Color.RandomCMYW: return(R.Choose(Color.Cyan, Color.Magenta, Color.Yellow, Color.White)); case Color.RandomRainbow: return(R.Choose(Color.Red, Color.Green, Color.Blue, Color.Cyan, Color.Yellow, Color.Magenta, Color.DarkBlue, Color.DarkCyan, Color.DarkGreen, Color.DarkMagenta, Color.DarkRed, Color.DarkYellow)); case Color.RandomAny: return(R.Choose(Color.Red, Color.Green, Color.Blue, Color.Cyan, Color.Yellow, Color.Magenta, Color.DarkBlue, Color.DarkCyan, Color.DarkGreen, Color.DarkMagenta, Color.DarkRed, Color.DarkYellow, Color.White, Color.Gray, Color.DarkGray)); case Color.OutOfSight: if (Global.Option(OptionType.DARK_GRAY_UNSEEN)) { if (Screen.GLMode) { return(Color.DarkerGray); } else { return(Color.DarkGray); } } else { return(Color.DarkBlue); } case Color.TerrainDarkGray: if (Screen.GLMode || !Global.Option(OptionType.DARK_GRAY_UNSEEN)) { return(Color.DarkGray); } else { return(Color.Gray); } case Color.HealthBar: if (Screen.GLMode) { return(Color.DarkerRed); } else { return(Color.DarkRed); } case Color.StatusEffectBar: if (Screen.GLMode) { return(Color.DarkerMagenta); } else { return(Color.DarkMagenta); } case Color.EnvironmentDescription: if (Screen.GLMode) { return(Color.ForestGreen); } else { return(Color.Green); } case Color.DarkEnvironmentDescription: if (Screen.GLMode) { return(Color.DarkForestGreen); } else { return(Color.DarkGreen); } default: return(c); } }
public async Task Print(bool special_message) { Game.Console.CursorVisible = false; //if(str.Last() != ""){ foreach (string s in str) { if (s != "You regenerate. " && s != "You rest... " && s != "") { player.Interrupt(); } } bool repeated_message = false; foreach (string s in str) { if (s != "") { int last = position - 1; 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 + (int.Parse(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 log[last] = prev + "(x" + (int.Parse(count) + 1).ToString() + ")"; repeated_message = true; } else { log[position] = s; ++position; if (position == 20) { position = 0; } repeated_message = false; } } } /* for(int i=0;i<3;++i){ * //Game.Console.SetCursorPosition(Global.MAP_OFFSET_COLS,i); * //Game.Console.Write("".PadRight(Global.COLS)); * Screen.WriteMapString(i-3,0,"".PadToMapSize()); * }*/ if (Global.Option(OptionType.HIDE_OLD_MESSAGES)) { for (int i = 0; i < 3; ++i) { if (i <= str.Count - 1) { //Game.Console.SetCursorPosition(Global.MAP_OFFSET_COLS,i); //Game.Console.Write(str[i]); Screen.WriteMapString(i - 3, 0, str[i].PadToMapSize()); } else { Screen.WriteMapString(i - 3, 0, "".PadToMapSize()); } } } else { int lines = str.Count; if (str.Last() == "") { --lines; } for (int i = 0; i < 3; ++i) { //Game.Console.SetCursorPosition(Global.MAP_OFFSET_COLS,i); /* if(i >= 3-lines && str[(i+lines)-3] != ""){ * Game.Console.Write(str[(i+lines)-3]); * } * else{ * Screen.ForegroundColor = ConsoleColor.DarkGray; * Game.Console.Write(PreviousMessage(3-(i+lines))); * Screen.ForegroundColor = ConsoleColor.Gray; * }*/ bool old_message = true; if (3 - i <= lines) { old_message = false; } if (old_message) { //Screen.ForegroundColor = ConsoleColor.DarkGray; //Game.Console.Write(PreviousMessage(3-i)); 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) { //Game.Console.Write(PreviousMessage(3-i).Substring(0,pos)); //Screen.ForegroundColor = ConsoleColor.DarkGray; //Game.Console.Write(PreviousMessage(3-i).Substring(pos)); 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 { //Game.Console.Write(PreviousMessage(3-i)); Screen.WriteMapString(i - 3, 0, PreviousMessage(3 - i).PadToMapSize()); } } else { //Game.Console.Write(PreviousMessage(3-i)); 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 = Game.Console.CursorTop; if (cursor_row > 2) { cursor_row = 2; //hack - attempts a quick fix for the [more] appearing at the player's row } if (Screen.MapChar(0, 0).c == "-") { //hack M.RedrawWithStrings(); } else { M.Draw(); } //Game.Console.SetCursorPosition(cursor_col,cursor_row); //Screen.ForegroundColor = ConsoleColor.Yellow; //Game.Console.Write("[more]"); Screen.WriteString(cursor_row, cursor_col, "[more]", Color.Yellow); Screen.ForegroundColor = ConsoleColor.Gray; Game.Console.CursorVisible = true; await Game.Console.ReadKey(true); } str.Clear(); str.Add(overflow); overflow = ""; /* } * else{ * for(int i=0;i<3;++i){ * Game.Console.SetCursorPosition(Global.MAP_OFFSET_COLS,i); * Game.Console.Write("".PadRight(Global.COLS)); * } * }*/ }