Merge pull request #2704 from RisingFog/frameadvancehold

Add Frame Advance Hold Hotkey Functionality
This commit is contained in:
Scott Mansell 2015-10-28 15:31:03 +13:00
commit 44a40642f3
4 changed files with 67 additions and 1 deletions

View File

@ -19,6 +19,9 @@ const std::string hotkey_labels[] =
_trans("Stop"),
_trans("Reset"),
_trans("Frame Advance"),
_trans("Frame Advance Decrease Speed"),
_trans("Frame Advance Increase Speed"),
_trans("Frame Advance Reset Speed"),
_trans("Start Recording"),
_trans("Play Recording"),

View File

@ -17,6 +17,9 @@ enum Hotkey
HK_STOP,
HK_RESET,
HK_FRAME_ADVANCE,
HK_FRAME_ADVANCE_DECREASE_SPEED,
HK_FRAME_ADVANCE_INCREASE_SPEED,
HK_FRAME_ADVANCE_RESET_SPEED,
HK_START_RECORDING,
HK_PLAY_RECORDING,

View File

@ -1291,7 +1291,6 @@ void CFrame::ParseHotkeys()
case HK_CHANGE_DISC:
case HK_REFRESH_LIST:
case HK_RESET:
case HK_FRAME_ADVANCE:
case HK_START_RECORDING:
case HK_PLAY_RECORDING:
case HK_EXPORT_RECORDING:
@ -1333,6 +1332,8 @@ void CFrame::ParseHotkeys()
// Pause and Unpause
if (IsHotkey(HK_PLAY_PAUSE))
DoPause();
// Frame advance
HandleFrameSkipHotkeys();
// Stop
if (IsHotkey(HK_STOP))
DoStop();
@ -1531,3 +1532,61 @@ void CFrame::ParseHotkeys()
if (IsHotkey(HK_UNDO_SAVE_STATE))
State::UndoSaveState();
}
void CFrame::HandleFrameSkipHotkeys()
{
static const int MAX_FRAME_SKIP_DELAY = 60;
static int frameStepCount = 0;
static const int FRAME_STEP_DELAY = 30;
static int holdFrameStepDelay = 1;
static int holdFrameStepDelayCount = 0;
static bool holdFrameStep = false;
if (IsHotkey(HK_FRAME_ADVANCE_DECREASE_SPEED))
{
++holdFrameStepDelay;
if (holdFrameStepDelay > MAX_FRAME_SKIP_DELAY)
holdFrameStepDelay = MAX_FRAME_SKIP_DELAY;
}
else if (IsHotkey(HK_FRAME_ADVANCE_INCREASE_SPEED))
{
--holdFrameStepDelay;
if (holdFrameStepDelay < 0)
holdFrameStepDelay = 0;
}
else if (IsHotkey(HK_FRAME_ADVANCE_RESET_SPEED))
{
holdFrameStepDelay = 1;
}
else if (IsHotkey(HK_FRAME_ADVANCE, true))
{
if (holdFrameStepDelayCount < holdFrameStepDelay && holdFrameStep)
++holdFrameStepDelayCount;
if ((frameStepCount == 0 || frameStepCount == FRAME_STEP_DELAY) && !holdFrameStep)
{
wxCommandEvent evt;
evt.SetId(IDM_FRAMESTEP);
CFrame::OnFrameStep(evt);
if (holdFrameStepDelay > 0 && frameStepCount == 0)
holdFrameStep = true;
}
if (frameStepCount < FRAME_STEP_DELAY)
++frameStepCount;
if (frameStepCount == FRAME_STEP_DELAY && holdFrameStep && holdFrameStepDelayCount >= holdFrameStepDelay)
{
holdFrameStep = false;
holdFrameStepDelayCount = 0;
}
}
else if (frameStepCount > 0)
{
// Reset values of frame advance to default
frameStepCount = 0;
holdFrameStep = false;
holdFrameStepDelayCount = 0;
}
}

View File

@ -211,6 +211,7 @@ private:
wxAuiNotebook * GetNotebookFromId(u32 NBId);
int GetNotebookCount();
wxAuiNotebook *CreateEmptyNotebook();
void HandleFrameSkipHotkeys();
// Perspectives
void AddRemoveBlankPage();