| 1 | // (_||_/ |
| 2 | // ( ) Mouse class |
| 3 | // ( o 0 ) |
| 4 | //-OOO°--(_)---°OOO--------------------------------------- |
| 5 | // Copyright (C) 2006 By Dominique Roux-Serret |
| 6 | // .OOOo oOOO. [email protected] |
| 7 | //-( )------( )--------------------------------------- |
| 8 | // ( ( ) / Copyright (C) 2023 By Johnny Jazeix |
| 9 | // (_) (_/ [email protected] |
| 10 | |
| 11 | // This program is free software; you can redistribute it and/or modify |
| 12 | // it under the terms of the GNU General Public License as published by |
| 13 | // the Free Software Foundation; either version 2 or version 3 of the License. |
| 14 | |
| 15 | // This program is distributed in the hope that it will be useful, |
| 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | // GNU General Public License for more details. |
| 19 | |
| 20 | // You should have received a copy of the GNU General Public License along |
| 21 | // with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 23 | |
| 24 | #ifndef MOUSE_DOM_ |
| 25 | #define MOUSE_DOM_ |
| 26 | |
| 27 | #include <SDL2/SDL_events.h> |
| 28 | |
| 29 | class Audio; |
| 30 | /*** Structure pour la position dans le menu Py ***/ |
| 31 | /**************************************************/ |
| 32 | struct mPy |
| 33 | { // DepX==-1 si derniere entrée |
| 34 | int DepX, DepY; |
| 35 | int FinX, FinY; |
| 36 | int Py; |
| 37 | bool Valide; // Si doit valider un enter quand click de la sourie |
| 38 | }; |
| 39 | |
| 40 | struct mButton |
| 41 | { // DepX=-1 si derniere entrée |
| 42 | int DepX, DepY; |
| 43 | int FinX, FinY; |
| 44 | int Valeur; |
| 45 | int *Adr; |
| 46 | }; |
| 47 | |
| 48 | /*** Définition de la class Tableau ***/ |
| 49 | /**************************************/ |
| 50 | class Mouse |
| 51 | { |
| 52 | public: |
| 53 | explicit Mouse(Audio &audio) : |
| 54 | m_audio(audio) { } |
| 55 | ~Mouse() = default; |
| 56 | |
| 57 | void InitStart(); // Initialise les coordonnées de la sourie |
| 58 | void Init(struct mPy *TablePy, struct mButton *B = nullptr); // Initialise la sourie |
| 59 | void GetEvent(SDL_Event &event, int &Py); // Prend les evenements |
| 60 | void Print() const; // Affiche le curseur |
| 61 | |
| 62 | int Px { 400 }, Py { 300 }; // Mouse screen position |
| 63 | |
| 64 | private: |
| 65 | Audio &m_audio; |
| 66 | struct mPy *tPy { nullptr }; // Pointe sur coordonées pour Py |
| 67 | struct mButton *Bo { nullptr }; // Pointe sur les coordonnées des bouttons |
| 68 | }; |
| 69 | |
| 70 | #endif |