Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $vcpkgTagName = &"git" -C $vcpkgRoot describe --exact-match --tags
$releasePath = [string](jq -r '.configurePresets[0].binaryDir' CMakePresets.json).Replace('${sourceDir}/', '')

Write-Output "--------------------------------------------------"
Write-Output "BUILD CONFIGURATION: $env:_RELEASE_CONFIGURATION"
Write-Output "BUILD CONFIGURATION: $env:_RELEASE_CONFIGURATION_PRESET"
Write-Output "RELEASE VERSION: $env:_RELEASE_VERSION"
Write-Output "VCPKG ORIGIN: $vcpkgOriginUrl"
Write-Output "VCPKG TAG: $vcpkgTagName"
Expand Down Expand Up @@ -113,9 +113,9 @@ cmd.exe /c "call $vcpkgRoot\bootstrap-vcpkg.bat"
vcpkg integrate install

# Start the build
cmake --preset "${env:_RELEASE_CONFIGURATION}"
cmake --build --preset "${env:_RELEASE_CONFIGURATION}"
cmake --preset "${env:_RELEASE_CONFIGURATION_PRESET}"
cmake --build --preset "${env:_RELEASE_CONFIGURATION_PRESET}"

# Start the packaging
7z a ".\.dist\${env:_RELEASE_NAME}-${env:_RELEASE_VERSION}.zip" ".\$releasePath\bin\${env:_RELEASE_CONFIGURATION}\*"
7z a ".\.dist\${env:_RELEASE_NAME}-${env:_RELEASE_VERSION}.zip" ".\$releasePath\bin\${env:_RELEASE_CONFIGURATION_RAW}\*"

3 changes: 2 additions & 1 deletion .github/workflows/main-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ env:
_IS_GITHUB_RELEASE: false
_RELEASE_NAME: Field-Map-Editor
_RELEASE_VERSION: v0
_RELEASE_CONFIGURATION: Release
_RELEASE_CONFIGURATION_PRESET: Release-windows
_RELEASE_CONFIGURATION_RAW: Release
_BUILD_BRANCH: "${{ github.ref }}"
_CHANGELOG_VERSION: "0"
# GIT: Fix reporting from stderr to stdout
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/ubuntu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ env:
_IS_GITHUB_RELEASE: false
_RELEASE_NAME: Field-Map-Editor
_RELEASE_VERSION: v0
_RELEASE_CONFIGURATION: Release
_RELEASE_CONFIGURATION_PRESET: Release-linux
_RELEASE_CONFIGURATION_RAW: Release
_BUILD_BRANCH: "${{ github.ref }}"
_CHANGELOG_VERSION: "0"
# GIT: Fix reporting from stderr to stdout
Expand Down Expand Up @@ -56,7 +57,8 @@ jobs:
sudo apt-get update
sudo add-apt-repository universe -y
sudo apt-get update
sudo apt-get install -y ninja-build libxmu-dev libxi-dev libgl-dev libxrandr-dev libxinerama-dev libxcursor-dev gcc-14 g++-14
sudo apt-get install -y ninja-build libxmu-dev libxi-dev libgl-dev libxrandr-dev libxinerama-dev libxcursor-dev gcc-14 g++-14 \
mono-complete
# GCC 14
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100
Expand All @@ -78,18 +80,14 @@ jobs:
restore-keys: |
vcpkg-${{ runner.os }}-

- name: Integrate vcpkg
run: ${{ github.workspace }}/vcpkg/vcpkg integrate install

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
run: cmake --preset "${{ env._RELEASE_CONFIGURATION_PRESET }}"

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --parallel
run: cmake --build --preset "${{ env._RELEASE_CONFIGURATION_PRESET }}"

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --output-on-failure

run: cmake --build --preset "${{ env._RELEASE_CONFIGURATION_PRESET }}" --target test
12 changes: 8 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,23 @@

{
"name": "Release-windows",
"configurePreset": "Release-windows"
"configurePreset": "Release-windows",
"configuration": "Release"
},
{
"name": "Debug-windows",
"configurePreset": "Debug-windows"
"configurePreset": "Debug-windows",
"configuration": "Debug"
},
{
"name": "RelWithDebInfo-windows",
"configurePreset": "RelWithDebInfo-windows"
"configurePreset": "RelWithDebInfo-windows",
"configuration": "RelWithDebInfo"
},
{
"name": "MinSizeRel-windows",
"configurePreset": "MinSizeRel-windows"
"configurePreset": "MinSizeRel-windows",
"configuration": "MinSizeRel"
}
]
}
33 changes: 20 additions & 13 deletions src/opengl/main/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
//

#include "Configuration.hpp"
#include "Paths.hpp"
#include "safedir.hpp"
#include <glengine/ScopeGuard.hpp>
#include <iostream>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <stacktrace>


fme::Configuration::Configuration(std::filesystem::path in_path)
: m_path(std::move(in_path))
, m_table(
Expand Down Expand Up @@ -45,19 +48,23 @@ fme::Configuration::Configuration()

if (!initialized)
{
std::error_code error_code{};
path = std::filesystem::current_path(error_code) / "res"
/ "field-map-editor.toml";
if (error_code)
{
spdlog::warn(
"{}:{} - {}: {} path: \"{}\"",
__FILE__,
__LINE__,
error_code.value(),
error_code.message(),
path.string());
}
path = getAppConfigDir() / "config.toml";
auto console_logger = spdlog::get("");
spdlog::info("Config path: \"{}\"", path.string());
console_logger->info("Config path: \"{}\"", path.string());
// std::error_code error_code{};
// path = std::filesystem::current_path(error_code) / "res"
// / "field-map-editor.toml";
// if (error_code)
// {
// spdlog::warn(
// "{}:{} - {}: {} path: \"{}\"",
// __FILE__,
// __LINE__,
// error_code.value(),
// error_code.message(),
// path.string());
// }
initialized = true;
}

Expand Down
49 changes: 49 additions & 0 deletions src/opengl/main/Paths.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "open_viii/paths/Paths.hpp"
#include <filesystem>
#include <spdlog/spdlog.h>

namespace fme
{
inline static const std::filesystem::path app_name = "Field-Map-Editor";


// Example: Config path (inside dataHome or configHome)
inline std::filesystem::path getAppDataDir()
{
return open_viii::Paths::dataHome() / app_name;
}

inline std::filesystem::path getAppConfigDir()
{
return open_viii::Paths::configHome() / app_name;
}

// Logs path (inside stateHome)
inline std::filesystem::path getAppLogsDir()
{
return open_viii::Paths::stateHome() / app_name / "Logs";
}

inline void createDirs()
{
const auto create_log
= [](
const spdlog::format_string_t<std::string> format,
const std::filesystem::path &path)
{
std::error_code ec;
std::filesystem::create_directories(path, ec);

if (ec)
{
spdlog::error("create_directories failed: {}", ec.message());
}

spdlog::info(format, path.string());
};
create_log("Data Dir: \"{}\"", getAppDataDir());
create_log("Config Dir: \"{}\"", getAppConfigDir());
create_log("Logs Dir: \"{}\"", getAppLogsDir());
}

}// namespace fme
13 changes: 10 additions & 3 deletions src/opengl/main/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "main_menu_paths.hpp"
#include "open_file_explorer.hpp"
#include "path_search.hpp"
#include "Paths.hpp"
#include "push_pop_id.hpp"
#include "safedir.hpp"
#include "tool_tip.hpp"
Expand Down Expand Up @@ -4151,9 +4152,15 @@ gui::gui(GLFWwindow *const window)
// 2. Configure ImGui (optional but common)
ImGuiIO &imgui_io = ImGui::GetIO();
std::error_code error_code = {};
static const auto path = (std::filesystem::current_path(error_code) / "res"
/ "field-map-editor_imgui.ini")
.string();


// static const auto path = (std::filesystem::current_path(error_code) / "res"
// / "field-map-editor_imgui.ini")
// .string();
auto console_logger = spdlog::get("");
static const auto path = (getAppConfigDir() / "imgui.ini").string();
spdlog::info("Imgui Confg: \"{}\"", path);
console_logger->info("Imgui Confg: \"{}\"", path);
imgui_io.ConfigFlags
= bitwise_or(imgui_io.ConfigFlags, ImGuiConfigFlags_DockingEnable);
imgui_io.ConfigFlags
Expand Down
65 changes: 64 additions & 1 deletion src/opengl/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <GLFW/glfw3.h>
// clang-format on
#include "gui/gui.hpp"
#include "Paths.hpp"
#include <chrono>
#include <fmt/chrono.h>
#include <glengine/BlendModeSettings.hpp>
#include <spdlog/sinks/basic_file_sink.h>

Expand Down Expand Up @@ -117,11 +120,70 @@ int main(
[[maybe_unused]] int argc,
[[maybe_unused]] char **argv)
{
fme::createDirs();// create paths first
const auto local_now = []() -> std::chrono::system_clock::time_point
{
try
{
// get current local time
const std::chrono::zoned_time cur_time{
std::chrono::current_zone(),
std::chrono::system_clock::now()
};

// get local_time rounded to seconds
auto local_sec
= std::chrono::time_point_cast<std::chrono::seconds>(
cur_time.get_local_time());

// reinterpret local_time as system_clock by measuring duration
// since epoch
auto local_duration = local_sec.time_since_epoch();

// NOTE: this just treats the underlying duration as system_clock
// time
return std::chrono::time_point_cast<std::chrono::seconds>(
std::chrono::system_clock::time_point{ local_duration });
}
catch (const std::runtime_error &ex)
{
spdlog::error("Failed to get time zone: {}", ex.what());
return std::chrono::time_point_cast<std::chrono::seconds>(
std::chrono::system_clock::now());
}
};
try
{

const auto now = local_now();

// YYYY_MM_DD_HH_MM_SS.log
const auto filename = [&]()
{
// format as usual
std::string tmp = fmt::format("{:%Y%m%d_%H%M%S}", now);

// find '.' and truncate if present
auto pos = tmp.find('.');
if (pos != std::string::npos)
{
tmp.resize(pos);
}

// append extension
tmp += ".log";
return tmp;
}();
// Create file logger and set as default
const auto file_logger_path = fme::getAppLogsDir() / filename;
spdlog::info("Created Log File: \"{}\"", file_logger_path);
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
auto file_logger = spdlog::basic_logger_mt(
"file_logger", "res/field_map_editor.log", true);
"file_logger", file_logger_path.wstring(), true);
#else
auto file_logger = spdlog::basic_logger_mt(
"file_logger", file_logger_path.string(), true);
#endif

// Remove logger name from output pattern
file_logger->set_pattern(R"([%Y-%m-%d %H:%M:%S.%e] [%^%l%$] %v)");
Expand All @@ -140,6 +202,7 @@ int main(

// Now log anywhere
spdlog::info("App started");
fme::createDirs();// rerun to log paths in log file.
}
catch (const spdlog::spdlog_ex &ex)
{
Expand Down