# 080 — One context menu for every title

## 1. Where

Every movie, series, season and episode item the addon produces:
My movies / My series listings, Home rows of all sections, the search window
rows, the addon's TMDb / ČSFD / AI / collections / similar / favourites /
recently-played listings. Built by one function
`menu.py build(item) -> [(label, builtin)]` and attached with
`ListItem.addContextMenuItems` (Kodi shows plugin context items in widgets
and Videos windows alike). Kodi's own items (Information, its watched /
resume items — synced, 040 §6) stay above them.

## 2. Items (decision 12), in this order, plain labels (Estuary 1:1, no colours)

| Group | Item | Shown for | Action |
|-------|------|-----------|--------|
| Přehrávání | Pokračovat od <mm:ss> | movie / episode with resume point | `mplay_req src=last from=resume` |
| | Přehrát od začátku | movie / episode | `mplay_req src=last from=start` (plain "Přehrát" when no resume) |
| | Vybrat stream | movie / episode | `mplay_req src=dialog from=start` |
| | Přehrát další díl (S02E01) | series, season | next-up episode, `src=auto` |
| Stav | Označit jako zhlédnuté / nezhlédnuté | movie, episode, season, series (040 §5) | `ctx_mark` |
| | Odebrat z Pokračovat | items with Continue state | `ctx_hide_continue` |
| Seznamy a kanály | Přidat do Moje filmy / Odebrat z Moje filmy | movie | `ctx_list` |
| | Přidat do Moje seriály / Odebrat z Moje seriály | series, season, episode (acts on the series) | `ctx_list` |
| | Přidat do MyTV | series, season, episode | channel picker (existing `lib_add_channel` logic, TMDb-based) |
| | Přidat do MyCinema | movie | cinema picker |
| Objevování | Detail | all | `show_wcs_details` |
| | Podobné | movie, series | `display_similar_*_dialog` |
| | Kolekce | movie with `belongs_to_collection` | collection dialog |
| | Milionář hra | all | `play_text_game` with the item's data |

After any state or list action: store write → mirror (040 §6) → token bump
and `Container.Refresh` so ticks, rows and labels update at once.

## 3. No Kodi library in skin.milionar

- With skin.milionar active (`xbmc.getSkinDir() == 'skin.milionar'`) no menu
  offers "Přidat do knihovny Kodi" (`check_library_settings_and_add`): the new
  menu never contains it, `wcs/ui/ContextMenu.py` drops it, and the details
  dialog hides its library button (`Window(Home).Property(milionar.skin)`
  set by the service when the skin is active; `DialogWcsDetails.xml` visible
  condition).
- In other skins the addon keeps its current library items unchanged.
- The `kodi.context.item` entries for real library items (F4 of the skin plan)
  stay; they only appear on Kodi library items, which skin.milionar no longer
  shows by default.

## 4. Result

Built 2026-10-01 (awaiting the user's test, **not yet accepted**):

- `wcs/library2/menu.py` (`Menu.build(kind, tmdb, s, e)` -> [(label, builtin)], plain labels) and `ctx.py` (fast-path
  actions `ctx_mark`, `ctx_hide_continue`, `ctx_list`, `ctx_open`; `ctx_channel` goes through the router to the old
  channel picker). Items as in §2: Pokračovat od <mm:ss> / Přehrát od začátku / Vybrat stream (same file as before when
  the store knows it, else the source dialog) or Přehrát; Přehrát další díl (S02E01) for series and seasons; Označit jako
  zhlédnuté / nezhlédnuté (movie, episode, season, series: aired regular episodes, a manual mark never counts a second
  view, mirrored into Kodi); Odebrat z Pokračovat; Přidat do / Odebrat z Moje filmy / Moje seriály; Přidat do MyTV /
  MyCinema; Detail, Podobné, Kolekce (movies with a collection), Milionář hra. After an action: mirror, widget token,
  `Container.Refresh`.
- Attached to: My movies / My series / seasons / episodes listings, every Home row (`rows.build`), the TMDb search rows
  of window 1120, and - when `skin.milionar` is active - every item of the old addon listings (TMDb, ČSFD, AI,
  collections, similar, favourites...) because `ContextMenu.create_*_context_menu` return the same menu. Not on the
  buttons, the "all seasons" folder and unaired episodes.
- **TV-friendly structure (user, 2026-10-01):** at most 6 entries on top - Pokračovat od / Přehrát, Přehrát od začátku (only
  with a resume point), Označit jako zhlédnuté / nezhlédnuté, Přidat do / Odebrat z Moje filmy|seriály
  and "Další…" - and behind "Další…": Vybrat stream (moved there on 2026-10-01, plain play is the cinema-like default), Odebrat z Pokračovat, Přidat do MyTV|MyCinema, Detail, Podobné, Kolekce, Milionář
  hra (`Menu.build_parts`, two `Dialog.contextmenu` calls in `ctx.open_menu`). Series / season: Přehrát další díl,
  Označit, Přidat do Moje seriály, Další….
- **Only our menu is shown (user's first test, 2026-10-01):** Kodi lists plugin context items among its own and ignores
  `replaceItems`, so the fork's `DialogContextMenu.xml` hides and closes Kodi's menu for items with `milionar.type` and
  runs `ctx_open`, which shows the standard menu dialog (`Dialog.contextmenu`) with only the 080 items (guard
  `Window(Home).Property(milionar.ctx.active)`). In media windows the dialog reads `ListItem.Property(milionar.*)`; Home
  widgets are not visible to it, so the service (`tracker.Engine.publish_focus`, every 0.5 s while Home is active)
  publishes the focused item as `Window(Home).Property(milionar.focus.*)` (needs a Kodi restart). Items of the Kodi
  library and other addons keep Kodi's own menu.
- Info dialog (skin): for addon items only Přehrát, Zobrazit fanart and Milionář remain (Stejný režisér, Verze, Bonusová videa, Zvolte obrázek and the trailer button are hidden when `milionar.tmdb` is set); the Kodi library is unchanged.
- Info dialog (skin): a second button 4501 "Milionář" for addon items opens the same menu as a select dialog (`ctx_open`);
  the old library button 4500 stays for library items.
- **Needs a Kodi restart after adding strings** (Kodi loads addon strings at start): found when the labels were blank.
- **Tests: 156 green** (`test_menu.py` 13). **Live:** the menu on My movies (resume, restart, source, mark, hide, list,
  MyCinema, detail, similar, collection, game), the info dialog button 4501, the details dialog without the library
  button; the actions mark movie / season / series, unmark, add / remove from the list ran through `RunPlugin` on fixture
  data (state checked in `library.db`, fixtures removed).
