@@ -42,9 +42,11 @@ public class NewTilesetDialog extends JDialog implements ChangeListener
42
42
private TileSet newTileset ;
43
43
private IntegerSpinner tileWidth , tileHeight ;
44
44
private IntegerSpinner tileSpacing ;
45
+ private IntegerSpinner tileMargin ;
45
46
private JTextField tilesetName ;
46
47
private JTextField tilebmpFile ;
47
48
private JLabel spacingLabel ;
49
+ private JLabel marginLabel ;
48
50
private JLabel tilebmpFileLabel , cutterLabel ;
49
51
private JCheckBox tilebmpCheck ;
50
52
private JCheckBox transCheck ;
@@ -63,6 +65,7 @@ public class NewTilesetDialog extends JDialog implements ChangeListener
63
65
private static final String TILE_WIDTH_LABEL = Resources .getString ("dialog.newtileset.tilewidth.label" );
64
66
private static final String TILE_HEIGHT_LABEL = Resources .getString ("dialog.newtileset.tileheight.label" );
65
67
private static final String TILE_SPACING_LABEL = Resources .getString ("dialog.newtileset.tilespacing.label" );
68
+ private static final String TILE_MARGIN_LABEL = Resources .getString ("dialog.newtileset.tilemargin.label" );
66
69
private static final String IMAGE_LABEL = Resources .getString ("dialog.newtileset.image.label" );
67
70
private static final String UNTITLED_FILE = Resources .getString ("general.file.untitled" );
68
71
private static final String TILESET_IMG_LABEL = Resources .getString ("dialog.newtileset.tilesetimgref.label" );
@@ -96,20 +99,23 @@ private void init() {
96
99
JLabel tileWidthLabel = new JLabel (TILE_WIDTH_LABEL );
97
100
JLabel tileHeightLabel = new JLabel (TILE_HEIGHT_LABEL );
98
101
spacingLabel = new JLabel (TILE_SPACING_LABEL );
102
+ marginLabel = new JLabel (TILE_MARGIN_LABEL );
99
103
tilebmpFileLabel = new JLabel (IMAGE_LABEL );
100
104
cutterLabel = new JLabel ("Tile Cutter: " );
101
105
102
106
tilesetName = new JTextField (UNTITLED_FILE );
103
107
tileWidth = new IntegerSpinner (map .getTileWidth (), 1 , 1024 );
104
108
tileHeight = new IntegerSpinner (map .getTileHeight (), 1 , 1024 );
105
109
tileSpacing = new IntegerSpinner (0 , 0 );
110
+ tileMargin = new IntegerSpinner (0 , 0 );
106
111
tilebmpFile = new JTextField (10 );
107
112
tilebmpFile .setEnabled (false );
108
113
109
114
nameLabel .setLabelFor (tilesetName );
110
115
tileWidthLabel .setLabelFor (tileWidth );
111
116
tileHeightLabel .setLabelFor (tileHeight );
112
117
spacingLabel .setLabelFor (tileSpacing );
118
+ marginLabel .setLabelFor (tileMargin );
113
119
tilebmpFileLabel .setLabelFor (tilebmpFile );
114
120
115
121
tileWidthLabel .setEnabled (false );
@@ -173,7 +179,7 @@ private void init() {
173
179
c .insets = new Insets (5 , 0 , 0 , 0 );
174
180
c .anchor = GridBagConstraints .EAST ;
175
181
c .fill = GridBagConstraints .HORIZONTAL ;
176
- c .gridwidth = 2 ;
182
+ c .gridwidth = 4 ;
177
183
tilebmpPanel .add (tilebmpCheck , c );
178
184
c .gridy = 1 ;
179
185
c .gridwidth = 1 ;
@@ -191,7 +197,9 @@ private void init() {
191
197
c .weightx = 1 ;
192
198
c .insets = new Insets (5 , 0 , 0 , 0 );
193
199
c .fill = GridBagConstraints .HORIZONTAL ;
200
+ c .gridwidth = 3 ;
194
201
tilebmpPanel .add (tilebmpPathPanel , c );
202
+ c .gridwidth = 1 ;
195
203
c .gridy = 2 ;
196
204
tilebmpPanel .add (tileSpacing , c );
197
205
/*
@@ -200,8 +208,17 @@ private void init() {
200
208
*/
201
209
c .gridx = 0 ;
202
210
c .gridy = 4 ;
203
- c .gridwidth = 2 ;
211
+ c .gridwidth = 4 ;
204
212
tilebmpPanel .add (tileColorPanel , c );
213
+ c .gridx = 2 ;
214
+ c .gridy = 2 ;
215
+ c .gridwidth = 1 ;
216
+ c .weightx = 0 ;
217
+ c .insets = new Insets (5 , 5 , 0 , 0 );
218
+ tilebmpPanel .add (marginLabel , c );
219
+ c .gridx = 3 ;
220
+ c .weightx = 1 ;
221
+ tilebmpPanel .add (tileMargin , c );
205
222
c .gridx = 1 ;
206
223
c .gridwidth = 1 ;
207
224
@@ -313,10 +330,10 @@ public TileSet create() {
313
330
return newTileset ;
314
331
}
315
332
316
- public TileCutter getCutter (int w , int h , int s ) {
333
+ public TileCutter getCutter (int w , int h , int spacing , int margin ) {
317
334
final String selectedItem = (String ) cutterBox .getSelectedItem ();
318
335
if (selectedItem .equalsIgnoreCase ("basic" )) {
319
- return new BasicTileCutter (w , h , s , 0 );
336
+ return new BasicTileCutter (w , h , spacing , margin );
320
337
} else if (selectedItem .equalsIgnoreCase ("border" )) {
321
338
return new BorderTileCutter ();
322
339
}
@@ -330,10 +347,11 @@ private void createSetAndDispose() {
330
347
newTileset .setDefaultProperties (defaultSetProperties );
331
348
332
349
if (tilebmpCheck .isSelected ()) {
333
- String file = tilebmpFile .getText ();
334
- int spacing = tileSpacing .intValue ();
335
- int width = tileWidth .intValue ();
336
- int height = tileHeight .intValue ();
350
+ final String file = tilebmpFile .getText ();
351
+ final int spacing = tileSpacing .intValue ();
352
+ final int margin = tileMargin .intValue ();
353
+ final int width = tileWidth .intValue ();
354
+ final int height = tileHeight .intValue ();
337
355
338
356
try {
339
357
if (transCheck .isSelected ()) {
@@ -342,7 +360,7 @@ private void createSetAndDispose() {
342
360
}
343
361
344
362
newTileset .importTileBitmap (file ,
345
- getCutter (width , height , spacing ));
363
+ getCutter (width , height , spacing , margin ));
346
364
}
347
365
catch (IOException e ) {
348
366
JOptionPane .showMessageDialog (this , e .getLocalizedMessage (),
@@ -386,7 +404,9 @@ private void setUseTileBitmap(boolean value) {
386
404
tilebmpFileLabel .setEnabled (value );
387
405
browseButton .setEnabled (value );
388
406
tileSpacing .setEnabled (value );
407
+ tileMargin .setEnabled (value );
389
408
spacingLabel .setEnabled (value );
409
+ marginLabel .setEnabled (value );
390
410
transCheck .setEnabled (value );
391
411
colorButton .setEnabled (value && transCheck .isSelected ());
392
412
/*
0 commit comments