private void LaunchNewGame() { var playerFaction = Settings.Natives.FirstOrDefault(f => f.Name == "Player"); var politics = Settings.GetPolitics(Settings.InstanceSettings.Cell.Faction, playerFaction); politics.AddEvent(new PoliticalEvent { Change = -2.0f, Description = "You stole our land." }); Settings.InstanceSettings.Cell.Faction = playerFaction; GameStateManager.ClearState(); GameStateManager.PushState(new LoadState(Game, Settings, LoadTypes.UseExistingOverworld)); }
public void Reset() { mainPanel.Clear(); Rectangle rect = GuiRoot.RenderData.VirtualScreen; mainPanel.AddChild(new Gui.Widgets.Button { Text = "< Back", TextHorizontalAlign = HorizontalAlign.Center, TextVerticalAlign = VerticalAlign.Center, Border = "border-button", Font = "font16", OnClick = (sender, args) => { GameStateManager.PopState(); }, AutoLayout = AutoLayout.FloatBottomLeft, }); var widgetList = mainPanel.AddChild(new WidgetListView() { AutoLayout = AutoLayout.DockTop, SelectedItemForegroundColor = Color.Black.ToVector4(), SelectedItemBackgroundColor = new Vector4(0, 0, 0, 0), ItemBackgroundColor2 = new Vector4(0, 0, 0, 0.1f), ItemBackgroundColor1 = new Vector4(0, 0, 0, 0), ItemHeight = 64, MinimumSize = new Point(0, 3 * GuiRoot.RenderData.VirtualScreen.Height / 4) }) as WidgetListView; var factions = Overworld.Natives.Where(f => f.InteractiveFaction && Library.GetRace(f.Race).HasValue(out var race) && race.IsIntelligent); foreach (var faction in factions) { var diplomacy = Overworld.GetPolitics(faction, Overworld.Natives.FirstOrDefault(n => n.Name == "Player")); var details = diplomacy.GetEvents().Select(e => string.Format("{0} ({1})", TextGenerator.ToSentenceCase(e.Description), e.Change > 0 ? "+" + e.Change.ToString() : e.Change.ToString())); var entry = widgetList.AddItem(new Widget() { Background = new TileReference("basic", 0), }); StringBuilder sb = new StringBuilder(); foreach (var detail in details) { sb.AppendLine(detail); } entry.Tooltip = "Recent events:\n" + sb.ToString(); if (sb.ToString() == "") { entry.Tooltip = "No recent events."; } var titlebar = entry.AddChild(new Widget() { InteriorMargin = new Margin(5, 5, 5, 5), MinimumSize = new Point(512, 36), AutoLayout = AutoLayout.DockTop, }); titlebar.AddChild(new Widget() { Background = new TileReference("map-icons", Library.GetRace(faction.Race).HasValue(out var race) ? race.Icon : 0), MaximumSize = new Point(32, 32), MinimumSize = new Point(32, 32), AutoLayout = AutoLayout.DockLeft, });