"""Constant variables for easy access throughout the addon."""

import os
import platform
from collections import OrderedDict
from pathlib import Path

PACKAGE_NAME = "rizomuvbridge_ultimate"


# These are all in the correct format for bpy.props.EnumProperty
AUTOSEAMS_ENUMS = OrderedDict(
    {
        "SHARP_EDGES": (
            "SHARP_EDGES",
            "Autoseams - Sharp Edges",
            "Unwrap using Sharp Edges Autoseams",
        ),
        "MOSAIC": ("MOSAIC", "Autoseams - Mosaic", "Unwrap using Mosaic Autoseams"),
        "PELT": ("PELT", "Autoseams - Pelt", "Unwrap using Pelt Autoseams"),
        "BOX": ("BOX", "Autoseams - Box", "Unwrap using Box Autoseams"),
    }
)


CUSTOM_ACTION_ENUMS = OrderedDict(
    {
        "RESET_UVS": ("RESET_UVS", "Reset UVs", "Reset UVs (weld seams)"),
        "OFFSET_STACKS": (
            "OFFSET_STACKS",
            "Offset Overlapping",
            (
                "Offset overlapping UVs for baking.\n"
                "- Group overlapping islands\n"
                "- Select group\n"
                "- Run action"
            ),
        ),
        "CLOSE": ("CLOSE", "Close Rizom", "Close RizomUV"),
        "APPLY_RIZOM_SETTINGS": (
            "APPLY_RIZOM_SETTINGS",
            "Apply Rizom Settings",
            "Sync RizomUV settings with those set in the addon UI",
        ),
    }
)

EXPORT_ENUMS = OrderedDict(
    {
        "EXPORT": ("EXPORT", "Export UVs", "Export existing UV data with no changes"),
        "USE_SEAMS": (
            "USE_SEAMS",
            "Use Seams",
            "Use Blender seams to unwrap before sending to RizomUV",
        ),
    }
)

TEXTURE_FORMATS = (".png", ".jpg", ".tga", ".tiff", ".bmp")


PANEL_IDS = (
    "PANEL_PT_RizomUVBridge",
    "PANEL_PT_RizomUVBridgeImportSettings",
    "PANEL_PT_RizomUVBridgeExportSettings",
    "PANEL_PT_RizomUVBridgeRizomSettings",
)
FBX = "mesh_files/rizom_transfer.fbx"
OBJ = "mesh_files/rizom_transfer.obj"
USD = "mesh_files/rizom_transfer.usdc"
RIZOM_PORTS = "rizom_ports.txt"
RIZOM_OUTPUT = "rizom_output.json"
BLENDER_OUTPUT = "blender_output.json"
RIZOM_PID = "rizom_pid.txt"

RESERVED_UVMAP_SEQUENCES = {"___dot___": "_", ".": "_"}

RIZOMUV_LINK_PACKAGE = str(Path(__file__).parent / "resources" / "RizomUVLink")

if platform.system() == "Windows":
    # DATA_PATH = Path(os.getenv("APPDATA")) / "RizomUV Bridge"
    # DATA_PATH = Path(bpy.utils.user_resource("SCRIPTS")) / "RizomUV Bridge"
    DATA_PATH = Path(os.getenv("USERPROFILE")) / "Documents" / "RizomUV Bridge"
else:
    DATA_PATH = Path(__file__).parent / "data"
