mirror of
https://gitlab.com/klmp200/LO27.git
synced 2025-07-11 14:19:23 +00:00
Renommage complet des fonctions
This commit is contained in:
30
LibGui/gui.c
30
LibGui/gui.c
@ -27,7 +27,7 @@
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
void setPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
|
||||
if (value){
|
||||
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||
@ -37,7 +37,7 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value){
|
||||
SDL_RenderDrawPoint(renderer, x, y);
|
||||
}
|
||||
|
||||
void DisplayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
void displayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
int i;
|
||||
int j;
|
||||
|
||||
@ -46,13 +46,13 @@ void DisplayMatrixSDL(SCREEN *screen, Matrix m){
|
||||
|
||||
for (i=0;i<m.rowCount;i++){
|
||||
for (j=0;j<m.colCount;j++){
|
||||
SetPixel(screen->renderer, i, j, GetCellValue(m, j, i));
|
||||
setPixel(screen->renderer, i, j, getCellValue(m, j, i));
|
||||
}
|
||||
}
|
||||
SDL_RenderPresent(screen->renderer);
|
||||
}
|
||||
|
||||
void WaitUntilEnter(SCREEN * screen){
|
||||
void waitUntilEnter(SCREEN * screen){
|
||||
int keypress = 0;
|
||||
|
||||
while (!keypress){
|
||||
@ -72,7 +72,7 @@ void WaitUntilEnter(SCREEN * screen){
|
||||
}
|
||||
}
|
||||
|
||||
int NewWindowFromMatrix(Matrix m){
|
||||
int newWindowFromMatrix(Matrix m){
|
||||
SCREEN screen;
|
||||
|
||||
screen.WIDTH = m.colCount;
|
||||
@ -92,9 +92,9 @@ int NewWindowFromMatrix(Matrix m){
|
||||
return 1;
|
||||
}
|
||||
|
||||
DisplayMatrixSDL(&screen, m);
|
||||
displayMatrixSDL(&screen, m);
|
||||
|
||||
WaitUntilEnter(&screen);
|
||||
waitUntilEnter(&screen);
|
||||
|
||||
SDL_DestroyRenderer(screen.renderer);
|
||||
SDL_DestroyWindow(screen.window);
|
||||
@ -104,12 +104,12 @@ int NewWindowFromMatrix(Matrix m){
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool YesOrNo(char message[]){
|
||||
bool inputYesOrNo(char message[]){
|
||||
char response;
|
||||
|
||||
printf("%s (Y/n)\n", message);
|
||||
response = getchar();
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
|
||||
if (response == 'n'){
|
||||
return false;
|
||||
@ -119,33 +119,33 @@ bool YesOrNo(char message[]){
|
||||
|
||||
}
|
||||
|
||||
void ClearBuffer(){
|
||||
void clearBuffer(){
|
||||
char c;
|
||||
while ((c = getchar()) != '\n' && c != EOF) { }
|
||||
}
|
||||
|
||||
void DisplayMatrixGUI(Matrix m, bool useSDL){
|
||||
void displayMatrixGUI(Matrix m, bool useSDL){
|
||||
if (useSDL){
|
||||
printf("Press ENTER or the red cross to exit the window and continue.\n");
|
||||
NewWindowFromMatrix(m);
|
||||
newWindowFromMatrix(m);
|
||||
} else {
|
||||
printMatrix(m);
|
||||
}
|
||||
}
|
||||
|
||||
int SafeNumberInput(int min, int max){
|
||||
int safeNumberInput(int min, int max){
|
||||
char str[30];
|
||||
int input;
|
||||
|
||||
fgets(str, 29, stdin);
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
|
||||
input = atoi(str);
|
||||
|
||||
while (input < min || input > max){
|
||||
printf("The number should be between %d and %d\n", min, max);
|
||||
fgets(str, 29, stdin);
|
||||
ClearBuffer();
|
||||
clearBuffer();
|
||||
input = atoi(str);
|
||||
}
|
||||
|
||||
|
16
LibGui/gui.h
16
LibGui/gui.h
@ -41,7 +41,7 @@ typedef struct {
|
||||
* @param value display white if true and black if false
|
||||
* @return
|
||||
*/
|
||||
void SetPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
void setPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
|
||||
/**
|
||||
* Display an entire matrix on a given screen
|
||||
@ -49,28 +49,28 @@ void SetPixel(SDL_Renderer *renderer, int x, int y, bool value);
|
||||
* @param m a Matrix
|
||||
* @return
|
||||
*/
|
||||
void DisplayMatrixSDL(SCREEN *screen, Matrix m);
|
||||
void displayMatrixSDL(SCREEN *screen, Matrix m);
|
||||
|
||||
/**
|
||||
* Wait until the user press the enter key
|
||||
* @param screen the screen where the renderer is
|
||||
* @return
|
||||
*/
|
||||
void WaitUntilEnter(SCREEN * screen);
|
||||
void waitUntilEnter(SCREEN * screen);
|
||||
|
||||
/**
|
||||
* Print a matrix in a new SDL window
|
||||
* @param Matrix the matrix to display
|
||||
* @return int error code
|
||||
*/
|
||||
int NewWindowFromMatrix(Matrix m);
|
||||
int newWindowFromMatrix(Matrix m);
|
||||
|
||||
/**
|
||||
* Display a message and ask for yes or no to the user
|
||||
* @param message the message to display
|
||||
* @return bool the answer
|
||||
*/
|
||||
bool YesOrNo(char message[]);
|
||||
bool inputYesOrNo(char message[]);
|
||||
|
||||
/**
|
||||
* Display matrix choosing the right function
|
||||
@ -78,7 +78,7 @@ bool YesOrNo(char message[]);
|
||||
* @param useSDL a bool
|
||||
* @return
|
||||
*/
|
||||
void DisplayMatrixGUI(Matrix m, bool useSDL);
|
||||
void displayMatrixGUI(Matrix m, bool useSDL);
|
||||
|
||||
/**
|
||||
* Get a number from the user safely
|
||||
@ -86,12 +86,12 @@ void DisplayMatrixGUI(Matrix m, bool useSDL);
|
||||
* @param max the maximal authorized number
|
||||
* @return int the input number
|
||||
*/
|
||||
int SafeNumberInput(int min, int max);
|
||||
int safeNumberInput(int min, int max);
|
||||
|
||||
/**
|
||||
* Clears the buffer of stdin
|
||||
* @return
|
||||
*/
|
||||
void ClearBuffer();
|
||||
void clearBuffer();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user