117 lines
3.8 KiB
C
117 lines
3.8 KiB
C
#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) {
|
|
int MenuHeight = HEIGHT - 120, i;
|
|
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);
|
|
DessinerRectangle(WIDTH - 200, 75 + (param-3) * 70, 50, 50);
|
|
} else if (selection == "columns") {
|
|
SetColor(0, 0, 0);
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + i * 70, 50, 50); //Colonnes
|
|
SetColor(255, 0, 0);
|
|
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);
|
|
}
|
|
};
|
|
|
|
int DrawMenu() {
|
|
ClearButtons();
|
|
EffacerEcran(GetColor(255, 255, 255));
|
|
|
|
int MenuHeight = HEIGHT - 120;
|
|
int Lines = 3, Columns = 3, i;
|
|
int X_image, Y_image;
|
|
|
|
char filename[100];
|
|
|
|
SetColor(0, 0, 0);
|
|
char str[3];
|
|
EcrireTexte(WIDTH/2 +120, 50 , "Colonnes", 2);
|
|
EcrireTexte(WIDTH - 220, 50 , "Lignes", 2);
|
|
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);
|
|
}
|
|
|
|
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);
|
|
|
|
UpdateSelection("lines", Lines);
|
|
UpdateSelection("columns", Columns);
|
|
|
|
SetColor(0, 0, 0);
|
|
DessinerRectangle(0, 0, WIDTH/2, MenuHeight/3);
|
|
AddButton(0, 0, WIDTH/2, MenuHeight/3, 3);
|
|
|
|
DessinerRectangle(0, MenuHeight/3, WIDTH/2, MenuHeight/3);
|
|
AddButton(0, MenuHeight/3, WIDTH/2, MenuHeight/3, 4);
|
|
|
|
DessinerRectangle(0, MenuHeight/3 * 2, WIDTH/2, MenuHeight/3);
|
|
AddButton(0, MenuHeight/3 *2, WIDTH/2, MenuHeight/3, 5);
|
|
|
|
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);
|
|
} 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 {
|
|
if (BT_ID == 1) {
|
|
ClearButtons();
|
|
EffacerEcran(GetColor(255, 255, 255));
|
|
CreateTaquin(filename, X_image, Y_image, Lines, Columns);
|
|
return 1;
|
|
} else if (BT_ID == 2) {
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|