Input processor start textinput

origin/fixingSettings
marouault 3 years ago
parent bcefa6c9c9
commit 42e41dde16

@ -73,16 +73,16 @@ int main(int argc, char *argv[]) {
}*/
generalState = GS_Game;
gameView(&generalState, window, renderer, players, nbPlayers, &fontHandler);
//gameView(&generalState, window, renderer, players, nbPlayers, &fontHandler);
//Pour tester le endGameMenu directement
generalState = GS_EndOfGameMenu;
/*players[0].eliminationTurn = 10;
players[0].eliminationTurn = 10;
players[0].rank = 3;
players[1].eliminationTurn = 15;
players[1].rank = 2;
players[2].eliminationTurn = 0;
players[2].rank = 1;*/
players[2].rank = 1;
endGameMenu(&generalState, window, renderer, &fontHandler, players, nbPlayers);
break;

@ -10,6 +10,8 @@
#include "engine/Button.h"
#include "engine/arrayButton.h"
#include "engine/TextInput.h"
#include "engine/arrayTextInput.h"
#include "engine/InputElement.h"
/**
@ -19,6 +21,8 @@
typedef struct
{
struct array_P_Button tabButton;
struct array_TextInput tabTextInput;
TextInput* selectedTextInput;
} InputProcessor;

@ -27,7 +27,8 @@
typedef struct
{
char* value;
int cursorPosition;
Sint32 cursorPosition;
SDL_Rect size;
bool isActive;
SDL_Color textColor;

@ -0,0 +1,9 @@
#ifndef ARRAY_TEXT_INPUT_INCLUDED
#define ARRAY_TEXT_INPUT_INCLUDED
#include "engine/TextInput.h"
#include "engine/ArrayUtils.h"
GENERATE_DYNAMIC_ARRAY(TextInput)
#endif //ARRAY_TEXT_INPUT_INCLUDED

@ -2,7 +2,8 @@
InputProcessor createInputProcessor() {
InputProcessor inputProcessor = {
.tabButton = array_P_Button_Create()
.tabButton = array_P_Button_Create(),
.tabTextInput = array_TextInput_Create()
};
return inputProcessor;
}
@ -33,6 +34,22 @@ InputElement proccessInput(InputProcessor *inputProcessor)
b->onClick(b);
}
}
bool textInputClicked = false;
for (size_t i = 0; i<inputProcessor->tabTextInput.size; ++i) {
TextInput* ti = &inputProcessor->tabTextInput.elems[i];
if (SDL_PointInRect(&mousePoint, &ti->size)) {
if (inputProcessor->selectedTextInput == NULL) {
SDL_StartTextInput();
}
inputProcessor->selectedTextInput = ti;
textInputClicked = true;
break;
}
}
if (!textInputClicked) {
inputProcessor->selectedTextInput = NULL;
SDL_StopTextInput();
}
return createInputElementNone();
}
case SDL_MOUSEMOTION:
@ -50,6 +67,12 @@ InputElement proccessInput(InputProcessor *inputProcessor)
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
return createInputElementResizeWindow(event.window.data1, event.window.data2);
}
break;
case SDL_TEXTINPUT:
break;
case SDL_TEXTEDITING:
break;
}

@ -50,9 +50,9 @@ struct array_TextLabel createGameInterfaceLabels(SDL_Renderer* renderer, FontHan
struct array_TextLabel labels = array_TextLabel_Create();
// Label : Nb Turn
TextLabel nbTurnLabel = createTextLabel("Turn : ",&positonNbTurnLabel,1,&colorLabel,fontHandler.fonts[FONT_retro],renderer,positionX,positionY);
TextLabel nbTurnLabel = createTextLabel("Turn : ",&positonNbTurnLabel,1,&colorLabel,fontHandler->fonts[FONT_retro],renderer,positionX,positionY);
// Label : Time of the game
TextLabel timeLabel = createTextLabel("Time : ",&positionTimeLablel,1,&colorLabel,fontHandler.fonts[FONT_retro],renderer,positionX,positionY);
TextLabel timeLabel = createTextLabel("Time : ",&positionTimeLablel,1,&colorLabel,fontHandler->fonts[FONT_retro],renderer,positionX,positionY);
//Add TextLabel to the array
array_TextLabel_AddElement(&labels, nbTurnLabel);

Loading…
Cancel
Save