From c0eb156a9b5e1543101c0d822a139f14ca3589c5 Mon Sep 17 00:00:00 2001 From: Ezequiel Leites Date: Wed, 21 Oct 2026 21:04:05 +0200 Subject: [PATCH] feat: option to export detected cards to files New "Export detected card info to files" checkbox in Feature flags (off by default). When it's on, the plugin passes DRAW2_CARD_INFO_DIR (a state folder next to decklists), the language and the full-db option to each backend, and the backend writes the current cards there. Useful for an OBS Text source with the card name, an overlay or a bot. Needs the matching change in the draw2 backend. README and translations updated. --- README.md | 22 ++++++++++++++++++++++ data/locale/en-US.ini | 2 ++ data/locale/fr-FR.ini | 2 ++ data/locale/ja-JP.ini | 2 ++ readmes/README_es.md | 23 +++++++++++++++++++++++ readmes/README_fr.md | 23 +++++++++++++++++++++++ readmes/README_jp.md | 13 +++++++++++++ readmes/README_pt-br.md | 22 ++++++++++++++++++++++ src/DrawDock.cpp | 24 ++++++++++++++++++++++++ src/SettingsDialog.cpp | 7 +++++++ src/SettingsDialog.hpp | 2 ++ src/bridge.h | 1 + src/plugin-main.cpp | 12 ++++++++++++ src/plugin-path.h | 4 ++++ 14 files changed, 159 insertions(+) diff --git a/README.md b/README.md index 8699db7..9cb87f9 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,8 @@ When the plugin is installed and the model weights are downloaded, you can launc capture details (input source, dimensions, crop). Handy when detection isn't behaving. - **Enable remote decklist** — lets each player load its deck from an HTTP(S) URL or a YDKE code instead of a local `.ydk` file; see the note below the `Draw Display` source. + - **Export detected card info to files** — write the detected cards (JSON / JSONL / plain text) to a per-user + folder, for OBS Text sources, bots or overlays; see the note below the `Draw Display` source. 3. The plugin provide a new source called `Draw Display`. You can add it to your scene like any other source. This source will display the detected cards on the screen. You can choose what source/scene to detect cards from. With two-player mode enabled, use the **Detector / Player** property on the source to pick which detector it reads from (**Player 1** or **Player 2**); add one `Draw Display` per player to show both at once. @@ -255,6 +257,26 @@ When the plugin is installed and the model weights are downloaded, you can launc > > ⚠️ URLs and the header value are stored in plain text in QSettings, like all other plugin settings — > avoid placing long-lived secrets there. + + > 💡 The plugin can also **export detected card info to files** so you can show it anywhere — an OBS Text source + > the streamer reads on stream, bots, or HTML/browser overlays. It is **off by default** — enable *Export + > detected card info to files* in the Draw 2 settings (*Feature flags*) and restart DRAW. While running, each + > detector writes to `plugin_config/draw2-plugin/state/` (per player `N`): + > - `current_pN.json` — cards currently on screen: + > `{ "updated_at", "channel", "cards": [ { "id", "name", "type", "attribute", "race", "atk", "def", "desc" } ] }` + > (rich fields come from YGOPRODeck; missing fields are omitted). + > - `events_pN.jsonl` — append-only log, one JSON per line: + > `{ "ts", "event": "appeared" | "disappeared", "card": { … } }`. + > - `current_card_pN.txt` — plain text, names of the cards on screen (newline-separated). Point an OBS **Text** + > source at this file (*Read from file*) to show the current card live. + > + > Metadata language defaults to English; set the `card_info_lang` key in the Draw 2 settings store to one of + > `en` / `fr` / `de` / `it` / `pt` (YGOPRODeck does not provide Spanish). The backend half lives in the `draw2` + > backend; the plugin only points it at the output folder. + > + > By default the backend downloads the full card database once (in the background) so metadata is resolved + > **offline**, with no per-card requests. Untick **Download full card database for offline use** to skip the + > download and resolve lazily, one card at a time, instead. 4. Click the `Start DRAW` button to start the detection process. The plugin will start detecting cards in real time and display them on the screen using the `Draw Display` source. The plugin start detecting from the moment you see the diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 197282f..19d6272 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -31,6 +31,8 @@ browse="Browse" ok="&OK" cancel="&Cancel" feature_remote_deck="Enable remote decklist (per player: deck files, a URL or a YDKE code)" +feature_card_info="Export detected card info to files (restart DRAW to apply)" +feature_card_info_db="Download full card database for offline use (restart DRAW to apply)" remote_deck_section="Remote decklist (auth header is sent with URL requests):" remote_header_name_ph="Header name (e.g. Authorization) — optional" remote_header_value_ph="Header value (e.g. Bearer …) — optional" diff --git a/data/locale/fr-FR.ini b/data/locale/fr-FR.ini index 571d9d4..f6cdf25 100644 --- a/data/locale/fr-FR.ini +++ b/data/locale/fr-FR.ini @@ -29,6 +29,8 @@ player_2="Joueur 2" channel="Détecteur / Joueur" feature_channel="Activer deux joueurs (un détecteur par joueur)" feature_remote_deck="Activer la decklist distante (par joueur : fichiers, une URL ou un code YDKE)" +feature_card_info="Exporter les infos des cartes détectées vers des fichiers (redémarrer DRAW pour appliquer)" +feature_card_info_db="Télécharger la base de cartes complète pour une utilisation hors ligne (redémarrer DRAW pour appliquer)" remote_deck_section="Decklist distante (l'en-tête d'authentification est envoyé avec les requêtes URL) :" remote_header_name_ph="Nom d'en-tête (ex. Authorization) — facultatif" remote_header_value_ph="Valeur d'en-tête (ex. Bearer …) — facultatif" diff --git a/data/locale/ja-JP.ini b/data/locale/ja-JP.ini index 6105398..a88abb2 100644 --- a/data/locale/ja-JP.ini +++ b/data/locale/ja-JP.ini @@ -29,6 +29,8 @@ player_2="プレイヤー 2" channel="ディテクター / プレイヤー" feature_channel="2人プレイを有効にする(プレイヤーごとにディテクターを割り当て)" feature_remote_deck="リモートデックリストを有効にする(プレイヤーごと:デッキファイル、URL、またはYDKEコード)" +feature_card_info="検出したカード情報をファイルに書き出す(DRAW を再起動して適用)" +feature_card_info_db="オフライン用にカードデータベース全体をダウンロード(DRAW を再起動して適用)" remote_deck_section="リモートデックリスト(認証ヘッダーはURLリクエストで送信されます):" remote_header_name_ph="ヘッダー名(例:Authorization)— 任意" remote_header_value_ph="ヘッダー値(例:Bearer …)— 任意" diff --git a/readmes/README_es.md b/readmes/README_es.md index 092e422..0e9d164 100644 --- a/readmes/README_es.md +++ b/readmes/README_es.md @@ -231,6 +231,7 @@ Cuando el plugin está instalado y los pesos del modelo están descargados, pued filtrar, y el log de OBS recibe los detalles de captura (fuente de entrada, dimensiones, recorte). Útil cuando la detección no funciona como se espera. - **Enable remote decklist** — permite que cada jugador cargue su deck desde una URL HTTP(S) o un código YDKE en lugar de un archivo `.ydk` local; mira la nota debajo de la fuente `Draw Display`. + - **Export detected card info to files** — escribe las cartas detectadas (JSON / JSONL / texto plano) en una carpeta por usuario, para fuentes de texto de OBS, bots u overlays; mira la nota debajo de la fuente `Draw Display`. 3. El plugin proporciona una nueva fuente llamada `Draw Display`. Puedes añadirla a tu escena como cualquier otra fuente. Esta fuente mostrará las cartas detectadas en pantalla. Puedes elegir de qué fuente/escena detectar las cartas. Con el modo de dos jugadores activado, usa la propiedad **Detector / Player** de la fuente para seleccionar de qué detector leer (**Player 1** o **Player 2**); añade un `Draw Display` por jugador para mostrar ambos a la vez. @@ -258,6 +259,28 @@ Cuando el plugin está instalado y los pesos del modelo están descargados, pued > > ⚠️ Las URLs y el valor de la cabecera se almacenan en texto plano en QSettings, igual que el resto de ajustes > del plugin — evita guardar secretos de larga duración ahí. + + > 💡 El plugin también puede **exportar la información de las cartas detectadas a archivos** para que puedas + > mostrarla en cualquier lugar — una fuente de texto de OBS que el streamer lee en directo, bots, u overlays + > HTML/navegador. Está **desactivado por defecto** — activa *Export detected card info to files* en los ajustes + > de Draw 2 (*Feature flags*) y reinicia DRAW. Mientras está en marcha, cada detector escribe en + > `plugin_config/draw2-plugin/state/` (por jugador `N`): + > - `current_pN.json` — cartas actualmente en pantalla: + > `{ "updated_at", "channel", "cards": [ { "id", "name", "type", "attribute", "race", "atk", "def", "desc" } ] }` + > (los campos enriquecidos provienen de YGOPRODeck; los campos ausentes se omiten). + > - `events_pN.jsonl` — registro de solo adición, un JSON por línea: + > `{ "ts", "event": "appeared" | "disappeared", "card": { … } }`. + > - `current_card_pN.txt` — texto plano, los nombres de las cartas en pantalla (separados por saltos de línea). + > Apunta una fuente **Text** de OBS a este archivo (*Read from file*) para mostrar la carta actual en directo. + > + > El idioma de los metadatos es inglés por defecto; establece la clave `card_info_lang` en el almacén de ajustes + > de Draw 2 a uno de `en` / `fr` / `de` / `it` / `pt` (YGOPRODeck no proporciona español). La mitad del backend + > vive en el backend `draw2`; el plugin solo lo apunta a la carpeta de salida. + > + > De forma predeterminada, el backend descarga la base de datos completa de cartas una vez (en segundo plano) para + > que los metadatos se resuelvan **sin conexión**, sin peticiones por carta. Desmarca + > **Download full card database for offline use** para omitir la descarga y resolverlas de forma diferida, una carta + > a la vez. 4. Haz clic en el botón `Start DRAW` para iniciar el proceso de detección. El plugin empezará a detectar cartas en tiempo real y a mostrarlas en pantalla mediante la fuente `Draw Display`. El plugin comienza a detectar en el momento en que ves el botón `Stop DRAW`. Si no lo ves, algo salió mal. diff --git a/readmes/README_fr.md b/readmes/README_fr.md index b4f2622..846e1a5 100644 --- a/readmes/README_fr.md +++ b/readmes/README_fr.md @@ -237,6 +237,7 @@ Une fois le plugin installé et les poids du modèle téléchargés, vous pouvez sans filtrage, et le journal OBS reçoit les détails de capture (source d'entrée, dimensions, recadrage). Pratique quand la détection ne se comporte pas comme prévu. - **Activer la decklist distante** — permet à chaque joueur de charger son deck depuis une URL HTTP(S) ou un code YDKE au lieu d'un fichier `.ydk` local ; voir la note sous la source `Affichage Draw`. + - **Exporter les infos des cartes détectées vers des fichiers** — écrit les cartes détectées (JSON / JSONL / texte brut) dans un dossier par utilisateur, pour des sources Texte OBS, des bots ou des overlays ; voir la note sous la source `Affichage Draw`. 3. Le plugin fournit une nouvelle source appelée `Affichage DRAW`. Vous pouvez l'ajouter à votre scène comme n'importe quelle autre source. Cette source affichera les cartes détectées à l'écran. Vous pouvez choisir la source/scène à partir de laquelle @@ -266,6 +267,28 @@ Une fois le plugin installé et les poids du modèle téléchargés, vous pouvez > > ⚠️ Les URLs et la valeur de l'en-tête sont stockées en texte brut dans QSettings, comme tous les autres paramètres > du plugin — évitez d'y placer des secrets à longue durée de vie. + + > 💡 Le plugin peut également **exporter les informations des cartes détectées vers des fichiers** afin que vous + > puissiez les afficher n'importe où — une source Texte OBS que le streamer lit en direct, des bots ou des overlays + > HTML/navigateur. C'est **désactivé par défaut** — activez *Exporter les infos des cartes détectées vers des fichiers* + > dans les paramètres de Draw 2 (onglet *Fonctionnalités*) et redémarrez DRAW. Pendant l'exécution, chaque détecteur + > écrit dans `plugin_config/draw2-plugin/state/` (par joueur `N`) : + > - `current_pN.json` — cartes actuellement à l'écran : + > `{ "updated_at", "channel", "cards": [ { "id", "name", "type", "attribute", "race", "atk", "def", "desc" } ] }` + > (les champs enrichis proviennent de YGOPRODeck ; les champs manquants sont omis). + > - `events_pN.jsonl` — journal en ajout seul, un JSON par ligne : + > `{ "ts", "event": "appeared" | "disappeared", "card": { … } }`. + > - `current_card_pN.txt` — texte brut, les noms des cartes à l'écran (séparés par des sauts de ligne). Pointez une + > source **Text** OBS vers ce fichier (*Read from file*) pour afficher la carte actuelle en direct. + > + > La langue des métadonnées est l'anglais par défaut ; définissez la clé `card_info_lang` dans le magasin de + > paramètres de Draw 2 sur l'une des valeurs `en` / `fr` / `de` / `it` / `pt` (YGOPRODeck ne fournit pas l'espagnol). + > La moitié backend vit dans le backend `draw2` ; le plugin se contente de la pointer vers le dossier de sortie. + > + > Par défaut, le backend télécharge une fois la base de données complète des cartes (en arrière-plan) afin que les + > métadonnées soient résolues **hors ligne**, sans requête par carte. Décochez + > **Télécharger la base de cartes complète pour une utilisation hors ligne** pour ignorer le téléchargement et les + > résoudre paresseusement, une carte à la fois. 4. Cliquez sur le bouton `Lancer DRAW` pour lancer le processus de détection. Le plugin commencera à détecter les cartes en temps réel et les affichera à l'écran à l'aide de la source `Affichage Draw`. Le plugin commence la détection dès que le bouton diff --git a/readmes/README_jp.md b/readmes/README_jp.md index 4703535..b0137d1 100644 --- a/readmes/README_jp.md +++ b/readmes/README_jp.md @@ -144,6 +144,7 @@ OSに応じた手順に従ってセットアップしてください。 OBSログにはキャプチャの詳細(入力ソース、サイズ、クロップ)が記録されます。 検出が期待通りに動作しない場合に役立ちます。 * **Enable remote decklist** — 各プレイヤーがローカルの `.ydk` ファイルの代わりに HTTP(S) URL または YDKE コードからデッキを読み込めるようにします。`Draw Display` ソースの下の注記を参照してください。 + * **Export detected card info to files** — 検出されたカード(JSON / JSONL / プレーンテキスト)をユーザーごとのフォルダに書き出します。OBS のテキストソース、ボット、オーバーレイ向けです。`Draw Display` ソースの下の注記を参照してください。 3. プラグインは `Draw Display` という新しいソースを提供します。シーンに追加すると、検出されたカードが画面上に表示されます。どのソースやシーンからカードを検出するか選択できます。2人プレイモードが有効な場合、ソースの **Detector / Player** プロパティで、どのディテクターから読み取るか(**Player 1** または **Player 2**)を選択できます。両方を表示するには、プレイヤーごとに1つの `Draw Display` を追加してください。 > 💡 プラグインはローカルの `.ydk` ファイルの代わりに **HTTP(S) URL** または **YDKE コード**(`ydke://…`)からデッキリストを読み込むこともできます。リモート API やトーナメント管理システムがデッキリストを提供している場合や、YDKE リンクで共有されている場合に便利です。この機能は**デフォルトでは無効**です。Draw 2 の設定(*高度な機能*)で **Enable remote decklist** を有効にしてください。ソースはその後、専用の **Decklist** タブで設定します。 @@ -157,6 +158,18 @@ OSに応じた手順に従ってセットアップしてください。 > 任意の認証ヘッダー(名前 + 値、例:`Authorization` / `Bearer …`)を設定でき、すべてのリクエストに付与されます。 > > ⚠️ URL とヘッダーの値は、他のすべてのプラグイン設定と同様に QSettings にプレーンテキストで保存されます。長期間有効なシークレットをここに保存しないように注意してください。 + + > 💡 プラグインは**検出されたカード情報をファイルにエクスポート**することもできるので、どこにでも表示できます — ストリーマーが配信で読み上げる OBS のテキストソース、ボット、または HTML/ブラウザのオーバーレイなど。**デフォルトでは無効**です。Draw 2 の設定(*Feature flags*)で *Export detected card info to files* を有効にして DRAW を再起動してください。実行中、各ディテクターは `plugin_config/draw2-plugin/state/` に書き込みます(プレイヤー `N` ごと): + > - `current_pN.json` — 現在画面上にあるカード: + > `{ "updated_at", "channel", "cards": [ { "id", "name", "type", "attribute", "race", "atk", "def", "desc" } ] }` + > (リッチなフィールドは YGOPRODeck から取得され、欠落しているフィールドは省略されます)。 + > - `events_pN.jsonl` — 追記専用のログ、1行につき1つの JSON: + > `{ "ts", "event": "appeared" | "disappeared", "card": { … } }`。 + > - `current_card_pN.txt` — プレーンテキスト、画面上のカードの名前(改行区切り)。OBS の **Text** ソースをこのファイルに向ければ(*Read from file*)、現在のカードをライブで表示できます。 + > + > メタデータの言語はデフォルトで英語です。Draw 2 の設定ストアの `card_info_lang` キーを `en` / `fr` / `de` / `it` / `pt` のいずれかに設定してください(YGOPRODeck はスペイン語を提供していません)。バックエンド側は `draw2` バックエンドにあり、プラグインはそれを出力フォルダに向けるだけです。 + > + > デフォルトでは、バックエンドはカードデータベース全体を一度(バックグラウンドで)ダウンロードするため、メタデータはカードごとのリクエストなしで**オフライン**で解決されます。**Download full card database for offline use** のチェックを外すと、ダウンロードを省略し、代わりに1枚ずつ遅延的に解決します。 4. `Start DRAW` ボタンをクリックして検出を開始します。プラグインはリアルタイムでカードを検出し、`Draw Display` ソースを使って画面に表示します。`Stop DRAW` ボタンが表示された時点から検出が始まります。表示されない場合は、何か問題が発生しています。 5. 問題がなければ、プラグインをお楽しみください! diff --git a/readmes/README_pt-br.md b/readmes/README_pt-br.md index 2ad0a1d..0b39ef7 100644 --- a/readmes/README_pt-br.md +++ b/readmes/README_pt-br.md @@ -226,6 +226,7 @@ Quando o plugin está instalado e os "model weights" estão baixados, você pode filtro, e o log do OBS recebe os detalhes de captura (fonte de entrada, dimensões, recorte). Útil quando a detecção não está se comportando como esperado. - **Enable remote decklist** — permite que cada jogador carregue seu deck a partir de uma URL HTTP(S) ou de um código YDKE em vez de um arquivo `.ydk` local; veja a nota abaixo da fonte `Draw Display`. + - **Export detected card info to files** — escreve as cartas detectadas (JSON / JSONL / texto simples) em uma pasta por usuário, para fontes de texto do OBS, bots ou overlays; veja a nota abaixo da fonte `Draw Display`. 3. O plugin irá fornecer uma nova fonte chamada `Draw Display`. Você pode adicioná-la a sua cena como qualquer outra fonte. Essa fonte irá exibir as cartas detectadas na tela. Você pode escolher de qual fonte/cena detectar as cartas. Com o modo de dois jogadores ativado, use a propriedade **Detector / Player** da fonte para escolher de qual detector ela lê (**Player 1** ou **Player 2**); adicione um `Draw Display` por jogador para exibir ambos ao mesmo tempo. @@ -253,6 +254,27 @@ Quando o plugin está instalado e os "model weights" estão baixados, você pode > > ⚠️ As URLs e o valor do cabeçalho são armazenados em texto simples no QSettings, como todas as outras > configurações do plugin — evite armazenar segredos de longa duração ali. + + > 💡 O plugin também pode **exportar as informações das cartas detectadas para arquivos** para que você possa + > exibi-las em qualquer lugar — uma fonte de texto do OBS que o streamer lê ao vivo, bots, ou overlays + > HTML/navegador. Vem **desativado por padrão** — ative *Export detected card info to files* nas configurações + > do Draw 2 (*Feature flags*) e reinicie o DRAW. Enquanto está em execução, cada detector escreve em + > `plugin_config/draw2-plugin/state/` (por jogador `N`): + > - `current_pN.json` — cartas atualmente na tela: + > `{ "updated_at", "channel", "cards": [ { "id", "name", "type", "attribute", "race", "atk", "def", "desc" } ] }` + > (os campos enriquecidos vêm do YGOPRODeck; os campos ausentes são omitidos). + > - `events_pN.jsonl` — log somente de adição, um JSON por linha: + > `{ "ts", "event": "appeared" | "disappeared", "card": { … } }`. + > - `current_card_pN.txt` — texto simples, os nomes das cartas na tela (separados por quebras de linha). Aponte uma + > fonte **Text** do OBS para este arquivo (*Read from file*) para exibir a carta atual ao vivo. + > + > O idioma dos metadados é inglês por padrão; defina a chave `card_info_lang` no armazenamento de configurações do + > Draw 2 para um de `en` / `fr` / `de` / `it` / `pt` (o YGOPRODeck não fornece espanhol). A metade do backend vive + > no backend `draw2`; o plugin apenas o aponta para a pasta de saída. + > + > Por padrão, o backend baixa o banco de dados completo de cartas uma vez (em segundo plano) para que os metadados + > sejam resolvidos **offline**, sem requisições por carta. Desmarque **Download full card database for offline use** + > para pular o download e resolvê-los de forma preguiçosa, uma carta por vez. 4. Clique no botão `Start DRAW` para começar o processo de detecção. O plugin irá começar a detectar cartas em tempo real e exibí-las na tela usando a fonte `Draw Display`. O plugin irá começar a detectar a partir do momento que você vir o botão `Stop DRAW`. Se não aparecer, algo deu errado. diff --git a/src/DrawDock.cpp b/src/DrawDock.cpp index 50ba156..d7a7fe2 100644 --- a/src/DrawDock.cpp +++ b/src/DrawDock.cpp @@ -10,6 +10,7 @@ #include "RemoteDeck.hpp" #include +#include #include #include #include @@ -300,6 +301,29 @@ void DrawDock::StartChannel(int channel, const QString &python_exe) AppendLog(QString("· [P%1] debug: deck_list=%2").arg(channel).arg(deck_list)); } + // Opt-in: export structured card info to files (for OBS Text sources / bots / + // overlays). When off, set nothing so the backend behaves exactly as before. + if (draw_feature_enabled(FEATURE_CARD_INFO)) { + const char *state_dir = get_state_path(); + if (state_dir) { + const QString lang = settings.value("card_info_lang", "en").toString(); + // Full local card DB (offline) is on by default; the checkbox can + // turn it off so the backend resolves lazily, one card at a time. + const bool full_db = settings.value("feature_card_info_db", true).toBool(); + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("DRAW2_CARD_INFO_DIR", QString::fromUtf8(state_dir)); + env.insert("DRAW2_CARD_INFO_LANG", lang); + env.insert("DRAW2_CARD_INFO_DB", full_db ? "1" : "0"); + process->setProcessEnvironment(env); + if (draw_feature_enabled(FEATURE_DEBUG)) + AppendLog(QString("· [P%1] debug: card info → %2 (lang=%3, full_db=%4)") + .arg(channel) + .arg(QString::fromUtf8(state_dir)) + .arg(lang) + .arg(full_db ? "yes" : "no")); + } + } + process->start(python_exe, args); } diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index 3aad03d..a846d1e 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -241,10 +241,15 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) this->feature_crop->setChecked(settings.value("feature_crop", false).toBool()); this->feature_debug->setChecked(settings.value("feature_debug", false).toBool()); this->feature_remote_deck->setChecked(feature_remote_deck_value); + this->feature_card_info->setChecked(settings.value("feature_card_info", false).toBool()); + // Full local card DB defaults ON (offline, no per-card requests). + this->feature_card_info_db->setChecked(settings.value("feature_card_info_db", true).toBool()); features_layout->addWidget(this->feature_channel); features_layout->addWidget(this->feature_crop); features_layout->addWidget(this->feature_debug); features_layout->addWidget(this->feature_remote_deck); + features_layout->addWidget(this->feature_card_info); + features_layout->addWidget(this->feature_card_info_db); features_layout->addStretch(); tabs->addTab(general_page, obs_module_text("general_tab")); @@ -325,6 +330,8 @@ void SettingsDialog::OkButtonClicked() settings.setValue("feature_crop", this->feature_crop->isChecked()); settings.setValue("feature_debug", this->feature_debug->isChecked()); settings.setValue("feature_remote_deck", this->feature_remote_deck->isChecked()); + settings.setValue("feature_card_info", this->feature_card_info->isChecked()); + settings.setValue("feature_card_info_db", this->feature_card_info_db->isChecked()); settings.setValue("deck_url1", this->deck_url1->text()); settings.setValue("deck_url1_p2", this->deck_url1_p2->text()); settings.setValue("deck_source", this->deck_source->currentIndex()); diff --git a/src/SettingsDialog.hpp b/src/SettingsDialog.hpp index f46ca53..baf628c 100644 --- a/src/SettingsDialog.hpp +++ b/src/SettingsDialog.hpp @@ -44,6 +44,8 @@ class SettingsDialog : public QDialog { QCheckBox *feature_crop = new QCheckBox(obs_module_text("feature_crop")); QCheckBox *feature_debug = new QCheckBox(obs_module_text("feature_debug")); QCheckBox *feature_remote_deck = new QCheckBox(obs_module_text("feature_remote_deck")); + QCheckBox *feature_card_info = new QCheckBox(obs_module_text("feature_card_info")); + QCheckBox *feature_card_info_db = new QCheckBox(obs_module_text("feature_card_info_db")); // Remote decklist (opt-in): each player picks its own deck source — files, // a URL or a ydke:// code — so e.g. Player 1 can be remote and Player 2 local. QComboBox *deck_source = new QComboBox(); diff --git a/src/bridge.h b/src/bridge.h index 729dd44..7b3c239 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -32,6 +32,7 @@ bool draw_feature_enabled(const char *key); #define FEATURE_CROP "feature_crop" #define FEATURE_DEBUG "feature_debug" #define FEATURE_REMOTE_DECK "feature_remote_deck" +#define FEATURE_CARD_INFO "feature_card_info" #ifdef __cplusplus } diff --git a/src/plugin-main.cpp b/src/plugin-main.cpp index ae4a206..f6c38e2 100644 --- a/src/plugin-main.cpp +++ b/src/plugin-main.cpp @@ -70,3 +70,15 @@ const char *get_decklists_path() } return decklists_path; } + +const char *get_state_path() +{ + static char *state_path = nullptr; + if (!state_path) { + // e.g. ~/Library/Application Support/obs-studio/plugin_config/draw2-plugin/state + state_path = obs_module_config_path("state"); + if (state_path) + os_mkdirs(state_path); + } + return state_path; +} diff --git a/src/plugin-path.h b/src/plugin-path.h index 7c25204..44ae17f 100644 --- a/src/plugin-path.h +++ b/src/plugin-path.h @@ -13,4 +13,8 @@ const char *get_plugin_path(); // inside the plugin bundle) so user .ydk files survive plugin updates/reinstalls. const char *get_decklists_path(); +// Stable, per-user directory for exported card-info files (current_pN.json, +// events_pN.jsonl, current_card_pN.txt). Lives in OBS' plugin_config. +const char *get_state_path(); + #endif //DRAW2_OBSPLUGIN_PLUGIN_PATH_H