@@ -31,12 +31,17 @@ function WAIT.new(arg)
3131 if WAIT .state then return end
3232
3333 assert (type (arg )== ' table' ," arg must be table" )
34- assert (arg .init == nil or type (arg .init ) == ' function' ," Field 'enter' must be function" )
35- assert (arg .update == nil or type (arg .update ) == ' function' ," Field 'update' must be function" )
36- assert (arg .quit == nil or type (arg .quit ) == ' function' ," Field 'leave' must be function" )
37- assert (arg .draw == nil or type (arg .draw ) == ' function' ," Field 'draw' must be function" )
38- assert (arg .escapable == nil or type (arg .escapable ) == ' boolean' , " Field 'escapable' must be boolean" )
39- WAIT .defaultInit ()
34+ assert (arg .init == nil or type (arg .init ) == ' function' ," Field 'enter' must be function" )
35+ assert (arg .update == nil or type (arg .update ) == ' function' ," Field 'update' must be function" )
36+ assert (arg .quit == nil or type (arg .quit ) == ' function' ," Field 'leave' must be function" )
37+ assert (arg .draw == nil or type (arg .draw ) == ' function' ," Field 'draw' must be function" )
38+ assert (arg .escapable == nil or type (arg .escapable ) == ' boolean' , " Field 'escapable' must be boolean" )
39+ assert (arg .coverAlpha == nil or type (arg .coverAlpha ) == ' number' , " Field 'coverAlpha' must be number" )
40+ assert (arg .noDefaultInit == nil or type (arg .noDefaultInit ) == ' boolean' , " Field 'noDefaultInit' must be boolean" )
41+ assert (arg .noDefaultUpdate == nil or type (arg .noDefaultUpdate ) == ' boolean' , " Field 'noDefaultUpdate' must be boolean" )
42+ assert (arg .noDefaultDraw == nil or type (arg .noDefaultDraw ) == ' boolean' , " Field 'noDefaultDraw' must be boolean" )
43+ assert (arg .noDefaultQuit == nil or type (arg .noDefaultQuit ) == ' boolean' , " Field 'noDefaultQuit' must be boolean" )
44+ if not arg .noDefaultInit then WAIT .defaultInit () end
4045 if arg .init then arg .init () end
4146
4247 WAIT .arg = arg
5560function WAIT .update (dt )
5661 if WAIT .state then
5762 WAIT .totalTimer = WAIT .totalTimer + dt
58- WAIT .defaultUpdate ()
59- if WAIT .arg .update then WAIT .arg .update (dt ) end
63+ if not WAIT .arg . noDefaultUpdate then WAIT . defaultUpdate (dt , WAIT . totalTimer ) end
64+ if WAIT .arg .update then WAIT .arg .update (dt , WAIT . totalTimer ) end
6065
6166 if WAIT .state ~= ' leave' and WAIT .totalTimer >= (WAIT .arg .timeout or WAIT .timeout ) then
6267 WAIT .interrupt ()
@@ -69,7 +74,7 @@ function WAIT.update(dt)
6974 WAIT .timer = WAIT .timer - dt
7075 if WAIT .timer <= 0 then
7176 WAIT .state = false
72- WAIT .defaultQuit ()
77+ if not WAIT .arg . noDefaultQuit then WAIT . defaultQuit () end
7378 if WAIT .arg .quit then WAIT .arg .quit () end
7479 end
7580 end
@@ -83,20 +88,18 @@ function WAIT.draw()
8388 WAIT .state == ' wait' and 1 or
8489 WAIT .state == ' leave' and WAIT .timer / WAIT .leaveTime
8590 )
86- if WAIT .coverAlpha > 0 then
91+ if ( WAIT .arg . coverAlpha or WAIT . coverAlpha ) > 0 then
8792 GC .setColor (
8893 WAIT .coverColor [1 ],
8994 WAIT .coverColor [2 ],
9095 WAIT .coverColor [3 ],
91- alpha * WAIT .coverAlpha
96+ alpha * ( WAIT .arg . coverAlpha or WAIT . coverAlpha )
9297 )
9398 GC .rectangle (' fill' ,0 ,0 ,SCR .w ,SCR .h );
9499 end
95100
96- WAIT .defaultDraw (alpha ,WAIT .totalTimer )
97- if WAIT .arg .draw then
98- WAIT .arg .draw (alpha ,WAIT .totalTimer )
99- end
101+ if not WAIT .arg .noDefaultDraw then WAIT .defaultDraw (alpha ,WAIT .totalTimer ) end
102+ if WAIT .arg .draw then WAIT .arg .draw (alpha ,WAIT .totalTimer ) end
100103 end
101104end
102105
0 commit comments