diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:13:02 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2024-08-07 19:23:24 +0300 |
commit | 04b5a62b8d9f5ff8240f25361046f2a5d58e8262 (patch) | |
tree | 98b126454cdf68d544e138d7e8b31d5fd45b72c2 /kue/interface.h | |
parent | 83ba00b7e569587d50383ff06a70148042ca780e (diff) | |
download | tdegames-feat/kue.tar.gz tdegames-feat/kue.zip |
Add Kue billiards gamefeat/kue
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'kue/interface.h')
-rw-r--r-- | kue/interface.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/kue/interface.h b/kue/interface.h new file mode 100644 index 00000000..72565d31 --- /dev/null +++ b/kue/interface.h @@ -0,0 +1,86 @@ +#ifndef _INTERFACE_H +#define _INTERFACE_H + +#include <tqdatetime.h> +#include <tqobject.h> +#include <tqcolor.h> +#include <tqgl.h> + +#include "circle.h" +#include "vector.h" +#include "texture.h" + +class table; +class rules; +class TQString; + +// Handles user interface functionality +class GLUserInterface : public TQGLWidget { + TQ_OBJECT + public: + GLUserInterface(TQWidget *parent); + ~GLUserInterface(); + + // Rules' functions + void placeBilliard(double cue_line); + void startShot(circle cue_location, TQColor player_color, bool forward_only = false); + + void update(); + + signals: + // Called by the interface when the user has decided on a cue location + void billiardPlaced(point &location); + // Called by the interface when the user is deciding on a cue location + void previewBilliardPlace(point &location); + void shotTaken(vector &velocity); + + private: + void initializeGL(); + void resizeGL(int widget, int height); + void paintGL(); + + void mouseMoveEvent(TQMouseEvent *e); + void mousePressEvent(TQMouseEvent *e); + void mouseReleaseEvent(TQMouseEvent *e); + + double windowToInternalX(int x); + double windowToInternalY(int y); + + void timerEvent( TQTimerEvent * ); + void updateView(); + double shotPower(); + + void mouseClicked(double x, double y, int button, int state); + + double positionToAngle(double position); + double positionToCuePlacement(double position); + + // Are we placing the cue ball? + bool _placing_cue; + double _cue_line; + + // Are we shooting? + bool _shooting; + // Can we shoot only in front of the start line? + bool _forward_only; + + + // Where is the cue? And how big is it? + circle _cue_location; + // Where is the mouse? + point _mouse_location; + + // When did the user begin the 'shot' by pressing down the mouse button + bool _shot_started; + TQTime _shot_time; + + // Cue texture + KueTexture _cue_texture; + + // The current player's color + TQColor _player_color; + + table *_table; +}; + +#endif |