QWClient.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. GNU General Public License version 3 notice
  3. Copyright (C) 2012 Mihawk <luiz@netdome.biz>. All rights reserved.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see < http://www.gnu.org/licenses/ >.
  14. */
  15. #ifndef QWCLIENT_H
  16. #define QWCLIENT_H
  17. #include "qwclient_global.h"
  18. class QWCLIENTSHARED_EXPORT QWClient {
  19. friend class QWClientPrivate;
  20. public:
  21. enum ClientState { DisconnectedState, ConnectingState, ConnectedState, LastState };
  22. QWClient();
  23. virtual ~QWClient();
  24. void connect(const char* host, quint16 port);
  25. void run();
  26. void disconnect();
  27. void observe();
  28. void join();
  29. void setQuakeFolder(const char* path);
  30. void setName(const char* name);
  31. void setColor(quint8 bottom, quint8 top);
  32. void setSpectator(bool spectate = true);
  33. void setPing(quint16 ping);
  34. void setRate(quint16 rate);
  35. void setPassword(const char* password);
  36. void sendCmd(const char* cmd);
  37. const QString& gameDir() const;
  38. const QString& quakeDir() const;
  39. void reconnect();
  40. const char* host() const;
  41. quint16 port() const;
  42. ClientState state() const;
  43. static void stripColor(char* string);
  44. protected:
  45. /* Overridable functions */
  46. virtual void onChallenge();
  47. virtual void onConnection();
  48. virtual void onConnected();
  49. virtual void onModelListFile(const char* fileName);
  50. virtual void onSoundListFile(const char* fileName);
  51. virtual void onDownloadStarted(const char* fileName);
  52. virtual void onDownloadFinished();
  53. virtual void onDownloadProgress(int progress);
  54. virtual void onDisconnect(); //disconnected by the remote side
  55. virtual void onPrint(int level, const char* msg);
  56. virtual void onCenterPrint(const char* msg);
  57. virtual void onStuffedCmd(const char* cmd); //some of these commands are already handled to estabilish connection
  58. virtual void onDamage(int armor, int blood);
  59. virtual 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);
  60. virtual void onPlaySound(int soundNum);
  61. virtual void onUpdateFrags(int playerNum, int frags);
  62. virtual void onUpdatePing(int playerNum, int ping);
  63. virtual void onUpdatePL(int playerNum, int pl);
  64. virtual void onUpdateUserInfo(int playerNum, int userID, const char* userInfoString);
  65. virtual void onSetInfo(int playerNum, const char* key, const char* value);
  66. virtual void onServerInfo(const char* key, const char* value);
  67. virtual void onMaxSpeedChange(float maxSpeed);
  68. virtual void onEntGravityChange(float entGravity);
  69. virtual void onSetPause(bool paused);
  70. virtual void onPlayerInfo(int playerNum, float x, float y, float z);
  71. virtual void onError(const char* description);
  72. virtual void onOOBPrint(const char* msg);
  73. virtual void onOOBCommand(const char* command);
  74. virtual void onOOBEcho(const char* msg);
  75. private:
  76. class QWClientPrivate* const myImplementation;
  77. };
  78. #endif // QWCLIENT_H