summaryrefslogtreecommitdiff
path: root/menu_options.c
blob: a27f38b3adf98d3fca4ecdd62508dd9fd2dfd351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "menu_options.h"

cMpvMenuOptions::cMpvMenuOptions(cMpvPlayer *Player)
:cOsdMenu(tr("Options"))
{
  SetDisplayMenu();
  player = Player;
  ShowOptions();
  Show();
  Display();
}

cMpvMenuOptions::~cMpvMenuOptions()
{
  dsyslog ("dekonstruktor\n");
}

void cMpvMenuOptions::ShowOptions()
{
  // display chapter select menu if the file has named named chapters
  if (player->NumChapters() && player->ChapterTitle(1) != "")
    Add(new cOsdItem(tr("Show chapters"), osUser1));

  // TODO if we are currently on a playlist display playlist menu
  
}

eOSState cMpvMenuOptions::ProcessKey(eKeys Key)
{
  eOSState State = cOsdMenu::ProcessKey(Key);

  if (!HasSubMenu())
  {
    switch (Key)
    {
      case kOk:
        AddSubMenu(new cMpvMenuChapters(player));
      break;

      default:
      break;
    }
  }

  return State;
}

cMpvMenuChapters::cMpvMenuChapters(cMpvPlayer *Player)
:cOsdMenu(tr("Chapters"))
{
  player = Player;
  for (int i=1; i<=player->NumChapters(); i++)
    AddItem(player->ChapterTitle(i), i);

  Display();
}

eOSState cMpvMenuChapters::ProcessKey(eKeys Key)
{
  eOSState State = cOsdMenu::ProcessKey(Key);
  if (State == osUnknown)
  {
    switch (Key)
    {
      case kOk:
        cMpvMenuChapterItem *item = (cMpvMenuChapterItem *) Get(Current());
        player->SetChapter(item->Number());
      return osEnd;
    }
  }

  return State;
}

void cMpvMenuChapters::AddItem(string Title, int Number)
{
  bool Current = false;
  if (player->ChapterTitle(player->CurrentChapter()) == Title)
    Current = true;
  Add(new cMpvMenuChapterItem(Title, Number), Current);
}

cMpvMenuChapterItem::cMpvMenuChapterItem(string Title, int Number)
{
  // TODO add number in front
  number = Number;
  SetText(Title.c_str());
}