using System;
using UnityEngine;
namespace Streamingle.Background.Editor
{
///
/// Notion 동기화 설정을 저장하는 ScriptableObject
///
[CreateAssetMenu(fileName = "NotionSyncSettings", menuName = "Streamingle/Notion Sync Settings")]
public class NotionSyncSettings : ScriptableObject
{
[Header("Notion API 설정")]
[Tooltip("Notion Integration Token (ntn_xxx... 또는 secret_xxx...)")]
public string notionApiToken = "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";
[Tooltip("Notion Database ID (32자리 hex) - 배경 일람")]
public string notionDatabaseId = "25ea7d46b958805f88fcf127979934bf";
[Header("Git 설정")]
[Tooltip("Git 서버 URL (예: https://kindnick-git.duckdns.org)")]
public string gitServerUrl = "https://kindnick-git.duckdns.org";
[Tooltip("Git 리포지토리 경로 (예: kindnick/Streamingle_URP)")]
public string gitRepoPath = "kindnick/Streamingle_URP";
[Tooltip("Git 브랜치 (예: main)")]
public string gitBranch = "main";
[Header("동기화 설정")]
[Tooltip("썸네일 캡처 시 자동 동기화")]
public bool autoSyncOnCapture = false;
[Tooltip("배경 씬 로드 시 사용 이력 기록")]
public bool trackUsageHistory = true;
[Header("썸네일 설정")]
[Tooltip("썸네일 너비")]
public int thumbnailWidth = 1920;
[Tooltip("썸네일 높이 (16:9 비율)")]
public int thumbnailHeight = 1080;
///
/// Git Raw 파일 URL 생성 (Gitea/Gogs 형식)
///
public string GetGitRawUrl(string assetPath)
{
// Assets/ResourcesData/Background/... 형식의 경로를 Git Raw URL로 변환
// Gitea Raw URL 형식: {serverUrl}/{repoPath}/raw/branch/{branch}/{filePath}
string relativePath = assetPath.Replace("\\", "/");
// 경로의 각 세그먼트를 URL 인코딩 (슬래시는 유지)
string[] segments = relativePath.Split('/');
for (int i = 0; i < segments.Length; i++)
{
segments[i] = Uri.EscapeDataString(segments[i]);
}
string encodedPath = string.Join("/", segments);
return $"{gitServerUrl}/{gitRepoPath}/raw/branch/{gitBranch}/{encodedPath}";
}
///
/// 설정이 유효한지 확인
///
public bool IsValid()
{
return !string.IsNullOrEmpty(notionApiToken) &&
!string.IsNullOrEmpty(notionDatabaseId) &&
!string.IsNullOrEmpty(gitServerUrl) &&
!string.IsNullOrEmpty(gitRepoPath);
}
///
/// Notion API Token이 설정되었는지 확인
///
public bool HasNotionToken => !string.IsNullOrEmpty(notionApiToken) &&
(notionApiToken.StartsWith("secret_") || notionApiToken.StartsWith("ntn_"));
///
/// Database ID가 유효한 형식인지 확인
///
public bool HasValidDatabaseId => !string.IsNullOrEmpty(notionDatabaseId) && notionDatabaseId.Length >= 32;
}
}