Permalink
Browse files

Exposed --time-scale option (previously only available interactively).

  • Loading branch information...
1 parent da74ace commit 4bd8ed82c83bf887c23cd6eb6a8dd9441024cdcb @acaudwell committed Oct 8, 2010
Showing with 35 additions and 15 deletions.
  1. +1 −0 ChangeLog
  2. +3 −0 README
  3. +3 −0 data/gource.1
  4. +10 −12 src/gource.cpp
  5. +0 −1 src/gource.h
  6. +17 −2 src/gource_settings.cpp
  7. +1 −0 src/gource_settings.h
View
@@ -1,5 +1,6 @@
0.29:
* Fix handling of avatars for UTF-8 usernames on MACOSX (Christian Köstlin).
+ * Exposed --time-scale option (previously only available interactively).
0.28:
* Bazaar support for merged commits (Nick Moffit).
View
@@ -78,6 +78,9 @@ options:
--realtime
Realtime playback speed.
+ -c, --time-scale SCALE
+ Change simulation time scale.
+
-i, --file-idle-time SECONDS
Time in seconds files remain idle before they are removed.
View
@@ -52,6 +52,9 @@ Speed of simulation in seconds per day.
\fB\ \-\-realtime\fR
Realtime playback speed.
.TP
+\fB\-c, \-\-time\-scale SCALE\fR
+Change simulation time scale.
+.TP
\fB\-i, \-\-file\-idle\-time SECONDS\fR
Time in seconds files remain idle before they are removed.
.TP
View
@@ -103,7 +103,7 @@ Gource::Gource(FrameExporter* exporter) {
camera = ZoomCamera(vec3f(0,0, -300), vec3f(0.0, 0.0, 0.0), 250.0, 5000.0);
camera.setPadding(gGourceSettings.padding);
-
+
setCameraMode(gGourceSettings.camera_mode);
root = 0;
@@ -248,7 +248,7 @@ void Gource::update(float t, float dt) {
}
//apply time scaling
- scaled_dt *= time_scale;
+ scaled_dt *= gGourceSettings.time_scale;
//have to manage runtime internally as we're messing with dt
if(!paused) runtime += scaled_dt;
@@ -716,24 +716,24 @@ void Gource::keyPress(SDL_KeyboardEvent *e) {
if(e->keysym.unicode == SDLK_PERIOD) {
- if(time_scale>=1.0) {
- time_scale = std::min(4.0f, floorf(time_scale) + 1.0f);
+ if(gGourceSettings.time_scale>=1.0) {
+ gGourceSettings.time_scale = std::min(4.0f, floorf(gGourceSettings.time_scale) + 1.0f);
} else {
- time_scale = std::min(1.0f, time_scale * 2.0f);
+ gGourceSettings.time_scale = std::min(1.0f, gGourceSettings.time_scale * 2.0f);
}
}
if(e->keysym.unicode == SDLK_COMMA) {
- if(time_scale>1.0) {
- time_scale = std::max(0.0f, floorf(time_scale) - 1.0f);
+ if(gGourceSettings.time_scale>1.0) {
+ gGourceSettings.time_scale = std::max(0.0f, floorf(gGourceSettings.time_scale) - 1.0f);
} else {
- time_scale = std::max(0.25f, time_scale * 0.5f);
+ gGourceSettings.time_scale = std::max(0.25f, gGourceSettings.time_scale * 0.5f);
}
}
if(e->keysym.unicode == SDLK_SLASH) {
- time_scale = 1.0f;
+ gGourceSettings.time_scale = 1.0f;
}
}
}
@@ -790,8 +790,6 @@ void Gource::reset() {
files.clear();
-
- time_scale = 1.0f;
idle_time=0;
currtime=0;
lasttime=0;
@@ -1939,7 +1937,7 @@ void Gource::draw(float t, float dt) {
font.print(1,20, "FPS: %.2f", fps);
font.print(1,40,"Days Per Second: %.2f",
gGourceSettings.days_per_second);
- font.print(1,60,"Time Scale: %.2f", time_scale);
+ font.print(1,60,"Time Scale: %.2f", gGourceSettings.time_scale);
font.print(1,80,"Users: %d", users.size());
font.print(1,100,"Files: %d", files.size());
font.print(1,120,"Dirs: %d", gGourceDirMap.size());
View
@@ -82,7 +82,6 @@ class Gource : public SDLApp {
bool backgroundSelected;
float last_percent;
- float time_scale;
bool stop_position_reached;
@@ -26,7 +26,7 @@ void GourceSettings::help(bool extended_help) {
SDLAppCreateWindowsConsole();
//resize window to fit help message
- SDLAppResizeWindowsConsole(770);
+ SDLAppResizeWindowsConsole(790);
#endif
printf("Gource v%s\n", GOURCE_VERSION);
@@ -50,6 +50,7 @@ void GourceSettings::help(bool extended_help) {
printf(" --disable-auto-skip Disable auto skip\n");
printf(" -s, --seconds-per-day SECONDS Speed in seconds per day (default: 10)\n");
printf(" --realtime Realtime playback speed\n");
+ printf(" -c, --time-scale SCALE Change simuation time scale (default: 1.0)\n");
printf(" -e, --elasticity FLOAT Elasticity of nodes\n\n");
printf(" --user-image-dir DIRECTORY Dir containing images to use as avatars\n");
@@ -152,6 +153,7 @@ GourceSettings::GourceSettings() {
arg_aliases["?"] = "help";
arg_aliases["H"] = "extended-help";
arg_aliases["b"] = "background-colour";
+ arg_aliases["c"] = "time-scale";
arg_aliases["background"] = "background-colour";
arg_aliases["disable-bloom"] = "hide-bloom";
arg_aliases["disable-progress"] = "hide-progress";
@@ -208,6 +210,7 @@ GourceSettings::GourceSettings() {
arg_types["max-user-speed"] = "float";
arg_types["user-friction"] = "float";
arg_types["padding"] = "float";
+ arg_types["time-scale"] = "float";
arg_types["max-files"] = "int";
arg_types["font-size"] = "int";
@@ -270,6 +273,7 @@ void GourceSettings::setGourceDefaults() {
auto_skip_seconds = 3.0f;
days_per_second = 0.1f; // TODO: check this is right
file_idle_time = 60.0f;
+ time_scale = 1.0f;
loop = false;
@@ -576,7 +580,7 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
std::string image_path = gGourceSettings.user_image_dir + dirfile;
std::string name = dirfile.substr(0,extpos);
-
+
#ifdef __APPLE__
CFMutableStringRef help = CFStringCreateMutable(kCFAllocatorDefault, 0);
CFStringAppendCString(help, name.c_str(), kCFStringEncodingUTF8);
@@ -768,6 +772,17 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}
+ if((entry = gource_settings->getEntry("time-scale")) != 0) {
+
+ if(!entry->hasValue())
+ conffile.entryException(entry, "specify time-scale (scale)");
+
+ time_scale = entry->getFloat();
+
+ if(time_scale <= 0.0f || time_scale > 4.0f) {
+ conffile.entryException(entry, "time-scale outside of range 0.0 - 4.0");
+ }
+ }
if((entry = gource_settings->getEntry("start-position")) != 0) {
@@ -106,6 +106,7 @@ class GourceSettings : public SDLAppSettings {
float user_idle_time;
float user_friction;
float user_scale;
+ float time_scale;
bool highlight_dirs;
bool highlight_all_users;

0 comments on commit 4bd8ed8

Please sign in to comment.