This commit is contained in:
Phillip Stephens 2016-01-15 20:05:55 -08:00
commit 72b60ce476
5 changed files with 74 additions and 6 deletions

View File

@ -99,6 +99,9 @@ bool ProjectManager::openProject(const HECL::SystemString& path)
m_vm.m_mainWindow->setTitle(m_proj->getProjectRootPath().getLastComponent());
m_vm.DismissSplash();
m_vm.FadeInEditors();
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());
return true;
makeDefault:
@ -164,6 +167,8 @@ bool ProjectManager::saveProject()
HECL::Rename(oldSpacesPath.getAbsolutePath().c_str(),
newSpacesPath.getAbsolutePath().c_str());
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());
return true;
}

View File

@ -93,7 +93,11 @@ class SplashScreen : public Specter::ModalWindow
std::string m_text;
const std::string* text() const {return &m_text;}
void activated() {m_parent.m_openProjBind.m_deferPath = m_path;}
void activated(const boo::SWindowCoord& coord)
{
m_parent.m_openProjBind.m_deferPath = m_path;
m_parent.m_openProjBind.m_splash.m_openButt.m_view->closeMenu(coord);
}
OpenRecentMenuItem(OpenRecentMenuRoot& parent, const HECL::SystemString& path)
: m_parent(parent), m_path(path)

View File

@ -4,6 +4,7 @@
#include "SplashScreen.hpp"
#include "locale/locale.hpp"
#include "ResourceBrowser.hpp"
#include <cstdio>
using YAMLNode = Athena::io::YAMLNode;
@ -75,20 +76,76 @@ void ViewManager::DismissSplash()
ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this),
m_fontCache(fileMgr), m_translator(URDE::SystemLocaleOrEnglish())
{}
m_fontCache(fileMgr), m_translator(URDE::SystemLocaleOrEnglish()),
m_recentProjectsPath(HECL::SysFormat(_S("%s/recent_projects.txt"), fileMgr.getStoreRoot().c_str())),
m_recentFilesPath(HECL::SysFormat(_S("%s/recent_files.txt"), fileMgr.getStoreRoot().c_str()))
{
char path[2048];
HECL::Sstat theStat;
FILE* fp = HECL::Fopen(m_recentProjectsPath.c_str(), _S("r"), HECL::FileLockType::Read);
if (fp)
{
while (fgets(path, 2048, fp))
{
std::string pathStr(path);
pathStr.pop_back();
HECL::SystemStringView pathStrView(pathStr);
if (!HECL::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
m_recentProjects.push_back(pathStrView);
}
fclose(fp);
}
fp = HECL::Fopen(m_recentFilesPath.c_str(), _S("r"), HECL::FileLockType::Read);
if (fp)
{
while (fgets(path, 2048, fp))
{
std::string pathStr(path);
pathStr.pop_back();
HECL::SystemStringView pathStrView(pathStr);
if (!HECL::Stat(pathStrView.c_str(), &theStat) && S_ISDIR(theStat.st_mode))
m_recentFiles.push_back(pathStrView);
}
fclose(fp);
}
}
ViewManager::~ViewManager() {}
void ViewManager::pushRecentProject(const HECL::SystemString& path)
{
for (HECL::SystemString& testPath : m_recentProjects)
{
if (path == testPath)
return;
}
m_recentProjects.push_back(path);
FILE* fp = HECL::Fopen(m_recentProjectsPath.c_str(), _S("w"), HECL::FileLockType::Write);
if (fp)
{
for (HECL::SystemString& pPath : m_recentProjects)
fprintf(fp, "%s\n", HECL::SystemUTF8View(pPath).c_str());
fclose(fp);
}
}
void ViewManager::pushRecentFile(const HECL::SystemString& path)
{
for (HECL::SystemString& testPath : m_recentFiles)
{
if (path == testPath)
return;
}
m_recentFiles.push_back(path);
}
FILE* fp = HECL::Fopen(m_recentFilesPath.c_str(), _S("w"), HECL::FileLockType::Write);
if (fp)
{
for (HECL::SystemString& pPath : m_recentFiles)
fprintf(fp, "%s\n", HECL::SystemUTF8View(pPath).c_str());
fclose(fp);
}}
void ViewManager::init(boo::IApplication* app)
{

View File

@ -29,7 +29,9 @@ class ViewManager : public Specter::IViewManager
std::unique_ptr<RootSpace> m_rootSpace;
Specter::View* m_rootSpaceView = nullptr;
std::vector<HECL::SystemString> m_recentProjects = {"Test", "One", "Two", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
HECL::SystemString m_recentProjectsPath;
std::vector<HECL::SystemString> m_recentProjects;
HECL::SystemString m_recentFilesPath;
std::vector<HECL::SystemString> m_recentFiles;
bool m_updatePf = false;

2
hecl

@ -1 +1 @@
Subproject commit 5b5d78c2c50f917b07b2a2f534e3659d23be383e
Subproject commit 691e6180c4ab6eae12ee236f4d35b8c2ff74a6b2