Просмотр исходного кода

Make HUD.visible obsolete

customisations
alemart 5 месяцев назад
Родитель
Сommit
4c7474d1c0
2 измененных файлов: 28 добавлений и 6 удалений
  1. 6
    2
      docs/api/hud.md
  2. 22
    4
      src/core/hud.ts

+ 6
- 2
docs/api/hud.md Просмотреть файл

@@ -12,6 +12,10 @@ The container of the HUD.
12 12
 
13 13
 ### visible
14 14
 
15
-`hud.visible: boolean`
15
+<span style="text-decoration: line-through">`hud.visible: boolean, read-only`</span>
16 16
 
17
-Whether or not the HUD is visible.
17
+Whether or not the HUD is visible.
18
+
19
+*Deprecated since:* 0.4.3
20
+
21
+*Note:* this property is read-only since 0.4.3

+ 22
- 4
src/core/hud.ts Просмотреть файл

@@ -92,18 +92,20 @@ export class HUD
92 92
 
93 93
     /**
94 94
      * Whether or not the HUD is visible
95
+     * @deprecated what's the purpose of this being public?
95 96
      */
96 97
     get visible(): boolean
97 98
     {
98
-        return !this._container.hidden;
99
+        return this._visible;
99 100
     }
100 101
 
101 102
     /**
102 103
      * Whether or not the HUD is visible
104
+     * @deprecated what's the purpose of this being public?
103 105
      */
104 106
     set visible(visible: boolean)
105 107
     {
106
-        this._container.hidden = !visible;
108
+        // this setter does nothing since 0.4.3
107 109
     }
108 110
 
109 111
     /**
@@ -136,7 +138,7 @@ export class HUD
136 138
         container.style.zIndex = String(zIndex);
137 139
         container.style.userSelect = 'none';
138 140
 
139
-        this.visible = true;
141
+        this._visible = true;
140 142
     }
141 143
 
142 144
     /**
@@ -145,7 +147,7 @@ export class HUD
145 147
      */
146 148
     _release(): void
147 149
     {
148
-        this.visible = false;
150
+        this._visible = false;
149 151
 
150 152
         this.#fullscreenButton.release();
151 153
         this.#statsPanel.release();
@@ -170,4 +172,20 @@ export class HUD
170 172
 
171 173
         return node;
172 174
     }
175
+
176
+    /**
177
+     * Whether or not the HUD is visible
178
+     */
179
+    private get _visible(): boolean
180
+    {
181
+        return !this._container.hidden;
182
+    }
183
+
184
+    /**
185
+     * Whether or not the HUD is visible
186
+     */
187
+    private set _visible(visible: boolean)
188
+    {
189
+        this._container.hidden = !visible;
190
+    }
173 191
 }

Загрузка…
Отмена
Сохранить