diff --git a/src/gource.cpp b/src/gource.cpp index 586ab502..04d4136f 100644 --- a/src/gource.cpp +++ b/src/gource.cpp @@ -1725,6 +1725,12 @@ void Gource::logic(float t, float dt) { idle_time = 0.0; } + if(gGourceSettings.transitions.size() > 0 && commit.timestamp > gGourceSettings.transitions.front()) { + gGourceSettings.days_per_second = gGourceSettings.days_per_second_list.front(); + gGourceSettings.days_per_second_list.pop_front(); + gGourceSettings.transitions.pop_front(); + } + if(commit.timestamp > currtime) break; processCommit(commit, t); diff --git a/src/gource_settings.cpp b/src/gource_settings.cpp index cefdc7cf..373a7498 100644 --- a/src/gource_settings.cpp +++ b/src/gource_settings.cpp @@ -71,6 +71,7 @@ void GourceSettings::help(bool extended_help) { printf(" for a number of seconds (default: 3)\n"); printf(" --disable-auto-skip Disable auto skip\n"); printf(" -s, --seconds-per-day SECONDS Speed in seconds per day (default: 10)\n"); + printf(" --transition TIMESTAMP Timestamp for transitions\n"); printf(" --realtime Realtime playback speed\n"); printf(" --no-time-travel Use the time of the last commit if the\n"); printf(" time of a commit is in the past\n"); @@ -288,7 +289,7 @@ GourceSettings::GourceSettings() { arg_types["bloom-intensity"] = "float"; arg_types["bloom-multiplier"] = "float"; arg_types["elasticity"] = "float"; - arg_types["seconds-per-day"] = "float"; + arg_types["seconds-per-day"] = "multi-value"; arg_types["auto-skip-seconds"] = "float"; arg_types["stop-at-time"] = "float"; arg_types["max-user-speed"] = "float"; @@ -312,6 +313,7 @@ GourceSettings::GourceSettings() { arg_types["file-show-filter"] = "multi-value"; arg_types["follow-user"] = "multi-value"; arg_types["highlight-user"] = "multi-value"; + arg_types["transition"] = "multi-value"; arg_types["log-level"] = "string"; arg_types["background-image"] = "string"; @@ -1179,16 +1181,56 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc if((entry = gource_settings->getEntry("seconds-per-day")) != 0) { - if(!entry->hasValue()) conffile.entryException(entry, "specify seconds-per-day (seconds)"); + ConfEntryList* seconds_list = gource_settings->getEntries("seconds-per-day"); - float seconds_per_day = entry->getFloat(); + for(ConfEntryList::iterator it = seconds_list->begin(); it != seconds_list->end(); it++) { - if(seconds_per_day<=0.0f) { - conffile.invalidValueException(entry); + entry = *it; + + if(!entry->hasValue()) conffile.entryException(entry, "specify seconds-per-day (seconds)"); + + float seconds_per_day = entry->getFloat(); + if(seconds_per_day<=0.0f) { + conffile.invalidValueException(entry); + } + + // convert seconds-per-day to days-per-second + days_per_second_list.push_back(1.0 / seconds_per_day); + } + + // initialize with first value + days_per_second = days_per_second_list.front(); + days_per_second_list.pop_front(); + } + + if((entry = gource_settings->getEntry("transition")) != 0) { + + ConfEntryList* timestamps = gource_settings->getEntries("transition"); + + for(ConfEntryList::iterator it = timestamps->begin(); it != timestamps->end(); it++) { + + entry = *it; + + if(!entry->hasValue()) conffile.entryException(entry, "specify transition timestamp (YYYY-MM-DD hh:mm:ss)"); + + std::string timestamp_string = entry->getString(); + + time_t transition; + + if (parseDateTime(timestamp_string, transition)) { + transitions.push_back(transition); + } else { + conffile.invalidValueException(entry); + } } - // convert seconds-per-day to days-per-second - days_per_second = 1.0 / seconds_per_day; + // Make sure that seconds-per-day is specified and that there are + // exactly 1 more seconds-per-day specified than transitions. + if(gource_settings->getEntry("seconds-per-day") == 0 || ( + gource_settings->getEntries("seconds-per-day")->size() != + timestamps->size() + 1)) { + conffile.entryException(entry, "transition requires exactly 1 more seconds-per-day specified"); + } } if((entry = gource_settings->getEntry("auto-skip-seconds")) != 0) { diff --git a/src/gource_settings.h b/src/gource_settings.h index 6b184fb8..33d5705e 100644 --- a/src/gource_settings.h +++ b/src/gource_settings.h @@ -24,6 +24,8 @@ #include "core/settings.h" #include "core/regex.h" +#include + class GourceSettings : public SDLAppSettings { protected: void commandLineOption(const std::string& name, const std::string& value); @@ -145,6 +147,8 @@ class GourceSettings : public SDLAppSettings { std::vector file_show_filters; std::vector user_filters; std::vector user_show_filters; + std::deque days_per_second_list; + std::deque transitions; bool file_extensions; bool file_extension_fallback; diff --git a/src/gource_shell.cpp b/src/gource_shell.cpp index 56c116d4..9a3a4767 100644 --- a/src/gource_shell.cpp +++ b/src/gource_shell.cpp @@ -197,8 +197,6 @@ Gource* GourceShell::getNext() { return 0; } - gGourceSettings.importGourceSettings(*conf, *gource_settings); - //recording a video kind of implies you want this, unless: // -- dont stop requested // -- loop requested