Skip to content

Commit

Permalink
Pressing S randomizes colours (resolve clashes, ugly file colours).
Browse files Browse the repository at this point in the history
  • Loading branch information
acaudwell committed Dec 7, 2010
1 parent e25b02d commit dc25ca0
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Made camera behaviour when zooming and selecting objects more intuitive. * Made camera behaviour when zooming and selecting objects more intuitive.
* Added mouse-over tool tips. * Added mouse-over tool tips.
* Added --highlight-colour option. * Added --highlight-colour option.
* Added --hash-seed option. * Added --hash-seed option. The S key now randomizes colours.
* Added --output-custom-log option. * Added --output-custom-log option.
* Exposed --time-scale option (previously only available interactively). * Exposed --time-scale option (previously only available interactively).
* Removed arbitrary 1024 maximum length limit for log lines. * Removed arbitrary 1024 maximum length limit for log lines.
Expand Down
1 change: 1 addition & 0 deletions README
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ Interactive keyboard commands:
(C) Displays Gource logo (C) Displays Gource logo
(M) Toggle mouse visibility (M) Toggle mouse visibility
(N) Jump forward in time to next log entry. (N) Jump forward in time to next log entry.
(S) Randomize colours.
(+-) Adjust simulation speed. (+-) Adjust simulation speed.
(<>) Adjust time scale. (<>) Adjust time scale.
(TAB) Cycle through visible users (TAB) Cycle through visible users
Expand Down
2 changes: 2 additions & 0 deletions data/gource.1
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ Interactive keyboard commands:
.ti 10 .ti 10
(N) Jump forward in time to next log entry. (N) Jump forward in time to next log entry.
.ti 10 .ti 10
(S) Randomize colours.
.ti 10
(+-) Adjust simulation speed. (+-) Adjust simulation speed.
.ti 10 .ti 10
(<>) Adjust time scale. (<>) Adjust time scale.
Expand Down
4 changes: 4 additions & 0 deletions src/file.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ void RFile::setSelected(bool selected) {
//glEndList(); //glEndList();
} }


void RFile::colourize() {
file_colour = ext.size() ? colourHash(ext) : vec3f(1.0f, 1.0f, 1.0f);
}

const vec3f& RFile::getNameColour() const{ const vec3f& RFile::getNameColour() const{
return selected ? selectedcol : namecol; return selected ? selectedcol : namecol;
} }
Expand Down
1 change: 1 addition & 0 deletions src/file.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class RFile : public Pawn {


const vec3f & getFileColour() const; const vec3f & getFileColour() const;
vec3f getColour() const; vec3f getColour() const;
void colourize();


float getAlpha() const; float getAlpha() const;


Expand Down
28 changes: 27 additions & 1 deletion src/gource.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ void Gource::keyPress(SDL_KeyboardEvent *e) {
gGourceGravity = !gGourceGravity; gGourceGravity = !gGourceGravity;
} }


if (e->keysym.sym == SDLK_s) {
recolour=true;
}

if(e->keysym.unicode == SDLK_TAB) { if(e->keysym.unicode == SDLK_TAB) {
selectNextUser(); selectNextUser();
} }
Expand Down Expand Up @@ -803,6 +807,8 @@ void Gource::reset() {
if(userTree!=0) delete userTree; if(userTree!=0) delete userTree;
if(dirNodeTree!=0) delete dirNodeTree; if(dirNodeTree!=0) delete dirNodeTree;


recolour = false;

userTree = 0; userTree = 0;
dirNodeTree = 0; dirNodeTree = 0;


Expand Down Expand Up @@ -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) { void Gource::logic(float t, float dt) {


if(draw_loading) return; if(draw_loading) return;
Expand Down Expand Up @@ -1436,6 +1456,11 @@ void Gource::logic(float t, float dt) {
rotate_angle = 0.0f; rotate_angle = 0.0f;
} }


if(recolour) {
changeColours();
recolour = false;
}

//still want to update camera while paused //still want to update camera while paused
if(paused) { if(paused) {
updateBounds(); updateBounds();
Expand Down Expand Up @@ -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, font.print(1,340,"Dir Inner Loops: %d (QTree items = %d, nodes = %d)", gGourceDirNodeInnerLoops,
dirNodeTree->item_count, dirNodeTree->node_count); 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,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(selectedUser != 0) {


} }


if(selectedFile != 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()); selectedFile->getDir()->fileCount(), selectedFile->getDir()->visibleFileCount());
} }


Expand Down
5 changes: 5 additions & 0 deletions src/gource.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ class Gource : public SDLApp {
bool mouseclicked; bool mouseclicked;
bool mousedragged; bool mousedragged;



vec2f cursor_move; vec2f cursor_move;


bool recolour;

bool use_selection_bounds; bool use_selection_bounds;
Bounds2D selection_bounds; Bounds2D selection_bounds;


Expand Down Expand Up @@ -208,6 +211,8 @@ class Gource : public SDLApp {
void drawBloom(Frustum &frustum, float dt); void drawBloom(Frustum &frustum, float dt);


void screenshot(); void screenshot();

void changeColours();
public: public:
Gource(FrameExporter* frameExporter = 0); Gource(FrameExporter* frameExporter = 0);
~Gource(); ~Gource();
Expand Down
6 changes: 5 additions & 1 deletion src/user.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ void RUser::applyForceToActions() {


} }


void RUser::colourize() {
usercol = colourHash(name);
}

void RUser::assignUserImage() { void RUser::assignUserImage() {
struct stat fileinfo; struct stat fileinfo;


usercol = colourHash(name); colourize();


TextureResource* graphic = 0; TextureResource* graphic = 0;


Expand Down
3 changes: 2 additions & 1 deletion src/user.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class RUser : public Pawn {
RUser(const std::string& name, vec2f pos, int tagid); RUser(const std::string& name, vec2f pos, int tagid);


vec3f getColour() const; vec3f getColour() const;

void colourize();

const std::string& getName() const; const std::string& getName() const;


void fileRemoved(RFile* f); void fileRemoved(RFile* f);
Expand Down

0 comments on commit dc25ca0

Please sign in to comment.