Separated createTrack to own c/h as we need to call it from more places that Editor.c
This commit is contained in:
parent
36bbcfda6d
commit
c8b656c03c
@ -7,6 +7,7 @@
|
|||||||
#include "LoadSave.h"
|
#include "LoadSave.h"
|
||||||
#include "TrackView.h"
|
#include "TrackView.h"
|
||||||
#include "rlog.h"
|
#include "rlog.h"
|
||||||
|
#include "TrackData.h"
|
||||||
#include "RemoteConnection.h"
|
#include "RemoteConnection.h"
|
||||||
#include "../../sync/sync.h"
|
#include "../../sync/sync.h"
|
||||||
#include "../../sync/base.h"
|
#include "../../sync/base.h"
|
||||||
@ -24,21 +25,11 @@
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
typedef struct TrackInfo
|
|
||||||
{
|
|
||||||
bool folded;
|
|
||||||
} TrackInfo;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
typedef struct EditorData
|
typedef struct EditorData
|
||||||
{
|
{
|
||||||
struct sync_data syncData;
|
struct sync_data syncData;
|
||||||
TrackViewInfo trackViewInfo;
|
TrackViewInfo trackViewInfo;
|
||||||
TrackInfo trackInfo;
|
TrackData trackData;
|
||||||
int trackOrder[8192];
|
|
||||||
int orderCount;
|
|
||||||
|
|
||||||
} EditorData;
|
} EditorData;
|
||||||
|
|
||||||
static EditorData s_editorData;
|
static EditorData s_editorData;
|
||||||
@ -141,16 +132,6 @@ bool Editor_keyDown(int key)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static int createTrack(EditorData* data, const char* name)
|
|
||||||
{
|
|
||||||
int index = sync_create_track(&data->syncData, name);
|
|
||||||
data->trackOrder[data->orderCount] = index;
|
|
||||||
data->orderCount++;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static void processCommands()
|
static void processCommands()
|
||||||
{
|
{
|
||||||
//SyncDocument *doc = trackView->getDocument();
|
//SyncDocument *doc = trackView->getDocument();
|
||||||
@ -180,9 +161,7 @@ static void processCommands()
|
|||||||
|
|
||||||
// find track
|
// find track
|
||||||
|
|
||||||
serverIndex = sync_find_track(&s_editorData.syncData, trackName);
|
serverIndex = TrackData_createGetTrack(&s_editorData.trackData, trackName);
|
||||||
if (0 > serverIndex)
|
|
||||||
serverIndex = createTrack(&s_editorData, trackName);
|
|
||||||
|
|
||||||
// setup remap and send the keyframes to the demo
|
// setup remap and send the keyframes to the demo
|
||||||
RemoteConnection_mapTrackName(trackName);
|
RemoteConnection_mapTrackName(trackName);
|
||||||
@ -220,7 +199,7 @@ void Editor_timedUpdate()
|
|||||||
|
|
||||||
static void onOpen()
|
static void onOpen()
|
||||||
{
|
{
|
||||||
LoadSave_loadRocketXMLDialog();
|
LoadSave_loadRocketXMLDialog(&s_editorData.trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
18
ogl_editor/src/TrackData.c
Normal file
18
ogl_editor/src/TrackData.c
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include "TrackData.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
int TrackData_createGetTrack(TrackData* trackData, const char* name)
|
||||||
|
{
|
||||||
|
int index = sync_find_track(&trackData->syncData, name);
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
int index = sync_create_track(&trackData->syncData, name);
|
||||||
|
trackData->order[trackData->orderCount] = index;
|
||||||
|
trackData->orderCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
18
ogl_editor/src/TrackData.h
Normal file
18
ogl_editor/src/TrackData.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../../sync/data.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
typedef struct TrackData
|
||||||
|
{
|
||||||
|
struct sync_data syncData;
|
||||||
|
int order[8192];
|
||||||
|
int orderCount;
|
||||||
|
} TrackData;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Will get the get the track if it exists else create it
|
||||||
|
|
||||||
|
int TrackData_createGetTrack(TrackData* trackData, const char* name);
|
||||||
|
|
||||||
@ -1,12 +1,17 @@
|
|||||||
#include "LoadSave.h"
|
#include "LoadSave.h"
|
||||||
#include "Dialog.h"
|
#include "Dialog.h"
|
||||||
|
#include "TrackData.h"
|
||||||
#include "External/mxml/mxml.h"
|
#include "External/mxml/mxml.h"
|
||||||
|
#include "../../sync/data.h"
|
||||||
#include <Types.h>
|
#include <Types.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static void parseXml(mxml_node_t* rootNode)
|
static void parseXml(mxml_node_t* rootNode, TrackData* trackData)
|
||||||
{
|
{
|
||||||
|
int track_index = 0;
|
||||||
|
//struct sync_track** tracks = trackData->syncData.tracks;
|
||||||
|
|
||||||
// find the tracks element
|
// find the tracks element
|
||||||
|
|
||||||
mxml_node_t* node = mxmlFindElement(rootNode, rootNode, "tracks", NULL, NULL, MXML_NO_DESCEND);
|
mxml_node_t* node = mxmlFindElement(rootNode, rootNode, "tracks", NULL, NULL, MXML_NO_DESCEND);
|
||||||
@ -44,15 +49,28 @@ static void parseXml(mxml_node_t* rootNode)
|
|||||||
if (!strcmp("track", element_name))
|
if (!strcmp("track", element_name))
|
||||||
{
|
{
|
||||||
// TODO: Create the new track/channel here
|
// TODO: Create the new track/channel here
|
||||||
|
|
||||||
|
track_index = TrackData_createGetTrack(trackData, element_name);
|
||||||
|
printf("track_index %d\n", track_index);
|
||||||
|
|
||||||
printf("Creating track/channel with name %s\n", mxmlElementGetAttr(node, "name"));
|
printf("Creating track/channel with name %s\n", mxmlElementGetAttr(node, "name"));
|
||||||
}
|
}
|
||||||
else if (!strcmp("key", element_name))
|
else if (!strcmp("key", element_name))
|
||||||
{
|
{
|
||||||
|
struct sync_track* track = trackData->syncData.tracks[track_index];
|
||||||
|
|
||||||
const char* row = mxmlElementGetAttr(node, "row");
|
const char* row = mxmlElementGetAttr(node, "row");
|
||||||
const char* value = mxmlElementGetAttr(node, "value");
|
const char* value = mxmlElementGetAttr(node, "value");
|
||||||
const char* interpolation = mxmlElementGetAttr(node, "interpolation");
|
const char* interpolation = mxmlElementGetAttr(node, "interpolation");
|
||||||
|
|
||||||
|
struct track_key k;
|
||||||
|
k.row = atoi(row);
|
||||||
|
k.value = (float)(atof(value));
|
||||||
|
k.type = (atoi(interpolation));
|
||||||
|
|
||||||
|
assert(!is_key_frame(track, k.row));
|
||||||
|
sync_set_key(track, &k);
|
||||||
|
|
||||||
printf("Adding key: row %s | value %s | interpolation %s\n", row, value, interpolation);
|
printf("Adding key: row %s | value %s | interpolation %s\n", row, value, interpolation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,7 +83,7 @@ static void parseXml(mxml_node_t* rootNode)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int LoadSave_loadRocketXML(const char* path)
|
int LoadSave_loadRocketXML(const char* path, TrackData* trackData)
|
||||||
{
|
{
|
||||||
FILE* fp = 0;
|
FILE* fp = 0;
|
||||||
mxml_node_t* tree = 0;
|
mxml_node_t* tree = 0;
|
||||||
@ -79,7 +97,7 @@ int LoadSave_loadRocketXML(const char* path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseXml(tree);
|
parseXml(tree, trackData);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
mxmlDelete(tree);
|
mxmlDelete(tree);
|
||||||
@ -89,14 +107,14 @@ int LoadSave_loadRocketXML(const char* path)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int LoadSave_loadRocketXMLDialog()
|
int LoadSave_loadRocketXMLDialog(TrackData* trackData)
|
||||||
{
|
{
|
||||||
char path[512];
|
char path[512];
|
||||||
|
|
||||||
if (!Dialog_open(path))
|
if (!Dialog_open(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return LoadSave_loadRocketXML(path);
|
return LoadSave_loadRocketXML(path, trackData);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
int LoadSave_loadRocketXML(const char* path);
|
struct TrackData;
|
||||||
int LoadSave_loadRocketXMLDialog();
|
|
||||||
|
int LoadSave_loadRocketXML(const char* path, struct TrackData* trackData);
|
||||||
|
int LoadSave_loadRocketXMLDialog(struct TrackData* trackData);
|
||||||
int LoadSave_saveRocketXML(const char* path);
|
int LoadSave_saveRocketXML(const char* path);
|
||||||
int LoadSave_saveRocketXMLDialog();
|
int LoadSave_saveRocketXMLDialog();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user