From bfeca1221d1aa439ed6ca18a7a511189612fad5c Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Mon, 15 Sep 2014 21:25:05 +0200 Subject: [PATCH] More WIP on #96 --- ogl_editor/src/Editor.c | 37 ++++++++++++++++++++++++++++++++++- ogl_editor/src/Menu.c | 1 + ogl_editor/src/Menu.h | 1 + ogl_editor/src/RemoteConnection.c | 2 ++ ogl_editor/src/TrackData.h | 3 +++ ogl_editor/src/TrackView.h | 2 ++ ogl_editor/src/windows/RocketWindow.c | 1 + 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index c6dc65c..db73192 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -289,6 +289,7 @@ void Editor_create() s_editorData.trackData.endRow = 10000; s_editorData.trackData.highlightRowStep = 8; s_editorData.trackData.isPlaying = false; + s_editorData.trackData.isLooping = false; Emgui_setDefaultFont(); } @@ -518,6 +519,7 @@ static bool internalUpdate() void Editor_update() { + TrackData* trackData = getTrackData(); bool need_update = internalUpdate(); if (need_update) @@ -525,6 +527,13 @@ void Editor_update() Editor_updateTrackScroll(); internalUpdate(); } + + if (trackData->isPlaying || trackData->isLooping) + { + printf("loop between %d %d\n", trackData->startLoop, trackData->endLoop); + } + + // } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -854,7 +863,7 @@ static int processCommands() { viewInfo->rowPos = htonl(newRow); viewInfo->selectStartRow = viewInfo->selectStopRow = viewInfo->rowPos; - rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos); + //rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos); } ret = 1; @@ -1246,6 +1255,30 @@ static void onPlay() { RemoteConnection_sendPauseCommand(!RemoteConnection_isPaused()); getTrackData()->isPlaying = !RemoteConnection_isPaused(); + getTrackData()->isLooping = false; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +static void onPlayLoop() +{ + TrackData* trackData = getTrackData(); + const int rowPos = getRowPos(); + const int startLoop = TrackData_getNextLoopmark(trackData, rowPos); + const int endLoop = TrackData_getPrevLoopmark(trackData, rowPos); + + // Make sure we have a range to loop within + + if (startLoop == -1 || endLoop == -1) + return; + + trackData->startLoop = startLoop; + trackData->endLoop = endLoop; + + RemoteConnection_sendPauseCommand(!RemoteConnection_isPaused()); + + trackData->isPlaying = !RemoteConnection_isPaused(); + trackData->isLooping = true; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1488,6 +1521,7 @@ void Editor_menuEvent(int menuItem) case EDITOR_MENU_PREV_KEY : case EDITOR_MENU_NEXT_KEY : case EDITOR_MENU_PLAY : + case EDITOR_MENU_PLAY_LOOP : { endEditing(); } @@ -1567,6 +1601,7 @@ void Editor_menuEvent(int menuItem) // View case EDITOR_MENU_PLAY : onPlay(); break; + case EDITOR_MENU_PLAY_LOOP : onPlayLoop(); break; case EDITOR_MENU_ROWS_UP : onRowStep(-highlightRowStep , NO_SELECTION); break; case EDITOR_MENU_ROWS_DOWN : onRowStep(highlightRowStep , NO_SELECTION); break; case EDITOR_MENU_ROWS_2X_UP : onRowStep(-highlightRowStep * 2 , NO_SELECTION); break; diff --git a/ogl_editor/src/Menu.c b/ogl_editor/src/Menu.c index d5a32c7..9634145 100644 --- a/ogl_editor/src/Menu.c +++ b/ogl_editor/src/Menu.c @@ -65,6 +65,7 @@ MenuDescriptor g_editMenu[] = MenuDescriptor g_viewMenu[] = { { _T("Start/Stop Playback"), EDITOR_MENU_PLAY, EMGUI_KEY_SPACE, 0, 0 }, + { _T("Start Loop Playback"), EDITOR_MENU_PLAY_LOOP, EMGUI_KEY_SPACE, 0, EMGUI_KEY_CTRL }, { _T(""), EDITOR_MENU_SEPARATOR, 0, 0, 0 }, { _T("Jump 8 rows up"), EDITOR_MENU_ROWS_UP, EMGUI_KEY_ARROW_UP, EMGUI_KEY_ALT, EMGUI_KEY_ALT }, { _T("Jump 8 rows down"), EDITOR_MENU_ROWS_DOWN, EMGUI_KEY_ARROW_DOWN, EMGUI_KEY_ALT, EMGUI_KEY_ALT }, diff --git a/ogl_editor/src/Menu.h b/ogl_editor/src/Menu.h index 93e828f..d3cafee 100644 --- a/ogl_editor/src/Menu.h +++ b/ogl_editor/src/Menu.h @@ -69,6 +69,7 @@ enum // View EDITOR_MENU_PLAY, + EDITOR_MENU_PLAY_LOOP, EDITOR_MENU_ROW_UP, EDITOR_MENU_ROW_DOWN, EDITOR_MENU_TRACK_LEFT, diff --git a/ogl_editor/src/RemoteConnection.c b/ogl_editor/src/RemoteConnection.c index 11618ac..40330c8 100644 --- a/ogl_editor/src/RemoteConnection.c +++ b/ogl_editor/src/RemoteConnection.c @@ -365,6 +365,8 @@ void RemoteConnection_sendSetRowCommand(int row) if (!RemoteConnection_connected()) return; + printf("rom %d\n", row); + row = htonl(row); RemoteConnection_send((char *)&cmd, 1, 0); RemoteConnection_send((char *)&row, sizeof(int), 0); diff --git a/ogl_editor/src/TrackData.h b/ogl_editor/src/TrackData.h index 2cff407..feec930 100644 --- a/ogl_editor/src/TrackData.h +++ b/ogl_editor/src/TrackData.h @@ -76,6 +76,9 @@ typedef struct TrackData int highlightRowStep; char* editText; bool isPlaying; + bool isLooping; + int startLoop; + int endLoop; } TrackData; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ogl_editor/src/TrackView.h b/ogl_editor/src/TrackView.h index 57f3544..de003f1 100644 --- a/ogl_editor/src/TrackView.h +++ b/ogl_editor/src/TrackView.h @@ -21,6 +21,8 @@ typedef struct TrackViewInfo int selectStopTrack; int selectStartRow; int selectStopRow; + int loopStart; + int loopEnd; } TrackViewInfo; diff --git a/ogl_editor/src/windows/RocketWindow.c b/ogl_editor/src/windows/RocketWindow.c index 95950b5..a74c135 100644 --- a/ogl_editor/src/windows/RocketWindow.c +++ b/ogl_editor/src/windows/RocketWindow.c @@ -545,6 +545,7 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam case EDITOR_MENU_ENTER_CURRENT_V: case EDITOR_MENU_TAB: case EDITOR_MENU_PLAY: + case EDITOR_MENU_PLAY_LOOP: case EDITOR_MENU_ROWS_UP: case EDITOR_MENU_ROWS_DOWN: case EDITOR_MENU_ROWS_2X_UP: