Advertisement
snake5

TACStrike - screens.sgs

Jan 17th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. global SplashScreen = {};
  4.  
  5. function SplashScreen.create()
  6. {
  7.     data =
  8.     {
  9.         timer = 0,
  10.         crage_tex = create_texture( "ui/crage_logo.png" ),
  11.         back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
  12.     };
  13.    
  14.     return class( data, SplashScreen );
  15. }
  16.  
  17. function SplashScreen.on_event( e )
  18. {
  19.     if( e.type == SDL_KEYDOWN || e.type == SDL_MOUSEBUTTONDOWN )
  20.     {
  21.         if( this.timer < 5 ) this.timer = 5;
  22.     }
  23.    
  24.     // inhibit all events
  25.     return false;
  26. }
  27.  
  28. function SplashScreen.draw( delta )
  29. {
  30.     this.timer += delta;
  31.    
  32.     draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, 1 );
  33.    
  34.     vis_crage = smoothlerp_range( this.timer, 0, 1, 3, 5 );
  35.     if( vis_crage )
  36.     {
  37.         draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_crage );
  38.         draw_tex_color_box_wh( W / 2, H / 2.1, this.crage_tex.width, this.crage_tex.height, this.crage_tex, 1, 1, 1, vis_crage );
  39.     }
  40.    
  41.     return this.timer > 5;
  42. }
  43.  
  44.  
  45.  
  46. global EndLevelScreen = {};
  47.  
  48. function EndLevelScreen.create( params )
  49. {
  50.     data =
  51.     {
  52.         level = params.level,
  53.         timer = 0,
  54.         back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
  55.     };
  56.    
  57.     Game.OverlayScreenNeedsBgr = false; // hacky hacky
  58.    
  59.     return class( data, EndLevelScreen );
  60. }
  61.  
  62. function EndLevelScreen.on_event( e )
  63. {
  64.     // inhibit all events
  65.     return false;
  66. }
  67.  
  68. function EndLevelScreen.draw( delta )
  69. {
  70.     this.timer += delta;
  71.    
  72.     vis_background = smoothlerp_range( this.timer, 0, 3, 7, 8 );
  73.     if( vis_background )
  74.     {
  75.         draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, vis_background );
  76.     }
  77.    
  78.     vis_text = smoothlerp_range( this.timer, 0, 3, 5, 7 );
  79.     if( vis_text )
  80.     {
  81.         draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_text );
  82.         draw_text_rect( "LEVEL COMPLETE\n\n\nLOADING...", g_GameFont, [1,1,1,vis_text], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H - 128 );
  83.     }
  84.    
  85.     if( this.timer > 7 )
  86.     {
  87.         Game.OverlayScreenNeedsBgr = true;
  88.         Game.Start( this.level );
  89.     }
  90.     return this.timer > 7;
  91. }
  92.  
  93.  
  94.  
  95. global EndGameScreen = {};
  96.  
  97. function EndGameScreen.create()
  98. {
  99.     data =
  100.     {
  101.         timer = 0,
  102.         back_tex = create_texture( "ui/flare_bg.png", "hrepeat,vrepeat" ),
  103.     };
  104.    
  105.     Game.OverlayScreenNeedsBgr = false; // hacky hacky
  106.    
  107.     return class( data, EndGameScreen );
  108. }
  109.  
  110. function EndGameScreen.on_event( e )
  111. {
  112.     // inhibit all events
  113.     return false;
  114. }
  115.  
  116. function EndGameScreen.draw( delta )
  117. {
  118.     this.timer += delta;
  119.    
  120.     vis_background = smoothlerp_range( this.timer, 0, 3, 7, 8 );
  121.     if( vis_background )
  122.     {
  123.         draw_color_rect_wh( 0, 0, 9999, 9999, 0, 0, 0, vis_background );
  124.     }
  125.    
  126.     vis_text = smoothlerp_range( this.timer, 0, 3, 5, 7 );
  127.     if( vis_text )
  128.     {
  129.         draw_tex_color_rect_wh( 0, -this.timer * 10, 1024, 1024, this.back_tex, 1, 1, 1, vis_text );
  130.         draw_text_rect( "MISSION COMPLETE\n\n\nTHANK YOU FOR PLAYING!\n\n\n\nTO BE CONTINUED...?", g_GameFont, [1,1,1,vis_text], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H - 128 );
  131.     }
  132.    
  133.     if( this.timer > 7 )
  134.     {
  135.         Game.OverlayScreenNeedsBgr = true;
  136.         Game.End(); // hacky hacky
  137.     }
  138.     return this.timer > 7;
  139. }
  140.  
  141.  
  142.  
  143. global ConfirmationScreen = {};
  144.  
  145. function ConfirmationScreen.create( params )
  146. {
  147.     callback = params.callback;
  148.     data =
  149.     {
  150.         question = params.question,
  151.         callback = callback,
  152.     };
  153.    
  154.     data.menu = GameMenu.create
  155.     ([
  156.         { text = "Yes", action = function() use(data){ data.callback( true ); data.menu = null; } },
  157.         { text = "No", action = function() use(data){ data.callback( false ); data.menu = null; } },
  158.     ],
  159.     { x = 384, width = 256, y = 384 });
  160.     data.menu.mouseon = 1;
  161.    
  162.     return class( data, ConfirmationScreen );
  163. }
  164.  
  165. function ConfirmationScreen.on_event( e )
  166. {
  167.     if( this.menu )
  168.         this.menu.on_event( e );
  169.    
  170.     // inhibit all events
  171.     return false;
  172. }
  173.  
  174. function ConfirmationScreen.draw( delta )
  175. {
  176.     if( !this.menu )
  177.         return true;
  178.     draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
  179.     draw_text_rect( this.question, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H/2 );
  180.     this.menu.draw( delta );
  181. }
  182.  
  183.  
  184.  
  185. global NotificationScreen = {};
  186.  
  187. function NotificationScreen.create( params )
  188. {
  189.     data =
  190.     {
  191.         title = params.title,
  192.         text = params.text,
  193.     };
  194.    
  195.     data.menu = GameMenu.create
  196.     ([
  197.         { text = "OK", action = function() use(data){ data.menu = null; } },
  198.     ],
  199.     { x = 384, width = 256, y = 480 });
  200.     data.menu.mouseon = 0;
  201.    
  202.     return class( data, NotificationScreen );
  203. }
  204.  
  205. function NotificationScreen.on_event( e )
  206. {
  207.     if( this.menu )
  208.         this.menu.on_event( e );
  209.    
  210.     // inhibit all events
  211.     return false;
  212. }
  213.  
  214. function NotificationScreen.draw( delta )
  215. {
  216.     if( !this.menu )
  217.         return true;
  218.     draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
  219.     draw_text_rect( this.title, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 192, 256 );
  220.     draw_text_rect( this.text, g_TextFont, [1,1,1], DT_LEFT | DT_TOP, 128, W - 128, 256, H*3/4 );
  221.     this.menu.draw( delta );
  222. }
  223.  
  224.  
  225.  
  226. global MenuScreen = {};
  227.  
  228. function MenuScreen.create( params )
  229. {
  230.     data =
  231.     {
  232.         title = params.title,
  233.     };
  234.    
  235.     if( isset( params, "params" ) )
  236.         prm = clone( params.params );
  237.     else
  238.         prm = {};
  239.     prm.width = 256;
  240.     prm.x = 384;
  241.     prm.y = 520 - 32 * params.options.size;
  242.    
  243.     data.menu = GameMenu.create( params.options, prm );
  244.     data.menu.mouseon = 0;
  245.    
  246.     if( isset( params, "default" ) )
  247.         data.menu.mouseon = params.default;
  248.    
  249.     return class( data, MenuScreen );
  250. }
  251.  
  252. function MenuScreen.on_event( e )
  253. {
  254.     if( this.menu )
  255.         this.menu.on_event( e );
  256.    
  257.     // inhibit all events
  258.     return false;
  259. }
  260.  
  261. function MenuScreen.draw( delta )
  262. {
  263.     if( !this.menu )
  264.         return true;
  265.     draw_color_rect_wh( 0, 0, 9999, 9999, 0.2, 0.2, 0.2, 0.5 );
  266.     draw_text_rect( this.title, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H/2 );
  267.     this.menu.draw( delta );
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement