示例#1
0
文件: MainForm.cs 项目: Cschwalb/PSAE
        void SaveGuiToPrison() {
            // Store general tab
            prison.TimeIndex = TimeConversion.ToIndex(
                Convert.ToInt32(nDay.Value), tTime.Text, cAmPm.SelectedIndex == 1);

            prison.EnabledMisconduct = xMisconduct.Checked;
            prison.EnabledIntake = xContinuousIntake.Checked;
            prison.EnabledVisibility = xFogOfWar.Checked;
            prison.FailureConditions = xFailureConditions.Checked;
            prison.EnabledDecay = xDecay.Checked;

            // Store finances tab
            prison.UnlimitedFunds = xUnlimitedFunds.Checked;
            prison.Finance.Balance = Convert.ToInt32(nBalance.Value);
            prison.Finance.BankLoan = Convert.ToInt32(nBankLoanAmount.Value);
            prison.Finance.BankCreditRating = Convert.ToDouble(nCreditRating.Value)/100;
            prison.Finance.Ownership = Convert.ToInt32(nOwnership.Value);

            // Prisoner tab is continuously saved already

            // Store research tab
            foreach (string itemName in ResearchData.AllResearch) {
                if (itemName == "None") continue;
                int idx = ResearchData.GetIndex(itemName);
                bool isUnlocked = clbResearch.GetItemChecked(idx);
                if (isUnlocked) {
                    prison.Research.Unlock(itemName);
                } else {
                    prison.Research.Lock(itemName);
                }
            }
        }
示例#2
0
文件: MainForm.cs 项目: Cschwalb/PSAE
        void LoadPrisonToGui() {
            // Load general tab
            nDay.Value = TimeConversion.IndexToDay(prison.TimeIndex);
            tTime.Text = String.Format("{0:00}:{1:00}",
                                       TimeConversion.IndexTo12Hour(prison.TimeIndex),
                                       TimeConversion.IndexToMinute(prison.TimeIndex));
            cAmPm.SelectedIndex = (TimeConversion.IsPm(prison.TimeIndex) ? 1 : 0);

            xMisconduct.Checked = prison.EnabledMisconduct;
            xContinuousIntake.Checked = prison.EnabledIntake;
            xFogOfWar.Checked = prison.EnabledVisibility;
            xFailureConditions.Checked = prison.FailureConditions;
            xDecay.Checked = prison.EnabledDecay;

            // Load finances tab
            xUnlimitedFunds.Checked = prison.UnlimitedFunds;
            nBalance.Value = prison.Finance.Balance;
            nBankLoanAmount.Value = prison.Finance.BankLoan;
            nCreditRating.Value = Convert.ToDecimal(prison.Finance.BankCreditRating*100);
            nOwnership.Value = Convert.ToDecimal(prison.Finance.Ownership);

            // Load prisoners tab
            UpdatePrisoners();
            SelectedPrisoner = null;

            // Load research tab
            clbResearch.Items.Clear();
            clbResearch.Items.AddRange(ResearchData.GetInGameNames());
            if (prison.Research != null) {
                foreach (ResearchItem item in prison.Research.Items) {
                    if (item.Label == "None") continue;
                    int idx = ResearchData.GetIndex(item.Label);
                    if (idx < 0) {
                        idx = ResearchData.AddItem(item.Label);
                        clbResearch.Items.Add(item.Label);
                    }
                    if (item.Progress > .999) {
                        clbResearch.SetItemChecked(idx, true);
                    }
                }
            }

            int numContraband = CountContraband();
            miRemoveAllContraband.Text = String.Format("Remove all contraband ({0})", numContraband);
            miRemoveAllContraband.Enabled = (numContraband > 0);

            int numTrees = prison.Objects.OtherObjects
                                 .Values .Count(obj => obj.Type == "Tree");
            miRemoveAllTrees.Text = String.Format("Remove all trees ({0})", numTrees);
            miRemoveAllTrees.Enabled = (numTrees > 0);
        }