Created
May 21, 2014 22:49
-
-
Save yoyz/2075e9704ce46a7d67ef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/projects/Makefile b/projects/Makefile | |
index 59768b2..d47f16d 100644 | |
--- a/projects/Makefile | |
+++ b/projects/Makefile | |
@@ -4,7 +4,7 @@ | |
.SUFFIXES: | |
#--------------------------------------------------------------------------------- | |
-PLATFORM:= RASPI | |
+PLATFORM:= DEB | |
include $(PWD)/Makefile.$(PLATFORM) | |
diff --git a/projects/Makefile.DEB b/projects/Makefile.DEB | |
index 4bf34ab..73cbf7b 100644 | |
--- a/projects/Makefile.DEB | |
+++ b/projects/Makefile.DEB | |
@@ -1,7 +1,7 @@ | |
include $(PWD)/deb_rules | |
-CFLAGS := -O3 -DCPP_MEMORY -Wall -I/usr/local/include -I$(PWD)/../sources -D__LINUX_ALSA__ -D__LINUX_ALSASEQ__ -D_DEBUG | |
+CFLAGS := -O3 -DCPP_MEMORY -Wall -I/usr/local/include -I$(PWD)/../sources -D__LINUX_ALSA__ -D__LINUX_ALSASEQ__ -D_DEBUG -fpermissive | |
#CFLAGS := -g -DCPP_MEMORY -Wall -I/usr/local/include -I$(PWD)/../sources -D__LINUX_ALSA__ -D__LINUX_ALSASEQ__ | |
diff --git a/sources/Application/AppWindow.cpp b/sources/Application/AppWindow.cpp | |
index faa12a2..f8eaa09 100644 | |
--- a/sources/Application/AppWindow.cpp | |
+++ b/sources/Application/AppWindow.cpp | |
@@ -77,6 +77,7 @@ AppWindow::AppWindow(I_GUIWindowImp &imp):GUIWindow(imp) { | |
_mixerView=0 ; | |
_grooveView=0 ; | |
_closeProject=0 ; | |
+ _loadAfterSaveAsProject=0 ; | |
_lastA=0 ; | |
_lastB=0 ; | |
_mask=0 ; | |
@@ -264,10 +265,11 @@ void AppWindow::Flush() { | |
} ; | |
void AppWindow::LoadProject(const Path &p) { | |
- | |
+ printf("project:%s\n",p.GetPath().c_str()); | |
_root=p ; | |
_closeProject=false ; | |
+ _loadAfterSaveAsProject=false; | |
PersistencyService *persist=PersistencyService::GetInstance() ; | |
@@ -450,6 +452,11 @@ bool AppWindow::onEvent(GUIEvent &event) { | |
CloseProject() ; | |
_isDirty=true ; | |
} | |
+ if(_loadAfterSaveAsProject) { | |
+ CloseProject(); | |
+ _isDirty=true; | |
+ LoadProject(_newProjectToLoad); | |
+ } | |
#ifdef _SHOW_GP2X_ | |
Redraw() ; | |
#else | |
@@ -529,12 +536,18 @@ void AppWindow::Update(Observable &o,I_ObservableData *d) { | |
break ; | |
} | |
-/* case VET_LIST_SELECT: | |
+ case VET_SAVEAS_PROJECT: | |
{ | |
char *name=(char*)ve->GetData() ; | |
- LoadProject(name) ; | |
+ //printf("name:%s\n",name); | |
+ //_isDirty=true ; | |
+ // CloseProject(); | |
+ //LoadProject(name) ; | |
+ //_closeProject=true; | |
+ _loadAfterSaveAsProject=true; | |
+ strcpy(_newProjectToLoad,name); | |
break ; | |
- } */ | |
+ } | |
case VET_QUIT_PROJECT: | |
{ | |
// defer event to after we got out of the view | |
diff --git a/sources/Application/AppWindow.h b/sources/Application/AppWindow.h | |
index 4cbf52c..704a4ee 100644 | |
--- a/sources/Application/AppWindow.h | |
+++ b/sources/Application/AppWindow.h | |
@@ -77,11 +77,13 @@ private: | |
bool _isDirty ; | |
bool _closeProject ; | |
+ bool _loadAfterSaveAsProject ; | |
bool _shouldQuit ; | |
unsigned short _mask ; | |
unsigned long _lastA ; | |
unsigned long _lastB ; | |
char _statusLine[80] ; | |
+ char _newProjectToLoad[80]; | |
unsigned char _charScreen[1200] ; | |
unsigned char _charScreenProp[1200] ; | |
unsigned char _preScreen[1200] ; | |
diff --git a/sources/Application/Views/BaseClasses/ViewEvent.h b/sources/Application/Views/BaseClasses/ViewEvent.h | |
index afa0432..151760c 100644 | |
--- a/sources/Application/Views/BaseClasses/ViewEvent.h | |
+++ b/sources/Application/Views/BaseClasses/ViewEvent.h | |
@@ -5,9 +5,9 @@ | |
enum ViewEventType { | |
VET_SWITCH_VIEW, | |
- VET_PLAYER_POSITION_UPDATE, | |
- VET_LIST_SELECT, | |
- VET_QUIT_PROJECT, | |
+ VET_PLAYER_POSITION_UPDATE, | |
+ VET_SAVEAS_PROJECT, | |
+ VET_QUIT_PROJECT, | |
VET_UPDATE, | |
VET_QUIT_APP | |
} ; | |
diff --git a/sources/Application/Views/ProjectView.cpp b/sources/Application/Views/ProjectView.cpp | |
index 573b940..5b7fc07 100644 | |
--- a/sources/Application/Views/ProjectView.cpp | |
+++ b/sources/Application/Views/ProjectView.cpp | |
@@ -6,13 +6,68 @@ | |
#include "System/System/System.h" | |
#include "Services/Midi/MidiService.h" | |
#include "Application/Views/ModalDialogs/MessageBox.h" | |
- | |
-#define ACTION_PURGE MAKE_FOURCC('P','U','R','G') | |
-#define ACTION_SAVE MAKE_FOURCC('S','A','V','E') | |
-#define ACTION_LOAD MAKE_FOURCC('L','O','A','D') | |
-#define ACTION_QUIT MAKE_FOURCC('Q','U','I','T') | |
+#include "Application/Views/ModalDialogs/NewProjectDialog.h" | |
+#include "Application/Views/ModalDialogs/SelectProjectDialog.h" | |
+ | |
+#define ACTION_PURGE MAKE_FOURCC('P','U','R','G') | |
+#define ACTION_SAVE MAKE_FOURCC('S','A','V','E') | |
+#define ACTION_SAVE_AS MAKE_FOURCC('S','V','A','S') | |
+#define ACTION_LOAD MAKE_FOURCC('L','O','A','D') | |
+#define ACTION_QUIT MAKE_FOURCC('Q','U','I','T') | |
#define ACTION_PURGE_INSTRUMENT MAKE_FOURCC('P','R','G','I') | |
-#define ACTION_TEMPO_CHANGED MAKE_FOURCC('T','E','M','P') | |
+#define ACTION_TEMPO_CHANGED MAKE_FOURCC('T','E','M','P') | |
+ | |
+ | |
+ | |
+static void SaveAsProjectCallback(View &v,ModalView &dialog) { | |
+ | |
+ FileSystemService FSS; | |
+ NewProjectDialog &npd=(NewProjectDialog &)dialog ; | |
+ | |
+ if (dialog.GetReturnCode()>0) { | |
+ std::string str_dstprjdir="../"+npd.GetName(); | |
+ std::string str_dstsmpdir="../"+npd.GetName()+"/samples"; | |
+ | |
+ Path path_dstprjdir = Path(str_dstprjdir.c_str()); | |
+ Path path_dstsmpdir = Path(str_dstsmpdir.c_str()); | |
+ Path path_srcprjdir("project:"); | |
+ Path path_srcsmpdir("project:samples"); | |
+ | |
+ Path path_srclgptdatsav=path_srcprjdir.GetPath()+"/lgptsav.dat"; | |
+ Path path_dstlgptdatsav=path_dstprjdir.GetPath()+"/lgptsav.dat"; | |
+ | |
+ | |
+ if (path_dstprjdir.Exists()) | |
+ Trace::Debug("Dst Dir Exist == true"); | |
+ else | |
+ { | |
+ Result result = FileSystem::GetInstance()->MakeDir(path_dstprjdir.GetPath().c_str()) ; | |
+ RETURN_IF_FAILED_MESSAGE(result,"Failed to create project dir"); | |
+ result = FileSystem::GetInstance()->MakeDir(path_dstsmpdir.GetPath().c_str()) ; | |
+ RETURN_IF_FAILED_MESSAGE(result,"Failed to create sample dir"); | |
+ | |
+ FSS.Copy(path_srclgptdatsav,path_dstlgptdatsav); | |
+ | |
+ I_Dir *idir_srcsmpdir=FileSystem::GetInstance()->Open(path_srcsmpdir.GetPath().c_str()) ; | |
+ if (idir_srcsmpdir) { | |
+ idir_srcsmpdir->GetContent("*") ; | |
+ idir_srcsmpdir->Sort() ; | |
+ IteratorPtr<Path>it(idir_srcsmpdir->GetIterator()) ; | |
+ for (it->Begin();!it->IsDone();it->Next()) { | |
+ Path ¤t=it->CurrentItem() ; | |
+ if (current.IsFile()) | |
+ { | |
+ Path dstfile = Path(str_dstsmpdir+"/"+current.GetName()); | |
+ Path srcfile = Path(current.GetPath()); | |
+ FSS.Copy(srcfile.GetPath(),dstfile.GetPath()); | |
+ } | |
+ } | |
+ } | |
+ //((ProjectView &)v).OnSaveAsProject(npd.GetName().c_str()) ; | |
+ ((ProjectView &)v).OnSaveAsProject(str_dstprjdir.c_str()) ; | |
+ } | |
+ } | |
+} | |
static void LoadCallback(View &v,ModalView &dialog) { | |
if (dialog.GetReturnCode()==MBL_YES) { | |
@@ -75,6 +130,11 @@ ProjectView::ProjectView(GUIWindow &w,ViewData *data):FieldView(w,data) { | |
a1->AddObserver(*this) ; | |
T_SimpleList<UIField>::Insert(a1) ; | |
+ position._y+=1 ; | |
+ a1=new UIActionField("Save As",ACTION_SAVE_AS,position) ; | |
+ a1->AddObserver(*this) ; | |
+ T_SimpleList<UIField>::Insert(a1) ; | |
+ | |
v=project_->FindVariable(VAR_MIDIDEVICE) ; | |
NAssert(v) ; | |
position._y+=2 ; | |
@@ -86,6 +146,8 @@ ProjectView::ProjectView(GUIWindow &w,ViewData *data):FieldView(w,data) { | |
a1->AddObserver(*this) ; | |
T_SimpleList<UIField>::Insert(a1) ; | |
+ | |
+ | |
} | |
ProjectView::~ProjectView() { | |
@@ -169,6 +231,20 @@ void ProjectView::Update(Observable &,I_ObservableData *data) { | |
DoModal(mb) ; | |
} | |
break ; | |
+ case ACTION_SAVE_AS: | |
+ if (!player->IsRunning()) { | |
+ PersistencyService *service=PersistencyService::GetInstance() ; | |
+ service->Save() ; | |
+ //MessageBox *mb=new MessageBox(*this,"Load song and lose changes ?",MBBF_YES|MBBF_NO) ; | |
+ NewProjectDialog *mb=new NewProjectDialog(*this) ; | |
+ DoModal(mb,SaveAsProjectCallback) ; | |
+ | |
+ } else { | |
+ MessageBox *mb=new MessageBox(*this,"Not while playing",MBBF_OK) ; | |
+ DoModal(mb) ; | |
+ } | |
+ break ; | |
+ | |
case ACTION_LOAD: | |
{ | |
if (!player->IsRunning()) { | |
@@ -211,8 +287,18 @@ void ProjectView::OnLoadProject() { | |
NotifyObservers(&ve) ; | |
} ; | |
+ | |
+void ProjectView::OnSaveAsProject(char * data) { | |
+ ViewEvent ve(VET_SAVEAS_PROJECT,data) ; | |
+ SetChanged(); | |
+ NotifyObservers(&ve) ; | |
+} ; | |
+ | |
+ | |
void ProjectView::OnQuit() { | |
ViewEvent ve(VET_QUIT_APP) ; | |
SetChanged(); | |
NotifyObservers(&ve) ; | |
} ; | |
+ | |
+ | |
diff --git a/sources/Application/Views/ProjectView.h b/sources/Application/Views/ProjectView.h | |
index d48a1d7..1f9474c 100644 | |
--- a/sources/Application/Views/ProjectView.h | |
+++ b/sources/Application/Views/ProjectView.h | |
@@ -21,6 +21,7 @@ public: | |
void Update(Observable &,I_ObservableData *) ; | |
void OnLoadProject() ; | |
+ void OnSaveAsProject(char * data) ; | |
void OnPurgeInstruments(bool removeFromDisk) ; | |
void OnQuit() ; | |
diff --git a/sources/Externals/Soundfont/DATATYPE.H b/sources/Externals/Soundfont/DATATYPE.H | |
index 762a724..69309a7 100644 | |
--- a/sources/Externals/Soundfont/DATATYPE.H | |
+++ b/sources/Externals/Soundfont/DATATYPE.H | |
@@ -87,6 +87,7 @@ | |
typedef char CHAR; /* 8 bit signed value */ | |
typedef short SHORT; /* 16 bit signed value was: INT */ | |
+ | |
#ifdef EMU_WINDOWS | |
/***************************************************************** | |
* These idiosyncratic pointer definitions for memory allocations | |
@@ -137,13 +138,13 @@ typedef unsigned short EMUSTAT; | |
#error <datatype.h>: short is out of range! | |
#endif | |
-#if (LONG_MAX != LONG_MAXVAL) | |
- #error <datatype.h>: long is out of range! | |
-#endif | |
+//#if (LONG_MAX != LONG_MAXVAL) | |
+//#error <datatype.h>: long is out of range! | |
+//#endif | |
-#if (ULONG_MAX != DWORD_MAXVAL) | |
- #error <datatype.h>: unsigned long is out of range! | |
-#endif | |
+//#if (ULONG_MAX != DWORD_MAXVAL) | |
+// #error <datatype.h>: unsigned long is out of range! | |
+//#endif | |
#ifdef __BYTE_COHERENT | |
diff --git a/sources/System/FileSystem/FileSystem.cpp b/sources/System/FileSystem/FileSystem.cpp | |
index 9f73a4e..38fc577 100644 | |
--- a/sources/System/FileSystem/FileSystem.cpp | |
+++ b/sources/System/FileSystem/FileSystem.cpp | |
@@ -166,6 +166,7 @@ Path::Alias::Alias(const char *alias,const char *path) { | |
const char *Path::Alias::GetAliasName() { | |
return alias_.c_str() ; | |
+ | |
} ; | |
const char *Path::Alias::GetPath() { | |
@@ -186,7 +187,7 @@ int FileSystemService::Copy(const Path &src,const Path &dst) | |
char buffer[bufsize]; | |
int count=0; | |
int nbwrite=-1; | |
- | |
+ | |
FileSystem * fs=FileSystem::GetInstance() ; | |
I_File * isrc=fs->Open(src.GetPath().c_str(),"r"); | |
I_File * idst=fs->Open(dst.GetPath().c_str(),"w"); | |
@@ -202,3 +203,4 @@ int FileSystemService::Copy(const Path &src,const Path &dst) | |
return nbwrite; | |
} | |
+ | |
diff --git a/sources/System/FileSystem/FileSystem.h b/sources/System/FileSystem/FileSystem.h | |
index a915ffc..15c260c 100644 | |
--- a/sources/System/FileSystem/FileSystem.h | |
+++ b/sources/System/FileSystem/FileSystem.h | |
@@ -108,9 +108,11 @@ public: | |
#define FS_FOPEN(a,b) FileSystem::GetInstance()->Open(a,b) | |
+ | |
class FileSystemService { | |
public: | |
int Copy(const Path &src,const Path &dst); | |
}; | |
#endif | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment