Advertisement
snake5

SGScript - some basic UI code

Nov 27th, 2013
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. global ConfirmationScreen = {};
  3.  
  4. function ConfirmationScreen.create( params )
  5. {
  6.     callback = params.callback;
  7.     data =
  8.     {
  9.         question = params.question,
  10.         callback = callback,
  11.     };
  12.    
  13.     data.menu = GameMenu.create
  14.     ([
  15.         { text = "Yes", action = function() use(data){ data.callback( true ); data.menu = null; } },
  16.         { text = "No", action = function() use(data){ data.callback( false ); data.menu = null; } },
  17.     ],
  18.     { x = 384, width = 256, y = 384 });
  19.     data.menu.mouseon = 1;
  20.    
  21.     return class( data, ConfirmationScreen );
  22. }
  23.  
  24. function ConfirmationScreen.on_event( e )
  25. {
  26.     if( this.menu )
  27.         this.menu.on_event( e );
  28.    
  29.     // inhibit all events
  30.     return false;
  31. }
  32.  
  33. function ConfirmationScreen.draw( delta )
  34. {
  35.     if( !this.menu )
  36.         return true;
  37.     draw_color_rect_wh( 0, 0, 9999, 9999, 0.5, 0.5, 0.5, 0.5 );
  38.     draw_text_rect( this.question, g_GameFont, [1,1,1], DT_CENTER | DT_VCENTER, 128, W - 128, 128, H/2 );
  39.     this.menu.draw( delta );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement