long CBParser::GetObject(char **buf, TokenDesc *tokens, char **name, char **data) { SkipCharacters(buf, m_WhiteSpace); // skip comment lines. while (**buf == ';') { *buf = strchr(*buf, '\n'); m_ParserLine++; SkipCharacters(buf, m_WhiteSpace); } if (! **buf) // at end of file return PARSERR_EOF; // find the token. // for now just use brute force. Improve later. while (tokens->id != 0) { if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { // here we could be matching PART of a string // we could detect this here or the token list // could just have the longer tokens first in the list break; } ++tokens; } if (tokens->id == 0) { char *p = strchr(*buf, '\n'); if (p && p > *buf) { strncpy(m_LastOffender, *buf, MIN(255, p - *buf)); } else strcpy(m_LastOffender, ""); return PARSERR_TOKENNOTFOUND; } // skip the token *buf += strlen(tokens->token); SkipCharacters(buf, m_WhiteSpace); // get optional name *name = GetSubText(buf, '\'', '\''); // single quotes SkipCharacters(buf, m_WhiteSpace); // get optional data if (**buf == '=') // An assignment rather than a command/object. *data = GetAssignmentText(buf); else *data = GetSubText(buf, '{', '}'); return tokens->id; }
char *CBParser::GetAssignmentText(char **buf) { ++*buf; // skip the '=' SkipCharacters(buf, m_WhiteSpace); char *result = *buf; if (*result == '"') { result = GetSubText(buf, '"', '"'); } else { // now, we need to find the next whitespace to end the data char theChar; while ((theChar = **buf) != 0) { if (theChar <= 0x20) // space and control chars break; ++*buf; } **buf = 0; // null terminate it if (theChar) // skip the terminator ++*buf; } return result; }
bool LetterButton::Draw() { if(!Object::Draw()) return false; if(IsVisible()) { Clear(Color[COLOR_BUTTON_BACKGROUND]); if(GetStatus() == OBJECT_STATUS::HELD) // If we're active/clicked DrawRect(GetScreen(), GetRect(), Color[COLOR_BUTTON_OUTLINE_ACTIVE]); else // If we're idle DrawRect(GetScreen(), GetRect(), Color[COLOR_BUTTON_OUTLINE]); DrawButtonImage(GetScreen(), m_letter, GetRect().GetX2() - 25, GetRect().GetY2() - 25); DrawString(GetScreen(), GetText(), TTF::FONT_SIZE_TITLE, TTF::FONT_BOLD, GetRect().GetX() + 3, GetRect().GetY() + 9, Color[COLOR_BUTTON_TEXT]); DrawString(GetScreen(), GetSubText(), TTF::FONT_SIZE_REGULAR, TTF::FONT_REGULAR, GetRect().GetX() + 15, GetRect().GetY() + 21, Color[COLOR_BUTTON_TEXT]); } return true; }