added: new command "XBMC.RestartApp" for skinners to restart only the application
[xbmc:xbmc-antiquated.git] / xbmc / GUIDialogSubMenu.cpp
1
2 #include "stdafx.h"
3 #include "guidialogsubmenu.h"
4 #include "guiWindowManager.h"
5 #include "localizeStrings.h"
6 #include "application.h"
7 #include "Credits.h"
8 #include "util.h"
9
10 #define CONTROL_BTN_SHUTDOWN            10
11 #define CONTROL_BTN_DASHBOARD           11
12 #define CONTROL_BTN_REBOOT                      12
13 #define CONTROL_BTN_CREDITS                     13
14 #define CONTROL_BTN_ONLINE                      14
15
16 CGUIDialogSubMenu::CGUIDialogSubMenu(void)
17 :CGUIDialog(0)
18 {
19         ON_CLICK_MESSAGE(CONTROL_BTN_SHUTDOWN,  CGUIDialogSubMenu, OnClickShutdown);    
20         ON_CLICK_MESSAGE(CONTROL_BTN_DASHBOARD, CGUIDialogSubMenu, OnClickDashboard);   
21         ON_CLICK_MESSAGE(CONTROL_BTN_REBOOT,    CGUIDialogSubMenu, OnClickReboot);      
22         ON_CLICK_MESSAGE(CONTROL_BTN_CREDITS,   CGUIDialogSubMenu, OnClickCredits);     
23         ON_CLICK_MESSAGE(CONTROL_BTN_ONLINE,    CGUIDialogSubMenu, OnClickOnlineGaming);        
24 }
25
26 CGUIDialogSubMenu::~CGUIDialogSubMenu(void)
27 {
28 }
29
30 void CGUIDialogSubMenu::OnAction(const CAction &action)
31 {
32         if (action.wID == ACTION_CLOSE_DIALOG || action.wID == ACTION_PREVIOUS_MENU)
33   {
34                 Close();
35                 return;
36   }
37         CGUIDialog::OnAction(action);
38 }
39
40 bool CGUIDialogSubMenu::OnMessage(CGUIMessage &message)
41 {
42         bool bRet = CGUIDialog::OnMessage(message);
43         if (message.GetMessage() == GUI_MSG_CLICKED)
44         {
45                 // someone has been clicked - deinit...
46                 Close();
47                 return true;
48         }
49         return bRet;
50 }
51
52 void CGUIDialogSubMenu::OnClickShutdown(CGUIMessage& aMessage)
53 {
54         g_applicationMessenger.Shutdown();
55 }
56
57 void CGUIDialogSubMenu::OnClickDashboard(CGUIMessage& aMessage)
58 {
59         CUtil::RunXBE(g_stSettings.szDashboard);
60 }
61
62 void CGUIDialogSubMenu::OnClickReboot(CGUIMessage& aMessage)
63 {
64         CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)m_gWindowManager.GetWindow(WINDOW_DIALOG_YES_NO);
65         if (dlgYesNo)
66         {
67                 dlgYesNo->SetHeading(13313);
68                 dlgYesNo->SetLine(0, 13308);
69                 dlgYesNo->SetLine(1, 13309);
70                 dlgYesNo->SetLine(2, "");
71                 dlgYesNo->DoModal(GetID());
72
73     if(dlgYesNo->IsConfirmed())
74       g_applicationMessenger.Restart();
75     else
76       g_applicationMessenger.RestartApp();
77   }
78 }
79
80 void CGUIDialogSubMenu::OnClickCredits(CGUIMessage& aMessage)
81 {
82         RunCredits();
83 }
84
85 void CGUIDialogSubMenu::OnClickOnlineGaming(CGUIMessage& aMessage)
86 {
87         m_gWindowManager.ActivateWindow( WINDOW_BUDDIES );
88 }