#pragma once

#include "serializer.h"

namespace pp::panopainter {

struct LegacyStartupPreferenceSnapshot {
    int run_counter = 0;
    bool auto_timelapse = true;
    bool vr_controllers_enabled = true;
};

struct LegacyCanvasPreferenceSnapshot {
    float viewport_density = 1.0F;
    int cursor_mode = 0;
};

struct LegacyUiPreferenceSnapshot {
    bool has_rtl = false;
    int rtl = 0;
    std::shared_ptr<Serializer::Descriptor> state;
};

struct LegacyWindowPreferenceSnapshot {
    bool has_ui_scale = false;
    float ui_scale = 1.0F;
    int show_command = 0;
    bool has_window_rect = false;
    glm::ivec4 window_rect {};
};

bool load_legacy_preferences();
LegacyStartupPreferenceSnapshot read_legacy_startup_preferences(bool default_vr_controllers_enabled);
LegacyCanvasPreferenceSnapshot read_legacy_canvas_preferences();
LegacyUiPreferenceSnapshot read_legacy_ui_preferences();
LegacyWindowPreferenceSnapshot read_legacy_window_preferences(int default_show_command);
void save_legacy_ui_scale_preference(float scale);
void set_legacy_ui_state_preferences(const Serializer::Descriptor& state, bool right_to_left);
void set_legacy_window_preferences(int show_command, const glm::ivec4& window_rect);
int legacy_whatsnew_id_or(int default_value);
void clear_legacy_whatsnew_id();
void set_legacy_whatsnew_id(int page_id);
void set_legacy_startup_run_counter(int value);
void save_legacy_vr_controllers_enabled(bool enabled);
void save_legacy_auto_timelapse_enabled(bool enabled);
void save_legacy_canvas_viewport_density(float density);
void save_legacy_canvas_cursor_mode(int mode);
bool save_legacy_preferences();

} // namespace pp::panopainter
