From 376be44f44ca2afcd55cf8fa94a615a6c996557c Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Sat, 27 Oct 2012 17:44:06 +0200 Subject: [PATCH] Basic playback working --- ogl_editor/src/Editor.c | 18 +++++++++++++++++- ogl_editor/src/TrackView.c | 9 ++++++--- ogl_editor/src/TrackView.h | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index a030ec1..974b778 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -97,6 +97,17 @@ bool Editor_keyDown(int key) return true; } + if (key == ' ') + { + // TODO: Don't start playing if we are in edit mode (but space shouldn't be added in edit mode but we still + // shouldn't start playing if we do + + bool paused = !RemoteConnection_isPaused(); + RemoteConnection_sendPauseCommand(paused); + + return true; + } + return handled_key; } @@ -155,7 +166,7 @@ static void processCommands() case SET_ROW: { RemoteConnection_recv((char*)&newRow, sizeof(int), 0); - //trackView->setEditRow(ntohl(newRow)); + s_editorData.trackViewInfo.rowPos = htonl(newRow); break; } } @@ -170,6 +181,11 @@ void Editor_timedUpdate() while (RemoteConnection_pollRead()) processCommands(); + + if (!RemoteConnection_isPaused()) + { + Editor_update(); + } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ogl_editor/src/TrackView.c b/ogl_editor/src/TrackView.c index df2574c..7770b8d 100644 --- a/ogl_editor/src/TrackView.c +++ b/ogl_editor/src/TrackView.c @@ -43,7 +43,6 @@ static void printRowNumbers(int x, int y, int rowCount, int rowOffset, int rowSp } } - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static void renderChannel(struct sync_track* track, int startX, int startY, int startPos, int endPos) @@ -128,7 +127,7 @@ void TrackView_render(const TrackViewInfo* viewInfo, struct sync_data* syncData) uint i = 0; //, channel_count = 10; - printRowNumbers(2, 42, 40, start_pos, font_size, 8); + printRowNumbers(2, 42, 40, start_pos + viewInfo->rowPos, font_size, 8); if (syncData->num_tracks == 0) return; @@ -141,7 +140,11 @@ void TrackView_render(const TrackViewInfo* viewInfo, struct sync_data* syncData) //i = 0; for (i = 0; i < num_tracks; ++i) - renderChannel(syncData->tracks[i], 40 + (i * 64), 20, start_pos, start_pos + 40); + { + renderChannel(syncData->tracks[i], 40 + (i * 64), 20, + (start_pos + viewInfo->rowPos), + (start_pos + viewInfo->rowPos + 40)); + } uint32_t color = Emgui_color32(127, 127, 127, 56); diff --git a/ogl_editor/src/TrackView.h b/ogl_editor/src/TrackView.h index 0c3e87a..cb3377c 100644 --- a/ogl_editor/src/TrackView.h +++ b/ogl_editor/src/TrackView.h @@ -10,6 +10,7 @@ typedef struct TrackViewInfo int scrollPosX; int windowSizeX; int windowSizeY; + int rowPos; } TrackViewInfo;