public static void SetOutputRateNew( App game, int orbitalId, string panelName, string valueStr) { PlanetInfo planetInfo = game.GameDatabase.GetPlanetInfo(orbitalId); ColonyInfo colonyInfoForPlanet = game.GameDatabase.GetColonyInfoForPlanet(orbitalId); Colony.OutputRate rate = Colony.OutputRate.Trade; if (panelName.Contains("partInfraSlider")) { rate = Colony.OutputRate.Infra; } else if (panelName.Contains("partTerraSlider")) { rate = Colony.OutputRate.Terra; } else if (panelName.Contains("partShipConSlider")) { rate = Colony.OutputRate.ShipCon; } else if (panelName.Contains("partOverDevelopment")) { rate = Colony.OutputRate.OverDev; } float outputRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(valueStr)); Colony.SetOutputRate(game.GameDatabase, game.AssetDatabase, ref colonyInfoForPlanet, planetInfo, rate, outputRate); game.GameDatabase.UpdateColony(colonyInfoForPlanet); }
protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams) { if (this._piechart.TryPanelMessage(panelName, msgType, msgParams, PanelBinding.PanelMessageTargetFlags.Self)) { return; } if (msgType == "slider_value") { if (this.SelectedObject == StarSystemDetailsUI.StarItemID) { return; } if (StarSystemDetailsUI.IsOutputRateSlider(panelName)) { StarSystemDetailsUI.SetOutputRate(this.App, this.SelectedObject, panelName, msgParams[0]); StarSystemUI.SyncColonyDetailsWidget(this.App.Game, "colonyDetailsWidget", this.SelectedObject, ""); } else if (panelName == "partOverharvestSlider") { ColonyInfo colonyInfoForPlanet = this.App.GameDatabase.GetColonyInfoForPlanet(this.SelectedObject); colonyInfoForPlanet.OverharvestRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])); this.App.GameDatabase.UpdateColony(colonyInfoForPlanet); StarSystemUI.SyncColonyDetailsWidget(this.App.Game, "colonyDetailsWidget", this.SelectedObject, ""); } else { if (!(panelName == "gameEmpireResearchSlider")) { return; } StarMapState.SetEmpireResearchRate(this.App.Game, msgParams[0], this._piechart); } } else if (msgType == "button_clicked") { if (panelName == "gameEmpireSummaryButton") { this.App.SwitchGameState <EmpireSummaryState>(); } else if (panelName == "btnAbandon") { this._confirmAbandon = this.App.UI.CreateDialog((Dialog) new GenericQuestionDialog(this.App, "@UI_DIALOGCONFIRMABANDON_TITLE", "@UI_DIALOGCONFIRMABANDON_DESC", "dialogGenericQuestion"), null); } else { if (!(panelName == "btnSystemOpen")) { return; } bool isOpen = !this.App.GameDatabase.GetStarSystemInfo(this.CurrentSystem).IsOpen; this.App.GameDatabase.UpdateStarSystemOpen(this.CurrentSystem, isOpen); this.App.UI.SetVisible("SystemDetailsWidget.ClosedSystem", !isOpen); this.App.Game.OCSystemToggleData.SystemToggled(this.App.LocalPlayer.ID, this.CurrentSystem, isOpen); } } else { if (!(msgType == "dialog_closed") || !(panelName == this._confirmAbandon) || !bool.Parse(msgParams[0])) { return; } PlanetInfo planetInfo = this.App.GameDatabase.GetPlanetInfo(this.SelectedObject); if (planetInfo == null) { return; } GameSession.AbandonColony(this.App, this.App.GameDatabase.GetColonyInfoForPlanet(planetInfo.ID).ID); } }