summaryrefslogtreecommitdiff
path: root/menu_options.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu_options.c')
-rw-r--r--menu_options.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/menu_options.c b/menu_options.c
new file mode 100644
index 0000000..a27f38b
--- /dev/null
+++ b/menu_options.c
@@ -0,0 +1,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());
+}
+