src/menucode.cpp
// executeFrame ***********
// Execute a frame, without drawing it on screen. It's what I call
// "virtual frames".
// Only return false for non-recover errors.

executeFrame
Execute a frame, without drawing it on screen. It's what I call
"virtual frames".
Only return false for non-recover errors.
executeFrame Execute a frame without drawing it on screen . It ' s what I call " virtual frames " . Only return false for non - recover errors .
bool MenuLoopCode::executeFrame(DWORD frameNumber)
{
	lua_State* lstate;
	int errCode;
	bool keyPreviousPressed=false;
	bool keyNextPressed=false;
	bool keyClickPressed=false;
	bool mouseClickPressed=false;
	if ((KEYDOWN(keyboard.keys, SDLK_UP) || KEYDOWN(keyboard.keys, SDLK_LEFT)) && !showConsole) {
		keyPreviousPressed=true;
	}
	if ((KEYDOWN(keyboard.keys, SDLK_DOWN) || KEYDOWN(keyboard.keys, SDLK_RIGHT)) && !showConsole) {
		keyNextPressed=true;
	}
	if (MOUSEDOWN(mouse.mouseData, MOUSE_BUTTON_LEFT)) {
		mouseClickPressed=true;
	}
	if (MOUSEX(mouse.mouseData)!=0 || MOUSEY(mouse.mouseData)) {
		mouseX+=MOUSEX(mouse.mouseData);
		if (mouseX<0) mouseX=0;
		if (mouseX>=DD.getWidth()-1) mouseX=DD.getWidth()-1;
		mouseY+=MOUSEY(mouse.mouseData);
		if (mouseY<0) mouseY=0;
		if (mouseY>=DD.getHeight()-1) mouseY=DD.getHeight()-1;
	}
	lstate=scriptMan.getLuaObject();
	lua_getglobal(lstate, "errorManager");
	lua_getglobal(lstate, "executeFrame");
	lua_pushnumber(lstate, frameNumber);
	lua_pushnumber(lstate, mouseX);
	lua_pushnumber(lstate, mouseY);
	lua_pushboolean(lstate, mouseClickPressed);
	lua_pushboolean(lstate, keyPreviousPressed);
	lua_pushboolean(lstate, keyNextPressed);
	lua_pushboolean(lstate, keyClickPressed);
	errCode=lua_pcall(lstate, 7, 0, -9);
	lua_pop(lstate, 1);
	if (errCode!=0) {
		lua_pop(lstate,1);
		logger.logLine("Error calling pcall over executeFrame");
		return false;
	}
	if (nowObscuring) {
		screenLightness-=obscuringSpeed;
		if (screenLightness<=0) {
			screenLightness=0;
			if (DD.isReady() && DD.isVideoModeReady()) {
				int i;
				for (i=0; i<DD.getBackBuffersCount(); i++) {
					DD.fillAllDword(0); DD.flip();
				}
			}
			if (!globalExit())
				return false;
		}
	}else{
		screenLightness+=obscuringSpeed;
		if (screenLightness>=255) screenLightness=255;
	}
	return true;
}
bool MenuLoopCode :: executeFrame ( DWORD frameNumber ) { lua_State * lstate ; int errCode ; bool keyPreviousPressed = false ; bool keyNextPressed = false ; bool keyClickPressed = false ; bool mouseClickPressed = false ; if ( ( KEYDOWN ( keyboard . keys , SDLK_UP ) || KEYDOWN ( keyboard . keys , SDLK_LEFT ) ) && ! showConsole ) { keyPreviousPressed = true ; } if ( ( KEYDOWN ( keyboard . keys , SDLK_DOWN ) || KEYDOWN ( keyboard . keys , SDLK_RIGHT ) ) && ! showConsole ) { keyNextPressed = true ; } if ( MOUSEDOWN ( mouse . mouseData , MOUSE_BUTTON_LEFT ) ) { mouseClickPressed = true ; } if ( MOUSEX ( mouse . mouseData ) != 0 || MOUSEY ( mouse . mouseData ) ) { mouseX += MOUSEX ( mouse . mouseData ) ; if ( mouseX < 0 ) mouseX = 0 ; if ( mouseX >= DD . getWidth ( ) - 1 ) mouseX = DD . getWidth ( ) - 1 ; mouseY += MOUSEY ( mouse . mouseData ) ; if ( mouseY < 0 ) mouseY = 0 ; if ( mouseY >= DD . getHeight ( ) - 1 ) mouseY = DD . getHeight ( ) - 1 ; } lstate = scriptMan . getLuaObject ( ) ; lua_getglobal ( lstate , " " ) ; lua_getglobal ( lstate , " " ) ; lua_pushnumber ( lstate , frameNumber ) ; lua_pushnumber ( lstate , mouseX ) ; lua_pushnumber ( lstate , mouseY ) ; lua_pushboolean ( lstate , mouseClickPressed ) ; lua_pushboolean ( lstate , keyPreviousPressed ) ; lua_pushboolean ( lstate , keyNextPressed ) ; lua_pushboolean ( lstate , keyClickPressed ) ; errCode = lua_pcall ( lstate , 7 , 0 , -9 ) ; lua_pop ( lstate , 1 ) ; if ( errCode != 0 ) { lua_pop ( lstate , 1 ) ; logger . logLine ( " " ) ; return false ; } if ( nowObscuring ) { screenLightness -= obscuringSpeed ; if ( screenLightness <= 0 ) { screenLightness = 0 ; if ( DD . isReady ( ) && DD . isVideoModeReady ( ) ) { int i ; for ( i = 0 ; i < DD . getBackBuffersCount ( ) ; i ++ ) { DD . fillAllDword ( 0 ) ; DD . flip ( ) ; } } if ( ! globalExit ( ) ) return false ; } } else { screenLightness += obscuringSpeed ; if ( screenLightness >= 255 ) screenLightness = 255 ; } return true ; }
executeFrame 
Execute a frame, without drawing it on screen.
executeFrame Execute a frame without drawing it on screen .
// CHECK FOR KEYS
 // check if it's time to change the currently selected menu option
 // Go up...
 // Go down...
 /*	// Check for selected buttons or mouse buttons
	if ((KEYDOWN(keyboard.keys, DIK_SPACE) ||// space key
		KEYDOWN(keyboard.keys, DIK_LCONTROL) ||// left control key
		KEYDOWN(keyboard.keys, DIK_ENTER))// return key
		&& !showConsole) {

		keyClickPressed=true;
	}*/ // mouse click
 // Check it has moved at all
 // Get the current mouse position
 // LUA EXECUTE FRAME
 // execute the lua code that manages frame execution
 // take errorManager off the stack
 // there is an extra value there...
 // THE ALPHA BLENDING THING
 // go obscure the screen
 // finished lighting down? should execute some
 // obscuring event... for now we just go away
 // first obscure all the buffers of the screen
 // bye bye
 // anywhere else from the exiting menu, light screen up
 // all ok
