void RebuildActionItems() { ActionScroll.Children.Clear(); List <RoundAction> actions = HumanPlayer.PossibleActions(); ActionItemControl c; // If the player has hit the top 50, provide the "Retire" option if (HumanPlayer.BestRank <= 50) { c = new ActionItemControl(); c.BindAction(RetireAction); c.ActionClicked += ActionClicked; ActionScroll.Children.Add(c); } foreach (RoundAction action in actions) { c = new ActionItemControl(); c.BindAction(action); c.ActionClicked += ActionClicked; ActionScroll.Children.Add(c); } // Add a special action at the end of the list to end the quarter and advance the game. c = new ActionItemControl(); EndRoundAction.CostString = GameFormat.FormatTime(HumanPlayer.ThisRound.TimeRemaining); c.BindAction(EndRoundAction); c.ActionClicked += ActionClicked; ActionScroll.Children.Add(c); }
void RebuildNewsItems(bool initialRebuild = false) { NewsScroll.Children.Clear(); List <MediaEvent> newsEvents = HumanPlayer.GetPlayerNews(); bool HasImportantNews = false; int index = 0; foreach (MediaEvent e in newsEvents) { NewsItemControl c = new NewsItemControl(); c.BindNews(e); NewsScroll.Children.Add(c); if (e.Important) { HasImportantNews = true; } // If this media event has reactions, add them to the list if (e.Important) { List <RoundAction> actions = HumanPlayer.MediaActions(e, index); if (actions.Count > 0) { // Build a container to hold these items indented StackPanel p = new StackPanel() { Margin = new Thickness(10, 0, 0, 0) }; NewsScroll.Children.Add(p); foreach (RoundAction action in actions) { ActionItemControl ac = new ActionItemControl(); ac.BindAction(action); ac.ActionClicked += ActionClicked; p.Children.Add(ac); } } } index++; } if (HumanPlayer.OldNews.Count > 0) { NewsScroll.Children.Add(new Label() { Content = "Older News:", FontSize = 18, Foreground = Brushes.White }); } foreach (MediaEvent e in HumanPlayer.OldNews) { NewsItemControl c = new NewsItemControl(); c.BindNews(e); NewsScroll.Children.Add(c); } if (HasImportantNews && initialRebuild) { // Switch to the news tab. tabControl.SelectedIndex = 0; } }