* 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: -- Usage:
-- Run the script, unpause emulation (or simply Frame Advance once). -- 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. -- Previously selected frames become deselected, all other frames become selected.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@ -51,5 +51,5 @@ function invert_selection()
end end
taseditor.registerauto(display_selection); 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. -- Use the script when you want to exchange recorded input between joypads.
-- Run the script, unpause emulation (or simply Frame Advance once). -- Run the script, unpause emulation (or simply Frame Advance once).
-- Now you can select several frames of input data and then -- 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. -- You can easily modify the script to swap any other joypads.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@ -32,16 +32,6 @@ function swap()
end end
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) (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: 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 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 Main - Main gate between emulator and Taseditor
[Singleton] [Singleton]
@ -108,8 +108,10 @@ bool EnterTasEditor()
history.init(); history.init();
taseditor_lua.init(); taseditor_lua.init();
// either start new movie or use current movie // 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 // create new movie
FCEUI_StopMovie(); FCEUI_StopMovie();
movieMode = MOVIEMODE_TASEDITOR; movieMode = MOVIEMODE_TASEDITOR;
@ -118,12 +120,6 @@ bool EnterTasEditor()
} else } else
{ {
// use current movie to create a new project // 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(); FCEUI_StopMovie();
movieMode = MOVIEMODE_TASEDITOR; movieMode = MOVIEMODE_TASEDITOR;
} }
@ -781,7 +777,7 @@ void ApplyMovieInputConfig()
// this getter contains formula to decide whether to record or replay movie // this getter contains formula to decide whether to record or replay movie
bool TaseditorIsRecording() bool TaseditorIsRecording()
{ {
if (movie_readonly || playback.GetPauseFrame() > currFrameCounter) if (movie_readonly || playback.GetPauseFrame() >= 0)
return false; // replay return false; // replay
return true; // record return true; // record
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -363,7 +363,7 @@ void TASEDITOR_WINDOW::update()
case DRAG_MODE_PLAYBACK: case DRAG_MODE_PLAYBACK:
{ {
// user is dragging Playback cursor - show either normal arrow or arrow+wait // user is dragging Playback cursor - show either normal arrow or arrow+wait
if (playback.GetPauseFrame()) if (playback.GetPauseFrame() >= 0)
cursor_icon = IDC_APPSTARTING; cursor_icon = IDC_APPSTARTING;
break; break;
} }
@ -1011,7 +1011,7 @@ BOOL CALLBACK WndprocTasEditor(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
taseditor_config.turbo_seek ^= 1; taseditor_config.turbo_seek ^= 1;
taseditor_window.UpdateCheckedItems(); taseditor_window.UpdateCheckedItems();
// if currently seeking, apply this option immediately // if currently seeking, apply this option immediately
if (playback.GetPauseFrame()) if (playback.GetPauseFrame() >= 0)
turbo = taseditor_config.turbo_seek; turbo = taseditor_config.turbo_seek;
break; break;
case ID_VIEW_SHOWBRANCHSCREENSHOTS: 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 PrintToWindowConsole(int hDlgAsInt, const char* str);
extern void WinLuaOnStart(int hDlgAsInt); extern void WinLuaOnStart(int hDlgAsInt);
extern void WinLuaOnStop(int hDlgAsInt); extern void WinLuaOnStop(int hDlgAsInt);
void TaseditorUpdateManualFunctionStatus(); void TaseditorDisableManualFunctionIfNeeded();
#endif #endif
static lua_State *L; static lua_State *L;
@ -243,7 +243,7 @@ static void FCEU_LuaOnStop() {
turbo = false; turbo = false;
//FCEUD_TurboOff(); //FCEUD_TurboOff();
#ifdef WIN32 #ifdef WIN32
TaseditorUpdateManualFunctionStatus(); TaseditorDisableManualFunctionIfNeeded();
#endif #endif
} }
@ -1886,15 +1886,13 @@ void TaseditorManualFunction()
} }
#ifdef WIN32 #ifdef WIN32
void TaseditorUpdateManualFunctionStatus() void TaseditorDisableManualFunctionIfNeeded()
{ {
if (L) if (L)
{ {
// check if LUACALL_TASEDITOR_MANUAL function is not nil // check if LUACALL_TASEDITOR_MANUAL function is not nil
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
if (lua_isfunction(L, -1)) if (!lua_isfunction(L, -1))
taseditor_lua.EnableRunFunction();
else
taseditor_lua.DisableRunFunction(); taseditor_lua.DisableRunFunction();
lua_pop(L, 1); lua_pop(L, 1);
} else taseditor_lua.DisableRunFunction(); } else taseditor_lua.DisableRunFunction();
@ -4316,17 +4314,22 @@ static int taseditor_registerauto(lua_State *L)
return 1; return 1;
} }
// bool taseditor.registermanual() // bool taseditor.registermanual(string caption)
static int taseditor_registermanual(lua_State *L) static int taseditor_registermanual(lua_State *L)
{ {
if (!lua_isnil(L,1)) if (!lua_isnil(L,1))
luaL_checktype(L, 1, LUA_TFUNCTION); 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_settop(L,1);
lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); lua_getfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
lua_insert(L,1); lua_insert(L,1);
lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]); lua_setfield(L, LUA_REGISTRYINDEX, luaCallIDStrings[LUACALL_TASEDITOR_MANUAL]);
#ifdef WIN32 #ifdef WIN32
TaseditorUpdateManualFunctionStatus(); taseditor_lua.EnableRunFunction(caption);
#endif #endif
return 1; return 1;
} }