Permalink
Browse files

Pressing S randomizes colours (resolve clashes, ugly file colours).

  • Loading branch information...
1 parent e25b02d commit dc25ca00959ce903ccdcba2ec6a81d1a2ecaa859 @acaudwell committed Dec 7, 2010
Showing with 48 additions and 4 deletions.
  1. +1 −1 ChangeLog
  2. +1 −0 README
  3. +2 −0 data/gource.1
  4. +4 −0 src/file.cpp
  5. +1 −0 src/file.h
  6. +27 −1 src/gource.cpp
  7. +5 −0 src/gource.h
  8. +5 −1 src/user.cpp
  9. +2 −1 src/user.h
View
@@ -4,7 +4,7 @@
* Made camera behaviour when zooming and selecting objects more intuitive.
* Added mouse-over tool tips.
* Added --highlight-colour option.
- * Added --hash-seed option.
+ * Added --hash-seed option. The S key now randomizes colours.
* Added --output-custom-log option.
* Exposed --time-scale option (previously only available interactively).
* Removed arbitrary 1024 maximum length limit for log lines.
View
@@ -329,6 +329,7 @@ Interactive keyboard commands:
(C) Displays Gource logo
(M) Toggle mouse visibility
(N) Jump forward in time to next log entry.
+ (S) Randomize colours.
(+-) Adjust simulation speed.
(<>) Adjust time scale.
(TAB) Cycle through visible users
View
@@ -305,6 +305,8 @@ Interactive keyboard commands:
.ti 10
(N) Jump forward in time to next log entry.
.ti 10
+(S) Randomize colours.
+.ti 10
(+-) Adjust simulation speed.
.ti 10
(<>) Adjust time scale.
View
@@ -119,6 +119,10 @@ void RFile::setSelected(bool selected) {
//glEndList();
}
+void RFile::colourize() {
+ file_colour = ext.size() ? colourHash(ext) : vec3f(1.0f, 1.0f, 1.0f);
+}
+
const vec3f& RFile::getNameColour() const{
return selected ? selectedcol : namecol;
}
View
@@ -60,6 +60,7 @@ class RFile : public Pawn {
const vec3f & getFileColour() const;
vec3f getColour() const;
+ void colourize();
float getAlpha() const;
View
@@ -727,6 +727,10 @@ void Gource::keyPress(SDL_KeyboardEvent *e) {
gGourceGravity = !gGourceGravity;
}
+ if (e->keysym.sym == SDLK_s) {
+ recolour=true;
+ }
+
if(e->keysym.unicode == SDLK_TAB) {
selectNextUser();
}
@@ -803,6 +807,8 @@ void Gource::reset() {
if(userTree!=0) delete userTree;
if(dirNodeTree!=0) delete dirNodeTree;
+ recolour = false;
+
userTree = 0;
dirNodeTree = 0;
@@ -1355,6 +1361,20 @@ void Gource::updateCamera(float dt) {
}
}
+//change the string hashing seed and recolour files and users
+void Gource::changeColours() {
+
+ gStringHashSeed = (rand() % 10000) + 1;
+
+ for(std::map<std::string,RUser*>::iterator it = users.begin(); it != users.end(); it++) {
+ it->second->colourize();
+ }
+
+ for(std::map<std::string,RFile*>::iterator it = files.begin(); it != files.end(); it++) {
+ it->second->colourize();
+ }
+}
+
void Gource::logic(float t, float dt) {
if(draw_loading) return;
@@ -1436,6 +1456,11 @@ void Gource::logic(float t, float dt) {
rotate_angle = 0.0f;
}
+ if(recolour) {
+ changeColours();
+ recolour = false;
+ }
+
//still want to update camera while paused
if(paused) {
updateBounds();
@@ -2092,13 +2117,14 @@ void Gource::draw(float t, float dt) {
font.print(1,340,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops,
dirNodeTree->item_count, dirNodeTree->node_count);
font.print(1,360,"Dir Bounds Ratio: %.2f, %.5f", dir_bounds.width() / dir_bounds.height(), rotation_remaining_angle);
+ font.print(1,380,"String Hash Seed: %d", gStringHashSeed);
if(selectedUser != 0) {
}
if(selectedFile != 0) {
- font.print(1,360,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(),
+ font.print(1,400,"%s: %d files (%d visible)", selectedFile->getDir()->getPath().c_str(),
selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount());
}
View
@@ -79,8 +79,11 @@ class Gource : public SDLApp {
bool mouseclicked;
bool mousedragged;
+
vec2f cursor_move;
+ bool recolour;
+
bool use_selection_bounds;
Bounds2D selection_bounds;
@@ -208,6 +211,8 @@ class Gource : public SDLApp {
void drawBloom(Frustum &frustum, float dt);
void screenshot();
+
+ void changeColours();
public:
Gource(FrameExporter* frameExporter = 0);
~Gource();
View
@@ -173,10 +173,14 @@ void RUser::applyForceToActions() {
}
+void RUser::colourize() {
+ usercol = colourHash(name);
+}
+
void RUser::assignUserImage() {
struct stat fileinfo;
- usercol = colourHash(name);
+ colourize();
TextureResource* graphic = 0;
View
@@ -61,7 +61,8 @@ class RUser : public Pawn {
RUser(const std::string& name, vec2f pos, int tagid);
vec3f getColour() const;
-
+ void colourize();
+
const std::string& getName() const;
void fileRemoved(RFile* f);

0 comments on commit dc25ca0

Please sign in to comment.