recording improvements
remove 'r' record shortcut add tpt.record function. Still gives the user a confirm prompt recordings now go into recordings/<timestamp>/, where timestamp is the time the recording was started. <timestamp> is returned by the tpt.record function. Each new recording starts the filenames over at 0 again. you probably still need a lua script to use the recording feature, this should make it easier for those
This commit is contained in:
parent
e4089a276a
commit
6bd068713e
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@ Saves/*
|
||||
scripts/*
|
||||
generated/*
|
||||
includes/*
|
||||
recordings/
|
||||
font/*
|
||||
generate
|
||||
Makefile.me
|
||||
|
@ -1571,6 +1571,11 @@ std::string GameController::WallName(int type)
|
||||
return "";
|
||||
}
|
||||
|
||||
int GameController::Record(bool record)
|
||||
{
|
||||
return gameView->Record(record);
|
||||
}
|
||||
|
||||
void GameController::NotifyAuthUserChanged(Client * sender)
|
||||
{
|
||||
User newUser = sender->GetAuthUser();
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
std::string ElementResolve(int type, int ctype);
|
||||
bool IsValidElement(int type);
|
||||
std::string WallName(int type);
|
||||
int Record(bool record);
|
||||
|
||||
void ResetAir();
|
||||
void ResetSpark();
|
||||
|
@ -186,8 +186,9 @@ GameView::GameView():
|
||||
introTextMessage(introTextData),
|
||||
|
||||
doScreenshot(false),
|
||||
recording(false),
|
||||
screenshotIndex(0),
|
||||
recording(false),
|
||||
recordingFolder(0),
|
||||
recordingIndex(0),
|
||||
currentPoint(ui::Point(0, 0)),
|
||||
lastPoint(ui::Point(0, 0)),
|
||||
@ -1044,28 +1045,31 @@ void GameView::screenshot()
|
||||
doScreenshot = true;
|
||||
}
|
||||
|
||||
void GameView::record()
|
||||
int GameView::Record(bool record)
|
||||
{
|
||||
if(recording)
|
||||
if (!record)
|
||||
{
|
||||
recording = false;
|
||||
recordingIndex = 0;
|
||||
recordingFolder = 0;
|
||||
}
|
||||
else
|
||||
else if (!recording)
|
||||
{
|
||||
class RecordingConfirmation: public ConfirmDialogueCallback {
|
||||
public:
|
||||
GameView * v;
|
||||
RecordingConfirmation(GameView * v): v(v) {}
|
||||
virtual void ConfirmCallback(ConfirmPrompt::DialogueResult result) {
|
||||
if (result == ConfirmPrompt::ResultOkay)
|
||||
{
|
||||
v->recording = true;
|
||||
}
|
||||
}
|
||||
virtual ~RecordingConfirmation() { }
|
||||
};
|
||||
new ConfirmPrompt("Recording", "You're about to start recording all drawn frames. This may use a load of hard disk space.", new RecordingConfirmation(this));
|
||||
// block so that the return value is correct
|
||||
bool record = ConfirmPrompt::Blocking("Recording", "You're about to start recording all drawn frames. This will use a load of disk space.");
|
||||
if (record)
|
||||
{
|
||||
time_t startTime = time(NULL);
|
||||
recordingFolder = startTime;
|
||||
std::stringstream recordingDir;
|
||||
recordingDir << "recordings" << PATH_SEP << recordingFolder;
|
||||
Client::Ref().MakeDirectory("recordings");
|
||||
Client::Ref().MakeDirectory(recordingDir.str().c_str());
|
||||
recording = true;
|
||||
recordingIndex = 0;
|
||||
}
|
||||
}
|
||||
return recordingFolder;
|
||||
}
|
||||
|
||||
void GameView::updateToolButtonScroll()
|
||||
@ -1496,8 +1500,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
case 'r':
|
||||
if (ctrl)
|
||||
c->ReloadSim();
|
||||
else
|
||||
record();
|
||||
break;
|
||||
case 'e':
|
||||
c->OpenElementSearch();
|
||||
@ -2233,6 +2235,7 @@ void GameView::OnDraw()
|
||||
std::vector<char> data = format::VideoBufferToPPM(screenshot);
|
||||
|
||||
std::stringstream filename;
|
||||
filename << "recordings" << PATH_SEP << recordingFolder << PATH_SEP;
|
||||
filename << "frame_";
|
||||
filename << std::setfill('0') << std::setw(6) << (recordingIndex++);
|
||||
filename << ".ppm";
|
||||
|
@ -66,8 +66,9 @@ private:
|
||||
std::string introTextMessage;
|
||||
|
||||
bool doScreenshot;
|
||||
bool recording;
|
||||
int screenshotIndex;
|
||||
bool recording;
|
||||
int recordingFolder;
|
||||
int recordingIndex;
|
||||
|
||||
ui::Point currentPoint, lastPoint;
|
||||
@ -117,7 +118,6 @@ private:
|
||||
void SetSaveButtonTooltips();
|
||||
|
||||
void screenshot();
|
||||
void record();
|
||||
|
||||
void enableShiftBehaviour();
|
||||
void disableShiftBehaviour();
|
||||
@ -147,6 +147,7 @@ public:
|
||||
void ExitPrompt();
|
||||
SelectMode GetSelectMode() { return selectMode; }
|
||||
void BeginStampSelection();
|
||||
int Record(bool record);
|
||||
|
||||
//all of these are only here for one debug lines
|
||||
bool GetMouseDown() { return isMouseDown; }
|
||||
|
@ -2032,4 +2032,14 @@ int luatpt_screenshot(lua_State* l)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int luatpt_record(lua_State* l)
|
||||
{
|
||||
if (!lua_isboolean(l, -1))
|
||||
return luaL_typerror(l, 1, lua_typename(l, LUA_TBOOLEAN));
|
||||
bool record = lua_toboolean(l, -1);
|
||||
int recordingFolder = luacon_controller->Record(record);
|
||||
lua_pushinteger(l, recordingFolder);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -131,6 +131,7 @@ int luatpt_getscript(lua_State* l);
|
||||
int luatpt_setwindowsize(lua_State* l);
|
||||
|
||||
int luatpt_screenshot(lua_State* l);
|
||||
int luatpt_record(lua_State* l);
|
||||
|
||||
|
||||
#endif /* LUASCRIPTHELPER_H_ */
|
||||
|
@ -202,6 +202,7 @@ LuaScriptInterface::LuaScriptInterface(GameController * c, GameModel * m):
|
||||
{"setwindowsize",&luatpt_setwindowsize},
|
||||
{"watertest",&luatpt_togglewater},
|
||||
{"screenshot",&luatpt_screenshot},
|
||||
{"record",&luatpt_record},
|
||||
{"element",&luatpt_getelement},
|
||||
{"element_func",&luatpt_element_func},
|
||||
{"graphics_func",&luatpt_graphics_func},
|
||||
|
Reference in New Issue
Block a user