mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-06 10:47:34 +01:00
new directory system on linux
This commit is contained in:
parent
d1a8425d43
commit
22d18a9e58
@ -117,6 +117,14 @@ int sdrpp_main(int argc, char *argv[]) {
|
|||||||
defConfig["windowSize"]["h"] = 720;
|
defConfig["windowSize"]["h"] = 720;
|
||||||
defConfig["windowSize"]["w"] = 1280;
|
defConfig["windowSize"]["w"] = 1280;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
defConfig["modulesDirectory"] = "./modules";
|
||||||
|
defConfig["resourcesDirectory"] = "./res";
|
||||||
|
#else
|
||||||
|
defConfig["modulesDirectory"] = "/usr/lib/sdrpp/plugins";
|
||||||
|
defConfig["resourcesDirectory"] = "/usr/share/sdrpp";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
spdlog::info("Loading config");
|
spdlog::info("Loading config");
|
||||||
core::configManager.setPath(options::opts.root + "/config.json");
|
core::configManager.setPath(options::opts.root + "/config.json");
|
||||||
@ -138,6 +146,7 @@ int sdrpp_main(int argc, char *argv[]) {
|
|||||||
int winWidth = core::configManager.conf["windowSize"]["w"];
|
int winWidth = core::configManager.conf["windowSize"]["w"];
|
||||||
int winHeight = core::configManager.conf["windowSize"]["h"];
|
int winHeight = core::configManager.conf["windowSize"]["h"];
|
||||||
maximized = core::configManager.conf["maximized"];
|
maximized = core::configManager.conf["maximized"];
|
||||||
|
std::string resDir = core::configManager.conf["resourcesDirectory"];
|
||||||
core::configManager.release();
|
core::configManager.release();
|
||||||
|
|
||||||
// Create window with graphics context
|
// Create window with graphics context
|
||||||
@ -198,13 +207,13 @@ int sdrpp_main(int argc, char *argv[]) {
|
|||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 150");
|
ImGui_ImplOpenGL3_Init("#version 150");
|
||||||
|
|
||||||
style::setDarkStyle();
|
if (!style::setDarkStyle(resDir)) { return -1; }
|
||||||
|
|
||||||
LoadingScreen::setWindow(window);
|
LoadingScreen::setWindow(window);
|
||||||
|
|
||||||
LoadingScreen::show("Loading icons");
|
LoadingScreen::show("Loading icons");
|
||||||
spdlog::info("Loading icons");
|
spdlog::info("Loading icons");
|
||||||
icons::load();
|
if (!icons::load(resDir)) { return -1; }
|
||||||
|
|
||||||
LoadingScreen::show("Loading band plans");
|
LoadingScreen::show("Loading band plans");
|
||||||
spdlog::info("Loading band plans");
|
spdlog::info("Loading band plans");
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include <imgui/stb_image.h>
|
#include <imgui/stb_image.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
namespace icons {
|
namespace icons {
|
||||||
ImTextureID LOGO;
|
ImTextureID LOGO;
|
||||||
@ -31,14 +33,21 @@ namespace icons {
|
|||||||
return texId;
|
return texId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void load() {
|
bool load(std::string resDir) {
|
||||||
LOGO = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/sdrpp.png");
|
if (!std::filesystem::is_directory(resDir)) {
|
||||||
PLAY = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/play.png");
|
spdlog::error("Inavlid resource directory: {0}", resDir);
|
||||||
STOP = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/stop.png");
|
return false;
|
||||||
MENU = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/menu.png");
|
}
|
||||||
MUTED = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/muted.png");
|
|
||||||
UNMUTED = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/unmuted.png");
|
LOGO = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/sdrpp.png");
|
||||||
NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/normal_tuning.png");
|
PLAY = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/play.png");
|
||||||
CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(options::opts.root + "/res/icons/center_tuning.png");
|
STOP = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/stop.png");
|
||||||
|
MENU = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/menu.png");
|
||||||
|
MUTED = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/muted.png");
|
||||||
|
UNMUTED = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/unmuted.png");
|
||||||
|
NORMAL_TUNING = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/normal_tuning.png");
|
||||||
|
CENTER_TUNING = (ImTextureID)(uintptr_t)loadTexture(resDir + "/icons/center_tuning.png");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -14,5 +14,5 @@ namespace icons {
|
|||||||
extern ImTextureID CENTER_TUNING;
|
extern ImTextureID CENTER_TUNING;
|
||||||
|
|
||||||
GLuint loadTexture(std::string path);
|
GLuint loadTexture(std::string path);
|
||||||
void load();
|
bool load(std::string resDir);
|
||||||
}
|
}
|
@ -120,6 +120,7 @@ void windowInit() {
|
|||||||
|
|
||||||
core::configManager.aquire();
|
core::configManager.aquire();
|
||||||
gui::menu.order = core::configManager.conf["menuOrder"].get<std::vector<std::string>>();
|
gui::menu.order = core::configManager.conf["menuOrder"].get<std::vector<std::string>>();
|
||||||
|
std::string modulesDir = core::configManager.conf["modulesDirectory"];
|
||||||
core::configManager.release();
|
core::configManager.release();
|
||||||
|
|
||||||
gui::menu.registerEntry("Source", sourecmenu::draw, NULL);
|
gui::menu.registerEntry("Source", sourecmenu::draw, NULL);
|
||||||
@ -144,8 +145,8 @@ void windowInit() {
|
|||||||
spdlog::info("Loading modules");
|
spdlog::info("Loading modules");
|
||||||
|
|
||||||
// Load modules from /module directory
|
// Load modules from /module directory
|
||||||
if (std::filesystem::is_directory(options::opts.root + "/modules")) {
|
if (std::filesystem::is_directory(modulesDir)) {
|
||||||
for (const auto & file : std::filesystem::directory_iterator(options::opts.root + "/modules")) {
|
for (const auto & file : std::filesystem::directory_iterator(modulesDir)) {
|
||||||
std::string path = file.path().generic_string();
|
std::string path = file.path().generic_string();
|
||||||
if (file.path().extension().generic_string() != SDRPP_MOD_EXTENTSION) {
|
if (file.path().extension().generic_string() != SDRPP_MOD_EXTENTSION) {
|
||||||
continue;
|
continue;
|
||||||
@ -157,7 +158,7 @@ void windowInit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
spdlog::warn("Module directory {0} does not exist, not loading modules from directory");
|
spdlog::warn("Module directory {0} does not exist, not loading modules from directory", modulesDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read module config
|
// Read module config
|
||||||
|
@ -3,13 +3,20 @@
|
|||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <options.h>
|
#include <options.h>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
ImFont* baseFont;
|
ImFont* baseFont;
|
||||||
ImFont* bigFont;
|
ImFont* bigFont;
|
||||||
ImFont* hugeFont;
|
ImFont* hugeFont;
|
||||||
|
|
||||||
void setDefaultStyle() {
|
bool setDefaultStyle(std::string resDir) {
|
||||||
|
if (!std::filesystem::is_directory(resDir)) {
|
||||||
|
spdlog::error("Inavlid resource directory: {0}", resDir);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::GetStyle().WindowRounding = 0.0f;
|
ImGui::GetStyle().WindowRounding = 0.0f;
|
||||||
ImGui::GetStyle().ChildRounding = 0.0f;
|
ImGui::GetStyle().ChildRounding = 0.0f;
|
||||||
ImGui::GetStyle().FrameRounding = 0.0f;
|
ImGui::GetStyle().FrameRounding = 0.0f;
|
||||||
@ -17,19 +24,26 @@ namespace style {
|
|||||||
ImGui::GetStyle().PopupRounding = 0.0f;
|
ImGui::GetStyle().PopupRounding = 0.0f;
|
||||||
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
||||||
|
|
||||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||||
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
//ImGui::StyleColorsLight();
|
//ImGui::StyleColorsLight();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void testtt() {
|
void testtt() {
|
||||||
ImGui::StyleColorsLight();
|
ImGui::StyleColorsLight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDarkStyle() {
|
bool setDarkStyle(std::string resDir) {
|
||||||
|
if (!std::filesystem::is_directory(resDir)) {
|
||||||
|
spdlog::error("Inavlid resource directory: {0}", resDir);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::GetStyle().WindowRounding = 0.0f;
|
ImGui::GetStyle().WindowRounding = 0.0f;
|
||||||
ImGui::GetStyle().ChildRounding = 0.0f;
|
ImGui::GetStyle().ChildRounding = 0.0f;
|
||||||
ImGui::GetStyle().FrameRounding = 0.0f;
|
ImGui::GetStyle().FrameRounding = 0.0f;
|
||||||
@ -37,9 +51,9 @@ namespace style {
|
|||||||
ImGui::GetStyle().PopupRounding = 0.0f;
|
ImGui::GetStyle().PopupRounding = 0.0f;
|
||||||
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
ImGui::GetStyle().ScrollbarRounding = 0.0f;
|
||||||
|
|
||||||
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 16.0f);
|
||||||
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 42.0f);
|
||||||
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(options::opts.root + "/res/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(((std::string)(resDir + "/fonts/Roboto-Medium.ttf")).c_str(), 128.0f);
|
||||||
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
|
||||||
@ -89,6 +103,8 @@ namespace style {
|
|||||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
colors[ImGuiCol_NavHighlight] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void beginDisabled() {
|
void beginDisabled() {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace style {
|
namespace style {
|
||||||
extern ImFont* baseFont;
|
extern ImFont* baseFont;
|
||||||
extern ImFont* bigFont;
|
extern ImFont* bigFont;
|
||||||
extern ImFont* hugeFont;
|
extern ImFont* hugeFont;
|
||||||
|
|
||||||
void setDefaultStyle();
|
bool setDefaultStyle(std::string resDir);
|
||||||
void setDarkStyle();
|
bool setDarkStyle(std::string resDir);
|
||||||
void beginDisabled();
|
void beginDisabled();
|
||||||
void endDisabled();
|
void endDisabled();
|
||||||
void testtt();
|
void testtt();
|
||||||
|
@ -8,7 +8,7 @@ namespace options {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
opts.root = ".";
|
opts.root = ".";
|
||||||
#else
|
#else
|
||||||
opts.root = "~/.sdrpp/";
|
opts.root = "~/.config/sdrpp";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user