Render x/y for UI elements.
This commit is contained in:
@ -38,12 +38,13 @@
|
||||
|
||||
#include "game/dawn/dawngame.h"
|
||||
|
||||
#include "game/poker/ui/pokerplayerui.h"
|
||||
#include "game/poker/ui/pokerui.h"
|
||||
#include "game/poker/pokerdiscussion.h"
|
||||
#include "game/poker/pokergame.h"
|
||||
#include "game/poker/pokergameaction.h"
|
||||
#include "game/poker/pokergameassets.h"
|
||||
#include "game/poker/pokerworld.h"
|
||||
#include "game/poker/pokerui.h"
|
||||
|
||||
// Player Input
|
||||
#include "input/input.h"
|
||||
|
@ -10,8 +10,8 @@
|
||||
#include "../../display/animation/queue.h"
|
||||
#include "pokergameassets.h"
|
||||
#include "pokerworld.h"
|
||||
#include "pokerui.h"
|
||||
#include "pokergameaction.h"
|
||||
#include "ui/pokerui.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "../../poker/player.h"
|
||||
#include "../../poker/dealer.h"
|
||||
|
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../ui/label.h"
|
||||
#include "../../poker/player.h"
|
||||
|
||||
typedef struct {
|
||||
label_t labelInfo;
|
||||
} pokerplayerui_t;
|
||||
|
||||
typedef struct {
|
||||
pokerplayerui_t players[POKER_PLAYER_COUNT];
|
||||
label_t labelGameInfo;
|
||||
} pokerui_t;
|
14
include/dawn/game/poker/ui/pokerplayerui.h
Normal file
14
include/dawn/game/poker/ui/pokerplayerui.h
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../ui/label.h"
|
||||
|
||||
typedef struct {
|
||||
label_t label;
|
||||
} pokerplayerui_t;
|
15
include/dawn/game/poker/ui/pokerui.h
Normal file
15
include/dawn/game/poker/ui/pokerui.h
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../../libs.h"
|
||||
#include "../../../poker/player.h"
|
||||
#include "pokerplayerui.h"
|
||||
|
||||
typedef struct {
|
||||
pokerplayerui_t player[POKER_PLAYER_COUNT];
|
||||
} pokerui_t;
|
@ -18,7 +18,6 @@
|
||||
#define FRAME_PRIMITIVE_COUNT 9
|
||||
|
||||
typedef struct {
|
||||
float x, y;
|
||||
texture_t *texture;
|
||||
primitive_t primitive;
|
||||
} frame_t;
|
@ -10,7 +10,6 @@
|
||||
#include "../display/primitive.h"
|
||||
|
||||
typedef struct {
|
||||
float x, y;
|
||||
texture_t *texture;
|
||||
primitive_t quad;
|
||||
float u0, v0;
|
||||
|
@ -13,7 +13,6 @@
|
||||
/** Representation of a Label UI Element */
|
||||
typedef struct {
|
||||
font_t *font;
|
||||
float x, y;
|
||||
float fontSize;
|
||||
fonttextinfo_t info;
|
||||
primitive_t primitive;
|
||||
|
@ -25,7 +25,6 @@ typedef void menulistcallback_t(menulist_t *list, uint8_t i, void *user);
|
||||
|
||||
/** Representation of a menu list, a menu with multiple menu items. */
|
||||
typedef struct _menulist_t {
|
||||
float x, y;
|
||||
char *items[MENULIST_ITEMS_MAX];
|
||||
label_t labels[MENULIST_ITEMS_MAX];
|
||||
frame_t frame;
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "../display/primitive.h"
|
||||
|
||||
typedef struct {
|
||||
float x, y;
|
||||
float width, height;
|
||||
texture_t texture;
|
||||
primitive_t quad;
|
||||
|
@ -33,9 +33,6 @@ typedef struct {
|
||||
int32_t linesMax;
|
||||
int32_t lineCurrent;
|
||||
|
||||
/** X, Y Position of the textbox */
|
||||
float x, y;
|
||||
|
||||
/** Readonly values for the dimensions of the textbox */
|
||||
float width, height;
|
||||
|
||||
|
@ -13,12 +13,10 @@
|
||||
#include "../../vn/vnscene.h"
|
||||
#include "../../util/array.h"
|
||||
#include "actions/start.h"
|
||||
#include "pokerui.h"
|
||||
#include "ui/pokerui.h"
|
||||
#include "pokerworld.h"
|
||||
#include "actions/start.h"
|
||||
|
||||
#include "../../ui/menulist.h"
|
||||
|
||||
/**
|
||||
* Initializes the game state for the poker game.
|
||||
*
|
||||
|
@ -1,68 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerui.h"
|
||||
|
||||
void pokerUiInit(pokergame_t *pokerGame) {
|
||||
pokerplayerui_t *playerUi;
|
||||
pokerplayer_t *playerPoker;
|
||||
vncharacter_t *character;
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
playerUi = pokerGame->ui.players + i;
|
||||
playerPoker = pokerGame->poker.players + i;
|
||||
character = pokerGame->scene.characters + i;
|
||||
|
||||
labelInit(&playerUi->labelInfo);
|
||||
playerUi->labelInfo.fontSize = 12.0;
|
||||
}
|
||||
|
||||
labelInit(&pokerGame->ui.labelGameInfo);
|
||||
pokerGame->ui.labelGameInfo.fontSize = 12.0f;
|
||||
}
|
||||
|
||||
void pokerUiRender(pokergame_t *pokerGame) {
|
||||
pokerplayerui_t *playerUi;
|
||||
pokerplayer_t *playerPoker;
|
||||
uint8_t i;
|
||||
char buffer[256];
|
||||
|
||||
sprintf(buffer, "Pot %i\n", pokerGame->poker.bet.pot);
|
||||
labelSetText(&pokerGame->ui.labelGameInfo, &pokerGame->assets.font, buffer);
|
||||
pokerGame->ui.labelGameInfo.x = 350;
|
||||
labelRender(&pokerGame->ui.labelGameInfo, &pokerGame->assets.shader);
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
playerUi = pokerGame->ui.players + i;
|
||||
playerPoker = pokerGame->poker.players + i;
|
||||
|
||||
// Player Chips
|
||||
sprintf(buffer, "Player %u - %u chips - %s%s",
|
||||
i,
|
||||
playerPoker->chips,
|
||||
i == POKER_PLAYER_HUMAN_INDEX ? "Human" : "AI",
|
||||
i == pokerGame->poker.bet.better ? " Betting" :
|
||||
playerPoker->state & POKER_PLAYER_STATE_FOLDED ? " Folded" :
|
||||
playerPoker->state & POKER_PLAYER_STATE_OUT ? " Out" :
|
||||
""
|
||||
);
|
||||
playerUi->labelInfo.y = (float)i * 32.0f;
|
||||
labelSetText(&playerUi->labelInfo, &pokerGame->assets.font, buffer);
|
||||
labelRender(&playerUi->labelInfo, &pokerGame->assets.shader);
|
||||
}
|
||||
}
|
||||
|
||||
void pokerUiDispose(pokergame_t *pokerGame) {
|
||||
pokerplayerui_t *player;
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
player = pokerGame->ui.players + i;
|
||||
labelDispose(&player->labelInfo);
|
||||
}
|
||||
}
|
51
src/game/poker/ui/pokerplayerui.c
Normal file
51
src/game/poker/ui/pokerplayerui.c
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerplayerui.h"
|
||||
|
||||
void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
||||
labelInit(&ui->label);
|
||||
}
|
||||
|
||||
void pokerPlayerUiRender(
|
||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font,
|
||||
int32_t playerIndex, float x, float y
|
||||
) {
|
||||
pokerplayer_t *player;
|
||||
char buffer[32];
|
||||
float scale;
|
||||
|
||||
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
||||
player = game->poker.players + playerIndex;
|
||||
|
||||
// Render chips
|
||||
sprintf(buffer, "$%i", player->chips);
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
labelRender(&ui->label, shader, x, 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);
|
||||
labelRender(&ui->label, shader, x, y + scale * FONT_LINE_HEIGHT);
|
||||
|
||||
// Render face?
|
||||
|
||||
}
|
||||
|
||||
void pokerPlayerUiDispose(pokerplayerui_t *ui) {
|
||||
labelDispose(&ui->label);
|
||||
}
|
20
src/game/poker/ui/pokerplayerui.h
Normal file
20
src/game/poker/ui/pokerplayerui.h
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "../../../ui/label.h"
|
||||
|
||||
|
||||
void pokerPlayerUiInit(pokerplayerui_t *ui);
|
||||
|
||||
void pokerPlayerUiRender(
|
||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font,
|
||||
int32_t playerIndex, float x, float y
|
||||
);
|
||||
|
||||
void pokerPlayerUiDispose(pokerplayerui_t *ui);
|
39
src/game/poker/ui/pokerui.c
Normal file
39
src/game/poker/ui/pokerui.c
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "pokerui.h"
|
||||
|
||||
void pokerUiInit(pokergame_t *pokerGame) {
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
pokerPlayerUiInit(pokerGame->ui.player + i);
|
||||
}
|
||||
}
|
||||
|
||||
void pokerUiRender(pokergame_t *pokerGame) {
|
||||
uint8_t i;
|
||||
pokerplayerui_t *ui;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
ui = pokerGame->ui.player + i;
|
||||
|
||||
pokerPlayerUiRender(ui, pokerGame,
|
||||
&pokerGame->assets.shader, &pokerGame->assets.font,
|
||||
i,
|
||||
i * 150.0f, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void pokerUiDispose(pokergame_t *pokerGame) {
|
||||
uint8_t i;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
pokerPlayerUiDispose(pokerGame->ui.player + i);
|
||||
}
|
||||
}
|
@ -7,7 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "../../ui/label.h"
|
||||
#include "../../../ui/label.h"
|
||||
#include "pokerplayerui.h"
|
||||
|
||||
/**
|
||||
* Initializes the UI Module.
|
@ -8,9 +8,6 @@
|
||||
#include "frame.h"
|
||||
|
||||
void frameInit(frame_t *frame) {
|
||||
frame->x = 0;
|
||||
frame->y = 0;
|
||||
|
||||
primitiveInit(
|
||||
&frame->primitive,
|
||||
QUAD_VERTICE_COUNT * FRAME_PRIMITIVE_COUNT,
|
||||
@ -103,8 +100,8 @@ void frameSetInnerSize(frame_t *frame, float width, float height) {
|
||||
);
|
||||
}
|
||||
|
||||
void frameRender(frame_t *frame, shader_t *shader) {
|
||||
shaderUsePosition(shader, frame->x, frame->y, 0, 0, 0, 0);
|
||||
void frameRender(frame_t *frame, shader_t *shader, float x, float y) {
|
||||
shaderUsePosition(shader, x, y, 0, 0, 0, 0);
|
||||
shaderUseTexture(shader, frame->texture);
|
||||
primitiveDraw(&frame->primitive, 0, -1);
|
||||
}
|
||||
|
@ -41,8 +41,10 @@ void frameSetInnerSize(frame_t *frame, float width, float height);
|
||||
*
|
||||
* @param frame Frame to render.
|
||||
* @param shader Shader to use while rendering.
|
||||
* @param x X position.
|
||||
* @param y Y position.
|
||||
*/
|
||||
void frameRender(frame_t *frame, shader_t *shader);
|
||||
void frameRender(frame_t *frame, shader_t *shader, float x, float y);
|
||||
|
||||
/**
|
||||
* Cleanup a previously initialized frame.
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "image.h"
|
||||
|
||||
void imageInit(image_t *image, texture_t *texture) {
|
||||
image->x = 0;
|
||||
image->y = 0;
|
||||
image->quad.verticeCount = -1;
|
||||
imageSetTexture(image, texture);
|
||||
}
|
||||
@ -24,8 +22,8 @@ void imageSetTexture(image_t *image, texture_t *texture) {
|
||||
quadInit(&image->quad, 0, 0,0,0,0, texture->width,texture->height,1,1);
|
||||
}
|
||||
|
||||
void imageRender(image_t *image, shader_t *shader) {
|
||||
shaderUsePosition(shader, image->x, image->y, 0, 0, 0, 0);
|
||||
void imageRender(image_t *image, shader_t *shader, float x, float y) {
|
||||
shaderUsePosition(shader, x, y, 0, 0, 0, 0);
|
||||
primitiveDraw(&image->quad, 0, -1);
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,10 @@ void imageSetTexture(image_t *image, texture_t *texture);
|
||||
*
|
||||
* @param image Image to render.
|
||||
* @param shader Shader to use while rendering.
|
||||
* @param x X position.
|
||||
* @param y Y position.
|
||||
*/
|
||||
void imageRender(image_t *image, shader_t *shader);
|
||||
void imageRender(image_t *image, shader_t *shader, float x, float y);
|
||||
|
||||
/**
|
||||
* Cleanup a previously initialized image.
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "label.h"
|
||||
|
||||
void labelInit(label_t *label) {
|
||||
label->x = 0;
|
||||
label->y = 0;
|
||||
label->fontSize = FONT_SIZE_DEFAULT;
|
||||
label->font = NULL;
|
||||
label->primitive.verticeCount = 0;
|
||||
@ -26,9 +24,9 @@ void labelSetText(label_t *label, font_t *font, char *text) {
|
||||
fontTextInit(font, &label->primitive, &label->info);
|
||||
}
|
||||
|
||||
void labelRender(label_t *label, shader_t *shader) {
|
||||
void labelRender(label_t *label, shader_t *shader, float x, float y) {
|
||||
if(label->primitive.verticeCount == 0) return;
|
||||
shaderUsePosition(shader, label->x,label->y,0, 0,0,0);
|
||||
shaderUsePosition(shader, x,y,0, 0,0,0);
|
||||
shaderUseTexture(shader, &label->font->texture);
|
||||
primitiveDraw(&label->primitive, 0, -1);
|
||||
}
|
||||
|
@ -29,8 +29,10 @@ void labelSetText(label_t *label, font_t *font, char *text);
|
||||
*
|
||||
* @param label Label to render.
|
||||
* @param shader Shader to use while rendering.
|
||||
* @param x X position.
|
||||
* @param y Y position.
|
||||
*/
|
||||
void labelRender(label_t *label, shader_t *shader);
|
||||
void labelRender(label_t *label, shader_t *shader, float x, float y);
|
||||
|
||||
/**
|
||||
* Dispose a previously created label.
|
||||
|
@ -14,8 +14,6 @@ void _menuListMenuOnSelect(menu_t *menu, menuitem_t *item, uint8_t i, void *u) {
|
||||
}
|
||||
|
||||
void menuListInit(menulist_t *ml, texture_t *texture) {
|
||||
ml->x = 0;
|
||||
ml->y = 0;
|
||||
ml->onSelect = NULL;
|
||||
|
||||
// Initialize menu
|
||||
@ -67,33 +65,29 @@ void menuListUpdate(menulist_t *ml, engine_t *engine) {
|
||||
menuUpdate(&ml->menu, engine);
|
||||
}
|
||||
|
||||
void menuListRender(menulist_t *ml, shader_t *shader) {
|
||||
void menuListRender(menulist_t *ml, shader_t *shader, float x, float y) {
|
||||
uint8_t i;
|
||||
label_t *label;
|
||||
float fontScale;
|
||||
|
||||
fontScale = fontGetScale(ml->labels->fontSize);
|
||||
|
||||
// Render the frame
|
||||
ml->frame.x = ml->x;
|
||||
ml->frame.y = ml->y;
|
||||
frameRender(&ml->frame, shader);
|
||||
frameRender(&ml->frame, shader, x, y);
|
||||
|
||||
// Render selection box.
|
||||
ml->selection.x = ml->x + FRAME_BORDER_SIZE;
|
||||
ml->selection.y = ml->y + FRAME_BORDER_SIZE +(
|
||||
ml->menu.selected * FONT_LINE_HEIGHT * fontScale
|
||||
);
|
||||
ml->selection.width = 100;
|
||||
ml->selection.height = FONT_LINE_HEIGHT * fontScale;
|
||||
rectangleRender(&ml->selection, shader);
|
||||
rectangleRender(&ml->selection, shader,
|
||||
x + FRAME_BORDER_SIZE,
|
||||
y + FRAME_BORDER_SIZE +ml->menu.selected * FONT_LINE_HEIGHT * fontScale
|
||||
);
|
||||
|
||||
// Render each label.
|
||||
for(i = 0; i < ml->menu.itemCount; i++) {
|
||||
label = ml->labels + i;
|
||||
label->x = FRAME_BORDER_SIZE;
|
||||
label->y = FRAME_BORDER_SIZE + i * FONT_LINE_HEIGHT * fontScale;
|
||||
labelRender(label, shader);
|
||||
labelRender(ml->labels + i, shader,
|
||||
FRAME_BORDER_SIZE,
|
||||
FRAME_BORDER_SIZE + i * FONT_LINE_HEIGHT * fontScale
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,10 @@ void menuListUpdate(menulist_t *ml, engine_t *engine);
|
||||
*
|
||||
* @param ml Menu list to render.
|
||||
* @param shader Shader to use.
|
||||
* @param x X position.
|
||||
* @param y Y position.
|
||||
*/
|
||||
void menuListRender(menulist_t *ml, shader_t *shader);
|
||||
void menuListRender(menulist_t *ml, shader_t *shader, float x, float y);
|
||||
|
||||
/**
|
||||
* Cleanup a previously created menu list.
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "rectangle.h"
|
||||
|
||||
void rectangleInit(rectangle_t *rectangle) {
|
||||
rectangle->x = 0;
|
||||
rectangle->y = 0;
|
||||
rectangle->width = 32;
|
||||
rectangle->height = 32;
|
||||
textureInit(&rectangle->texture, 1, 1, NULL);
|
||||
@ -22,14 +20,14 @@ void rectangleSetColor(rectangle_t *rectangle, pixel_t color) {
|
||||
);
|
||||
}
|
||||
|
||||
void rectangleRender(rectangle_t *rectangle, shader_t *shader) {
|
||||
void rectangleRender(rectangle_t *rect, shader_t *shader, float x, float y) {
|
||||
shaderUsePositionAndScale(shader,
|
||||
rectangle->x, rectangle->y, 0,
|
||||
x, y, 0,
|
||||
0, 0, 0,
|
||||
rectangle->width, rectangle->height, 1
|
||||
rect->width, rect->height, 1
|
||||
);
|
||||
shaderUseTexture(shader, &rectangle->texture);
|
||||
primitiveDraw(&rectangle->quad, 0, -1);
|
||||
shaderUseTexture(shader, &rect->texture);
|
||||
primitiveDraw(&rect->quad, 0, -1);
|
||||
}
|
||||
|
||||
void rectangleDispose(rectangle_t *rectangle) {
|
||||
|
@ -16,6 +16,6 @@ void rectangleInit(rectangle_t *rectangle);
|
||||
|
||||
void rectangleSetColor(rectangle_t *rectangle, pixel_t color);
|
||||
|
||||
void rectangleRender(rectangle_t *rectangle, shader_t *shader);
|
||||
void rectangleRender(rectangle_t *rect, shader_t *shader, float x, float y);
|
||||
|
||||
void rectangleDispose(rectangle_t *rectangle);
|
@ -28,13 +28,16 @@ queueaction_t * vnConversationAdd(vnconversation_t *conversation) {
|
||||
}
|
||||
|
||||
void vnConversationUpdate(vnconversation_t *convo, engine_t *engine) {
|
||||
convo->textbox.y = engine->render.height - convo->textbox.height;
|
||||
vnTextBoxUpdate(&convo->textbox, engine);
|
||||
queueUpdate(&convo->actionQueue, engine);
|
||||
}
|
||||
|
||||
void vnConversationRender(vnconversation_t *convo, shader_t *shader) {
|
||||
vnTextBoxRender(&convo->textbox, shader);
|
||||
void vnConversationRender(
|
||||
vnconversation_t *convo, engine_t *engine, shader_t *shader
|
||||
) {
|
||||
vnTextBoxRender(&convo->textbox, shader,
|
||||
0, engine->render.height - convo->textbox.height
|
||||
);
|
||||
}
|
||||
|
||||
void vnConversationDispose(vnconversation_t *convo) {
|
||||
|
@ -38,9 +38,12 @@ void vnConversationUpdate(vnconversation_t *convo, engine_t *engine);
|
||||
/**
|
||||
* Renders the conversation, mostly just a wrapper for the textbox.
|
||||
* @param convo Conversation to render.
|
||||
* @param engine Engine to use for rendering.
|
||||
* @param shader Shader to use while rendering.
|
||||
*/
|
||||
void vnConversationRender(vnconversation_t *convo, shader_t *shader);
|
||||
void vnConversationRender(
|
||||
vnconversation_t *convo, engine_t *engine, shader_t *shader
|
||||
);
|
||||
|
||||
/**
|
||||
* Dispose the conversation when finished.
|
||||
|
@ -11,7 +11,6 @@ void vnTextBoxInit(vntextbox_t *box, font_t *font, texture_t *texture) {
|
||||
box->font = font;
|
||||
box->widthMax = 400;
|
||||
box->text = NULL;
|
||||
box->x = 0, box->y = 0;
|
||||
box->linesMax = 3;
|
||||
box->lineCurrent = 0;
|
||||
box->state = 0;
|
||||
@ -78,15 +77,13 @@ void vnTextBoxUpdate(vntextbox_t *box, engine_t *engine) {
|
||||
box->lineCurrent += box->linesMax;
|
||||
}
|
||||
|
||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader) {
|
||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader, float x, float y) {
|
||||
int32_t charStart, charCount;
|
||||
float yOffset;
|
||||
if(box->text == NULL || box->state & VN_TEXTBOX_STATE_CLOSED) return;
|
||||
|
||||
// Render the debug box.
|
||||
box->frame.x = box->x;
|
||||
box->frame.y = box->y;
|
||||
frameRender(&box->frame, shader);
|
||||
frameRender(&box->frame, shader, x, y);
|
||||
|
||||
// Determine where we're rendering the indices up to.
|
||||
charCount = (int32_t)box->textScroll;
|
||||
@ -116,7 +113,7 @@ void vnTextBoxRender(vntextbox_t *box, shader_t *shader) {
|
||||
|
||||
// Render the Text Box
|
||||
shaderUsePosition(shader,
|
||||
box->x + FRAME_BORDER_SIZE, box->y - yOffset + FRAME_BORDER_SIZE, 0,
|
||||
x + FRAME_BORDER_SIZE, y - yOffset + FRAME_BORDER_SIZE, 0,
|
||||
0,0,0
|
||||
);
|
||||
shaderUseTexture(shader, &box->font->texture);
|
||||
|
@ -52,8 +52,10 @@ void vnTextBoxUpdate(vntextbox_t *box, engine_t *engine);
|
||||
* will not be ticked, use update to do this.
|
||||
* @param box Box to render.
|
||||
* @param shader Shader to render to.
|
||||
* @param x X position.
|
||||
* @param y Y position.
|
||||
*/
|
||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader);
|
||||
void vnTextBoxRender(vntextbox_t *box, shader_t *shader, float x, float y);
|
||||
|
||||
/**
|
||||
* Disposes a previously created Visual Novel Text Box.
|
||||
|
@ -97,5 +97,5 @@ void vnSceneRenderGui(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
||||
shaderUseCamera(shader, &scene->camera);
|
||||
|
||||
// Render Conversation Element
|
||||
vnConversationRender(&scene->conversation, shader);
|
||||
vnConversationRender(&scene->conversation, engine, shader);
|
||||
}
|
Reference in New Issue
Block a user