inline wxString TxtHandler::ReadLine(bool strip) { wxString ret; // See if we have any lines on the stack already if (! m_lastLines.empty()) { ret = m_lastLines.top(); m_lastLines.pop(); } else // Noting in the stack, read a line from the stream ret = m_inText->ReadLine(); ++m_line; if (strip) return ret.Trim(true).Trim(false); // Left and right sides return ret; }
// read two sequential lines inline void GetLines(wxTextInputStream& text, wxString& line1, wxString& line2) { line1 = text.ReadLine().Trim().Trim(false); line2 = text.ReadLine().Trim().Trim(false); }
void read_mse1_card(Set& set, wxFileInputStream& f, wxTextInputStream& file) { CardP card(new Card(*set.game)); while (!f.Eof()) { // read a line String line = file.ReadLine(); if (line.empty()) continue; Char type = line.GetChar(0); line = line.substr(1); // interpret this line switch (type) { case 'A': { // done set.cards.push_back(card); return; } case 'B': { // name card->value(_("name")) = to_script(line); break; } case 'C': case 'D': { // image filename LocalFileName image_file = set.newFileName(_("image"),_("")); // a new unique name in the package if (wxCopyFile(line, set.nameOut(image_file), true)) { card->value(_("image")) = script_local_image_file(image_file); } break; } case 'E': { // super type card->value(_("super type")) = to_script(line); break; } case 'F': { // sub type card->value(_("sub type")) = to_script(line); break; } case 'G': { // casting cost card->value(_("casting cost")) = to_script(line); break; } case 'H': { // rarity String rarity; if (line == _("(U)")) rarity = _("uncommon"); else if (line == _("(R)")) rarity = _("rare"); else rarity = _("common"); card->value(_("rarity")) = to_script(rarity); break; } case 'I': { // power/thoughness size_t pos = line.find_first_of(_('/')); if (pos != String::npos) { card->value(_("power")) = to_script(line.substr(0, pos)); card->value(_("toughness")) = to_script(line.substr(pos+1)); } break; } case 'J': { // rule text or part of text append_line(card->value(_("rule text")), line); break; } case 'K': { // flavor text or part of text append_line(card->value(_("flavor text")), line); break; } case 'L': { // card color (if not default) // decode color String color; if (line == _("1")) color = _("white"); else if (line == _("2")) color = _("blue"); else if (line == _("3")) color = _("black"); else if (line == _("4")) color = _("red"); else if (line == _("5")) color = _("green"); else if (line == _("6")) color = _("colorless"); else if (line == _("7")) color = _("land"); else if (line == _("9")) color = _("multicolor"); else color = _("colorless"); card->value(_("card color")) = to_script(color); break; } default: { throw ParseError(_("Not a valid MSE1 file")); } } } }