Moved some code around.
This commit is contained in:
@ -8,8 +8,7 @@
|
||||
#include "pokerplayerui.h"
|
||||
|
||||
void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
||||
gridchild_t *child;
|
||||
|
||||
gridInit(&ui->grid);
|
||||
labelInit(&ui->label);
|
||||
frameBufferInit(&ui->frame,
|
||||
POKER_PLAYER_UI_IMAGE_RESOLUTION, POKER_PLAYER_UI_IMAGE_RESOLUTION
|
||||
@ -19,21 +18,6 @@ void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
||||
POKER_PLAYER_UI_IMAGE_SIZE, POKER_PLAYER_UI_IMAGE_SIZE, 1, 0
|
||||
);
|
||||
|
||||
// Grid
|
||||
gridInit(&ui->grid);
|
||||
gridAddBreakpoint(&ui->grid, -1, 2, 2, POKER_PLAYER_UI_PADDING, 0);
|
||||
|
||||
// Player UI Image
|
||||
child = gridAddChild(&ui->grid);
|
||||
gridChildAddBreakpoint(child, 1,0, 1,2);
|
||||
|
||||
// Chips
|
||||
child = gridAddChild(&ui->grid);
|
||||
gridChildAddBreakpoint(child, 0,0, 1,1);
|
||||
|
||||
// Title.
|
||||
child = gridAddChild(&ui->grid);
|
||||
gridChildAddBreakpoint(child, 0,1, 1,1);
|
||||
}
|
||||
|
||||
void pokerPlayerUiUpdate(
|
||||
@ -99,51 +83,51 @@ void pokerPlayerUiRender(
|
||||
engine->render.width, engine->render.height,
|
||||
POKER_PLAYER_UI_IMAGE_SIZE*2, POKER_PLAYER_UI_IMAGE_SIZE, -1, -1
|
||||
);
|
||||
gridSetSize(
|
||||
&ui->grid, engine->render.width, engine->render.height,
|
||||
align.width, align.height,
|
||||
align.x + x, align.y + y
|
||||
);
|
||||
// gridSetSize(
|
||||
// &ui->grid, engine->render.width, engine->render.height,
|
||||
// align.width, align.height,
|
||||
// align.x + x, align.y + y
|
||||
// );
|
||||
|
||||
// Render face
|
||||
gridGetChildSize(&ui->grid, ui->grid.breakpointCurrent, ui->grid.children+0,
|
||||
&sCol, &sRow, &gx, &gy, &gw, &gh
|
||||
);
|
||||
shaderUseTexture(shader, &ui->frame.texture);
|
||||
shaderUsePosition(shader, gx, gy, 0, 0,0,0);
|
||||
primitiveDraw(&ui->quad, 0, -1);
|
||||
// // Render face
|
||||
// gridGetChildSize(&ui->grid, ui->grid.breakpointCurrent, ui->grid.children+0,
|
||||
// &sCol, &sRow, &gx, &gy, &gw, &gh
|
||||
// );
|
||||
// shaderUseTexture(shader, &ui->frame.texture);
|
||||
// shaderUsePosition(shader, gx, gy, 0, 0,0,0);
|
||||
// primitiveDraw(&ui->quad, 0, -1);
|
||||
|
||||
// Render chips
|
||||
sprintf(buffer, "$%i", player->chips);
|
||||
ui->label.maxWidth = -1;
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
align = gridAlignChild(
|
||||
&ui->grid, ui->grid.breakpointCurrent, ui->grid.children + 1, &sCol, &sRow,
|
||||
ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
ui->label.info.width, ui->label.info.height
|
||||
);
|
||||
labelRender(&ui->label, shader, align.x, align.y);
|
||||
// // Render chips
|
||||
// sprintf(buffer, "$%i", player->chips);
|
||||
// ui->label.maxWidth = -1;
|
||||
// labelSetText(&ui->label, font, buffer);
|
||||
// align = gridAlignChild(
|
||||
// &ui->grid, ui->grid.breakpointCurrent, ui->grid.children + 1, &sCol, &sRow,
|
||||
// ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
// ui->label.info.width, ui->label.info.height
|
||||
// );
|
||||
// labelRender(&ui->label, shader, align.x, align.y);
|
||||
|
||||
|
||||
// Render state
|
||||
if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||
sprintf(buffer, "Out");
|
||||
} else if(player->state & POKER_PLAYER_STATE_FOLDED) {
|
||||
sprintf(buffer, "Folded");
|
||||
} else if(player->state & POKER_PLAYER_STATE_SHOWING) {
|
||||
sprintf(buffer, "Showing");
|
||||
} else if(game->poker.bet.better == playerIndex) {
|
||||
sprintf(buffer, "Thinking");
|
||||
} else {
|
||||
sprintf(buffer, "Whatever");
|
||||
}
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
align = gridAlignChild(
|
||||
&ui->grid, ui->grid.breakpointCurrent, ui->grid.children + 2, &sCol, &sRow,
|
||||
ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
ui->label.info.width, ui->label.info.height
|
||||
);
|
||||
labelRender(&ui->label, shader, align.x, align.y);
|
||||
// // Render state
|
||||
// if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||
// sprintf(buffer, "Out");
|
||||
// } else if(player->state & POKER_PLAYER_STATE_FOLDED) {
|
||||
// sprintf(buffer, "Folded");
|
||||
// } else if(player->state & POKER_PLAYER_STATE_SHOWING) {
|
||||
// sprintf(buffer, "Showing");
|
||||
// } else if(game->poker.bet.better == playerIndex) {
|
||||
// sprintf(buffer, "Thinking");
|
||||
// } else {
|
||||
// sprintf(buffer, "Whatever");
|
||||
// }
|
||||
// labelSetText(&ui->label, font, buffer);
|
||||
// align = gridAlignChild(
|
||||
// &ui->grid, ui->grid.breakpointCurrent, ui->grid.children + 2, &sCol, &sRow,
|
||||
// ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
// ui->label.info.width, ui->label.info.height
|
||||
// );
|
||||
// labelRender(&ui->label, shader, align.x, align.y);
|
||||
}
|
||||
|
||||
void pokerPlayerUiDispose(pokerplayerui_t *ui) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sandboxscene.h"
|
||||
|
||||
framedtextmenu_t menu;
|
||||
framedtextmenu_t ftm;
|
||||
|
||||
bool sandboxSceneInit(sandboxscene_t *game) {
|
||||
assetFontLoad(&game->font, "fonts/opensans/OpenSans-Regular.ttf");
|
||||
@ -15,19 +15,16 @@ bool sandboxSceneInit(sandboxscene_t *game) {
|
||||
assetShaderLoad(&game->shader,
|
||||
"shaders/textured.vert", "shaders/textured.frag"
|
||||
);
|
||||
|
||||
framedTextMenuInit(&menu, &game->font, &game->texture);
|
||||
|
||||
gridAddBreakpoint(&menu.menu.menu.grid, -1, 2, 3, 0, 0);
|
||||
|
||||
gridchild_t *child = textMenuListAdd(&menu.menu, "First");
|
||||
gridChildAddBreakpoint(child, 0,0, 1,1);
|
||||
child = textMenuListAdd(&menu.menu, "Second");
|
||||
gridChildAddBreakpoint(child, 0,1, 1,1);
|
||||
child = textMenuListAdd(&menu.menu, "Third");
|
||||
gridChildAddBreakpoint(child, 0,2, 1,1);
|
||||
child = textMenuListAdd(&menu.menu, "Fourth");
|
||||
gridChildAddBreakpoint(child, 1,0, 1,1);
|
||||
menuitem_t *item;
|
||||
framedTextMenuInit(&ftm, &game->font, &game->texture);
|
||||
ftm.menu.grid.rows = 3;
|
||||
item = textMenuAdd(&ftm.menu, "Option 1");
|
||||
item->y = 0;
|
||||
item = textMenuAdd(&ftm.menu, "Option 2");
|
||||
item->y = 1;
|
||||
item = textMenuAdd(&ftm.menu, "Option 3");
|
||||
item->y = 2;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -46,12 +43,10 @@ void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
|
||||
|
||||
shaderUse(&game->shader);
|
||||
shaderUseCamera(&game->shader, &game->camera);
|
||||
shaderUseTexture(&game->shader, &game->texture);
|
||||
|
||||
float x, y;
|
||||
|
||||
framedTextMenuUpdate(&menu, engine);
|
||||
framedTextMenuRender(&menu, &game->shader, 0, 0);
|
||||
framedTextMenuResize(&ftm, 400, 400);
|
||||
framedTextMenuUpdate(&ftm, engine);
|
||||
framedTextMenuRender(&ftm, &game->shader, 0, 0);
|
||||
}
|
||||
|
||||
void sandboxSceneDispose(sandboxscene_t *game) {
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "../../ui/grid.h"
|
||||
#include "../../ui/menu.h"
|
||||
#include "../../ui/textmenu.h"
|
||||
#include "../../ui/image.h"
|
||||
#include "../../ui/framedtextmenu.h"
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user