Exemplo 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)
            {
                // 変更ありの項目は文字色を変更する
                Country country = Countries.Tags[e.Index];
                brush = RandomLeaders.IsDirty(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();
        }
Exemplo n.º 2
0
        /// <summary>
        ///     ランダム指揮官名リスト変更時の処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnNameTextBoxValidated(object sender, EventArgs e)
        {
            // 選択中の国家がなければ戻る
            if (countryListBox.SelectedIndex < 0)
            {
                return;
            }
            Country country = Countries.Tags[countryListBox.SelectedIndex];

            // ランダム指揮官名リストを更新する
            RandomLeaders.SetNames(nameTextBox.Lines.Where(line => !string.IsNullOrEmpty(line)).ToList(), country);

            // 編集済みフラグが更新されるため表示を更新する
            countryListBox.Refresh();
        }
Exemplo n.º 3
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());
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
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");
        }
Exemplo n.º 6
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("[RandomLeader] Replace: {0} -> {1}", to, with);

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

                // ランダム指揮官名を置換する
                RandomLeaders.Replace(to, with, country, regexCheckBox.Checked);
            }

            // ランダム指揮官名リストの表示を更新する
            UpdateNameList();

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

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

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

            // 履歴コンボボックスを更新する
            UpdateHistory();
        }
Exemplo n.º 7
0
        /// <summary>
        ///     ランダム指揮官名リストを更新する
        /// </summary>
        private void UpdateNameList()
        {
            nameTextBox.Clear();

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

            // ランダム指揮官名を順に追加する
            StringBuilder sb = new StringBuilder();

            foreach (string name in RandomLeaders.GetNames(country))
            {
                sb.AppendLine(name);
            }

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

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

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

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

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

            // ランダム指揮官名定義ファイルを読み込む
            RandomLeaders.Load();

            // データ読み込み後の処理
            OnFileLoaded();
        }
Exemplo 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;
        }