mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-09 04:29:04 +03:00
fix: handle missing files
This commit is contained in:
@@ -172,6 +172,7 @@ void color_scheme_editor::render_controls()
|
||||
apply_palette_to_imgui();
|
||||
apply_palette_to_editor();
|
||||
notify_palette_changed();
|
||||
m_controller.select_palette(new_palette_name_buf);
|
||||
new_palette_name_buf[0] = 0;
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
@@ -328,6 +329,12 @@ void color_scheme_editor::render_preview_content()
|
||||
{
|
||||
const auto ¤t = m_controller.current_palette();
|
||||
|
||||
if (current.colors().empty())
|
||||
{
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.3f, 0.3f, 1.0f), "Current palette is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
auto get_color = [&](const std::string &key) -> ImVec4 {
|
||||
auto it = current.colors().find(key);
|
||||
if (it != current.colors().end())
|
||||
@@ -389,6 +396,8 @@ void color_scheme_editor::render_preview_content()
|
||||
void color_scheme_editor::apply_palette_to_editor()
|
||||
{
|
||||
const auto ¤t = m_controller.current_palette();
|
||||
if (current.colors().empty())
|
||||
return;
|
||||
|
||||
auto get_color_u32 = [&](const std::string &key, const std::string &fallback = "") -> uint32_t {
|
||||
auto it = current.colors().find(key);
|
||||
@@ -446,6 +455,9 @@ void color_scheme_editor::apply_palette_to_editor()
|
||||
void color_scheme_editor::apply_palette_to_imgui() const
|
||||
{
|
||||
const auto ¤t = m_controller.current_palette();
|
||||
|
||||
if (current.colors().empty())
|
||||
return;
|
||||
|
||||
auto getColor = [&](const std::string &key, const std::string &fallback = "") -> ImVec4 {
|
||||
auto it = current.colors().find(key);
|
||||
|
||||
@@ -28,14 +28,9 @@ void palette_controller::select_palette(const std::string& name)
|
||||
|
||||
void palette_controller::create_palette(const std::string& name)
|
||||
{
|
||||
clrsync::core::palette new_palette = m_current_palette;
|
||||
clrsync::core::palette new_palette = m_palette_manager.load_palette_from_file(std::string(CLRSYNC_DATADIR) + "/palettes/cursed.toml");
|
||||
new_palette.set_name(name);
|
||||
|
||||
auto colors = m_current_palette.colors();
|
||||
for (auto& pair : colors) {
|
||||
new_palette.set_color(pair.first, pair.second);
|
||||
}
|
||||
|
||||
|
||||
auto dir = clrsync::core::config::instance().palettes_path();
|
||||
m_palette_manager.save_palette_to_file(new_palette, dir);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ template_editor::template_editor() : m_template_name("new_template")
|
||||
void template_editor::apply_current_palette(const clrsync::core::palette &pal)
|
||||
{
|
||||
auto colors = pal.colors();
|
||||
if (colors.empty())
|
||||
return;
|
||||
auto get_color_u32 = [&](const std::string &key, const std::string &fallback = "") -> uint32_t {
|
||||
auto it = colors.find(key);
|
||||
if (it == colors.end() && !fallback.empty())
|
||||
|
||||
Reference in New Issue
Block a user