Skip to content

feat: opt-in export of detected card info to files - #9

Open
leiteszeke wants to merge 1 commit into
up/06-remote-decklistfrom
up/07-card-info
Open

leiteszeke wants to merge 1 commit into
up/06-remote-decklistfrom
up/07-card-info

Conversation

@leiteszeke

@leiteszeke leiteszeke commented Jun 29, 2026 •

Copy link
Copy Markdown
Owner

Fork-internal PR (base up/06-remote-decklist) — kept out of upstream for now because it depends on the unpublished backend half. Here for change tracking until the draw2 backend side is ready; will be opened upstream then.

Summary

Adds an opt-in "Export detected card info to files" toggle (Draw 2 settings → Feature flags, off by default): when on, the plugin points each backend detector at a stable per-user folder and the backend writes the currently-detected cards there, so you can surface them anywhere — an OBS Text source the streamer reads on stream, bots, or HTML/browser overlays. With the flag off, nothing is set and the backend behaves exactly as upstream.

Changes

  • src/feature_flags.h — FEATURE_CARD_INFO key.
  • src/plugin-path.h / src/plugin-main.cpp — get_state_path() helper (per-user plugin_config/draw2-plugin/state dir, created on demand), mirroring get_decklists_path().
  • src/SettingsDialog.{cpp,hpp} — in the Feature flags tab: an Export detected card info to files checkbox (QSettings feature_card_info), plus a Download full card database for offline use checkbox (QSettings feature_card_info_db, on by default) that controls whether the backend uses its local offline DB or resolves lazily per card.
  • src/DrawDock.cpp — when card info is on, each backend process is launched with DRAW2_CARD_INFO_DIR (= the state dir), DRAW2_CARD_INFO_LANG (QSettings card_info_lang, default en) and DRAW2_CARD_INFO_DB (1/0 from the toggle). When off, no environment is set. With debug logging on (FEATURE_DEBUG, from feat: opt-in debug logging (plugin-side) HichTala/draw2-plugin#29) the dock log shows the resolved output dir, language and full_db.
  • README + all translations (es/fr/jp/pt-br) document the toggle and the file contract.

File contract (written by the backend, per player N)

  • current_pN.json — cards currently on screen: { updated_at, channel, cards: [ { id, name, type, attribute, race, atk, def, desc } ] } (rich fields from YGOPRODeck; missing fields omitted).
  • events_pN.jsonl — append-only, one JSON per line: { ts, event: "appeared" | "disappeared", card: { … } }.
  • current_card_pN.txt — plain text, names on screen (newline-separated); point an OBS Text source at it (Read from file).

Opt-in / default behaviour

Off by default: with it off, no env var is set and the backend writes nothing — identical to upstream.

Backend dependency

This is the plugin half: it only sets the env vars pointing at the output folder. The backend reads DRAW2_CARD_INFO_DIR / DRAW2_CARD_INFO_LANG and writes the files (the draw2 backend change). With a backend that doesn't support it, the toggle is a no-op (no files written), no crash.

How it was tested

  • Universal plugin build succeeds (cmake --preset macos).

@leiteszeke
leiteszeke force-pushed the up/06-remote-decklist branch 2 times, most recently from 89c24be to 4c51b6d Compare October 13, 2026 10:56
Adds an opt-in "Export detected card info to files" toggle (Feature flags
tab, off by default). When on, each backend detector is pointed at a stable
per-user folder and writes the currently-detected cards there, for OBS Text
sources, bots or overlays.

- bridge.h: FEATURE_CARD_INFO key.
- plugin-path.h / plugin-main.cpp: get_state_path() helper (per-user
  plugin_config/draw2-plugin/state dir), mirroring get_decklists_path().
- SettingsDialog: checkbox in the Feature flags tab (QSettings
  feature_card_info), wired like the other opt-in toggles.
- DrawDock: when on, launch each backend with DRAW2_CARD_INFO_DIR (= state
  dir) and DRAW2_CARD_INFO_LANG (QSettings card_info_lang, default en); with
  debug logging on, the dock log shows the resolved dir + language. Off ->
  no env set, backend behaves exactly as upstream.
- README + all translations (es/fr/jp/pt-br) document the toggle and the
  file contract (current_pN.json / events_pN.jsonl / current_card_pN.txt).

The backend half (writing the files) lives in the draw2 backend; the plugin
only points it at the output folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant