//
// Created by sasha on 01.12.2025.
//

#include "label_info_victory.h"

LabelInfoVictory::LabelInfoVictory(IWidget *parent, float x, float y, const std::string &text,const std::string &type): IWidget (parent,x,y,272,64) {
    this->text=text;

    image = new Image(this,x,y,272,64,"");
    textDescription = new Text(this,image->getFRect().x+20,image->getFRect().y+22.5);
    textDescription->setCached(true);
    textValue = new Text(this,image->getFRect().x+199,image->getFRect().y+20);

    setType(type);
}

LabelInfoVictory::~LabelInfoVictory() {
    delete image;
    delete textDescription;
    delete textValue;
}

void LabelInfoVictory::setValue(const std::string &value) {
    textValue->setText(value,"inter.ttf",20,{255,255,255});
    textValue->move(image->getFRect().x+ (image->getFRect().w-textValue->getFRect().w-20) , textValue->getFRect().y);
}

void LabelInfoVictory::setType(const std::string &type) {
    std::string filename = "";

    if (type=="easy"){
        filename = "victory_label_green.png";
        textDescription->setText(text,"inter.ttf",16,{0xE0,0xFF,0xFF});
    }
    if (type=="normal"){
        filename="victory_label_blue.png";
        textDescription->setText(text,"inter.ttf",16,{0xA9,0xC6,0xFF});
    }
    if (type=="hard"){
        filename="victory_label_red.png";
        textDescription->setText(text,"inter.ttf",16,{0xFF,0xDA,0xDB});
    }
    image->setTexture(filename);
}


