コード例 #1
0
 public ConsequenceEditDialog(
     App game,
     ref TreatyConsequenceInfo tci,
     Vector3 panelColor,
     string template = "TreatyConsequencePopup")
     : base(game, template)
 {
     this._editedConsequence = tci;
     this._panelColor        = panelColor;
 }
コード例 #2
0
        protected override void OnPanelMessage(string panelId, string msgType, string[] msgParams)
        {
            if (this._durationSpinner.TryPanelMessage(panelId, msgType, msgParams, PanelBinding.PanelMessageTargetFlags.Self | PanelBinding.PanelMessageTargetFlags.Recursive) || this._limitationValueSpinner.TryPanelMessage(panelId, msgType, msgParams, PanelBinding.PanelMessageTargetFlags.Self | PanelBinding.PanelMessageTargetFlags.Recursive))
            {
                return;
            }
            if (msgType == "list_sel_changed")
            {
                if (panelId == "lstTreatyType")
                {
                    this._editedTreaty.Type = (TreatyType)int.Parse(msgParams[0]);
                    this.SyncTreatyTypePanels();
                    this.SyncRDPCost(this._editedTreaty);
                }
                else if (panelId == "lstLimitationType")
                {
                    LimitationTreatyInfo editedTreaty = (LimitationTreatyInfo)this._editedTreaty;
                    editedTreaty.LimitationType = (LimitationTreatyType)int.Parse(msgParams[0]);
                    if (TreatyEditDialog.EnableValueList.Contains(editedTreaty.LimitationType))
                    {
                        this._limitationValueSpinner.SetValueDescriptor(TreatyEditDialog.LimitationTypeSpinnerDescriptors[editedTreaty.LimitationType]);
                        editedTreaty.LimitationAmount = (float)this._limitationValueSpinner.Value;
                        this._app.UI.SetPropertyString("txtLimitationValue", "text", editedTreaty.LimitationAmount.ToString());
                    }
                    this.SyncLimitationGroup(editedTreaty.LimitationType);
                    this._app.UI.ClearSelection("lstLimitationGroup");
                    this.SyncRDPCost((TreatyInfo)editedTreaty);
                }
                else if (panelId == "lstArmisticeType")
                {
                    ArmisticeTreatyInfo editedTreaty = (ArmisticeTreatyInfo)this._editedTreaty;
                    editedTreaty.SuggestedDiplomacyState = (DiplomacyState)int.Parse(msgParams[0]);
                    this.SyncRDPCost((TreatyInfo)editedTreaty);
                }
                else if (panelId == "lstLimitationGroup")
                {
                    if (int.Parse(msgParams[0]) == -1)
                    {
                        return;
                    }
                    LimitationTreatyInfo editedTreaty = (LimitationTreatyInfo)this._editedTreaty;
                    switch (editedTreaty.LimitationType)
                    {
                    case LimitationTreatyType.ShipClass:
                        editedTreaty.LimitationGroup = msgParams[0];
                        break;

                    case LimitationTreatyType.Weapon:
                        editedTreaty.LimitationGroup = msgParams[0];
                        break;

                    case LimitationTreatyType.ResearchTree:
                        editedTreaty.LimitationGroup = this._app.AssetDatabase.MasterTechTree.TechFamilies[int.Parse(msgParams[0])].Id;
                        break;

                    case LimitationTreatyType.ResearchTech:
                        editedTreaty.LimitationGroup = msgParams[0];
                        break;

                    case LimitationTreatyType.StationType:
                        editedTreaty.LimitationGroup = msgParams[0];
                        break;
                    }
                }
                else if (panelId == "lstConsequences")
                {
                    this._selectedConsequence = string.IsNullOrEmpty(msgParams[0]) ? new int?() : new int?(int.Parse(msgParams[0]));
                }
                else if (panelId == "lstIncentives")
                {
                    this._selectedIncentive = string.IsNullOrEmpty(msgParams[0]) ? new int?() : new int?(int.Parse(msgParams[0]));
                }
            }
            else if (msgType == "button_clicked")
            {
                if (panelId == "btnCancel")
                {
                    this._app.UI.CloseDialog((Dialog)this, true);
                }
                if (panelId == "btnDone")
                {
                    this._app.GameDatabase.SpendDiplomacyPoints(this._app.GameDatabase.GetPlayerInfo(this._editedTreaty.InitiatingPlayerId), this._app.GameDatabase.GetPlayerFactionID(this._editedTreaty.ReceivingPlayerId), this._app.Game.GetTreatyRdpCost(this._editedTreaty));
                    this._app.GameDatabase.DeleteTreatyInfo(this._editedTreaty.ID);
                    this._app.GameDatabase.InsertTreaty(this._editedTreaty);
                    this._app.UI.CloseDialog((Dialog)this, true);
                }
                else if (panelId == "btnRemoveConsequence")
                {
                    if (this._selectedConsequence.HasValue)
                    {
                        this._editedTreaty.Consequences.RemoveAt(this._selectedConsequence.Value);
                        this.SyncConsequences();
                    }
                }
                else if (panelId == "btnEditConsequence")
                {
                    if (this._selectedConsequence.HasValue)
                    {
                        TreatyConsequenceInfo consequence = this._editedTreaty.Consequences[this._selectedConsequence.Value];
                        this._consequenceDialogId = this._app.UI.CreateDialog((Dialog) new ConsequenceEditDialog(this._app, ref consequence, this._receivingPlayer.PrimaryColor, "TreatyConsequencePopup"), null);
                    }
                }
                else if (panelId == "btnAddConsequence")
                {
                    TreatyConsequenceInfo tci = new TreatyConsequenceInfo();
                    tci.TreatyId = this._editedTreaty.ID;
                    this._editedTreaty.Consequences.Add(tci);
                    this._consequenceDialogId = this._app.UI.CreateDialog((Dialog) new ConsequenceEditDialog(this._app, ref tci, this._receivingPlayer.PrimaryColor, "TreatyConsequencePopup"), null);
                }
                else if (panelId == "btnRemoveIncentive")
                {
                    if (this._selectedIncentive.HasValue)
                    {
                        this._editedTreaty.Incentives.RemoveAt(this._selectedIncentive.Value);
                        this.SyncIncentives();
                    }
                }
                else if (panelId == "btnEditIncentive")
                {
                    if (this._selectedIncentive.HasValue)
                    {
                        TreatyIncentiveInfo incentive = this._editedTreaty.Incentives[this._selectedIncentive.Value];
                        this._incentiveDialogId = this._app.UI.CreateDialog((Dialog) new IncentiveEditDialog(this._app, ref incentive, this._receivingPlayer.PrimaryColor, "TreatyConsequencePopup"), null);
                    }
                }
                else if (panelId == "btnAddIncentive")
                {
                    TreatyIncentiveInfo tci = new TreatyIncentiveInfo();
                    tci.TreatyId = this._editedTreaty.ID;
                    this._editedTreaty.Incentives.Add(tci);
                    this._incentiveDialogId = this._app.UI.CreateDialog((Dialog) new IncentiveEditDialog(this._app, ref tci, this._receivingPlayer.PrimaryColor, "TreatyConsequencePopup"), null);
                }
            }
            else if (msgType == "dialog_closed")
            {
                if (panelId == this._incentiveDialogId)
                {
                    this.SyncIncentives();
                }
                else if (panelId == this._consequenceDialogId)
                {
                    this.SyncConsequences();
                }
            }
            else if (msgType == "text_changed")
            {
                if (panelId == "txtDuration")
                {
                    int result = 0;
                    if (int.TryParse(msgParams[0], out result))
                    {
                        this._editedTreaty.Duration = result;
                    }
                }
                else if (panelId == "txtLimitationValue")
                {
                    float result = 0.0f;
                    if (float.TryParse(msgParams[0], out result))
                    {
                        ((LimitationTreatyInfo)this._editedTreaty).LimitationAmount = result;
                    }
                }
            }
            base.OnPanelMessage(panelId, msgType, msgParams);
        }