Skip to content
Browse files

Apply the modified file colour when the action is applied.

  • Loading branch information...
1 parent 6e2a71d commit ee07e902db4a44dabaf50a2f7b2f864d5536fd44 @acaudwell committed Nov 3, 2012
Showing with 32 additions and 24 deletions.
  1. +17 −7 src/action.cpp
  2. +6 −1 src/action.h
  3. +6 −13 src/gource.cpp
  4. +3 −3 src/gource.h
View
24 src/action.cpp
@@ -27,11 +27,15 @@ RAction::RAction(RUser* source, RFile* target, float addedtime) {
rate = 0.5;
}
+void RAction::apply() {
+ target->touch(colour);
+}
+
void RAction::logic(float dt) {
if(progress >= 1.0) return;
if(progress == 0.0) {
- target->touch(colour);
+ apply();
}
float action_rate = std::min(10.0f, rate * std::max(1.0f, ((float)source->getPendingActionCount())));
@@ -46,10 +50,10 @@ void RAction::drawToVBO(quadbuf& buffer) const {
vec2 dest = target->getAbsolutePos();
//TODO: could use glm::perp
-
- vec2 n = normalise(dest - src);
+
+ vec2 n = normalise(dest - src);
vec2 perp = vec2(-n.y, n.x);
-
+
vec2 offset = perp * target->getSize() * 0.5f;
vec2 offset_src = offset * 0.3f;
@@ -73,9 +77,9 @@ void RAction::draw(float dt) {
vec2 src = source->getPos();
vec2 dest = target->getAbsolutePos();
- vec2 n = normalise(dest - src);
+ vec2 n = normalise(dest - src);
vec2 perp = vec2(-n.y, n.x);
-
+
vec2 offset = perp * target->getSize() * 0.5f;
vec2 offset_src = offset * 0.3f;
@@ -118,6 +122,12 @@ void RemoveAction::logic(float dt) {
}
}
-ModifyAction::ModifyAction(RUser* source, RFile* target, float addedtime) : RAction(source, target, addedtime) {
+ModifyAction::ModifyAction(RUser* source, RFile* target, float addedtime, const vec3& modify_colour)
+ : modify_colour(modify_colour), RAction(source, target, addedtime) {
colour = vec3(1.0, 0.7, 0.3);
}
+
+void ModifyAction::apply() {
+ RAction::apply();
+ target->setFileColour(modify_colour);
+}
View
7 src/action.h
@@ -27,6 +27,7 @@ class RFile;
class RAction {
protected:
vec3 colour;
+ virtual void apply();
public:
RUser* source;
RFile* target;
@@ -59,8 +60,12 @@ class RemoveAction : public RAction {
};
class ModifyAction : public RAction {
+protected:
+ vec3 modify_colour;
public:
- ModifyAction(RUser* source, RFile* target, float addedtime);
+ ModifyAction(RUser* source, RFile* target, float addedtime, const vec3& modify_colour);
+
+ void apply();
};
#endif
View
19 src/gource.cpp
@@ -1046,7 +1046,6 @@ void Gource::readLog() {
}
if(first_read && commitqueue.empty()) {
- fprintf(stderr, "no files on first read\n");
throw SDLAppException("no commits found");
}
@@ -1104,7 +1103,7 @@ void Gource::processCommit(RCommit& commit, float t) {
for(std::list<RFile*>::iterator it = dir_files.begin(); it != dir_files.end(); it++) {
RFile* file = *it;
- addFileAction(commit.username, cf.action, file, t);
+ addFileAction(commit.username, cf, file, t);
}
}
@@ -1115,22 +1114,16 @@ void Gource::processCommit(RCommit& commit, float t) {
if(seen_file != files.end()) file = seen_file->second;
if(file == 0) {
-
file = addFile(cf);
if(!file) continue;
}
- else {
- if (cf.action == "M") {
- file->setFileColour(cf.colour);
- }
- }
- addFileAction(commit.username, cf.action, file, t);
+ addFileAction(commit.username, cf, file, t);
}
}
-void Gource::addFileAction(const std::string& username, const std::string& action, RFile* file, float t) {
+void Gource::addFileAction(const std::string& username, const RCommitFile& cf, RFile* file, float t) {
//create user if havent yet. do it here to ensure at least one of there files
//was added (incase we hit gGourceSettings.max_files)
@@ -1165,13 +1158,13 @@ void Gource::addFileAction(const std::string& username, const std::string& actio
commit_seq++;
- if(action == "D") {
+ if(cf.action == "D") {
userAction = new RemoveAction(user, file, t);
} else {
- if(action == "A") {
+ if(cf.action == "A") {
userAction = new CreateAction(user, file, t);
} else {
- userAction = new ModifyAction(user, file, t);
+ userAction = new ModifyAction(user, file, t, cf.colour);
}
}
View
6 src/gource.h
@@ -193,7 +193,7 @@ class Gource : public SDLApp {
float message_timer;
void setMessage(const char* str, ...);
-
+
void reset();
RUser* addUser(const std::string& username);
@@ -212,7 +212,7 @@ class Gource : public SDLApp {
void logReadingError(const std::string& error);
void processCommit(RCommit& commit, float t);
- void addFileAction(const std::string& username, const std::string& action, RFile* file, float t);
+ void addFileAction(const std::string& username, const RCommitFile& cf, RFile* file, float t);
std::string dateAtPosition(float percent);
@@ -279,7 +279,7 @@ class Gource : public SDLApp {
void reload();
void quit();
-
+
void update(float t, float dt);
void keyPress(SDL_KeyboardEvent *e);
void mouseMove(SDL_MouseMotionEvent *e);

0 comments on commit ee07e90

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