#include "common.h"

static int register_indices[REGISTER_SKILL_COUNT] = {
    IDX_MINING, IDX_COMBAT, IDX_CASTING, IDX_EXPLORATION, IDX_DUNGEONEERING, IDX_QUESTING};
static const char *register_skill_names[REGISTER_SKILL_COUNT] = {
    "Mining","Combat","Casting","Exploration","Dungeoneering","Questing"};

// Register tab
void DrawTabRegister(int cX, int cY, int *skills)
{
    DrawText("REGISTER",cX,cY,22,C_GOLD_L);
    HDivider(cX,cY+28,640);
    int sum=0;
    for(int i=0;i<REGISTER_SKILL_COUNT;i++) sum+=skills[register_indices[i]];
    int register_level=sum/REGISTER_SKILL_COUNT;
    Panel((Rectangle){(float)cX,(float)(cY+40),320.f,100.f},C_PANEL2,C_BORDER);
    DrawText("S_Lord",cX+16,cY+52,24,C_GOLD_L);
    Badge(cX+16, cY+84,"Rank: Gold",C_PANEL3,C_MUTED);
    char rls[32]; snprintf(rls,sizeof(rls),"Level %d",register_level);
    Badge(cX+130,cY+84,rls,C_PANEL3,C_BLUE_L);
    HDivider(cX,cY+156,640);
    DrawText("REGISTERED SKILLS",cX,cY+164,13,C_MUTED);
    for(int i=0;i<REGISTER_SKILL_COUNT;i++){
        int y=cY+186+i*40, val=skills[register_indices[i]];
        Panel((Rectangle){(float)cX,(float)y,460.f,32.f},C_PANEL2,C_BORDER);
        DrawText(register_skill_names[i],cX+14,y+8,16,C_TEXT);
        char vs[16]; snprintf(vs,sizeof(vs),"%d",val);
        DrawText(vs,cX+460-MeasureText(vs,16)-14,y+8,16,val>0?C_GREEN_L:val<0?C_RED_L:C_MUTED);
    }
}
