00001
00002 #include "defaultCmds.h"
00003
00004 IC_Command_ECHO::IC_Command_ECHO() : IC_Command(L"echo")
00005 {
00006 setUsage(L"echo <string>");
00007 addDescLine(L"This command echoes the given string to console");
00008 }
00009 IC_Command_ECHO::~IC_Command_ECHO()
00010 {
00011 }
00012 bool IC_Command_ECHO::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00013 {
00014 if(args.size() > 1)
00015 {
00016 WideString wstr = args[0];
00017 for(u32 i = 1; i < args.size(); i++)
00018 {
00019 wstr += L" ";
00020 wstr += args[i];
00021 }
00022 pOutput->appendMessage(wstr);
00023 }
00024 return true;
00025 }
00026 IC_Command_HELP::IC_Command_HELP() : IC_Command(L"help")
00027 {
00028 setUsage(L"help <cmd-name>");
00029 addDescLine(L"this command prints the help available for console commands");
00030 addDescLine(L"if cmd-name is not supplied a list of commands is printed with usage");
00031 addDescLine(L"any command has to be preceded with the backslash character to execute");
00032 addDescLine(L"e.g. \\help");
00033 }
00034 IC_Command_HELP::~IC_Command_HELP()
00035 {
00036 }
00037 bool IC_Command_HELP::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00038 {
00039 if(args.size() == 0)
00040 {
00041 pDispatcher->printCommandList(pOutput,true);
00042 }
00043 else
00044 {
00045 WideString wstr = args[0];
00046 for(u32 i = 1; i < args.size(); i++)
00047 {
00048 wstr += L" ";
00049 wstr += args[i];
00050 }
00051 if(pDispatcher->hasCommand(wstr))
00052 {
00053 pDispatcher->printCommandDesc(wstr,pOutput);
00054 }
00055 else
00056 {
00057 WideString msg = " No help available for command ";
00058 msg+= wstr;
00059 pOutput->appendMessage(msg);
00060 }
00061 }
00062 return true;
00063 }
00064
00065 IC_Command_LIST::IC_Command_LIST(): IC_Command(L"list")
00066 {
00067 setUsage("list <detailed>");
00068 addDescLine("This command lists the available commands");
00069 addDescLine("If an additional paramter is specified then");
00070 addDescLine("the command returns usage information for the commands");
00071 }
00072 IC_Command_LIST::~IC_Command_LIST()
00073 {
00074 }
00075 bool IC_Command_LIST::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00076 {
00077 if(args.size() > 0)
00078 {
00079 pDispatcher->printCommandList(pOutput,true);
00080 }
00081 else
00082 {
00083 pDispatcher->printCommandList(pOutput,false);
00084 }
00085 return true;
00086 }
00087
00088
00089 IC_Command_DRIVER_INFO::IC_Command_DRIVER_INFO(irr::IrrlichtDevice *pDevice) : IC_Command("driver_info"),device(pDevice)
00090 {
00091 setUsage("driver_info");
00092 addDescLine("This command prints some info about the engine");
00093
00094 }
00095 IC_Command_DRIVER_INFO::~IC_Command_DRIVER_INFO()
00096 {
00097 device = 0;
00098 }
00099 bool IC_Command_DRIVER_INFO::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00100 {
00101 if(device)
00102 {
00103 WideString wstr = L" Irrlicht Version : ";
00104 wstr+= device->getVersion();
00105 pOutput->appendMessage(wstr);
00106
00107 wstr = L" OS Version : ";
00108 wstr+= device->getOSOperator()->getOperationSystemVersion();
00109 pOutput->appendMessage(wstr);
00110
00111 wstr = L" Display Driver : ";
00112 wstr+= device->getVideoDriver()->getName();
00113 pOutput->appendMessage(wstr);
00114
00115 wstr=L"";
00116 return true;
00117 }
00118 else
00119 {
00120 throw IC_Error(L"No valid irrlicht device detected!!");
00121 }
00122 }
00123 IC_Command_EXIT::IC_Command_EXIT() : IC_Command(L"exit")
00124 {
00125 setUsage("exit");
00126 addDescLine("sets the console to invisible");
00127 }
00128 IC_Command_EXIT::~IC_Command_EXIT()
00129 {
00130 }
00131 bool IC_Command_EXIT::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00132 {
00133 pOutput->toggleVisible();
00134 return true;
00135 }
00136
00137 IC_Command_QUIT::IC_Command_QUIT() : IC_Command(L"quit")
00138 {
00139 setUsage("exit");
00140 addDescLine("sets the console to invisible");
00141 }
00142 IC_Command_QUIT::~IC_Command_QUIT()
00143 {
00144 }
00145 bool IC_Command_QUIT::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00146 {
00147 pOutput->toggleVisible();
00148 return true;
00149 }
00150
00151 IC_Command_CLS::IC_Command_CLS() : IC_Command(L"cls")
00152 {
00153 setUsage("exit");
00154 addDescLine("clears the console messages");
00155 }
00156 IC_Command_CLS::~IC_Command_CLS()
00157 {
00158 }
00159 bool IC_Command_CLS::invoke(const array<WideString>& args, IC_Dispatcher* pDispatcher, IC_MessageSink* pOutput)
00160 {
00161 pOutput->toggleVisible();
00162 return true;
00163 }