瀏覽代碼

Modify the panel

customisations
alemart 1 年之前
父節點
當前提交
d13bf1e20a
共有 1 個文件被更改,包括 47 次插入14 次删除
  1. 47
    14
      src/core/stats-panel.ts

+ 47
- 14
src/core/stats-panel.ts 查看文件

@@ -181,23 +181,56 @@ export class StatsPanel
181 181
      */
182 182
     private _createContainer(): HTMLDivElement
183 183
     {
184
-        const container = document.createElement('div') as HTMLDivElement;
185
-        const print = (html: string) => container.insertAdjacentHTML('beforeend', html);
184
+        const container = document.createElement('div');
186 185
 
187 186
         container.style.position = 'absolute';
188 187
         container.style.left = container.style.top = '0px';
189 188
         container.style.zIndex = '1000000';
190
-        container.style.padding = '4px';
191
-        container.style.whiteSpace = 'pre-line';
192
-        container.style.backgroundColor = 'rgba(0,0,0,0.5)';
193
-        container.style.color = 'white';
194
-        container.style.fontFamily = 'monospace';
195
-        container.style.fontSize = '14px';
189
+        container.style.padding = '0px';
196 190
 
197
-        // all sanitized
198
-        container.innerText = 'encantAR.js ' + AR.version;
191
+        container.appendChild(this._createTitle());
192
+        container.appendChild(this._createContent());
199 193
 
200
-        print('<br>');
194
+        return container;
195
+    }
196
+
197
+    /**
198
+     * Create a title
199
+     * @returns a title
200
+     */
201
+    private _createTitle(): HTMLElement
202
+    {
203
+        const title = document.createElement('div');
204
+
205
+        title.style.backgroundColor = '#7e56c2';
206
+        title.style.color = 'white';
207
+        title.style.fontFamily = 'monospace';
208
+        title.style.fontSize = '14px';
209
+        title.style.fontWeight = 'bold';
210
+        title.style.padding = '2px';
211
+        title.innerHTML = '&#x2728;';
212
+        title.innerText += 'encantAR.js ' + AR.version;
213
+
214
+        return title;
215
+    }
216
+
217
+    /**
218
+     * Create a content container
219
+     * @returns a content container
220
+     */
221
+    private _createContent(): HTMLElement
222
+    {
223
+        const content = document.createElement('div');
224
+        const print = (html: string): void => content.insertAdjacentHTML('beforeend', html);
225
+
226
+        content.style.backgroundColor = 'rgba(0,0,0,0.5)';
227
+        content.style.color = 'white';
228
+        content.style.fontFamily = 'monospace';
229
+        content.style.fontSize = '14px';
230
+        content.style.padding = '2px';
231
+        content.style.whiteSpace = 'pre-line';
232
+
233
+        // all sanitized
201 234
         print('FPS: <span class="_ar_fps"></span> | ');
202 235
         print('GPU: <span class="_ar_gpu"></span> ');
203 236
         print('<span class="_ar_power"></span>');
@@ -210,10 +243,10 @@ export class StatsPanel
210 243
 
211 244
         if(this._viewport.fullscreenAvailable) {
212 245
             print('<br>');
213
-            container.appendChild(this._createFullscreenToggle());
246
+            content.appendChild(this._createFullscreenToggle());
214 247
         }
215 248
 
216
-        return container;
249
+        return content;
217 250
     }
218 251
 
219 252
     /**
@@ -222,7 +255,7 @@ export class StatsPanel
222 255
      */
223 256
     private _createFullscreenToggle(): HTMLElement
224 257
     {
225
-        const toggle = document.createElement('a') as HTMLAnchorElement;
258
+        const toggle = document.createElement('a');
226 259
 
227 260
         Utils.assert(this._viewport != null);
228 261
 

Loading…
取消
儲存