Example #1
0
    void GuiManager::showSelectHeroMenuCallback()
    {
        mFadeCurrentDocument = menus["selectHeroMenu"];

        hideAllMenus();
        menus["selectHeroMenu"]->Show();
        startFadeIn(menus["selectHeroMenu"]);
    }
Example #2
0
    void GuiManager::showTitleScreen()
    {
        menus["titleScreen"]->Show();
        menus["titleScreen"]->PullToFront();

        mFadeCurrentDocument = menus["titleScreen"];
        mStartTime = std::chrono::system_clock::now();
        mCurrentGuiType = TitleScreen;

        startFadeIn(menus["titleScreen"]);
    }
Example #3
0
    void GuiManager::showCreditsCallback()
    {
        mFadeCurrentDocument = menus["credits"];

        mCreditsScrollBox = std::make_shared<ScrollBox>(menus["credits"]);

        hideAllMenus();
        menus["credits"]->Show();
        startFadeIn(menus["credits"]);

        mCurrentGuiType = Credits;
    }
Example #4
0
    void GuiManager::showMainMenuCallback()
    {
        mFadeCurrentDocument = menus["mainMenu"];

        Engine::ThreadManager& threadManager = *Engine::ThreadManager::get();
        threadManager.playMusic("music/dintro.wav");

        hideAllMenus();
        menus["mainMenu"]->Show();
        startFadeIn(menus["mainMenu"]);

        mCurrentGuiType = MainMenu;
    }
//--------------------------------------------------------------
void captureApp::keyPressed(int key) {
	if (key == '='){
		serial.writeByte(255);		// this will turn on led.
	}	
	
	if (key == '-') {
		serial.writeByte(0);		// this will turn off led.
	}
	
	if(key == 'f') {
		ofToggleFullscreen();
	}
	
	if(key == '\t') {
		if( state < CAP_STATE_FADEIN ){
			startFadeIn();
		}
		else if( state == CAP_STATE_FADEIN ){
			bNeedsToLeaveFrame = false;
			face.resetCounters();		
			state = CAP_STATE_WAITING;	
		}
		else if( state == CAP_STATE_CAPTURE ){
			endCapture(true); //force override and cancel - normally capture is timed. 
			bNeedsToLeaveFrame = false;
			face.resetCounters();				
		}else if( state == CAP_STATE_DECODING ){
			endDecode(true);
			bNeedsToLeaveFrame = false;
			face.resetCounters();
		}
	}
	
	if( key == 'h' ){
		if( debugState == CAP_DEBUG ){
			debugState = CAP_NORMAL;
		}else if( debugState == CAP_NORMAL ){
			debugState = CAP_DEBUG;
		}	
	}
	
	if( debugState == CAP_DEBUG ){
		if(panel.getValueB("frameByFrame") && key == OF_KEY_UP){
			patternFrame--;
		}
		
		if(panel.getValueB("frameByFrame") && key == OF_KEY_DOWN){
			patternFrame++;
		}
	}
}
//-----------------------------------------------
void captureApp::handleFaceTrigger(){
	
	if( camState != CAMERA_CLOSED && state < CAP_STATE_FADEIN ){
		
		float faceFps  = panel.getValueF("FACE_FPS");
		float timeDiff = 1.0/ofClamp(faceFps, 4.0, 60.0);
		
		face.confidenceAddAmnt		= panel.getValueF("confidence_add");
		face.confidenceFadeRate		= panel.getValueF("confidence_fade");
		face.confidenceGateValStart = panel.getValueF("confidence_gate_start");
		face.confidenceGateValStop  = panel.getValueF("confidence_gate_stop");
		
		if( ofGetElapsedTimef() - prevFaceCheckTimeF >= timeDiff ){
			
			unsigned char * pix = NULL;
			if( do1394 ){
				pix = camera1394.getPixels();
			}else{
				pix = camera.getPixels();
			}
			if(pix != NULL){
				face.updatePixels(pix, cameraWidth, cameraHeight);
			}
			
			prevFaceCheckTimeF = ofGetElapsedTimef();
		}
		
		//update the trigger dispite the rate we update the pixels
		face.update();
		
		if( panel.hasValueChanged("B_FACE_TRIGGER") && panel.getValueB("B_FACE_TRIGGER") ){
			bNeedsToLeaveFrame = false;
			face.resetCounters();
		}
		
		if( bNeedsToLeaveFrame ){
			if( face.getState() == FACE_NONE ){
				bNeedsToLeaveFrame = false;
			}
		}else{		
			//only trigger a capture if the flag is set!!!
			if( panel.getValueB("B_FACE_TRIGGER") && face.firstSawFace() ){
				face.clearFirstSawFace();
				startFadeIn();
			}
		}
	}
	
}
//-----------------------------------------------
void captureApp::update(){
	panel.update();
	
	if( panel.getValueB("bRestart") ){
		if( panel.getValueI("restartHour") == ofGetHours() ){
			if( panel.getValueI("restartMinute") == ofGetMinutes() ){
				printf("shutting down now!\n");
				
				system(ofToDataPath("reboot.sh").c_str());
			}
		}
	}
	
	char data[10];
	memset(data, 0, 10);
	if (serial.available() > 0){
		serial.readBytes((unsigned char*) data, 10);
		if(state == CAP_STATE_WAITING)
			startFadeIn();
	}
	
	if( panel.hasValueChanged("bOverideLight") ){
		if( panel.getValueB("bOverideLight") ){
			light.lightOn();
		}else{
			light.lightOff();
		}
	}
	
	bEnableOsc = panel.getValueB("use_osc");
	if( panel.hasValueChanged("use_osc") ){
		if( bEnableOsc && !bOscSetup ){
			setupOsc();
			printf("------------- setting up osc\n");
		}
	}
	
	if( state == CAP_STATE_FADEIN || state == CAP_STATE_CAPTURE ){
		panel.setValueB("frameByFrame", false);
		panel.setValueB("bSpotLight", true);
	}
	
	//the capture part happens in the camera callbacks at the top.
	//this just checks to make sure that the capture doesn't need to keep running.
	if( state == CAP_STATE_CAPTURE ){
		panel.hidden = true;
		if( ofGetFrameNum() % 4 == 0 ){
			printf("fps is %s\n", ofToString(camFps, 2).c_str());
		}
		if( ofGetElapsedTimef() >= timeToEndCapture ){
			printf("time is %f - time to end is %f\n", ofGetElapsedTimef(), timeToEndCapture);
			endCapture();		
		}
	}else if( debugState == CAP_DEBUG ){
		panel.hidden = false;
	}

	if( debugState == CAP_NORMAL ){
		ofHideCursor();
	}else {
		ofShowCursor();
	}

	
	if( state == CAP_STATE_CAPTURE && ofGetElapsedTimef() >= timeToEndCapture ){
		printf("time is %f - time to end is %f\n", ofGetElapsedTimef(), timeToEndCapture);
		endCapture();		
		if( panel.getValueB("B_FACE_TRIGGER") ){
			bNeedsToLeaveFrame = true;
		}else{
			bNeedsToLeaveFrame = false;
		}
	}
	
	if( state == CAP_STATE_FADEIN && ofGetElapsedTimef() > fadeInStartTime + panel.getValueF("fadeInTime") ){
		startCapture();
	}	
	
	if( state == CAP_STATE_DECODING ){
		handleDecode();
	}else{	
		handleProjection();
		handleCamera();
		handleFaceTrigger();
	}
	
	panel.clearAllChanged();
}