1 //////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // Nestopia - NES/Famicom emulator written in C++ 4 // 5 // Copyright (C) 2003-2008 Martin Freij 6 // 7 // This file is part of Nestopia. 8 // 9 // Nestopia is free software; you can redistribute it and/or modify 10 // it under the terms of the GNU General Public License as published by 11 // the Free Software Foundation; either version 2 of the License, or 12 // (at your option) any later version. 13 // 14 // Nestopia is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // You should have received a copy of the GNU General Public License 20 // along with Nestopia; if not, write to the Free Software 21 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 // 23 //////////////////////////////////////////////////////////////////////////////////////// 24 25 #include "NstDialogAbout.hpp" 26 #include "NstDialogLicense.hpp" 27 #include "NstManager.hpp" 28 #include "NstManagerHelp.hpp" 29 #include <ShellAPI.h> 30 31 namespace Nestopia 32 { 33 namespace Managers 34 { Help(Emulator & e,Window::Menu & m)35 Help::Help(Emulator& e,Window::Menu& m) 36 : Manager(e,m,this,&Help::OnEmuEvent) 37 { 38 static const Window::Menu::CmdHandler::Entry<Help> commands[] = 39 { 40 { IDM_HELP_HELP, &Help::OnCmdHelp }, 41 { IDM_HELP_ABOUT, &Help::OnCmdAbout }, 42 { IDM_HELP_LICENSE, &Help::OnCmdLicense } 43 }; 44 45 menu.Commands().Add( this, commands ); 46 menu[IDM_HELP_HELP].Enable( Application::Instance::GetExePath(L"readme.html").FileExists() ); 47 } 48 OnCmdHelp(uint)49 void Help::OnCmdHelp(uint) 50 { 51 ::ShellExecute 52 ( 53 NULL, 54 L"open", 55 Application::Instance::GetExePath(L"readme.html").Ptr(), 56 NULL, 57 NULL, 58 SW_SHOWNORMAL 59 ); 60 } 61 OnCmdAbout(uint)62 void Help::OnCmdAbout(uint) 63 { 64 Window::About().Open(); 65 } 66 OnCmdLicense(uint)67 void Help::OnCmdLicense(uint) 68 { 69 Window::License().Open(); 70 } 71 OnEmuEvent(const Emulator::Event event,const Emulator::Data data)72 void Help::OnEmuEvent(const Emulator::Event event,const Emulator::Data data) 73 { 74 switch (event) 75 { 76 case Emulator::EVENT_NETPLAY_MODE: 77 78 menu[IDM_HELP_HELP].Enable( !data ); 79 menu[IDM_HELP_ABOUT].Enable( !data ); 80 menu[IDM_HELP_LICENSE].Enable( !data ); 81 break; 82 } 83 } 84 } 85 } 86