private void recordForFrames(object maxFrames) { int currentFrame = sf4memory.GetFrameCount(); int endFrame = currentFrame + (int)maxFrames; int waitGap = 0; //If the state stays empty - add in waittimelineitem SF4InputState prevState = null; List <TimeLineItem> timeLineItems = new List <TimeLineItem>(); // Reset / start the frameTimer which is used to get time between frames. frameTimer.Reset(); frameTimer.Start(); while (currentFrame < endFrame && frameTimer.ElapsedMilliseconds < MIN_TIME_BETWEEN_FRAMES && recordingActive) { // Set lastFrame then the new current frame lastFrame = currentFrame; currentFrame = sf4memory.GetFrameCount(); if (currentFrame != lastFrame) { // Stop the frame timer since the frame has changed. frameTimer.Stop(); //Time to check inputs inputHandler.InputUpdate(); //Get controllers input state this frame //Use the back button on the controller to reset the timeline if (inputHandler.CurrentState.Back) { OnResetInput(); } //If no input - increment the wait gap so we can get timings if (inputHandler.CurrentState.NonePressed == false) { //If nothing pressed in last frame but something pressed now - // add the wait time to the list and if (prevState.NonePressed) { OnRecordInput(new WaitFrameItem(waitGap)); waitGap = 0; } else if (inputHandler.CurrentState != prevState) { OnRecordInput(new PressItem(inputHandler.CurrentState.ToInputsArray())); Debug.WriteLine("RECORDED INPUT"); } } else { waitGap++; } prevState = inputHandler.CurrentState; frameTimer.Reset(); frameTimer.Start(); // Since we currentFrame != lastFrame we are in a match. // (frames on menu screen or pause menu are constant). InMatch = true; } else { InMatch = false; } Thread.Sleep(1); } }
public void Record() { inputHandler.InputUpdate(); SF4InputState state = inputHandler.CurrentState; }