81 lines
2.6 KiB
C
81 lines
2.6 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) {
|
|
if (selection == "lines") {
|
|
int i;
|
|
SetColor(0, 0, 0);
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH - 200, 75 + i * 70, 50, 50); //Lignes
|
|
SetColor(255, 0, 0);
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH - 200, 75 + (param-3) * 70, 50, 50);
|
|
} else if (selection == "columns") {
|
|
int i;
|
|
SetColor(0, 0, 0);
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + i * 70, 50, 50); //Lignes
|
|
SetColor(255, 0, 0);
|
|
for (i = 0; i <= 5; i++) DessinerRectangle(WIDTH/2 + 150, 75 + (param-3) * 70, 50, 50);
|
|
}
|
|
};
|
|
|
|
int DrawMenu() {
|
|
ClearButtons();
|
|
|
|
int MenuHeight = HEIGHT - 120;
|
|
int Lines = 3, Columns = 3, i;
|
|
|
|
char filename[100];
|
|
strcpy(filename, "./images/luna.png");
|
|
|
|
SetColor(0, 0, 0);
|
|
char str[3];
|
|
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/2 - 100, HEIGHT - 100, 200, 80);
|
|
AddButton(WIDTH/2 - 100, HEIGHT - 100, 200, 80, 1);
|
|
|
|
UpdateSelection("lines", Lines);
|
|
UpdateSelection("columns", Columns);
|
|
|
|
SetColor(0, 0, 0);
|
|
DessinerRectangle(0, 0, WIDTH/2, MenuHeight/3);
|
|
DessinerRectangle(0, MenuHeight/3, WIDTH/2, MenuHeight/3);
|
|
DessinerRectangle(0, MenuHeight/3 * 2, WIDTH/2, MenuHeight/3);
|
|
|
|
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 == 1) {
|
|
ClearButtons();
|
|
EffacerEcran(GetColor(255, 255, 255));
|
|
CreateTaquin(filename, 500, 445, Lines, Columns);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
} |