Client.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef CLIENT_H
  2. #define CLIENT_H
  3. #include "QWClient.h"
  4. #include <QString>
  5. #include <QList>
  6. #include <QTime>
  7. class App;
  8. class QTcpSocket;
  9. class Client : public QWClient
  10. {
  11. public:
  12. Client(App* app);
  13. ~Client();
  14. void disconnect();
  15. void say(const QString& msg);
  16. void sayTeam(const QString& msg);
  17. void setTeam(const QString& msg);
  18. void setSocket(class QTcpSocket* socket);
  19. void retryConnection(); //unused
  20. bool isOnServer() const;
  21. // quint8 playerCount() const;
  22. protected:
  23. 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);
  24. void onDisconnect();
  25. void onPrint(int level, const char *msg);
  26. void onChallenge();
  27. void onConnection();
  28. void onConnected();
  29. void onDownloadStarted(const char *fileName);
  30. void onDownloadFinished();
  31. void onDownloadProgress(int percent);
  32. void onStuffedCmd(const char *cmd);
  33. void onError(const char *description);
  34. void onOOBPrint(const char *msg);
  35. private:
  36. App* myApp;
  37. QTcpSocket* mySocket;
  38. QTime myTimer;
  39. bool myFloodMsgPrinted;
  40. int myConnectionRetries;
  41. static const int ConnectionRetries = 10;
  42. QString myPrintLine;
  43. bool myDownloadProgressPrintedFlag;
  44. bool myOnServerFlag;
  45. // struct Player {
  46. // int slot;
  47. // int userID;
  48. // QString team;
  49. // QString name;
  50. // };
  51. // Player* myPlayers[32];
  52. // quint8 myPlayerCount;
  53. // void cleanupPlayers();
  54. void print(const QString& msg);
  55. void parsePrintedLine();
  56. // static const QString& getInfoKeyValue(const QStringList& infoString, const QString& key);
  57. static void yellowText(const QString& text);
  58. };
  59. #endif // CLIENT_H