Skip to content

Commit

Permalink
Use inotify for file watcing on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
dfranx committed Aug 22, 2019
1 parent ad6014b commit 4e62d5a
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 50 deletions.
24 changes: 20 additions & 4 deletions GUIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ namespace ed

Settings::Instance().Load();
m_loadTemplateList();


Logger::Get().Log("Initializing Dear ImGUI");

// set vsync on startup
SDL_GL_SetSwapInterval(Settings::Instance().General.VSync);

Expand All @@ -82,6 +84,8 @@ namespace ed

ImGui::StyleColorsDark();

Logger::Get().Log("Creating various UI view objects");

m_views.push_back(new PinnedUI(this, objects, "Pinned"));
m_views.push_back(new PreviewUI(this, objects, "Preview"));
m_views.push_back(new CodeEditorUI(this, objects, "Code"));
Expand Down Expand Up @@ -119,9 +123,11 @@ namespace ed
}
GUIManager::~GUIManager()
{
// turn off the tracker on startup
// turn off the tracker on exit
((CodeEditorUI*)Get(ViewID::Code))->SetTrackFileChanges(false);

Logger::Get().Log("Shutting down UI");

for (auto view : m_views)
delete view;

Expand Down Expand Up @@ -168,6 +174,8 @@ namespace ed
strcmp(settings.General.Font, "null") != 0) ||
m_fontNeedsUpdate)
{
Logger::Get().Log("Updating fonts...");

std::pair<std::string, int> edFont = ((CodeEditorUI*)Get(ViewID::Code))->GetFont();

m_cachedFont = settings.General.Font;
Expand Down Expand Up @@ -1043,6 +1051,8 @@ namespace ed
{
m_selectedTemplate = "";

Logger::Get().Log("Loading template list");

for (const auto & entry : ghc::filesystem::directory_iterator("templates")) {
std::string file = entry.path().filename().native();
m_templates.push_back(file);
Expand All @@ -1051,9 +1061,15 @@ namespace ed
m_selectedTemplate = file;
}

if (m_selectedTemplate.size() == 0)
if (m_templates.size() != 0)
if (m_selectedTemplate.size() == 0) {
if (m_templates.size() != 0) {
Logger::Get().Log("Default template set to " + m_selectedTemplate);
m_selectedTemplate = m_templates[0];
} else {
m_selectedTemplate = "?empty";
Logger::Get().Log("No templates found", true);
}
}

m_data->Parser.SetTemplate(m_selectedTemplate);
}
Expand Down
4 changes: 4 additions & 0 deletions Objects/HLSL2GLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ namespace ed
shaderType = EShLangGeometry;

glslang::TShader shader(shaderType);
if (entry.size() > 0 && entry != "main") {
shader.setEntryPoint(entry.c_str());
shader.setSourceEntryPoint(entry.c_str());
}
shader.setStrings(&inputStr, 1);

// set up
Expand Down
2 changes: 1 addition & 1 deletion Objects/PipelineManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace ed

m_project->ResetProjectDirectory();

if (openTemplate)
if (openTemplate && m_project->GetTemplate() != "?empty")
m_project->OpenTemplate();
}
}
6 changes: 5 additions & 1 deletion Objects/ProjectParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ namespace ed
{
std::string toGenericPath(const std::string& p)
{
return ghc::filesystem::path(p).generic_string();
std::string ret = p;
std::replace(ret.begin(), ret.end(), '\\', '/');
return ret;
}

ProjectParser::ProjectParser(PipelineManager* pipeline, ObjectManager* objects, RenderEngine* rend, MessageStack* msgs, GUIManager* gui) :
Expand All @@ -37,6 +39,8 @@ namespace ed
{}
void ProjectParser::Open(const std::string & file)
{
setlocale(LC_ALL,"C");

Logger::Get().Log("Openning a project file " + file);

m_file = file;
Expand Down
1 change: 1 addition & 0 deletions Objects/ProjectParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace ed
inline std::string GetProjectDirectory() { return m_projectPath; }

inline std::string GetOpenedFile() { return m_file; }
inline std::string GetTemplate() { return m_template; }

private:
void m_parseV1(pugi::xml_node& projectNode); // old
Expand Down
6 changes: 6 additions & 0 deletions Objects/RenderEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,15 @@ namespace ed
Logger::Get().Log("Caching a new shader pass " + std::string(items[i]->Name));

pipe::ShaderPass* data = reinterpret_cast<ed::pipe::ShaderPass*>(items[i]->Data);

m_items.insert(m_items.begin() + i, items[i]);
m_shaders.insert(m_shaders.begin() + i, 0);

if (strlen(data->VSPath) == 0 || strlen(data->PSPath) == 0) {
Logger::Get().Log("No shader paths are set", true);
continue;
}

/*
ITEM CACHING
*/
Expand Down
10 changes: 9 additions & 1 deletion Objects/Settings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Settings.h"
#include "Logger.h"
#include <inih/INIReader.h>

#include <algorithm>
Expand Down Expand Up @@ -61,9 +62,14 @@ namespace ed
}
void Settings::Load()
{
Logger::Get().Log("Reading settings");

INIReader ini("data/settings.ini");

if (ini.ParseError() != 0) return;
if (ini.ParseError() != 0) {
Logger::Get().Log("Failed to parse data/settings.ini", true);
return;
}

General.HLSLExtensions.clear();

Expand Down Expand Up @@ -121,6 +127,8 @@ namespace ed
}
void Settings::Save()
{
Logger::Get().Log("Saving settings");

std::ofstream ini("data/settings.ini");

ini << "[general]" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion Objects/SystemVariableManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace ed

SystemVariableManager() :
m_deltaTime(0.0f),
m_viewport(0,0), m_mouse(0,0),
m_viewport(0,1), m_mouse(0,0),
m_isPicked(false),
m_wasd(0,0,0,0) {
m_geometryTransform = glm::identity<glm::mat4>();
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,6 @@ There are also some features that I am looking to implement:


Except those large features, I am also planning to do some small QoL changes:
- logs from GUIManager and InterfaceManager
- reimplement Entry (disable if IsGLSL)
- convert paths in ProjectParser
- test 2 bound textures in a glsl shader
- test when there are no templates (should create fully empty project and not crash)
- implement inotify on linux

- feature such as "Change variables" for items but for changing textures -> render textured 3D models easily (have an option to set up everything automatically)
- add "Advanced" menu that allows user to modify (at least some) system variables when taking screenshot/video
- program crashes on invalid input layout (+ probably other invalid inputs too)
Expand Down
Loading

0 comments on commit 4e62d5a

Please sign in to comment.