@@ -39,7 +39,9 @@ public SpriteExportDialog()
3939 btnCopy . Tapped += BtnCopy_Tapped ;
4040 btnExport . Tapped += BtnExport_Tapped ;
4141 btnOutputFile . Tapped += BtnOutputFile_Tapped ;
42+ cmbDataType . SelectionChanged += CmbDataType_SelectionChanged ;
4243 cmbArrayBase . SelectionChanged += CmbArrayBase_SelectionChanged ;
44+ chkAttr . Click += ChkAttr_Click ;
4345 btnSave . Tapped += BtnSave_Tapped ;
4446 }
4547
@@ -61,6 +63,7 @@ public bool Initialize(string fileName, IEnumerable<Sprite> spritesData)
6163 txtOutputFile . Text = exportConfig . ExportFilePath ;
6264 txtLabelName . Text = exportConfig . LabelName ;
6365 chkAuto . IsChecked = exportConfig . AutoExport ;
66+ cmbDataType . SelectedIndex = ( int ) exportConfig . ExportDataType ;
6467 cmbArrayBase . SelectedIndex = exportConfig . ArrayBase . ToInteger ( ) ;
6568 chkAttr . IsChecked = exportConfig . IncludeAttr ;
6669
@@ -75,7 +78,12 @@ public bool Initialize(string fileName, IEnumerable<Sprite> spritesData)
7578 private void ExportType_Changed ( ExportTypes exportType )
7679 {
7780 exportConfig . ExportType = exportType ;
81+ Refresh ( ) ;
82+ }
83+
7884
85+ private void Refresh ( )
86+ {
7987 grdOptions . IsVisible = true ;
8088
8189 chkAuto . IsVisible = true ;
@@ -88,6 +96,7 @@ private void ExportType_Changed(ExportTypes exportType)
8896 txtLabelName . IsVisible = true ;
8997
9098 lblArrayBase . IsVisible = true ;
99+ cmbDataType . IsVisible = true ;
91100 cmbArrayBase . IsVisible = true ;
92101
93102 bool canExport = false ;
@@ -101,7 +110,7 @@ private void ExportType_Changed(ExportTypes exportType)
101110 txtError . IsVisible = false ;
102111 }
103112
104- switch ( exportType )
113+ switch ( exportConfig . ExportType )
105114 {
106115 case ExportTypes . PutChars :
107116 CreateExportPath ( ".bas" ) ;
@@ -145,6 +154,7 @@ private void GetConfigFromUI()
145154 }
146155 exportConfig . ArrayBase = cmbArrayBase . SelectedIndex . ToInteger ( ) ;
147156 exportConfig . AutoExport = chkAuto . IsChecked == true ;
157+ exportConfig . ExportDataType = ( ExportDataTypes ) cmbDataType . SelectedIndex . ToInteger ( ) ;
148158 exportConfig . ExportFilePath = txtOutputFile . Text . ToStringNoNull ( ) ;
149159 exportConfig . ExportType = cmbSelectExportType . ExportType ;
150160 exportConfig . LabelName = txtLabelName . Text . ToStringNoNull ( ) ;
@@ -160,24 +170,53 @@ private void CreateExample_PutChars()
160170 txtCode . Text = "" ;
161171 }
162172
163- GetConfigFromUI ( ) ;
164173 var sb = new StringBuilder ( ) ;
165- sb . AppendLine ( "'- Includes -----------------------------------------------" ) ;
166- sb . AppendLine ( "#INCLUDE <putchars.bas>" ) ;
167- sb . AppendLine ( "" ) ;
168- sb . AppendLine ( ExportManager . Export_Sprite_PutChars ( exportConfig , sprites ) ) ;
169- sb . AppendLine ( "" ) ;
170- sb . AppendLine ( "'- Draw sprite --------------------------------------------" ) ;
171-
172- var sprite = sprites . ElementAt ( 0 ) ;
173- sb . AppendLine ( string . Format (
174- "putChars(10,5,{0},{1},@{2}{3}({4}))" ,
175- sprite . Width / 8 ,
176- sprite . Height / 8 ,
177- exportConfig . LabelName ,
178- sprite . Name . Replace ( " " , "_" ) ,
179- sprite . Frames == 1 ? "0" : "0,0" ) ) ;
180- sb . AppendLine ( "" ) ;
174+ switch ( exportConfig . ExportDataType )
175+ {
176+ case ExportDataTypes . DIM :
177+ {
178+ sb . AppendLine ( "'- Includes -----------------------------------------------" ) ;
179+ sb . AppendLine ( "#INCLUDE <putchars.bas>" ) ;
180+ sb . AppendLine ( "" ) ;
181+ sb . AppendLine ( string . Format ( "' Can use: #INCLUDE \" {0}\" " ,
182+ Path . GetFileName ( exportConfig . ExportFilePath ) ) ) ;
183+ sb . AppendLine ( ExportManager . Export_Sprite_PutChars ( exportConfig , sprites ) ) ;
184+ sb . AppendLine ( "" ) ;
185+ sb . AppendLine ( "'- Draw sprite --------------------------------------------" ) ;
186+
187+ var sprite = sprites . ElementAt ( 0 ) ;
188+ sb . AppendLine ( string . Format (
189+ "putChars(10,5,{0},{1},@{2}{3}({4}))" ,
190+ sprite . Width / 8 ,
191+ sprite . Height / 8 ,
192+ exportConfig . LabelName ,
193+ sprite . Name . Replace ( " " , "_" ) ,
194+ sprite . Frames == 1 ? "0" : "0,0" ) ) ;
195+ sb . AppendLine ( "" ) ;
196+ }
197+ break ;
198+
199+ case ExportDataTypes . ASM :
200+ {
201+ sb . AppendLine ( "'- Includes -----------------------------------------------" ) ;
202+ sb . AppendLine ( "#INCLUDE <putchars.bas>" ) ;
203+ sb . AppendLine ( "" ) ;
204+ sb . AppendLine ( "'- Draw sprite --------------------------------------------" ) ;
205+ var sprite = sprites . ElementAt ( 0 ) ;
206+ sb . AppendLine ( string . Format (
207+ "putChars(10,5,{0},{1},@{2}{3})" ,
208+ sprite . Width / 8 ,
209+ sprite . Height / 8 ,
210+ exportConfig . LabelName ,
211+ sprite . Name . Replace ( " " , "_" ) ) ) ;
212+ sb . AppendLine ( "" ) ;
213+ sb . AppendLine ( "' This section must not be executed" ) ;
214+ sb . AppendLine ( string . Format ( "' Can use: #INCLUDE \" {0}\" " ,
215+ Path . GetFileName ( exportConfig . ExportFilePath ) ) ) ;
216+ sb . AppendLine ( ExportManager . Export_Sprite_PutChars ( exportConfig , sprites ) ) ;
217+ }
218+ break ;
219+ }
181220
182221 txtCode . Text = sb . ToString ( ) ;
183222 }
@@ -253,6 +292,22 @@ private void CmbArrayBase_SelectionChanged(object? sender, SelectionChangedEvent
253292 {
254293 var idx = cmbArrayBase . SelectedIndex ;
255294 exportConfig . ArrayBase = idx ;
295+ Refresh ( ) ;
296+ }
297+
298+
299+ private void CmbDataType_SelectionChanged ( object ? sender , SelectionChangedEventArgs e )
300+ {
301+ var idx = cmbDataType . SelectedIndex ;
302+ exportConfig . ExportDataType = ( ExportDataTypes ) idx ;
303+ Refresh ( ) ;
304+ }
305+
306+
307+ private void ChkAttr_Click ( object ? sender , Avalonia . Interactivity . RoutedEventArgs e )
308+ {
309+ exportConfig . IncludeAttr = chkAttr . IsChecked . ToBoolean ( ) ;
310+ Refresh ( ) ;
256311 }
257312
258313 #endregion
0 commit comments