Skip to content

Commit

Permalink
Exposed --time-scale option (previously only available interactively).
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Oct 8, 2010
1 parent da74ace commit 4bd8ed8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions data/gource.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions src/gource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -790,8 +790,6 @@ void Gource::reset() {

files.clear();


time_scale = 1.0f;
idle_time=0;
currtime=0;
lasttime=0;
Expand Down Expand Up @@ -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());
Expand Down
1 change: 0 additions & 1 deletion src/gource.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class Gource : public SDLApp {
bool backgroundSelected;

float last_percent;
float time_scale;

bool stop_position_reached;

Expand Down
19 changes: 17 additions & 2 deletions src/gource_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {

Expand Down
1 change: 1 addition & 0 deletions src/gource_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4bd8ed8

Please sign in to comment.