summaryrefslogtreecommitdiffstats
path: root/kue/interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'kue/interface.h')
-rw-r--r--kue/interface.h86
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