void wxMainFrame::ProcessChatExit(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  if (tok==_T("OK"))
  {
    m_TEDProtocol->SetUserChatRoomID(0);
    // IF WE SET TRY ROOM TO ZERO WE CAN HAVE PROBLEMS BECAUSE
    // IF WE DO A CALL TO CHATEXIT AND THEN WE CALL CHATENTER
    // WE ARE GOING TO RECEIVE A CHATEXIT MESSAGE AFTER SETTING TRYROOM
    // SO WE ARE GOING TO UNSET IT AND THAT'S NOT GOOD
//    m_TEDProtocol->SetTryRoomID(0);
    m_TEDProtocol->SetChatting(FALSE);
    m_ChatWnd->UsuariosListCtrl->DeleteAllItems();
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nCX ")+
      tok+_T(" ")+msgtok.GetString());
    m_TEDProtocol->SetUserChatRoomID(0);
  }
//  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
void wxMainFrame::ProcessDeckNew(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  wxInt32 deckid;
  wxString deckname;
  long int longvalue;

  deckname=m_TEDProtocol->GetNewDeck();
  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // EN OK <id_baraj> | EN NO
  if (tok==_T("OK"))
  {
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    deckid=longvalue;
    m_DeckWnd->ProcessDeckNew(deckname,deckid);
  }
  else if (tok==_T("NO"))
  {
    // WE NEED TO DO SOMETHING BETTER WITH THIS
    tok=msgtok.GetNextToken();
    ::wxSafeShowMessage(_("Titanes"),_("No puedes tener más barajas."));
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEM ")+
      tok+_T(" ")+msgtok.GetString());
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
void wxMainFrame::ProcessChatMessage(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  long int longvalue;
  wxInt32 userid;
  wxString rcvmsg;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // CM <type> <user_id> <mensaje>
  if (tok==_T("B"))
  {
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    userid=longvalue;
    rcvmsg=msgtok.GetString();
    m_ChatWnd->ProcessBroadcastChatMessage(userid,rcvmsg);
  }
  else if (tok==_T("P"))
  {
    // IT IS SUPPOSED WE SHOULD NOT GET THIS KIND OF CHAT MESSAGE
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nCM ")+
      tok+_T(" ")+msgtok.GetString());
  }
//  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
void wxMainFrame::ProcessGameSelect(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();

  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
/*
			} else if (Msg[0].Equals("GE")) {
				GameSelect (Msg);
*/
}
void wxMainFrame::ProcessDeckExit(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  m_TEDProtocol->SetEditing(FALSE);
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
/*
			} else if (Msg[0].Equals("EX")) {
				User.Editing = 0;
*/
}
void wxMainFrame::ProcessDuelCancelled(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();

  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
/*
			} else if (Msg[0].Equals("DC")) {
				DuelCancel (Msg);
*/
}
void wxMainFrame::ProcessDuelChallenged(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  wxInt32 userid;
  long int longvalue;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // DH <user_id>
  tok.ToLong(&longvalue);
  userid=longvalue;
  m_ChatWnd->ProcessDuelChallenged(userid);
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
void wxMainFrame::ProcessGameText(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();

  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
/*
			if (Msg[0].Equals("GT")) {
				String Ms = "";
				for (int i = 1; i < Msg.Length; i++) Ms += Msg[i] + " ";
				ChatWrite (this.OponentName, Ms);
*/
}
void wxMainFrame::ProcessDeckActive(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // EA OK | IM
  if (tok==_T("OK"))
  {
    m_DeckWnd->ProcessDeckActive();
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEA ")+
      tok+_T(" ")+msgtok.GetString());
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #10
0
void wxMainFrame::ProcessChatUser(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  struct TEDChatter *chatter;
  long int longvalue;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // CU <tipo> <user_num> [<user_name> <deck value> <rank>]
  if (tok==_T("I"))
  {
    chatter=new struct TEDChatter;
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    chatter->Id=longvalue;
    tok=msgtok.GetNextToken();
    chatter->Name=tok;
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    chatter->DeckValue=longvalue;
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    chatter->Rank=longvalue;
    m_ChatWnd->AddUser(chatter);
  }
  else if (tok==_T("O"))
  {
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    m_ChatWnd->RemoveUser(longvalue);
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nCU ")+
    tok+_T(" ")+msgtok.GetString());
  }
m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #11
0
void wxMainFrame::ProcessChatEnter(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  if (tok==_T("OK"))
  {
    m_TEDProtocol->SetUserChatRoomID(m_TEDProtocol->GetTryRoomID());
    m_TEDProtocol->SetTryRoomID(0);
    m_TEDProtocol->SetChatting(TRUE);
  }
  else if (tok==_T("NO"))
  {
    tok=msgtok.GetNextToken();
    if (tok==_T("1"))
    {
      ::wxSafeShowMessage(_("Titanes"),_T("La sala está llena."));
    }
    else if (tok==_T("2"))
    {
      ::wxSafeShowMessage(_("Titanes"),_T("La sala es incorrecta."));
    }
    else
    {
      ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEC NO ")+
        tok+_T(" ")+msgtok.GetString());
    }
    m_TEDProtocol->SetTryRoomID(0);
    m_TEDProtocol->SetUserChatRoomID(0);
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.EC \n")+
      tok+msgtok.GetString());
  }
//  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #12
0
void wxMainFrame::ProcessDeckDescribe(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  long int longvalue;
  wxInt32 deckid;
  wxInt32 carduid;
  wxInt32 cardid;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // ED <id_baraja> <uid_carta> <id_carta>
  // ED OK
  if (tok!=_T("OK"))
  {
    tok.ToLong(&longvalue);
    deckid=longvalue;
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    carduid=longvalue;
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    cardid=longvalue;
    m_DeckWnd->ProcessDeckDescribe(deckid,carduid,cardid);
/*
    else
    {
      ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nED ")+
        tok+_T(" ")+msgtok.GetString());
    }
*/
  }
  else
  {
    // WE HAVE FINISHED GETTING CARD LIST
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #13
0
void wxMainFrame::ProcessDeckList(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  long int longvalue;
  wxInt32 deckid;
  wxString deckname;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // EL <id_baraja> <nombre>
  // EL OK
  if (tok!=_T("OK"))
  {
    if (m_TEDProtocol->IsGettingDeckList()==TRUE)
    {
      // WE SHOULD CHECK IF WE ARE GETTING A CORRECT DECKID
      // BUT ON THIS MOMENT WE SUPPOSSE EVERYTHING IS FINE
      tok.ToLong(&longvalue);
      deckid=longvalue;
      deckname=msgtok.GetString();
      m_DeckWnd->ProcessDeckList(deckid,deckname);
    }
    else
    {
      ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEL ")+
        tok+_T(" ")+msgtok.GetString());
    }
  }
  else
  {
    // WE HAVE FINISHED GETTING DECK LIST
    m_TEDProtocol->SetGettingDeckList(FALSE);
    m_DeckWnd->LoadReserveDeck();
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #14
0
void wxMainFrame::ProcessDeckEdit(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  wxInt32 deckid;
  long int longvalue;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();

  // EE OK <id_active_deck>
  if (tok==_T("OK"))
  {
    tok=msgtok.GetNextToken();
    tok.ToLong(&longvalue);
    deckid=longvalue;
    m_TEDProtocol->SetEditing(TRUE);
    m_TEDProtocol->SetActiveDeckID(deckid);
    m_DeckWnd->ClearDecks();
    m_TEDProtocol->DeckList();
/*
			for (int i = 0; i < 20; i++)
      {
        Decks[i] = null;
      }
			this.lblActive.Text = "Mazo: " + this.ActiveDeck;
			this.lblGold.Text =	"Oro: " + User.Gold + " €";
*/
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEE ")+
      tok+_T(" ")+msgtok.GetString());
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #15
0
void wxMainFrame::ProcessDeckGet(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  long int longvalue;
  wxInt32 gold;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // ED <...> | EG NO
  // EG <oro>
  if (tok!=_T("NO"))
  {
    tok.ToLong(&longvalue);
    gold=longvalue;
    m_DeckWnd->ProcessDeckGet(gold);
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("No tienes suficiente dinero para comprar otro sobre."));
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #16
0
void wxMainFrame::ProcessGameStart(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  wxString name;
  wxInt32 deckvalue;
  wxInt32 rank;
  long int longvalue;

  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // GS <user_name> <deck value> <rank>
  name=tok;
  tok.ToLong(&longvalue);
  deckvalue=longvalue;
  tok=msgtok.GetNextToken();
  tok.ToLong(&longvalue);
  rank=longvalue;
//  StartDuelMode();
  m_DuelWnd->ProcessGameStart(name,deckvalue,rank);

  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
}
Beispiel #17
0
bool ChatPanel::Say(const wxString& message) //FIXME: remove all parsing / tokenizing / ... to dedicated file
{
	static const unsigned int flood_threshold = 5;
	slLogDebugFunc("");
	wxStringTokenizer lines(message, _T('\n'));
	if (lines.CountTokens() > flood_threshold) {
		PasteDialog dl(this, wxString::Format(_("Are you sure you want to paste %d lines?"), lines.CountTokens()));
		switch (dl.ShowModal()) {
			case wxID_NO:
				return true;
			case PasteDialog::pasteButtonReturnCode: {
				wxString url = Paste2Pastebin(message);
				if (url != wxEmptyString && wxStringTokenizer(url, _T('\n')).CountTokens() <= flood_threshold) {
					Say(url);
					return true;
				} else {
					customMessageBoxModal(SL_MAIN_ICON, wxString::Format(_("Failed to post to %s"), _T("paste.springfiles.com")));
					return false;
				}
			}
			default:
				break;
		}
	}
	while (lines.HasMoreTokens()) {
		wxString line = lines.GetNextToken();
		wxLogDebug(_T( "line: %s" ), line.c_str());

		if (line == "/help") {
			ui().ConsoleHelp();
			return true;
		}

		if (line == "/channels") {
			ui().mw().ShowChannelChooser();
			return true;
		}

		if (line == _T( "/ver" )) {
			//!this instance is not replaced with GetAppname for sake of help/debug online
			OutputLine(wxString::Format(_("You have %s."), GetSpringlobbyAgent()), sett().GetChatColorNormal());
			return true;
		}

		if (line == _T( "/clear" )) {
			m_chatlog_text->SetValue(wxEmptyString);
			return true;
		}

		if (m_type == CPT_Channel) {

			if (m_channel == 0) {
				OutputError(_("You are not in channel or channel does not exist."));
				return true;
			}
			if (line.StartsWith(_T( "/" ))) {
				if (m_channel->ExecuteSayCommand(STD_STRING(line)))
					return true;
				if (m_channel->GetServer().ExecuteSayCommand(STD_STRING(line)))
					return true;
				OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str()));
				return true;
			}
			m_channel->Say(STD_STRING(line));

		} else if (m_type == CPT_Battle) {

			if (m_battle == 0) {
				OutputError(_("You are not in battle or battle does not exist, use /help for a list of available commands."));
				return true;
			}
			if (line.StartsWith(_T( "/" ))) {
				if (m_battle->ExecuteSayCommand(STD_STRING(line)))
					return true;
				if (m_battle->GetServer().ExecuteSayCommand(STD_STRING(line)))
					return true;
				OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str()));
				return true;
			}
			m_battle->Say(STD_STRING(line));

		} else if (m_type == CPT_User) {

			if (m_user == 0) {
				OutputError(_("User is offline."));
				return true;
			}
			if (line.StartsWith(_T( "/" ))) {
				if (m_user->ExecuteSayCommand(STD_STRING(line)))
					return true;
				if (m_user->GetServer().ExecuteSayCommand(STD_STRING(line)))
					return true;
				OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str()));
				return true;
			}
			m_user->Say(STD_STRING(line));

		} else if (m_type == CPT_Server) {
			if (m_server == 0) {
				OutputError(_("Not connected to server"));
				return true;
			}

			if (line.StartsWith(_T( "/" ))) {
				if (m_server->ExecuteSayCommand(STD_STRING(line)))
					return true;
				OutputError(wxString::Format(_("Command (%s) does not exist, use /help for a list of available commands."), line.c_str()));
				return true;
			}

			m_server->SendCmd(STD_STRING(line), "");
			OutputLine(_("Sent: \"") + line + _T("\""), sett().GetChatColorNormal());
		}
	}
	return true;
}
Beispiel #18
0
void wxMainFrame::ProcessDeckMove(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;
  struct TEDMovingCard *movingcard;

  movingcard=m_TEDProtocol->GetMovingCard();
  msgtok=wxStringTokenizer(msg);
  tok=msgtok.GetNextToken();
  tok=msgtok.GetNextToken();
  // EM OK | EM NO <motivo>
  if (tok==_T("OK"))
  {
    m_DeckWnd->ProcessDeckMove(movingcard);
  }
  else if (tok==_T("NO"))
  {
    // WE NEED TO DO SOMETHING BETTER WITH THIS
    tok=msgtok.GetNextToken();
    ::wxSafeShowMessage(_("Titanes"),_("La carta no cabe en la baraja destino"));
  }
  else
  {
    ::wxSafeShowMessage(_("Titanes"),_T("El servidor ha respondido con un comando desconocido.\nEM ")+
      tok+_T(" ")+msgtok.GetString());
  }
  m_ChatWnd->MensajesTextCtrl->AppendText(msg+_T("\n"));
/*
			} else if (Msg[0].Equals("EM")) {
			} else {
				ListView lstFrom = (MovingDeck == 1)?lstDeckB:lstDeckA;
				ListView lstTo = (MovingDeck == 1)?lstDeckA:lstDeckB;
				clsDeck deckFrom = Decks[NumBaraja(MovingDeck == 1?cbxDeckB.Text:cbxDeckA.Text)];
				clsDeck deckTo = Decks[NumBaraja(MovingDeck == 1?cbxDeckA.Text:cbxDeckB.Text)];
				
				clsEditCard c = (clsEditCard) deckFrom.Cards[MovingId];
				c.UIDs.Remove(this.MovingUID);
				int nu = 0;
				for (int i = 0; i < lstFrom.Items.Count; i++) {
					if (lstFrom.Items[i].SubItems[6].Text.Equals ("" + MovingId)) nu = i;
				}
				if (c.UIDs.Count == 0) {
					// Era la ultima
					deckFrom.Cards.Remove(c.Id);
					lstFrom.Items.RemoveAt(nu);
				} else {
					lstFrom.Items[nu].SubItems[1].Text = "" + c.UIDs.Count;
				}
				if (deckTo.Cards[this.MovingId] == null) {
					// Añadimos (es la primera)
					clsEditCard aux = new clsEditCard();
					aux.Attack = c.Attack; aux.Cost = c.Cost;
					aux.Defense = c.Defense; aux.Freq = c.Freq;
					aux.Gold = c.Gold; aux.Id = c.Id;
					aux.Max = c.Max; aux.Name = c.Name;
					aux.Text = c.Text; aux.Type = c.Type;
					aux.UIDs = new ArrayList();
					aux.UIDs.Add (this.MovingUID);
					deckTo.Cards.Add(this.MovingId, aux);
					lstTo.Items.Add (HazFila(aux));
				} else {
					// Ya existe esa carta, añadimos el UID
					((clsEditCard)deckTo.Cards[MovingId]).UIDs.Add (MovingUID);
					for (int i = 0; i < lstTo.Items.Count; i++) {
						if (lstTo.Items[i].SubItems[6].Text.Equals ("" + MovingId)) {
							lstTo.Items[i].SubItems[1].Text = "" + ((clsEditCard)deckTo.Cards[MovingId]).UIDs.Count;
						}
					}
				}
				User.Editing = 2;
				UpdateDeckInfo ();
			}
*/
}
Beispiel #19
0
/** @brief Processes a single line from a LOF text file, doing whatever is
 * indicated on the line.
 *
 * This function should just return for lines it cannot deal with, and the
 * caller will continue to the next line of the input file
 */
void LOFImportFileHandle::lofOpenFiles(wxString* ln)
{  
   wxStringTokenizer tok(*ln, wxT(" "));
   wxStringTokenizer temptok1(*ln, wxT("\""));
   wxStringTokenizer temptok2(*ln, wxT(" "));
   int tokenplace = 0;
   
   wxString targetfile;
   wxString tokenholder = tok.GetNextToken();
   
   if (tokenholder.IsSameAs(wxT("window"), false))
   {
      // set any duration/offset factors for last window, as all files were called
      doDuration();
      doScrollOffset();
      
      if (windowCalledOnce)
      {
         mProject = CreateNewAudacityProject();
      }

      windowCalledOnce = true;
      
      while (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();
         
         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            
            if (Internat::CompatibleToDouble(tokenholder, &scrollOffset))
            {
               callScrollOffset = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid window offset in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE);
            }
               
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
         }
         
         if (tokenholder.IsSameAs(wxT("duration"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            
            if (Internat::CompatibleToDouble(tokenholder, &durationFactor))
            {
               callDurationFactor = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid duration in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE);
            }
         }     // End if statement

         if (tokenholder.IsSameAs(wxT("#")))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }
      }     // End while loop
   }        // End if statement handling "window" lines
   
   else if (tokenholder.IsSameAs(wxT("file"), false))
   {

      // To identify filename and open it
      tokenholder = temptok1.GetNextToken();
      targetfile = temptok1.GetNextToken();

      // If path is relative, make absolute path from LOF path
      if(!wxIsAbsolutePath(targetfile)) {
         wxFileName fName(targetfile);
         fName.Normalize(wxPATH_NORM_ALL, mLOFFileName->GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
         if(fName.FileExists()) {
            targetfile = fName.GetFullPath();
         }
      }
     
      #ifdef USE_MIDI
      // If file is a midi
      if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false)
          ||  targetfile.AfterLast(wxT('.')).IsSameAs(wxT("midi"), false))
      {
         NoteTrack *nTrack = new NoteTrack(mProject->GetDirManager());
         
         if (::ImportMIDI(targetfile, nTrack))
            mProject->GetTracks()->Add(nTrack);
         else
            delete nTrack;
      }
      
      // If not a midi, open audio file
      else
      {
      #else // !USE_MIDI
         /* if we don't have midi support, go straight on to opening as an
          * audio file. TODO: Some sort of message here? */
      {
      #endif // USE_MIDI
         mProject->OpenFile(targetfile);
      }

      // Set tok to right after filename
      temptok2.SetString(targetfile);
      tokenplace = temptok2.CountTokens();
      
      for (int i = 0; i < tokenplace; i++)
         tokenholder = tok.GetNextToken();
      
      if (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();
         
         if (tokenholder.IsSameAs(wxT("#")))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }
         
         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            double offset;
           
            // handle an "offset" specifier
            if (Internat::CompatibleToDouble(tokenholder, &offset))
            {
               Track *t;
               TrackListIterator iter(mProject->GetTracks());
               
               t = iter.First();
               
               for (int i = 1; i < CountNumTracks(mProject) - 1; i++)
                  t = iter.Next();

               // t is now the last track in the project, unless the import of
               // all tracks failed, in which case it will be null. In that
               // case we return because we cannot offset a non-existent track.
               if (t == NULL) return;
#ifdef USE_MIDI
               if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false) ||
                   targetfile.AfterLast(wxT('.')).IsSameAs(wxT("midi"), false))
               {
                  wxMessageBox(_("MIDI tracks cannot be offset individually, only audio files can be."),
                               _("LOF Error"), wxOK | wxCENTRE);
               }
               else
#endif
               {
                  if (CountNumTracks(mProject) == 1)
                     t->SetOffset(offset);
                  else
                  {
                     if (t->GetLinked())
                        t->SetOffset(offset);
                     
                     t = iter.Next();
                     t->SetOffset(offset);
                  }
               }
            } // end of converting "offset" argument
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid track offset in LOF file."),
                            _("LOF Error"), wxOK | wxCENTRE);
            }
         }     // End if statement for "offset" parameters
      }     // End if statement (more tokens after file name)
   }     // End if statement "file" lines
   
   else if (tokenholder.IsSameAs(wxT("#")))
Beispiel #20
0
void wxMainFrame::ProcessMessage(wxString msg)
{
  wxStringTokenizer msgtok;
  wxString tok;

  msgtok=wxStringTokenizer(msg);
  if (msgtok.HasMoreTokens()==FALSE)
  {
    ::wxLogFatalError(_("Error en la respuesta del servidor."));
    return;
  }
  tok=msgtok.GetNextToken();
  // MESSAGE CODES WE CAN RECEIVE IN NEUTRAL MODE
  if (tok==_T("CE"))
  {
    ProcessChatEnter(msg);
  }
  else if (tok==_T("EE"))
  {
    ProcessDeckEdit(msg);
  }
  // MESSAGE CODES WE CAN RECEIVE IN CHAT MODE
  else if (tok==_T("GS"))
  {
    ProcessGameStart(msg);
  }
  else if (tok==_T("CX"))
  {
    ProcessChatExit(msg);
  }
  else if (tok==_T("CM"))
  {
    ProcessChatMessage(msg);
  }
  else if (tok==_T("DH"))
  {
    ProcessDuelChallenged(msg);
  }
  else if (tok==_T("DC"))
  {
    ProcessDuelCancelled(msg);
  }
  else if (tok==_T("CU"))
  {
    ProcessChatUser(msg);
  }
  // MESSAGE CODES WE CAN RECEIVE IN DECK MODE
  else if (tok==_T("EL"))
  {
    ProcessDeckList(msg);
  }
  else if (tok==_T("ED"))
  {
    ProcessDeckDescribe(msg);
  }
  // THIS COMMAND IS NOT GOING TO BE IMPLEMENTED
  // USERS MUST HAVE A FRESH COPY OF CARDS ON DISK
/*
  else if (tok==_T("EC"))
  {
    ProcessDeckCard(msg);
  }
*/
  else if (tok==_T("EN"))
  {
    ProcessDeckNew(msg);
  }
  else if (tok==_T("EM"))
  {
    ProcessDeckMove(msg);
  }
  else if (tok==_T("EK"))
  {
    ProcessDeckClear(msg);
  }
  else if (tok==_T("ER"))
  {
    ProcessDeckRename(msg);
  }
  else if (tok==_T("EA"))
  {
    ProcessDeckActive(msg);
  }
  else if (tok==_T("EG"))
  {
    ProcessDeckGet(msg);
  }
  else if (tok==_T("EX"))
  {
    ProcessDeckExit(msg);
  }
  // MESSAGE CODES WE CAN RECEIVE IN DUEL MODE
  else if (tok==_T("GZ"))
  {
    ProcessGameFinish(msg);
  }
  else if (tok==_T("GX"))
  {
    ProcessGameExit(msg);
  }
  else if (tok==_T("GI"))
  {
    ProcessGameInfo(msg);
  }
  else if (tok==_T("GF"))
  {
    ProcessGamePhase(msg);
  }
  else if (tok==_T("GC"))
  {
    ProcessGameCard(msg);
  }
  else if (tok==_T("GT"))
  {
    ProcessGameText(msg);
  }
  else if (tok==_T("GE"))
  {
    ProcessGameSelect(msg);
  }
  else if (tok==_T("GU"))
  {
    ProcessGameUse(msg);
  }
  else
  {
    ProcessUnknownMessage(msg);
  }
}
Beispiel #21
0
               }
            }            
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid track offset in LOF file."),
                            _("LOF Error"), wxOK | wxCENTRE, gParentWindow);
            }
         }     // End if statement
      }     // End if statement
   }     // End if statement
   
   else if (tokenholder.IsSameAs(wxT("#")))
   {
      // # indicates comments; ignore line
      tok = wxStringTokenizer(wxT(""), wxT(" "));
   }
   else
   {
      // Couldn't parse a line
   }
}

void LOFImportFileHandle::doDuration()
{
   if (callDurationFactor)
   {
      double longestDuration = mProject->GetTracks()->GetEndTime();
      double realZoomValue = ((longestDuration/durationFactor)*(mProject->GetZoom()));
      mProject->Zoom(realZoomValue);
      callDurationFactor = false;
Beispiel #22
0
bool ChatPanel::Say( const wxString& message )
{
	static const unsigned int flood_threshold = 5;
	wxLogDebugFunc( message );
	wxStringTokenizer lines( message, _T( '\n' ) );
	if ( lines.CountTokens() > flood_threshold ) {
		PasteDialog dl ( this, wxString::Format(
			_( "Are you sure you want to paste %d lines?" ), lines.CountTokens() ) );
		switch ( dl.ShowModal() ) {
			case wxID_NO :
				return true;
			case PasteDialog::pasteButtonReturnCode : {
				wxString url = Paste2Pastebin( message );
				if ( url != wxEmptyString && wxStringTokenizer( url, _T( '\n' )).CountTokens() <= flood_threshold ) {
					Say( url );
					return true;
				}
				else {
					customMessageBoxNoModal( SL_MAIN_ICON, _("Failed to post to pastebin.com.") );
					return false;
				}
			}
			default:
				break;
		}
	}
	while ( lines.HasMoreTokens() ) {
		wxString line = lines.GetNextToken();
		wxLogMessage( _T( "line: %s" ), line.c_str() );

		if ( line.Find( '/' ) == 0 ) {
			if ( ui().ExecuteSayCommand( line ) ) return true;
		}

		if ( line == _T( "/ver" ) ) {
			//!this instance is not replaced with GetAppname for sake of help/debug online
			OutputLine( _( " You have SpringLobby v" ) + GetSpringLobbyVersion(), sett().GetChatColorNormal() , sett().GetChatFont() );
			return true;
		}

		if ( line == _T( "/clear" ) ) {
            m_chatlog_text->SetValue( _T("") );
			return true;
		}

		if ( m_type == CPT_Channel ) {

			if ( m_channel == 0 ) {
				OutputLine( _( " You are not in channel or channel does not exist." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_channel->ExecuteSayCommand( line ) ) return true;
				if ( m_channel->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_channel->Say( line );

		} else if ( m_type == CPT_Battle ) {

			if ( m_battle == 0 ) {
				OutputLine( _( " You are not in battle or battle does not exist, use /help for a list of available commands." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_battle->ExecuteSayCommand( line ) ) return true;
				if ( m_battle->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_battle->Say( line );

		} else if ( m_type == CPT_User ) {

			if ( m_user == 0 ) {
				OutputLine( _( " User is offline." ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_user->ExecuteSayCommand( line ) ) return true;
				if ( m_user->GetServer().ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}
			m_user->Say( line );

		} else if ( m_type == CPT_Server ) {
			if ( m_server == 0 ) return true;

			if ( line.StartsWith( _T( "/" ) ) ) {
				if ( m_server->ExecuteSayCommand( line ) ) return true;
				OutputLine( wxString::Format( _( " Error: Command (%s) does not exist, use /help for a list of available commands." ), line.c_str() ), sett().GetChatColorError(), sett().GetChatFont() );
				return true;
			}

            //we need to disable the channel tab if leaving manually
            if (line.Upper().StartsWith( _T( "LEAVE" ) ) )
            {
                wxString channame = line.AfterFirst(' ').BeforeFirst(' ');
                try
                {
									Channel& chan = m_server->GetChannel( channame );
									chan.Leave();
									chan.uidata.panel = 0;
								}
								catch( assert_exception ) {}
            }

			m_server->SendRaw( line );
			OutputLine( _( " Sent: \"" ) + line + _( "\"" ), sett().GetChatColorNormal(), sett().GetChatFont() );
		}
	}
	return true;
}
Beispiel #23
0
void LOFImportFileHandle::lofOpenFiles(wxString* ln)
{  
   wxStringTokenizer tok(*ln, wxT(" "));
   wxStringTokenizer temptok1(*ln, wxT("\""));
   wxStringTokenizer temptok2(*ln, wxT(" "));
   int tokenplace = 0;
   
   wxString targetfile;
   wxString tokenholder = tok.GetNextToken();
   
   if (tokenholder.IsSameAs(wxT("window"), false))
   {
      // set any duration/offset factors for last window, as all files were called
      doDuration();
      doScrollOffset();
      
      if (windowCalledOnce)
      {
         mProject = CreateNewAudacityProject(gParentWindow);
      }

      windowCalledOnce = true;
      
      while (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();
         
         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            
            if (Internat::CompatibleToDouble(tokenholder, &scrollOffset))
            {
               callScrollOffset = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid window offset in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE, gParentWindow);
            }
               
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
         }
         
         if (tokenholder.IsSameAs(wxT("duration"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            
            if (Internat::CompatibleToDouble(tokenholder, &durationFactor))
            {
               callDurationFactor = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid duration in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE, gParentWindow);
            }
         }     // End if statement

         if (tokenholder.IsSameAs(wxT("#")))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }
      }     // End while loop
   }        // End if statement
   
   else if (tokenholder.IsSameAs(wxT("file"), false))
   {

      // To identify filename and open it
      tokenholder = temptok1.GetNextToken();
      targetfile = temptok1.GetNextToken();
     
      #ifdef USE_MIDI
      // If file is a midi
      if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false)
          ||  targetfile.AfterLast(wxT('.')).IsSameAs(wxT("midi"), false))
      {
         NoteTrack *nTrack = new NoteTrack(mProject->GetDirManager());
         
         if (::ImportMIDI(targetfile, nTrack))
            mProject->GetTracks()->Add(nTrack);
         else
            delete nTrack;
      }
      
      // If not a midi, open audio file
      else
      {
      #else // !USE_MIDI
         /* if we don't have midi support, go straight on to opening as an
          * audio file. TODO: Some sort of message here? */
      {
      #endif // USE_MIDI
         mProject->OpenFile(targetfile);
      }

      // Set tok to right after filename
      temptok2.SetString(targetfile);
      tokenplace = temptok2.CountTokens();
      
      for (int i = 0; i < tokenplace; i++)
         tokenholder = tok.GetNextToken();
      
      if (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();
         
         if (tokenholder.IsSameAs(wxT("#")))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }
         
         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            double offset;
            
            if (Internat::CompatibleToDouble(tokenholder, &offset))
            {
               Track *t;
               TrackListIterator iter(mProject->GetTracks());
               
               t = iter.First();
               
               for (int i = 1; i < CountNumTracks(mProject) - 1; i++)
                  t = iter.Next();

#ifdef USE_MIDI
               if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false) ||
                   targetfile.AfterLast(wxT('.')).IsSameAs(wxT("midi"), false))
               {
                  wxMessageBox(_("MIDI tracks cannot be offset individually, only audio files can be."),
                               _("LOF Error"), wxOK | wxCENTRE, gParentWindow);
               }
               else
#endif
               {
                  if (CountNumTracks(mProject) == 1)
                     t->SetOffset(offset);
                  else
                  {
                     if (t->GetLinked())
                        t->SetOffset(offset);
                     
                     t = iter.Next();
                     t->SetOffset(offset);
                  }
               }
            }            
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               wxMessageBox(_("Invalid track offset in LOF file."),
                            _("LOF Error"), wxOK | wxCENTRE, gParentWindow);
            }
         }     // End if statement
      }     // End if statement
   }     // End if statement
   
   else if (tokenholder.IsSameAs(wxT("#")))
Beispiel #24
0
/** @brief Processes a single line from a LOF text file, doing whatever is
 * indicated on the line.
 *
 * This function should just return for lines it cannot deal with, and the
 * caller will continue to the next line of the input file
 */
void LOFImportFileHandle::lofOpenFiles(wxString* ln)
{
   wxStringTokenizer tok(*ln, wxT(" "));
   wxStringTokenizer temptok1(*ln, wxT("\""));
   wxStringTokenizer temptok2(*ln, wxT(" "));
   int tokenplace = 0;

   wxString targetfile;
   wxString tokenholder = tok.GetNextToken();

   if (tokenholder.IsSameAs(wxT("window"), false))
   {
      // set any duration/offset factors for last window, as all files were called
      doDurationAndScrollOffset();

      if (windowCalledOnce)
         // Cause a project to be created with the next import
         mProject = nullptr;
      else
         // Apply any offset and duration directives of the first "window" line
         // to the previously open project, not a NEW one.
         ;

      windowCalledOnce = true;

      while (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();

         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();

            if (Internat::CompatibleToDouble(tokenholder, &scrollOffset))
            {
               callScrollOffset = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               AudacityMessageBox(_("Invalid window offset in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE);
            }

            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
         }

         if (tokenholder.IsSameAs(wxT("duration"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();

            if (Internat::CompatibleToDouble(tokenholder, &durationFactor))
            {
               callDurationFactor = true;
            }
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               AudacityMessageBox(_("Invalid duration in LOF file."),
                            /* i18n-hint: You do not need to translate "LOF" */
                            _("LOF Error"), wxOK | wxCENTRE);
            }
         }     // End if statement

         if (tokenholder == wxT("#"))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }
      }     // End while loop
   }        // End if statement handling "window" lines

   else if (tokenholder.IsSameAs(wxT("file"), false))
   {

      // To identify filename and open it
      tokenholder = temptok1.GetNextToken();
      wxString targettoken = temptok1.GetNextToken();
      targetfile = targettoken;

      // If path is relative, make absolute path from LOF path
      if(!wxIsAbsolutePath(targetfile)) {
         wxFileName fName(targetfile);
         fName.Normalize(wxPATH_NORM_ALL, mLOFFileName.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
         if(fName.FileExists()) {
            targetfile = fName.GetFullPath();
         }
      }

      // Do recursive call to import

#ifdef USE_MIDI
      // If file is a midi
      if (Importer::IsMidi(targetfile))
      {
         mProject = FileActions::DoImportMIDI(mProject, targetfile);
      }

      // If not a midi, open audio file
      else

#else // !USE_MIDI
         /* if we don't have midi support, go straight on to opening as an
          * audio file. TODO: Some sort of message here? */

#endif // USE_MIDI
         mProject = AudacityProject::OpenProject( mProject, targetfile );

      // Set tok to right after filename
      temptok2.SetString(targettoken);
      tokenplace = temptok2.CountTokens();

      for (int i = 0; i < tokenplace; i++)
         tokenholder = tok.GetNextToken();

      if (tok.HasMoreTokens())
      {
         tokenholder = tok.GetNextToken();

         if (tokenholder == wxT("#"))
         {
            // # indicates comments; ignore line
            tok = wxStringTokenizer(wxT(""), wxT(" "));
         }

         if (tokenholder.IsSameAs(wxT("offset"), false))
         {
            if (tok.HasMoreTokens())
               tokenholder = tok.GetNextToken();
            double offset;

            // handle an "offset" specifier
            if (!mProject)
               // there was an import error,
               // presumably with its own error message
               ;
            else if (Internat::CompatibleToDouble(tokenholder, &offset))
            {
               auto tracks = mProject->GetTracks();
               auto t = *tracks->Leaders().rbegin();

               // t is now the last track in the project, unless the import of
               // all tracks failed, in which case it will be null. In that
               // case we return because we cannot offset a non-existent track.
               if (t == NULL)
                  return;
#ifdef USE_MIDI
               if (targetfile.AfterLast(wxT('.')).IsSameAs(wxT("mid"), false) ||
                   targetfile.AfterLast(wxT('.')).IsSameAs(wxT("midi"), false))
               {
                  AudacityMessageBox(_("MIDI tracks cannot be offset individually, only audio files can be."),
                               _("LOF Error"), wxOK | wxCENTRE);
               }
               else
#endif
               {
                  for (auto channel : TrackList::Channels(t))
                     channel->SetOffset(offset);
               }

               // Amend the undo transaction made by import
               mProject->ModifyState(false);
            } // end of converting "offset" argument
            else
            {
               /* i18n-hint: You do not need to translate "LOF" */
               AudacityMessageBox(_("Invalid track offset in LOF file."),
                            _("LOF Error"), wxOK | wxCENTRE);
            }
         }     // End if statement for "offset" parameters
      }     // End if statement (more tokens after file name)
   }     // End if statement "file" lines

   else if (tokenholder == wxT("#"))
   {
      // # indicates comments; ignore line
      tok = wxStringTokenizer(wxT(""), wxT(" "));
   }
   else
   {
      // Couldn't parse a line
   }
}