Example #1
0
void OpenProjectsFromList(COMMAND_T*)
{
	char cPath[256];
	GetProjectPath(cPath, 256);
	char* filename = BrowseForFiles(__LOCALIZE("Select project list","sws_mbox"), cPath, NULL, false, "Reaper Project List (*.RPL)\0*.RPL\0All Files\0*.*\0");
	if (filename)
	{
		FILE* f = fopenUTF8(filename, "r");
		if (f)
		{
			// Save "prompt on new project" variable
			int iNewProjOpts;
			int sztmp;
			int* pNewProjOpts = (int*)get_config_var("newprojdo", &sztmp);
			iNewProjOpts = *pNewProjOpts;
			*pNewProjOpts = 0;
			int i = 0;

			int iProjects = -1;
			while (EnumProjects(++iProjects, NULL, 0)); // Count projects
			char cName[10];
			EnumProjects(-1, cName, 10);

			if (iProjects != 1 || cName[0] != 0 || GetNumTracks() != 0)
			{
				if (MessageBox(g_hwndParent, __LOCALIZE("Close active tabs first?","sws_mbox"), __LOCALIZE("SWS Project List Open","sws_mbox"), MB_YESNO) == IDYES)
					Main_OnCommand(40886, 0);
				else
					i = 1;
			}

			while(fgets(cPath, 256, f))
			{
				char* pC;
				while((pC = strchr(cPath, '\r'))) *pC = 0; // Strip newlines no matter the format
				while((pC = strchr(cPath, '\n'))) *pC = 0;
				if (cPath[0])
				{
					if (i++)
						Main_OnCommand(41929, 0); // New project tab (ignore default template)
					Main_openProject(cPath);
				}
			}
			fclose(f);

			*pNewProjOpts = iNewProjOpts;
		}
		else
			MessageBox(g_hwndParent, __LOCALIZE("Unable to open file.","sws_mbox"), __LOCALIZE("SWS Project List Open","sws_mbox"), MB_OK);

		free(filename);
	}
}
Example #2
0
void OpenLastProject(COMMAND_T*)
{
	char key[32];
	char cLastProj[MAX_PATH];
	int recentNum = GetPrivateProfileInt("REAPER", "numrecent", 0, get_ini_file());
	if (recentNum > 0)
	{
		sprintf(key, "recent%02d", recentNum);
		GetPrivateProfileString("Recent", key, "", cLastProj, MAX_PATH, get_ini_file());
		if (cLastProj[0])
			Main_openProject(cLastProj);
	}
}
Example #3
0
void OpenRelatedProject(COMMAND_T* pCmd)
{
	if ((int)pCmd->user == g_relatedProjects.Get()->GetSize())
		// Give the user the chance to add a related project if they selected the first open spot
		if (MessageBox(g_hwndParent, __LOCALIZE("No related project found. Add one now?","sws_mbox"), __LOCALIZE("SWS Open Related Project","sws_mbox"), MB_YESNO) == IDYES)
			AddRelatedProject();

	if ((int)pCmd->user >= g_relatedProjects.Get()->GetSize())
		return;

	WDL_String* pStr = g_relatedProjects.Get()->Get((int)pCmd->user);
	ReaProject* pProj;
	// See if it's already opened
	char cOpenedProj[256];
	int i = 0;
	while ((pProj = EnumProjects(i++, cOpenedProj, 256)))
	{
		if (_stricmp(cOpenedProj, pStr->Get()) == 0)
		{
			SelectProjectInstance(pProj);
			return;
		}
	}

	// Nope, open in new tab
	// Save "prompt on new project" variable
	int iNewProjOpts;
	int sztmp;
	int* pNewProjOpts = (int*)get_config_var("newprojdo", &sztmp);
	iNewProjOpts = *pNewProjOpts;
	*pNewProjOpts = 0;
	pProj = EnumProjects(-1, NULL, 0);
	Main_OnCommand(41929, 0); // New project tab (ignore default template)
	Main_openProject(pStr->Get());
	EnumProjects(-1, cOpenedProj, 256);
	if (_stricmp(pStr->Get(), cOpenedProj))
	{
		Main_OnCommand(40860, 0); // 40860 = Close current project tab
		SelectProjectInstance(pProj);
		g_relatedProjects.Get()->Delete((int)pCmd->user, true);
	}
	*pNewProjOpts = iNewProjOpts;
}
Example #4
0
void LoadOrSelectProject(const char* _fn, bool _newTab)
{
	if (!_fn)
		return;

	int i=0;
	bool found = false;
	ReaProject* prj = NULL;
	char fn[SNM_MAX_PATH] = "";
	while (!found && (prj = EnumProjects(i++, fn, sizeof(fn))))
		if (!_stricmp(_fn, fn))
			found = true;

	if (found)
		SelectProjectInstance(prj);
	else {
		if (_newTab) Main_OnCommand(40859,0);
		Main_openProject((char*)_fn); // includes an undo point
	}
}