Esempio n. 1
0
        /// <summary>
        ///     国家リストボックスの項目描画処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCountryListBoxDrawItem(object sender, DrawItemEventArgs e)
        {
            // 項目がなければ何もしない
            if (e.Index == -1)
            {
                return;
            }

            // 背景を描画する
            e.DrawBackground();

            // 項目の文字列を描画する
            Brush brush;

            if ((e.State & DrawItemState.Selected) != DrawItemState.Selected)
            {
                // 変更ありの項目は文字色を変更する
                Branch  branch  = (Branch)(branchListBox.SelectedIndex + 1);
                Country country = Countries.Tags[e.Index];
                brush = CorpsNames.IsDirty(branch, country)
                    ? new SolidBrush(Color.Red)
                    : new SolidBrush(SystemColors.WindowText);
            }
            else
            {
                brush = new SolidBrush(SystemColors.HighlightText);
            }
            string s = countryListBox.Items[e.Index].ToString();

            e.Graphics.DrawString(s, e.Font, brush, e.Bounds);
            brush.Dispose();

            // フォーカスを描画する
            e.DrawFocusRectangle();
        }
Esempio n. 2
0
        /// <summary>
        ///     軍団名リストを更新する
        /// </summary>
        private void UpdateNameList()
        {
            nameTextBox.Clear();

            // 選択中の兵科がなければ戻る
            if (branchListBox.SelectedIndex < 0)
            {
                return;
            }
            Branch branch = (Branch)(branchListBox.SelectedIndex + 1);

            // 選択中の国家がなければ戻る
            if (countryListBox.SelectedIndex < 0)
            {
                return;
            }
            Country country = Countries.Tags[countryListBox.SelectedIndex];

            // 軍団名を順に追加する
            StringBuilder sb = new StringBuilder();

            foreach (string name in CorpsNames.GetNames(branch, country))
            {
                sb.AppendLine(name);
            }

            nameTextBox.Text = sb.ToString();
        }
Esempio n. 3
0
        /// <summary>
        ///     フォーム読み込み時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFormLoad(object sender, EventArgs e)
        {
            // 国家データを初期化する
            Countries.Init();

            // 文字列定義ファイルを読み込む
            Config.Load();

            // 兵科リストボックスを初期化する
            InitBranchListBox();

            // 国家リストボックスを初期化する
            InitCountryListBox();

            // 履歴を初期化する
            InitHistory();

            // オプション設定を初期化する
            InitOption();

            // 軍団名定義ファイルを読み込む
            CorpsNames.Load();

            // データ読み込み後の処理
            OnFileLoaded();
        }
Esempio n. 4
0
        /// <summary>
        ///     補間ボタン押下時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnInterpolateButtonClick(object sender, EventArgs e)
        {
            Log.Info("[CorpsName] Interpolate");

            if (allBranchCheckBox.Checked)
            {
                if (allCountryCheckBox.Checked)
                {
                    // 全ての軍団名を補間する
                    CorpsNames.InterpolateAll();
                }
                else
                {
                    // 国家リストボックスの選択項目がなければ戻る
                    if (countryListBox.SelectedIndex < 0)
                    {
                        return;
                    }
                    Country country = Countries.Tags[countryListBox.SelectedIndex];

                    // 全ての兵科の軍団名を補間する
                    CorpsNames.InterpolateAllBranches(country);
                }
            }
            else
            {
                // 兵科リストボックスの選択項目がなければ戻る
                if (branchListBox.SelectedIndex < 0)
                {
                    return;
                }
                Branch branch = (Branch)(branchListBox.SelectedIndex + 1);

                if (allCountryCheckBox.Checked)
                {
                    // 全ての国の軍団名を補間する
                    CorpsNames.InterpolateAllCountries(branch);
                }
                else
                {
                    // 国家リストボックスの選択項目がなければ戻る
                    if (countryListBox.SelectedIndex < 0)
                    {
                        return;
                    }
                    Country country = Countries.Tags[countryListBox.SelectedIndex];

                    // 軍団名を補間する
                    CorpsNames.Interpolate(branch, country);
                }
            }

            // 軍団名リストの表示を更新する
            UpdateNameList();

            // 編集済みフラグが更新されるため表示を更新する
            branchListBox.Refresh();
            countryListBox.Refresh();
        }
Esempio n. 5
0
 /// <summary>
 ///     編集済みかどうかを取得する
 /// </summary>
 /// <returns>編集済みならばtrueを返す</returns>
 public static bool IsDirty()
 {
     return(Misc.IsDirty() ||
            Config.IsDirty() ||
            Leaders.IsDirty() ||
            Ministers.IsDirty() ||
            Teams.IsDirty() ||
            Provinces.IsDirty() ||
            Techs.IsDirty() ||
            Units.IsDirty() ||
            CorpsNames.IsDirty() ||
            UnitNames.IsDirty() ||
            RandomLeaders.IsDirty() ||
            Scenarios.IsDirty());
 }
Esempio n. 6
0
 /// <summary>
 ///     データを保存する
 /// </summary>
 private static void SaveFiles()
 {
     if (!Misc.Save())
     {
         return;
     }
     if (!Config.Save())
     {
         return;
     }
     if (!Leaders.Save())
     {
         return;
     }
     if (!Ministers.Save())
     {
         return;
     }
     if (!Teams.Save())
     {
         return;
     }
     if (!Provinces.Save())
     {
         return;
     }
     if (!Techs.Save())
     {
         return;
     }
     if (!Units.Save())
     {
         return;
     }
     if (!CorpsNames.Save())
     {
         return;
     }
     if (!UnitNames.Save())
     {
         return;
     }
     if (!RandomLeaders.Save())
     {
         return;
     }
     Scenarios.Save();
 }
Esempio n. 7
0
        /// <summary>
        ///     追加ボタン押下時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnAddButtonClick(object sender, EventArgs e)
        {
            // 兵科リストボックスの選択項目がなければ戻る
            if (branchListBox.SelectedIndex < 0)
            {
                return;
            }
            Branch branch = (Branch)(branchListBox.SelectedIndex + 1);

            // 国家リストボックスの選択項目がなければ戻る
            if (countryListBox.SelectedIndex < 0)
            {
                return;
            }
            Country country = Countries.Tags[countryListBox.SelectedIndex];

            string prefix = prefixComboBox.Text;
            string suffix = suffixComboBox.Text;
            int    start  = (int)startNumericUpDown.Value;
            int    end    = (int)endNumericUpDown.Value;

            Log.Info("[CorpsName] Add: {0}-{1} {2} {3} [{4}] <{5}>", start, end, prefix, suffix,
                     Branches.GetName(branch), Countries.Strings[(int)country]);

            // 軍団名を一括追加する
            CorpsNames.AddSequential(prefix, suffix, start, end, branch, country);

            // 軍団名リストの表示を更新する
            UpdateNameList();

            // 編集済みフラグが更新されるため表示を更新する
            branchListBox.Refresh();
            countryListBox.Refresh();

            // 履歴を更新する
            _prefixHistory.Add(prefix);
            _suffixHistory.Add(suffix);

            HoI2EditorController.Settings.CorpsNameEditor.PrefixHistory = _prefixHistory.Get().ToList();
            HoI2EditorController.Settings.CorpsNameEditor.SuffixHistory = _suffixHistory.Get().ToList();

            // 履歴コンボボックスを更新する
            UpdateAddHistory();
        }
Esempio n. 8
0
        /// <summary>
        ///     ファイルの再読み込みを要求する
        /// </summary>
        public static void RequestReload()
        {
            Misc.RequestReload();
            Config.RequestReload();
            Leaders.RequestReload();
            Ministers.RequestReload();
            Teams.RequestReload();
            Techs.RequestReload();
            Units.RequestReload();
            Provinces.RequestReload();
            CorpsNames.RequestReload();
            UnitNames.RequestReload();
            RandomLeaders.RequestReload();
            Scenarios.RequestReload();
            Maps.RequestReload();

            SaveCanceled = false;

            Log.Verbose("Request to reload");
        }
Esempio n. 9
0
        /// <summary>
        ///     データを再読み込みする
        /// </summary>
        public static void Reload()
        {
            Log.Info("Reload");

            // データを再読み込みする
            Misc.Reload();
            Config.Reload();
            Leaders.Reload();
            Ministers.Reload();
            Teams.Reload();
            Provinces.Reload();
            Techs.Reload();
            Units.Reload();
            CorpsNames.Reload();
            UnitNames.Reload();
            RandomLeaders.Reload();
            Scenarios.Reload();

            // データ読み込み後の更新処理呼び出し
            OnFileLoaded();

            SaveCanceled = false;
        }
Esempio n. 10
0
        /// <summary>
        ///     軍団名リスト変更時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNameTextBoxValidated(object sender, EventArgs e)
        {
            // 選択中の兵科がなければ戻る
            if (branchListBox.SelectedIndex < 0)
            {
                return;
            }
            Branch branch = (Branch)(branchListBox.SelectedIndex + 1);

            // 選択中の国家がなければ戻る
            if (countryListBox.SelectedIndex < 0)
            {
                return;
            }
            Country country = Countries.Tags[countryListBox.SelectedIndex];

            // 軍団名リストを更新する
            CorpsNames.SetNames(nameTextBox.Lines.Where(line => !string.IsNullOrEmpty(line)).ToList(), branch,
                                country);

            // 編集済みフラグが更新されるため表示を更新する
            branchListBox.Refresh();
            countryListBox.Refresh();
        }
Esempio n. 11
0
        /// <summary>
        ///     置換ボタン押下時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnReplaceButtonClick(object sender, EventArgs e)
        {
            string to   = toComboBox.Text;
            string with = withComboBox.Text;

            Log.Info("[CorpsName] Replace: {0} -> {1}", to, with);

            if (allBranchCheckBox.Checked)
            {
                if (allCountryCheckBox.Checked)
                {
                    // 全ての軍団名を置換する
                    CorpsNames.ReplaceAll(to, with, regexCheckBox.Checked);
                }
                else
                {
                    // 国家リストボックスの選択項目がなければ戻る
                    if (countryListBox.SelectedIndex < 0)
                    {
                        return;
                    }
                    Country country = Countries.Tags[countryListBox.SelectedIndex];

                    // 全ての兵科の軍団名を置換する
                    CorpsNames.ReplaceAllBranches(to, with, country, regexCheckBox.Checked);
                }
            }
            else
            {
                // 兵科リストボックスの選択項目がなければ戻る
                if (branchListBox.SelectedIndex < 0)
                {
                    return;
                }
                Branch branch = (Branch)(branchListBox.SelectedIndex + 1);

                if (allCountryCheckBox.Checked)
                {
                    // 全ての国の軍団名を置換する
                    CorpsNames.ReplaceAllCountries(to, with, branch, regexCheckBox.Checked);
                }
                else
                {
                    // 国家リストボックスの選択項目がなければ戻る
                    if (countryListBox.SelectedIndex < 0)
                    {
                        return;
                    }
                    Country country = Countries.Tags[countryListBox.SelectedIndex];

                    // 軍団名を置換する
                    CorpsNames.Replace(to, with, branch, country, regexCheckBox.Checked);
                }
            }

            // 軍団名リストの表示を更新する
            UpdateNameList();

            // 編集済みフラグが更新されるため表示を更新する
            branchListBox.Refresh();
            countryListBox.Refresh();

            // 履歴を更新する
            _toHistory.Add(to);
            _withHistory.Add(with);

            HoI2EditorController.Settings.CorpsNameEditor.ToHistory   = _toHistory.Get().ToList();
            HoI2EditorController.Settings.CorpsNameEditor.WithHistory = _withHistory.Get().ToList();

            // 履歴コンボボックスを更新する
            UpdateReplaceHistory();
        }