@@ -39,6 +39,23 @@ class Editor
39
39
container : HTMLDivElement ,
40
40
data :
41
41
{
42
+ // editorSize:
43
+ // {
44
+ // autoLabel: HTMLLabelElement,
45
+ // manual:
46
+ // {
47
+ // label: HTMLLabelElement,
48
+ // widthInput: HTMLInputElement,
49
+ // heightInput: HTMLInputElement
50
+ // }
51
+ // },
52
+ editorBackground :
53
+ {
54
+ defaultBackground : HTMLLabelElement ,
55
+ customBackground : HTMLLabelElement ,
56
+ customBackgroundRadio : HTMLInputElement ,
57
+ customBackgroundInput : HTMLInputElement
58
+ } ,
42
59
placeholderData : HTMLLabelElement ,
43
60
sampleData : HTMLLabelElement ,
44
61
gameData : HTMLLabelElement ,
@@ -146,6 +163,23 @@ class Editor
146
163
container : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#optionsMenuContainer" ) ) ,
147
164
data :
148
165
{
166
+ // editorSize:
167
+ // {
168
+ // autoLabel: Main.ThrowIfNullOrUndefined(document.querySelector("#autoSizeRadio")),
169
+ // manual:
170
+ // {
171
+ // label: Main.ThrowIfNullOrUndefined(document.querySelector("#manualSizeRadio")),
172
+ // widthInput: Main.ThrowIfNullOrUndefined(document.querySelector("#manualSizeWidthInput")),
173
+ // heightInput: Main.ThrowIfNullOrUndefined(document.querySelector("#manualSizeHeightInput"))
174
+ // }
175
+ // },
176
+ editorBackground :
177
+ {
178
+ defaultBackground : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#defaultBackgroundRadio" ) ) ,
179
+ customBackground : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#customBackgroundRadio" ) ) ,
180
+ customBackgroundRadio : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#customBackgroundRadio > input[type='radio']" ) ) ,
181
+ customBackgroundInput : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#customBackgroundInput" ) )
182
+ } ,
149
183
placeholderData : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#placeholderDataRadio" ) ) ,
150
184
sampleData : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#sampleDataRadio" ) ) ,
151
185
gameData : Main . ThrowIfNullOrUndefined ( document . querySelector ( "#gameDataRadio" ) ) ,
@@ -304,6 +338,32 @@ class Editor
304
338
{ if ( ( < HTMLInputElement > this . optionsMenu . data . gameData . querySelector ( "input[type=radio]" ) ) . checked ) { this . ToggleDataSet ( 3 ) ; } } ) ;
305
339
( < HTMLFormElement > Main . ThrowIfNullOrUndefined ( document . querySelector ( "#ipForm" ) ) ) . addEventListener ( "submit" , ( e ) => { e . preventDefault ( ) ; } ) ;
306
340
this . optionsMenu . data . gameIP . addEventListener ( "change" , ( ) => { if ( this . dataSet == 3 ) { this . ToggleDataSet ( 3 ) ; } } ) ;
341
+ this . optionsMenu . data . editorBackground . defaultBackground . addEventListener ( "click" , ( ) =>
342
+ {
343
+ this . ui . overlay . style . backgroundImage = `url("${ Main . WEB_ROOT } /assets/images/beat-saber.jpg")` ;
344
+ this . optionsMenu . data . editorBackground . customBackgroundInput . disabled = true ;
345
+ this . optionsMenu . data . editorBackground . customBackgroundInput . value = "" ;
346
+ } ) ;
347
+ this . optionsMenu . data . editorBackground . defaultBackground . click ( ) ;
348
+ this . optionsMenu . data . editorBackground . customBackground . addEventListener ( "click" , ( ) =>
349
+ { this . optionsMenu . data . editorBackground . customBackgroundInput . disabled = false ; } ) ;
350
+ this . optionsMenu . data . editorBackground . customBackgroundInput . addEventListener ( "input" , ( e ) =>
351
+ {
352
+ if (
353
+ ! this . optionsMenu . data . editorBackground . customBackgroundRadio . checked &&
354
+ this . optionsMenu . data . editorBackground . customBackgroundInput . files !== null &&
355
+ this . optionsMenu . data . editorBackground . customBackgroundInput . files [ 0 ] !== undefined &&
356
+ this . optionsMenu . data . editorBackground . customBackgroundInput . files [ 0 ] . type . startsWith ( "image/" )
357
+ ) { return ; }
358
+
359
+ const reader = new FileReader ( ) ;
360
+ reader . onloadend = ( file ) =>
361
+ {
362
+ if ( file . target == null ) { return ; }
363
+ this . ui . overlay . style . backgroundImage = `url("${ file . target . result } ")` ;
364
+ } ;
365
+ reader . readAsDataURL ( this . optionsMenu . data . editorBackground . customBackgroundInput . files ! [ 0 ] ) ;
366
+ } ) ;
307
367
308
368
Main . ThrowIfNullOrUndefined ( document . querySelector ( "#walkthroughButton" ) ) . addEventListener ( "click" , ( ) => { this . ShowWalkthroughContainer ( ) ; } ) ;
309
369
Main . ThrowIfNullOrUndefined ( this . walkthroughContainer . querySelector ( ".background" ) ) . addEventListener ( "click" , ( ) =>
0 commit comments