@@ -69,52 +69,53 @@ protected void drawBorder(GC gc, Rectangle rect) {
69
69
70
70
@ Override
71
71
protected void drawMore (GC gc , int srcW , int srcH , int dstW , int dstH , int dstX , int dstY ) {
72
+ if (_spritesheet == null ) {
73
+ return ;
74
+ }
75
+
72
76
SpritesheetAssetModel spritesheet = _spritesheet ;
73
- if (spritesheet != null ) {
74
- Rectangle canvasBounds = getBounds ();
75
- List <FrameData > list ;
76
- Rectangle imgBounds = _image .getBounds ();
77
- if (_singleFrame ) {
78
- Rectangle dst = PhaserEditorUI .computeImageZoom (imgBounds , canvasBounds );
79
- list = AssetPackUI .generateSpriteSheetRects (spritesheet , imgBounds , dst );
80
- if (list .isEmpty ()) {
81
- PhaserEditorUI .paintPreviewMessage (gc , canvasBounds , "Cannot compute the grid." );
82
- } else {
83
- FrameData fd = list .get (_frame % list .size ());
84
-
85
- Rectangle r = new Rectangle (0 , 0 , fd .src .width , fd .src .height );
86
- r = PhaserEditorUI .computeImageZoom (r , getBounds ());
87
-
88
- try {
89
- gc .drawImage (_image , fd .src .x , fd .src .y , fd .src .width , fd .src .height , r .x , r .y , r .width ,
90
- r .height );
91
- } catch (IllegalArgumentException e ) {
92
- // wrong parameters
93
- }
77
+ Rectangle canvasBounds = getBounds ();
78
+ List <FrameData > list ;
79
+ Rectangle imgBounds = _image .getBounds ();
80
+ if (_singleFrame ) {
81
+ Rectangle dst = PhaserEditorUI .computeImageZoom (imgBounds , canvasBounds );
82
+ list = AssetPackUI .generateSpriteSheetRects (spritesheet , imgBounds , dst );
83
+ if (list .isEmpty ()) {
84
+ PhaserEditorUI .paintPreviewMessage (gc , canvasBounds , "Cannot compute the grid." );
85
+ } else {
86
+ FrameData fd = list .get (_frame % list .size ());
87
+
88
+ Rectangle r = new Rectangle (0 , 0 , fd .src .width , fd .src .height );
89
+ r = PhaserEditorUI .computeImageZoom (r , getBounds ());
90
+
91
+ try {
92
+ gc .drawImage (_image , fd .src .x , fd .src .y , fd .src .width , fd .src .height , r .x , r .y , r .width , r .height );
93
+ } catch (IllegalArgumentException e ) {
94
+ // wrong parameters
94
95
}
96
+ }
97
+ } else {
98
+ Rectangle dst = PhaserEditorUI .computeImageZoom (imgBounds , canvasBounds );
99
+ list = AssetPackUI .generateSpriteSheetRects (spritesheet , imgBounds , dst );
100
+ if (list .isEmpty ()) {
101
+ PhaserEditorUI .paintPreviewMessage (gc , canvasBounds , "Cannot compute the grid." );
95
102
} else {
96
- Rectangle dst = PhaserEditorUI .computeImageZoom (imgBounds , canvasBounds );
97
- list = AssetPackUI .generateSpriteSheetRects (spritesheet , imgBounds , dst );
98
- if (list .isEmpty ()) {
99
- PhaserEditorUI .paintPreviewMessage (gc , canvasBounds , "Cannot compute the grid." );
100
- } else {
101
- int i = 0 ;
102
- for (FrameData fd : list ) {
103
- gc .setForeground (getDisplay ().getSystemColor (SWT .COLOR_RED ));
104
- Rectangle r = fd .dst ;
105
- gc .drawRectangle (r .x , r .y , r .width , r .height );
106
- String label = Integer .toString (i );
107
- Point labelRect = gc .stringExtent (Integer .toString (i ));
108
- int left = r .x + r .width / 2 - labelRect .x / 2 ;
109
- int top = Math .min (r .y + r .height + 5 , getBounds ().height - labelRect .y - 5 );
110
- gc .setAlpha (200 );
111
- gc .setBackground (getDisplay ().getSystemColor (SWT .COLOR_WHITE ));
112
- gc .fillRectangle (left - 2 , top , labelRect .x + 4 , labelRect .y );
113
- gc .setAlpha (255 );
114
- gc .setForeground (getDisplay ().getSystemColor (SWT .COLOR_BLACK ));
115
- gc .drawString (label , left , top , true );
116
- i ++;
117
- }
103
+ int i = 0 ;
104
+ for (FrameData fd : list ) {
105
+ gc .setForeground (getDisplay ().getSystemColor (SWT .COLOR_RED ));
106
+ Rectangle r = fd .dst ;
107
+ gc .drawRectangle (r .x , r .y , r .width , r .height );
108
+ String label = Integer .toString (i );
109
+ Point labelRect = gc .stringExtent (Integer .toString (i ));
110
+ int left = r .x + r .width / 2 - labelRect .x / 2 ;
111
+ int top = Math .min (r .y + r .height + 5 , getBounds ().height - labelRect .y - 5 );
112
+ gc .setAlpha (200 );
113
+ gc .setBackground (getDisplay ().getSystemColor (SWT .COLOR_WHITE ));
114
+ gc .fillRectangle (left - 2 , top , labelRect .x + 4 , labelRect .y );
115
+ gc .setAlpha (255 );
116
+ gc .setForeground (getDisplay ().getSystemColor (SWT .COLOR_BLACK ));
117
+ gc .drawString (label , left , top , true );
118
+ i ++;
118
119
}
119
120
}
120
121
}
0 commit comments