2021-12-09 11:26:52 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <graph.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "taquin.h"
|
|
|
|
#include "graph_sup.h"
|
|
|
|
|
|
|
|
void UpdateSelection(char* selection, int param) {
|
2021-12-10 18:57:48 +01:00
|
|
|
int MenuHeight = HEIGHT - 120, i;
|
2021-12-09 11:26:52 +01:00
|
|
|
if (selection == "lines") {
|
|
|
|
SetColor(0, 0, 0);
|
|
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH - 200, 75 + i * 70, 50, 50); //Lignes
|
|
|
|
SetColor(255, 0, 0);
|
2021-12-10 18:57:48 +01:00
|
|
|
DessinerRectangle(WIDTH - 200, 75 + (param-3) * 70, 50, 50);
|
2021-12-09 11:26:52 +01:00
|
|
|
} else if (selection == "columns") {
|
|
|
|
SetColor(0, 0, 0);
|
2021-12-10 18:57:48 +01:00
|
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + i * 70, 50, 50); //Colonnes
|
2021-12-09 11:26:52 +01:00
|
|
|
SetColor(255, 0, 0);
|
2021-12-10 18:57:48 +01:00
|
|
|
DessinerRectangle(WIDTH/2 + 150, 75 + (param-3) * 70, 50, 50);
|
|
|
|
} else if (selection == "image"){
|
|
|
|
SetColor(0, 0, 0);
|
|
|
|
for (i=0; i<3; i++) DessinerRectangle(0, MenuHeight/3 * i, WIDTH/2, MenuHeight/3);
|
|
|
|
SetColor(255,0,0);
|
|
|
|
DessinerRectangle(0, MenuHeight/3 * param, WIDTH/2, MenuHeight/3);
|
2021-12-09 11:26:52 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int DrawMenu() {
|
|
|
|
ClearButtons();
|
2021-12-10 18:57:48 +01:00
|
|
|
EffacerEcran(GetColor(255, 255, 255));
|
2021-12-09 11:26:52 +01:00
|
|
|
|
|
|
|
int MenuHeight = HEIGHT - 120;
|
|
|
|
int Lines = 3, Columns = 3, i;
|
2021-12-10 18:57:48 +01:00
|
|
|
int X_image, Y_image;
|
2021-12-09 11:26:52 +01:00
|
|
|
|
|
|
|
char filename[100];
|
|
|
|
|
|
|
|
SetColor(0, 0, 0);
|
|
|
|
char str[3];
|
2021-12-10 18:57:48 +01:00
|
|
|
EcrireTexte(WIDTH/2 +120, 50 , "Colonnes", 2);
|
|
|
|
EcrireTexte(WIDTH - 220, 50 , "Lignes", 2);
|
2021-12-09 11:26:52 +01:00
|
|
|
for (i = 0; i <= 5; i++) {
|
|
|
|
AddButton(WIDTH/2 + 150, 75 + i * 70, 50, 50, 10 + i); //Colonnes
|
|
|
|
AddButton(WIDTH - 200, 75 + i * 70, 50, 50, 20 + i); //Lignes
|
|
|
|
|
|
|
|
sprintf(str, "%d", i+3);
|
|
|
|
EcrireTexte(WIDTH/2 + 175, 100 + i * 70, str, 2);
|
|
|
|
EcrireTexte(WIDTH - 175, 100 + i * 70, str, 2);
|
|
|
|
}
|
|
|
|
|
2021-12-10 18:57:48 +01:00
|
|
|
DessinerRectangle(WIDTH/4 *3 - 100, HEIGHT - 100, 200, 80);
|
|
|
|
AddButton(WIDTH/4 *3 - 100, HEIGHT - 100, 200, 80, 1);
|
|
|
|
EcrireTexte(WIDTH/4 *3 - 75 , HEIGHT - 50, "Start taquin", 2);
|
|
|
|
|
|
|
|
DessinerRectangle(WIDTH/4 -100, HEIGHT - 100, 200, 80);
|
|
|
|
AddButton(WIDTH/4 - 100, HEIGHT -100, 200, 80, 2);
|
|
|
|
EcrireTexte(WIDTH/4 - 90, HEIGHT - 50, "Quitter menu", 2);
|
2021-12-09 11:26:52 +01:00
|
|
|
|
|
|
|
UpdateSelection("lines", Lines);
|
|
|
|
UpdateSelection("columns", Columns);
|
|
|
|
|
|
|
|
SetColor(0, 0, 0);
|
|
|
|
DessinerRectangle(0, 0, WIDTH/2, MenuHeight/3);
|
2021-12-10 18:57:48 +01:00
|
|
|
AddButton(0, 0, WIDTH/2, MenuHeight/3, 3);
|
|
|
|
|
2021-12-09 11:26:52 +01:00
|
|
|
DessinerRectangle(0, MenuHeight/3, WIDTH/2, MenuHeight/3);
|
2021-12-10 18:57:48 +01:00
|
|
|
AddButton(0, MenuHeight/3, WIDTH/2, MenuHeight/3, 4);
|
|
|
|
|
2021-12-09 11:26:52 +01:00
|
|
|
DessinerRectangle(0, MenuHeight/3 * 2, WIDTH/2, MenuHeight/3);
|
2021-12-10 18:57:48 +01:00
|
|
|
AddButton(0, MenuHeight/3 *2, WIDTH/2, MenuHeight/3, 5);
|
2021-12-09 11:26:52 +01:00
|
|
|
|
|
|
|
DessinerSegment(WIDTH/2, 0, WIDTH/2, MenuHeight);
|
|
|
|
DessinerRectangle(0, MenuHeight, WIDTH, HEIGHT - MenuHeight);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (DrawNextFrame()) {
|
|
|
|
if (SourisCliquee()) {
|
|
|
|
int BT_ID = GetButton(_X, _Y);
|
|
|
|
|
|
|
|
if (BT_ID >= 10 && BT_ID <= 15) {
|
|
|
|
Columns = BT_ID - 7;
|
|
|
|
UpdateSelection("columns", Columns);
|
|
|
|
} else if (BT_ID >= 20 && BT_ID <= 25) {
|
|
|
|
Lines = BT_ID - 17;
|
|
|
|
UpdateSelection("lines", Lines);
|
2021-12-10 18:57:48 +01:00
|
|
|
} else if (BT_ID >= 3 && BT_ID <= 5){
|
|
|
|
UpdateSelection("image", BT_ID - 3);
|
|
|
|
if (BT_ID == 3){
|
|
|
|
X_image = 500;
|
|
|
|
Y_image = 445;
|
|
|
|
strcpy(filename, "./images/luna.png");
|
|
|
|
} else if (BT_ID == 4){
|
|
|
|
X_image = 300;
|
|
|
|
Y_image = 168;
|
|
|
|
strcpy(filename, "./images/zenitsu.jpg");
|
|
|
|
} else if (BT_ID == 5){
|
|
|
|
X_image = 400;
|
|
|
|
Y_image = 400;
|
|
|
|
strcpy(filename, "./images/banzai.png");
|
|
|
|
}
|
|
|
|
} else {
|
2021-12-09 11:26:52 +01:00
|
|
|
if (BT_ID == 1) {
|
|
|
|
ClearButtons();
|
|
|
|
EffacerEcran(GetColor(255, 255, 255));
|
2021-12-10 18:57:48 +01:00
|
|
|
CreateTaquin(filename, X_image, Y_image, Lines, Columns);
|
|
|
|
return 1;
|
|
|
|
} else if (BT_ID == 2) {
|
|
|
|
return 0;
|
|
|
|
}
|
2021-12-09 11:26:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2021-12-10 18:57:48 +01:00
|
|
|
}
|