static bool Cmd_MessageBoxEX_Execute(COMMAND_ARGS) { *result = 0; char buffer[kMaxMessageLength]; if (!ExtractFormatStringArgs(0, buffer, paramInfo, arg1, opcodeOffsetPtr, scriptObj, eventList, kCommandInfo_MessageBoxEX.numParams)) return true; //extract the buttons char* b[10] = {0}; UInt32 btnIdx = 0; for (char* ch = buffer; *ch && btnIdx < 10; ch++) { if (*ch == GetSeparatorChar(scriptObj)) { *ch = '\0'; b[btnIdx++] = ch + 1; } } if (!btnIdx) //supply default OK button b[0] = "Ok"; if (thisObj && !(thisObj->flags & 0x00004000)) //if not temporary object and not quest script *ShowMessageBox_pScriptRefID = thisObj->refID; else *ShowMessageBox_pScriptRefID = scriptObj->refID; *ShowMessageBox_button = 0xFF; //overwrite any previously pressed button ShowMessageBox(buffer, ShowMessageBox_Callback, 0, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], 0); return true; }
// setting name included in format string i.e. "sSomeSetting|newSettingValue" bool Cmd_SetStringIniSetting_Execute(COMMAND_ARGS) { char fmtString[kMaxMessageLength] = { 0 }; *result = 0; if (ExtractFormatStringArgs(0, fmtString, PASS_FMTSTR_ARGS, kCommandInfo_SetStringGameSettingEX.numParams)) { UInt32 pipePos = std::string(fmtString).find(GetSeparatorChar(scriptObj)); if (pipePos != -1) { fmtString[pipePos] = 0; char* newValue = fmtString + pipePos + 1; Setting* setting = NULL; GameSettingCollection* gmsts = GameSettingCollection::GetSingleton(); if (gmsts && gmsts->GetGameSetting(fmtString, &setting) && setting && setting->GetType() == Setting::kSetting_String) { setting->Set(newValue);; *result = 1; } } } return true; }
bool StringVar_Find_Execute(COMMAND_ARGS, UInt32 mode, CommandInfo* commandInfo) { *result = -1; UInt32 strID = 0; UInt32 startPos = 0; UInt32 numChars = -1; UInt32 bCaseSensitive = 0; UInt32 numToReplace = -1; //replace all by default char toFind[kMaxMessageLength] = { 0 }; UInt32 intResult = -1; if (!ExtractFormatStringArgs(0, toFind, PASS_FMTSTR_ARGS, commandInfo->numParams, &strID, &startPos, &numChars, &bCaseSensitive, &numToReplace)) return true; StringVar* strVar = g_StringMap.Get(strID); if (strVar) { if (numChars == -1) numChars = strVar->GetLength() - startPos; switch (mode) { case eMode_svFind: intResult = strVar->Find(toFind, startPos, numChars, bCaseSensitive ? true : false); break; case eMode_svCount: intResult = strVar->Count(toFind, startPos, numChars, bCaseSensitive ? true : false); break; case eMode_svReplace: { std::string str(toFind); UInt32 splitPoint = str.find(GetSeparatorChar(scriptObj)); if (splitPoint != -1 && splitPoint < str.length()) { toFind[splitPoint] = '\0'; char* replaceWith = (splitPoint == str.length() - 1) ? "" : toFind + splitPoint + 1; intResult = strVar->Replace(toFind, replaceWith, startPos, numChars, bCaseSensitive ? true : false, numToReplace); } break; } } } if (intResult != -1) *result = intResult; return true; }
void TextInputMessageBox::Init() { char* buttons[10] = { NULL }; UInt32 numButtons = 0; UInt32 fmtStringLen = strlen(m_fmtString); char* fmtString = new char[fmtStringLen + 1]; strcpy_s(fmtString, fmtStringLen + 1, m_fmtString); //separate prompt text and button text for (UInt32 strPos = 0; strPos < fmtStringLen && numButtons < 10; strPos++) { if (fmtString[strPos] == GetSeparatorChar(m_script) && (strPos + 1 < fmtStringLen)) { fmtString[strPos] = '\0'; buttons[numButtons++] = fmtString + strPos + 1; } } m_promptText = fmtString; if (!buttons[0]) //supply default button if none specified buttons[0] = "Finished"; //now display the messagebox ShowMessageBox(fmtString, ShowMessageBox_Callback, 0, buttons[0], buttons[1], buttons[2], buttons[3], buttons[4], buttons[5], buttons[6], buttons[7], buttons[8], buttons[9], 0); //Register it with the game so scripts can pick up button pressed *ShowMessageBox_pScriptRefID = m_scriptRefID; *ShowMessageBox_button = -1; //Disable menu shortcut keys so they don't interfere with typing if (!m_bShortcutsDisabled) { m_bShortcutsDisabled = true; ToggleMenuShortcutKeys(false, GetMenuByType(kMenuType_Message)); } }
// setting name included in format string i.e. "sSomeSetting|newSettingValue" bool Cmd_SetStringGameSettingEX_Execute(COMMAND_ARGS) { char fmtString[kMaxMessageLength] = { 0 }; *result = 0; if (ExtractFormatStringArgs(0, fmtString, PASS_FMTSTR_ARGS, kCommandInfo_SetStringGameSettingEX.numParams)) { UInt32 pipePos = std::string(fmtString).find(GetSeparatorChar(scriptObj)); if (pipePos != -1) { fmtString[pipePos] = 0; char* newValue = fmtString + pipePos + 1; Setting* setting = NULL; if (GetIniSetting(fmtString, &setting)) { setting->Set(newValue);; *result = 1; } } } return true; }