#pragma once

#include <span>
#include <string_view>

#include <glm/glm.hpp>
#include <imgui.h>

namespace game::util::imgui
{
  struct DialogueEffectSpan
  {
    enum Type
    {
      COLOR,
      TEXT_SCALE,
      OSCILLATE,
      SHAKE
    };

    Type type{COLOR};
    int start{};
    int end{};
    glm::vec3 color{1.0f};
    float textScale{1.0f};
    float frequency{1.0f};
    float amplitude{};
  };

  int utf8_char_count(std::string_view text);
  int utf8_byte_to_char_index(std::string_view text, int byteIndex);
  const char* utf8_advance_chars(const char* text, const char* end, int count);
  ImVec2 dialogue_text_draw(std::string_view text, int count, std::span<const DialogueEffectSpan> effects = {},
                            glm::vec3 defaultColor = glm::vec3{1.0f}, float time = 0.0f);
}
