2021-11-22 17:29:33 +01:00
|
|
|
#include "utils.h"
|
|
|
|
#include <graph.h>
|
|
|
|
#include <stdio.h>
|
2021-11-24 10:24:18 +01:00
|
|
|
#include <stdlib.h>
|
2021-11-22 17:29:33 +01:00
|
|
|
#include <string.h>
|
2021-11-24 10:24:18 +01:00
|
|
|
#include "graph_sup.h"
|
2021-11-22 17:29:33 +01:00
|
|
|
|
|
|
|
#define FPS 60.0
|
|
|
|
|
2021-11-24 10:24:18 +01:00
|
|
|
button* Buttons;
|
|
|
|
int BT_Count = 0;
|
|
|
|
|
|
|
|
void clearButtons() {
|
|
|
|
BT_Count = 0;
|
|
|
|
Buttons = (button*)realloc(Buttons, sizeof(button) * 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddButton(int x, int y, int w, int h, char* id) {
|
|
|
|
button BT = {0, 0, 0, 0};
|
|
|
|
BT.x = x;
|
|
|
|
BT.y = y;
|
|
|
|
BT.w = w;
|
|
|
|
BT.h = h;
|
|
|
|
BT.id = id;
|
|
|
|
|
|
|
|
BT_Count++;
|
|
|
|
Buttons = (button*) realloc(Buttons, BT_Count * sizeof(button));
|
|
|
|
Buttons[BT_Count-1] = BT;
|
|
|
|
}
|
|
|
|
|
|
|
|
char* GetButton(int x, int y) {
|
|
|
|
for (int ID = 0; ID < BT_Count; ID++) {
|
|
|
|
button BT = Buttons[ID];
|
|
|
|
if (x >= BT.y && y >= BT.y && x <= BT.x + BT.w && y <= BT.y + BT.h) {
|
|
|
|
return BT.id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2021-11-22 17:29:33 +01:00
|
|
|
int RegisterInputs(char * screen) {
|
|
|
|
if (ToucheEnAttente() > 0) {
|
|
|
|
int key = Touche();
|
|
|
|
|
|
|
|
if (key == XK_Escape) return -1;
|
|
|
|
|
|
|
|
if (screen == "main_menu") {
|
|
|
|
|
|
|
|
} else if (screen == "taquin") {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-24 10:24:18 +01:00
|
|
|
if (SourisCliquee()) {
|
|
|
|
char* BT_ID = GetButton(_X, _Y);
|
|
|
|
}
|
|
|
|
|
2021-11-22 17:29:33 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
double delta = (1/FPS)*1000000;
|
|
|
|
unsigned long suivant = (1/FPS)*1000000;
|
|
|
|
|
|
|
|
int DrawNextFrame() {
|
|
|
|
if (Microsecondes() >= suivant) {
|
|
|
|
suivant = Microsecondes() + delta;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|