Set up user interface integration

This commit is contained in:
Doyle Thai 2016-11-26 14:11:59 +11:00
parent 91cc891b36
commit 9cfe60fcf8
4 changed files with 57 additions and 0 deletions

View File

@ -917,6 +917,32 @@ void asteroid_gameUpdateAndRender(GameState *state, Memory *memory,
collideColor, flags);
}
{ // Draw Ui
UiState *uiState = &state->uiState;
MemoryArena_ *transientArena = &state->transientArena;
AssetManager *assetManager = &state->assetManager;
Renderer *renderer = &state->renderer;
InputBuffer *inputBuffer = &state->input;
userInterface_beginState(uiState);
WindowState window = {0};
window.id = userInterface_generateId(uiState);
Rect windowRect = {0};
windowRect.min = V2(200, 200);
windowRect.max = V2(500, 500);
window.rect = windowRect;
#if 0
userInterface_window(uiState, transientArena, assetManager, renderer,
&assetManager->font, *inputBuffer, &window);
#endif
userInterface_endState(uiState, inputBuffer);
}
for (i32 i = 0; i < world->numAudioRenderers; i++)
{
AudioRenderer *audioRenderer = &world->audioRenderer[i];

View File

@ -1,9 +1,33 @@
#include "Dengine/UserInterface.h"
#include "Dengine/AssetManager.h"
#include "Dengine/Assets.h"
#include "Dengine/Asteroid.h"
#include "Dengine/Debug.h"
#include "Dengine/Renderer.h"
void userInterface_beginState(UiState *state)
{
state->hotItem = 0;
}
void userInterface_endState(UiState *state, InputBuffer *input)
{
if (!common_isSet(input->keys[keycode_mouseLeft].flags,
keystateflag_ended_down))
{
state->activeItem = 0;
}
else if (state->activeItem == 0)
{
state->activeItem = -1;
}
if (state->keyEntered == keycode_tab) state->kbdItem = 0;
state->keyEntered = keycode_null;
state->keyChar = keycode_null;
}
i32 userInterface_button(UiState *const uiState, MemoryArena_ *const arena,
AssetManager *const assetManager,
Renderer *const renderer, Font *const font,

View File

@ -8,6 +8,7 @@
#include "Dengine/MemoryArena.h"
#include "Dengine/Platform.h"
#include "Dengine/Renderer.h"
#include "Dengine/UserInterface.h"
typedef struct World
{
@ -48,6 +49,8 @@ typedef struct GameState {
AssetManager assetManager;
InputBuffer input;
Renderer renderer;
UiState uiState;
World world;
} GameState;

View File

@ -10,6 +10,7 @@ typedef struct AssetManager AssetManager;
typedef struct Font Font;
typedef struct MemoryArena MemoryArena_;
typedef struct Renderer Renderer;
typedef struct GameState GameState;
enum UiType
{
@ -76,6 +77,9 @@ inline i32 userInterface_generateId(UiState *const uiState)
return result;
}
void userInterface_beginState(UiState *state);
void userInterface_endState(UiState *state, InputBuffer *input);
i32 userInterface_button(UiState *const uiState, MemoryArena_ *const arena,
AssetManager *const assetManager,
Renderer *const renderer, Font *const font,