From 595f140cd82b06346dbfa668cdfa672fc402a9a9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 8 Jul 2012 22:18:18 +0200 Subject: WINTERMUTE: Rename FuncName/VarName -> funcName/varName in BStringTable --- engines/wintermute/Ad/AdGame.cpp | 2 +- engines/wintermute/Ad/AdNodeState.cpp | 2 +- engines/wintermute/Ad/AdObject.cpp | 4 +- engines/wintermute/Base/BGame.cpp | 2 +- engines/wintermute/Base/BObject.cpp | 16 ++--- engines/wintermute/Base/BStringTable.cpp | 100 +++++++++++++++---------------- engines/wintermute/Base/BStringTable.h | 10 ++-- engines/wintermute/UI/UIButton.cpp | 2 +- engines/wintermute/UI/UIEdit.cpp | 2 +- engines/wintermute/UI/UIText.cpp | 2 +- engines/wintermute/UI/UIWindow.cpp | 2 +- 11 files changed, 72 insertions(+), 72 deletions(-) diff --git a/engines/wintermute/Ad/AdGame.cpp b/engines/wintermute/Ad/AdGame.cpp index 58b3250deb..66dd247a76 100644 --- a/engines/wintermute/Ad/AdGame.cpp +++ b/engines/wintermute/Ad/AdGame.cpp @@ -475,7 +475,7 @@ HRESULT CAdGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this if (res) { res->_iD = id; res->setText(text); - _stringTable->Expand(&res->_text); + _stringTable->expand(&res->_text); if (!val1->isNULL()) res->setIcon(val1->getString()); if (!val2->isNULL()) res->setIconHover(val2->getString()); if (!val3->isNULL()) res->setIconPressed(val3->getString()); diff --git a/engines/wintermute/Ad/AdNodeState.cpp b/engines/wintermute/Ad/AdNodeState.cpp index 266adc9378..954c12c9fc 100644 --- a/engines/wintermute/Ad/AdNodeState.cpp +++ b/engines/wintermute/Ad/AdNodeState.cpp @@ -115,7 +115,7 @@ void CAdNodeState::setCaption(const char *caption, int caseVal) { _caption[caseVal- 1] = new char[strlen(caption) + 1]; if (_caption[caseVal- 1]) { strcpy(_caption[caseVal- 1], caption); - Game->_stringTable->Expand(&_caption[caseVal- 1]); + Game->_stringTable->expand(&_caption[caseVal- 1]); } } diff --git a/engines/wintermute/Ad/AdObject.cpp b/engines/wintermute/Ad/AdObject.cpp index 4bea6921b9..978c4d2c04 100644 --- a/engines/wintermute/Ad/AdObject.cpp +++ b/engines/wintermute/Ad/AdObject.cpp @@ -838,7 +838,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const _sentence->_sound = NULL; _sentence->setText(text); - Game->_stringTable->Expand(&_sentence->_text); + Game->_stringTable->expand(&_sentence->_text); _sentence->setStances(stances); _sentence->_duration = duration; _sentence->_align = Align; @@ -850,7 +850,7 @@ void CAdObject::talk(const char *text, const char *sound, uint32 duration, const // try to locate speech file automatically bool deleteSound = false; if (!sound) { - char *key = Game->_stringTable->GetKey(text); + char *key = Game->_stringTable->getKey(text); if (key) { sound = ((CAdGame *)Game)->findSpeechFile(key); delete [] key; diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 088aebe4a3..7f24352b5e 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -1118,7 +1118,7 @@ HRESULT CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS CScValue *val = stack->pop(); char *str = new char[strlen(val->getString()) + 1]; strcpy(str, val->getString()); - _stringTable->Expand(&str); + _stringTable->expand(&str); stack->pushString(str); delete [] str; return S_OK; diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp index 49c4a19fcc..6b4b0f5da2 100644 --- a/engines/wintermute/Base/BObject.cpp +++ b/engines/wintermute/Base/BObject.cpp @@ -137,16 +137,16 @@ HRESULT CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int Case) { // TODO: rename Case to something usefull - if (Case == 0) Case = 1; - if (Case < 1 || Case > 7) +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) return; - delete[] _caption[Case - 1]; - _caption[Case - 1] = new char[strlen(caption) + 1]; - if (_caption[Case - 1]) { - strcpy(_caption[Case - 1], caption); - Game->_stringTable->Expand(&_caption[Case - 1]); + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + Game->_stringTable->expand(&_caption[caseVal - 1]); } } diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp index 72b5535714..ed33e4d776 100644 --- a/engines/wintermute/Base/BStringTable.cpp +++ b/engines/wintermute/Base/BStringTable.cpp @@ -50,35 +50,35 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::AddString(const char *Key, const char *Val, bool ReportDuplicities) { - if (Key == NULL || Val == NULL) return E_FAIL; +HRESULT CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return E_FAIL; - if (scumm_stricmp(Key, "@right-to-left") == 0) { + if (scumm_stricmp(key, "@right-to-left") == 0) { Game->_textRTL = true; return S_OK; } - Common::String final_key = Key; + Common::String final_key = key; StringUtil::toLowerCase(final_key); _stringsIter = _strings.find(final_key); - if (_stringsIter != _strings.end() && ReportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); + if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str()); - _strings[final_key] = Val; + _strings[final_key] = val; return S_OK; } ////////////////////////////////////////////////////////////////////////// -char *CBStringTable::GetKey(const char *Str) { - if (Str == NULL || Str[0] != '/') return NULL; +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; - const char *value = strchr(Str + 1, '/'); + const char *value = strchr(str + 1, '/'); if (value == NULL) return NULL; - char *key = new char[value - Str]; - strncpy(key, Str + 1, value - Str - 1); - key[value - Str - 1] = '\0'; + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; CBPlatform::strlwr(key); char *new_str; @@ -89,7 +89,7 @@ char *CBStringTable::GetKey(const char *Str) { strcpy(new_str, _stringsIter->_value.c_str()); if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { delete [] key; - char *Ret = GetKey(new_str); + char *Ret = getKey(new_str); delete [] new_str; return Ret; } else { @@ -102,17 +102,17 @@ char *CBStringTable::GetKey(const char *Str) { } ////////////////////////////////////////////////////////////////////////// -void CBStringTable::Expand(char **Str, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return; +void CBStringTable::expand(char **str, bool forceExpand) { + if (Game->_doNotExpandStrings && !forceExpand) return; - if (Str == NULL || *Str == NULL || *Str[0] != '/') return; + if (str == NULL || *str == NULL || *str[0] != '/') return; - char *value = strchr(*Str + 1, '/'); + char *value = strchr(*str + 1, '/'); if (value == NULL) return; - char *key = new char[value - *Str]; - strncpy(key, *Str + 1, value - *Str - 1); - key[value - *Str - 1] = '\0'; + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; CBPlatform::strlwr(key); value++; @@ -129,25 +129,25 @@ void CBStringTable::Expand(char **Str, bool ForceExpand) { } delete [] key; - delete [] *Str; - *Str = new_str; + delete [] *str; + *str = new_str; - if (strlen(*Str) > 0 && *Str[0] == '/') Expand(Str, ForceExpand); + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); } ////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { - if (Game->_doNotExpandStrings && !ForceExpand) return String; +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (Game->_doNotExpandStrings && !forceExpand) return string; - if (String == NULL || String[0] == '\0' || String[0] != '/') return String; + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; - const char *value = strchr(String + 1, '/'); - if (value == NULL) return String; + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; - char *key = new char[value - String]; - strncpy(key, String + 1, value - String - 1); - key[value - String - 1] = '\0'; + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; CBPlatform::strlwr(key); value++; @@ -163,28 +163,28 @@ const char *CBStringTable::ExpandStatic(const char *String, bool ForceExpand) { delete [] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return ExpandStatic(new_str, ForceExpand); + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); else return new_str; } ////////////////////////////////////////////////////////////////////////// -HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { +HRESULT CBStringTable::loadFile(const char *filename, bool clearOld) { Game->LOG(0, "Loading string table..."); - if (ClearOld) _strings.clear(); + if (clearOld) _strings.clear(); - uint32 Size; - byte *buffer = Game->_fileManager->readWholeFile(filename, &Size); + uint32 size; + byte *buffer = Game->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { Game->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); return E_FAIL; } - int Pos = 0; + int pos = 0; - if (Size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - Pos += 3; + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; if (Game->_textEncoding != TEXT_UTF8) { Game->_textEncoding = TEXT_UTF8; //Game->_textEncoding = TEXT_ANSI; @@ -192,15 +192,15 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { } } else Game->_textEncoding = TEXT_ANSI; - int LineLength = 0; - while (Pos < Size) { - LineLength = 0; - while (Pos + LineLength < Size && buffer[Pos + LineLength] != '\n' && buffer[Pos + LineLength] != '\0') LineLength++; + int lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - int RealLength = LineLength - (Pos + LineLength >= Size ? 0 : 1); - char *line = new char[RealLength + 1]; - strncpy(line, (char *)&buffer[Pos], RealLength); - line[RealLength] = '\0'; + int realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; char *value = strchr(line, '\t'); if (value == NULL) value = strchr(line, ' '); @@ -211,12 +211,12 @@ HRESULT CBStringTable::loadFile(const char *filename, bool ClearOld) { for (int i = 0; i < strlen(value); i++) { if (value[i] == '|') value[i] = '\n'; } - AddString(line, value, ClearOld); - } else if (line[0] != '\0') AddString(line, "", ClearOld); + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); } delete [] line; - Pos += LineLength + 1; + pos += lineLength + 1; } delete [] buffer; diff --git a/engines/wintermute/Base/BStringTable.h b/engines/wintermute/Base/BStringTable.h index ea35cf817b..059ff6fec0 100644 --- a/engines/wintermute/Base/BStringTable.h +++ b/engines/wintermute/Base/BStringTable.h @@ -37,14 +37,14 @@ namespace WinterMute { class CBStringTable : public CBBase { public: - const char *ExpandStatic(const char *String, bool ForceExpand = false); - HRESULT loadFile(const char *filename, bool DeleteAll = true); - void Expand(char **Str, bool ForceExpand = false); - HRESULT AddString(const char *Key, const char *Val, bool ReportDuplicities = true); + const char *expandStatic(const char *string, bool forceExpand = false); + HRESULT loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + HRESULT addString(const char *key, const char *val, bool reportDuplicities = true); CBStringTable(CBGame *inGame); virtual ~CBStringTable(); Common::HashMap _strings; - char *GetKey(const char *Str); + char *getKey(const char *str); private: Common::HashMap::iterator _stringsIter; diff --git a/engines/wintermute/UI/UIButton.cpp b/engines/wintermute/UI/UIButton.cpp index d10d4c7c89..4c16d708de 100644 --- a/engines/wintermute/UI/UIButton.cpp +++ b/engines/wintermute/UI/UIButton.cpp @@ -353,7 +353,7 @@ HRESULT CUIButton::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp index 5403081df0..ee583c8b89 100644 --- a/engines/wintermute/UI/UIEdit.cpp +++ b/engines/wintermute/UI/UIEdit.cpp @@ -221,7 +221,7 @@ HRESULT CUIEdit::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_X: diff --git a/engines/wintermute/UI/UIText.cpp b/engines/wintermute/UI/UIText.cpp index c52af0cf43..82f7701b80 100644 --- a/engines/wintermute/UI/UIText.cpp +++ b/engines/wintermute/UI/UIText.cpp @@ -216,7 +216,7 @@ HRESULT CUIText::loadBuffer(byte *buffer, bool complete) { case TOKEN_TEXT: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TEXT_ALIGN: diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp index 44d2bc5743..52c15ba904 100644 --- a/engines/wintermute/UI/UIWindow.cpp +++ b/engines/wintermute/UI/UIWindow.cpp @@ -382,7 +382,7 @@ HRESULT CUIWindow::loadBuffer(byte *buffer, bool complete) { case TOKEN_TITLE: setText((char *)params); - Game->_stringTable->Expand(&_text); + Game->_stringTable->expand(&_text); break; case TOKEN_TITLE_ALIGN: -- cgit v1.2.3