public void receive_chat(NetIncomingMessage p, Exilania g, Display d, World w) { byte player_id = p.ReadByte(); string msg = p.ReadString(); if (player_id < w.players.Count) { if (msg[0] == '!' && Exilania.gstate == 100) { for (int i = 0; i < msg.Length; i++) { if (msg[i] == '!') { msg = msg.Substring(0, i) + msg.Substring(i + 1); break; } } d.fading_text.Add(new FadeText("@00" + msg, 3000, (int)w.players[player_id].avatar.world_loc.X, (int)w.players[player_id].avatar.world_loc.Y - 60, true, TargetType.Player, player_id, w)); } else { d.add_message("@05" + w.players[player_id].avatar.name + "@00: " + msg); } Exilania.text_stream.WriteLine("@05" + w.players[player_id].avatar.name + "@00: " + msg); } else { d.add_message("@05New Player@00: " + msg); Exilania.text_stream.WriteLine(Acc.sanitize_text_color("@05New Player@00: " + msg)); } }
public void update_choose_name(Input input, Exilania e) { if (input.key_input.Length > 30) { input.key_input = input.key_input.Substring(0, 30); } chosen_world_name = input.key_input.Trim(); if (input.mouse_cur_spot.X < Exilania.screen_size.X / 2 - 200 || input.mouse_cur_spot.X > Exilania.screen_size.X / 2 + 100) { cur_hover = -1; return; } if (input.mouse_now.Y < Exilania.screen_size.Y * (.30f)) { cur_hover = -1; } else if (input.mouse_now.Y > Exilania.screen_size.Y - 100) { cur_hover = -2; } else { float loc = (float)input.mouse_now.Y / (float)Exilania.screen_size.Y; loc -= .285f; cur_hover = (int)(loc * 100f) / 5; } if (input.left_clicked && input.mouse_now.X > -1 && input.mouse_now.Y > -1 && input.mouse_now.X <= Exilania.screen_size.X && input.mouse_now.Y <= Exilania.screen_size.Y && e.IsActive) { input.left_clicked = false; switch (cur_hover) { case -2: //you have chosen to create the world... continue? if (Acc.sanitize_text_color(input.key_input.Trim()).Length >= 5 && cur_option > -1) { chosen_world_name = input.key_input.Trim(); input.key_input = ""; world_template = cur_option; making = new World(chosen_world_name, Exilania.seed_id, (int)(System.DateTime.Now.Ticks / 1000)); cur_info_text = "Initializing."; Exilania.gstate = 92; creation_state = -1; creation_fine_control = 0; Exilania.disable_chat = false; } break; default: //learn more about a world type. if (cur_hover > -1) { cur_option = cur_hover; } break; } } }
public void draw_text_with_outline(SpriteBatch s, SpriteFont sf, string text, int x_start, int y_start, int max_width, AccColors c_use) { string sanitized = "@" + ((int)c_use).ToString().PadLeft(2, '0') + Acc.sanitize_text_color(text); for (int i = 0; i < World.xes.Length; i++) { draw_text(s, small_font, sanitized, x_start + (World.xes[i] * 2), y_start + (World.yes[i] * 2), max_width); } draw_text(s, small_font, text, x_start, y_start, max_width); }
public void draw_choosing_menu(SpriteBatch s, Display d) { string add_beginning = "@00"; s.Draw(d.planet_bkd, new Rectangle((Exilania.screen_size.X / 2) - (1920 / 2), (Exilania.screen_size.Y / 2) - (1080 / 2), 1920, 1080), new Rectangle(0, 0, 1920, 1080), Color.White); Vector2 size_text = d.font.MeasureString("World Creation Menu"); d.draw_text(s, d.font, "@05World Creation Menu", Exilania.screen_size.X / 2 - (int)size_text.X / 2, 10, Exilania.screen_size.X); s.Draw(d.Exilania_title, new Rectangle(Exilania.screen_size.X - 400, (int)((float)Exilania.screen_size.Y - 100), 392, 87), new Rectangle(0, 0, 392, 87), Color.White); for (int x = 0; x < diff_worlds.Count; x++) { if (x == cur_option) { add_beginning = "@05"; } else if (x == cur_hover) { add_beginning = "@08"; } else { add_beginning = "@00"; } d.draw_text(s, d.middle_font, add_beginning + diff_worlds[x].ToString(), Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y * (.30f + ((float)x * .05f))), Exilania.screen_size.X / 2); } string fix_text = ""; if (Acc.sanitize_text_color(chosen_world_name).Length >= 5 && cur_option > -1) { add_beginning = "@05"; } else { if (Acc.sanitize_text_color(chosen_world_name).Length < 5) { fix_text += "Type a name for this world. It must have at least 5 characters."; } if (cur_option < 0) { fix_text += " You must choose a template."; } add_beginning = "@08"; } if (fix_text != "") { Vector2 meas = d.middle_font.MeasureString(fix_text); d.draw_text(s, d.middle_font, "@00" + fix_text, Exilania.screen_size.X / 2 - (int)(meas.X / 2), (int)((float)Exilania.screen_size.Y - 150), Exilania.screen_size.X); } d.draw_text(s, d.middle_font, add_beginning + "[ Click to Generate World ]", Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y - 60), Exilania.screen_size.X / 2); d.draw_text(s, d.middle_font, "@00World Name: " + chosen_world_name, Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y - 200), Exilania.screen_size.X / 2); }
public void draw_fade_text(SpriteBatch s, Vector2 top_left) { Vector2 size_string; int left, top; byte use; for (int x = 0; x < fading_text.Count; x++) { size_string = small_font.MeasureString(Acc.sanitize_text_color(fading_text[x].text)); if (size_string.X >= Exilania.screen_size.X || size_string.Y >= Exilania.screen_size.Y) { fading_text.RemoveAt(x); x--; } else { if (fading_text[x].world_loc) { left = fading_text[x].loc.X - (int)(size_string.X / 2) - (int)top_left.X; top = fading_text[x].loc.Y - (int)(size_string.Y / 2) - (int)top_left.Y; } else { left = fading_text[x].loc.X - (int)(size_string.X / 2); top = fading_text[x].loc.Y - (int)(size_string.Y / 2); } if (fading_text[x].time_left <0 && fading_text[x].time_left> -255) { use = (byte)((255 + fading_text[x].time_left) / 2); //use.A = Convert.ToByte(255 + fading_text[x].time_left); } else { use = 255; } if (fading_text[x].time_left > -256) { string sanitized = "@31" + Acc.sanitize_text_color(fading_text[x].text); for (int i = 0; i < World.xes.Length; i++) { draw_text(s, small_font, sanitized, left + (World.xes[i] * 2), top + (World.yes[i] * 2), (int)size_string.X, use); } draw_text(s, small_font, fading_text[x].text, left, top, (int)size_string.X, use); } if (fading_text[x].time_left <= -255) { fading_text.RemoveAt(x); x--; } } } }
/// <summary> /// controls the viewing of the messaging system... always visible, always able to be turned off (unless enter has been pressed and message typing is commenced) /// </summary> /// <param name="input"></param> public void input_message_display(Input input, Settings settings, Actor me, World w) { if (Exilania.input.current_input_type != InputConsume.Message && !Exilania.disable_chat) { if (input.enter) { input.enter = false; show_messages = true; input.key_input = ""; Exilania.input.current_input_type = InputConsume.Message; } if (input.key_input.Contains('M') || input.key_input.Contains('m')) { input.key_input = input.key_input.Replace("M", ""); input.key_input = input.key_input.Replace("m", ""); show_messages = !show_messages; } if (input.key_input.Contains('-')) { input.key_input = input.key_input.Replace("-", ""); start_show_messages--; if (start_show_messages < Math.Min(20, messages.Count - 1)) { start_show_messages = Math.Min(20, messages.Count - 1); } } if (input.key_input.Contains('+')) { input.key_input = input.key_input.Replace("+", ""); start_show_messages++; if (start_show_messages > messages.Count - 1) { start_show_messages = messages.Count - 1; } } if (input.keys_now.Contains(Keys.PageUp) && !input.keys_previous.Contains(Keys.PageUp)) { start_show_messages -= 20; if (start_show_messages < Math.Min(20, messages.Count - 1)) { start_show_messages = Math.Min(20, messages.Count - 1); } } if (input.keys_now.Contains(Keys.PageDown) && !input.keys_previous.Contains(Keys.PageDown)) { start_show_messages += 20; if (start_show_messages > messages.Count - 1) { start_show_messages = messages.Count - 1; } } if (input.keys_now.Contains(Keys.Home) && !input.keys_previous.Contains(Keys.Home)) { start_show_messages = Math.Min(20, messages.Count - 1); } if (input.keys_now.Contains(Keys.End) && !input.keys_previous.Contains(Keys.End)) { start_show_messages = messages.Count - 1; } } else if (!Exilania.disable_chat) { if (input.enter) { input.enter = false; show_messages = true; input.key_input = input.key_input.Trim(); if (input.key_input != "") { if (input.key_input[0] == '/') { add_message(settings.modify_settings(input.key_input.Substring(1), w)); } else { if (Exilania.game_client) { Exilania.network_client.send_chat(Exilania.game_my_user_id, input.key_input); } if (input.key_input[0] == '!' && me != null) { for (int i = 0; i < input.key_input.Length; i++) { if (input.key_input[i] == '!') { input.key_input = input.key_input.Substring(0, i) + input.key_input.Substring(i + 1); break; } } fading_text.Add(new FadeText("@00" + input.key_input, 3000, (int)me.world_loc.X, (int)me.world_loc.Y - 60, true, TargetType.Player, Exilania.game_my_user_id, w)); } else { add_message("@02You@00: " + input.key_input); } Exilania.text_stream.WriteLine(Acc.sanitize_text_color("@02You@00: " + input.key_input)); } } input.key_input = ""; Exilania.input.current_input_type = InputConsume.Normal; } } }