You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.5 KiB
57 lines
2.5 KiB
#include "uiContainer.h"
|
|
#include "../game.h"
|
|
#include "button.h"
|
|
#include "raylib.h"
|
|
#include "stdlib.h"
|
|
#include "stdio.h"
|
|
|
|
UiContainer * UiContainerInitPauseUiContainer(){
|
|
UiContainer *uiContainer = malloc(sizeof(UiContainer));
|
|
|
|
Texture2D textures[4] = { LoadTexture("assets/button.png"), //DEFAULT
|
|
LoadTexture("assets/button_hovered.png"), //HOVERED
|
|
LoadTexture("assets/button_pressed.png"), //PRESSED
|
|
LoadTexture("assets/button_pressed.png")}; //RELEASED
|
|
Vector2 position = (Vector2){GetScreenWidth()/2 - textures[0].width/2, GetScreenHeight()/2 - 300};
|
|
|
|
Button *continuebutton = ButtonInitButton(textures, &position, "Continue", 9, BUTTON_ID_CONTINUE);
|
|
uiContainer->buttons[0] = continuebutton;
|
|
uiContainer->buttonCounter = 1;
|
|
|
|
Texture2D textures2[4] = { LoadTexture("assets/button.png"), //DEFAULT
|
|
LoadTexture("assets/button_hovered.png"), //HOVERED
|
|
LoadTexture("assets/button_pressed.png"), //PRESSED
|
|
LoadTexture("assets/button_pressed.png")}; //RELEASED
|
|
|
|
Vector2 position2 = (Vector2){GetScreenWidth()/2 - textures[0].width/2, GetScreenHeight()/2 - 50};
|
|
Button *exitButton = ButtonInitButton(textures2, &position2, "EXIT", 5, BUTTON_ID_EXIT);
|
|
uiContainer->buttons[1] = exitButton;
|
|
uiContainer->buttonCounter = 2;
|
|
|
|
// Methode funktioniert wieso auch immer auch ohne dieses return. C returned Implizit odder was O_o
|
|
return uiContainer;
|
|
}
|
|
|
|
UiContainer * UiContainerInitGameUiContainer(){
|
|
printf("\n\n\n\n UiContainerInitGameUiContainer not implemented yet!! \n\n\n\n");
|
|
return 0;
|
|
}
|
|
|
|
// Updated alle Buttons und führt gegebenenfalls deren Code aus
|
|
void UiContainerUpdateUiContainer(UiContainer *uiContainer, Game *game){
|
|
int i = 0;
|
|
for(i=0 ; i < uiContainer->buttonCounter; i++){
|
|
ButtonUpdateButtonState(uiContainer->buttons[i]);
|
|
if(uiContainer->buttons[i]->state == BUTTON_STATE_RELEASED){
|
|
ButtonExecuteButton(uiContainer->buttons[i], game);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Drawed alle Buttons
|
|
void UiContainerDrawUiContainer(UiContainer *uiContainer){
|
|
int i = 0;
|
|
for(i=0 ; i < uiContainer->buttonCounter; i++){
|
|
ButtonDrawButton(uiContainer->buttons[i]);
|
|
}
|
|
} |