@@ -10,7 +10,6 @@ function SetDialog(id, json) {
1010 menuContentDiv . style . width = ( json . columns . length * 300 ) + "px" ; ;
1111 if ( json . title !== undefined ) {
1212 if ( json . title . length > 0 ) {
13- menuContentDiv . appendChild ( document . createElement ( "hr" ) ) ;
1413 let titleH = document . createElement ( "h1" ) ;
1514 titleH . className = "menu-title" ;
1615 titleH . appendChild ( document . createTextNode ( json . title ) ) ;
@@ -31,33 +30,30 @@ function SetDialog(id, json) {
3130 gridElement . className = "row" ;
3231 gridElement . style . width = ( json . columns . length * 300 ) + "px" ;
3332 gridElement . style . marginLeft = "0px" ;
33+ let rendered = 0 ;
3434 for ( let colId = 0 ; colId < json . columns . length ; colId ++ ) {
3535 let column = json . columns [ colId ] ;
3636 let colElement = document . createElement ( "div" ) ;
3737 switch ( json . columns . length ) {
3838 case 1 :
39- colElement . className = "col-md-12" ;
39+ colElement . className = "col-md-12 spl-c1-1 " ;
4040 break ;
4141 case 2 :
42- colElement . className = "col-md-6" ;
42+ colElement . className = "col-md-6 spl-c2-" + ( colId + 1 ) ;
4343 break ;
4444 case 3 :
45- colElement . className = "col-md-4" ;
46- break ;
47- case 4 :
48- colElement . className = "col-md-3" ;
45+ colElement . className = "col-md-4 spl-c3-" + ( colId + 1 ) ;
4946 break ;
5047 }
5148 if ( column . inputs !== undefined && column . inputs . length > 0 ) {
52- let rendered = 0 ;
5349 for ( let jsonInput of column . inputs ) {
5450 if ( jsonInput . type === "text" ) {
5551 let inputElement = document . createElement ( "input" ) ;
5652 inputElement . className = "menu-input-text" ;
5753 if ( jsonInput . name . length > 0 ) {
5854 let labelElement = document . createElement ( "label" ) ;
5955 labelElement . className = "menu-label" ;
60- labelElement . appendChild ( document . createTextNode ( jsonInput . name + ':' ) ) ;
56+ labelElement . appendChild ( document . createTextNode ( jsonInput . name ) ) ;
6157 colElement . appendChild ( labelElement ) ;
6258 colElement . appendChild ( inputElement ) ;
6359 rendered ++ ;
@@ -88,7 +84,7 @@ function SetDialog(id, json) {
8884 if ( jsonInput . name !== undefined ) {
8985 let labelElement = document . createElement ( "label" ) ;
9086 labelElement . className = "menu-label" ;
91- labelElement . appendChild ( document . createTextNode ( jsonInput . name + ':' ) ) ;
87+ labelElement . appendChild ( document . createTextNode ( jsonInput . name ) ) ;
9288 colElement . appendChild ( labelElement ) ;
9389 }
9490 colElement . appendChild ( selectElement ) ;
@@ -112,9 +108,30 @@ function SetDialog(id, json) {
112108 inputs . push ( checkboxElement ) ;
113109 }
114110 }
115- if ( rendered > 0 ) {
116- colElement . appendChild ( document . createElement ( "hr" ) ) ;
117- }
111+ }
112+ gridElement . appendChild ( colElement ) ;
113+ }
114+ menuContentDiv . appendChild ( gridElement ) ;
115+ if ( rendered > 0 ) {
116+ menuContentDiv . appendChild ( document . createElement ( "hr" ) ) ;
117+ }
118+ gridElement = document . createElement ( "div" ) ;
119+ gridElement . className = "row" ;
120+ gridElement . style . width = ( json . columns . length * 300 ) + "px" ;
121+ gridElement . style . marginLeft = "0px" ;
122+ for ( let colId = 0 ; colId < json . columns . length ; colId ++ ) {
123+ let column = json . columns [ colId ] ;
124+ let colElement = document . createElement ( "div" ) ;
125+ switch ( json . columns . length ) {
126+ case 1 :
127+ colElement . className = "col-md-12 spl-c1-1" ;
128+ break ;
129+ case 2 :
130+ colElement . className = "col-md-6 spl-c2-" + ( colId + 1 ) ;
131+ break ;
132+ case 3 :
133+ colElement . className = "col-md-4 spl-c3-" + ( colId + 1 ) ;
134+ break ;
118135 }
119136 for ( let i = 0 ; i < column . buttons . length ; i ++ ) {
120137 if ( column . buttons [ i ] . length == 0 ) {
@@ -145,6 +162,32 @@ function SetDialog(id, json) {
145162 gridElement . appendChild ( colElement ) ;
146163 }
147164 menuContentDiv . appendChild ( gridElement ) ;
165+ for ( let i = 0 ; i < json . buttons . length ; i ++ ) {
166+ if ( json . buttons [ i ] . length == 0 ) {
167+ continue ;
168+ }
169+ let buttonElement = document . createElement ( "button" ) ;
170+ buttonElement . className = "menu-button" ;
171+ buttonElement . appendChild ( document . createTextNode ( json . buttons [ i ] ) ) ;
172+ let buttonId = nextButtonId ;
173+ nextButtonId ++ ;
174+ buttonElement . onclick = function ( ) {
175+ let params = [ id , buttonId ] ;
176+ for ( let input of inputs ) {
177+ if ( input . type === "checkbox" ) {
178+ params . push ( input . checked ) ;
179+ } else {
180+ params . push ( input . value ) ;
181+ }
182+ }
183+ if ( json . autoclose === undefined || json . autoclose ) {
184+ CloseDialog ( ) ;
185+ ue . game . callevent ( "__dialog_system_closed" , "[]" ) ;
186+ }
187+ ue . game . callevent ( "OnDialogSubmit" , JSON . stringify ( params ) ) ;
188+ } ;
189+ menuContentDiv . appendChild ( buttonElement ) ;
190+ }
148191 menuDiv . appendChild ( menuContentDiv ) ;
149192}
150193
0 commit comments