OSDN Git Service

6隻未満でHPのパーセント表示を切り替えると表示がおかしくなるのを直す
authorKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 21 Jun 2019 12:34:09 +0000 (21:34 +0900)
committerKazuhiro Fujieda <fujieda@users.osdn.me>
Fri, 21 Jun 2019 12:34:09 +0000 (21:34 +0900)
KancolleSniffer/View/ShipLabel.cs

index a19c518..c9e3477 100644 (file)
@@ -27,7 +27,6 @@ namespace KancolleSniffer.View
     public abstract class ShipLabel : GrowLeftLabel\r
     {\r
         protected Color InitialBackColor;\r
-        protected ShipStatus Status;\r
 \r
         protected Font BaseFont => Parent.Font;\r
 \r
@@ -204,6 +203,7 @@ namespace KancolleSniffer.View
         public sealed class Hp : ShipLabel\r
         {\r
             private bool _hpPercent;\r
+            private ShipStatus _status;\r
 \r
             public Hp()\r
             {\r
@@ -220,13 +220,14 @@ namespace KancolleSniffer.View
 \r
             public override void Reset()\r
             {\r
+                _status = null;\r
                 Text = "";\r
                 BackColor = InitialBackColor;\r
             }\r
 \r
             public override void Set(ShipStatus status)\r
             {\r
-                Status = status;\r
+                _status = status;\r
                 Font = BaseFont;\r
                 Text = _hpPercent\r
                     ? $"{(int)Floor(status.NowHp * 100.0 / status.MaxHp):D}%"\r
@@ -237,8 +238,8 @@ namespace KancolleSniffer.View
             public void ToggleHpPercent()\r
             {\r
                 _hpPercent = !_hpPercent;\r
-                if (Status != null)\r
-                    Set(Status);\r
+                if (_status != null)\r
+                    Set(_status);\r
             }\r
 \r
             public void SetHp(int now, int max)\r