Client.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3. #include "QWClient.h"
  4. #include <QString>
  5. #include <QStringList>
  6. #include <QList>
  7. #include "ServerQuery.h"
  8. class App;
  9. class QTime;
  10. class QTimer;
  11. class ActiveClient;
  12. class Client : public QWClient
  13. {
  14. public:
  15. Client(App* app, ActiveClient* ac);
  16. ~Client();
  17. void run();
  18. void disconnect();
  19. void say(const QString& msg);
  20. void sayTeam(const QString& msg);
  21. void setTeam(const QString& msg);
  22. void setSocket(class QTcpSocket* socket);
  23. void retryConnection(); //unused
  24. bool isOnServer() const;
  25. bool isMuted() const;
  26. void setPlayerList(PlayerList &playerList);
  27. protected:
  28. void onLevelChanged(int playerNum, const char *levelName, float gravity, float stopSpeed, float maxSpeed, float spectatorMaxSpeed, float accelerate, float airAccelerate, float waterAccelerate, float friction, float waterFriction, float entGravity);
  29. void onDisconnect();
  30. void onPrint(int level, const char *msg);
  31. void onChallenge();
  32. void onConnection();
  33. void onConnected();
  34. void onDownloadStarted(const char *fileName);
  35. void onDownloadFinished();
  36. void onDownloadProgress(int percent);
  37. void onStuffedCmd(const char *cmd);
  38. void onError(const char *description);
  39. void onOOBPrint(const char *msg);
  40. private:
  41. ActiveClient* myActiveClient;
  42. App* myApp;
  43. QTime* myEndFloodTime;
  44. bool myFloodMsgPrinted;
  45. int myConnectionRetries;
  46. static const int ConnectionRetries = 10;
  47. QString myPrintLine;
  48. bool myDownloadProgressPrintedFlag;
  49. bool myOnServerFlag;
  50. bool myMutedFlag;
  51. QTimer* myJoinMessageTimer;
  52. bool myJoinMessagePrinted;
  53. PlayerList myPlayerList;
  54. void print(const QString& msg);
  55. void parsePrintedLine();
  56. static QString parseNameFun(const QString& string);
  57. };
  58. #endif // CLIENT_H