/**
 * 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;

    // Chips label
    labelInit(&playerUi->labelChips);
    playerUi->labelChips.fontSize = 12.0;

    // Name Label
    labelInit(&playerUi->labelName);
    playerUi->labelName.fontSize = 12.0;
    // labelSetText(&playerUi->labelChips, &pokerGame->assets.font, character->name);
  }
}

void pokerUiRender(pokergame_t *pokerGame) {
  pokerplayerui_t *playerUi;
  pokerplayer_t *playerPoker;
  uint8_t i;
  char buffer[256];

  for(i = 0; i < POKER_PLAYER_COUNT; i++) {
    break;
    playerUi = pokerGame->ui.players + i;
    playerPoker = pokerGame->poker.players + i;

    // Player Chips
    sprintf(buffer, "%u chips", playerPoker->chips);
    playerUi->labelChips.y = ((float)i+1.0f) * 32.0f;
    labelSetText(&playerUi->labelChips, &pokerGame->assets.font, buffer);
    labelRender(&playerUi->labelChips, &pokerGame->assets.shader);

    // Player Name
    labelRender(&playerUi->labelName, &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->labelChips);
  }
}