295 lines
9.4 KiB
C
295 lines
9.4 KiB
C
#include "vue.h"
|
|
|
|
|
|
void splashScreen(sfRenderWindow *window)
|
|
{
|
|
sfRenderTexture *renderTexture = initialisationRenderTexture(sfRenderWindow_getSize(window).x, sfRenderWindow_getSize(window).y);
|
|
|
|
// Fond gris (clair)
|
|
sfRenderTexture_clear(renderTexture, COULEUR_GRIS);
|
|
|
|
// Image du projet
|
|
sfTexture *texture = loadTextureFromFile(PROJECTIMAGEPATH);
|
|
|
|
const double ratio = 35 / 100.0;
|
|
const sfVector2f scale = {((WIDTH + MENUWIDTH) / (float)sfTexture_getSize(texture).x) * ratio, (HEIGHT / (float)sfTexture_getSize(texture).y) * ratio};
|
|
|
|
sfSprite *sprite = loadSpriteFromTexture((sfVector2f){(WIDTH + MENUWIDTH) * (8 / 100.0), HEIGHT * (25 / 100.0)}, texture);
|
|
sfSprite_setScale(sprite, scale);
|
|
sfRenderTexture_drawSprite(renderTexture, sprite, NULL);
|
|
|
|
// GINPA
|
|
// GINPA Is Not A Position Analyst
|
|
sfFont *italicFont = loadFontFromFile(ITALICFONTPATH);
|
|
sfFont *boldFont = loadFontFromFile(BOLDFONTPATH);
|
|
|
|
sfText *title = creerTexte((sfVector2f){(WIDTH + MENUWIDTH) * (50 / 100.0), HEIGHT * (35 / 100.0)}, PROJECTNAME, boldFont, 50, sfBlack);
|
|
sfRenderTexture_drawText(renderTexture, title, NULL);
|
|
|
|
sfText *description = creerTexte((sfVector2f){(WIDTH + MENUWIDTH) * (40 / 100.0), HEIGHT * (45 / 100.0)}, PROJECTDESC, italicFont, 25, sfBlack);
|
|
sfRenderTexture_drawText(renderTexture, description, NULL);
|
|
|
|
sfRenderTexture_display(renderTexture);
|
|
|
|
sfSprite *renderSprite = loadSpriteFromRenderTexture(renderTexture);
|
|
|
|
displayBackgroundSprite(window, renderSprite);
|
|
|
|
sfEvent event;
|
|
waitingForEvent(window, &event, renderSprite);
|
|
|
|
scrollUpDisplay(window, renderSprite);
|
|
|
|
sfTexture_destroy(texture);
|
|
sfSprite_destroy(sprite);
|
|
sfFont_destroy(boldFont);
|
|
sfFont_destroy(italicFont);
|
|
sfText_destroy(title);
|
|
sfText_destroy(description);
|
|
sfRenderTexture_destroy(renderTexture);
|
|
sfSprite_destroy(renderSprite);
|
|
}
|
|
|
|
|
|
void handleMenu(sfRenderWindow *const window)
|
|
{
|
|
sfRenderTexture *renderTexture = initialisationRenderTexture(sfRenderWindow_getSize(window).x, sfRenderWindow_getSize(window).y);
|
|
sfRenderTexture_clear(renderTexture, COULEUR_GRIS);
|
|
|
|
sfFont *font = loadFontFromFile(REGULARFONTPATH);
|
|
sfFont *fontIt = loadFontFromFile(ITALICFONTPATH);
|
|
|
|
// Image du projet
|
|
sfTexture *texture = loadTextureFromFile(PROJECTIMAGEPATH);
|
|
|
|
const double ratio = 15 / 100.0;
|
|
const sfVector2f scale = {((WIDTH + MENUWIDTH) / (float)sfTexture_getSize(texture).x) * ratio, (HEIGHT / (float)sfTexture_getSize(texture).y) * ratio};
|
|
|
|
sfSprite *sprite = loadSpriteFromTexture((sfVector2f){(WIDTH + MENUWIDTH) * 83 / 100.0, HEIGHT * 1 / 100.0}, texture);
|
|
sfSprite_setScale(sprite, scale);
|
|
|
|
/*--------------------------------Textes----------------------------------*/
|
|
const uint8_t nombreTextes = 4;
|
|
sfText *textes[nombreTextes];
|
|
|
|
textes[0] = creerTexte((sfVector2f){WIDTH * (18 / 100.0), HEIGHT * (67 / 100.0)}, "GLOBAL", font, WIDTH / 21.3, sfBlack);
|
|
textes[1] = creerTexte((sfVector2f){WIDTH * (60 / 100.0), HEIGHT * (67 / 100.0)}, "POINT PAR POINT", font, WIDTH / 21.3, sfBlack);
|
|
textes[2] = creerTexte((sfVector2f){WIDTH * (18 / 100.0), HEIGHT * (67 / 100.0)}, "MANUEL", font, WIDTH / 21.3, sfBlack);
|
|
textes[3] = creerTexte((sfVector2f){WIDTH * (64 / 100.0), HEIGHT * (67 / 100.0)}, "AUTOMATIQUE", font, WIDTH / 21.3, sfBlack);
|
|
|
|
sfText *cheminFichier = NULL;
|
|
|
|
/* -------------------------- Création des boutons du premier menu ------------------------- */
|
|
Bouton *boutonPBP = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/navigation.png", &(sfVector2f){WIDTH * (60/100.0), HEIGHT * (20 / 100.0)}, false);
|
|
Bouton *boutonGLO = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/global.png", &(sfVector2f){WIDTH / 15, HEIGHT * (20 / 100.0)}, false);
|
|
Bouton *boutonPBPA = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/video-player.png", &(sfVector2f){WIDTH * (60/100.0), HEIGHT * (20 / 100.0)}, false);
|
|
Bouton *boutonPBPM = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/placeholder.png", &(sfVector2f){WIDTH / 15, HEIGHT * (20 / 100.0)}, false);
|
|
Bouton *boutonHOME = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/home.png", &(sfVector2f){WIDTH / 10.0, HEIGHT / 1.2}, true);
|
|
Bouton *boutonGLMF = ajouterBoutonAccueil(NO_TOOL, "Vue/Ressources/Icones/folder.png", &(sfVector2f){WIDTH / 1.2, HEIGHT / 1.2}, true);
|
|
/* ----------------------------------------------------------------------------------------- */
|
|
|
|
sfSprite *renderSprite = NULL;
|
|
|
|
Mode mode;
|
|
sfEvent event;
|
|
|
|
uint16_t nbFiles = 0;
|
|
const char *temp = NULL;
|
|
|
|
// Les chemins des fichiers seront stockés ici
|
|
char selectedFiles[MAXSELECTEDFILES][MAXPATHLENGTH];
|
|
|
|
while(sfRenderWindow_isOpen(window))
|
|
{
|
|
sfRenderTexture_clear(renderTexture, COULEUR_GRIS);
|
|
|
|
for(uint8_t i = 0; i < 2; i++)
|
|
{
|
|
sfRenderTexture_drawText(renderTexture, textes[i], NULL);
|
|
}
|
|
|
|
sfRenderTexture_drawSprite(renderTexture, boutonPBP->spriteButton, NULL);
|
|
sfRenderTexture_drawSprite(renderTexture, boutonGLO->spriteButton, NULL);
|
|
sfRenderTexture_drawSprite(renderTexture, boutonGLMF->spriteButton, NULL);
|
|
|
|
if(cheminFichier != NULL)
|
|
{
|
|
sfRenderTexture_drawText(renderTexture, cheminFichier, NULL);
|
|
}
|
|
|
|
sfRenderTexture_drawSprite(renderTexture, sprite, NULL);
|
|
sfRenderTexture_display(renderTexture);
|
|
|
|
sfSprite_destroy(renderSprite);
|
|
renderSprite = loadSpriteFromRenderTexture(renderTexture);
|
|
|
|
displayBackgroundSprite(window, renderSprite);
|
|
|
|
mode = NO_MODE;
|
|
waitingForEvent(window, &event, renderSprite);
|
|
|
|
if(event.type == sfEvtMouseButtonPressed)
|
|
{
|
|
if(mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonGLO->zone))
|
|
{
|
|
if(temp == NULL)
|
|
{
|
|
temp = chooseFilesToOpen(window, renderSprite, false);
|
|
|
|
if(temp != NULL)
|
|
{
|
|
mode = MODE_GLOBAL;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
mode = MODE_GLOBAL;
|
|
}
|
|
}
|
|
|
|
else if(mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonPBP->zone))
|
|
{
|
|
sfRenderTexture_clear(renderTexture, COULEUR_GRIS);
|
|
|
|
/* ------------------- Affichage du texte et des boutons du second menu ------------------- */
|
|
for(uint8_t i = 2; i < nombreTextes; i++)
|
|
{
|
|
sfRenderTexture_drawText(renderTexture, textes[i], NULL);
|
|
}
|
|
|
|
sfRenderTexture_drawSprite(renderTexture, boutonPBPA->spriteButton, NULL);
|
|
sfRenderTexture_drawSprite(renderTexture, boutonPBPM->spriteButton, NULL);
|
|
sfRenderTexture_drawSprite(renderTexture, boutonHOME->spriteButton, NULL);
|
|
sfRenderTexture_drawSprite(renderTexture, sprite, NULL);
|
|
sfRenderTexture_display(renderTexture);
|
|
|
|
sfSprite_destroy(renderSprite);
|
|
renderSprite = loadSpriteFromRenderTexture(renderTexture);
|
|
displayBackgroundSprite(window, renderSprite);
|
|
/* ---------------------------------------------------------------------------------------- */
|
|
|
|
while(mode == NO_MODE)
|
|
{
|
|
waitingForEvent(window, &event, renderSprite);
|
|
|
|
if(mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonPBPA->zone))
|
|
{
|
|
if(temp == NULL)
|
|
{
|
|
temp = chooseFilesToOpen(window, renderSprite, false);
|
|
|
|
if(temp != NULL)
|
|
{
|
|
mode = MODE_PBP_AUTOMATIC;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
mode = MODE_PBP_AUTOMATIC;
|
|
}
|
|
}
|
|
|
|
else if(mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonPBPM->zone))
|
|
{
|
|
if(temp == NULL)
|
|
{
|
|
temp = chooseFilesToOpen(window, renderSprite, false);
|
|
|
|
if(temp != NULL)
|
|
{
|
|
mode = MODE_PBP_MANUAL;
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
mode = MODE_PBP_MANUAL;
|
|
}
|
|
}
|
|
|
|
else if(sfKeyboard_isKeyPressed(sfKeyBack) || mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonHOME->zone))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
else if(mouseIsInRect(((sfVector2f){event.mouseButton.x, event.mouseButton.y}), boutonGLMF->zone))
|
|
{
|
|
temp = chooseFilesToOpen(window, renderSprite, true);
|
|
if(temp != NULL)
|
|
{
|
|
ssize_t taille = strlen(temp);
|
|
|
|
sfText_destroy(cheminFichier);
|
|
cheminFichier = NULL;
|
|
|
|
// Le nombre de fichiers sélectionnés
|
|
nbFiles = convertLineToFilePaths(temp, selectedFiles);
|
|
if(nbFiles > 1)
|
|
{
|
|
mode = MODE_MULTI_FILES;
|
|
}
|
|
|
|
else if(nbFiles == 1)
|
|
{
|
|
cheminFichier = creerTexte((sfVector2f){WIDTH * (10 / 100.0), HEIGHT * (90 / 100.0)}, temp, fontIt, WIDTH * (2.5 / 100.0) * 50 / (float)taille, sfBlack);
|
|
}
|
|
|
|
else
|
|
{
|
|
warningBox(window, renderSprite, "La taille d'un des fichiers sélectionnés dépasse la longueur autorisée...");
|
|
temp = NULL;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(mode != NO_MODE)
|
|
{
|
|
sfRenderWindow_setFramerateLimit(window, FRAMERATELIMITPOWER);
|
|
|
|
// L'utilisateur a choisi un mode pour un seul fichier, ça part !
|
|
if(mode != MODE_MULTI_FILES)
|
|
{
|
|
controlePoints(window, temp, mode);
|
|
}
|
|
|
|
// Sinon... On appelle le Contrôleur qui gère particulièrement le mode fichiers multiples !
|
|
else
|
|
{
|
|
controleMultipleLogs(window, selectedFiles, nbFiles);
|
|
}
|
|
|
|
sfRenderWindow_setFramerateLimit(window, FRAMERATELIMITSLEEP);
|
|
|
|
temp = NULL;
|
|
|
|
sfText_destroy(cheminFichier);
|
|
cheminFichier = NULL;
|
|
}
|
|
}
|
|
}
|
|
|
|
detruireBouton(boutonPBP);
|
|
detruireBouton(boutonGLO);
|
|
detruireBouton(boutonGLMF);
|
|
detruireBouton(boutonPBPA);
|
|
detruireBouton(boutonPBPM);
|
|
detruireBouton(boutonHOME);
|
|
|
|
sfFont_destroy(font);
|
|
sfFont_destroy(fontIt);
|
|
|
|
for(uint8_t i = 0; i < nombreTextes; i++)
|
|
{
|
|
sfText_destroy(textes[i]);
|
|
}
|
|
|
|
sfText_destroy(cheminFichier);
|
|
|
|
sfRenderTexture_destroy(renderTexture);
|
|
sfSprite_destroy(renderSprite);
|
|
}
|