Beispiel #1
0
 private void SetTrapInputsEnabled(bool enabled)
 {
     foreach (PlanetWidget planetWidget in this._planetWidgets)
     {
         PlanetWidget widget = planetWidget;
         if (!this._existingTraps.Any <ColonyTrapInfo>((Func <ColonyTrapInfo, bool>)(x => x.PlanetID == widget.GetPlanetID())) && (enabled || !this._placedTraps.Any <int>((Func <int, bool>)(x => x == widget.GetPlanetID()))))
         {
             this.App.UI.SetPropertyBool("applyTrap|" + widget.GetPlanetID().ToString(), "input_enabled", enabled);
             this.App.UI.SetEnabled("applyTrap|" + widget.GetPlanetID().ToString(), enabled);
         }
     }
 }
Beispiel #2
0
        protected override void OnEnter()
        {
            base.OnEnter();
            this._planetWidget = new PlanetWidget(this.App, this.App.UI.Path(this.ID, "planetDetailsCard"));
            IEnumerable <int> missionTargetPlanets = this.GetMissionTargetPlanets();

            FleetUI.SyncPlanetListControl(this.App.Game, this.App.UI.Path(this.ID, "overlayPlanetList"), missionTargetPlanets);
            this.App.UI.SetEnabled("gameConfirmMissionButton", false);
            if (missionTargetPlanets.Count <int>() <= 0)
            {
                return;
            }
            this.SetSelectedPlanet(missionTargetPlanets.First <int>(), "");
        }
Beispiel #3
0
 public override void Initialize()
 {
     if (this.mission != null)
     {
         this._app.UI.SetPropertyString(this._app.UI.Path(this.ID, "lblDesc"), "text", string.Format(App.Localize("@UI_DIALOGSELFSUFFICIENT_DESC"), (object)this.orbitalObject.Name, (object)this._app.GameDatabase.GetStarSystemInfo(this.orbitalObject.StarSystemID).Name, (object)this._app.Game.GetNumSupportTrips(this.mission), (object)this._app.GameDatabase.GetFleetInfo(this.mission.FleetID).Name));
         this._app.UI.SetVisible(this._app.UI.Path(this.ID, "btnSupport"), true);
         this._app.UI.SetVisible(this._app.UI.Path(this.ID, "lblDesc"), true);
     }
     else
     {
         this._app.UI.SetVisible(this._app.UI.Path(this.ID, "btnSupport"), false);
         this._app.UI.SetVisible(this._app.UI.Path(this.ID, "lblDesc"), false);
     }
     this.planetwidget = new PlanetWidget(this._app, this._app.UI.Path(this.ID, "planetcard"));
     this.planetwidget.Sync(this.planet.ID, false, false);
 }
Beispiel #4
0
 protected void UICommChannel_OnPanelMessage(
     string panelName,
     string msgType,
     string[] msgParams)
 {
     if (msgType == "slider_value")
     {
         if (!panelName.StartsWith("__"))
         {
             return;
         }
         string[] strArray = panelName.Split('|');
         if (int.Parse(strArray[1]) != this._widgetID)
         {
             return;
         }
         ColonyInfo colonyInfo = this.App.GameDatabase.GetColonyInfo(int.Parse(strArray[2]));
         if (colonyInfo == null)
         {
             return;
         }
         if (PlanetWidget.IsOutputRateSlider(panelName))
         {
             StarSystemDetailsUI.SetOutputRateNew(this.App, colonyInfo.OrbitalObjectID, panelName, msgParams[0]);
             StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName);
         }
         if (strArray[0].Contains("partOverharvestSlider"))
         {
             colonyInfo.OverharvestRate = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0]));
             this.App.GameDatabase.UpdateColony(colonyInfo);
             StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName);
         }
         else if (strArray[0].Contains("partCivSlider"))
         {
             colonyInfo.CivilianWeight = StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0]));
             this.App.GameDatabase.UpdateColony(colonyInfo);
             StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName);
         }
         else
         {
             if (!strArray[0].Contains("partPopSlider"))
             {
                 return;
             }
             int lockedVar = int.Parse(strArray[3]);
             Dictionary <int, float> ratios = new Dictionary <int, float>();
             foreach (ColonyFactionInfo faction in colonyInfo.Factions)
             {
                 ratios.Add(faction.FactionID, faction.CivPopWeight);
             }
             AlgorithmExtensions.DistributePercentages <int>(ref ratios, lockedVar, StarSystemDetailsUI.SliderValueToOutputRate(int.Parse(msgParams[0])));
             foreach (ColonyFactionInfo faction in colonyInfo.Factions)
             {
                 faction.CivPopWeight = ratios[faction.FactionID];
                 this.App.GameDatabase.UpdateCivilianPopulation(faction);
             }
             this.App.GameDatabase.UpdateColony(colonyInfo);
             StarSystemUI.SyncColonyDetailsControlNew(this.App.Game, this._rootPanel, colonyInfo.ID, this._widgetID, panelName);
         }
     }
     else
     {
         if (!(msgType == "slider_notched") || !panelName.StartsWith("__"))
         {
             return;
         }
         string[] strArray = panelName.Split('|');
         if (int.Parse(strArray[1]) != this._widgetID)
         {
             return;
         }
         ColonyInfo colonyInfo = this.App.GameDatabase.GetColonyInfo(int.Parse(strArray[2]));
         if (colonyInfo == null || !panelName.Contains("partTradeSlider"))
         {
             return;
         }
         PlanetWidget.UpdateTradeSliderNotchInfo(this.App, colonyInfo.ID, int.Parse(msgParams[0]));
     }
 }