void Music::getSongNames(Common::StringArray &songs) { songs.clear(); if (IS_SERRATED_SCALPEL) { if (IS_3DO) { Common::FSDirectory gameDirectory(ConfMan.get("path")); Common::FSDirectory *musicDirectory = gameDirectory.getSubDirectory("music"); Common::ArchiveMemberList files; musicDirectory->listMatchingMembers(files, "*_mw22.aifc"); for (Common::ArchiveMemberList::iterator i = files.begin(); i != files.end(); ++i) { Common::String name = (*i)->getName(); name.erase(name.size() - 10); songs.push_back(name); } } else { for (int i = 0; i < ARRAYSIZE(SONG_NAMES); i++) { songs.push_back(SONG_NAMES[i]); } } } else { Common::StringArray fileList; _vm->_res->getResourceNames("music.lib", fileList); for (Common::StringArray::iterator i = fileList.begin(); i != fileList.end(); ++i) { if ((*i).matchString("*.XMI", true)) { (*i).erase((*i).size() - 4); songs.push_back(*i); } } } Common::sort(songs.begin(), songs.end()); }
Common::String WidgetBase::splitLines(const Common::String &str, Common::StringArray &lines, int maxWidth, uint maxLines) { Talk &talk = *_vm->_talk; const char *strP = str.c_str(); // Loop counting up lines lines.clear(); do { int width = 0; const char *spaceP = nullptr; const char *lineStartP = strP; // Find how many characters will fit on the next line while (width < maxWidth && *strP && ((byte)*strP < talk._opcodes[OP_SWITCH_SPEAKER] || (byte)*strP == talk._opcodes[OP_NULL])) { width += _surface.charWidth(*strP); // Keep track of the last space if (*strP == ' ') spaceP = strP; ++strP; } // If the line was too wide to fit on a single line, go back to the last space // if there was one, or otherwise simply break the line at this point if (width >= maxWidth && spaceP != nullptr) strP = spaceP; // Add the line to the output array lines.push_back(Common::String(lineStartP, strP)); // Move the string ahead to the next line if (*strP == ' ' || *strP == 13) ++strP; } while (*strP && (lines.size() < maxLines) && ((byte)*strP < talk._opcodes[OP_SWITCH_SPEAKER] || (byte)*strP == talk._opcodes[OP_NULL])); // Return any remaining text left over return *strP ? Common::String(strP) : Common::String(); }