📄 commandsmtor.cpp
字号:
}
PrintMessage("Gathering MSP files...");
_msp.GatherFiles(strPath);
PrintMessage("Done gathering files.");
_config.bMspOn = TRUE;
}
void MultipleActions(CString &strLine)
{
if (_config.bMultipleActions)
{
_config.bMultipleActions = FALSE;
PrintMessage("Action matching will find only the first matching action.");
}
else
{
_config.bMultipleActions = TRUE;
PrintMessage("Action matching will find all matching actions.");
}
WriteIniInt("Miscellaneous","Multiple Actions",_config.bMultipleActions);
}
void NoDefault(CString &strLine)
{
WriteIniString("Miscellaneous","Default File","");
PrintMessage("Default command file cleared.");
}
void NotifyDll(CString &strLine)
{
CString strType;
CString strDll;
CString strFunction;
FindStatement(strLine,strType);
FindStatement(strLine,strDll);
FindStatement(strLine,strFunction);
ReplaceVariables(strDll);
ReplaceVariables(strType);
ReplaceVariables(strFunction);
if (strType.IsEmpty())
{
PrintMessage("Usage: /notifydll {notification type} {dll name} {function name}");
PrintMessage("The following notification types are available:");
CommandPrintOn();
_terminal.Print(" Connect\n Disconnect\n ChatConnect\n ChatDisconnect\n Input\n Raw");
CommandPrintOff();
return;
}
strType.MakeLower();
if (strDll.IsEmpty())
{
PrintMessage("Active Notifications:\n");
CommandPrintOn();
_terminal.Print("Type Dll Function\n");
_terminal.Print("=============== ==================== ===============================\n");
if (IsPartial(strType,"connect"))
_notifyConnect.Print();
else if (IsPartial(strType,"disconnect"))
_notifyDisconnect.Print();
else if (IsPartial(strType,"chatconnect"))
_notifyChatConnect.Print();
else if (IsPartial(strType,"chatdisconnect"))
_notifyChatDisconnect.Print();
else if (IsPartial(strType,"input"))
_notifyInput.Print();
else if (IsPartial(strType,"raw"))
_notifyRaw.Print();
CommandPrintOff();
return;
}
DLL *pDll = _dlls.FindExact(strDll);
if (pDll == NULL)
{
PrintMessage("DLL not found.");
return;
}
if (strFunction.IsEmpty())
{
PrintMessage("A function name is required.");
return;
}
if (IsPartial(strType,"connect"))
_notifyConnect.Add(pDll->hDLL,strFunction);
else if (IsPartial(strType,"disconnect"))
_notifyDisconnect.Add(pDll->hDLL,strFunction);
else if (IsPartial(strType,"chatconnect"))
_notifyChatConnect.Add(pDll->hDLL,strFunction);
else if (IsPartial(strType,"chatdisconnect"))
_notifyChatDisconnect.Add(pDll->hDLL,strFunction);
else if (IsPartial(strType,"input"))
_notifyInput.Add(pDll->hDLL,strFunction);
else if (IsPartial(strType,"raw"))
_notifyRaw.Add(pDll->hDLL,strFunction);
}
void Pace(CString &strLine)
{
CString strPace;
FindStatement(strLine,strPace);
if (!strPace.IsEmpty())
_config.nPace = atoi(strPace);
CString strTemp;
strTemp.Format("SpeedWalk pacing set at: %d",_config.nPace);
PrintMessage(strTemp);
WriteIniInt("Speed Walking","Pace",_config.nPace);
}
void Pause(CString &strLine)
{
CString strParam;
FindStatement(strLine,strParam);
if (strParam.IsEmpty())
{
if (_config.bPause)
_config.bPause = FALSE;
else
_config.bPause = TRUE;
}
else
{
strParam.MakeLower();
if (!CString("on").Find(strParam))
_config.bPause = TRUE;
else
if (!CString("off").Find(strParam))
_config.bPause = FALSE;
}
CString strTemp;
strTemp.Format("Screen pause is %s.",
(_config.bPause ? "on" : "off"));
PrintMessage(strTemp);
WriteIniInt("Miscellaneous","Screen Pause",_config.bPause);
}
void PeekConnections(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
BOOL bResult;
int nIndex = atoi(strName);
if (nIndex)
bResult = _chat.PeekConnections(nIndex-1);
else
bResult = _chat.PeekConnections(strName);
if (!bResult)
PrintMessage("Chat name not found.");
}
void Ping(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
BOOL bResult;
int nIndex = atoi(strName);
if (nIndex)
bResult = _chat.Ping(nIndex-1);
else
bResult = _chat.Ping(strName);
if (!bResult)
PrintMessage("Chat name not found.");
}
void PlayMidi(CString &strLine)
{
CString strMidi;
FindStatement(strLine,strMidi);
ReplaceVariables(strMidi);
if (strMidi.IsEmpty())
{
_sound.PlayMidi("");
return;
}
if (!_sound.PlayMidi(_config.strSoundPath + strMidi))
{
PrintMessage("Unable to play that midi file.");
return;
}
}
void PlayWav(CString &strLine)
{
CString strWav;
CString strVolume;
CString strPriority;
CString strRepeat;
FindStatement(strLine,strWav);
FindStatement(strLine,strVolume);
FindStatement(strLine,strPriority);
FindStatement(strLine,strRepeat);
ReplaceVariables(strWav);
ReplaceVariables(strVolume);
ReplaceVariables(strPriority);
ReplaceVariables(strRepeat);
if (strWav.IsEmpty())
{
_sound.PlayWave(NULL);
return;
}
if (_config.bUsePlaySound)
{
PlaySound(_config.strSoundPath+strWav,NULL,SND_ASYNC|SND_FILENAME);
return;
}
int nLeftVol, nRightVol;
if (strVolume.IsEmpty())
{
nLeftVol = _config.nDefaultVolume;
nRightVol = nLeftVol;
}
else
{
int nIndex = strVolume.Find(',');
if (nIndex == -1)
{
nLeftVol = atoi(strVolume);
nRightVol = nLeftVol;
}
else
{
nLeftVol = atoi(strVolume.Left(nIndex));
nRightVol = atoi(strVolume.Right(strVolume.GetLength()-nIndex-1));
}
}
int nPriority;
if (strPriority.IsEmpty())
nPriority = 100;
else
nPriority = atoi(strPriority);
int nRepeat;
if (strRepeat.IsEmpty())
nRepeat = 1;
else
nRepeat = atoi(strRepeat);
CString strFile(_config.strSoundPath+strWav);
_sound.PlayWave(strFile,nLeftVol,nRightVol,nPriority,nRepeat);
}
void Presubstitute(CString &strLine)
{
if (_config.bPreSub)
{
_config.bPreSub = FALSE;
PrintMessage("Substitutes will be processed after actions and gags.");
}
else
{
_config.bPreSub = TRUE;
PrintMessage("Substitutes will be processed before actions and gags.");
}
WriteIniInt("Miscellaneous","PreSub",_config.bPreSub);
}
void PromptOverwrite(CString &strLine)
{
if (_config.bPromptOverwrite)
{
_config.bPromptOverwrite = FALSE;
PrintMessage("Ok, you won't get prompted to overwrite files.");
}
else
{
_config.bPromptOverwrite = TRUE;
PrintMessage("Ok, you'll be asked if you want to overwrite files.");
}
WriteIniInt("Miscellaneous","Prompt Overwrite",_config.bPromptOverwrite);
}
void OpenPort(CString &strLine)
{
// Can only open the port 1 time.
if (_bConnected)
{
PrintMessage("Port already open.");
return;
}
CString strPort, strSpeed, strData, strParity, strStop;
FindStatement(strLine,strPort);
FindStatement(strLine,strSpeed);
FindStatement(strLine,strData);
FindStatement(strLine,strParity);
FindStatement(strLine,strStop);
if (_modem.Open(strPort,strSpeed,strData,strParity,strStop))
{
PrintMessage("Port Opened.");
_bConnected = TRUE;
}
else
PrintMessage("Failed to open com port.");
}
void Read(CString &strLine)
{
// This is to keep track of the number of times this function has been
// recursed into. This happens when somebody embeds a /read command in
// a command file. The problem was the state variables getting saved
// when they had already been turned off due to a previous call to
// this function.
static int nNested = 0;
BOOL bVar;
BOOL bAct;
BOOL bAli;
BOOL bTab;
BOOL bMac;
BOOL bItm;
BOOL bLst;
BOOL bEvt;
BOOL bBar;
BOOL bArr;
BOOL bGag;
BOOL bHig;
BOOL bSub;
CStdioFileFixed file;
CString strFilename;
FindStatement(strLine,strFilename);
CString strPath(_config.strScriptPath+strFilename);
if (!file.Open(strPath,CFile::modeRead|CFile::typeText))
{
PrintMessage("Unable to open that file.");
return;
}
nNested++;
if (nNested == 1)
{
CommandPrintOn();
_bReadingFile = TRUE;
// Temporarily turn off messaging.
bVar = _config.bVarMessages;
bAct = _config.bActionMessages;
bAli = _config.bAliasMessages;
bTab = _config.bTabMessages;
bMac = _config.bMacroMessages;
bItm = _config.bItemMessages;
bLst = _config.bListMessages;
bEvt = _config.bEventMessages;
bBar = _config.bBarMessages;
bArr = _config.bArrayMessages;
bGag = _config.bGagMessages;
bHig = _config.bHighMessages;
bSub = _config.bSubMessages;
_config.bVarMessages = FALSE;
_config.bActionMessages = FALSE;
_config.bAliasMessages = FALSE;
_config.bTabMessages = FALSE;
_config.bMacroMessages = FALSE;
_config.bItemMessages = FALSE;
_config.bListMessages = FALSE;
_config.bEventMessages = FALSE;
_config.bBarMessages = FALSE;
_config.bArrayMessages = FALSE;
_config.bGagMessages = FALSE;
_config.bHighMessages = FALSE;
_config.bSubMessages = FALSE;
}
PrintMessage("Reading command file...");
BOOL bFirstLine = TRUE;
CString strInput;
while(file.ReadString(strInput))
{
if (strInput.IsEmpty())
continue;
// This will assume the first character of the first
// line has the command character. This should allow
// people with any command char to load a command file.
if (bFirstLine)
{
bFirstLine = FALSE;
strInput.TrimLeft();
_config.chCommand = strInput.GetAt(0);
}
ProcessLine(strInput);
}
if (_config.bShowInfo)
Information(CString(""));
file.Close();
PrintMessage("Done.");
if (nNested == 1)
{
_config.bVarMessages = bVar;
_config.bActionMessages = bAct;
_config.bAliasMessages = bAli;
_config.bTabMessages = bTab;
_config.bMacroMessages = bMac;
_config.bItemMessages = bItm;
_config.bListMessages = bLst;
_config.bEventMessages = bEvt;
_config.bBarMessages = bBar;
_config.bArrayMessages = bArr;
_config.bGagMessages = bGag;
_config.bHighMessages = bHig;
_config.bSubMessages = bSub;
_bReadingFile = FALSE;
CommandPrintOff();
}
nNested--;
}
void RequestConnects(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
if (strName.IsEmpty())
return;
int nIndex = atoi(strName);
if (nIndex)
{
CHAT *pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
return;
strName = pChat->strName;
}
if (_chat.RequestConnects(strName))
PrintMessage("Request Sent.");
}
void ResetEvent(CString &strLine)
{
CString strIndex;
FindStatement(strLine,strIndex);
if (strIndex.IsEmpty())
return;
if (strIndex == "*")
{
EVENT *pEvent = _events.GetFirst();
while(pEvent != NULL)
{
pEvent->dwStarted = _dwTime;
pEvent = _events.GetNext();
}
PrintMessage("All events reset.");
return;
}
EVENT *pEvent;
int nIndex = atoi(strIndex);
if (nIndex)
pEvent = _events.GetAt(nIndex-1);
else
pEvent = _events.FindByName(strIndex);
if (pEvent != NULL)
{
pEvent->dwStarted = _dwTime;
if (_config.bEventMessages)
PrintMessage("Event reset.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -