Merge and Win32 compile fixes
This commit is contained in:
commit
5fffecc270
@ -8,8 +8,10 @@
|
||||
#include "LoadSave.h"
|
||||
#include "TrackView.h"
|
||||
#include "rlog.h"
|
||||
#include "minmax.h"
|
||||
#include "TrackData.h"
|
||||
#include "RemoteConnection.h"
|
||||
#include "MinecraftiaFont.h"
|
||||
#include "../../sync/sync.h"
|
||||
#include "../../sync/base.h"
|
||||
#include "../../sync/data.h"
|
||||
@ -17,13 +19,33 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct CopyEntry
|
||||
{
|
||||
int track;
|
||||
struct track_key keyFrame;
|
||||
} CopyEntry;
|
||||
|
||||
typedef struct CopyData
|
||||
{
|
||||
CopyEntry* entries;
|
||||
int bufferWidth;
|
||||
int bufferHeight;
|
||||
int count;
|
||||
|
||||
} CopyData;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct EditorData
|
||||
{
|
||||
TrackViewInfo trackViewInfo;
|
||||
TrackData trackData;
|
||||
CopyEntry* copyEntries;
|
||||
int copyCount;
|
||||
} EditorData;
|
||||
|
||||
static EditorData s_editorData;
|
||||
static CopyData s_copyData;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -53,22 +75,21 @@ static inline int getTrackCount()
|
||||
return s_editorData.trackData.syncData.num_tracks;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//static uint64_t fontIds[2];
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Editor_create()
|
||||
{
|
||||
int id;
|
||||
Emgui_create("foo");
|
||||
//fontIds[0] = Emgui_loadFont("/Users/daniel/Library/Fonts/MicroKnight_v1.0.ttf", 11.0f);
|
||||
//fontIds[0] = Emgui_loadFont(FONT_PATH "Arial.ttf", 11.0f);
|
||||
Emgui_setDefaultFont();
|
||||
|
||||
id = Emgui_loadFontBitmap(g_minecraftiaFont, g_minecraftiaFontSize, EMGUI_FONT_MEMORY, 32, 128, g_minecraftiaFontLayout);
|
||||
memset(&s_editorData, 0, sizeof(s_editorData));
|
||||
|
||||
RemoteConnection_createListner();
|
||||
|
||||
s_editorData.trackViewInfo.smallFontId = id;
|
||||
|
||||
Emgui_setDefaultFont();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -85,39 +106,49 @@ void Editor_init()
|
||||
{
|
||||
}
|
||||
|
||||
static char s_numRows[64] = "10000";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void drawStatus()
|
||||
{
|
||||
char temp[256];
|
||||
int row, idx;
|
||||
int active_track = 0;
|
||||
int current_row = 0;
|
||||
float value = 0.0f;
|
||||
const char *str = "---";
|
||||
const struct sync_track* track;
|
||||
struct sync_track** tracks = getTracks();
|
||||
int active_track = getActiveTrack();
|
||||
const int sizeY = s_editorData.trackViewInfo.windowSizeY;
|
||||
|
||||
if (!tracks)
|
||||
return;
|
||||
active_track = getActiveTrack();
|
||||
current_row = s_editorData.trackViewInfo.rowPos;
|
||||
|
||||
track = tracks[active_track];
|
||||
row = s_editorData.trackViewInfo.rowPos;
|
||||
idx = key_idx_floor(track, row);
|
||||
if (idx >= 0)
|
||||
if (tracks)
|
||||
{
|
||||
switch (track->keys[idx].type)
|
||||
const struct sync_track* track = tracks[active_track];
|
||||
int row = s_editorData.trackViewInfo.rowPos;
|
||||
int idx = key_idx_floor(track, row);
|
||||
|
||||
if (idx >= 0)
|
||||
{
|
||||
case KEY_STEP: str = "step"; break;
|
||||
case KEY_LINEAR: str = "linear"; break;
|
||||
case KEY_SMOOTH: str = "smooth"; break;
|
||||
case KEY_RAMP: str = "ramp"; break;
|
||||
default: break;
|
||||
switch (track->keys[idx].type)
|
||||
{
|
||||
case KEY_STEP: str = "step"; break;
|
||||
case KEY_LINEAR: str = "linear"; break;
|
||||
case KEY_SMOOTH: str = "smooth"; break;
|
||||
case KEY_RAMP: str = "ramp"; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
value = sync_get_val(track, row);
|
||||
}
|
||||
|
||||
snprintf(temp, 256, "track %d row %d value %f type %s", active_track, row, sync_get_val(track, row), str);
|
||||
snprintf(temp, 256, "track %d row %d value %f type %s", active_track, current_row, value, str);
|
||||
|
||||
Emgui_fill(Emgui_color32(0x10, 0x10, 0x10, 0xff), 1, 588, 400, 11);
|
||||
Emgui_drawText(temp, 3, 590, Emgui_color32(255, 255, 255, 255));
|
||||
Emgui_fill(Emgui_color32(0x10, 0x10, 0x10, 0xff), 1, sizeY - 12, 400, 11);
|
||||
Emgui_drawText(temp, 3, sizeY - 10, Emgui_color32(255, 255, 255, 255));
|
||||
Emgui_editBoxXY(400, sizeY - 14, 100, 12, s_numRows);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -133,6 +164,83 @@ void Editor_update()
|
||||
Emgui_end();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void copySelection(int row, int track, int selectLeft, int selectRight, int selectTop, int selectBottom)
|
||||
{
|
||||
CopyEntry* entry = 0;
|
||||
int copy_count = 0;
|
||||
struct sync_track** tracks = getTracks();
|
||||
|
||||
// Count how much we need to copy
|
||||
|
||||
for (track = selectLeft; track <= selectRight; ++track)
|
||||
{
|
||||
struct sync_track* t = tracks[track];
|
||||
for (row = selectTop; row <= selectBottom; ++row)
|
||||
{
|
||||
int idx = sync_find_key(t, row);
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
copy_count++;
|
||||
}
|
||||
}
|
||||
|
||||
free(s_copyData.entries);
|
||||
entry = s_copyData.entries = malloc(sizeof(CopyEntry) * copy_count);
|
||||
|
||||
for (track = selectLeft; track <= selectRight; ++track)
|
||||
{
|
||||
struct sync_track* t = tracks[track];
|
||||
for (row = selectTop; row <= selectBottom; ++row)
|
||||
{
|
||||
int idx = sync_find_key(t, row);
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
entry->track = track - selectLeft;
|
||||
entry->keyFrame = t->keys[idx];
|
||||
entry->keyFrame.row -= selectTop;
|
||||
entry++;
|
||||
}
|
||||
}
|
||||
|
||||
s_copyData.bufferWidth = selectRight - selectLeft + 1;
|
||||
s_copyData.bufferHeight = selectBottom - selectTop + 1;
|
||||
s_copyData.count = copy_count;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void deleteArea(int rowPos, int track, int bufferWidth, int bufferHeight)
|
||||
{
|
||||
int i, j;
|
||||
const int track_count = getTrackCount();
|
||||
struct sync_track** tracks = getTracks();
|
||||
|
||||
for (i = 0; i < bufferWidth; ++i)
|
||||
{
|
||||
struct sync_track* t;
|
||||
int trackPos = track + i;
|
||||
int trackIndex = trackPos;
|
||||
|
||||
if (trackPos >= track_count)
|
||||
continue;
|
||||
|
||||
t = tracks[trackIndex];
|
||||
|
||||
for (j = 0; j < bufferHeight; ++j)
|
||||
{
|
||||
int row = rowPos + j;
|
||||
|
||||
RemoteConnection_sendDeleteKeyCommand(t->name, row);
|
||||
|
||||
if (is_key_frame(t, row))
|
||||
sync_del_key(t, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -142,106 +250,259 @@ static bool is_editing = false;
|
||||
bool Editor_keyDown(int key, int modifiers)
|
||||
{
|
||||
bool handled_key = true;
|
||||
TrackViewInfo* viewInfo = &s_editorData.trackViewInfo;
|
||||
bool paused = RemoteConnection_isPaused();
|
||||
struct sync_track** tracks = getTracks();
|
||||
int active_track = getActiveTrack();
|
||||
int row_pos = s_editorData.trackViewInfo.rowPos;
|
||||
int row_pos = viewInfo->rowPos;
|
||||
|
||||
const int selectLeft = mini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
const int selectRight = maxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
const int selectTop = mini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||
const int selectBottom = maxi(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||
|
||||
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
|
||||
|
||||
RemoteConnection_sendPauseCommand(!paused);
|
||||
Editor_update();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!paused)
|
||||
return false;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case EMGUI_ARROW_DOWN:
|
||||
{
|
||||
if (paused)
|
||||
int row = row_pos;
|
||||
|
||||
row += modifiers & EDITOR_KEY_ALT ? 8 : 1;
|
||||
viewInfo->rowPos = row;
|
||||
|
||||
if (modifiers & EDITOR_KEY_SHIFT)
|
||||
{
|
||||
int row = row_pos;
|
||||
|
||||
if (modifiers & EDITOR_KEY_ALT)
|
||||
row += 8;
|
||||
else
|
||||
row++;
|
||||
|
||||
s_editorData.trackViewInfo.rowPos = row;
|
||||
|
||||
RemoteConnection_sendSetRowCommand(row);
|
||||
handled_key = true;
|
||||
viewInfo->selectStopRow = row;
|
||||
break;
|
||||
}
|
||||
|
||||
viewInfo->selectStartRow = viewInfo->selectStopRow = row;
|
||||
viewInfo->selectStartTrack = viewInfo->selectStopTrack = active_track;
|
||||
|
||||
RemoteConnection_sendSetRowCommand(row);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EMGUI_ARROW_UP:
|
||||
{
|
||||
if (paused)
|
||||
int row = row_pos;
|
||||
|
||||
row -= modifiers & EDITOR_KEY_ALT ? 8 : 1;
|
||||
|
||||
if ((modifiers & EDITOR_KEY_COMMAND) || row < 0)
|
||||
row = 0;
|
||||
|
||||
viewInfo->rowPos = row;
|
||||
|
||||
if (modifiers & EDITOR_KEY_SHIFT)
|
||||
{
|
||||
int row = row_pos;
|
||||
|
||||
if (modifiers & EDITOR_KEY_ALT)
|
||||
row -= 8;
|
||||
else
|
||||
row--;
|
||||
|
||||
if (row < 0)
|
||||
row = 0;
|
||||
|
||||
s_editorData.trackViewInfo.rowPos = row;
|
||||
|
||||
RemoteConnection_sendSetRowCommand(row);
|
||||
handled_key = true;
|
||||
viewInfo->selectStopRow = row;
|
||||
break;
|
||||
}
|
||||
|
||||
viewInfo->selectStartRow = viewInfo->selectStopRow = row;
|
||||
viewInfo->selectStartTrack = viewInfo->selectStopTrack = active_track;
|
||||
|
||||
RemoteConnection_sendSetRowCommand(row);
|
||||
handled_key = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EMGUI_ARROW_LEFT:
|
||||
{
|
||||
if (paused)
|
||||
{
|
||||
int track = getActiveTrack(); track--;
|
||||
setActiveTrack(track < 0 ? 0 : track);
|
||||
int track = getActiveTrack() - 1;
|
||||
|
||||
handled_key = true;
|
||||
if (modifiers & EDITOR_KEY_COMMAND)
|
||||
track = 0;
|
||||
|
||||
setActiveTrack(track < 0 ? 0 : track);
|
||||
|
||||
if (modifiers & EDITOR_KEY_SHIFT)
|
||||
{
|
||||
viewInfo->selectStopTrack = track;
|
||||
break;
|
||||
}
|
||||
|
||||
viewInfo->selectStartRow = viewInfo->selectStopRow = row_pos;
|
||||
viewInfo->selectStartTrack = viewInfo->selectStopTrack = track;
|
||||
|
||||
handled_key = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case EMGUI_ARROW_RIGHT:
|
||||
{
|
||||
if (paused)
|
||||
int track = getActiveTrack() + 1;
|
||||
int track_count = getTrackCount();
|
||||
|
||||
if (track >= track_count)
|
||||
track = track_count - 1;
|
||||
|
||||
if (modifiers & EDITOR_KEY_COMMAND)
|
||||
track = track_count - 1;
|
||||
|
||||
setActiveTrack(track);
|
||||
|
||||
if (modifiers & EDITOR_KEY_SHIFT)
|
||||
{
|
||||
int track = getActiveTrack(); track++;
|
||||
|
||||
if (track >= getTrackCount())
|
||||
track = getTrackCount() - 1;
|
||||
|
||||
setActiveTrack(track);
|
||||
|
||||
handled_key = true;
|
||||
viewInfo->selectStopTrack = track;
|
||||
break;
|
||||
}
|
||||
|
||||
viewInfo->selectStartRow = viewInfo->selectStopRow = row_pos;
|
||||
viewInfo->selectStartTrack = viewInfo->selectStopTrack = track;
|
||||
|
||||
handled_key = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default : handled_key = false; break;
|
||||
}
|
||||
|
||||
// do edit here
|
||||
// handle copy of tracks/values
|
||||
|
||||
if (paused)
|
||||
if (key == 'c' && (modifiers & EDITOR_KEY_COMMAND))
|
||||
{
|
||||
if ((key >= '0' && key <= '9') || key == '.' || key == '-')
|
||||
copySelection(row_pos, active_track, selectLeft, selectRight, selectTop, selectBottom);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == 'x' && (modifiers & EDITOR_KEY_COMMAND))
|
||||
{
|
||||
copySelection(row_pos, active_track, selectLeft, selectRight, selectTop, selectBottom);
|
||||
deleteArea(selectTop, selectLeft, s_copyData.bufferWidth, s_copyData.bufferHeight);
|
||||
handled_key = true;
|
||||
}
|
||||
|
||||
// Handle paste of data
|
||||
|
||||
if (key == 'v' && (modifiers & EDITOR_KEY_COMMAND))
|
||||
{
|
||||
const int buffer_width = s_copyData.bufferWidth;
|
||||
const int buffer_height = s_copyData.bufferHeight;
|
||||
const int buffer_size = s_copyData.count;
|
||||
const int track_count = getTrackCount();
|
||||
int i, trackPos;
|
||||
|
||||
if (!s_copyData.entries)
|
||||
return false;
|
||||
|
||||
// First clear the paste area
|
||||
|
||||
deleteArea(row_pos, active_track, buffer_width, buffer_height);
|
||||
|
||||
for (i = 0; i < buffer_size; ++i)
|
||||
{
|
||||
if (!is_editing)
|
||||
const CopyEntry* ce = &s_copyData.entries[i];
|
||||
|
||||
assert(ce->track >= 0);
|
||||
assert(ce->track < buffer_width);
|
||||
assert(ce->keyFrame.row >= 0);
|
||||
assert(ce->keyFrame.row < buffer_height);
|
||||
|
||||
trackPos = active_track + ce->track;
|
||||
if (trackPos < track_count)
|
||||
{
|
||||
memset(s_editBuffer, 0, sizeof(s_editBuffer));
|
||||
is_editing = true;
|
||||
size_t trackIndex = trackPos;
|
||||
struct track_key key = ce->keyFrame;
|
||||
key.row += row_pos;
|
||||
|
||||
rlog(R_INFO, "key.row %d\n", key.row);
|
||||
|
||||
sync_set_key(tracks[trackIndex], &key);
|
||||
|
||||
RemoteConnection_sendSetKeyCommand(tracks[trackIndex]->name, &key);
|
||||
}
|
||||
|
||||
s_editBuffer[strlen(s_editBuffer)] = (char)key;
|
||||
s_editorData.trackData.editText = s_editBuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (is_editing)
|
||||
|
||||
handled_key = true;
|
||||
}
|
||||
|
||||
// Handle biasing of values
|
||||
|
||||
if ((key >= '1' && key <= '9') && ((modifiers & EDITOR_KEY_CTRL) || (modifiers & EDITOR_KEY_ALT)))
|
||||
{
|
||||
struct sync_track** tracks;
|
||||
int track, row;
|
||||
|
||||
float bias_value = 0.0f;
|
||||
tracks = getTracks();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case '1' : bias_value = 0.01f; break;
|
||||
case '2' : bias_value = 0.1f; break;
|
||||
case '3' : bias_value = 1.0f; break;
|
||||
case '4' : bias_value = 10.f; break;
|
||||
case '5' : bias_value = 100.0f; break;
|
||||
case '6' : bias_value = 1000.0f; break;
|
||||
case '7' : bias_value = 10000.0f; break;
|
||||
}
|
||||
|
||||
bias_value = modifiers & EDITOR_KEY_ALT ? -bias_value : bias_value;
|
||||
|
||||
for (track = selectLeft; track <= selectRight; ++track)
|
||||
{
|
||||
struct sync_track* t = tracks[track];
|
||||
|
||||
for (row = selectTop; row <= selectBottom; ++row)
|
||||
{
|
||||
struct track_key newKey;
|
||||
int idx = sync_find_key(t, row);
|
||||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
newKey = t->keys[idx];
|
||||
newKey.value += bias_value;
|
||||
|
||||
sync_set_key(t, &newKey);
|
||||
|
||||
RemoteConnection_sendSetKeyCommand(t->name, &newKey);
|
||||
}
|
||||
}
|
||||
|
||||
Editor_update();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// do edit here and biasing here
|
||||
|
||||
if ((key >= '0' && key <= '9') || key == '.' || key == '-')
|
||||
{
|
||||
if (!is_editing)
|
||||
{
|
||||
memset(s_editBuffer, 0, sizeof(s_editBuffer));
|
||||
is_editing = true;
|
||||
}
|
||||
|
||||
s_editBuffer[strlen(s_editBuffer)] = (char)key;
|
||||
s_editorData.trackData.editText = s_editBuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (is_editing)
|
||||
{
|
||||
// if we press esc we discard the value
|
||||
|
||||
if (key != 27)
|
||||
{
|
||||
const char* track_name;
|
||||
struct track_key key;
|
||||
@ -258,39 +519,30 @@ bool Editor_keyDown(int key, int modifiers)
|
||||
rlog(R_INFO, "Setting key %f at %d row %d (name %s)\n", key.value, active_track, key.row, track_name);
|
||||
|
||||
RemoteConnection_sendSetKeyCommand(track_name, &key);
|
||||
|
||||
is_editing = false;
|
||||
s_editorData.trackData.editText = 0;
|
||||
}
|
||||
|
||||
if (key == 'i')
|
||||
{
|
||||
struct track_key newKey;
|
||||
struct sync_track* track = tracks[active_track];
|
||||
int row = s_editorData.trackViewInfo.rowPos;
|
||||
|
||||
int idx = key_idx_floor(track, row);
|
||||
if (idx < 0)
|
||||
return false;
|
||||
|
||||
// copy and modify
|
||||
newKey = track->keys[idx];
|
||||
newKey.type = ((newKey.type + 1) % KEY_TYPE_COUNT);
|
||||
|
||||
sync_set_key(track, &newKey);
|
||||
|
||||
RemoteConnection_sendSetKeyCommand(track->name, &newKey);
|
||||
|
||||
handled_key = true;
|
||||
}
|
||||
is_editing = false;
|
||||
s_editorData.trackData.editText = 0;
|
||||
}
|
||||
|
||||
if (key == ' ')
|
||||
if (key == 'i')
|
||||
{
|
||||
// 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
|
||||
struct track_key newKey;
|
||||
struct sync_track* track = tracks[active_track];
|
||||
int row = viewInfo->rowPos;
|
||||
|
||||
int idx = key_idx_floor(track, row);
|
||||
if (idx < 0)
|
||||
return false;
|
||||
|
||||
// copy and modify
|
||||
newKey = track->keys[idx];
|
||||
newKey.type = ((newKey.type + 1) % KEY_TYPE_COUNT);
|
||||
|
||||
sync_set_key(track, &newKey);
|
||||
|
||||
RemoteConnection_sendSetKeyCommand(track->name, &newKey);
|
||||
|
||||
RemoteConnection_sendPauseCommand(!paused);
|
||||
handled_key = true;
|
||||
}
|
||||
|
||||
@ -343,9 +595,31 @@ static int processCommands()
|
||||
|
||||
case SET_ROW:
|
||||
{
|
||||
RemoteConnection_recv((char*)&newRow, sizeof(int), 0);
|
||||
s_editorData.trackViewInfo.rowPos = htonl(newRow);
|
||||
int i = 0;
|
||||
ret = RemoteConnection_recv((char*)&newRow, sizeof(int), 0);
|
||||
|
||||
if (ret == -1)
|
||||
{
|
||||
// retry to get the data and do it for max of 20 times otherwise disconnect
|
||||
|
||||
for (i = 0; i < 20; ++i)
|
||||
{
|
||||
if (RemoteConnection_recv((char*)&newRow, sizeof(int), 0) == 4)
|
||||
{
|
||||
s_editorData.trackViewInfo.rowPos = htonl(newRow);
|
||||
rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s_editorData.trackViewInfo.rowPos = htonl(newRow);
|
||||
rlog(R_INFO, "row from demo %d\n", s_editorData.trackViewInfo.rowPos);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,5 +22,6 @@ enum
|
||||
EDITOR_KEY_SHIFT = 1,
|
||||
EDITOR_KEY_ALT = 2,
|
||||
EDITOR_KEY_CTRL = 4,
|
||||
EDITOR_KEY_COMMAND = 8,
|
||||
};
|
||||
|
||||
|
||||
172
ogl_editor/src/MinecraftiaFont.c
Normal file
172
ogl_editor/src/MinecraftiaFont.c
Normal file
@ -0,0 +1,172 @@
|
||||
#include <Emgui.h>
|
||||
#include "MinecraftiaFont.h"
|
||||
|
||||
int g_minecraftiaFontSize = 713;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char g_minecraftiaFont[] =
|
||||
{
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40,
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x8f, 0x02, 0x2e, 0x02, 0x00, 0x00, 0x02,
|
||||
0x90, 0x49, 0x44, 0x41, 0x54, 0x58, 0x85, 0xe5, 0x57, 0xc7, 0x76, 0x03,
|
||||
0x21, 0x0c, 0x1c, 0xed, 0xe3, 0xff, 0x7f, 0x79, 0x72, 0x40, 0x65, 0x44,
|
||||
0xb1, 0x9d, 0x72, 0x8b, 0x9c, 0xec, 0x62, 0x10, 0x6a, 0x23, 0x09, 0x0c,
|
||||
0x00, 0x20, 0x40, 0x92, 0x00, 0x40, 0x1f, 0x13, 0xf4, 0x05, 0xd0, 0x59,
|
||||
0x0e, 0xff, 0x04, 0x06, 0x00, 0x18, 0x68, 0x00, 0xe8, 0x6f, 0x73, 0x06,
|
||||
0x21, 0x82, 0x70, 0x16, 0xd0, 0x68, 0xb5, 0x32, 0x10, 0xd3, 0xb0, 0x39,
|
||||
0x40, 0xcc, 0xe4, 0xce, 0xd8, 0xe1, 0x73, 0x6d, 0x3f, 0x9e, 0x45, 0x93,
|
||||
0x3b, 0x92, 0x2c, 0x36, 0x3f, 0x3a, 0xcf, 0xcd, 0xbe, 0xa9, 0xa6, 0xf9,
|
||||
0x1d, 0x93, 0x1e, 0x0f, 0xf4, 0xf9, 0x0c, 0x00, 0x81, 0x11, 0xca, 0xc4,
|
||||
0x2c, 0x9f, 0xa2, 0x11, 0x30, 0x1a, 0x0d, 0x4c, 0x06, 0x1a, 0x60, 0xcd,
|
||||
0x80, 0x50, 0x3a, 0x15, 0xf1, 0x03, 0x14, 0x6a, 0x6d, 0x46, 0x8e, 0x4d,
|
||||
0xfb, 0xb7, 0xc9, 0xd4, 0xea, 0x09, 0xd2, 0x14, 0xc9, 0xb9, 0x4a, 0xb8,
|
||||
0xc9, 0xe9, 0x96, 0xec, 0x98, 0xba, 0xdd, 0xf6, 0xb2, 0x73, 0xcd, 0x17,
|
||||
0xa8, 0xc5, 0x01, 0x00, 0xe3, 0xfb, 0xa0, 0xc2, 0xbf, 0x1b, 0xe8, 0x4a,
|
||||
0xd4, 0x4d, 0x42, 0x03, 0x39, 0x5c, 0xb8, 0x5d, 0x84, 0x4c, 0xf1, 0x96,
|
||||
0xee, 0x55, 0xbe, 0x3a, 0x3d, 0xa1, 0xbf, 0x63, 0x73, 0xa4, 0x96, 0x8f,
|
||||
0x25, 0xe0, 0x6e, 0x3f, 0xf6, 0x94, 0xdb, 0x69, 0xa4, 0x44, 0xa3, 0x4d,
|
||||
0x8f, 0x4d, 0x3c, 0xd6, 0x71, 0xe4, 0x97, 0x83, 0x43, 0x18, 0x41, 0xfb,
|
||||
0xab, 0x3c, 0x48, 0x31, 0xf4, 0x60, 0x6c, 0xd9, 0x60, 0xa5, 0xbb, 0x72,
|
||||
0xa2, 0xf2, 0x40, 0x7b, 0x84, 0x62, 0x7f, 0x7b, 0x22, 0xc7, 0x9e, 0x07,
|
||||
0x3d, 0x21, 0x25, 0x06, 0xbb, 0xcd, 0x61, 0x8d, 0x2f, 0x8d, 0xf2, 0xc1,
|
||||
0x04, 0x27, 0x81, 0x86, 0x11, 0x56, 0x07, 0x3a, 0x7a, 0x92, 0x03, 0x34,
|
||||
0x42, 0x98, 0xa1, 0x26, 0x9b, 0xc2, 0x4a, 0x22, 0x6b, 0xb0, 0xba, 0xbc,
|
||||
0x91, 0xe9, 0x15, 0xba, 0x0f, 0x7d, 0xad, 0x49, 0x5b, 0xc8, 0xb4, 0x02,
|
||||
0x9d, 0x27, 0xbd, 0xac, 0xf4, 0x2d, 0xbf, 0x1d, 0x85, 0xa8, 0x52, 0x0b,
|
||||
0xd0, 0x7e, 0x4c, 0x11, 0x7e, 0x14, 0xd2, 0xbb, 0x35, 0x73, 0x95, 0xe5,
|
||||
0x79, 0x4e, 0x59, 0x61, 0x7a, 0x47, 0x5a, 0x9f, 0x68, 0xcf, 0x3c, 0x58,
|
||||
0xc2, 0xcb, 0x6b, 0x45, 0x07, 0x8f, 0xe5, 0x13, 0xc4, 0xac, 0x85, 0x80,
|
||||
0x51, 0x23, 0x7f, 0x2b, 0x41, 0x53, 0x79, 0xe6, 0x51, 0x1e, 0xbd, 0x41,
|
||||
0xc4, 0xd1, 0xf6, 0xbe, 0x8c, 0x83, 0x9e, 0x6e, 0xb7, 0x36, 0xae, 0x7d,
|
||||
0x74, 0xa2, 0xd1, 0xbf, 0xca, 0x99, 0xa6, 0xbd, 0x81, 0x90, 0x14, 0xa8,
|
||||
0x55, 0x44, 0x4a, 0x7f, 0x6e, 0xf0, 0x95, 0x56, 0xa0, 0x8e, 0x85, 0xec,
|
||||
0xcb, 0x79, 0x72, 0x22, 0xfb, 0x7c, 0x1c, 0x94, 0xc9, 0x31, 0xff, 0xc0,
|
||||
0x2e, 0xa3, 0x9f, 0x14, 0x8b, 0x00, 0xea, 0x62, 0x7d, 0xb6, 0xc4, 0x69,
|
||||
0x27, 0x0d, 0x41, 0x0c, 0x44, 0x95, 0x4b, 0xa5, 0x59, 0x06, 0x6a, 0xb9,
|
||||
0x8e, 0x84, 0xc3, 0x75, 0x52, 0xe3, 0x81, 0x99, 0xf0, 0x37, 0xb2, 0xec,
|
||||
0x26, 0xeb, 0x02, 0x4b, 0xcc, 0xb3, 0xad, 0xbe, 0xa0, 0x14, 0x67, 0x59,
|
||||
0xcd, 0x8b, 0x80, 0xbc, 0x8e, 0x1c, 0xb7, 0xcf, 0x34, 0x65, 0x6c, 0x86,
|
||||
0xb1, 0x82, 0xf8, 0x27, 0x54, 0x38, 0xcf, 0x0b, 0xca, 0x94, 0xef, 0x63,
|
||||
0xfa, 0x8a, 0xc0, 0xce, 0xc4, 0x92, 0x85, 0xd2, 0xa5, 0x13, 0x30, 0x37,
|
||||
0xe5, 0x7c, 0xbc, 0x1f, 0xd0, 0xce, 0x91, 0x6e, 0x1d, 0x78, 0x79, 0xd7,
|
||||
0xc5, 0x24, 0xaf, 0x2f, 0x71, 0xc7, 0x11, 0x88, 0xa3, 0x9d, 0x16, 0x4f,
|
||||
0xca, 0x6d, 0x97, 0x92, 0xc5, 0xfc, 0x9e, 0x8d, 0xe5, 0x8e, 0x32, 0x57,
|
||||
0x74, 0xa4, 0xa5, 0x9d, 0xdb, 0x99, 0x54, 0xf0, 0x3a, 0xd3, 0x2d, 0xf0,
|
||||
0x20, 0x03, 0x2b, 0x0a, 0x2f, 0xa9, 0x15, 0xc6, 0x9d, 0x65, 0xe9, 0xd6,
|
||||
0xcb, 0x5d, 0x74, 0xe1, 0x8f, 0xd5, 0xf3, 0x56, 0x8d, 0xd7, 0x52, 0xaa,
|
||||
0x59, 0xff, 0x47, 0xad, 0xad, 0xb4, 0xa9, 0xa5, 0x5f, 0x1b, 0x28, 0xe6,
|
||||
0xa9, 0x67, 0x8c, 0x47, 0x8d, 0xa5, 0xf7, 0x20, 0x8f, 0x2a, 0x6d, 0xec,
|
||||
0xf5, 0xab, 0x64, 0xc9, 0x86, 0x3c, 0x86, 0x21, 0x27, 0xaa, 0xb2, 0x65,
|
||||
0x8e, 0xac, 0x3d, 0xf8, 0x0d, 0xbd, 0x82, 0x81, 0xea, 0x47, 0xd6, 0x84,
|
||||
0x63, 0x40, 0x92, 0x18, 0xf0, 0xfb, 0x49, 0xf0, 0xe7, 0xcd, 0x2c, 0x7e,
|
||||
0x5b, 0xb4, 0xcb, 0x0e, 0x85, 0x3b, 0xf6, 0x48, 0x5e, 0x36, 0x5b, 0x28,
|
||||
0xea, 0x79, 0xb7, 0xb1, 0x81, 0xa4, 0x02, 0x3e, 0x6d, 0x34, 0x63, 0x9f,
|
||||
0x9a, 0x2e, 0x88, 0x63, 0xef, 0x04, 0x48, 0x3b, 0xe7, 0xfd, 0x96, 0xf0,
|
||||
0x99, 0x05, 0xbf, 0xb9, 0x34, 0xff, 0x63, 0xfa, 0x02, 0x69, 0x60, 0x73,
|
||||
0x1f, 0x6d, 0x77, 0x33, 0x94, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
|
||||
0x44, 0xae, 0x42, 0x60, 0x82
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// BMFont was used to generate the data (and regexp magic to generate the C layout)
|
||||
|
||||
EmguiFontLayout g_minecraftiaFontLayout[] =
|
||||
{
|
||||
{ 32, 60, 50, 3, 1, -1, 11, 5 },
|
||||
{ 33, 62, 32, 1, 7, 0, 3, 2 },
|
||||
{ 34, 35, 53, 4, 3, 0, 3, 5 },
|
||||
{ 35, 31, 0, 5, 7, 0, 3, 6 },
|
||||
{ 36, 37, 0, 5, 7, 0, 3, 6 },
|
||||
{ 37, 43, 0, 5, 7, 0, 3, 6 },
|
||||
{ 38, 49, 0, 5, 7, 0, 3, 6 },
|
||||
{ 39, 40, 53, 2, 3, 0, 3, 3 },
|
||||
{ 40, 47, 32, 4, 7, 0, 3, 5 },
|
||||
{ 41, 42, 32, 4, 7, 0, 3, 5 },
|
||||
{ 42, 30, 53, 4, 3, 0, 5, 5 },
|
||||
{ 43, 0, 49, 5, 5, 0, 4, 6 },
|
||||
{ 44, 62, 40, 1, 3, 0, 8, 2 },
|
||||
{ 45, 58, 53, 5, 1, 0, 6, 6 },
|
||||
{ 46, 50, 53, 1, 2, 0, 8, 2 },
|
||||
{ 47, 42, 8, 5, 7, 0, 3, 6 },
|
||||
{ 48, 0, 9, 5, 7, 0, 3, 6 },
|
||||
{ 49, 54, 8, 5, 7, 0, 3, 6 },
|
||||
{ 50, 0, 17, 5, 7, 0, 3, 6 },
|
||||
{ 51, 6, 16, 5, 7, 0, 3, 6 },
|
||||
{ 52, 12, 16, 5, 7, 0, 3, 6 },
|
||||
{ 53, 18, 16, 5, 7, 0, 3, 6 },
|
||||
{ 54, 13, 0, 5, 7, 0, 3, 6 },
|
||||
{ 55, 30, 16, 5, 7, 0, 3, 6 },
|
||||
{ 56, 36, 16, 5, 7, 0, 3, 6 },
|
||||
{ 57, 42, 16, 5, 7, 0, 3, 6 },
|
||||
{ 58, 54, 40, 1, 6, 0, 4, 2 },
|
||||
{ 59, 24, 40, 1, 7, 0, 4, 2 },
|
||||
{ 60, 52, 32, 4, 7, 0, 3, 5 },
|
||||
{ 61, 18, 54, 5, 4, 0, 5, 6 },
|
||||
{ 62, 5, 41, 4, 7, 0, 3, 5 },
|
||||
{ 63, 12, 24, 5, 7, 0, 3, 6 },
|
||||
{ 64, 6, 0, 6, 7, 0, 3, 7 },
|
||||
{ 65, 18, 24, 5, 7, 0, 3, 6 },
|
||||
{ 66, 48, 16, 5, 7, 0, 3, 6 },
|
||||
{ 67, 30, 24, 5, 7, 0, 3, 6 },
|
||||
{ 68, 36, 24, 5, 7, 0, 3, 6 },
|
||||
{ 69, 42, 24, 5, 7, 0, 3, 6 },
|
||||
{ 70, 48, 24, 5, 7, 0, 3, 6 },
|
||||
{ 71, 54, 24, 5, 7, 0, 3, 6 },
|
||||
{ 72, 0, 33, 5, 7, 0, 3, 6 },
|
||||
{ 73, 60, 8, 3, 7, 0, 3, 4 },
|
||||
{ 74, 24, 24, 5, 7, 0, 3, 6 },
|
||||
{ 75, 6, 32, 5, 7, 0, 3, 6 },
|
||||
{ 76, 12, 32, 5, 7, 0, 3, 6 },
|
||||
{ 77, 18, 32, 5, 7, 0, 3, 6 },
|
||||
{ 78, 24, 32, 5, 7, 0, 3, 6 },
|
||||
{ 79, 18, 8, 5, 7, 0, 3, 6 },
|
||||
{ 80, 6, 24, 5, 7, 0, 3, 6 },
|
||||
{ 81, 24, 16, 5, 7, 0, 3, 6 },
|
||||
{ 82, 36, 8, 5, 7, 0, 3, 6 },
|
||||
{ 83, 30, 8, 5, 7, 0, 3, 6 },
|
||||
{ 84, 24, 8, 5, 7, 0, 3, 6 },
|
||||
{ 85, 12, 8, 5, 7, 0, 3, 6 },
|
||||
{ 86, 55, 0, 5, 7, 0, 3, 6 },
|
||||
{ 87, 25, 0, 5, 7, 0, 3, 6 },
|
||||
{ 88, 30, 32, 5, 7, 0, 3, 6 },
|
||||
{ 89, 36, 32, 5, 7, 0, 3, 6 },
|
||||
{ 90, 19, 0, 5, 7, 0, 3, 6 },
|
||||
{ 91, 60, 16, 3, 7, 0, 3, 4 },
|
||||
{ 92, 6, 8, 5, 7, 0, 3, 6 },
|
||||
{ 93, 20, 40, 3, 7, 0, 3, 4 },
|
||||
{ 94, 24, 54, 5, 3, 0, 3, 6 },
|
||||
{ 95, 52, 53, 5, 1, 0, 9, 6 },
|
||||
{ 96, 60, 46, 2, 3, 0, 3, 3 },
|
||||
{ 97, 48, 47, 5, 5, 0, 5, 6 },
|
||||
{ 98, 48, 8, 5, 7, 0, 3, 6 },
|
||||
{ 99, 18, 48, 5, 5, 0, 5, 6 },
|
||||
{ 100, 54, 16, 5, 7, 0, 3, 6 },
|
||||
{ 101, 56, 40, 5, 5, 0, 5, 6 },
|
||||
{ 102, 0, 41, 4, 7, 0, 3, 5 },
|
||||
{ 103, 30, 40, 5, 6, 0, 5, 6 },
|
||||
{ 104, 0, 25, 5, 7, 0, 3, 6 },
|
||||
{ 105, 26, 40, 1, 7, 0, 3, 2 },
|
||||
{ 106, 0, 0, 5, 8, 0, 3, 6 },
|
||||
{ 107, 57, 32, 4, 7, 0, 3, 5 },
|
||||
{ 108, 61, 0, 2, 7, 0, 3, 3 },
|
||||
{ 109, 0, 55, 5, 5, 0, 5, 6 },
|
||||
{ 110, 6, 55, 5, 5, 0, 5, 6 },
|
||||
{ 111, 12, 54, 5, 5, 0, 5, 6 },
|
||||
{ 112, 36, 40, 5, 6, 0, 5, 6 },
|
||||
{ 113, 42, 40, 5, 6, 0, 5, 6 },
|
||||
{ 114, 6, 49, 5, 5, 0, 5, 6 },
|
||||
{ 115, 12, 48, 5, 5, 0, 5, 6 },
|
||||
{ 116, 60, 24, 3, 7, 0, 3, 4 },
|
||||
{ 117, 24, 48, 5, 5, 0, 5, 6 },
|
||||
{ 118, 30, 47, 5, 5, 0, 5, 6 },
|
||||
{ 119, 36, 47, 5, 5, 0, 5, 6 },
|
||||
{ 120, 42, 47, 5, 5, 0, 5, 6 },
|
||||
{ 121, 48, 40, 5, 6, 0, 5, 6 },
|
||||
{ 122, 54, 47, 5, 5, 0, 5, 6 },
|
||||
{ 123, 15, 40, 4, 7, 0, 3, 5 },
|
||||
{ 124, 28, 40, 1, 7, 0, 3, 2 },
|
||||
{ 125, 10, 40, 4, 7, 0, 3, 5 },
|
||||
{ 126, 43, 53, 6, 2, 0, 3, 7 },
|
||||
};
|
||||
8
ogl_editor/src/MinecraftiaFont.h
Normal file
8
ogl_editor/src/MinecraftiaFont.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Emgui.h>
|
||||
|
||||
extern EmguiFontLayout g_minecraftiaFontLayout[];
|
||||
extern char g_minecraftiaFont[];
|
||||
extern int g_minecraftiaFontSize;
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "../../sync/base.h"
|
||||
#include "../../sync/track.h"
|
||||
#include "rlog.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef INVALID_SOCKET
|
||||
#define INVALID_SOCKET -1
|
||||
@ -127,6 +128,7 @@ static bool setBlocking(int sock, bool blocking)
|
||||
bool RemoteConnection_createListner()
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int yes = 1;
|
||||
|
||||
s_serverSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
@ -139,9 +141,16 @@ bool RemoteConnection_createListner()
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
sin.sin_port = htons(1338);
|
||||
|
||||
if (setsockopt(s_serverSocket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
|
||||
{
|
||||
perror("setsockopt");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (-1 == bind(s_serverSocket, (struct sockaddr *)&sin, sizeof(sin)))
|
||||
{
|
||||
rlog(R_ERROR, "Unable to create server socket\n");
|
||||
perror("bind");
|
||||
rlog(R_ERROR, "Unable to bind server socket\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -150,7 +159,7 @@ bool RemoteConnection_createListner()
|
||||
|
||||
setBlocking(s_serverSocket, false);
|
||||
|
||||
rlog(R_INFO, "Creaded listner\n");
|
||||
rlog(R_INFO, "Created listner\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -197,23 +206,14 @@ static SOCKET clientConnect(SOCKET serverSocket, struct sockaddr_in* host)
|
||||
|
||||
void RemoteConnection_updateListner()
|
||||
{
|
||||
fd_set fds;
|
||||
struct timeval timeout;
|
||||
SOCKET clientSocket;
|
||||
struct sockaddr_in client;
|
||||
|
||||
if (RemoteConnection_connected())
|
||||
return;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(s_serverSocket, &fds);
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
// look for new clients
|
||||
|
||||
//if (select(0, &fds, NULL, NULL, &timeout) > 0)
|
||||
{
|
||||
clientSocket = clientConnect(s_serverSocket, &client);
|
||||
|
||||
@ -245,27 +245,30 @@ void RemoteConnection_disconnect()
|
||||
|
||||
rlog(R_INFO, "disconnect!\n");
|
||||
|
||||
s_paused = true;
|
||||
|
||||
memset(s_nameLookup.ids, -1, sizeof(int) * s_nameLookup.count);
|
||||
s_nameLookup.count = 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool RemoteConnection_recv(char* buffer, size_t length, int flags)
|
||||
int RemoteConnection_recv(char* buffer, size_t length, int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!RemoteConnection_connected())
|
||||
return false;
|
||||
|
||||
if ((ret = recv(s_socket, buffer, (int)length, flags)) != (int)length)
|
||||
ret = recv(s_socket, buffer, (int)length, flags);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
//rlog(R_INFO, "%d %d\n", ret, length);
|
||||
//RemoteConnection_disconnect();
|
||||
//return false;
|
||||
RemoteConnection_disconnect();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -415,3 +418,20 @@ void RemoteConnection_sendKeyFrames(const char* name, struct sync_track* track)
|
||||
sendSetKeyCommandIndex((uint32_t)track_id, &track->keys[i]);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RemoteConnection_close()
|
||||
{
|
||||
if (RemoteConnection_connected())
|
||||
{
|
||||
rlog(R_INFO, "closing client socket %d\n", s_socket);
|
||||
closesocket(s_socket);
|
||||
s_socket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
rlog(R_INFO, "closing socket %d\n", s_serverSocket);
|
||||
|
||||
closesocket(s_serverSocket);
|
||||
s_serverSocket = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ struct sync_track;
|
||||
|
||||
bool RemoteConnection_createListner();
|
||||
void RemoteConnection_updateListner();
|
||||
void RemoteConnection_close();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Talk with the demo stuff
|
||||
@ -17,7 +18,7 @@ void RemoteConnection_updateListner();
|
||||
bool RemoteConnection_isPaused();
|
||||
bool RemoteConnection_connected();
|
||||
void RemoteConnection_disconnect();
|
||||
bool RemoteConnection_recv(char* buffer, size_t length, int flags);
|
||||
int RemoteConnection_recv(char* buffer, size_t length, int flags);
|
||||
bool RemoteConnection_send(const char* buffer, size_t length, int flags);
|
||||
bool RemoteConnection_pollRead();
|
||||
|
||||
|
||||
@ -5,12 +5,13 @@
|
||||
#include <string.h>
|
||||
#include "TrackData.h"
|
||||
#include "rlog.h"
|
||||
#include "minmax.h"
|
||||
#include "../../sync/sync.h"
|
||||
#include "../../sync/data.h"
|
||||
#include "../../sync/track.h"
|
||||
|
||||
const int font_size = 8;
|
||||
static int start_pos = -27;
|
||||
const int min_track_size = 100;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -20,7 +21,7 @@ void TrackView_init()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void printRowNumbers(int x, int y, int rowCount, int rowOffset, int rowSpacing, int maskBpm)
|
||||
static void printRowNumbers(int x, int y, int rowCount, int rowOffset, int rowSpacing, int maskBpm, int endY)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -43,20 +44,44 @@ static void printRowNumbers(int x, int y, int rowCount, int rowOffset, int rowSp
|
||||
|
||||
y += rowSpacing;
|
||||
rowOffset++;
|
||||
|
||||
if (y > endY)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void renderChannel(struct sync_track* track, int startX, int startY, int startPos, int endPos)
|
||||
static int renderChannel(const TrackViewInfo* viewInfo, struct sync_track* track, int editRow,
|
||||
int startX, int startY, int startPos, int endPos, int endSizeY,
|
||||
int trackId, int selectLeft, int selectRight, int selectTop, int selectBottom)
|
||||
{
|
||||
int x, y, y_offset;
|
||||
|
||||
int y, y_offset;
|
||||
int size = min_track_size;
|
||||
uint32_t color = Emgui_color32(40, 40, 40, 255);
|
||||
|
||||
Emgui_drawBorder(color, color, startX, startY - 20, 160, 600);
|
||||
|
||||
if (track)
|
||||
Emgui_drawText(track->name, startX + 2, startY + 2, Emgui_color32(0xff, 0xff, 0xff, 0xff));
|
||||
{
|
||||
int text_size;
|
||||
int x_adjust = 0;
|
||||
|
||||
Emgui_setFont(viewInfo->smallFontId);
|
||||
text_size = Emgui_getTextSize(track->name) + 4;
|
||||
|
||||
// if text is smaller than min size we center the text
|
||||
|
||||
if (text_size < min_track_size)
|
||||
x_adjust = (min_track_size - text_size) / 2;
|
||||
else
|
||||
size = text_size + 1;
|
||||
|
||||
Emgui_drawText(track->name, (startX + 3) + x_adjust, startY - 12, Emgui_color32(0xff, 0xff, 0xff, 0xff));
|
||||
Emgui_setDefaultFont();
|
||||
}
|
||||
|
||||
Emgui_drawBorder(color, color, startX, startY - font_size * 2, size, endSizeY);
|
||||
|
||||
y_offset = startY;// + font_size / 2;
|
||||
|
||||
@ -64,7 +89,6 @@ static void renderChannel(struct sync_track* track, int startX, int startY, int
|
||||
{
|
||||
y_offset = startY + (font_size * -startPos);
|
||||
startPos = 0;
|
||||
endPos = 40;
|
||||
}
|
||||
|
||||
y_offset += font_size / 2;
|
||||
@ -73,46 +97,61 @@ static void renderChannel(struct sync_track* track, int startX, int startY, int
|
||||
{
|
||||
int offset = startX + 6;
|
||||
int idx = -1;
|
||||
|
||||
int fidx;
|
||||
enum key_type interpolationType;
|
||||
uint32_t color;
|
||||
bool selected;
|
||||
float value = 0.0f;
|
||||
|
||||
if (track)
|
||||
idx = sync_find_key(track, y);
|
||||
|
||||
// This is kinda crappy implementation as we will overdraw this quite a bit but might be fine
|
||||
|
||||
fidx = idx >= 0 ? idx : -idx - 2;
|
||||
interpolationType = (fidx >= 0) ? track->keys[fidx].type : KEY_STEP;
|
||||
|
||||
switch (interpolationType)
|
||||
{
|
||||
case KEY_STEP : color = 0; break;
|
||||
case KEY_LINEAR : color = Emgui_color32(255, 0, 0, 255); break;
|
||||
case KEY_SMOOTH : color = Emgui_color32(0, 255, 0, 255); break;
|
||||
case KEY_RAMP : color = Emgui_color32(0, 0, 255, 255); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (viewInfo)
|
||||
Emgui_fill(color, startX + (size - 4), y_offset - font_size / 2, 2, (endSizeY - y_offset) + font_size - 1);
|
||||
|
||||
// Draw text if we have any
|
||||
|
||||
if (idx >= 0)
|
||||
{
|
||||
char temp[256];
|
||||
value = track->keys[idx].value;
|
||||
snprintf(temp, 256, "% .2f", value);
|
||||
|
||||
Emgui_drawText(temp, offset, y_offset - font_size / 2, Emgui_color32(255, 255, 255, 255));
|
||||
if (y != editRow)
|
||||
Emgui_drawText(temp, offset, y_offset - font_size / 2, Emgui_color32(255, 255, 255, 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
int points[64];
|
||||
int* points_ptr = (int*)&points[0];
|
||||
|
||||
for (x = 0; x < 6; ++x)
|
||||
{
|
||||
points_ptr[0] = offset + 0;
|
||||
points_ptr[1] = y_offset;
|
||||
points_ptr[2] = offset + 2;
|
||||
points_ptr[3] = y_offset;
|
||||
points_ptr[4] = offset + 4;
|
||||
points_ptr[5] = y_offset;
|
||||
|
||||
points_ptr += 6;
|
||||
offset += 10;
|
||||
}
|
||||
|
||||
if (y & 7)
|
||||
Emgui_drawDots(0x004f4f4f, (int*)&points[0], 18 * 2);
|
||||
else
|
||||
Emgui_drawDots(0x007f7f7f, (int*)&points[0], 18 * 2);
|
||||
uint32_t color = (y & 7) ? Emgui_color32(0x4f, 0x4f, 0x4f, 0xff) : Emgui_color32(0x7f, 0x7f, 0x7f, 0xff);
|
||||
Emgui_drawText("---", offset, y_offset - font_size / 2, color);
|
||||
}
|
||||
|
||||
selected = (trackId >= selectLeft && trackId <= selectRight) && (y >= selectTop && y < selectBottom);
|
||||
|
||||
if (selected)
|
||||
Emgui_fill(Emgui_color32(0x4f, 0x4f, 0x4f, 0x3f), startX, y_offset - font_size/2, size, font_size);
|
||||
|
||||
y_offset += font_size;
|
||||
|
||||
if (y_offset > (endSizeY + font_size/2))
|
||||
break;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -128,23 +167,39 @@ void TrackView_render(const TrackViewInfo* viewInfo, TrackData* trackData)
|
||||
int x_pos = 40;
|
||||
int end_track = 0;
|
||||
int i = 0;
|
||||
int adjust_top_size;
|
||||
int mid_screen_y ;
|
||||
int y_pos_row, end_row, y_end_border;
|
||||
|
||||
int selectLeft = emini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
int selectRight = emaxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||
int selectTop = emini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||
int selectBottom = emaxi(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||
|
||||
// Calc to position the selection in the ~middle of the screen
|
||||
|
||||
adjust_top_size = 3 * font_size;
|
||||
mid_screen_y = (viewInfo->windowSizeY / 2) & ~(font_size - 1);
|
||||
y_pos_row = viewInfo->rowPos - (mid_screen_y / font_size);
|
||||
|
||||
// TODO: Calculate how many channels we can draw given the width
|
||||
|
||||
printRowNumbers(2, 42, 40, start_pos + viewInfo->rowPos, font_size, 8);
|
||||
end_row = viewInfo->windowSizeY / font_size;
|
||||
y_end_border = viewInfo->windowSizeY - 32; // adjust to have some space at the end of the screen
|
||||
|
||||
printRowNumbers(2, adjust_top_size, end_row, y_pos_row, font_size, 8, y_end_border);
|
||||
|
||||
if (syncData->num_tracks == 0)
|
||||
{
|
||||
renderChannel(0, 40 + (i * 64), 42,
|
||||
(start_pos + viewInfo->rowPos),
|
||||
(start_pos + viewInfo->rowPos + 40));
|
||||
Emgui_fill(Emgui_color32(127, 127, 127, 56), 0, 257, 800, font_size + 2);
|
||||
uint32_t color = Emgui_color32(127, 127, 127, 56);
|
||||
renderChannel(0, 0, -1, 40 + (i * 64), adjust_top_size, y_pos_row, y_pos_row + end_row, y_end_border,
|
||||
0, 0, 0, 0, 0);
|
||||
Emgui_fill(color, 0, mid_screen_y + adjust_top_size, viewInfo->windowSizeX, font_size + 2);
|
||||
return;
|
||||
}
|
||||
|
||||
num_tracks = syncData->num_tracks;
|
||||
|
||||
max_render_tracks = viewInfo->windowSizeX / 128;
|
||||
max_render_tracks = viewInfo->windowSizeX / min_track_size;
|
||||
|
||||
if (num_tracks > max_render_tracks)
|
||||
num_tracks = max_render_tracks;
|
||||
@ -156,21 +211,25 @@ void TrackView_render(const TrackViewInfo* viewInfo, TrackData* trackData)
|
||||
|
||||
for (i = start_track; i < end_track; ++i)
|
||||
{
|
||||
renderChannel(syncData->tracks[i], x_pos, 42,
|
||||
(start_pos + viewInfo->rowPos),
|
||||
(start_pos + viewInfo->rowPos + 40));
|
||||
int size, editRow = -1;
|
||||
|
||||
if (sel_track == i && trackData->editText)
|
||||
editRow = viewInfo->rowPos;
|
||||
|
||||
size = renderChannel(viewInfo, syncData->tracks[i], editRow, x_pos, adjust_top_size, y_pos_row, y_pos_row + end_row, y_end_border,
|
||||
i, selectLeft, selectRight, selectTop, selectBottom);
|
||||
|
||||
if (sel_track == i)
|
||||
{
|
||||
Emgui_fill(Emgui_color32(0xff, 0xff, 0x00, 0x80), x_pos, 257, 160, font_size + 2);
|
||||
Emgui_fill(Emgui_color32(0xff, 0xff, 0x00, 0x80), x_pos, mid_screen_y + adjust_top_size, size, font_size + 1);
|
||||
|
||||
if (trackData->editText)
|
||||
Emgui_drawText(trackData->editText, x_pos, 257, Emgui_color32(255, 255, 255, 255));
|
||||
Emgui_drawText(trackData->editText, x_pos, mid_screen_y + adjust_top_size, Emgui_color32(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
x_pos += 160;
|
||||
x_pos += size;
|
||||
}
|
||||
|
||||
Emgui_fill(color, 0, 257, 800, font_size + 3);
|
||||
Emgui_fill(Emgui_color32(127, 127, 127, 56), 0, mid_screen_y + adjust_top_size, viewInfo->windowSizeX, font_size + 1);
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,11 @@ typedef struct TrackViewInfo
|
||||
int windowSizeX;
|
||||
int windowSizeY;
|
||||
int rowPos;
|
||||
int smallFontId;
|
||||
int selectStartTrack;
|
||||
int selectStopTrack;
|
||||
int selectStartRow;
|
||||
int selectStopRow;
|
||||
|
||||
} TrackViewInfo;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "Dialog.h"
|
||||
#include "TrackData.h"
|
||||
#include "External/mxml/mxml.h"
|
||||
#include "RemoteConnection.h"
|
||||
#include "../../sync/data.h"
|
||||
#include <Types.h>
|
||||
#include <stdio.h>
|
||||
@ -56,6 +57,9 @@ static void parseXml(mxml_node_t* rootNode, TrackData* trackData)
|
||||
|
||||
if (!strcmp("track", element_name))
|
||||
{
|
||||
int i;
|
||||
struct sync_track* track;
|
||||
|
||||
// TODO: Create the new track/channel here
|
||||
|
||||
const char* track_name = mxmlElementGetAttr(node, "name");
|
||||
@ -63,6 +67,21 @@ static void parseXml(mxml_node_t* rootNode, TrackData* trackData)
|
||||
track_index = TrackData_createGetTrack(trackData, track_name);
|
||||
printf("track_index %d\n", track_index);
|
||||
|
||||
track = trackData->syncData.tracks[track_index];
|
||||
|
||||
// If we already have this track loaded we delete all the existing keys
|
||||
|
||||
for (i = 0; i < track->num_keys; ++i)
|
||||
{
|
||||
int row = track->keys[i].row;
|
||||
RemoteConnection_sendDeleteKeyCommand(track->name, row);
|
||||
}
|
||||
|
||||
free(track->keys);
|
||||
|
||||
track->keys = 0;
|
||||
track->num_keys = 0;
|
||||
|
||||
printf("Creating track/channel with name %s\n", track_name);
|
||||
}
|
||||
else if (!strcmp("key", element_name))
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#import "RocketView.h"
|
||||
#include "../Editor.h"
|
||||
#include "../rlog.h"
|
||||
#include <Emgui.h>
|
||||
#include <GFXBackend.h>
|
||||
|
||||
@ -83,6 +84,9 @@
|
||||
if ([theEvent modifierFlags] & NSControlKeyMask)
|
||||
specialKeys |= EDITOR_KEY_CTRL;
|
||||
|
||||
if ([theEvent modifierFlags] & NSCommandKeyMask)
|
||||
specialKeys |= EDITOR_KEY_COMMAND;
|
||||
|
||||
if ([theEvent modifierFlags] & NSNumericPadKeyMask)
|
||||
{
|
||||
switch (keyChar)
|
||||
@ -123,8 +127,9 @@
|
||||
NSWindow* window = [self window];
|
||||
NSRect originalFrame = [window frame];
|
||||
NSPoint location = [window mouseLocationOutsideOfEventStream];
|
||||
NSRect adjustFrame = [NSWindow contentRectForFrameRect: originalFrame styleMask: NSTitledWindowMask];
|
||||
|
||||
Emgui_setMousePos((int)location.x, (int)originalFrame.size.height - (int)location.y);
|
||||
Emgui_setMousePos((int)location.x, (int)adjustFrame.size.height - (int)location.y);
|
||||
Editor_update();
|
||||
}
|
||||
|
||||
@ -143,8 +148,9 @@
|
||||
NSWindow *window = [self window];
|
||||
NSRect originalFrame = [window frame];
|
||||
NSPoint location = [window mouseLocationOutsideOfEventStream];
|
||||
NSRect adjustFrame = [NSWindow contentRectForFrameRect: originalFrame styleMask: NSTitledWindowMask];
|
||||
|
||||
Emgui_setMousePos((int)location.x, (int)originalFrame.size.height - (int)location.y);
|
||||
Emgui_setMousePos((int)location.x, (int)adjustFrame.size.height - (int)location.y);
|
||||
Emgui_setMouseLmb(1);
|
||||
|
||||
Editor_update();
|
||||
@ -157,14 +163,5 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
-(void) dealloc
|
||||
{
|
||||
Editor_destroy();
|
||||
EMGFXBackend_destroy();
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
|
||||
#import "delegate.h"
|
||||
#include "../Editor.h"
|
||||
#include "../RemoteConnection.h"
|
||||
#include "rlog.h"
|
||||
|
||||
@implementation MinimalAppAppDelegate
|
||||
|
||||
@ -20,4 +22,13 @@
|
||||
Editor_menuEvent((int)((NSButton*)sender).tag);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||
{
|
||||
rlog(R_INFO, "Dealloc\n");
|
||||
Editor_destroy();
|
||||
RemoteConnection_close();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
24
ogl_editor/src/minmax.h
Normal file
24
ogl_editor/src/minmax.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static EMGUI_INLINE int maxi(int a, int b)
|
||||
{
|
||||
if (a > b)
|
||||
return a;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static EMGUI_INLINE int mini(int a, int b)
|
||||
{
|
||||
if (a < b)
|
||||
return a;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user