private void SetupTextOverMap(Battle battle, double timeLeft, MapSettings settings) { Color color = settings.TextMapColor; Locate locate = new Locate(PictureBox.Width, PictureBox.Height); if (settings.ShowLifeSeconds) { TimerLabel.ForeColor = color; TimerLabel.Parent = PictureBox; TimerLabel.Visible = true; locate.BottomCenter(TimerLabel, 20); } if (settings.ShowLevelName || settings.ShowDesigner) { HeaderLabel.ForeColor = color; HeaderLabel.Parent = PictureBox; HeaderLabel.Visible = true; StringBuilder text = new StringBuilder(); if (settings.ShowLevelName) text.Append(battle.Name); if (settings.ShowDesigner) text.Append(" by " + battle.Desginer); HeaderLabel.Text = text.ToString(); HeaderLabel.MaximumSize = new Size(PictureBox.Width, PictureBox.Height); locate.BottomRight(HeaderLabel, 5); } if (settings.ShowType) { TypeLabel.ForeColor = color; TypeLabel.Parent = PictureBox; TypeLabel.Visible = true; TypeLabel.Text = EnumExtensions.GetDescription(battle.Type); locate.BottomLeft(TypeLabel, 5); } if (settings.ShowAttributes) { AttributesLabel.ForeColor = color; AttributesLabel.Parent = PictureBox; AttributesLabel.Visible = true; List<string> attributes = new List<string>(); foreach (BattleAttribute att in EnumExtensions.GetFlags(battle.Attributes)) attributes.Add(EnumExtensions.GetDescription(att)); AttributesLabel.Text = Util.FirstCharToUpper(string.Join(", ", attributes).ToLower()); AttributesLabel.MaximumSize = new Size(PictureBox.Width, PictureBox.Height); int margin = AttributesLabel.Height + 2; locate.BottomCenter(AttributesLabel, 20); locate.MoveUp(TimerLabel, margin); } // Check for collisions. if ((settings.ShowDesigner || settings.ShowLevelName) && settings.ShowType && HeaderLabel.Width > PictureBox.Width - TypeLabel.Width - 10) { locate.ToLeft(HeaderLabel, 5); locate.MoveUp(TypeLabel, HeaderLabel.Height + 2); locate.MoveUp(TimerLabel, HeaderLabel.Height + 2); if (settings.ShowAttributes) { locate.BottomRight(AttributesLabel, 5); locate.MoveUp(AttributesLabel, HeaderLabel.Height + 2); locate.BottomRight(TimerLabel, 5); locate.MoveUp(TimerLabel, AttributesLabel.Height + HeaderLabel.Height + TypeLabel.Height + 2 ); if (AttributesLabel.Width > PictureBox.Width - TypeLabel.Width - 10) { locate.ToLeft(AttributesLabel, 5); locate.MoveUp(TypeLabel, AttributesLabel.Height + 2); } } else if (settings.ShowLifeSeconds && TimerLabel.Location.Y + TimerLabel.Height > HeaderLabel.Location.Y) { // Timer is over Header, take out designer to fit everything. if (!showOnlyTimerAndType) { showOnlyTimerAndType = true; HeaderLabel.Visible = false; settings.ShowDesigner = false; tooSmallMap = true; SetupTextOverMap(battle, timeLeft, settings); } } } // Check if important information is not shown. if (settings.ShowLifeSeconds) { if (TimerLabel.Location.Y < 0) { if (!tooSmallMap) { tooSmallMap = true; AttributesLabel.Visible = false; settings.ShowAttributes = false; SetupTextOverMap(battle, timeLeft, settings); } else { HeaderLabel.Visible = false; locate.BottomRight(TimerLabel, 5); if (settings.ShowType) locate.BottomLeft(TypeLabel, 5); } } } }
public BattleNotificationSettings() { Basic = new BasicSettings(); General = new GeneralSettings(); Map = new MapSettings(); }