Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on Linux #3

Open
sphaero opened this issue Mar 13, 2024 · 0 comments
Open

Building on Linux #3

sphaero opened this issue Mar 13, 2024 · 0 comments

Comments

@sphaero
Copy link

sphaero commented Mar 13, 2024

I guess this project is primarily Windows focused?

I managed to compile it on Linux but had to do quite a few changes. It runs but I can't open a file. Editor seems to work but panels don't:

  • First there are some case insensitivity problems I had to correct, ie PathUtils instead of pathUtils
  • First I had to use my own GLFW instead of the one in the vendor dir. I'm not familiar with premake so I didn't dive in it.
  • change some platform specifics in premake
  • glfwIsWindowLightTheme is only recently added to GLFW I guess so had to remove that
  • casting to int for ID's is losing precision use long instead
  • Utils::Utf8ToWstring doesn't want to compile so remove that
  • add some missing includes

Here's the full diff:

diff --git a/premake5.lua b/premake5.lua
index e71a833..a882e6c 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -17,7 +17,6 @@ outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
 
 -- Projects
 group "Dependencies"
-       include "vendor/GLFW"
        include "vendor/Glad"
        include "vendor/imgui"
 
@@ -50,7 +49,6 @@ project "scex"
        includedirs
        {
                "src",
-               "vendor/GLFW/include",
                "vendor/Glad/include",
                "vendor/imgui",
                "vendor/ImGuiColorTextEdit",
@@ -63,10 +61,9 @@ project "scex"
 
        links 
        { 
-               "GLFW",
+               "glfw",
                "Glad",
                "ImGui",
-               "opengl32.lib"
        }
 
        filter "system:windows"
@@ -82,10 +79,8 @@ project "scex"
                defines "SCEX_DEBUG"
                runtime "Debug"
                symbols "on"
-               buildoptions { "/openmp" }
 
        filter "configurations:Release"
                defines "SCEX_RELEASE"
                runtime "Release"
                optimize "on"
-               buildoptions { "/openmp" }
\ No newline at end of file
diff --git a/src/ImGuiController.cpp b/src/ImGuiController.cpp
index 96bd117..9744f78 100644
--- a/src/ImGuiController.cpp
+++ b/src/ImGuiController.cpp
@@ -171,16 +171,8 @@ void scex::ImGuiController::Setup(GLFWwindow* window)
                std::cout << "Config file not found, using default values\n";
 
        // Setup Dear ImGui style
-       if (glfwIsWindowLightTheme(window))
-       {
-               ImGui::StyleColorsLight();
-               FileTextEdit::SetLightPaletteAsDefault();
-       }
-       else
-       {
-               ImGui::StyleColorsDark();
-               FileTextEdit::SetDarkPaletteAsDefault();
-       }
+    ImGui::StyleColorsDark();
+       FileTextEdit::SetDarkPaletteAsDefault();
 
        FontManager::Initialize(io, fontSize);
 
diff --git a/src/PathUtils.cpp b/src/PathUtils.cpp
index 93ead15..f71587d 100644
--- a/src/PathUtils.cpp
+++ b/src/PathUtils.cpp
@@ -1,7 +1,8 @@
-#include "pathUtils.h"
+#include "PathUtils.h"
 
 #include <filesystem>
 #include <iostream>
+#include <vector>
 
 #ifdef SCEX_PLATFORM_WINDOWS
 #define PATH_SEP '\\'
@@ -91,4 +92,4 @@ std::string PathUtils::GetFolderPath(const std::string& filePath)
        int i = filePath.length() - 1;
        for (; i > -1 && filePath[i] != '/' && filePath[i] != '\\'; i--) {};
        return filePath.substr(0, i + 1);
-}
\ No newline at end of file
+}
diff --git a/src/main.cpp b/src/main.cpp
index e2a11fb..30ad291 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,8 +1,8 @@
-#include <GLFW/glfw3.h>
 #include <filesystem>
 #include <iostream>
 #include <vector>
 #include <glad/glad.h>
+#include <GLFW/glfw3.h>
 
 #include <Utils.h>
 #include <PathUtils.h>
@@ -170,4 +170,4 @@ int main(int argc, char** argv)
 
        glfwTerminate();
        return 0;
-}
\ No newline at end of file
+}
diff --git a/src/panels/DirectoryFinder.cpp b/src/panels/DirectoryFinder.cpp
index 2a9c12e..47d4f84 100644
--- a/src/panels/DirectoryFinder.cpp
+++ b/src/panels/DirectoryFinder.cpp
@@ -20,7 +20,7 @@ DirectoryFinder::DirectoryFinder(const std::string& folderPath,
        this->onResultFoundCallback = onResultFoundCallback;
        this->onSearchFinishedCallback = onSearchFinishedCallback;
        this->onFocusedCallback = onFocusedCallback;
-       panelName = "Folder search##" + std::to_string((int)this);
+       panelName = "Folder search##" + folderPath;
        strcpy(directoryPath, folderPath.c_str());
        directoryPath[folderPath.length()] = '\0';
 }
@@ -131,7 +131,7 @@ void DirectoryFinder::Find()
                        continue;
 
                std::ifstream fileInput;
-               fileInput.open(Utils::Utf8ToWstring(filePath));
+               fileInput.open(filePath);
                std::string line;
                int curLine = 0;
                while (std::getline(fileInput, line))
@@ -198,4 +198,4 @@ void DirectoryFinder::Find()
 
        finderThread = nullptr;
        if (onSearchFinishedCallback != nullptr) onSearchFinishedCallback();
-}
\ No newline at end of file
+}
diff --git a/src/panels/DirectoryTreeView.cpp b/src/panels/DirectoryTreeView.cpp
index 79273eb..3bfbfce 100644
--- a/src/panels/DirectoryTreeView.cpp
+++ b/src/panels/DirectoryTreeView.cpp
@@ -1,6 +1,7 @@
 #include "DirectoryTreeView.h"
 
 #include <iostream>
+#include <algorithm>
 #include <PathUtils.h>
 
 #define MAX_SEARCH_RESULTS 50
@@ -16,7 +17,7 @@ DirectoryTreeView::DirectoryTreeView(
        int id)
 {
        this->id = id;
-       panelName = "Folder view##" + std::to_string((int)this);
+       panelName = "Folder view##" + folderPath;
        directoryPath = folderPath;
        this->onNodeFoundCallback = onNodeFoundCallback;
        this->onFileClickCallback = onFileClickCallback;
diff --git a/src/panels/FileTextEdit.cpp b/src/panels/FileTextEdit.cpp
index 0ddd7e6..99b84da 100644
--- a/src/panels/FileTextEdit.cpp
+++ b/src/panels/FileTextEdit.cpp
@@ -59,14 +59,14 @@ FileTextEdit::FileTextEdit(
        this->codeFontSize = FontManager::GetDefaultUiFontSize();
        editor = new TextEditor();
        if (filePath == nullptr)
-               panelName = "untitled##" + std::to_string((int)this);
+               panelName = "untitled##" + std::to_string((long)this);
        else
        {
                hasAssociatedFile = true;
                associatedFile = std::string(filePath);
                auto pathObject = std::filesystem::path(filePath);
-               panelName = pathObject.filename().string() + "##" + std::to_string((int)this);
-               std::ifstream t(Utils::Utf8ToWstring(filePath));
+               panelName = pathObject.filename().string() + "##" + std::to_string((long)this);
+               std::ifstream t(filePath);
                std::string str((std::istreambuf_iterator<char>(t)),
                        std::istreambuf_iterator<char>());
                editor->SetText(str);
@@ -329,7 +329,7 @@ void FileTextEdit::SetShowDebugPanel(bool value)
 
 void FileTextEdit::OnReloadCommand()
 {
-       std::ifstream t(Utils::Utf8ToWstring(associatedFile));
+       std::ifstream t(associatedFile);
        std::string str((std::istreambuf_iterator<char>(t)),
                std::istreambuf_iterator<char>());
        editor->SetText(str);
@@ -343,7 +343,7 @@ void FileTextEdit::OnLoadFromCommand()
                std::cout << "File not loaded\n";
        else
        {
-               std::ifstream t(Utils::Utf8ToWstring(selection[0]));
+               std::ifstream t(selection[0]);
                std::string str((std::istreambuf_iterator<char>(t)),
                        std::istreambuf_iterator<char>());
                editor->SetText(str);
@@ -365,10 +365,10 @@ void FileTextEdit::OnSaveCommand()
        {
                associatedFile = destination;
                hasAssociatedFile = true;
-               panelName = std::filesystem::path(destination).filename().string() + "##" + std::to_string((int)this);
-               std::ofstream outFile(Utils::Utf8ToWstring(destination), std::ios::binary);
+               panelName = std::filesystem::path(destination).filename().string() + "##" + std::to_string((long)this);
+               std::ofstream outFile(destination, std::ios::binary);
                outFile << textToSave;
                outFile.close();
        }
        undoIndexInDisk = editor->GetUndoIndex();
-}
\ No newline at end of file
+}
diff --git a/vendor/ImGuiColorTextEdit b/vendor/ImGuiColorTextEdit
--- a/vendor/ImGuiColorTextEdit
+++ b/vendor/ImGuiColorTextEdit
@@ -1 +1 @@
-Subproject commit bcfc10d7b8dd6fe6e3f77df6f2509ccb71a50233
+Subproject commit bcfc10d7b8dd6fe6e3f77df6f2509ccb71a50233-dirty
[:~/src/scex] master(+21/-32)* ± cd vendor/ImGuiColorTextEdit/
[:~/src/scex/vendor/ImGuiColorTextEdit] bcfc10d(+1/-0) ± git diff
diff --git a/TextEditor.h b/TextEditor.h
index 29552c2..c5fd928 100644
--- a/TextEditor.h
+++ b/TextEditor.h
@@ -9,6 +9,7 @@
 #include <unordered_set>
 #include <unordered_map>
 #include <map>
+#include <math.h>
 #include <boost/regex.hpp>
 #include "imgui.h"
 
[:~/src/scex/vendor/ImGuiColorTextEdit] bcfc10d(+1/-0) ± git diff
diff --git a/TextEditor.h b/TextEditor.h
index 29552c2..c5fd928 100644
--- a/TextEditor.h
+++ b/TextEditor.h
@@ -9,6 +9,7 @@
 #include <unordered_set>
 #include <unordered_map>
 #include <map>
+#include <math.h>
 #include <boost/regex.hpp>
 #include "imgui.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant