122
118
file_key = FileKey(1.0f);
124
camera = ZoomCamera(vec3f(0,0, -300), vec3f(0.0, 0.0, 0.0), 250.0, 5000.0);
120
camera = ZoomCamera(vec3(0,0, -300), vec3(0.0, 0.0, 0.0), gGourceSettings.camera_zoom_default, gGourceSettings.camera_zoom_max);
125
121
camera.setPadding(gGourceSettings.padding);
127
123
setCameraMode(gGourceSettings.camera_mode);
179
187
if(output_file != "-") fclose(fh);
182
RCommitLog* Gource::determineFormat(const std::string& logfile) {
183
debugLog("determineFormat(%s)\n", logfile.c_str());
185
RCommitLog* clog = 0;
187
//we've been told what format to use
188
if(gGourceSettings.log_format.size() > 0) {
189
debugLog("--log-format = %s\n", gGourceSettings.log_format.c_str());
191
if(gGourceSettings.log_format == "git") {
192
clog = new GitCommitLog(logfile);
193
if(clog->checkFormat()) return clog;
196
clog = new GitRawCommitLog(logfile);
197
if(clog->checkFormat()) return clog;
201
if(gGourceSettings.log_format == "hg") {
202
clog = new MercurialLog(logfile);
203
if(clog->checkFormat()) return clog;
206
if(gGourceSettings.log_format == "bzr") {
207
clog = new BazaarLog(logfile);
208
if(clog->checkFormat()) return clog;
212
if(gGourceSettings.log_format == "cvs") {
213
clog = new CVSEXPCommitLog(logfile);
214
if(clog->checkFormat()) return clog;
218
if(gGourceSettings.log_format == "custom") {
219
clog = new CustomLog(logfile);
220
if(clog->checkFormat()) return clog;
224
if(gGourceSettings.log_format == "apache") {
225
clog = new ApacheCombinedLog(logfile);
226
if(clog->checkFormat()) return clog;
230
if(gGourceSettings.log_format == "svn") {
231
clog = new SVNCommitLog(logfile);
232
if(clog->checkFormat()) return clog;
236
if(gGourceSettings.log_format == "cvs2cl") {
237
clog = new CVS2CLCommitLog(logfile);
238
if(clog->checkFormat()) return clog;
246
debugLog("trying git...\n");
247
clog = new GitCommitLog(logfile);
248
if(clog->checkFormat()) return clog;
253
debugLog("trying mercurial...\n");
254
clog = new MercurialLog(logfile);
255
if(clog->checkFormat()) return clog;
260
debugLog("trying bzr...\n");
261
clog = new BazaarLog(logfile);
262
if(clog->checkFormat()) return clog;
267
debugLog("trying git raw...\n");
268
clog = new GitRawCommitLog(logfile);
269
if(clog->checkFormat()) return clog;
274
debugLog("trying cvs-exp...\n");
275
clog = new CVSEXPCommitLog(logfile);
276
if(clog->checkFormat()) return clog;
281
debugLog("trying svn...\n");
282
clog = new SVNCommitLog(logfile);
283
if(clog->checkFormat()) return clog;
288
debugLog("trying cvs2cl...\n");
289
clog = new CVS2CLCommitLog(logfile);
290
if(clog->checkFormat()) return clog;
295
debugLog("trying custom...\n");
296
clog = new CustomLog(logfile);
297
if(clog->checkFormat()) return clog;
302
debugLog("trying apache combined...\n");
303
clog = new ApacheCombinedLog(logfile);
304
if(clog->checkFormat()) return clog;
311
190
Gource::~Gource() {
314
if(commitlog!=0) delete commitlog;
315
if(root!=0) delete root;
193
if(logmill!=0) delete logmill;
194
if(root!=0) delete root;
318
197
gGourceSettings.setGourceDefaults();
451
351
distance /= zoom_multi;
453
if(distance < 100.0f) distance = 100.0f;
353
if(distance < gGourceSettings.camera_zoom_min) distance = gGourceSettings.camera_zoom_min;
455
355
distance *= zoom_multi;
457
if(distance > 4999.0f) distance = 4999.0f;
357
if(distance > gGourceSettings.camera_zoom_max) distance = gGourceSettings.camera_zoom_max;
460
360
camera.setDistance(distance);
363
#if SDL_VERSION_ATLEAST(1,3,0)
364
void Gource::mouseWheel(SDL_MouseWheelEvent *e) {
366
int mouse_x, mouse_y;
367
SDL_GetMouseState(&mouse_x, &mouse_y);
369
vec2 mousepos(mouse_x, mouse_y);
463
382
void Gource::mouseClick(SDL_MouseButtonEvent *e) {
464
383
if(commitlog==0) return;
465
384
if(gGourceSettings.hide_mouse) return;
478
397
if(e->button == SDL_BUTTON_LEFT || e->button == SDL_BUTTON_RIGHT) {
479
398
if(!cursor.buttonPressed()) {
400
#if SDL_VERSION_ATLEAST(1,3,0)
401
SDL_SetRelativeMouseMode(SDL_FALSE);
402
SDL_WarpMouseInWindow(display.sdl_window, mousepos.x, mousepos.y);
404
SDL_WarpMouse(mousepos.x, mousepos.y);
480
406
cursor.showCursor(true);
482
SDL_WarpMouse(mousepos.x, mousepos.y);
682
609
if (e->type == SDL_KEYUP) return;
684
611
if (e->type == SDL_KEYDOWN) {
685
if (e->keysym.unicode == SDLK_ESCAPE) {
613
#if SDL_VERSION_ATLEAST(1,3,0)
614
bool key_escape = e->keysym.scancode == SDL_SCANCODE_ESCAPE;
615
bool key_tab = e->keysym.scancode == SDL_SCANCODE_TAB;
616
bool key_space = e->keysym.scancode == SDL_SCANCODE_SPACE;
617
bool key_plus = e->keysym.scancode == SDL_SCANCODE_EQUALS;
618
bool key_equals = e->keysym.scancode == SDL_SCANCODE_EQUALS;
619
bool key_minus = e->keysym.scancode == SDL_SCANCODE_MINUS;
620
bool key_leftbracket = e->keysym.scancode == SDL_SCANCODE_LEFTBRACKET;
621
bool key_rightbracket = e->keysym.scancode == SDL_SCANCODE_RIGHTBRACKET;
622
bool key_comma = e->keysym.scancode == SDL_SCANCODE_COMMA;
623
bool key_period = e->keysym.scancode == SDL_SCANCODE_PERIOD;
624
bool key_slash = e->keysym.scancode == SDL_SCANCODE_SLASH;
626
bool key_escape = e->keysym.unicode == SDLK_ESCAPE;
627
bool key_tab = e->keysym.unicode == SDLK_TAB;
628
bool key_space = e->keysym.unicode == SDLK_SPACE;
629
bool key_plus = e->keysym.unicode == SDLK_PLUS;
630
bool key_equals = e->keysym.unicode == SDLK_EQUALS;
631
bool key_minus = e->keysym.unicode == SDLK_MINUS;
632
bool key_leftbracket = e->keysym.unicode == SDLK_LEFTBRACKET;
633
bool key_rightbracket = e->keysym.unicode == SDLK_RIGHTBRACKET;
634
bool key_comma = e->keysym.unicode == SDLK_COMMA;
635
bool key_period = e->keysym.unicode == SDLK_PERIOD;
636
bool key_slash = e->keysym.unicode == SDLK_SLASH;
689
643
if(commitlog==0) return;
981
937
RFile* Gource::addFile(const RCommitFile& cf) {
939
//if we already have max files in circulation
940
//we cant add any more
941
if(gGourceSettings.max_files > 0 && files.size() >= gGourceSettings.max_files) return 0;
943
//see if this is a directory
944
std::string file_as_dir = cf.filename;
945
if(file_as_dir[file_as_dir.size()-1] != '/') file_as_dir.append("/");
947
if(root->isDir(file_as_dir)) return 0;
983
949
int tagid = tag_seq++;
985
RFile* file = new RFile(cf.filename, cf.colour, vec2f(0.0,0.0), tagid);
951
RFile* file = new RFile(cf.filename, cf.colour, vec2(0.0,0.0), tagid);
987
953
files[cf.filename] = file;
988
954
tagfilemap[tagid] = file;
1105
1070
void Gource::processCommit(RCommit& commit, float t) {
1107
//check user against filters, if found, discard commit
1108
if(!gGourceSettings.user_filters.empty()) {
1109
for(std::vector<Regex*>::iterator ri = gGourceSettings.user_filters.begin(); ri != gGourceSettings.user_filters.end(); ri++) {
1112
if(r->match(commit.username)) {
1118
1072
//find files of this commit or create it
1119
1073
for(std::list<RCommitFile>::iterator it = commit.files.begin(); it != commit.files.end(); it++) {
1121
1075
RCommitFile& cf = *it;
1122
1076
RFile* file = 0;
1124
//check filename against filters
1125
if(!gGourceSettings.file_filters.empty()) {
1127
bool filtered_filename = false;
1129
for(std::vector<Regex*>::iterator ri = gGourceSettings.file_filters.begin(); ri != gGourceSettings.file_filters.end(); ri++) {
1132
if(r->match(cf.filename)) {
1133
filtered_filename = true;
1138
if(filtered_filename) continue;
1141
1078
//is this a directory (ends in slash)
1142
1079
//deleting a directory - find directory: then for each file, remove each file
1204
1138
if(user == 0) {
1205
1139
user = addUser(username);
1207
// set the highlighted flag if name matches a highlighted user
1208
for(std::vector<std::string>::iterator hi = gGourceSettings.highlight_users.begin(); hi != gGourceSettings.highlight_users.end(); hi++) {
1209
std::string highlight = *hi;
1141
if(gGourceSettings.highlight_all_users) user->setHighlighted(true);
1144
// set the highlighted flag if name matches a highlighted user
1145
for(std::vector<std::string>::iterator hi = gGourceSettings.highlight_users.begin(); hi != gGourceSettings.highlight_users.end(); hi++) {
1146
std::string highlight = *hi;
1211
if(highlight.size() && user->getName() == highlight) {
1212
user->setHighlighted(true);
1148
if(!highlight.empty() && user->getName() == highlight) {
1149
user->setHighlighted(true);
1514
1454
void Gource::logic(float t, float dt) {
1516
if(draw_loading) return;
1456
if(shutdown && logmill->isFinished()) {
1518
1461
if(message_timer>0.0f) message_timer -= dt;
1519
1462
if(splash>0.0f) splash -= dt;
1521
1464
//init log file
1522
1465
if(commitlog == 0) {
1526
commitlog = determineFormat(logfile);
1528
} catch(SeekLogException& exception) {
1529
throw SDLAppException("unable to read log file");
1532
if(commitlog == 0) {
1533
//if not in a git dir and no log file, show help
1534
if(logfile.size() == 0 || logfile == ".") {
1467
if(!logmill->isFinished()) return;
1469
commitlog = logmill->getLog();
1471
std::string error = logmill->getError();
1475
if(!error.empty()) {
1476
throw SDLAppException(error);
1479
if(frameExporter!=0) frameExporter->stop();
1537
1483
SDLAppException exception("");
1538
1484
exception.setShowHelp(true);
1539
1486
throw exception;
1540
} else if(SDLAppDirExists(logfile)) {
1541
throw SDLAppException("directory not supported");
1543
throw SDLAppException("unsupported log format (you may need to regenerate your log file)");
1554
1497
slider.logic(dt);
1504
#if SDL_VERSION_ATLEAST(1,3,0)
1505
Uint8 *keystate = SDL_GetKeyboardState(0);
1507
right = keystate[SDL_SCANCODE_RIGHT];
1508
left = keystate[SDL_SCANCODE_LEFT];
1509
up = keystate[SDL_SCANCODE_UP];
1510
down = keystate[SDL_SCANCODE_DOWN];
1556
1512
Uint8 *keystate = SDL_GetKeyState(0);
1558
if(keystate[SDLK_RIGHT]) {
1514
right = keystate[SDLK_RIGHT];
1515
left = keystate[SDLK_LEFT];
1516
up = keystate[SDLK_UP];
1517
down = keystate[SDLK_DOWN];
1559
1521
cursor_move.x = 10.0;
1560
1522
manual_camera = true;
1563
if(keystate[SDLK_LEFT]) {
1564
1526
cursor_move.x = -10.0;
1565
1527
manual_camera = true;
1568
if(keystate[SDLK_UP]) {
1569
1531
cursor_move.y = -10.0;
1570
1532
manual_camera = true;
1573
if(keystate[SDLK_DOWN]) {
1574
1536
cursor_move.y = 10.0;
1575
1537
manual_camera = true;
1690
1652
updateCamera(dt);
1692
updateTime(commitqueue.size() > 0 ? currtime : lasttime);
1654
updateTime(!commitqueue.empty() ? currtime : lasttime);
1695
1657
void Gource::mousetrace(float dt) {
1697
vec3f cam_pos = camera.getPos();
1659
vec3 cam_pos = camera.getPos();
1699
vec2f projected_mouse = vec2f( -(mousepos.x * 2.0f - ((float)display.width)) / ((float)display.height),
1661
vec2 projected_mouse = vec2( -(mousepos.x * 2.0f - ((float)display.width)) / ((float)display.height),
1700
1662
(1.0f - (2.0f * mousepos.y) / ((float)display.height)))
1702
1664
projected_mouse.x += cam_pos.x;
1814
1776
glColor4f(1.0, 1.0, 1.0, 1.0);
1816
std::string loading_message("Reading Log...");
1817
int width = font.getWidth(loading_message);
1819
font.print(display.width/2 - width/2, display.height/2 - 10, "%s", loading_message.c_str());
1778
const char* progress;
1780
switch(int(runtime*3.0f)%4) {
1795
const char* action = !shutdown ? "Reading Log" : "Aborting";
1797
int width = font.getWidth(action);
1798
font.setColour(vec4(1.0f));
1799
font.print(display.width/2 - width/2, display.height/2 - 10, "%s%s", action, progress);
1822
1802
void Gource::drawBackground(float dt) {
1823
1803
if(!gGourceDrawBackground) return;
1825
display.setClearColour(vec4f(gGourceSettings.background_colour, gGourceSettings.transparent ? 0.0f : 1.0f));
1805
display.setClearColour(vec4(gGourceSettings.background_colour, gGourceSettings.transparent ? 0.0f : 1.0f));
1826
1806
display.clear();
1828
1808
if(backgroundtex!=0) {
2085
2065
RUser* user = it->second;
2087
2067
float alpha = user->getAlpha();
2088
vec3f col = user->getColour();
2068
vec3 col = user->getColour();
2090
user_vbo.add(user->graphic->textureid, user->getPos() - user->dims*0.5f, user->dims, vec4f(col.x, col.y, col.z, alpha));
2070
user_vbo.add(user->graphic->textureid, user->getPos() - user->dims*0.5f, user->dims, vec4(col.x, col.y, col.z, alpha));
2093
2073
user->updateActionsVBO(action_vbo);
2446
2426
glEnable(GL_TEXTURE_2D);
2448
glColor4f(1.0,1.0,1.0,1.0);
2428
fontlarge.setColour(vec4(1.0f));
2449
2429
fontlarge.draw(display.width/2 - logowidth/2,display.height/2 - 30, "Gource");
2431
font.setColour(vec4(1.0f));
2450
2432
font.draw(display.width/2 - cwidth/2,display.height/2 + 10, "Software Version Control Visualization");
2451
2433
font.draw(display.width/2 - awidth/2,display.height/2 + 30, "(C) 2009 Andrew Caudwell");
2454
2436
// text using the specified font goes here
2456
fontmedium.setColour(vec4f(gGourceSettings.font_colour, 1.0f));
2438
fontmedium.setColour(vec4(gGourceSettings.font_colour, 1.0f));
2458
2440
if(!gGourceSettings.hide_date) {
2459
2441
fontmedium.draw(display.width/2 - date_x_offset, 20, displaydate);
2505
font.setAlpha(1.0f);
2487
font.setColour(vec4(1.0f));
2507
2489
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2508
2490
glEnable(GL_BLEND);
2509
2491
glEnable(GL_TEXTURE_2D);
2512
2493
font.print(1,20, "FPS: %.2f", fps);
2513
2494
font.print(1,40,"Days Per Second: %.2f",
2514
2495
gGourceSettings.days_per_second);
2515
font.print(1,60,"Time Scale: %.2f", gGourceSettings.time_scale);
2496
font.print(1,60,"Commit Queue: %d", commitqueue.size());
2516
2497
font.print(1,80,"Users: %d", users.size());
2517
2498
font.print(1,100,"Files: %d", files.size());
2518
2499
font.print(1,120,"Dirs: %d", gGourceDirMap.size());