#include "VegaMain.h" #include "Tournament.h" int filter[8][2]; // [][0]=on/off status, [][1]=start column struct FontListDisplay : Display { virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { Font fnt = Courier(12); //Font(q, r.Height() - 2); // String txt = Font::GetFaceName(q); String txt = AsString(q); w.DrawRect(r, paper); w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(txt, fnt).cy) / 2, txt, fnt, ink); // <- Change is here - "w." no more needed } }; struct FontDisplay : Display { virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const { Font fnt = Courier(13).Bold(); //Font(q, r.Height() - 2); String txt = AsString(q); w.DrawRect(r, paper); w.DrawText(r.left + 2, r.top + (r.Height() - GetTextSize(txt, fnt).cy) / 2, txt, fnt, ink); // <- Change is here - "w." no more needed } }; VegaConsoleFrame::VegaConsoleFrame() { int i; CtrlLayout(*this); AddFrame(ThinOutsetFrame()); // editBoardPos.SetEditable(false).LeftPosZ(272, 44).TopPosZ(4, 19); for (i=1; i<=MAX_BOARDS; i++) editBoardPos.Add(AsString(i)); editBoardPos <<= AsString(1); //now set the window database slist.SetDisplay(Single()); editSearch.Tip(t_("Insert at least 5 characters\nspace included")); editSearch.WhenAction = THISBACK(EditSearchCB); // slist.WhenLeftDouble = THISBACK(RegisterPlayerCB); btnFilter.WhenAction = THISBACK(SetFilterCB); //now set the array ctrl of the status bar console.AddColumn("Time", t_("Time"), 8); console.AddColumn("Tournament", t_("Tournament"), 5); console.AddColumn("System", t_("System"), 5); console.AddColumn("Round", t_("Round"), 3); console.AddColumn("Total", t_(" Total, Avail, Bye"), 9).SetDisplay(Single()); // console.AddColumn("Total", t_(" Total, Avail, Bye"), 9); console.AddColumn("Action", t_("Action"), 13); console.AddColumn("Status", t_("Status"), 13); for (i=0; i<7; i++) console.HeaderTab(i).SetInk(SLtRed); console.Add(AsString(GetSysTime()), "...", "..." , "0", " 0, 0, 0", t_("Hello!"), t_("Open or Create a tournament!")); } void VegaConsoleFrame::SetConsoleDatabse(String fn, int flagDB) { filedbname = fn; IMPORT_DB = flagDB; console.Hide(); String dbtype; if (flagDB == 1) dbtype = t_("import from FIDE db: "); if (flagDB == 2) dbtype = t_("import from VEG db: "); if (flagDB == 3) dbtype = t_("import from Fixed Length db: "); if (flagDB == 4) dbtype = t_("import from FSI db: "); if (flagDB == 5) dbtype = t_("import from USCF db (regular): "); if (flagDB == 6) dbtype = t_("import from FSI db (quick): "); rt.SetQTF( NFormat("[s0;*@6;2 [*@0 %s ]%s]", dbtype, GetFileName(filedbname)) ); if (IMPORT_DB == 2 || IMPORT_DB == 4 || IMPORT_DB == 5 || IMPORT_DB == 6) btnFilter.Disable(); //no filter for *.veg and FSI format #ifdef PLATFORM_WIN32 if (IMPORT_DB == 1) { String s = ""; SetFilterDlg flt(s); flt.LoadFilter(TD.PATHVEGAPRG + "\\filter\\fide.flt"); //default filter for FIDE DB } #endif #ifdef PLATFORM_POSIX if (IMPORT_DB == 1) { String s = ""; SetFilterDlg flt(s); flt.LoadFilter(TD.PATHVEGAPRG + "/filter/fide.flt"); //default filter for FIDE DB } #endif if (TD.IS_CLOSED_REGISTRATION) PromptOK(t_("Because the registration are closed & you cannot import players & but only browse the DB")); } /* bool VegaConsoleFrame::Key(dword key, int count) { if(key == K_ENTER) { if (slist.IsCursor()) RegisterPlayerCB(); return true; // key accepted } return TopWindow::Key(key, count); } */ //search the name present in the editSearch widget void VegaConsoleFrame::EditSearchCB() { String pattern = TrimLeft(AsString(~editSearch)); // if ( IsNull(pattern) ) Exclamation(t_("Cannot find an empty string")); if (pattern.GetLength() <5) return; bool find = false; FileIn in(filedbname); slist.Clear(); while(!in.IsEof()) { String line = in.GetLine(); String s1, s2; s1 = ToLower(line); s2 = ToLower(pattern); if ( s1.Find(s2) >= 0 || pattern == "*****" ) { slist.Add(line); find = true; } } in.Close(); slist.Sort( StdValueOrder() ); if (!find) Exclamation(t_("not found")); } void VegaConsoleFrame::SetFilterCB() { int i = 0; FileIn in(filedbname); String testdb=""; for(i=0;i<=3;i++) { //get the first 3 lines of the batabase to be showed in the spyfilter editor testdb << "\n" << in.GetLine(); } in.Close(); SetFilterDlg flt(testdb); flt.Execute();//.Run(); } void VegaConsoleFrame::RegisterPlayerCB( Vector& playerData ) { int i = slist.GetCursor(); if (i<0 || slist.GetCount()==0) return; // if ( TD.NPlayer>TD.MAX_PLAYERS) return; if (TD.IS_CLOSED_REGISTRATION && !TD.IS_SWISS) { Exclamation(t_("Option not available for Round Robin tournament") ); return; } if (TD.IS_CLOSED_REGISTRATION) Exclamation(t_("You cannot add player from the DB.&Insert it from Edit Mask")); String record = AsString (slist.Get(i)); switch (IMPORT_DB) { case 1: ParsePlayerFIDE(record); break; case 2: ParsePlayerVEG(record); break; case 3: ParsePlayerFixedLenghtDB(record); break; case 4: ParsePlayerFSI(record); break; case 5: ParsePlayerUSCFregular(record); break; case 6: ParsePlayerUSCFquick(record); break; } slist.Remove(i); rt2.SetQTF( NFormat("[s0;*@6;2 %d]", TD.NPlayer) ); //build the vestor playerData.Add(play.name); playerData.Add(play.country); playerData.Add(play.data); playerData.Add(play.sex); playerData.Add(play.codetitle); playerData.Add( AsString(play.idfide) ); playerData.Add( AsString(play.ratingfide) ); playerData.Add( AsString(play.idnat) ); playerData.Add( AsString(play.ratingnat) ); playerData.Add(play.kcoeff); playerData.Add(play.isAvailable); } void VegaConsoleFrame::ParsePlayerFSI(String playerstr) { PlayerArchive player; if (TD.NPlayer < TD.MAX_PLAYERS) { int i = TD.NPlayer + 1; Vector field = Split( playerstr, ';', false); if (field.GetCount()>9 || field.GetCount()<9) { Exclamation( t_("record") + playerstr + t_("& in the wrong format!&check the DB")); return; } play.name = TrimLeft(field[0] ); // remove leading white spaces play.ratingnat = StrIntValue( field[1] ); play.codetitle = TrimLeft(field[2] ); //play.title = player[i].TitleToCode(); play.kcoeff = StrIntValue( field[3] ); if (play.kcoeff != 0) play.ratingfide = 0; else play.ratingfide = play.ratingnat; play.country = TrimLeft(field[4] ); play.data = TrimLeft(field[5] ); play.idfide = StrIntValue( field[6] ); play.idnat = StrIntValue( field[7] ); play.sex = TrimLeft( field[8] ) ; if ( play.sex!="m" && play.sex!="f") play.sex="m"; play.isAvailable = "1" ; // by default //TD.NPlayer++; } else Exclamation( t_("exceeded maximum number of players")); } void VegaConsoleFrame::ParsePlayerVEG(String playerstr) { if (TD.NPlayer < TD.MAX_PLAYERS) { int i = TD.NPlayer + 1; Vector field = Split( playerstr, ';', false); if ( /*field.GetCount()>10 ||*/ field.GetCount()<10) { Exclamation( t_("record") + playerstr + t_("& in the wrong format!&check the DB")); return; } // for (int j=0; j field = Split( name, ','); for (int j=0; j field = Split( playerstr, '\t', false); if ( field.GetCount()<6) { Exclamation( t_("record") + playerstr + t_("& in the wrong format!&check the DB")); return; } // for (int j=0; j field = Split( playerstr, '\t', false); if ( field.GetCount()<6) { Exclamation( t_("record") + playerstr + t_("& in the wrong format!&check the DB")); return; } // for (int j=0; j