mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-20 21:33:28 -04:00
Migrate to Borealis (#2266)
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include "dusk/logging.h"
|
||||
#include "dusk/settings.h"
|
||||
#include "f_op/f_op_overlap_mng.h"
|
||||
#include "../file_select.hpp"
|
||||
#include <borealis/file_select.hpp>
|
||||
#include "aurora/lib/window.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
@@ -40,15 +40,6 @@ static constexpr auto STATES_FILENAME = "states.json";
|
||||
|
||||
static bool ValidateEncodedState(const std::string&);
|
||||
|
||||
void ImGuiStateShare::onMergeFileSelected(void* userdata, const char* path, const char* /*error*/) {
|
||||
auto* self = static_cast<ImGuiStateShare*>(userdata);
|
||||
if (path != nullptr) {
|
||||
self->m_pendingMergePath = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static std::filesystem::path GetStatesFilePath() {
|
||||
return ConfigPath / STATES_FILENAME;
|
||||
}
|
||||
@@ -381,8 +372,18 @@ void ImGuiStateShare::draw(bool& open) {
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Load Pack")) {
|
||||
static constexpr SDL_DialogFileFilter filter = {"State pack", "json"};
|
||||
ShowFileSelect(&onMergeFileSelected, this, aurora::window::get_sdl_window(), &filter, 1, nullptr, false);
|
||||
borealis::file_select::open_file(
|
||||
{
|
||||
.parentWindow = aurora::window::get_sdl_window(),
|
||||
.filters = {{"State pack", "json"}},
|
||||
},
|
||||
[this](borealis::file_select::Result result) {
|
||||
if (result.status == borealis::file_select::Status::Selected &&
|
||||
!result.locations.empty())
|
||||
{
|
||||
m_pendingMergePath = std::move(result.locations.front());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!m_states.empty()) {
|
||||
|
||||
@@ -24,8 +24,6 @@ private:
|
||||
void loadStatesFile();
|
||||
void saveStatesFile();
|
||||
void mergeFromFile(const std::string& path);
|
||||
static void onMergeFileSelected(void* userdata, const char* path, const char* error);
|
||||
|
||||
std::vector<SavedStateEntry> m_states;
|
||||
std::string m_statusMsg;
|
||||
std::optional<dSv_info_c> m_pendingInfo;
|
||||
|
||||
@@ -11,24 +11,8 @@ namespace dusk {
|
||||
static bool StubLogPaused;
|
||||
static std::mutex StubLogMutex;
|
||||
|
||||
const char* LogLevelName(const AuroraLogLevel level) {
|
||||
switch (level) {
|
||||
case LOG_DEBUG:
|
||||
return "DEBUG";
|
||||
case LOG_INFO:
|
||||
return "INFO";
|
||||
case LOG_WARNING:
|
||||
return "WARNING";
|
||||
case LOG_ERROR:
|
||||
return "ERROR";
|
||||
case LOG_FATAL:
|
||||
return "FATAL";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
void SendToStubLog(AuroraLogLevel level, const char* module, const char* message) {
|
||||
void SendToStubLog(
|
||||
borealis::LogLevel level, std::string_view module, std::string_view message) {
|
||||
if (StubLogPaused) {
|
||||
return;
|
||||
}
|
||||
@@ -41,8 +25,10 @@ namespace dusk {
|
||||
}
|
||||
|
||||
LineOffsets.push_back(StubLogBuffer.size());
|
||||
const auto levelName = LogLevelName(level);
|
||||
StubLogBuffer.appendf("[%s | %s] %s\n", levelName, module, message);
|
||||
const auto levelName = borealis::to_string(level);
|
||||
StubLogBuffer.appendf("[%.*s | %.*s] %.*s\n", static_cast<int>(levelName.size()),
|
||||
levelName.data(), static_cast<int>(module.size()), module.data(),
|
||||
static_cast<int>(message.size()), message.data());
|
||||
}
|
||||
|
||||
void ImGuiMenuTools::ShowStubLog() {
|
||||
|
||||
Reference in New Issue
Block a user