/// <summary> /// 編集項目の値変更時のログを出力する /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void OutputItemValueChangedLog(ScenarioEditorItemId itemId, object val, Province province, CountrySettings settings) { switch (itemId) { case ScenarioEditorItemId.CountryCapital: Log.Info("[Scenario] {0}: {1} -> {2} ({3})", ItemStrings[(int) itemId], settings.Capital, province.Id, Countries.Strings[(int) settings.Country]); break; case ScenarioEditorItemId.CountryCoreProvinces: case ScenarioEditorItemId.CountryOwnedProvinces: case ScenarioEditorItemId.CountryControlledProvinces: case ScenarioEditorItemId.CountryClaimedProvinces: Log.Info("[Scenario] {0}: {1}{2} ({3})", ItemStrings[(int) itemId], (bool) val ? '+' : '-', province.Id, Countries.Strings[(int) settings.Country]); break; } }
/// <summary> /// 地域とプロヴィンスの対応付けを設定する /// </summary> /// <param name="areaId">地域</param> /// <param name="province">プロヴィンス</param> private static void AttachAreaProvince(AreaId areaId, Province province) { // 地域の項目がなければ作成する if (!AreaProvinceMap.ContainsKey(areaId)) { AreaProvinceMap.Add(areaId, new List<Province>()); } // プロヴィンスリストにプロヴィンスを追加する if (!AreaProvinceMap[areaId].Contains(province)) { AreaProvinceMap[areaId].Add(province); } }
/// <summary> /// プロヴィンス定義行を解釈する /// </summary> /// <param name="lexer">字句解析器</param> /// <returns>プロヴィンスデータ</returns> private static Province ParseLine(CsvLexer lexer) { string[] tokens = lexer.GetTokens(); // ID指定のない行は読み飛ばす if (string.IsNullOrEmpty(tokens?[0])) { return null; } // トークン数が足りない行は読み飛ばす if (tokens.Length < 49) { Log.Warning("[Province] Invalid token count: {0} ({1} L{2})", tokens.Length, lexer.FileName, lexer.LineNo); return null; } Province province = new Province(); int index = 0; // プロヴィンスID int n; if (!int.TryParse(tokens[index], out n)) { Log.Warning("[Province] Invalid id: {0} ({1} L{2})", tokens[index], lexer.FileName, lexer.LineNo); return null; } province.Id = n; index++; // プロヴィンス名 province.Name = tokens[index]; index++; // 地域ID string s = tokens[index].ToLower(); if (string.IsNullOrEmpty(s)) { province.Area = AreaId.None; } else if (AreaStringMap.ContainsKey(s)) { province.Area = AreaStringMap[s]; } else { Log.Warning("[Province] Invalid area: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); province.Area = AreaId.None; } index++; // 地方ID s = tokens[index].ToLower(); if (string.IsNullOrEmpty(s)) { province.Region = RegionId.None; } else if (RegionStringMap.ContainsKey(s)) { province.Region = RegionStringMap[s]; } else { Log.Warning("[Province] Invalid region: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); province.Region = RegionId.None; } index++; // 大陸ID s = tokens[index].ToLower(); if (string.IsNullOrEmpty(s)) { province.Continent = ContinentId.None; } else if (ContinentStringMap.ContainsKey(s)) { province.Continent = ContinentStringMap[s]; } else { Log.Warning("[Province] Invalid continent: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); province.Continent = ContinentId.None; } index++; // 気候ID s = tokens[index].ToLower(); if (string.IsNullOrEmpty(s)) { province.Climate = ClimateId.None; } else if (ClimateStringMap.ContainsKey(s)) { province.Climate = ClimateStringMap[s]; } else { Log.Warning("[Province] Invalid climate: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); province.Climate = ClimateId.None; } index++; // 地形ID s = tokens[index].ToLower(); if (string.IsNullOrEmpty(s)) { province.Terrain = TerrainId.Unknown; } else if (TerrainStringMap.ContainsKey(s)) { province.Terrain = TerrainStringMap[s]; } else { Log.Warning("[Province] Invalid terrain: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); province.Terrain = TerrainId.Unknown; } index += 3; // インフラ double d; if (string.IsNullOrEmpty(tokens[index])) { province.Infrastructure = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Infrastructure = d; } else { Log.Warning("[Province] Invalid infrastructure: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index += 2; // 砂浜の有無 if (string.IsNullOrEmpty(tokens[index])) { province.Beaches = false; } else if (int.TryParse(tokens[index], out n)) { province.Beaches = n > 0; } else { Log.Warning("[Province] Invalid beach: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 港の有無 if (string.IsNullOrEmpty(tokens[index])) { province.PortAllowed = false; } else if (int.TryParse(tokens[index], out n)) { province.PortAllowed = n > 0; } else { Log.Warning("[Province] Invalid port allowed: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 港の海域 if (string.IsNullOrEmpty(tokens[index])) { province.PortSeaZone = 0; } else if (int.TryParse(tokens[index], out n)) { province.PortSeaZone = n; } else { Log.Warning("[Province] Invalid port sea zone: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // IC if (string.IsNullOrEmpty(tokens[index])) { province.Ic = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Ic = d; } else { Log.Warning("[Province] Invalid ic: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 労働力 if (string.IsNullOrEmpty(tokens[index])) { province.Manpower = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Manpower = d; } else { Log.Warning("[Province] Invalid manpower: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 石油 if (string.IsNullOrEmpty(tokens[index])) { province.Oil = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Oil = d; } else { Log.Warning("[Province] Invalid oil: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 金属 if (string.IsNullOrEmpty(tokens[index])) { province.Metal = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Metal = d; } else { Log.Warning("[Province] Invalid metal: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // エネルギー if (string.IsNullOrEmpty(tokens[index])) { province.Energy = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.Energy = d; } else { Log.Warning("[Province] Invalid energy: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 希少資源 if (string.IsNullOrEmpty(tokens[index])) { province.RareMaterials = 0; } else if (DoubleHelper.TryParse(tokens[index], out d)) { province.RareMaterials = d; } else { Log.Warning("[Province] Invalid rare materials: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 都市のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.CityXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.CityXPos = n; } else { Log.Warning("[Province] Invalid city posision x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 都市のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.CityYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.CityYPos = n; } else { Log.Warning("[Province] Invalid city position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 軍隊のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.ArmyXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.ArmyXPos = n; } else { Log.Warning("[Province] Invalid army position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 軍隊のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.ArmyYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.ArmyYPos = n; } else { Log.Warning("[Province] Invalid army position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 港のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.PortXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.PortXPos = n; } else { Log.Warning("[Province] Invalid port position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 港のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.PortYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.PortYPos = n; } else { Log.Warning("[Province] Invalid port position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 砂浜のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.BeachXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.BeachXPos = n; } else { Log.Warning("[Province] Invalid beach position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 砂浜のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.BeachYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.BeachYPos = n; } else { Log.Warning("[Province] Invalid beach position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 砂浜のアイコン if (string.IsNullOrEmpty(tokens[index])) { province.BeachIcon = 0; } else if (int.TryParse(tokens[index], out n)) { province.BeachIcon = n; } else { Log.Warning("[Province] Invalid beach icon: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 要塞のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.FortXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.FortXPos = n; } else { Log.Warning("[Province] Invalid fort position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 要塞のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.FortYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.FortYPos = n; } else { Log.Warning("[Province] Invalid fort position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 対空砲のX座標 if (string.IsNullOrEmpty(tokens[index])) { province.AaXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.AaXPos = n; } else { Log.Warning("[Province] Invalid aa position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 対空砲のY座標 if (string.IsNullOrEmpty(tokens[index])) { province.AaYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.AaYPos = n; } else { Log.Warning("[Province] Invalid aa position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // カウンターのX座標 if (string.IsNullOrEmpty(tokens[index])) { province.CounterXPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.CounterXPos = n; } else { Log.Warning("[Province] Invalid counter position x: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // カウンターのY座標 if (string.IsNullOrEmpty(tokens[index])) { province.CounterYPos = 0; } else if (int.TryParse(tokens[index], out n)) { province.CounterYPos = n; } else { Log.Warning("[Province] Invalid counter position y: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index += 11; // 塗りつぶしX座標1 if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX1 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX1 = n; } else { Log.Warning("[Province] Invalid fill position x1: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 塗りつぶしY座標1 if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordY1 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordY1 = n; } else { Log.Warning("[Province] Invalid fill position y1: {0} [{1}: {2}] ({3} L{4})", tokens[index], province.Id, province.Name, lexer.FileName, lexer.LineNo); } index++; // 塗りつぶしX座標2 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX2 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX2 = n; } } index++; // 塗りつぶしY座標2 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordY2 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordY2 = n; } } index++; // 塗りつぶしX座標3 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX3 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX3 = n; } } index++; // 塗りつぶしY座標3 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordY3 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordY3 = n; } } index++; // 塗りつぶしX座標4 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX4 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX4 = n; } } index++; // 塗りつぶしY座標4 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordY4 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordY4 = n; } } index++; // 塗りつぶしX座標5 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX5 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX5 = n; } } index++; // 塗りつぶしY座標5 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordY5 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordY5 = n; } } index++; // 塗りつぶしX座標6 if (index < tokens.Length) { if (string.IsNullOrEmpty(tokens[index])) { province.FillCoordX6 = 0; } else if (int.TryParse(tokens[index], out n)) { province.FillCoordX6 = n; } } return province; }
/// <summary> /// プロヴィンスの大陸を変更する /// </summary> /// <param name="province">プロヴィンス</param> /// <param name="continent">大陸</param> public static void ModifyContinent(Province province, ContinentId continent) { // 大陸と地方の対応付けを変更する DetachContinentRegion(province.Continent, province.Region); AttachContinentRegion(continent, province.Region); // 値を更新する province.Continent = continent; }
/// <summary> /// プロヴィンスリストの項目を移動する /// </summary> /// <param name="src">移動元の項目</param> /// <param name="dest">移動先の項目</param> public static void MoveItem(Province src, Province dest) { int srcIndex = Items.IndexOf(src); int destIndex = Items.IndexOf(dest); if (srcIndex > destIndex) { // 上へ移動する場合 Items.Insert(destIndex, src); Items.RemoveAt(srcIndex + 1); } else { // 下へ移動する場合 Items.Insert(destIndex + 1, src); Items.RemoveAt(srcIndex); } }
/// <summary> /// プロヴィンスリストビューの項目を作成する /// </summary> /// <param name="province">プロヴィンスデータ</param> /// <returns>プロヴィンスリストビューの項目</returns> private static ListViewItem CreateProvinceListItem(Province province) { ProvinceSettings settings = Scenarios.GetProvinceSettings(province.Id); ListViewItem item = new ListViewItem { Text = IntHelper.ToString(province.Id), Tag = province }; item.SubItems.Add(Scenarios.GetProvinceName(province, settings)); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); item.SubItems.Add(""); return item; }
/// <summary> /// プロヴィンスリストに項目を挿入する /// </summary> /// <param name="province">挿入対象の項目</param> /// <param name="position">挿入位置の直前の項目</param> public static void InsertItem(Province province, Province position) { Items.Insert(Items.IndexOf(position) + 1, province); if (province.Terrain == TerrainId.Ocean) { AddSeaZone(province); } }
/// <summary> /// 編集項目の値を設定する /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void SetItemValue(ScenarioEditorItemId itemId, object val, Province province, CountrySettings settings) { switch (itemId) { case ScenarioEditorItemId.CountryCapital: settings.Capital = province.Id; break; case ScenarioEditorItemId.CountryCoreProvinces: if ((bool) val) { Scenarios.AddCoreProvince(province.Id, settings); } else { Scenarios.RemoveCoreProvince(province.Id, settings); } break; case ScenarioEditorItemId.CountryOwnedProvinces: if ((bool) val) { Scenarios.AddOwnedProvince(province.Id, settings); } else { Scenarios.RemoveOwnedProvince(province.Id, settings); } break; case ScenarioEditorItemId.CountryControlledProvinces: if ((bool) val) { Scenarios.AddControlledProvince(province.Id, settings); } else { Scenarios.RemoveControlledProvince(province.Id, settings); } break; case ScenarioEditorItemId.CountryClaimedProvinces: if ((bool) val) { Scenarios.AddClaimedProvince(province.Id, settings); } else { Scenarios.RemoveClaimedProvince(province.Id, settings); } break; } }
/// <summary> /// 編集項目の色を更新する /// </summary> /// <param name="control">コントロール</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void UpdateItemColor(Control control, Province province, CountrySettings settings) { ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag; control.ForeColor = IsItemDirty(itemId, province, settings) ? Color.Red : SystemColors.WindowText; }
/// <summary> /// 項目値変更前の処理 /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void PreItemChanged(ScenarioEditorItemId itemId, object val, Province province, CountrySettings settings) { switch (itemId) { case ScenarioEditorItemId.CountryCapital: PreItemChangedCapital(_form.GetItemControl(itemId), val, province, settings); break; case ScenarioEditorItemId.CountryOwnedProvinces: PreItemChangedOwnedProvinces(_form.GetItemControl(itemId), val, province); break; case ScenarioEditorItemId.CountryControlledProvinces: PreItemChangedControlledProvinces(_form.GetItemControl(itemId), val, province); break; } }
/// <summary> /// 編集項目の編集済みフラグを設定する /// </summary> /// <param name="itemId">項目ID</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void SetItemDirty(ScenarioEditorItemId itemId, Province province, CountrySettings settings) { switch (itemId) { case ScenarioEditorItemId.CountryCapital: settings.SetDirty((CountrySettings.ItemId) ItemDirtyFlags[(int) itemId]); Scenarios.SetDirty(); break; case ScenarioEditorItemId.CountryCoreProvinces: settings.SetDirtyCoreProvinces(province.Id); Scenarios.SetDirty(); break; case ScenarioEditorItemId.CountryOwnedProvinces: settings.SetDirtyOwnedProvinces(province.Id); Scenarios.SetDirty(); break; case ScenarioEditorItemId.CountryControlledProvinces: settings.SetDirtyControlledProvinces(province.Id); Scenarios.Data.SetDirtyProvinces(); Scenarios.SetDirty(); break; case ScenarioEditorItemId.CountryClaimedProvinces: settings.SetDirtyClaimedProvinces(province.Id); Scenarios.SetDirty(); break; } }
/// <summary> /// 項目値変更後の処理 /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">プロヴィンス設定</param> public void PostItemChanged(ScenarioEditorItemId itemId, object val, Province province, ProvinceSettings settings) { switch (itemId) { case ScenarioEditorItemId.ProvinceNameKey: TextBox control = (TextBox) _form.GetItemControl(ScenarioEditorItemId.ProvinceNameString); UpdateItemValue(control, province, settings); UpdateItemColor(control, settings); break; } }
/// <summary> /// 項目値変更後の処理 /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void PostItemChanged(ScenarioEditorItemId itemId, object val, Province province, CountrySettings settings) { switch (itemId) { case ScenarioEditorItemId.CountryCoreProvinces: PostItemChangedCoreProvinces(val, province); break; case ScenarioEditorItemId.CountryOwnedProvinces: PostItemChangedOwnedProvinces(val, province, settings); break; case ScenarioEditorItemId.CountryControlledProvinces: PostItemChangedControlledProvinces(val, province, settings); break; case ScenarioEditorItemId.CountryClaimedProvinces: PostItemChangedClaimedProvinces(val, province); break; } }
/// <summary> /// 編集項目の値変更時のログを出力する /// </summary> /// <param name="itemId">項目ID</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">プロヴィンス設定</param> public void OutputItemValueChangedLog(ScenarioEditorItemId itemId, object val, Province province, ProvinceSettings settings) { switch (itemId) { case ScenarioEditorItemId.ProvinceNameKey: case ScenarioEditorItemId.ProvinceNameString: Log.Info("[Scenario] {0}: {1} -> {2} ({3})", ItemStrings[(int) itemId], GetItemValue(itemId, province, settings), val, province.Id); break; } }
/// <summary> /// プロヴィンス国家情報の編集項目を更新する /// </summary> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> private void UpdateProvinceCountryItems(Province province, CountrySettings settings) { _controller.UpdateItemValue(capitalCheckBox, province, settings); _controller.UpdateItemValue(coreProvinceCheckBox, province, settings); _controller.UpdateItemValue(ownedProvinceCheckBox, province, settings); _controller.UpdateItemValue(controlledProvinceCheckBox, province, settings); _controller.UpdateItemValue(claimedProvinceCheckBox, province, settings); _controller.UpdateItemColor(capitalCheckBox, province, settings); _controller.UpdateItemColor(coreProvinceCheckBox, province, settings); _controller.UpdateItemColor(ownedProvinceCheckBox, province, settings); _controller.UpdateItemColor(controlledProvinceCheckBox, province, settings); _controller.UpdateItemColor(claimedProvinceCheckBox, province, settings); }
/// <summary> /// 編集項目の値を更新する /// </summary> /// <param name="control">コントロール</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> public void UpdateItemValue(CheckBox control, Province province, CountrySettings settings) { if (settings == null) { control.Checked = false; return; } ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag; switch (itemId) { case ScenarioEditorItemId.CountryCapital: control.Checked = settings.Capital == province.Id; control.Enabled = !control.Checked; break; case ScenarioEditorItemId.CountryCoreProvinces: control.Checked = settings.NationalProvinces.Contains(province.Id); break; case ScenarioEditorItemId.CountryOwnedProvinces: control.Checked = settings.OwnedProvinces.Contains(province.Id); control.Enabled = !control.Checked; break; case ScenarioEditorItemId.CountryControlledProvinces: control.Checked = settings.ControlledProvinces.Contains(province.Id); control.Enabled = !control.Checked; break; case ScenarioEditorItemId.CountryClaimedProvinces: control.Checked = settings.ClaimedProvinces.Contains(province.Id); control.Enabled = Game.Type == GameType.DarkestHour; break; } }
/// <summary> /// プロヴィンス情報の編集項目を更新する /// </summary> /// <param name="province">プロヴィンス</param> /// <param name="settings">プロヴィンス設定</param> private void UpdateProvinceInfoItems(Province province, ProvinceSettings settings) { _controller.UpdateItemValue(provinceIdTextBox, province); _controller.UpdateItemValue(provinceNameKeyTextBox, province, settings); _controller.UpdateItemValue(provinceNameStringTextBox, province, settings); _controller.UpdateItemValue(vpTextBox, settings); _controller.UpdateItemValue(revoltRiskTextBox, settings); _controller.UpdateItemColor(provinceNameKeyTextBox, settings); _controller.UpdateItemColor(provinceNameStringTextBox, settings); _controller.UpdateItemColor(vpTextBox, settings); _controller.UpdateItemColor(revoltRiskTextBox, settings); }
/// <summary> /// 編集項目の値を更新する /// </summary> /// <param name="control">コントロール</param> /// <param name="province">プロヴィンス</param> public void UpdateItemValue(Control control, Province province) { ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag; control.Text = ObjectHelper.ToString(GetItemValue(itemId, province)); }
/// <summary> /// プロヴィンスリストに項目を追加する /// </summary> /// <param name="province">追加対象の項目</param> public static void AddItem(Province province) { Items.Add(province); if (province.Terrain == TerrainId.Ocean) { AddSeaZone(province); } }
/// <summary> /// 編集項目の値を更新する /// </summary> /// <param name="control">コントロール</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">プロヴィンス設定</param> public void UpdateItemValue(TextBox control, Province province, ProvinceSettings settings) { ScenarioEditorItemId itemId = (ScenarioEditorItemId) control.Tag; control.Text = ObjectHelper.ToString(GetItemValue(itemId, province, settings)); switch (itemId) { case ScenarioEditorItemId.ProvinceNameString: // プロヴィンス設定のプロヴィンス名定義がなければ編集不可 control.ReadOnly = string.IsNullOrEmpty(settings?.Name); break; } }
/// <summary> /// プロヴィンスの地域を変更する /// </summary> /// <param name="province">プロヴィンス</param> /// <param name="area">地域</param> public static void ModifyArea(Province province, AreaId area) { // 地域とプロヴィンスの対応付けを変更する DetachAreaProvince(province.Area, province); AttachAreaProvince(area, province); // 地方と地域の対応付けを変更する DetachRegionArea(province.Region, province.Area); AttachRegionArea(province.Region, area); // 値を更新する province.Area = area; }
/// <summary> /// 項目変更前の処理 - 保有プロヴィンス /// </summary> /// <param name="control">対象コントロール</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> private static void PreItemChangedOwnedProvinces(Control control, object val, Province province) { // チェックを入れた後はチェックボックスを無効化する if ((bool) val) { control.Enabled = false; } // 元の保有国を解除する foreach (Country country in Countries.Tags) { CountrySettings settings = Scenarios.GetCountrySettings(country); if (settings == null) { continue; } if (settings.OwnedProvinces.Contains(province.Id)) { settings.OwnedProvinces.Remove(province.Id); settings.SetDirtyOwnedProvinces(province.Id); } } }
/// <summary> /// プロヴィンスの地方を変更する /// </summary> /// <param name="province">プロヴィンス</param> /// <param name="region">地方</param> public static void ModifyRegion(Province province, RegionId region) { // 地方と地域の対応付けを変更する DetachRegionArea(province.Region, province.Area); AttachRegionArea(region, province.Area); // 大陸と地方の対応付けを変更する DetachContinentRegion(province.Continent, province.Region); AttachContinentRegion(province.Continent, region); // 値を更新する province.Region = region; }
/// <summary> /// 項目値変更後の処理 - 中核プロヴィンス /// </summary> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> private void PostItemChangedCoreProvinces(object val, Province province) { // プロヴィンスリストビューの表示を更新する int index = GetLandProvinceIndex(province.Id); if (index >= 0) { _form.SetProvinceListItemText(index, 3, (bool) val ? Resources.Yes : ""); } // プロヴィンスの強調表示を更新する if (_mapPanelController.FilterMode == MapPanelController.MapFilterMode.Core) { _mapPanelController.UpdateProvince((ushort) province.Id, (bool) val); } }
/// <summary> /// プロヴィンスリストから項目を削除する /// </summary> /// <param name="province">削除対象の項目</param> public static void RemoveItem(Province province) { Items.Remove(province); if (province.Terrain == TerrainId.Ocean) { RemoveSeaZone(province); } }
/// <summary> /// 項目値変更後の処理 - 保有プロヴィンス /// </summary> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> private void PostItemChangedOwnedProvinces(object val, Province province, CountrySettings settings) { // 変更前の保有国を解除 foreach (Country country in Countries.Tags) { CountrySettings cs = Scenarios.GetCountrySettings(country); if (cs == null || cs.Country == settings.Country || !cs.OwnedProvinces.Contains(province.Id)) { continue; } cs.OwnedProvinces.Remove(province.Id); cs.SetDirtyOwnedProvinces(province.Id); } // プロヴィンスリストビューの表示を更新する int index = GetLandProvinceIndex(province.Id); if (index >= 0) { _form.SetProvinceListItemText(index, 4, (bool) val ? Resources.Yes : ""); } // プロヴィンスの強調表示を更新する if (_mapPanelController.FilterMode == MapPanelController.MapFilterMode.Owned) { _mapPanelController.UpdateProvince((ushort) province.Id, (bool) val); } }
/// <summary> /// 地域とプロヴィンスの対応付けを解除する /// </summary> /// <param name="areaId">地域</param> /// <param name="province">プロヴィンス</param> private static void DetachAreaProvince(AreaId areaId, Province province) { // 地域の項目がなければ何もしない if (!AreaProvinceMap.ContainsKey(areaId)) { return; } // プロヴィンスリストからプロヴィンスを削除する if (AreaProvinceMap[areaId].Contains(province)) { AreaProvinceMap[areaId].Remove(province); // プロヴィンスリストの項目がなくなれば地域の項目を削除する if (AreaProvinceMap[areaId].Count == 0) { AreaProvinceMap.Remove(areaId); } } }
/// <summary> /// 項目変更前の処理 - 首都 /// </summary> /// <param name="control">対象コントロール</param> /// <param name="val">編集項目の値</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> private void PreItemChangedCapital(Control control, object val, Province province, CountrySettings settings) { // チェックを入れた後はチェックボックスを無効化する if ((bool) val) { control.Enabled = false; } // プロヴィンスリストビューの表示を更新する int index = GetLandProvinceIndex(settings.Capital); if (index >= 0) { _form.SetProvinceListItemText(index, 2, ""); } index = _landProvinces.IndexOf(province); if (index >= 0) { _form.SetProvinceListItemText(index, 2, Resources.Yes); } }
/// <summary> /// 海域リストから項目を削除する /// </summary> /// <param name="province"></param> private static void RemoveSeaZone(Province province) { // 名前が空文字列の場合は何もしない if (!Config.ExistsKey(province.Name) || string.IsNullOrEmpty(province.GetName())) { return; } SeaZones.Remove(province.Id); SeaZoneMap.Remove(province.Id); }
/// <summary> /// 編集項目の編集済みフラグを取得する /// </summary> /// <param name="itemId">項目ID</param> /// <param name="province">プロヴィンス</param> /// <param name="settings">国家設定</param> /// <returns>編集済みフラグ</returns> public bool IsItemDirty(ScenarioEditorItemId itemId, Province province, CountrySettings settings) { if (settings == null) { return false; } switch (itemId) { case ScenarioEditorItemId.CountryCapital: return settings.IsDirty((CountrySettings.ItemId) ItemDirtyFlags[(int) itemId]); case ScenarioEditorItemId.CountryCoreProvinces: return settings.IsDirtyCoreProvinces(province.Id); case ScenarioEditorItemId.CountryOwnedProvinces: return settings.IsDirtyOwnedProvinces(province.Id); case ScenarioEditorItemId.CountryControlledProvinces: return settings.IsDirtyControlledProvinces(province.Id); case ScenarioEditorItemId.CountryClaimedProvinces: return settings.IsDirtyClaimedProvinces(province.Id); } return false; }