Skip to content
Browse files

Set title, change font size and colour.

  • Loading branch information...
1 parent a1ac241 commit 5968867414631b6c707d78c948a2b023033baedc @acaudwell committed Apr 16, 2010
Showing with 100 additions and 10 deletions.
  1. +12 −0 README
  2. +12 −0 data/gource.1
  3. +20 −6 src/gource.cpp
  4. +51 −4 src/gource_settings.cpp
  5. +5 −0 src/gource_settings.h
View
12 README
@@ -60,6 +60,9 @@ options:
--stop-position POSITION
Stop (exit) at some position in the log (does not work with STDIN).
+ -t, --stop-at-time SECONDS
+ Stop (exit) after a specified number of seconds.
+
--stop-on-idle
Stop on break in activity. May be combined with --stop-position.
@@ -96,6 +99,15 @@ options:
--logo-offset XxY
Offset position of the logo.
+ --title TITLE
+ Set a title.
+
+ --font-size SIZE
+ Font size.
+
+ --font-colour FFFFFF
+ Font colour in hex.
+
--date-format FORMAT
Specify display date string (strftime format).
View
12 data/gource.1
@@ -34,6 +34,9 @@ Begin at some position in the log (between 0.0 and 1.0 or 'random').
\fB \-\-stop\-position POSITION\fR
Stop (exit) at some position in the log (does not work with STDIN).
.TP
+\fB\-t, \-\-stop\-at\-time SECONDS\fR
+Stop (exit) after a specified number of seconds.
+.TP
\fB \-\-stop\-on\-idle\fR
Stop on break in activity. May be combined with \-\-stop\-position.
.TP
@@ -64,6 +67,15 @@ Background colour in hex.
\fB\-\-background\-image IMAGE\fR
Set a background image.
.TP
+\fB\-\-title TITLE\fR
+Set a title
+.TP
+\fB\-\-font\-size SIZE\fR
+Font size.
+.TP
+\fB\-\-font\-colour FFFFFF\fR
+Font colour in hex.
+.TP
\fB\-\-logo IMAGE\fR
Logo to display in the foreground.
.TP
View
26 src/gource.cpp
@@ -33,7 +33,7 @@ Gource::Gource(FrameExporter* exporter) {
fontlarge.dropShadow(true);
fontlarge.roundCoordinates(true);
- fontmedium = fontmanager.grab("FreeSans.ttf", 16);
+ fontmedium = fontmanager.grab("FreeSans.ttf", gGourceSettings.font_size);
fontmedium.dropShadow(true);
fontmedium.roundCoordinates(false);
@@ -1761,10 +1761,6 @@ void Gource::draw(float t, float dt) {
vec3f campos = camera.getPos();
- if(!gGourceSettings.hide_date) {
- fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate);
- }
-
if(logotex!=0) {
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
@@ -1822,9 +1818,27 @@ void Gource::draw(float t, float dt) {
font.draw(display.width/2 - awidth/2,display.height/2 + 30, "(C) 2009 Andrew Caudwell");
}
+ // text using the specified font goes here
+
+ glColor4f(gGourceSettings.font_colour.x, gGourceSettings.font_colour.y, gGourceSettings.font_colour.z, 1.0f);
+
+ if(!gGourceSettings.hide_date) {
+ fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate);
+ }
+
+ if(gGourceSettings.title.size()>0) {
+ fontmedium.alignTop(false);
+ fontmedium.draw(10, display.height - 10, gGourceSettings.title);
+ fontmedium.alignTop(true);
+ }
+
if(message_timer>0.0f) {
- font.draw(1, 3, message);
+ fontmedium.draw(1, 3, message);
}
+
+ // end text
+
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if(debug) {
font.print(1,20, "FPS: %.2f", fps);
View
55 src/gource_settings.cpp
@@ -41,7 +41,7 @@ void GourceSettings::help() {
printf(" -p, --start-position POSITION Begin at some position (0.0-1.0 or 'random')\n");
printf(" --stop-position POSITION Stop at some position\n");
- printf(" --stop-at-time SECONDS Stop after a specified number of seconds\n");
+ printf(" -t, --stop-at-time SECONDS Stop after a specified number of seconds\n");
printf(" --stop-on-idle Stop on break in activity\n");
printf(" --stop-at-end Stop at end of the log\n");
printf(" --dont-stop Keep running after the end of the log\n");
@@ -56,10 +56,12 @@ void GourceSettings::help() {
printf(" -e, --elasticity FLOAT Elasticity of nodes\n\n");
printf(" -b, --background-colour FFFFFF Background colour in hex\n");
- printf(" --background-image IMAGE Set a background image\n\n");
-
+ printf(" --background-image IMAGE Set a background image\n");
printf(" --logo IMAGE Logo to display in the foreground\n");
- printf(" --logo-offset XxY Offset position of the logo\n\n");
+ printf(" --logo-offset XxY Offset position of the logo\n");
+ printf(" --title TITLE Set a title\n");
+ printf(" --font-size SIZE Font size\n");
+ printf(" --font-colour FFFFFF Font colour in hex\n\n");
printf(" --user-image-dir DIRECTORY Dir containing images to use as avatars\n");
printf(" --default-user-image IMAGE Default user image file\n");
@@ -121,6 +123,7 @@ GourceSettings::GourceSettings() {
arg_aliases["p"] = "start-position";
arg_aliases["a"] = "auto-skip-seconds";
arg_aliases["s"] = "seconds-per-day";
+ arg_aliases["t"] = "stop-at-time";
arg_aliases["i"] = "file-idle-time";
arg_aliases["e"] = "elasticity";
arg_aliases["h"] = "help";
@@ -179,6 +182,7 @@ GourceSettings::GourceSettings() {
arg_types["user-friction"] = "float";
arg_types["max-files"] = "int";
+ arg_types["font-size"] = "int";
arg_types["file-filter"] = "multi-value";
arg_types["follow-user"] = "multi-value";
@@ -206,6 +210,8 @@ GourceSettings::GourceSettings() {
arg_types["max-file-lag"] = "string";
arg_types["user-scale"] = "string";
arg_types["camera-mode"] = "string";
+ arg_types["title"] = "string";
+ arg_types["font-colour"] = "string";
}
void GourceSettings::setGourceDefaults() {
@@ -255,6 +261,11 @@ void GourceSettings::setGourceDefaults() {
background_colour = vec3f(0.1f, 0.1f, 0.1f);
background_image = "";
+ title = "";
+
+ font_size = 16;
+ font_colour = vec3f(1.0f, 1.0f, 1.0f);
+
elasticity = 0.0f;
git_branch = "";
@@ -559,6 +570,35 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}
+ if((entry = gource_settings->getEntry("font-size")) != 0) {
+
+ if(!entry->hasValue()) conffile.entryException(entry, "specify font size (FFFFFF)");
+
+ font_size = entry->getInt();
+
+ if(font_size<1 || font_size>100) {
+ conffile.invalidValueException(entry);
+ }
+ }
+
+ if((entry = gource_settings->getEntry("font-colour")) != 0) {
+
+ if(!entry->hasValue()) conffile.entryException(entry, "specify font colour (FFFFFF)");
+
+ int r,g,b;
+
+ std::string colstring = entry->getString();
+
+ if(entry->isVec3()) {
+ font_colour = entry->getVec3();
+ } else if(colstring.size()==6 && sscanf(colstring.c_str(), "%02x%02x%02x", &r, &g, &b) == 3) {
+ font_colour = vec3f(r,g,b);
+ font_colour /= 255.0f;
+ } else {
+ conffile.invalidValueException(entry);
+ }
+ }
+
if((entry = gource_settings->getEntry("background-colour")) != 0) {
if(!entry->hasValue()) conffile.entryException(entry, "specify background colour (FFFFFF)");
@@ -584,6 +624,13 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
background_image = entry->getString();
}
+ if((entry = gource_settings->getEntry("title")) != 0) {
+
+ if(!entry->hasValue()) conffile.entryException(entry, "specify title");
+
+ title = entry->getString();
+ }
+
if((entry = gource_settings->getEntry("logo")) != 0) {
if(!entry->hasValue()) conffile.entryException(entry, "specify logo (image path)");
View
5 src/gource_settings.h
@@ -84,6 +84,11 @@ class GourceSettings : public SDLAppSettings {
vec3f background_colour;
std::string background_image;
+ std::string title;
+
+ int font_size;
+ vec3f font_colour;
+
float elasticity;
std::string git_branch;

0 comments on commit 5968867

Please sign in to comment.
Something went wrong with that request. Please try again.