1
1
package com .zzzyt .rs .client ;
2
2
3
3
import com .badlogic .gdx .ApplicationListener ;
4
+ import com .badlogic .gdx .Gdx ;
4
5
import com .badlogic .gdx .backends .gwt .GwtApplication ;
5
6
import com .badlogic .gdx .backends .gwt .GwtApplicationConfiguration ;
7
+ import com .google .gwt .event .logical .shared .ResizeEvent ;
8
+ import com .google .gwt .event .logical .shared .ResizeHandler ;
9
+ import com .google .gwt .user .client .Window ;
6
10
import com .zzzyt .rs .RocketSimulator ;
7
11
8
12
public class HtmlLauncher extends GwtApplication {
9
13
10
- // USE THIS CODE FOR A FIXED SIZE APPLICATION
11
- @ Override
12
- public GwtApplicationConfiguration getConfig () {
13
- return new GwtApplicationConfiguration (480 , 320 );
14
- }
15
- // END CODE FOR FIXED SIZE APPLICATION
14
+ // USE THIS CODE FOR A FIXED SIZE APPLICATION
15
+ // @Override
16
+ // public GwtApplicationConfiguration getConfig() {
17
+ // return new GwtApplicationConfiguration(480*3 , 320*3 );
18
+ // }
19
+ // END CODE FOR FIXED SIZE APPLICATION
16
20
17
- // UNCOMMENT THIS CODE FOR A RESIZABLE APPLICATION
18
- // PADDING is to avoid scrolling in iframes, set to 20 if you have problems
19
- // private static final int PADDING = 0;
20
- // private GwtApplicationConfiguration cfg;
21
- //
22
- // @Override
23
- // public GwtApplicationConfiguration getConfig() {
24
- // int w = Window.getClientWidth() - PADDING;
25
- // int h = Window.getClientHeight() - PADDING;
26
- // cfg = new GwtApplicationConfiguration(w, h);
27
- // Window.enableScrolling(false);
28
- // Window.setMargin("0");
29
- // Window.addResizeHandler(new ResizeListener());
30
- // cfg.preferFlash = false;
31
- // return cfg;
32
- // }
33
- //
34
- // class ResizeListener implements ResizeHandler {
35
- // @Override
36
- // public void onResize(ResizeEvent event) {
37
- // int width = event.getWidth() - PADDING;
38
- // int height = event.getHeight() - PADDING;
39
- // getRootPanel().setWidth("" + width + "px");
40
- // getRootPanel().setHeight("" + height + "px");
41
- // getApplicationListener().resize(width, height);
42
- // Gdx.graphics.setWindowedMode(width, height);
43
- // }
44
- // }
45
- // END OF CODE FOR RESIZABLE APPLICATION
21
+ // UNCOMMENT THIS CODE FOR A RESIZABLE APPLICATION
22
+ // PADDING is to avoid scrolling in iframes, set to 20 if you have problems
23
+ private static final int PADDING = 0 ;
24
+ private GwtApplicationConfiguration cfg ;
46
25
47
- @ Override
48
- public ApplicationListener createApplicationListener () {
49
- return new RocketSimulator ();
50
- }
26
+ @ Override
27
+ public GwtApplicationConfiguration getConfig () {
28
+ int w = Window .getClientWidth () - PADDING ;
29
+ int h = Window .getClientHeight () - PADDING ;
30
+ cfg = new GwtApplicationConfiguration (w , h );
31
+ Window .enableScrolling (false );
32
+ Window .setMargin ("0" );
33
+ Window .addResizeHandler (new ResizeListener ());
34
+ cfg .preferFlash = false ;
35
+ return cfg ;
36
+ }
37
+
38
+ class ResizeListener implements ResizeHandler {
39
+ @ Override
40
+ public void onResize (ResizeEvent event ) {
41
+ int width = event .getWidth () - PADDING ;
42
+ int height = event .getHeight () - PADDING ;
43
+ getRootPanel ().setWidth ("" + width + "px" );
44
+ getRootPanel ().setHeight ("" + height + "px" );
45
+ getApplicationListener ().resize (width , height );
46
+ Gdx .graphics .setWindowedMode (width , height );
47
+ }
48
+ }
49
+ // END OF CODE FOR RESIZABLE APPLICATION
50
+
51
+ @ Override
52
+ public ApplicationListener createApplicationListener () {
53
+ RocketSimulator game = new RocketSimulator ();
54
+ game .control = new HtmlController ();
55
+ game .handler = new HtmlHandler ();
56
+ return game ;
57
+ }
51
58
}
0 commit comments