Fix' glitch affichage menu
Optimisation mémoire Fin du mode verbeux pour les modes de preview Fix' d'un futur bug Optimisation fonction d'attente Ajout des confirmations de fermeture de programme et retour menu
This commit is contained in:
parent
7088a7d7e9
commit
9704508e26
@ -117,7 +117,10 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
Menu menu;
|
||||
initialiserMenu(&menu);
|
||||
|
||||
updateAndDrawMenu(renderTexture, &menu, mode, (mode != MODE_GLOBAL ? false : true), true, NO_TOOL);
|
||||
if(mode == MODE_PBP_AUTOMATIC || mode == MODE_PBP_MANUAL)
|
||||
{
|
||||
updateAndDrawMenu(renderTexture, &menu, mode, false, true, NO_TOOL);
|
||||
}
|
||||
|
||||
Point **ptsAffiches = affichageLogs(window, renderTexture, tabPoints, nbElements, &nbPointsAffiches, nbPointAgglosMin, tabPointeursCercles, agglos, nbAgglos, tabPointeursCerclesAgglos, &nbAgglosAffiches, allPoint, carte, mode, &menu);
|
||||
if(ptsAffiches == NULL)
|
||||
@ -134,9 +137,15 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
|
||||
updateAndDrawMenu(renderTexture, &menu, mode, true, true, NO_TOOL);
|
||||
|
||||
freeSprite(&renderSprite);
|
||||
renderSprite = loadSpriteFromRenderTexture(renderTexture);
|
||||
displayBackgroundSprite(window, renderSprite);
|
||||
|
||||
carre = waitingOnMapEvent(window, &event, renderTexture, renderSprite, carte, nbPointsAffiches, ptsAffiches, tabPointeursCercles, nbAgglos, tabPointeursCerclesAgglos, agglos, nbElements, tabPoints, tabDatesConverties, font, &action, mode, &menu, ¤tTool);
|
||||
|
||||
detruireMenu(&menu);
|
||||
|
||||
// Nous pouvons remettre ce sprite à `NULL` car il a été (normalement) correctement libéré dans la fonction d'attente ci-dessus !
|
||||
renderSprite = NULL;
|
||||
free(ptsAffiches);
|
||||
ptsAffiches = NULL;
|
||||
@ -179,6 +188,8 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
|
||||
if(action == ACTION_ZOOM_ZONE)
|
||||
{
|
||||
/* ZOOM ZONE (CLIC) */
|
||||
|
||||
// On convertit les pixels retournés en coordonnées géographiques...
|
||||
conversionRec(&carre, &carte->pointHautGauche, &carte->pointBasDroite, &carte->pointCentral, carte->echelle);
|
||||
|
||||
@ -218,7 +229,6 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
|
||||
case ACTION_ZOOM_NEXT:
|
||||
case ACTION_ZOOM_PREV:
|
||||
|
||||
// L'utilisateur a demandé d'afficher la vue précédente / suivante. Donc on commence par empiler la vue actuelle dans la pile des suivantes / précédentes.
|
||||
if(!empilerPileCartes((action == ACTION_ZOOM_NEXT ? &previous : &next), carte))
|
||||
{
|
||||
@ -254,17 +264,14 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
if(mode == MODE_GLOBAL)
|
||||
{
|
||||
mode = MODE_PREVIEW;
|
||||
printf("Mode prévisualisation\n");
|
||||
}
|
||||
else if(mode == MODE_PREVIEW)
|
||||
{
|
||||
mode = MODE_PREVIEW_SUGG;
|
||||
printf("Mode prévisualisation suggéré\n");
|
||||
}
|
||||
else if(mode == MODE_PREVIEW_SUGG)
|
||||
{
|
||||
mode = MODE_GLOBAL;
|
||||
printf("Mode normal\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -288,14 +295,8 @@ ErrEnum controlePoints(sfRenderWindow *window, const char *cheminFichier, Mode m
|
||||
break;
|
||||
|
||||
case ACTION_TOGGLEAGGLO:
|
||||
if(allPoint)
|
||||
{
|
||||
allPoint = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
allPoint = true;
|
||||
}
|
||||
afficherSablier(window, renderTexture, &renderSprite);
|
||||
allPoint = !allPoint;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -119,8 +119,8 @@ void chargerMenuAffichageLog(Menu *const menu, const Mode mode, const bool displ
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_ZOOMNEXT, "VUE SUIVANTE ", "Vue/Ressources/Icones/next.png"));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_ZOOMZONE, "ZOOMER ZONE ", (currentTool == TOOL_ZOOMZONE ? "Vue/Ressources/Icones/zoom-in_selected.png" : "Vue/Ressources/Icones/zoom-in.png")));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_CHANGEMAP, "CHANGER FOND ", "Vue/Ressources/Icones/layers.png"));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_SELECTPOINTS, "SELECTIONNE ZONE", (currentTool == TOOL_ZOOMZONE ? "Vue/Ressources/Icones/flag_selected.png" : "Vue/Ressources/Icones/flag.png")));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_DESELECTPOINTS, "DESELECT. ZONE ", (currentTool == TOOL_ZOOMZONE ? "Vue/Ressources/Icones/flag_barre_selected.png" : "Vue/Ressources/Icones/flag_barre.png")));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_SELECTPOINTS, "SELECTIONNE ZONE", (currentTool == TOOL_SELECTPOINTS ? "Vue/Ressources/Icones/flag_selected.png" : "Vue/Ressources/Icones/flag.png")));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_DESELECTPOINTS, "DESELECT. ZONE ", (currentTool == TOOL_DESELECTPOINTS ? "Vue/Ressources/Icones/flag_barre_selected.png" : "Vue/Ressources/Icones/flag_barre.png")));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_PREVIEW, "PREVISUALISATION", (mode == MODE_GLOBAL ? "Vue/Ressources/Icones/hide_mode1.png" : (mode == MODE_PREVIEW ? "Vue/Ressources/Icones/hide_mode2.png" : "Vue/Ressources/Icones/hide_mode3.png"))));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_SAVE, "SAUVEGARDER ", "Vue/Ressources/Icones/download.png"));
|
||||
ajouterEntreeMenu(menu, loadButtonMenu(TOOL_CENTERPOSITION, "RECENTRER ", "Vue/Ressources/Icones/target.png"));
|
||||
|
@ -133,106 +133,126 @@ Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event,
|
||||
break;
|
||||
}
|
||||
|
||||
else if(event->type == sfEvtMouseButtonPressed && event->mouseButton.x > MAPSIZE)
|
||||
else if(event->type == sfEvtMouseButtonPressed && inWindow)
|
||||
{
|
||||
// Dans quasiment tous les cas, il faudra sortir de la boucle englobante...
|
||||
bool needToBreakTheWhile = true;
|
||||
|
||||
switch(whichTool(event, menu))
|
||||
if(event->mouseButton.x > MAPSIZE)
|
||||
{
|
||||
case TOOL_EXIT:
|
||||
exit(EXIT_SUCCESS);
|
||||
// Dans quasiment tous les cas, il faudra sortir de la boucle englobante...
|
||||
bool needToBreakTheWhile = true;
|
||||
|
||||
case TOOL_BACKTOHOME:
|
||||
*action = ACTION_QUIT;
|
||||
break;
|
||||
|
||||
case TOOL_CHANGEMAP:
|
||||
*action = ACTION_CHANGE_MAP_TYPE;
|
||||
break;
|
||||
|
||||
case TOOL_CENTERPOSITION:
|
||||
*action = ACTION_CENTERPOSITION;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMZONE:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_ZOOMZONE) ? NO_TOOL : TOOL_ZOOMZONE;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMPREV:
|
||||
*action = ACTION_ZOOM_PREV;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMNEXT:
|
||||
*action = ACTION_ZOOM_NEXT;
|
||||
break;
|
||||
|
||||
case TOOL_SELECTPOINTS:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_SELECTPOINTS) ? NO_TOOL : TOOL_SELECTPOINTS;
|
||||
break;
|
||||
case TOOL_DESELECTPOINTS:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_DESELECTPOINTS) ? NO_TOOL : TOOL_DESELECTPOINTS;
|
||||
break;
|
||||
case TOOL_PREVIEW:
|
||||
*action = ACTION_CHANGE_VISUALISATION;
|
||||
break;
|
||||
|
||||
case TOOL_SAVE:
|
||||
needToBreakTheWhile = false;
|
||||
if(mode == MODE_PREVIEW)
|
||||
{
|
||||
suppressionAndVerbosity(window, renderSprite, tabPoint, nbPoints, agglos, nbAgglos);
|
||||
}
|
||||
break;
|
||||
|
||||
case TOOL_REPEAT:
|
||||
*action = ACTION_REPEAT;
|
||||
break;
|
||||
|
||||
case TOOL_TOGGLEAGGLO:
|
||||
*action = ACTION_TOGGLEAGGLO;
|
||||
break;
|
||||
|
||||
case NO_TOOL:
|
||||
default:
|
||||
needToBreakTheWhile = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(needToBreakTheWhile)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if(sfMouse_isButtonPressed(sfMouseLeft) && inWindow)
|
||||
{
|
||||
if(*currentTool == TOOL_ZOOMZONE && *action == ACTION_ZOOMABLE)
|
||||
{
|
||||
Rectangle carre = selectionRectangle(window, event, renderSprite, true);
|
||||
|
||||
// Si l'utilisateur a réellement sélectionné une zone...
|
||||
if(carre.positionHG.x != 0.0 && carre.positionHG.y != 0.0 && carre.positionBD.x != 0.0 && carre.positionBD.y != 0.0)
|
||||
switch(whichTool(event, menu))
|
||||
{
|
||||
*action = ACTION_ZOOM_ZONE;
|
||||
sfTexture_destroy(originalTexture);
|
||||
return carre;
|
||||
case TOOL_EXIT:
|
||||
if(questionBox(window, renderSprite, "Êtes-vous vraiment sûr de vouloir quitter le logiciel ?"))
|
||||
{
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
needToBreakTheWhile = false;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case TOOL_BACKTOHOME:
|
||||
if(questionBox(window, renderSprite, "Êtes-vous vraiment sûr de vouloir quitter cette vue ?"))
|
||||
{
|
||||
*action = ACTION_QUIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
needToBreakTheWhile = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case TOOL_CHANGEMAP:
|
||||
*action = ACTION_CHANGE_MAP_TYPE;
|
||||
break;
|
||||
|
||||
case TOOL_CENTERPOSITION:
|
||||
*action = ACTION_CENTERPOSITION;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMZONE:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_ZOOMZONE) ? NO_TOOL : TOOL_ZOOMZONE;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMPREV:
|
||||
*action = ACTION_ZOOM_PREV;
|
||||
break;
|
||||
|
||||
case TOOL_ZOOMNEXT:
|
||||
*action = ACTION_ZOOM_NEXT;
|
||||
break;
|
||||
|
||||
case TOOL_SELECTPOINTS:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_SELECTPOINTS) ? NO_TOOL : TOOL_SELECTPOINTS;
|
||||
break;
|
||||
case TOOL_DESELECTPOINTS:
|
||||
needToBreakTheWhile = false;
|
||||
*currentTool = (*currentTool == TOOL_DESELECTPOINTS) ? NO_TOOL : TOOL_DESELECTPOINTS;
|
||||
break;
|
||||
case TOOL_PREVIEW:
|
||||
*action = ACTION_CHANGE_VISUALISATION;
|
||||
break;
|
||||
|
||||
case TOOL_SAVE:
|
||||
needToBreakTheWhile = false;
|
||||
if(mode == MODE_PREVIEW)
|
||||
{
|
||||
suppressionAndVerbosity(window, renderSprite, tabPoint, nbPoints, agglos, nbAgglos);
|
||||
}
|
||||
break;
|
||||
|
||||
case TOOL_REPEAT:
|
||||
*action = ACTION_REPEAT;
|
||||
break;
|
||||
|
||||
case TOOL_TOGGLEAGGLO:
|
||||
*action = ACTION_TOGGLEAGGLO;
|
||||
break;
|
||||
|
||||
case NO_TOOL:
|
||||
default:
|
||||
needToBreakTheWhile = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(needToBreakTheWhile)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(*currentTool == TOOL_SELECTPOINTS && mode != MODE_PREVIEW)
|
||||
|
||||
else
|
||||
{
|
||||
controleSelectionSuppression(window, event, renderSprite, ptsAffiches, nbPointsAffiches, pointAffiche, agglos, nbAgglos, aggloSelectionne, tabPointeursCercles, tabPointeursCerclesAgglos, true);
|
||||
*action = ACTION_REFRESH;
|
||||
break;
|
||||
}
|
||||
else if(*currentTool == TOOL_DESELECTPOINTS && mode != MODE_PREVIEW)
|
||||
{
|
||||
controleSelectionSuppression(window, event, renderSprite, ptsAffiches, nbPointsAffiches, pointAffiche, agglos, nbAgglos, aggloSelectionne, tabPointeursCercles, tabPointeursCerclesAgglos, false);
|
||||
*action = ACTION_REFRESH;
|
||||
break;
|
||||
if(*currentTool == TOOL_ZOOMZONE && *action == ACTION_ZOOMABLE)
|
||||
{
|
||||
Rectangle carre = selectionRectangle(window, event, renderSprite, true);
|
||||
|
||||
// Si l'utilisateur a réellement sélectionné une zone...
|
||||
if(carre.positionHG.x != 0.0 && carre.positionHG.y != 0.0 && carre.positionBD.x != 0.0 && carre.positionBD.y != 0.0)
|
||||
{
|
||||
*action = ACTION_ZOOM_ZONE;
|
||||
sfTexture_destroy(originalTexture);
|
||||
sfSprite_destroy(renderSprite);
|
||||
return carre;
|
||||
}
|
||||
}
|
||||
else if(*currentTool == TOOL_SELECTPOINTS && mode != MODE_PREVIEW)
|
||||
{
|
||||
controleSelectionSuppression(window, event, renderSprite, ptsAffiches, nbPointsAffiches, pointAffiche, agglos, nbAgglos, aggloSelectionne, tabPointeursCercles, tabPointeursCerclesAgglos, true);
|
||||
*action = ACTION_REFRESH;
|
||||
break;
|
||||
}
|
||||
else if(*currentTool == TOOL_DESELECTPOINTS && mode != MODE_PREVIEW)
|
||||
{
|
||||
controleSelectionSuppression(window, event, renderSprite, ptsAffiches, nbPointsAffiches, pointAffiche, agglos, nbAgglos, aggloSelectionne, tabPointeursCercles, tabPointeursCerclesAgglos, false);
|
||||
*action = ACTION_REFRESH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,6 +283,7 @@ Rectangle waitingOnMapEvent(sfRenderWindow *const window, sfEvent *const event,
|
||||
displayBackgroundSprite(window, renderSprite);
|
||||
|
||||
sfTexture_destroy(originalTexture);
|
||||
sfSprite_destroy(renderSprite);
|
||||
|
||||
// On retourne un Rectangle nul, mais c'est la valeur de `action` qui importe le plus ici.
|
||||
return (Rectangle){{0.0, 0.0}, {0.0, 0.0}};
|
||||
|
@ -169,7 +169,7 @@ void dessinerMenu(sfRenderTexture *const renderTexture, const Menu *const menu)
|
||||
|
||||
Bouton* ajouterBoutonAccueil(const Tool outil, const char *const icone, const sfVector2f *const position)
|
||||
{
|
||||
const sfVector2f scale = {WIDTH / 4266.666666667, HEIGHT / 4266.666666667};
|
||||
const sfVector2f scale = {WIDTH / 4266.7, HEIGHT / 4266.7};
|
||||
|
||||
Bouton *bouton = loadButtonMenu(outil, "", icone);
|
||||
|
||||
|
Reference in New Issue
Block a user