_G. { tex_background = TEXTURE("ui/bg1.png"), tex_button_core_n = TEXTURE("ui/button_core.png"), tex_button_core_h = TEXTURE("ui/button_core_h.png"), tex_button_core_c = TEXTURE("ui/button_core_c.png"), tex_button_core_f = TEXTURE("ui/button_core_f.png"), }; function ButtonShader( ctrl ) { tex = if( ctrl.clickedL, tex_button_core_c, if( ctrl.hover, tex_button_core_h, tex_button_core_n ) ); ctrl.DTex( tex ); ctrl.DButton( 0, 0, ctrl.width, ctrl.height, 4, 4/128 ); ctrl.DFont( "core", ctrl.height / 2 ); ctrl.DText( ctrl.text, ctrl.width / 2, ctrl.height / 2 + ctrl.InvIS( ctrl.clickedL ), HALIGN_CENTER, VALIGN_CENTER ); if( ctrl.focused ) { ctrl.DTex( tex_button_core_f ); ctrl.DButton( 0, 0, ctrl.width, ctrl.height, 4, 4/128 ); } } function CreateButton( x, y, w, h, text ) { ctrl = this.CreateControl( x, y, w, h ); ocb = ctrl.eventCallback; function button_callback( ev ) use( ocb ) { if( ev.type == GUI_Event_BtnUp ) { if( this.Hit( ev.x, ev.y ) && ev.button == GUI_MB_Left ) this.InvokeCallbacks( "onclick" ); return 1; } return this!ocb( ev ); } ctrl.eventCallback = button_callback; ctrl.shaders.push( ButtonShader ); ctrl.text = text; ctrl.focusable = true; return ctrl; } function YesNoQuestion( text ) { answer = null; factor = 0.0; scr_overlay = ROOT.CreateScreen( GUI_ScrMode_Crop, 100, 100 ).{ z = 1000 }; scr_overlay.shaders.push(function( ctrl ) { ctrl.DCol( 0, 0.5 ); ctrl.DQuad( 0, 0, ctrl.width, ctrl.height ); }); scr_bgr = ROOT.CreateScreen( GUI_ScrMode_Fit, 200, 100 ).{ z = 1001, xscale = 0.4, yscale = 0.4, text = text }; scr_bgr.shaders.push(function( ctrl ) use( factor ) { // background ctrl.DCol( 0.1, 0.3, 0.7, 0.5 ); ctrl.DQuad( 0, 0, 200, 100 ); // top border ctrl.DCol( 0.7, 1 ); ctrl.DQuad( 0, 0, 200 * factor, 20 ); ctrl.DCol( 0.8, 1 ); ctrl.DQuad( 0, 20, 200 * factor, 21 ); ctrl.DCol( 0.0, 0.2 ); ctrl.DQuad( 0, 21, 200 * factor, 24 ); // question text ctrl.DCol( 0.02, 1 * factor ); ctrl.DFont( "core", 10 ); ctrl.DText( ctrl.text, 5, 10, HALIGN_LEFT, VALIGN_CENTER ); }); btn_yes = scr_bgr!CreateButton( 10, 70, 60, 20, "Yes" ); btn_yes.AddCallback( "onclick", function() use(answer){ answer = true; } ); btn_no = scr_bgr!CreateButton( 200-70, 70, 60, 20, "No" ); btn_no.AddCallback( "onclick", function() use(answer){ answer = false; } ); SetFocusRoot( scr_bgr ); function min(a,b){ return if(a