*Addition of automatic directory detection. *Info on how to set Gorgon Resource Management Tool to run from any file location. 4.x-dev

Fri, 18 Dec 2020 20:58:10 +0100

author
Luca Tonini <luca.r.tonini@gmail.com>
date
Fri, 18 Dec 2020 20:58:10 +0100
branch
4.x-dev
changeset 1519
97abbb4f837f
parent 1518
ca727fb96027
child 1520
7b36ea054f75

*Addition of automatic directory detection. *Info on how to set Gorgon Resource Management Tool to run from any file location.

Tools/ResourceManagementUI/Source/Main.cpp file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Source/UI/App.cpp file | annotate | diff | comparison | revisions
Tools/ResourceManagementUI/Source/UI/App.h file | annotate | diff | comparison | revisions
--- a/Tools/ResourceManagementUI/Source/Main.cpp	Wed Dec 16 16:19:13 2020 +0100
+++ b/Tools/ResourceManagementUI/Source/Main.cpp	Fri Dec 18 20:58:10 2020 +0100
@@ -3,12 +3,17 @@
 #include <Gorgon/String.h>
 #include <Gorgon/OS.h>
 
+#include <Gorgon/Filesystem.h>
+
 #include "UI/App.h"
 
+#include <filesystem>
+
 #ifdef LINUX
 #include <unistd.h>
 #include <wait.h>
 
+
 namespace Gorgon { namespace OS {
     bool Start(const std::string &name, std::streambuf *&buf, const std::vector<std::string> &args);
 } }
@@ -51,14 +56,15 @@
         commandline = PrepareArguments(argc, argv);
     
     Gorgon::Initialize("ResourceManagementUI");
-    
     //This will set up default fonts on a linux system if the provided font is not available
     std::streambuf *buf;
     Gorgon::OS::Start("fc-match", buf, {"-v", "sans"});
     system("pwd");
     
+    std::string fp = Gorgon::Filesystem::CurrentDirectory();
+    
     //Initializes the UI
-    UI::App app({550,350}, fs, "Gorgon Resource Manager", commandline);
+    UI::App app({850,350}, fs, "Gorgon Resource Manager", commandline, fp);
 
     //Continues to diplay the UI until it is closed by the user
     while(true){
--- a/Tools/ResourceManagementUI/Source/UI/App.cpp	Wed Dec 16 16:19:13 2020 +0100
+++ b/Tools/ResourceManagementUI/Source/UI/App.cpp	Fri Dec 18 20:58:10 2020 +0100
@@ -2,15 +2,16 @@
 #include <Gorgon/UI/Organizers/Flow.h>
 
 
+
 namespace UI{
 
     //Initialization of constructor class 
-    UI::App::App (Gorgon::Geometry::Size size, int fontSize, std::string title, std::vector<std::string> &tcommands ):window(size,title),initstyl("Goldman-Regular.ttf",14), cli(tcommands),btnImport("IMPORT"),btnFileFrom("Path From"), btnFileTo("Path To"), btnExit("EXIT"){
+    UI::App::App (Gorgon::Geometry::Size size, int fontSize, std::string title, std::vector<std::string> &tcommands, std::string filePath):window(size,title),initstyl("/home/luca/Gorgon/Tools/ResourceManagementUI/Bin/Goldman-Regular.ttf",14), cli(tcommands),btnImport("IMPORT"),btnFileFrom("Path From"), btnFileTo("Path To"), btnExit("EXIT"), pathTo(filePath), pathFrom(filePath){
         
         
         //Import application icon and apply to window
         //This may fail if the debug path is not set correctly
-        ico.Import("Icon.png");
+        ico.Import("/home/luca/Gorgon/Tools/ResourceManagementUI/Bin/Icon.png");
         icon = Gorgon::WindowManager::Icon{ico.GetData()};
         window.SetIcon(icon);
         
@@ -24,24 +25,26 @@
         
         
         //Initialization of settings  panel
-        pnlSettings.SetWidth(550);
+        pnlSettings.SetWidth(size.Width);
         pnlSettings.Move(0, 0);
-        pnlSettings.SetHeight(350);
+        pnlSettings.SetHeight(size.Height);
         pnlSettings.EnableScroll(false, false);
         window.Add(pnlSettings);
         
+        
+        
         //Organizers to display elements to the panel.
         auto &org = pnlSettings.CreateOrganizer<Gorgon::UI::Organizers::Flow>();
         
         org 
         << org.Break 
-        << 1 << "" << 4 << "Import From:" << 9 << pathFrom << btnFileFrom
+        << 1 << "" << 4 << "Import From:" << 19 << pathFrom << btnFileFrom
         << org.Break << org.Break
-        << 1 << "" << 4 << "Import To:" << 9 << pathTo << btnFileTo 
+        << 1 << "" << 4 << "Import To:" << 19 << pathTo << btnFileTo 
         << org.Break 
         << org.Break << org.Break << org.Break << org.Break << org.Break
         << org.Break 
-        << btnExit << 12 << "" << btnImport ;
+        << btnExit << 22 << "" << btnImport ;
         
         btnImport.PressEvent.Register([&]{
             Import();
--- a/Tools/ResourceManagementUI/Source/UI/App.h	Wed Dec 16 16:19:13 2020 +0100
+++ b/Tools/ResourceManagementUI/Source/UI/App.h	Fri Dec 18 20:58:10 2020 +0100
@@ -31,6 +31,7 @@
 #include <Gorgon/Graphics/FreeType.h>
 
 #include <Gorgon/Graphics/Color.h>
+#include <Gorgon/Filesystem.h>
 
 #include "Cli.h"
 
@@ -48,7 +49,7 @@
     class App{
     public:    
         //Declaration function for UI to be called in Main.cpp
-        App (Gorgon::Geometry::Size size, int fontSize, std::string title, std::vector<std::string> &tcommands );
+        App (Gorgon::Geometry::Size size, int fontSize, std::string title, std::vector<std::string> &tcommands, std::string filePath );
         
         
     private:

mercurial