add #include format
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "file_.hpp"
|
||||
@@ -199,6 +200,28 @@ namespace anm2ed::anm2
|
||||
Anm2 Anm2::normalized_for_serialize() const
|
||||
{
|
||||
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{};
|
||||
|
||||
int normalizedID = 0;
|
||||
@@ -214,6 +237,7 @@ namespace anm2ed::anm2
|
||||
|
||||
for (auto& animation : normalized.animations.items)
|
||||
{
|
||||
sanitize_layer_order(animation);
|
||||
std::unordered_map<int, Item> layerAnimations{};
|
||||
std::vector<int> layerOrder{};
|
||||
|
||||
@@ -231,6 +255,7 @@ namespace anm2ed::anm2
|
||||
|
||||
animation.layerAnimations = std::move(layerAnimations);
|
||||
animation.layerOrder = std::move(layerOrder);
|
||||
sanitize_layer_order(animation);
|
||||
}
|
||||
|
||||
return normalized;
|
||||
|
||||
@@ -136,4 +136,4 @@ namespace anm2ed::anm2
|
||||
return finalIndex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "anm2.hpp"
|
||||
|
||||
#include <format>
|
||||
|
||||
#include "map_.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "working_directory.hpp"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "toast.hpp"
|
||||
|
||||
#include <format>
|
||||
|
||||
#include "log.hpp"
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
|
||||
@@ -780,9 +780,11 @@ namespace anm2ed::imgui
|
||||
|
||||
for (auto& id : animation->layerOrder)
|
||||
{
|
||||
if (!animation->layerAnimations.contains(id)) continue;
|
||||
auto& layerAnimation = animation->layerAnimations[id];
|
||||
if (!layerAnimation.isVisible) continue;
|
||||
|
||||
if (!anm2.content.layers.contains(id)) continue;
|
||||
auto& layer = anm2.content.layers.at(id);
|
||||
|
||||
auto spritesheet = anm2.spritesheet_get(layer.spritesheetID);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "events.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
#include "log.hpp"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "layers.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
#include "log.hpp"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "nulls.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
#include "log.hpp"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "sounds.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -595,7 +595,7 @@ namespace anm2ed::imgui
|
||||
mergePopup.close();
|
||||
};
|
||||
|
||||
auto optionsSize = child_size_get(5);
|
||||
auto optionsSize = child_size_get(6);
|
||||
if (ImGui::BeginChild("##Merge Spritesheets Options", optionsSize, ImGuiChildFlags_Borders))
|
||||
{
|
||||
ImGui::SeparatorText(localize.get(LABEL_REGION_PROPERTIES_ORIGIN));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <format>
|
||||
|
||||
#include <imgui_internal.h>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "welcome.hpp"
|
||||
|
||||
#include <format>
|
||||
#include <ranges>
|
||||
|
||||
#include "path_.hpp"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#include "configure.hpp"
|
||||
|
||||
#include "imgui_.hpp"
|
||||
#include "log.hpp"
|
||||
#include "path_.hpp"
|
||||
#include "sdl.hpp"
|
||||
|
||||
using namespace anm2ed::types;
|
||||
|
||||
@@ -180,6 +183,7 @@ namespace anm2ed::imgui::wizard
|
||||
shortcut(manager.chords[SHORTCUT_CONFIRM]);
|
||||
if (ImGui::Button(localize.get(BASIC_SAVE), widgetSize))
|
||||
{
|
||||
auto settingsPath = util::sdl::preferences_directory_get() / "settings.ini";
|
||||
settings = temporary;
|
||||
|
||||
ImGui::GetIO().KeyRepeatDelay = settings.keyboardRepeatDelay;
|
||||
@@ -193,6 +197,8 @@ namespace anm2ed::imgui::wizard
|
||||
for (auto& document : manager.documents)
|
||||
document.snapshots.apply_limit();
|
||||
|
||||
settings.save(settingsPath, ImGui::SaveIniSettingsToMemory(nullptr));
|
||||
|
||||
isSet = true;
|
||||
}
|
||||
ImGui::SetItemTooltip("%s", localize.get(TOOLTIP_SETTINGS_SAVE));
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <cerrno>
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
|
||||
#include <imgui/backends/imgui_impl_opengl3.h>
|
||||
#include <imgui/backends/imgui_impl_sdl3.h>
|
||||
@@ -22,7 +23,6 @@
|
||||
#ifdef _WIN32
|
||||
#include "util/path_.hpp"
|
||||
#include <DbgHelp.h>
|
||||
#include <format>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "log.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <format>
|
||||
#include <print>
|
||||
|
||||
#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)
|
||||
{
|
||||
auto pathUtf8 = path::to_utf8(path);
|
||||
logger.info(std::format("Saving settings to: {}", pathUtf8));
|
||||
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";
|
||||
|
||||
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;
|
||||
|
||||
file.flush();
|
||||
if (file.fail())
|
||||
{
|
||||
logger.error(std::format("Failed while writing settings file: {}", pathUtf8));
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
logger.info(std::format("Saved settings to: {}", pathUtf8));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user