Added textmenu

This commit is contained in:
2021-09-08 23:10:59 -07:00
parent f19ec89aba
commit 9ef961f871
10 changed files with 196 additions and 72 deletions

View File

@ -7,51 +7,30 @@
#include "sandboxscene.h"
menuv2_t menu;
void gridTest(
void *user, int32_t i,
float screenWidth, float screenHeight,
float x, float y,
float width, float height
) {
sandboxscene_t *game = (sandboxscene_t *)user;
game->items[i].x = x;
game->items[i].y = y;
game->items[i].width = width;
game->items[i].height = height;
}
textmenu_t menu;
bool sandboxSceneInit(sandboxscene_t *game) {
menu2Init(&menu);
gridAddBreakpoint(&menu.grid, -1, 3, 1, 0, 0);
gridchild_t *child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,0, 1,1);
child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,1, 1,1);
child = gridAddChild(&menu.grid);
gridChildAddBreakpoint(child, 0,2, 1,1);
assetFontLoad(&game->font, "fonts/opensans/OpenSans-Regular.ttf");
assetTextureLoad(&game->texture, "test_texture.png");
assetShaderLoad(&game->shader,
"shaders/textured.vert", "shaders/textured.frag"
);
quadInit(&game->primitive, 0,
0,0,0,0,
1,1,1,1
);
textMenuInit(&menu, &game->font);
gridAddBreakpoint(&menu.menu.grid, -1, 3, 1, 0, 0);
gridchild_t *child = textMenuListAdd(&menu, "First");
gridChildAddBreakpoint(child, 0,0, 1,1);
child = textMenuListAdd(&menu, "Second");
gridChildAddBreakpoint(child, 0,1, 1,1);
child = textMenuListAdd(&menu, "Third");
gridChildAddBreakpoint(child, 0,2, 1,1);
return true;
}
void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
cameraLookAt(&game->camera,
0, 0, 10,
0, 0, 0
@ -67,29 +46,13 @@ void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
shaderUseCamera(&game->shader, &game->camera);
shaderUseTexture(&game->shader, &game->texture);
menu2Update(&menu, engine);
gridSetSize(&menu.grid,
engine->render.width, engine->render.height,
gridSetSize(&menu.menu.grid,
engine->render.width, engine->render.height,
engine->render.width, FONT_LINE_HEIGHT * fontGetScale(16.0f) * 3,
0, 0
);
// gridSetSize(&grid,
// engine->render.width, engine->render.height,
// engine->render.width, engine->render.height,
// 0, 0
// );
for(uint8_t i = 0; i < GRID_BRUH_COUNT; i++) {
gridbruh_t *b = game->items + i;
shaderUsePositionAndScale(&game->shader,
b->x, b->y, 0,
0, 0, 0,
b->width, b->height, 1
);
primitiveDraw(&game->primitive, 0, -1);
}
menu2Update(&menu.menu, engine);
textMenuListRender(&menu, &game->shader, 0, 0);
}
void sandboxSceneDispose(sandboxscene_t *game) {

View File

@ -19,6 +19,7 @@
#include "../../ui/grid.h"
#include "../../ui/menuv2.h"
#include "../../ui/textmenu.h"
/**
* Initialize the sandbox scene test game.