1 // Copyright (c) 2005-2010, Niels Martin Hansen 2 // Copyright (c) 2005-2010, Rodrigo Braz Monteiro 3 // Copyright (c) 2010, Amar Takhar 4 // All rights reserved. 5 // 6 // Redistribution and use in source and binary forms, with or without 7 // modification, are permitted provided that the following conditions are met: 8 // 9 // * Redistributions of source code must retain the above copyright notice, 10 // this list of conditions and the following disclaimer. 11 // * Redistributions in binary form must reproduce the above copyright notice, 12 // this list of conditions and the following disclaimer in the documentation 13 // and/or other materials provided with the distribution. 14 // * Neither the name of the Aegisub Group nor the names of its contributors 15 // may be used to endorse or promote products derived from this software 16 // without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 // POSSIBILITY OF SUCH DAMAGE. 29 // 30 // Aegisub Project http://www.aegisub.org/ 31 32 #include "command.h" 33 34 #include "../help_button.h" 35 #include "../include/aegisub/context.h" 36 #include "../libresrc/libresrc.h" 37 38 #include <libaegisub/make_unique.h> 39 40 #include <wx/msgdlg.h> 41 42 namespace { 43 using cmd::Command; 44 45 struct help_bugs final : public Command { 46 CMD_NAME("help/bugs") CMD_ICON__anona225dd210111::help_bugs47 CMD_ICON(bugtracker_button) 48 STR_MENU("&Bug Tracker...") 49 STR_DISP("Bug Tracker") 50 STR_HELP("Visit Aegisub's bug tracker to report bugs and request new features") 51 52 void operator()(agi::Context *c) override { 53 if (wxGetMouseState().CmdDown()) { 54 if (wxGetMouseState().ShiftDown()) { 55 wxMessageBox("Now crashing with an access violation..."); 56 for (char *foo = (char*)nullptr;;) *foo++ = 42; 57 } else { 58 wxMessageBox("Now crashing with an unhandled exception..."); 59 throw c->parent; 60 } 61 } 62 wxLaunchDefaultBrowser("http://devel.aegisub.org/", wxBROWSER_NEW_WINDOW); 63 } 64 }; 65 66 struct help_contents final : public Command { 67 CMD_NAME("help/contents") CMD_ICON__anona225dd210111::help_contents68 CMD_ICON(contents_button) 69 STR_MENU("&Contents") 70 STR_DISP("Contents") 71 STR_HELP("Help topics") 72 73 void operator()(agi::Context *) override { 74 HelpButton::OpenPage("Main"); 75 } 76 }; 77 78 struct help_forums final : public Command { 79 CMD_NAME("help/forums") CMD_ICON__anona225dd210111::help_forums80 CMD_ICON(forums_button) 81 STR_MENU("&Forums") 82 STR_DISP("Forums") 83 STR_HELP("Visit Aegisub's forums") 84 85 void operator()(agi::Context *) override { 86 wxLaunchDefaultBrowser("http://forum.aegisub.org/", wxBROWSER_NEW_WINDOW); 87 } 88 }; 89 90 struct help_irc final : public Command { 91 CMD_NAME("help/irc") CMD_ICON__anona225dd210111::help_irc92 CMD_ICON(irc_button) 93 STR_MENU("&IRC Channel") 94 STR_DISP("IRC Channel") 95 STR_HELP("Visit Aegisub's official IRC channel") 96 97 void operator()(agi::Context *) override { 98 wxLaunchDefaultBrowser("irc://irc.rizon.net/aegisub", wxBROWSER_NEW_WINDOW); 99 } 100 }; 101 102 struct help_video final : public Command { 103 CMD_NAME("help/video") CMD_ICON__anona225dd210111::help_video104 CMD_ICON(visual_help) 105 STR_MENU("&Visual Typesetting") 106 STR_DISP("Visual Typesetting") 107 STR_HELP("Open the manual page for Visual Typesetting") 108 109 void operator()(agi::Context *) override { 110 HelpButton::OpenPage("Visual Typesetting"); 111 } 112 }; 113 114 struct help_website final : public Command { 115 CMD_NAME("help/website") CMD_ICON__anona225dd210111::help_website116 CMD_ICON(website_button) 117 STR_MENU("&Website") 118 STR_DISP("Website") 119 STR_HELP("Visit Aegisub's official website") 120 121 void operator()(agi::Context *) override { 122 wxLaunchDefaultBrowser("http://www.aegisub.org/", wxBROWSER_NEW_WINDOW); 123 } 124 }; 125 } 126 127 namespace cmd { init_help()128 void init_help() { 129 reg(agi::make_unique<help_bugs>()); 130 reg(agi::make_unique<help_contents>()); 131 reg(agi::make_unique<help_forums>()); 132 reg(agi::make_unique<help_irc>()); 133 reg(agi::make_unique<help_video>()); 134 reg(agi::make_unique<help_website>()); 135 } 136 } 137