Close to done refactoring now.
This commit is contained in:
@ -25,9 +25,9 @@ void _pokerGameActionBetOnUpdate(
|
||||
// Handle as an AI
|
||||
if(isHuman) {
|
||||
|
||||
if(inputIsPressed(&game->engine->input, INPUT_DOWN)) {
|
||||
} else if(inputIsPressed(&game->engine->input, INPUT_RIGHT)) {
|
||||
} else if(inputIsPressed(&game->engine->input, INPUT_UP)) {
|
||||
if(inputIsPressed(&game->engine.input, INPUT_DOWN)) {
|
||||
} else if(inputIsPressed(&game->engine.input, INPUT_RIGHT)) {
|
||||
} else if(inputIsPressed(&game->engine.input, INPUT_UP)) {
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -84,7 +84,9 @@ void _pokerGameActionBetOnEnd(
|
||||
pokergame_t *game = (pokergame_t *)action->data;
|
||||
|
||||
// Get which player is remaining to move.
|
||||
game->poker.bet.better = pokerBetGetRemainingPlayer(&game->poker);
|
||||
game->poker.bet.better = pokerBetGetRemainingPlayer(
|
||||
&game->poker.bet, game->poker.players, game->poker.roundSmallBlind
|
||||
);
|
||||
|
||||
// Restack
|
||||
pokerGameActionRestackAdd(game);
|
||||
@ -106,7 +108,9 @@ void _pokerGameActionBetOnEnd(
|
||||
discussion.poker = game;
|
||||
pokerDiscussionQueue(&discussion);
|
||||
|
||||
pokerBetResetBetter(&game->poker);
|
||||
pokerBetResetBetter(
|
||||
&game->poker, &game->poker.players, game->poker.roundSmallBlind
|
||||
);
|
||||
pokerGameActionRestackAdd(game);
|
||||
pokerGameActionLookAdd(game, game->poker.bet.better);
|
||||
pokerGameActionBetAdd(game);
|
||||
|
@ -9,9 +9,11 @@
|
||||
#include "../../../libs.h"
|
||||
#include "action.h"
|
||||
#include "restack.h"
|
||||
#include "../../../input/input.h"
|
||||
#include "../../../poker/turn.h"
|
||||
#include "../../../poker/bet.h"
|
||||
#include "../../../poker/actions/flop.h"
|
||||
#include "../pokerdiscussion.h"
|
||||
|
||||
/** Callback when the bet action is updated. */
|
||||
void _pokerGameActionBetOnUpdate(
|
||||
|
@ -41,7 +41,9 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){
|
||||
|
||||
// Begin Betting Round. This will queue for one player only and then the round
|
||||
// will take over.
|
||||
pokerBetResetBetter(&game->poker);
|
||||
pokerBetResetBetter(
|
||||
&game->poker, game->poker.players, game->poker.roundSmallBlind
|
||||
);
|
||||
pokerGameActionBetAdd(game);
|
||||
}
|
||||
|
||||
|
@ -18,10 +18,10 @@ bool gameInstanceInit(pokergame_t *game) {
|
||||
);
|
||||
|
||||
// Initialize the world
|
||||
pokerWorldInit(game);
|
||||
pokerWorldInit(&game->world, &game->scene, &game->assets);
|
||||
|
||||
// Initialize the UI.
|
||||
pokerUiInit(game);
|
||||
pokerUiInit(&game->ui);
|
||||
|
||||
// Add the first action, the game action, and then start the action queue.
|
||||
pokerGameActionStartAdd(game);
|
||||
@ -30,34 +30,40 @@ bool gameInstanceInit(pokergame_t *game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void gameInstanceUpdate(pokergame_t *game, engine_t *engine) {
|
||||
void gameInstanceUpdate(pokergame_t *game) {
|
||||
// Update the VN Engine.
|
||||
vnSceneUpdate(&game->scene, engine);
|
||||
vnSceneUpdate(&game->scene, &game->engine);
|
||||
|
||||
// Update the UI
|
||||
pokerUiUpdate(game, engine);
|
||||
pokerUiUpdate(
|
||||
&game->ui,
|
||||
&game->engine,
|
||||
&game->assets.shader,
|
||||
game->scene.characters,
|
||||
game->poker.players
|
||||
);
|
||||
|
||||
|
||||
// Bind the shader.
|
||||
shaderUse(&game->assets.shader);
|
||||
|
||||
// Render the visual novel scene.
|
||||
vnSceneRenderWorld(&game->scene, engine, &game->assets.shader);
|
||||
vnSceneRenderWorld(&game->scene, &game->engine, &game->assets.shader);
|
||||
|
||||
pokerWorldRender(&game->world, engine, &game->assets);
|
||||
pokerWorldRender(&game->world, &game->assets);
|
||||
vnSceneRenderCharacters(&game->scene, &game->assets.shader);
|
||||
|
||||
// Render the UI
|
||||
vnSceneRenderGui(&game->scene, engine, &game->assets.shader);
|
||||
pokerUiRender(game, engine);
|
||||
vnSceneRenderGui(&game->scene, &game->engine, &game->assets.shader);
|
||||
pokerUiRender(&game->ui, &game->engine, &game->assets, &game->poker);
|
||||
}
|
||||
|
||||
void gameInstanceDispose(pokergame_t *game) {
|
||||
//Cleanup the UI
|
||||
pokerUiDispose(game);
|
||||
pokerUiDispose(&game->ui);
|
||||
|
||||
// Cleanup the world
|
||||
pokerWorldDispose(game);
|
||||
pokerWorldDispose(&game->world);
|
||||
|
||||
// Destroy the Visual Novel engine.
|
||||
vnSceneDispose(&game->scene);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "pokerui.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokergameaction.h"
|
||||
#include "actions/start.h"
|
||||
|
||||
/**
|
||||
* Initializes the game state for the poker game.
|
||||
|
@ -83,7 +83,7 @@ void pokerUiUpdate(
|
||||
shaderUse(shader);
|
||||
shaderUseCamera(shader, &camera);
|
||||
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
||||
vnCharacterRender(characters + playerIndex, shader);
|
||||
vnCharacterRender(characters + j, shader);
|
||||
|
||||
// Increment
|
||||
j++;
|
||||
@ -92,34 +92,35 @@ void pokerUiUpdate(
|
||||
renderResetFramebuffer(&engine->render);
|
||||
}
|
||||
|
||||
void pokerUiRender(pokerui_t *ui, engine_t *engine, shader_t *shader) {
|
||||
void pokerUiRender(
|
||||
pokerui_t *ui, engine_t *engine, pokergameassets_t *assets, poker_t *poker
|
||||
) {
|
||||
uint8_t i, j;
|
||||
pokerplayerui_t *ui;
|
||||
pokerplayer_t *player;
|
||||
char message[128];
|
||||
float scale;
|
||||
align_t align;
|
||||
float gx, gy, gw, gh, x, y;
|
||||
char message[128];
|
||||
|
||||
// Get the default font scale size.
|
||||
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
||||
|
||||
// <testing>
|
||||
if(pokerGame->poker.state >= POKER_STATE_DEALING) {
|
||||
if(poker->state >= POKER_STATE_DEALING) {
|
||||
for(j = 0; j < POKER_PLAYER_COUNT; j++) {
|
||||
player = pokerGame->poker.players + j;
|
||||
player = poker->players + j;
|
||||
for(i = 0; i < player->cardCount; i++) {
|
||||
pokerCardSetImage(&pokerGame->ui.card, &pokerGame->assets.cardTexture, player->cards[i]);
|
||||
imageRender(&pokerGame->ui.card, &pokerGame->assets.shader, i * 64.0f, j * 100);
|
||||
pokerCardSetImage(&ui->card, &assets->cardTexture, player->cards[i]);
|
||||
imageRender(&ui->card, &assets->shader, i * 64.0f, j * 100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player = pokerGame->poker.players + POKER_PLAYER_HUMAN_INDEX;
|
||||
if(pokerGame->poker.bet.better == POKER_PLAYER_HUMAN_INDEX) {
|
||||
player = poker->players + POKER_PLAYER_HUMAN_INDEX;
|
||||
if(poker->bet.better == POKER_PLAYER_HUMAN_INDEX) {
|
||||
sprintf(message, "Press down to fold, up to bet, right to check/call.");
|
||||
labelSetText(&pokerGame->ui.player->label, &pokerGame->assets.font, message);
|
||||
labelRender(&pokerGame->ui.player->label, &pokerGame->assets.shader, 300, 100);
|
||||
labelSetText(&ui->label, &assets->font, message);
|
||||
labelRender(&ui->label, &assets->shader, 300, 100);
|
||||
}
|
||||
// </testing>
|
||||
j = 0;
|
||||
@ -127,7 +128,7 @@ void pokerUiRender(pokerui_t *ui, engine_t *engine, shader_t *shader) {
|
||||
if(i == POKER_PLAYER_HUMAN_INDEX) continue;
|
||||
|
||||
// Get the player.
|
||||
player = game->poker.players + i;
|
||||
player = poker->players + i;
|
||||
|
||||
// Position the grid itself.
|
||||
x = 0;
|
||||
@ -135,40 +136,40 @@ void pokerUiRender(pokerui_t *ui, engine_t *engine, shader_t *shader) {
|
||||
|
||||
// Render face
|
||||
gridGetChild(&ui->grid, 1, 0, 1, 2, &gx, &gy, &gw, &gh);
|
||||
shaderUseTexture(shader, &ui->frames + j);
|
||||
shaderUsePosition(shader, x + gx, y + gy, 0, 0,0,0);
|
||||
shaderUseTexture(&assets->shader, &ui->frames + j);
|
||||
shaderUsePosition(&assets->shader, x + gx, y + gy, 0, 0,0,0);
|
||||
primitiveDraw(&ui->quad, 0, -1);
|
||||
|
||||
// Render chips
|
||||
sprintf(buffer, "$%i", player->chips);
|
||||
sprintf(message, "$%i", player->chips);
|
||||
ui->label.maxWidth = -1;
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
labelSetText(&ui->label, &assets->font, message);
|
||||
align = gridGetAndAlignChild(
|
||||
&ui->grid, 0, 0, 1, 1,
|
||||
ALIGN_POS_END|ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER|ALIGN_SIZE_ORIGINAL,
|
||||
ui->label.info.width, ui->label.info.height
|
||||
);
|
||||
labelRender(&ui->label, shader, x+align.x, y+align.y);
|
||||
labelRender(&ui->label, &assets->shader, x+align.x, y+align.y);
|
||||
|
||||
// Render state
|
||||
if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||
sprintf(buffer, "Out");
|
||||
sprintf(message, "Out");
|
||||
} else if(player->state & POKER_PLAYER_STATE_FOLDED) {
|
||||
sprintf(buffer, "Folded");
|
||||
sprintf(message, "Folded");
|
||||
} else if(player->state & POKER_PLAYER_STATE_SHOWING) {
|
||||
sprintf(buffer, "Showing");
|
||||
} else if(game->poker.bet.better == playerIndex) {
|
||||
sprintf(buffer, "Thinking");
|
||||
sprintf(message, "Showing");
|
||||
} else if(poker->bet.better == j) {
|
||||
sprintf(message, "Thinking");
|
||||
} else {
|
||||
sprintf(buffer, "Whatever");
|
||||
sprintf(message, "Whatever");
|
||||
}
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
labelSetText(&ui->label, &assets->font, message);
|
||||
align = gridGetAndAlignChild(
|
||||
&ui->grid, 0, 1, 1, 1,
|
||||
ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL,
|
||||
ui->label.info.width, ui->label.info.height
|
||||
);
|
||||
labelRender(&ui->label, shader, x+align.x, y+align.y);
|
||||
labelRender(&ui->label, &assets->shader, x+align.x, y+align.y);
|
||||
|
||||
// Increment.
|
||||
j++;
|
||||
|
@ -21,7 +21,10 @@
|
||||
#include "../../ui/align.h"
|
||||
#include "../../poker/player.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "../../poker/bet.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokergameassets.h"
|
||||
|
||||
#define POKER_UI_PLAYER_IMAGE_SIZE 64
|
||||
#define POKER_UI_PLAYER_WIDTH 300
|
||||
@ -67,8 +70,12 @@ void pokerUiUpdate(
|
||||
*
|
||||
* @param ui UI to render.
|
||||
* @param engine Engine to use for the render.
|
||||
* @param assets Poker game assets.
|
||||
* @param poker Poker instance.
|
||||
*/
|
||||
void pokerUiRender(pokerui_t *ui, engine_t *engine);
|
||||
void pokerUiRender(
|
||||
pokerui_t *ui, engine_t *engine, pokergameassets_t *assets, poker_t *poker
|
||||
);
|
||||
|
||||
/**
|
||||
* Cleanup only the UI elements for a poker game.
|
||||
|
Reference in New Issue
Block a user