* Taseditor: Markers aren't bound to Input by default, Markers are always restored when deploying Bookmarks

* Taseditor: Lua registermanual allows changing the "Run function" button caption
* Taseditor: fixed bug with rejecting movies starting from savestate
This commit is contained in:
ansstuff 2012-07-19 19:40:40 +00:00
parent b8edb6e17e
commit a40e4c655a
14 changed files with 72 additions and 75 deletions

View File

@ -8,7 +8,7 @@
---------------------------------------------------------------------------
-- Usage:
-- Run the script, unpause emulation (or simply Frame Advance once).
-- Now you can press "Run function" button to invert current Selection.
-- Now you can press "Invert Selection" button to invert current Selection.
-- Previously selected frames become deselected, all other frames become selected.
---------------------------------------------------------------------------
@ -51,5 +51,5 @@ function invert_selection()
end
taseditor.registerauto(display_selection);
taseditor.registermanual(invert_selection);
taseditor.registermanual(invert_selection, "Invert Selection");

View File

@ -13,7 +13,7 @@
-- Use the script when you want to exchange recorded input between joypads.
-- Run the script, unpause emulation (or simply Frame Advance once).
-- Now you can select several frames of input data and then
-- press "Run function" button to swap inputs of 1P and 2P.
-- press "Swap 1P/2P" button to swap Input of 1P and 2P in selected frames.
-- You can easily modify the script to swap any other joypads.
---------------------------------------------------------------------------
@ -32,16 +32,6 @@ function swap()
end
end
taseditor.registermanual(swap);
taseditor.registermanual(swap, "Swap 1P/2P");

View File

@ -5,7 +5,7 @@ Copyright (c) 2011-2012 AnS
(The MIT License)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVID ED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------------------------
Main - Main gate between emulator and Taseditor
[Singleton]
@ -108,8 +108,10 @@ bool EnterTasEditor()
history.init();
taseditor_lua.init();
// either start new movie or use current movie
if (FCEUMOV_Mode(MOVIEMODE_INACTIVE))
if (FCEUMOV_Mode(MOVIEMODE_INACTIVE) || currMovieData.savestate.size() != 0)
{
if (currMovieData.savestate.size() != 0)
FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
// create new movie
FCEUI_StopMovie();
movieMode = MOVIEMODE_TASEDITOR;
@ -118,12 +120,6 @@ bool EnterTasEditor()
} else
{
// use current movie to create a new project
if (currMovieData.savestate.size() != 0)
{
FCEUD_PrintError("This version of TAS Editor doesn't work with movies starting from savestate.");
// delete savestate, but preserve Input anyway
currMovieData.savestate.clear();
}
FCEUI_StopMovie();
movieMode = MOVIEMODE_TASEDITOR;
}
@ -781,7 +777,7 @@ void ApplyMovieInputConfig()
// this getter contains formula to decide whether to record or replay movie
bool TaseditorIsRecording()
{
if (movie_readonly || playback.GetPauseFrame() > currFrameCounter)
if (movie_readonly || playback.GetPauseFrame() >= 0)
return false; // replay
return true; // record
}

View File

@ -391,8 +391,7 @@ void BOOKMARKS::jump(int slot)
{
int frame = bookmarks_array[slot].snapshot.jump_frame;
playback.jump(frame);
if (playback.GetPauseFrame())
piano_roll.FollowPauseframe();
piano_roll.FollowPauseframe();
bookmarks_array[slot].jumped();
}
}
@ -410,7 +409,7 @@ void BOOKMARKS::deploy(int slot)
int jump_frame = bookmarks_array[slot].snapshot.jump_frame;
bool markers_changed = false;
// revert Markers to the Bookmarked state
if (taseditor_config.bind_markers)
//if (taseditor_config.bind_markers)
{
if (bookmarks_array[slot].snapshot.MarkersDifferFromCurrent())
{

View File

@ -98,20 +98,20 @@ void GREENZONE::CollectCurrentState()
lag_history.erase(lag_history.begin() + (currFrameCounter - 1));
editor.AdjustUp(currFrameCounter - 1);
// since AdjustUp didn't restore Playback cursor, we must rewind here
int pause_frame = playback.GetPauseFrame();
int saved_pause_frame = playback.GetPauseFrame();
playback.jump(currFrameCounter - 1); // rewind
if (pause_frame)
playback.SeekingStart(pause_frame);
if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame);
} else if (!old_lagFlag && lagFlag)
{
// there's new lag on previous frame - shift Input down
lag_history.insert(lag_history.begin() + (currFrameCounter - 1), 1);
editor.AdjustDown(currFrameCounter - 1);
// since AdjustDown didn't restore Playback cursor, we must rewind here
int pause_frame = playback.GetPauseFrame();
int saved_pause_frame = playback.GetPauseFrame();
playback.jump(currFrameCounter - 1); // rewind
if (pause_frame)
playback.SeekingStart(pause_frame);
if (saved_pause_frame >= 0)
playback.SeekingStart(saved_pause_frame);
}
} else
{
@ -436,21 +436,23 @@ void GREENZONE::InvalidateAndCheck(int after)
{
if (after >= 0)
{
if (greenZoneCount > after+1)
if (greenZoneCount > after + 1)
{
greenZoneCount = after+1;
greenZoneCount = after + 1;
currMovieData.rerecordCount++;
// either set Playback cursor to the end of Greenzone or run seeking to restore Playback cursor position
if (currFrameCounter >= greenZoneCount)
{
if (playback.GetFixedPauseFrame())
{
playback.jump(playback.GetPauseFrame() - 1);
// continue seeking
playback.jump(playback.GetPauseFrame());
} else
{
playback.SetLostPosition(currFrameCounter);
if (taseditor_config.restore_position)
playback.jump(currFrameCounter);
// start seeking
playback.jump(playback.GetLostPosition());
else
playback.jump(greenZoneCount - 1);
}
@ -461,14 +463,14 @@ void GREENZONE::InvalidateAndCheck(int after)
piano_roll.RedrawList();
bookmarks.RedrawBookmarksList();
}
// This version doesn't restore playback, may be used only by Branching, Recording and Adjusting functions!
// This version doesn't restore playback, may be used only by Branching, Recording and AdjustLag functions!
void GREENZONE::Invalidate(int after)
{
if (after >= 0)
{
if (greenZoneCount > after+1)
if (greenZoneCount > after + 1)
{
greenZoneCount = after+1;
greenZoneCount = after + 1;
currMovieData.rerecordCount++;
}
}

View File

@ -540,7 +540,7 @@ void PIANO_ROLL::update()
{
case DRAG_MODE_PLAYBACK:
{
if (!playback.GetPauseFrame() || can_drag_when_seeking)
if (playback.GetPauseFrame() < 0 || can_drag_when_seeking)
{
DragPlaybackCursor();
// after first seeking is finished (if there was any seeking), it now becomes possible to drag when seeking
@ -963,8 +963,8 @@ void PIANO_ROLL::FollowSelection()
}
void PIANO_ROLL::FollowPauseframe()
{
if (playback.GetPauseFrame() > 0)
CenterListAt(playback.GetPauseFrame() - 1);
if (playback.GetPauseFrame() >= 0)
CenterListAt(playback.GetPauseFrame());
}
void PIANO_ROLL::FollowMarker(int marker_id)
{

View File

@ -141,7 +141,7 @@ void PLAYBACK::update()
// pause when seeking hits pause_frame
if (pause_frame && currFrameCounter + 1 >= pause_frame)
SeekingStop();
else if (currFrameCounter + 1 > lost_position_frame && currFrameCounter >= currMovieData.getNumRecords()-1 && autopause_at_the_end && taseditor_config.autopause_at_finish)
else if (currFrameCounter >= GetLostPosition() && currFrameCounter >= currMovieData.getNumRecords() - 1 && autopause_at_the_end && taseditor_config.autopause_at_finish)
// pause at the end of the movie
PauseEmulation();
@ -269,10 +269,10 @@ void PLAYBACK::UnpauseEmulation()
}
void PLAYBACK::RestorePosition()
{
if (lost_position_frame > currFrameCounter + 1)
if (GetLostPosition() > currFrameCounter)
{
if (emu_paused)
SeekingStart(lost_position_frame);
SeekingStart(GetLostPosition());
else
PauseEmulation();
}
@ -293,23 +293,23 @@ void PLAYBACK::MiddleButtonClick()
for (; target_frame <= last_frame; ++target_frame)
if (markers_manager.GetMarker(target_frame)) break;
if (target_frame <= last_frame)
SeekingStart(target_frame + 1);
SeekingStart(target_frame);
} else if (GetAsyncKeyState(VK_CONTROL) < 0)
{
// if Ctrl is held, seek to Selection cursor or replay from Selection cursor
int selection_beginning = selection.GetCurrentSelectionBeginning();
if (selection_beginning > currFrameCounter)
{
SeekingStart(selection_beginning + 1);
SeekingStart(selection_beginning);
} else if (selection_beginning < currFrameCounter)
{
int saved_currFrameCounter = currFrameCounter;
if (selection_beginning < 0)
selection_beginning = 0;
jump(selection_beginning);
SeekingStart(saved_currFrameCounter + 1);
SeekingStart(saved_currFrameCounter);
}
} else if (lost_position_frame > currFrameCounter + 1)
} else if (GetLostPosition() > currFrameCounter)
{
RestorePosition();
} else
@ -325,10 +325,10 @@ void PLAYBACK::MiddleButtonClick()
void PLAYBACK::SeekingStart(int finish_frame)
{
if (pause_frame != finish_frame)
if ((pause_frame - 1) != finish_frame)
{
seeking_start_frame = currFrameCounter;
pause_frame = finish_frame;
pause_frame = finish_frame + 1;
}
pause_frame_must_be_fixed = true;
if (taseditor_config.turbo_seek)
@ -456,7 +456,7 @@ bool PLAYBACK::JumpToFrame(int index)
// make jump outside Greenzone
if (currFrameCounter == greenzone.GetSize() - 1 || JumpToFrame(greenzone.GetSize() - 1))
// seek there from the end of greenzone
SeekingStart(index+1);
SeekingStart(index);
return false;
}
// make jump inside greenzone
@ -476,13 +476,13 @@ bool PLAYBACK::JumpToFrame(int index)
StartFromZero(); // couldn't find a savestate
// continue from the frame
if (index != currFrameCounter)
SeekingStart(index + 1);
SeekingStart(index);
return true;
}
void PLAYBACK::SetLostPosition(int frame)
{
if ((lost_position_frame < frame + 1) || (lost_position_frame > frame + 1 && !lost_position_must_be_fixed))
if ((lost_position_frame - 1 < frame) || (lost_position_frame - 1 > frame && !lost_position_must_be_fixed))
{
if (lost_position_frame)
piano_roll.RedrawRow(lost_position_frame - 1);
@ -497,7 +497,7 @@ int PLAYBACK::GetLostPosition()
int PLAYBACK::GetPauseFrame()
{
return pause_frame;
return pause_frame - 1;
}
int PLAYBACK::GetFlashingPauseFrame()
{

View File

@ -12,7 +12,7 @@ Popup display - Manager of popup windows
* implements all operations with popup windows: initialization, redrawing, centering, screenshot decompression and conversion
* regularly inspects changes of Bookmarks Manager and shows/updates/hides popup windows
* on demend: updates contents of popup windows
* on demand: updates contents of popup windows
* stores resources: coordinates and appearance of popup windows, timings of fade in/out
------------------------------------------------------------------------------------ */

View File

@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
Recorder - Tool for Input recording
[Singleton]
* at the moment of recording movie Input (at the beginning of a frame) by emulator's call the Recorder intercepts Input data and applies its filters (multitracking/etc), then reflects Input changes into History and Greenzone
* at the moment of recording movie Input (at the very end of a frame) by emulator's call the Recorder intercepts Input data and applies its filters (multitracking/etc), then reflects Input changes into History and Greenzone
* regularly tracks virtual joypad buttonpresses and provides data for Piano Roll List Header lights. Also reacts on external changes of Recording status, and updates GUI (Recorder panel and Bookmarks/Branches caption)
* implements Input editing in Read-only mode (ColumnSet by pressing buttons on virtual joypad)
* stores resources: ids and names of multitracking modes, suffixes for TAS Editor window caption

View File

@ -40,7 +40,7 @@ TASEDITOR_CONFIG::TASEDITOR_CONFIG()
enable_hot_changes = true;
jump_to_undo = true;
follow_note_context = true;
bind_markers = true;
bind_markers = false;
empty_marker_notes = true;
combine_consecutive = false;
use_1p_rec = true;

View File

@ -12,8 +12,8 @@ Lua - Manager of Lua features
* implements logic of all functions of "taseditor" Lua library
* stores the list of pending Input changes
* on demend: (from FCEUX Lua engine) updates GUI items on "Lua" panel of TAS Editor window
* stores resources: ids of joypads for Input changes, max length of a name for applychanges()
* on demand: (from FCEUX Lua engine) updates "Run function" button
* stores resources: ids of joypads for Input changes, max length of a name for applychanges(), default caption for "Run function" button
------------------------------------------------------------------------------------ */
#include "taseditor_project.h"
@ -30,7 +30,9 @@ extern GREENZONE greenzone;
extern PIANO_ROLL piano_roll;
extern SELECTION selection;
extern void TaseditorUpdateManualFunctionStatus();
extern void TaseditorDisableManualFunctionIfNeeded();
const char defaultRunFunctionCaption[] = "Run function";
TASEDITOR_LUA::TASEDITOR_LUA()
{
@ -44,19 +46,24 @@ void TASEDITOR_LUA::init()
}
void TASEDITOR_LUA::reset()
{
TaseditorUpdateManualFunctionStatus();
TaseditorDisableManualFunctionIfNeeded();
}
void TASEDITOR_LUA::update()
{
}
void TASEDITOR_LUA::EnableRunFunction()
void TASEDITOR_LUA::EnableRunFunction(const char* caption)
{
if (caption)
SetWindowText(hwndRunFunction, caption);
else
SetWindowText(hwndRunFunction, defaultRunFunctionCaption);
EnableWindow(hwndRunFunction, true);
}
void TASEDITOR_LUA::DisableRunFunction()
{
SetWindowText(hwndRunFunction, defaultRunFunctionCaption);
EnableWindow(hwndRunFunction, false);
}
@ -227,7 +234,7 @@ int TASEDITOR_LUA::getlostplayback()
int TASEDITOR_LUA::getplaybacktarget()
{
if (FCEUMOV_Mode(MOVIEMODE_TASEDITOR))
return playback.GetPauseFrame() - 1;
return playback.GetPauseFrame();
else
return -1;
}

View File

@ -34,7 +34,7 @@ public:
void reset();
void update();
void EnableRunFunction();
void EnableRunFunction(const char* caption = NULL);
void DisableRunFunction();
void InsertDelete_rows_to_Snaphot(SNAPSHOT& snapshot);

View File

@ -363,7 +363,7 @@ void TASEDITOR_WINDOW::update()
case DRAG_MODE_PLAYBACK:
{
// user is dragging Playback cursor - show either normal arrow or arrow+wait
if (playback.GetPauseFrame())
if (playback.GetPauseFrame() >= 0)
cursor_icon = IDC_APPSTARTING;
break;
}
@ -1011,7 +1011,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
taseditor_config.turbo_seek ^= 1;
taseditor_window.UpdateCheckedItems();
// if currently seeking, apply this option immediately
if (playback.GetPauseFrame())
if (playback.GetPauseFrame() >= 0)
turbo = taseditor_config.turbo_seek;
break;
case ID_VIEW_SHOWBRANCHSCREENSHOTS:

View File

@ -127,7 +127,7 @@ extern INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, L
extern void PrintToWindowConsole(int hDlgAsInt, const char* str);
extern void WinLuaOnStart(int hDlgAsInt);
extern void WinLuaOnStop(int hDlgAsInt);
void TaseditorUpdateManualFunctionStatus();
void TaseditorDisableManualFunctionIfNeeded();
#endif
static lua_State *L;
@ -243,7 +243,7 @@ static void FCEU_LuaOnStop() {
turbo = false;
//FCEUD_TurboOff();
#ifdef WIN32
TaseditorUpdateManualFunctionStatus();
TaseditorDisableManualFunctionIfNeeded();
#endif
}
@ -1886,15 +1886,13 @@ void TaseditorManualFunction()
}
#ifdef WIN32
void TaseditorUpdateManualFunctionStatus()
void TaseditorDisableManualFunctionIfNeeded()
{
if (L)
{
// check if LUACALL_TASEDITOR_MANUAL function is not nil
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
if (lua_isfunction(L, -1))
taseditor_lua.EnableRunFunction();
else
if (!lua_isfunction(L, -1))
taseditor_lua.DisableRunFunction();
lua_pop(L, 1);
} else taseditor_lua.DisableRunFunction();
@ -4316,17 +4314,22 @@ static int taseditor_registerauto(lua_State *L)
return 1;
}
// bool taseditor.registermanual()
// bool taseditor.registermanual(string caption)
static int taseditor_registermanual(lua_State *L)
{
if (!lua_isnil(L,1))
luaL_checktype(L, 1, LUA_TFUNCTION);
const char* caption = NULL;
if (!lua_isnil(L, 2))
caption = lua_tostring(L, 2);
lua_settop(L,1);
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
lua_insert(L,1);
lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
#ifdef WIN32
TaseditorUpdateManualFunctionStatus();
taseditor_lua.EnableRunFunction(caption);
#endif
return 1;
}