void WordConsole::DelSent() { TextInputConsole txtId(Root, "请输入编号:", TEXTINPUT_LINE); txtId.Show(); if (txtId.Value != "") { size_t id = StringUtils::FromString<size_t>(txtId.Value); if (txtId.Value != StringUtils::ToString(id)) { // is not number return; } ConfirmConsole cc(Root, "您确定要删除吗?", false); cc.Show(); if (cc.Value) { Globals::CurrentUser->DelSentence(Word, id - 1); Globals::UserSentDB->Sync(); } } }
raceC* raceLoad(char* bf, char* e) { raceC* race = new raceC; char* s = bf; // id s = txtId(race->Id, s, sizeof(race->Id)); if(s == NULL) { sprintf(e, "bad race id `%s`", txtWordTerminate(bf)); goto ERROR; } // add error token e += sprintf(e, "%s/", race->Id); // same line, growth race->Growth = strtol(s, &s, 10); if(race->Growth > +50) race->Growth = +50; // silently cut sensless values if(race->Growth < -50) race->Growth = -50; // same line, specials s = txtReadSpecials(s, e, raceSpcA); if(s == NULL) goto ERROR; for(spcC* spc = raceSpcA; spc->Id; spc++) if(spc->Flag & SPC_ACTIVE) race->Spc |= spc->Code; if(!race->Spc) race->Spc = RACE_LAND; // set default settling ability // name, info, CityFN, LandFN s = txtSkipLine(s); txtString(race->Name, s, sizeof(race->Name)); s = txtSkipLine(s); txtString(race->Info, s, sizeof(race->Info)); s = txtSkipLine(s); txtString(race->City.Fn, s, sizeof(race->City.Fn)); s = txtSkipLine(s); txtString(race->Land.Fn, s, sizeof(race->Land.Fn)); // language s = txtSearch("[LANG]", bf); if(s == NULL) { sprintf(e, "no [LANG] section"); goto ERROR; } for(; *s >= 'A' && *s <= 'Z'; s = txtSkipLine(s)) race->Language.AddStr(s); if(raceCheckLang(race, "NAMEF", e)) goto ERROR; if(raceCheckLang(race, "NAMEM", e)) goto ERROR; if(raceCheckLang(race, "CITY", e)) goto ERROR; // blocks { blockC **b; s = bf; b = &race->Flesh; while(s = txtSearch("[BLO]", s)) { *b = fleshLoadBlock(s, e); if(*b == NULL) goto ERROR; b = &(*b)->Next; } } // blds race->Blds = bldLoadAll(bf, e); if(race->Blds == NULL) goto ERROR; // units if(unitLoadExRace(bf, e, race)) goto ERROR; // population { s = txtSearch("[POP]", bf); if(!s) { sprintf(e, "[POP] not found"); goto ERROR; } s = fleshRead(s, e, &race->Farmer, race->Flesh); if(!s) goto ERROR; s = txtSkipLine(s); s = fleshRead(s, e, &race->Worker, race->Flesh); if(!s) goto ERROR; s = txtSkipLine(s); s = fleshRead(s, e, &race->Rebel , race->Flesh); if(!s) goto ERROR; s = txtSkipLine(s); fleshApplyDefaultParts(&race->Farmer, race->Flesh); fleshApplyDefaultParts(&race->Worker, race->Flesh); fleshApplyDefaultParts(&race->Rebel, race->Flesh); } // success!! return race; ERROR: delete race; return NULL; }