public override void Initialize()
 {
     DiplomacyUI.SyncPanelColor(this._app, this.ID, this._panelColor);
     this._app.UI.ClearItems("lstType");
     foreach (KeyValuePair <ConsequenceType, string> consequenceTypeLoc in TreatyEditDialog.ConsequenceTypeLocMap)
     {
         this._app.UI.AddItem("lstType", string.Empty, (int)consequenceTypeLoc.Key, App.Localize(consequenceTypeLoc.Value));
     }
     this._app.UI.SetSelection("lstType", (int)this._editedConsequence.Type);
     this._app.UI.SetPropertyString("txtValue", "text", this._editedConsequence.ConsequenceValue.ToString());
     this._valueSpinner = new ValueBoundSpinner(this.UI, "spnValue", 0.0, 1.0, 1.0, 1.0);
     this._valueSpinner.ValueChanged += new ValueChangedEventHandler(this._valueSpinner_ValueChanged);
     if (ConsequenceEditDialog.ConsequenceTypeSpinnerDescriptors.ContainsKey(this._editedConsequence.Type))
     {
         this._valueSpinner.SetValueDescriptor(ConsequenceEditDialog.ConsequenceTypeSpinnerDescriptors[this._editedConsequence.Type]);
         this._editedConsequence.ConsequenceValue = (float)this._valueSpinner.Value;
         this._app.UI.SetPropertyString("txtValue", "text", this._editedConsequence.ConsequenceValue.ToString());
         this._valueSpinner.SetVisible(true);
         this._app.UI.SetVisible("txtValue", true);
     }
     else
     {
         this._valueSpinner.SetVisible(false);
         this._app.UI.SetVisible("txtValue", false);
     }
 }
Exemple #2
0
        public static void SyncIndyDiplomacyCard(App game, string panelName, int playerId)
        {
            PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(playerId);

            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UICardPlayerName), "text", playerInfo.Name);
            DiplomacyUI.SyncPanelColor(game, game.UI.Path(panelName, DiplomacyUI.UIPanelBackground), playerInfo.PrimaryColor);
            DiplomacyUI.CardStateFunctionMap[DiplomacyCardState.DiplomacyActions](game, game.UI.Path(panelName, "stateDiplomacyActions"), playerInfo, false);
            DiplomacyUI.CardStateFunctionMap[DiplomacyCardState.PlayerHistory](game, game.UI.Path(panelName, "statePlayerHistory"), playerInfo, false);
            DiplomacyUI.CardStateFunctionMap[DiplomacyCardState.PlayerStats](game, game.UI.Path(panelName, "statePlayerStats"), playerInfo, false);
        }
 public override void Initialize()
 {
     DiplomacyUI.SyncPanelColor(this._app, this.ID, this._panelColor);
     this._app.UI.ClearItems("lstType");
     foreach (KeyValuePair <IncentiveType, string> incentiveTypeLoc in TreatyEditDialog.IncentiveTypeLocMap)
     {
         this._app.UI.AddItem("lstType", string.Empty, (int)incentiveTypeLoc.Key, App.Localize(incentiveTypeLoc.Value));
     }
     this._app.UI.SetSelection("lstType", (int)this._editedIncentive.Type);
     this._app.UI.SetPropertyString("txtValue", "text", this._editedIncentive.IncentiveValue.ToString());
     this._valueSpinner = new ValueBoundSpinner(this.UI, "spnValue", IncentiveEditDialog.IncentiveTypeSpinnerDescriptors[this._editedIncentive.Type]);
     this._valueSpinner.ValueChanged += new ValueChangedEventHandler(this._valueSpinner_ValueChanged);
 }
Exemple #4
0
        public static void SyncPlayerDiplomacyCard(
            App game,
            string panelName,
            int playerId,
            DiplomacyCardState cardState,
            bool updateButtonIds)
        {
            PlayerInfo playerInfo = game.GameDatabase.GetPlayerInfo(playerId);

            if (updateButtonIds)
            {
                game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UICardPreviousState), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICardPreviousState));
                game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UICardNextState), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICardNextState));
                game.UI.SetButtonText(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UIDeclareButton), string.Format(App.Localize("@UI_DIPLOMACY_DECLARE"), (object)game.AssetDatabase.DeclareWarPointCost));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UISurpriseAttackButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UISurpriseAttackButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UIDeclareButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIDeclareButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UIRequestButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIRequestButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UIDemandButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIDemandButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UITreatyButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UITreatyButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UILobbyButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UILobbyButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateDiplomacyActions", DiplomacyUI.UIGiveButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIGiveButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateEspionage", DiplomacyUI.UIIntelButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIIntelButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateEspionage", DiplomacyUI.UICounterIntelButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICounterIntelButton));
                game.UI.SetPropertyString(game.UI.Path(panelName, "stateEspionage", DiplomacyUI.UIOperationsButton), "id", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIOperationsButton));
            }
            game.UI.SetEnabled(game.UI.Path(panelName, string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICardPreviousState)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICardNextState)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UISurpriseAttackButton)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIDeclareButton)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIRequestButton)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIDemandButton)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UITreatyButton)), (!playerInfo.isDefeated ? 1 : 0) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIGiveButton)), (playerInfo.isDefeated ? 0 : (game.GameDatabase.GetPlayerInfo(game.LocalPlayer.ID).Savings > 0.0 ? 1 : 0)) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateDiplomacyActions", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UILobbyButton)), (playerInfo.isDefeated ? 0 : (game.Game.CanPerformLocalDiplomacyAction(playerInfo, DiplomacyAction.LOBBY, new RequestType?(), new DemandType?()) ? 1 : 0)) != 0);
            bool flag = game.AssetDatabase.GetFaction(playerInfo.FactionID).Name == "loa" && game.GameDatabase.PlayerHasTech(game.LocalPlayer.ID, "CCC_Artificial_Intelligence") || game.AssetDatabase.GetFaction(playerInfo.FactionID).Name != "loa";

            game.UI.SetEnabled(game.UI.Path(panelName, "stateEspionage", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIIntelButton)), (playerInfo.isDefeated ? 0 : (flag ? 1 : 0)) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateEspionage", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UICounterIntelButton)), (playerInfo.isDefeated ? 0 : (flag ? 1 : 0)) != 0);
            game.UI.SetEnabled(game.UI.Path(panelName, "stateEspionage", string.Format("{0}|{1}", (object)panelName, (object)DiplomacyUI.UIOperationsButton)), (playerInfo.isDefeated ? 0 : (flag ? 1 : 0)) != 0);
            foreach (DiplomacyCardState diplomacyCardState in Enum.GetValues(typeof(DiplomacyCardState)))
            {
                game.UI.SetVisible(game.UI.Path(panelName, string.Format("state{0}", (object)diplomacyCardState.ToString())), (playerInfo.isDefeated ? (diplomacyCardState == DiplomacyCardState.PlayerStats ? 1 : 0) : (diplomacyCardState == cardState ? 1 : 0)) != 0);
            }
            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UICardPlayerName), "text", playerInfo.Name);
            DiplomacyUI.SyncEspionageState(game, panelName, playerInfo, updateButtonIds);
            DiplomacyUI.SyncPanelColor(game, game.UI.Path(panelName, DiplomacyUI.UIPanelBackground), playerInfo.PrimaryColor);
            DiplomacyUI.CardStateFunctionMap[cardState](game, game.UI.Path(panelName, string.Format("state{0}", (object)cardState.ToString())), playerInfo, (updateButtonIds ? 1 : 0) != 0);
        }
 public override void Initialize()
 {
     this.InitializePanel();
     this._receivingPlayer = this._app.GameDatabase.GetPlayerInfo(this._editedTreaty.ReceivingPlayerId);
     DiplomacyUI.SyncPanelColor(this._app, "pnlBackground", this._receivingPlayer.PrimaryColor);
     this.hasTreaty = true;
     this.SyncTreatyEditor();
     this._durationSpinner                      = new ValueBoundSpinner(this.UI, "spnDuration", 1.0, 500.0, 1.0, 1.0);
     this._limitationValueSpinner               = new ValueBoundSpinner(this.UI, "spnLimitationValue", 1.0, (double)int.MaxValue, 1.0, 1.0);
     this._durationSpinner.ValueChanged        += new ValueChangedEventHandler(this._durationSpinner_ValueChanged);
     this._limitationValueSpinner.ValueChanged += new ValueChangedEventHandler(this._limitationValueSpinner_ValueChanged);
     if (this._receivingPlayer.isStandardPlayer)
     {
         return;
     }
     this._editedTreaty.Type = TreatyType.Incorporate;
     this.SyncTreatyEditor();
 }
Exemple #6
0
        public static void SyncDiplomacyPopup(App game, string panelName, int playerId)
        {
            PlayerInfo     playerInfo     = game.GameDatabase.GetPlayerInfo(playerId);
            DiplomaticMood diplomaticMood = game.GameDatabase.GetDiplomacyInfo(playerInfo.ID, game.Game.LocalPlayer.ID).GetDiplomaticMood();

            game.UI.SetVisible(DiplomacyUI.UIRelation, true);
            switch (diplomaticMood)
            {
            case DiplomaticMood.Hatred:
                game.UI.SetPropertyString(DiplomacyUI.UIRelation, "sprite", "Hate");
                break;

            case DiplomaticMood.Love:
                game.UI.SetPropertyString(DiplomacyUI.UIRelation, "sprite", "Love");
                break;

            default:
                game.UI.SetVisible(DiplomacyUI.UIRelation, false);
                break;
            }
            DiplomacyUI.SyncPanelColor(game, game.UI.Path(panelName, DiplomacyUI.UIPanelBackground), playerInfo.PrimaryColor);
            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UIAvatar), "sprite", Path.GetFileNameWithoutExtension(playerInfo.AvatarAssetPath));
            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UIBadge), "sprite", Path.GetFileNameWithoutExtension(playerInfo.BadgeAssetPath));
            game.UI.SetPropertyString(game.UI.Path(panelName, DiplomacyUI.UICardPlayerName), "text", playerInfo.Name);
            if (!(panelName == DiplomacyUI.UILobbyPanel))
            {
                return;
            }
            foreach (PlayerInfo standardPlayerInfo in game.GameDatabase.GetStandardPlayerInfos())
            {
                if (standardPlayerInfo.ID != playerId)
                {
                    float num1 = (float)game.GameDatabase.GetDiplomacyInfo(playerInfo.ID, standardPlayerInfo.ID).Relations / 2000f;
                    float num2 = ((float)((!(game.GameDatabase.GetPlayerFaction(standardPlayerInfo.ID).Name == "morrigi") || standardPlayerInfo.ID != game.Game.LocalPlayer.ID ? 0.0 : (double)game.AssetDatabase.GetTechBonus <float>("PSI_Lesser_Glamour", "diplomaticoffering") * 0.5) + (game.GameDatabase.PlayerHasTech(game.Game.LocalPlayer.ID, "PSI_Lesser_Glamour") ? (double)game.AssetDatabase.GetTechBonus <float>("PSI_Lesser_Glamour", "diplomaticoffering") : 0.0)) + num1) * 100f;
                    game.UI.AddItem(DiplomacyUI.UILobbyPlayerList, "", standardPlayerInfo.ID, standardPlayerInfo.Name + " (" + (object)(int)num2 + "% Chance)");
                }
            }
            game.UI.SetSelection(DiplomacyUI.UILobbyPlayerList, game.LocalPlayer.ID);
        }