Merge branch 'master' of gitlab.iut-clermont.uca.fr:maribemont/projet-tut

merge-requests/1/head
thmaillarb 4 years ago
commit 0f3f8d0d1f

@ -4,6 +4,7 @@
// #include "../test/testGenerateurTexture.c"
#include "../test/testButton.c"
#include "../test/testTextInput.c"
#include "../test/testConnectionMenu.c"
/*
This file is meant to be modified (used only to called other tests functions)
*/
@ -14,6 +15,7 @@ int main(/*int argc, char *argv[]*/) {
//testFontLoader();
//testGenerateurTexture();
//testTextInput();
testButtonTextureLoader();
//testButtonTextureLoader();
testConnectionMenu();
return 0;
}

@ -3,6 +3,7 @@
* \brief Basic TextInput
* \author Allan Point
* \date 05/01/2022
* \copyright CECILL
*/
#ifndef TEXT_INPUT_INCLUDED
@ -21,7 +22,6 @@
* \typedef
* \brief A text-inputable zone representation
* \author Allan Point
* \copyright CECILL
* \date 05/01/2022
*/
typedef struct
@ -41,7 +41,6 @@ typedef struct
* \return True if all goes right. Else false.
* \author Allan Point
* \date 05/01/2022
* \copyright CECILL
*/
bool addCharacterToInputTextValueAtCursor(TextInput* textInput, const char charToAdd);
@ -51,7 +50,6 @@ bool addCharacterToInputTextValueAtCursor(TextInput* textInput, const char charT
* \return True if all goes right. Esle false.
* \author Allan Point
* \date 05/01/2022
* \copyright CECILL
*/
bool removeCharacterToInputTextValueAtCursor(TextInput* textInput);
@ -62,7 +60,6 @@ bool removeCharacterToInputTextValueAtCursor(TextInput* textInput);
* \return True on success. Esle false;
* \author Allan POINT
* \date 05/01/2022
* \copyright CECILL
*/
bool drawTextInputOnRenderer(SDL_Renderer* renderer, const TextInput* textInput);
@ -81,9 +78,8 @@ bool drawTextInputOnRenderer(SDL_Renderer* renderer, const TextInput* textInput)
* \return True on succsess. Esle false.
* \author Allan POINT
* \date 05/01/2022
* \copyright CECILL
*/
bool initTextInput(TextInput* textInput, const SDL_Rect* size, const SDL_Color* textColor, const TTF_Font* textFont);
bool initTextInput(TextInput* textInput, const SDL_Rect* size, const SDL_Color* textColor, TTF_Font* textFont);
/*
* \brief Free what is needed to be free and clear all data in the TextInput

@ -0,0 +1,13 @@
#ifndef MENU_CONNECTION_INCLUDED
#define MENU_CONNECTION_INCLUDED
#include <SDL2/SDL.h>
#include <string.h>
#include "engine/Button.h"
#include "engine/TextLabel.h"
#include "engine/TextInput.h"
#include "engine/FontUtils.h"
bool drawMenuConnection(const SDL_Renderer* renderer, TTF_Font* font, int w, int h);
#endif

@ -0,0 +1,4 @@
#include <SDL2/SDL.h>
#include <stdbool.h>
bool drawGameCreationMenu(SDL_Renderer* renderer, TTF_Font* font, int width, int height);

@ -1,10 +0,0 @@
#ifndef MENU_CONNECTION_INCLUDED
#define MENU_CONNECTION_INCLUDED
#include <SDL2/SDL.h>
#include <string.h>
#include "engine/Button.h"
bool drawMenuConnection(const SDL_Renderer* renderer);
#endif

@ -0,0 +1 @@
curvilingus/Curvilingus.otf

@ -0,0 +1,16 @@
Free font by Tup Wanders
http://www.tupwanders.nl
Licensed with a Creative Commons attribution license.
If you add to the font, please send me a copy! If you've made fun stuff with the font that you would like to show me, please send me that as well. I like that.
Have fun,
Tuppus
tupwanders@tupwanders.nl
If this font suddenly makes you feel like spending huge amounts of money, please do so by going to Paypal and transferring your fortune to tupwanders@tupwanders.nl
And if this font suddenly makes feel like spending small or fairly large amounts of money, you can do that via Paypal as well.
More fonts here:
http://www.dafont.com/tup-wanders.d2245

Binary file not shown.

@ -138,6 +138,7 @@ bool drawTextInputOnRenderer(SDL_Renderer* renderer, const TextInput* textInput)
return false;
}
textTexture = SDL_CreateTextureFromSurface(renderer, textRendered);
SDL_FreeSurface(textRendered);
if(textTexture == NULL)
{
fprintf(stderr, "WARNING: Can't create texture from surface: %s\n", SDL_GetError());
@ -159,10 +160,11 @@ bool drawTextInputOnRenderer(SDL_Renderer* renderer, const TextInput* textInput)
fprintf(stderr, "WARNING: Can't copy the text on renderer");
return false;
}
SDL_DestroyTexture(textTexture);
return true;
}
bool initTextInput(TextInput* textInput, const SDL_Rect* size, const SDL_Color* textColor, const TTF_Font* font)
bool initTextInput(TextInput* textInput, const SDL_Rect* size, const SDL_Color* textColor, TTF_Font* font)
{
if(textInput == NULL)
{

@ -0,0 +1,41 @@
#include "view/ConnectionMenu.h"
bool drawMenuConnection(const SDL_Renderer* renderer, TTF_Font* font, int w, int h)
{
if(font == NULL)
{
fprintf(stderr, "WARNING: Font can't be null\n");
return false;
}
TextInput pseudoInput;
P_Button connectionButton;
SDL_Color black = {255,255,255,255};
SDL_Rect pseudoInputRect = {50, h*0.35, 50, 20};
char title[] = "Connexion";
SDL_Point titlePos = {.x=w*0.05, .y=h*0.1};
TextLabel titleLabel = createTextLabel(title, &titlePos, &black, font, renderer);
char pseudoText[] = "Pseudonyme: ";
SDL_Point pseudoPos = {.x=w*0.05, .y=h*0.35};
TextLabel pseudoLabel = createTextLabel(pseudoText, &pseudoPos, &black, font, renderer);
char colorText[] = "Couleur: ";
SDL_Point colorPos = {.x=w*0.05, .y=h*0.55};
TextLabel colorLabel = createTextLabel(colorText, &colorPos, &black, font, renderer);
if(!initTextInput(&pseudoInput, &pseudoInputRect, NULL, font))
{
fprintf(stderr, "WARNING: Can't init TextInput\n");
return false;
}
drawTextLabel(renderer, &titleLabel);
drawTextLabel(renderer, &pseudoLabel);
drawTextLabel(renderer, &colorLabel);
return true;
}

@ -1,17 +0,0 @@
#include "view/MenuConnection.h"
bool drawMenuConnection(const SDL_Renderer* renderer)
{
const char title[] = "Connexion";
const unsigned int titleHeightPercetange = 8;
const char pseudoLabel[] = "Pseudonyme: ";
const unsigned int pseudoLabelHeightPercentage = 16;
const char colorLabel[] = "Couleur: ";
const unsigned int colorLabelHeihetPercentage = 18;
return true;
}

@ -0,0 +1,98 @@
#include <SDL2/SDL.h>
#include <stdio.h>
#include "view/ConnectionMenu.h"
#include "engine/FontLoader.h"
#include "engine/TextInput.h"
int testConnectionMenu(void) {
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture* picture;
TextInput textInput;
int statut = EXIT_FAILURE;
char* path = "rsrc/img/Lenna.png";
int i=0;
int w, h;
if(0 != SDL_Init(SDL_INIT_VIDEO))
{
fprintf(stderr, "Erreur SDL_INIT: %s\n", SDL_GetError());
goto Quit;
}
//fenetre
window = SDL_CreateWindow("Fenêtre", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640,480, SDL_WINDOW_SHOWN);
if(window == NULL)
{
fprintf(stderr, "Erreur SDL_CreateWindow: %s\n", SDL_GetError());
goto Quit;
}
//rendu
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(renderer == NULL)
{
fprintf(stderr, "Erreur SDL_CreateRenderer: %s\n", SDL_GetError());
goto Quit;
}
//Fonts
if(TTF_Init() == -1)
{
fprintf(stderr, "Erreur: TTF_Init: %s\n", TTF_GetError());
goto Quit;
}
if(0 != SDL_SetRenderDrawColor(renderer, 0,0,0,0)) //choisi la couleur avec laquelle travailler
{
fprintf(stderr, "Erreur SDL_SetRenderDrawColor: %s\n", SDL_GetError());
goto Quit;
}
if(0 != SDL_RenderClear(renderer)) //efface le rendu en le repeignant avec la couleur choisi
{
fprintf(stderr, "Erreur SDL_SetRenderDrawColor: %s\n", SDL_GetError());
goto Quit;
}
if(0 != SDL_SetRenderDrawColor(renderer, 255,255,255,255)) //choisi la couleur avec laquelle travailler
{
fprintf(stderr, "Erreur SDL_SetRenderDrawColor: %s\n", SDL_GetError());
goto Quit;
}
SDL_bool quit = SDL_FALSE;
SDL_Event event;
FontHandler fontHandler = loadFonts();
SDL_GetWindowSize(window, &w, &h);
while(!quit)
{
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_QUIT:
quit = SDL_TRUE;
break;
case SDL_MOUSEBUTTONUP:
break;
}
}
drawMenuConnection(renderer, fontHandler.fonts[FONT_retro], w, h);
SDL_RenderPresent(renderer);
SDL_Delay(20);
}
Quit:
freeFonts(fontHandler);
if(renderer != NULL)
SDL_DestroyRenderer(renderer);
if(window != NULL)
SDL_DestroyWindow(window);
TTF_Quit();
SDL_Quit();
return statut;
}
Loading…
Cancel
Save