mirror of https://github.com/AxioDL/metaforce.git
Recent projects functionality
This commit is contained in:
parent
342fc4a00c
commit
877a389da6
|
@ -99,6 +99,9 @@ bool ProjectManager::openProject(const HECL::SystemString& path)
|
||||||
m_vm.m_mainWindow->setTitle(m_proj->getProjectRootPath().getLastComponent());
|
m_vm.m_mainWindow->setTitle(m_proj->getProjectRootPath().getLastComponent());
|
||||||
m_vm.DismissSplash();
|
m_vm.DismissSplash();
|
||||||
m_vm.FadeInEditors();
|
m_vm.FadeInEditors();
|
||||||
|
|
||||||
|
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
makeDefault:
|
makeDefault:
|
||||||
|
@ -164,6 +167,8 @@ bool ProjectManager::saveProject()
|
||||||
HECL::Rename(oldSpacesPath.getAbsolutePath().c_str(),
|
HECL::Rename(oldSpacesPath.getAbsolutePath().c_str(),
|
||||||
newSpacesPath.getAbsolutePath().c_str());
|
newSpacesPath.getAbsolutePath().c_str());
|
||||||
|
|
||||||
|
m_vm.pushRecentProject(m_proj->getProjectRootPath().getAbsolutePath());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,11 @@ class SplashScreen : public Specter::ModalWindow
|
||||||
std::string m_text;
|
std::string m_text;
|
||||||
|
|
||||||
const std::string* text() const {return &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)
|
OpenRecentMenuItem(OpenRecentMenuRoot& parent, const HECL::SystemString& path)
|
||||||
: m_parent(parent), m_path(path)
|
: m_parent(parent), m_path(path)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "SplashScreen.hpp"
|
#include "SplashScreen.hpp"
|
||||||
#include "locale/locale.hpp"
|
#include "locale/locale.hpp"
|
||||||
#include "ResourceBrowser.hpp"
|
#include "ResourceBrowser.hpp"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
using YAMLNode = Athena::io::YAMLNode;
|
using YAMLNode = Athena::io::YAMLNode;
|
||||||
|
|
||||||
|
@ -75,20 +76,76 @@ void ViewManager::DismissSplash()
|
||||||
|
|
||||||
ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
|
ViewManager::ViewManager(HECL::Runtime::FileStoreManager& fileMgr, HECL::CVarManager& cvarMgr)
|
||||||
: m_fileStoreManager(fileMgr), m_cvarManager(cvarMgr), m_projManager(*this),
|
: 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() {}
|
ViewManager::~ViewManager() {}
|
||||||
|
|
||||||
void ViewManager::pushRecentProject(const HECL::SystemString& path)
|
void ViewManager::pushRecentProject(const HECL::SystemString& path)
|
||||||
{
|
{
|
||||||
|
for (HECL::SystemString& testPath : m_recentProjects)
|
||||||
|
{
|
||||||
|
if (path == testPath)
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_recentProjects.push_back(path);
|
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)
|
void ViewManager::pushRecentFile(const HECL::SystemString& path)
|
||||||
{
|
{
|
||||||
|
for (HECL::SystemString& testPath : m_recentFiles)
|
||||||
|
{
|
||||||
|
if (path == testPath)
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_recentFiles.push_back(path);
|
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)
|
void ViewManager::init(boo::IApplication* app)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,9 @@ class ViewManager : public Specter::IViewManager
|
||||||
std::unique_ptr<RootSpace> m_rootSpace;
|
std::unique_ptr<RootSpace> m_rootSpace;
|
||||||
Specter::View* m_rootSpaceView = nullptr;
|
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;
|
std::vector<HECL::SystemString> m_recentFiles;
|
||||||
|
|
||||||
bool m_updatePf = false;
|
bool m_updatePf = false;
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 02236f04488aee598ee268a6aefbdfb9e56bb98c
|
Subproject commit 691e6180c4ab6eae12ee236f4d35b8c2ff74a6b2
|
|
@ -1 +1 @@
|
||||||
Subproject commit c0cc30bca09e92b0c8e566016334c162c459f9dc
|
Subproject commit a7644ff04e5a21ffbd18721f4f53cc3d6fa531c4
|
Loading…
Reference in New Issue