Implemented "Recent Files" on Mac OS X
Also added shortcut for each recent file (CMD + 1-4 for each entry in the list) Closes #18
This commit is contained in:
parent
a50c6752fa
commit
cb47ecdb1d
@ -125,7 +125,30 @@
|
|||||||
<reference key="NSMixedImage" ref="502551668"/>
|
<reference key="NSMixedImage" ref="502551668"/>
|
||||||
<int key="NSTag">1</int>
|
<int key="NSTag">1</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMenuItem" id="1025936716">
|
<object class="NSMenuItem" id="752287694">
|
||||||
|
<reference key="NSMenu" ref="720053764"/>
|
||||||
|
<string key="NSTitle">Recent Files</string>
|
||||||
|
<string key="NSKeyEquiv"/>
|
||||||
|
<int key="NSMnemonicLoc">2147483647</int>
|
||||||
|
<reference key="NSOnImage" ref="35465992"/>
|
||||||
|
<reference key="NSMixedImage" ref="502551668"/>
|
||||||
|
<string key="NSAction">submenuAction:</string>
|
||||||
|
<object class="NSMenu" key="NSSubmenu" id="573498689">
|
||||||
|
<string key="NSTitle">Recent Files</string>
|
||||||
|
<object class="NSMutableArray" key="NSMenuItems">
|
||||||
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<object class="NSMenuItem" id="264375453">
|
||||||
|
<reference key="NSMenu" ref="573498689"/>
|
||||||
|
<string key="NSTitle">Item</string>
|
||||||
|
<string key="NSKeyEquiv"/>
|
||||||
|
<int key="NSMnemonicLoc">2147483647</int>
|
||||||
|
<reference key="NSOnImage" ref="35465992"/>
|
||||||
|
<reference key="NSMixedImage" ref="502551668"/>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
|
<object class="NSMenuItem" id="573637146">
|
||||||
<reference key="NSMenu" ref="720053764"/>
|
<reference key="NSMenu" ref="720053764"/>
|
||||||
<string key="NSTitle">Open Recent</string>
|
<string key="NSTitle">Open Recent</string>
|
||||||
<string key="NSKeyEquiv"/>
|
<string key="NSKeyEquiv"/>
|
||||||
@ -134,12 +157,12 @@
|
|||||||
<reference key="NSOnImage" ref="35465992"/>
|
<reference key="NSOnImage" ref="35465992"/>
|
||||||
<reference key="NSMixedImage" ref="502551668"/>
|
<reference key="NSMixedImage" ref="502551668"/>
|
||||||
<string key="NSAction">submenuAction:</string>
|
<string key="NSAction">submenuAction:</string>
|
||||||
<object class="NSMenu" key="NSSubmenu" id="1065607017">
|
<object class="NSMenu" key="NSSubmenu" id="29659592">
|
||||||
<string key="NSTitle">Open Recent</string>
|
<string key="NSTitle">Open Recent</string>
|
||||||
<object class="NSMutableArray" key="NSMenuItems">
|
<object class="NSMutableArray" key="NSMenuItems">
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
<object class="NSMenuItem" id="759406840">
|
<object class="NSMenuItem" id="833175649">
|
||||||
<reference key="NSMenu" ref="1065607017"/>
|
<reference key="NSMenu" ref="29659592"/>
|
||||||
<string key="NSTitle">Clear Menu</string>
|
<string key="NSTitle">Clear Menu</string>
|
||||||
<string key="NSKeyEquiv"/>
|
<string key="NSKeyEquiv"/>
|
||||||
<int key="NSKeyEquivModMask">1048576</int>
|
<int key="NSKeyEquivModMask">1048576</int>
|
||||||
@ -149,6 +172,8 @@
|
|||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<string key="NSName">_NSRecentDocumentsMenu</string>
|
<string key="NSName">_NSRecentDocumentsMenu</string>
|
||||||
|
<bool key="NSNoAutoenable">YES</bool>
|
||||||
|
<bool key="NSMenuExcludeMarkColumn">YES</bool>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMenuItem" id="425164168">
|
<object class="NSMenuItem" id="425164168">
|
||||||
@ -310,6 +335,7 @@
|
|||||||
<string key="NSFrameSize">{800, 600}</string>
|
<string key="NSFrameSize">{800, 600}</string>
|
||||||
<reference key="NSSuperview" ref="439893737"/>
|
<reference key="NSSuperview" ref="439893737"/>
|
||||||
<reference key="NSWindow"/>
|
<reference key="NSWindow"/>
|
||||||
|
<reference key="NSNextKeyView"/>
|
||||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||||
<string key="NSClassName">RocketView</string>
|
<string key="NSClassName">RocketView</string>
|
||||||
</object>
|
</object>
|
||||||
@ -369,22 +395,6 @@
|
|||||||
</object>
|
</object>
|
||||||
<object class="IBConnectionRecord">
|
<object class="IBConnectionRecord">
|
||||||
<object class="IBActionConnection" key="connection">
|
<object class="IBActionConnection" key="connection">
|
||||||
<string key="label">arrangeInFront:</string>
|
|
||||||
<reference key="source" ref="1014"/>
|
|
||||||
<reference key="destination" ref="625202149"/>
|
|
||||||
</object>
|
|
||||||
<int key="connectionID">39</int>
|
|
||||||
</object>
|
|
||||||
<object class="IBConnectionRecord">
|
|
||||||
<object class="IBActionConnection" key="connection">
|
|
||||||
<string key="label">clearRecentDocuments:</string>
|
|
||||||
<reference key="source" ref="1014"/>
|
|
||||||
<reference key="destination" ref="759406840"/>
|
|
||||||
</object>
|
|
||||||
<int key="connectionID">127</int>
|
|
||||||
</object>
|
|
||||||
<object class="IBConnectionRecord">
|
|
||||||
<object class="IBActionConnection" key="connection">
|
|
||||||
<string key="label">performZoom:</string>
|
<string key="label">performZoom:</string>
|
||||||
<reference key="source" ref="1014"/>
|
<reference key="source" ref="1014"/>
|
||||||
<reference key="destination" ref="575023229"/>
|
<reference key="destination" ref="575023229"/>
|
||||||
@ -525,10 +535,11 @@
|
|||||||
<reference ref="117038363"/>
|
<reference ref="117038363"/>
|
||||||
<reference ref="722745758"/>
|
<reference ref="722745758"/>
|
||||||
<reference ref="705341025"/>
|
<reference ref="705341025"/>
|
||||||
<reference ref="1025936716"/>
|
|
||||||
<reference ref="425164168"/>
|
<reference ref="425164168"/>
|
||||||
<reference ref="49223823"/>
|
<reference ref="49223823"/>
|
||||||
<reference ref="1010469920"/>
|
<reference ref="1010469920"/>
|
||||||
|
<reference ref="573637146"/>
|
||||||
|
<reference ref="752287694"/>
|
||||||
</object>
|
</object>
|
||||||
<reference key="parent" ref="379814623"/>
|
<reference key="parent" ref="379814623"/>
|
||||||
</object>
|
</object>
|
||||||
@ -538,15 +549,6 @@
|
|||||||
<reference key="parent" ref="720053764"/>
|
<reference key="parent" ref="720053764"/>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBObjectRecord">
|
<object class="IBObjectRecord">
|
||||||
<int key="objectID">124</int>
|
|
||||||
<reference key="object" ref="1025936716"/>
|
|
||||||
<object class="NSMutableArray" key="children">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<reference ref="1065607017"/>
|
|
||||||
</object>
|
|
||||||
<reference key="parent" ref="720053764"/>
|
|
||||||
</object>
|
|
||||||
<object class="IBObjectRecord">
|
|
||||||
<int key="objectID">79</int>
|
<int key="objectID">79</int>
|
||||||
<reference key="object" ref="425164168"/>
|
<reference key="object" ref="425164168"/>
|
||||||
<reference key="parent" ref="720053764"/>
|
<reference key="parent" ref="720053764"/>
|
||||||
@ -557,20 +559,6 @@
|
|||||||
<reference key="parent" ref="720053764"/>
|
<reference key="parent" ref="720053764"/>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBObjectRecord">
|
<object class="IBObjectRecord">
|
||||||
<int key="objectID">125</int>
|
|
||||||
<reference key="object" ref="1065607017"/>
|
|
||||||
<object class="NSMutableArray" key="children">
|
|
||||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
|
||||||
<reference ref="759406840"/>
|
|
||||||
</object>
|
|
||||||
<reference key="parent" ref="1025936716"/>
|
|
||||||
</object>
|
|
||||||
<object class="IBObjectRecord">
|
|
||||||
<int key="objectID">126</int>
|
|
||||||
<reference key="object" ref="759406840"/>
|
|
||||||
<reference key="parent" ref="1065607017"/>
|
|
||||||
</object>
|
|
||||||
<object class="IBObjectRecord">
|
|
||||||
<int key="objectID">57</int>
|
<int key="objectID">57</int>
|
||||||
<reference key="object" ref="110575045"/>
|
<reference key="object" ref="110575045"/>
|
||||||
<object class="NSMutableArray" key="children">
|
<object class="NSMutableArray" key="children">
|
||||||
@ -704,6 +692,52 @@
|
|||||||
<reference key="object" ref="117038363"/>
|
<reference key="object" ref="117038363"/>
|
||||||
<reference key="parent" ref="720053764"/>
|
<reference key="parent" ref="720053764"/>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">548</int>
|
||||||
|
<reference key="object" ref="573637146"/>
|
||||||
|
<object class="NSMutableArray" key="children">
|
||||||
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<reference ref="29659592"/>
|
||||||
|
</object>
|
||||||
|
<reference key="parent" ref="720053764"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">549</int>
|
||||||
|
<reference key="object" ref="29659592"/>
|
||||||
|
<object class="NSMutableArray" key="children">
|
||||||
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<reference ref="833175649"/>
|
||||||
|
</object>
|
||||||
|
<reference key="parent" ref="573637146"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">550</int>
|
||||||
|
<reference key="object" ref="833175649"/>
|
||||||
|
<reference key="parent" ref="29659592"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">562</int>
|
||||||
|
<reference key="object" ref="752287694"/>
|
||||||
|
<object class="NSMutableArray" key="children">
|
||||||
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<reference ref="573498689"/>
|
||||||
|
</object>
|
||||||
|
<reference key="parent" ref="720053764"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">563</int>
|
||||||
|
<reference key="object" ref="573498689"/>
|
||||||
|
<object class="NSMutableArray" key="children">
|
||||||
|
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||||
|
<reference ref="264375453"/>
|
||||||
|
</object>
|
||||||
|
<reference key="parent" ref="752287694"/>
|
||||||
|
</object>
|
||||||
|
<object class="IBObjectRecord">
|
||||||
|
<int key="objectID">564</int>
|
||||||
|
<reference key="object" ref="264375453"/>
|
||||||
|
<reference key="parent" ref="573498689"/>
|
||||||
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||||
@ -713,9 +747,6 @@
|
|||||||
<string>-1.IBPluginDependency</string>
|
<string>-1.IBPluginDependency</string>
|
||||||
<string>-2.IBPluginDependency</string>
|
<string>-2.IBPluginDependency</string>
|
||||||
<string>-3.IBPluginDependency</string>
|
<string>-3.IBPluginDependency</string>
|
||||||
<string>124.IBPluginDependency</string>
|
|
||||||
<string>125.IBPluginDependency</string>
|
|
||||||
<string>126.IBPluginDependency</string>
|
|
||||||
<string>136.IBPluginDependency</string>
|
<string>136.IBPluginDependency</string>
|
||||||
<string>149.IBPluginDependency</string>
|
<string>149.IBPluginDependency</string>
|
||||||
<string>19.IBPluginDependency</string>
|
<string>19.IBPluginDependency</string>
|
||||||
@ -734,7 +765,13 @@
|
|||||||
<string>494.IBPluginDependency</string>
|
<string>494.IBPluginDependency</string>
|
||||||
<string>5.IBPluginDependency</string>
|
<string>5.IBPluginDependency</string>
|
||||||
<string>537.IBPluginDependency</string>
|
<string>537.IBPluginDependency</string>
|
||||||
|
<string>548.IBPluginDependency</string>
|
||||||
|
<string>549.IBPluginDependency</string>
|
||||||
|
<string>550.IBPluginDependency</string>
|
||||||
<string>56.IBPluginDependency</string>
|
<string>56.IBPluginDependency</string>
|
||||||
|
<string>562.IBPluginDependency</string>
|
||||||
|
<string>563.IBPluginDependency</string>
|
||||||
|
<string>564.IBPluginDependency</string>
|
||||||
<string>57.IBPluginDependency</string>
|
<string>57.IBPluginDependency</string>
|
||||||
<string>58.IBPluginDependency</string>
|
<string>58.IBPluginDependency</string>
|
||||||
<string>72.IBPluginDependency</string>
|
<string>72.IBPluginDependency</string>
|
||||||
@ -761,9 +798,6 @@
|
|||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
|
||||||
<string>{{928, 459}, {480, 360}}</string>
|
<string>{{928, 459}, {480, 360}}</string>
|
||||||
<integer value="1"/>
|
<integer value="1"/>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
@ -787,6 +821,12 @@
|
|||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
|
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||||
@ -801,7 +841,7 @@
|
|||||||
<reference key="dict.values" ref="0"/>
|
<reference key="dict.values" ref="0"/>
|
||||||
</object>
|
</object>
|
||||||
<nil key="sourceID"/>
|
<nil key="sourceID"/>
|
||||||
<int key="maxID">547</int>
|
<int key="maxID">567</int>
|
||||||
</object>
|
</object>
|
||||||
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
<object class="IBClassDescriber" key="IBDocument.Classes"/>
|
||||||
<int key="IBDocument.localizationMode">0</int>
|
<int key="IBDocument.localizationMode">0</int>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
<string>icon</string>
|
<string>icon</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>com.yourcompany.someid</string>
|
<string>com.tbl.rocketeditor</string>
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "../../sync/data.h"
|
#include "../../sync/data.h"
|
||||||
|
|
||||||
extern void Window_setTitle(const char* title);
|
extern void Window_setTitle(const char* title);
|
||||||
|
extern void Window_populateRecentList(const char** files);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -45,10 +46,61 @@ typedef struct EditorData
|
|||||||
int copyCount;
|
int copyCount;
|
||||||
} EditorData;
|
} EditorData;
|
||||||
|
|
||||||
static char s_currentFile[2048];
|
|
||||||
static EditorData s_editorData;
|
static EditorData s_editorData;
|
||||||
static CopyData s_copyData;
|
static CopyData s_copyData;
|
||||||
static bool reset_tracks = true;
|
static bool reset_tracks = true;
|
||||||
|
static char s_filenames[5][2048];
|
||||||
|
|
||||||
|
static char* s_recentFiles[] =
|
||||||
|
{
|
||||||
|
s_filenames[0],
|
||||||
|
s_filenames[1],
|
||||||
|
s_filenames[2],
|
||||||
|
s_filenames[3],
|
||||||
|
s_filenames[4],
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
char** Editor_getRecentFiles()
|
||||||
|
{
|
||||||
|
return (char**)s_recentFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const char* getMostRecentFile()
|
||||||
|
{
|
||||||
|
return s_recentFiles[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void setMostRecentFile(const char* filename)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// move down all files
|
||||||
|
for (i = 3; i >= 0; --i)
|
||||||
|
strcpy(s_recentFiles[i+1], s_recentFiles[i]);
|
||||||
|
|
||||||
|
strcpy(s_recentFiles[0], filename);
|
||||||
|
|
||||||
|
// check if the string was already present and remove it if that is the case by compacting the array
|
||||||
|
|
||||||
|
for (i = 1; i < 5; ++i)
|
||||||
|
{
|
||||||
|
if (!strcmp(s_recentFiles[i], filename))
|
||||||
|
{
|
||||||
|
for (; i < 4; ++i)
|
||||||
|
strcpy(s_recentFiles[i], s_recentFiles[i + 1]);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window_populateRecentList((const char**)s_recentFiles);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -565,6 +617,7 @@ bool Editor_keyDown(int key, int keyCode, int modifiers)
|
|||||||
row = t->keys[idx + 1].row;
|
row = t->keys[idx + 1].row;
|
||||||
|
|
||||||
viewInfo->rowPos = row;
|
viewInfo->rowPos = row;
|
||||||
|
viewInfo->selectStartRow = viewInfo->selectStopRow = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -826,14 +879,9 @@ bool Editor_keyDown(int key, int keyCode, int modifiers)
|
|||||||
case 14 : bias_value = 1.0f; break;
|
case 14 : bias_value = 1.0f; break;
|
||||||
case 15 : bias_value = 10.f; break;
|
case 15 : bias_value = 10.f; break;
|
||||||
case 17 : bias_value = 100.0f; break;
|
case 17 : bias_value = 100.0f; break;
|
||||||
case 16 : bias_value = 1000.0f; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
biasSelection(bias_value, selectLeft, selectRight, selectTop, selectBottom);
|
biasSelection(bias_value, selectLeft, selectRight, selectTop, selectBottom);
|
||||||
|
|
||||||
Editor_update();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// do edit here and biasing here
|
// do edit here and biasing here
|
||||||
@ -1089,12 +1137,30 @@ static void setWindowTitle(const char* path)
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static void onOpen()
|
void Editor_loadRecentFile(int id)
|
||||||
{
|
{
|
||||||
if (LoadSave_loadRocketXMLDialog(s_currentFile, getTrackData()))
|
char path[2048];
|
||||||
|
strcpy(path, s_recentFiles[id]); // must be unique buffer when doing set mostRecent
|
||||||
|
|
||||||
|
if (LoadSave_loadRocketXML(path, getTrackData()))
|
||||||
{
|
{
|
||||||
Editor_update();
|
Editor_update();
|
||||||
setWindowTitle(s_currentFile);
|
setWindowTitle(path);
|
||||||
|
setMostRecentFile(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static void onOpen()
|
||||||
|
{
|
||||||
|
char currentFile[2048];
|
||||||
|
|
||||||
|
if (LoadSave_loadRocketXMLDialog(currentFile, getTrackData()))
|
||||||
|
{
|
||||||
|
Editor_update();
|
||||||
|
setWindowTitle(currentFile);
|
||||||
|
setMostRecentFile(currentFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,7 +1168,7 @@ static void onOpen()
|
|||||||
|
|
||||||
static void onSave()
|
static void onSave()
|
||||||
{
|
{
|
||||||
LoadSave_saveRocketXML(s_currentFile, getTrackData());
|
LoadSave_saveRocketXML(getMostRecentFile(), getTrackData());
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1110,9 +1176,11 @@ static void onSave()
|
|||||||
static void onSaveDialog()
|
static void onSaveDialog()
|
||||||
{
|
{
|
||||||
char path[2048];
|
char path[2048];
|
||||||
|
|
||||||
if (!LoadSave_saveRocketXMLDialog(path, getTrackData()))
|
if (!LoadSave_saveRocketXMLDialog(path, getTrackData()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
setMostRecentFile(path);
|
||||||
setWindowTitle(path);
|
setWindowTitle(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1120,7 +1188,6 @@ static void onSaveDialog()
|
|||||||
|
|
||||||
void Editor_menuEvent(int menuItem)
|
void Editor_menuEvent(int menuItem)
|
||||||
{
|
{
|
||||||
printf("%d\n", menuItem);
|
|
||||||
switch (menuItem)
|
switch (menuItem)
|
||||||
{
|
{
|
||||||
case EDITOR_MENU_OPEN : onOpen(); break;
|
case EDITOR_MENU_OPEN : onOpen(); break;
|
||||||
|
|||||||
@ -13,6 +13,9 @@ void Editor_setWindowSize(int x, int y);
|
|||||||
void Editor_menuEvent(int menuItem);
|
void Editor_menuEvent(int menuItem);
|
||||||
void Editor_scroll(float deltaX, float deltaY, int flags);
|
void Editor_scroll(float deltaX, float deltaY, int flags);
|
||||||
void Editor_updateTrackScroll();
|
void Editor_updateTrackScroll();
|
||||||
|
void Editor_loadRecentFile(int file);
|
||||||
|
|
||||||
|
char** Editor_getRecentFiles();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@ -213,6 +213,43 @@ static int getModifierFlags(int flags)
|
|||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
- (void)onRecentFile:(id)sender
|
||||||
|
{
|
||||||
|
NSString* string = [sender representedObject];
|
||||||
|
Editor_loadRecentFile([string intValue]);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void Window_populateRecentList(const char** files)
|
||||||
|
{
|
||||||
|
NSMenu* fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
|
||||||
|
NSMenu* recentItems = [[fileMenu itemWithTitle:@"Recent Files"] submenu];
|
||||||
|
|
||||||
|
[recentItems removeAllItems];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
const char* filename = files[i];
|
||||||
|
|
||||||
|
if (!strcmp(filename, ""))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
NSString* name = [NSString stringWithUTF8String: filename];
|
||||||
|
|
||||||
|
NSMenuItem* newItem = [[NSMenuItem alloc] initWithTitle:name action:@selector(onRecentFile:) keyEquivalent:@""];
|
||||||
|
[newItem setRepresentedObject:[NSString stringWithFormat:@"%d",i]];
|
||||||
|
[newItem setKeyEquivalentModifierMask: NSCommandKeyMask];
|
||||||
|
[newItem setKeyEquivalent:[NSString stringWithFormat:@"%d",i + 1]];
|
||||||
|
|
||||||
|
[recentItems addItem:newItem];
|
||||||
|
|
||||||
|
[newItem release];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -229,3 +266,4 @@ void Window_setTitle(const char* title)
|
|||||||
[g_window setTitle:[NSString stringWithUTF8String:title]];
|
[g_window setTitle:[NSString stringWithUTF8String:title]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
#include "../RemoteConnection.h"
|
#include "../RemoteConnection.h"
|
||||||
#include "rlog.h"
|
#include "rlog.h"
|
||||||
|
|
||||||
|
void Window_populateRecentList(char** files);
|
||||||
|
|
||||||
@implementation MinimalAppAppDelegate
|
@implementation MinimalAppAppDelegate
|
||||||
|
|
||||||
@synthesize window;
|
@synthesize window;
|
||||||
@ -12,6 +14,24 @@
|
|||||||
|
|
||||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
|
char** recent_list = Editor_getRecentFiles();
|
||||||
|
|
||||||
|
NSUserDefaults* prefs = [NSUserDefaults standardUserDefaults];
|
||||||
|
|
||||||
|
if (prefs)
|
||||||
|
{
|
||||||
|
NSArray* stringArray = [prefs objectForKey:@"recentFiles"];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
NSString* name = [stringArray objectAtIndex:i];
|
||||||
|
const char* filename = [name cStringUsingEncoding:NSASCIIStringEncoding];
|
||||||
|
if (filename)
|
||||||
|
strcpy(recent_list[i], filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window_populateRecentList(recent_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -25,7 +45,17 @@
|
|||||||
|
|
||||||
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
- (void)applicationWillTerminate:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
rlog(R_INFO, "Dealloc\n");
|
int i;
|
||||||
|
NSMutableArray* stringArray;
|
||||||
|
char** recent_list = Editor_getRecentFiles();
|
||||||
|
stringArray = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
[stringArray addObject:[NSString stringWithUTF8String: recent_list[i]]];
|
||||||
|
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:stringArray forKey:@"recentFiles"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
|
||||||
Editor_destroy();
|
Editor_destroy();
|
||||||
RemoteConnection_close();
|
RemoteConnection_close();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user