public FormBattle(FormMain parent) { InitializeComponent(); ControlHelper.SetDoubleBuffered(TableTop); ControlHelper.SetDoubleBuffered(TableBottom); ConfigurationChanged(); HPBars = new List <ShipStatusHP>(18); TableBottom.SuspendLayout(); for (int i = 0; i < 18; i++) { HPBars.Add(new ShipStatusHP()); HPBars[i].Size = new Size(80, 20); HPBars[i].Margin = new Padding(2, 0, 2, 0); HPBars[i].Anchor = AnchorStyles.None; HPBars[i].MainFont = MainFont; HPBars[i].SubFont = SubFont; HPBars[i].UsePrevValue = true; HPBars[i].ShowDifference = true; HPBars[i].MaximumDigit = 9999; if (i < 6) { TableBottom.Controls.Add(HPBars[i], 0, i + 1); } else if (i < 12) { TableBottom.Controls.Add(HPBars[i], 2, i - 5); } else { TableBottom.Controls.Add(HPBars[i], 1, i - 11); } } TableBottom.ResumeLayout(); SearchingFriend.ImageList = SearchingEnemy.ImageList = AACutin.ImageList = AirStage1Friend.ImageList = AirStage1Enemy.ImageList = AirStage2Friend.ImageList = AirStage2Enemy.ImageList = ResourceManager.Instance.Equipments; BaseLayoutPanel.Visible = false; Icon = ResourceManager.ImageToIcon(ResourceManager.Instance.Icons.Images[(int)ResourceManager.IconContent.FormBattle]); }
/// <summary> /// 味方遊撃部隊7人目のHPゲージ(通常時は連合艦隊第二艦隊旗艦のHPゲージ)を移動します。 /// </summary> private void MoveHPBar(bool hasFriend7thShip) { if (Utility.Configuration.Config.FormBattle.Display7thAsSingleLine && hasFriend7thShip) { if (_hpBarMoved) return; TableBottom.SetCellPosition(HPBars[BattleIndex.FriendEscort1], new TableLayoutPanelCellPosition(0, 7)); bool fixSize = Utility.Configuration.Config.UI.IsLayoutFixed; bool showHPBar = Utility.Configuration.Config.FormBattle.ShowHPBar; ControlHelper.SetTableRowStyle(TableBottom, 7, fixSize ? new RowStyle(SizeType.Absolute, showHPBar ? 21 : 16) : new RowStyle(SizeType.AutoSize)); _hpBarMoved = true; } else { if (!_hpBarMoved) return; TableBottom.SetCellPosition(HPBars[BattleIndex.FriendEscort1], new TableLayoutPanelCellPosition(1, 1)); ControlHelper.SetTableRowStyle(TableBottom, 7, new RowStyle(SizeType.Absolute, 0)); _hpBarMoved = false; } }
private void Updated(string apiname, dynamic data) { KCDatabase db = KCDatabase.Instance; BattleManager bm = db.Battle; bool hideDuringBattle = Utility.Configuration.Config.FormBattle.HideDuringBattle; BaseLayoutPanel.SuspendLayout(); TableTop.SuspendLayout(); TableBottom.SuspendLayout(); switch (apiname) { case "api_port/port": BaseLayoutPanel.Visible = false; ToolTipInfo.RemoveAll(); break; case "api_req_map/start": case "api_req_map/next": if (!bm.Compass.HasAirRaid) goto case "api_port/port"; SetFormation(bm); ClearSearchingResult(); ClearBaseAirAttack(); SetAerialWarfare(null, ((BattleBaseAirRaid)bm.BattleDay).BaseAirRaid); SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; break; case "api_req_sortie/battle": case "api_req_practice/battle": case "api_req_sortie/ld_airbattle": case "api_req_sortie/ld_shooting": { SetFormation(bm); SetSearchingResult(bm.BattleDay); SetBaseAirAttack(bm.BattleDay.BaseAirAttack); SetAerialWarfare(bm.BattleDay.JetAirBattle, bm.BattleDay.AirBattle); SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_battle_midnight/battle": case "api_req_practice/midnight_battle": { SetNightBattleEvent(bm.BattleNight.NightInitial); SetHPBar(bm.BattleNight); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_battle_midnight/sp_midnight": { SetFormation(bm); ClearBaseAirAttack(); ClearAerialWarfare(); ClearSearchingResult(); SetNightBattleEvent(bm.BattleNight.NightInitial); SetHPBar(bm.BattleNight); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_sortie/airbattle": { SetFormation(bm); SetSearchingResult(bm.BattleDay); SetBaseAirAttack(bm.BattleDay.BaseAirAttack); SetAerialWarfare(bm.BattleDay.JetAirBattle, bm.BattleDay.AirBattle, ((BattleAirBattle)bm.BattleDay).AirBattle2); SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_sortie/night_to_day": { // 暫定 var battle = bm.BattleNight as BattleDayFromNight; SetFormation(bm); ClearAerialWarfare(); ClearSearchingResult(); ClearBaseAirAttack(); SetNightBattleEvent(battle.NightInitial); if (battle.NextToDay) { SetSearchingResult(battle); SetBaseAirAttack(battle.BaseAirAttack); SetAerialWarfare(battle.JetAirBattle, battle.AirBattle); } SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_combined_battle/battle": case "api_req_combined_battle/battle_water": case "api_req_combined_battle/ld_airbattle": case "api_req_combined_battle/ec_battle": case "api_req_combined_battle/each_battle": case "api_req_combined_battle/each_battle_water": case "api_req_combined_battle/ld_shooting": { SetFormation(bm); SetSearchingResult(bm.BattleDay); SetBaseAirAttack(bm.BattleDay.BaseAirAttack); SetAerialWarfare(bm.BattleDay.JetAirBattle, bm.BattleDay.AirBattle); SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_combined_battle/airbattle": { SetFormation(bm); SetSearchingResult(bm.BattleDay); SetBaseAirAttack(bm.BattleDay.BaseAirAttack); SetAerialWarfare(bm.BattleDay.JetAirBattle, bm.BattleDay.AirBattle, ((BattleCombinedAirBattle)bm.BattleDay).AirBattle2); SetHPBar(bm.BattleDay); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_combined_battle/midnight_battle": case "api_req_combined_battle/ec_midnight_battle": { SetNightBattleEvent(bm.BattleNight.NightInitial); SetHPBar(bm.BattleNight); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_combined_battle/sp_midnight": { SetFormation(bm); ClearAerialWarfare(); ClearSearchingResult(); ClearBaseAirAttack(); SetNightBattleEvent(bm.BattleNight.NightInitial); SetHPBar(bm.BattleNight); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_combined_battle/ec_night_to_day": { var battle = bm.BattleNight as BattleDayFromNight; SetFormation(bm); ClearAerialWarfare(); ClearSearchingResult(); ClearBaseAirAttack(); SetNightBattleEvent(battle.NightInitial); if (battle.NextToDay) { SetSearchingResult(battle); SetBaseAirAttack(battle.BaseAirAttack); SetAerialWarfare(battle.JetAirBattle, battle.AirBattle); } SetHPBar(battle); SetDamageRate(bm); BaseLayoutPanel.Visible = !hideDuringBattle; } break; case "api_req_sortie/battleresult": case "api_req_combined_battle/battleresult": case "api_req_practice/battle_result": { SetMVPShip(bm); BaseLayoutPanel.Visible = true; } break; } TableTop.ResumeLayout(); TableBottom.ResumeLayout(); BaseLayoutPanel.ResumeLayout(); if (Utility.Configuration.Config.UI.IsLayoutFixed) TableTop.Width = TableTop.GetPreferredSize(BaseLayoutPanel.Size).Width; else TableTop.Width = TableBottom.ClientSize.Width; TableTop.Height = TableTop.GetPreferredSize(BaseLayoutPanel.Size).Height; }
void ConfigurationChanged() { var config = Utility.Configuration.Config; MainFont = TableTop.Font = TableBottom.Font = Font = config.UI.MainFont; SubFont = config.UI.SubFont; BaseLayoutPanel.AutoScroll = config.FormBattle.IsScrollable; bool fixSize = config.UI.IsLayoutFixed; bool showHPBar = config.FormBattle.ShowHPBar; TableBottom.SuspendLayout(); if (fixSize) { ControlHelper.SetTableColumnStyles(TableBottom, new ColumnStyle(SizeType.AutoSize)); ControlHelper.SetTableRowStyle(TableBottom, 0, new RowStyle(SizeType.Absolute, 21)); for (int i = 1; i <= 6; i++) ControlHelper.SetTableRowStyle(TableBottom, i, new RowStyle(SizeType.Absolute, showHPBar ? 21 : 16)); ControlHelper.SetTableRowStyle(TableBottom, 8, new RowStyle(SizeType.Absolute, 21)); } else { ControlHelper.SetTableColumnStyles(TableBottom, new ColumnStyle(SizeType.AutoSize)); ControlHelper.SetTableRowStyles(TableBottom, new RowStyle(SizeType.AutoSize)); } if (HPBars != null) { foreach (var b in HPBars) { b.MainFont = MainFont; b.SubFont = SubFont; b.AutoSize = !fixSize; if (!b.AutoSize) { b.Size = (HPBars[12].Visible && HPBars[18].Visible) ? SmallBarSize : DefaultBarSize; } b.HPBar.ColorMorphing = config.UI.BarColorMorphing; b.HPBar.SetBarColorScheme(config.UI.BarColorScheme.Select(col => col.ColorData).ToArray()); b.ShowHPBar = showHPBar; } } FleetFriend.MaximumSize = FleetFriendEscort.MaximumSize = FleetEnemy.MaximumSize = FleetEnemyEscort.MaximumSize = DamageFriend.MaximumSize = DamageEnemy.MaximumSize = fixSize ? DefaultBarSize : Size.Empty; WinRank.MinimumSize = fixSize ? new Size(80, 0) : new Size(HPBars[0].Width, 0); TableBottom.ResumeLayout(); TableTop.SuspendLayout(); if (fixSize) { ControlHelper.SetTableColumnStyles(TableTop, new ColumnStyle(SizeType.Absolute, 21 * 4)); ControlHelper.SetTableRowStyles(TableTop, new RowStyle(SizeType.Absolute, 21)); TableTop.Width = TableTop.GetPreferredSize(BaseLayoutPanel.Size).Width; } else { ControlHelper.SetTableColumnStyles(TableTop, new ColumnStyle(SizeType.Percent, 100)); ControlHelper.SetTableRowStyles(TableTop, new RowStyle(SizeType.AutoSize)); TableTop.Width = TableBottom.ClientSize.Width; } TableTop.Height = TableTop.GetPreferredSize(BaseLayoutPanel.Size).Height; TableTop.ResumeLayout(); }
private void Updated(string apiname, dynamic data) { KCDatabase db = KCDatabase.Instance; BattleManager bm = db.Battle; BaseLayoutPanel.SuspendLayout(); TableTop.SuspendLayout(); TableBottom.SuspendLayout(); switch (apiname) { case "api_req_map/start": case "api_req_map/next": case "api_port/port": BaseLayoutPanel.Visible = false; ToolTipInfo.RemoveAll(); break; case "api_req_sortie/battle": case "api_req_practice/battle": { int[] hp = bm.BattleDay.EmulateBattle(); SetFormation(bm.BattleDay); SetSearchingResult(bm.BattleDay); SetAerialWarfare(bm.BattleDay); SetHPNormal(hp, bm.BattleDay); SetDamageRateNormal(hp, bm.BattleDay); BaseLayoutPanel.Visible = true; } break; case "api_req_battle_midnight/battle": case "api_req_practice/midnight_battle": { int[] hp = bm.BattleNight.EmulateBattle(); SetNightBattleEvent(hp, false, bm.BattleNight); SetHPNormal(hp, bm.BattleNight); SetDamageRateNormal(hp, bm.BattleDay); BaseLayoutPanel.Visible = true; } break; case "api_req_battle_midnight/sp_midnight": { int[] hp = bm.BattleNight.EmulateBattle(); SetFormation(bm.BattleNight); ClearAerialWarfare(); ClearSearchingResult(); SetNightBattleEvent(hp, false, bm.BattleNight); SetHPNormal(hp, bm.BattleNight); SetDamageRateNormal(hp, bm.BattleNight); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/battle": case "api_req_combined_battle/battle_water": { int[] hp = bm.BattleDay.EmulateBattle(); SetFormation(bm.BattleDay); SetSearchingResult(bm.BattleDay); SetAerialWarfare(bm.BattleDay); SetHPCombined(hp, bm.BattleDay); SetDamageRateCombined(hp, bm.BattleDay); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/airbattle": { int[] hp = bm.BattleDay.EmulateBattle(); SetFormation(bm.BattleDay); SetSearchingResult(bm.BattleDay); SetAerialWarfareAirBattle(bm.BattleDay); SetHPCombined(hp, bm.BattleDay); SetDamageRateCombined(hp, bm.BattleDay); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/midnight_battle": { int[] hp = bm.BattleNight.EmulateBattle(); SetNightBattleEvent(hp, true, bm.BattleNight); SetHPCombined(hp, bm.BattleNight); SetDamageRateCombined(hp, bm.BattleDay); BaseLayoutPanel.Visible = true; } break; case "api_req_combined_battle/sp_midnight": { int[] hp = bm.BattleNight.EmulateBattle(); SetFormation(bm.BattleNight); ClearAerialWarfare(); ClearSearchingResult(); SetNightBattleEvent(hp, true, bm.BattleNight); SetHPCombined(hp, bm.BattleNight); SetDamageRateCombined(hp, bm.BattleNight); BaseLayoutPanel.Visible = true; } break; } TableTop.ResumeLayout(); TableBottom.ResumeLayout(); BaseLayoutPanel.ResumeLayout(); }