add #include format
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "file_.hpp"
|
#include "file_.hpp"
|
||||||
@@ -199,6 +200,28 @@ namespace anm2ed::anm2
|
|||||||
Anm2 Anm2::normalized_for_serialize() const
|
Anm2 Anm2::normalized_for_serialize() const
|
||||||
{
|
{
|
||||||
auto normalized = *this;
|
auto normalized = *this;
|
||||||
|
auto sanitize_layer_order = [](Animation& animation)
|
||||||
|
{
|
||||||
|
std::vector<int> sanitized{};
|
||||||
|
sanitized.reserve(animation.layerAnimations.size());
|
||||||
|
std::set<int> seen{};
|
||||||
|
|
||||||
|
for (auto id : animation.layerOrder)
|
||||||
|
{
|
||||||
|
if (!animation.layerAnimations.contains(id)) continue;
|
||||||
|
if (!seen.insert(id).second) continue;
|
||||||
|
sanitized.push_back(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> missing{};
|
||||||
|
missing.reserve(animation.layerAnimations.size());
|
||||||
|
for (auto& id : animation.layerAnimations | std::views::keys)
|
||||||
|
if (!seen.contains(id)) missing.push_back(id);
|
||||||
|
|
||||||
|
std::sort(missing.begin(), missing.end());
|
||||||
|
sanitized.insert(sanitized.end(), missing.begin(), missing.end());
|
||||||
|
animation.layerOrder = std::move(sanitized);
|
||||||
|
};
|
||||||
std::unordered_map<int, int> layerRemap{};
|
std::unordered_map<int, int> layerRemap{};
|
||||||
|
|
||||||
int normalizedID = 0;
|
int normalizedID = 0;
|
||||||
@@ -214,6 +237,7 @@ namespace anm2ed::anm2
|
|||||||
|
|
||||||
for (auto& animation : normalized.animations.items)
|
for (auto& animation : normalized.animations.items)
|
||||||
{
|
{
|
||||||
|
sanitize_layer_order(animation);
|
||||||
std::unordered_map<int, Item> layerAnimations{};
|
std::unordered_map<int, Item> layerAnimations{};
|
||||||
std::vector<int> layerOrder{};
|
std::vector<int> layerOrder{};
|
||||||
|
|
||||||
@@ -231,6 +255,7 @@ namespace anm2ed::anm2
|
|||||||
|
|
||||||
animation.layerAnimations = std::move(layerAnimations);
|
animation.layerAnimations = std::move(layerAnimations);
|
||||||
animation.layerOrder = std::move(layerOrder);
|
animation.layerOrder = std::move(layerOrder);
|
||||||
|
sanitize_layer_order(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return normalized;
|
return normalized;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "anm2.hpp"
|
#include "anm2.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "map_.hpp"
|
#include "map_.hpp"
|
||||||
#include "path_.hpp"
|
#include "path_.hpp"
|
||||||
#include "working_directory.hpp"
|
#include "working_directory.hpp"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "toast.hpp"
|
#include "toast.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include <imgui/imgui.h>
|
#include <imgui/imgui.h>
|
||||||
|
|
||||||
|
|||||||
@@ -780,9 +780,11 @@ namespace anm2ed::imgui
|
|||||||
|
|
||||||
for (auto& id : animation->layerOrder)
|
for (auto& id : animation->layerOrder)
|
||||||
{
|
{
|
||||||
|
if (!animation->layerAnimations.contains(id)) continue;
|
||||||
auto& layerAnimation = animation->layerAnimations[id];
|
auto& layerAnimation = animation->layerAnimations[id];
|
||||||
if (!layerAnimation.isVisible) continue;
|
if (!layerAnimation.isVisible) continue;
|
||||||
|
|
||||||
|
if (!anm2.content.layers.contains(id)) continue;
|
||||||
auto& layer = anm2.content.layers.at(id);
|
auto& layer = anm2.content.layers.at(id);
|
||||||
|
|
||||||
auto spritesheet = anm2.spritesheet_get(layer.spritesheetID);
|
auto spritesheet = anm2.spritesheet_get(layer.spritesheetID);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "events.hpp"
|
#include "events.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "layers.hpp"
|
#include "layers.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "nulls.hpp"
|
#include "nulls.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "sounds.hpp"
|
#include "sounds.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ namespace anm2ed::imgui
|
|||||||
mergePopup.close();
|
mergePopup.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
auto optionsSize = child_size_get(5);
|
auto optionsSize = child_size_get(6);
|
||||||
if (ImGui::BeginChild("##Merge Spritesheets Options", optionsSize, ImGuiChildFlags_Borders))
|
if (ImGui::BeginChild("##Merge Spritesheets Options", optionsSize, ImGuiChildFlags_Borders))
|
||||||
{
|
{
|
||||||
ImGui::SeparatorText(localize.get(LABEL_REGION_PROPERTIES_ORIGIN));
|
ImGui::SeparatorText(localize.get(LABEL_REGION_PROPERTIES_ORIGIN));
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include <imgui_internal.h>
|
#include <imgui_internal.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "welcome.hpp"
|
#include "welcome.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
#include "path_.hpp"
|
#include "path_.hpp"
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#include "configure.hpp"
|
#include "configure.hpp"
|
||||||
|
|
||||||
#include "imgui_.hpp"
|
#include "imgui_.hpp"
|
||||||
|
#include "log.hpp"
|
||||||
|
#include "path_.hpp"
|
||||||
|
#include "sdl.hpp"
|
||||||
|
|
||||||
using namespace anm2ed::types;
|
using namespace anm2ed::types;
|
||||||
|
|
||||||
@@ -180,6 +183,7 @@ namespace anm2ed::imgui::wizard
|
|||||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||||
if (ImGui::Button(localize.get(BASIC_SAVE), widgetSize))
|
if (ImGui::Button(localize.get(BASIC_SAVE), widgetSize))
|
||||||
{
|
{
|
||||||
|
auto settingsPath = util::sdl::preferences_directory_get() / "settings.ini";
|
||||||
settings = temporary;
|
settings = temporary;
|
||||||
|
|
||||||
ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay;
|
ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay;
|
||||||
@@ -193,6 +197,8 @@ namespace anm2ed::imgui::wizard
|
|||||||
for (auto& document : manager.documents)
|
for (auto& document : manager.documents)
|
||||||
document.snapshots.apply_limit();
|
document.snapshots.apply_limit();
|
||||||
|
|
||||||
|
settings.save(settingsPath, ImGui::SaveIniSettingsToMemory(nullptr));
|
||||||
|
|
||||||
isSet = true;
|
isSet = true;
|
||||||
}
|
}
|
||||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SETTINGS_SAVE));
|
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SETTINGS_SAVE));
|
||||||
|
|||||||
+1
-1
@@ -3,6 +3,7 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
#include <format>
|
||||||
|
|
||||||
#include <imgui/backends/imgui_impl_opengl3.h>
|
#include <imgui/backends/imgui_impl_opengl3.h>
|
||||||
#include <imgui/backends/imgui_impl_sdl3.h>
|
#include <imgui/backends/imgui_impl_sdl3.h>
|
||||||
@@ -22,7 +23,6 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "util/path_.hpp"
|
#include "util/path_.hpp"
|
||||||
#include <DbgHelp.h>
|
#include <DbgHelp.h>
|
||||||
#include <format>
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <format>
|
||||||
#include <print>
|
#include <print>
|
||||||
|
|
||||||
#include "file_.hpp"
|
#include "file_.hpp"
|
||||||
|
|||||||
@@ -338,7 +338,15 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1496,860 S
|
|||||||
|
|
||||||
void Settings::save(const std::filesystem::path& path, const std::string& imguiData)
|
void Settings::save(const std::filesystem::path& path, const std::string& imguiData)
|
||||||
{
|
{
|
||||||
|
auto pathUtf8 = path::to_utf8(path);
|
||||||
|
logger.info(std::format("Saving settings to: {}", pathUtf8));
|
||||||
std::ofstream file(path, std::ios::out | std::ios::binary);
|
std::ofstream file(path, std::ios::out | std::ios::binary);
|
||||||
|
if (!file.is_open())
|
||||||
|
{
|
||||||
|
logger.error(std::format("Failed to save settings file: {}", pathUtf8));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
file << "[Settings]\n";
|
file << "[Settings]\n";
|
||||||
|
|
||||||
auto value_save = [&](const std::string& key, const auto& value)
|
auto value_save = [&](const std::string& key, const auto& value)
|
||||||
@@ -395,6 +403,12 @@ DockSpace ID=0x123F8F08 Window=0x6D581B32 Pos=8,62 Size=1496,860 S
|
|||||||
<< imguiData;
|
<< imguiData;
|
||||||
|
|
||||||
file.flush();
|
file.flush();
|
||||||
|
if (file.fail())
|
||||||
|
{
|
||||||
|
logger.error(std::format("Failed while writing settings file: {}", pathUtf8));
|
||||||
|
return;
|
||||||
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
logger.info(std::format("Saved settings to: {}", pathUtf8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user