#include "texturelodinformation.h"
#include "ui_texturelodinformation.h"
#include "modelcreatordata.h"

TextureLodInformation::TextureLodInformation(QWidget *parent) :
    QWidget(parent),
    m_ui(new Ui::TextureLodInformation)
{
    m_ui->setupUi(this);
}

TextureLodInformation::~TextureLodInformation()
{
    delete m_ui;
}

void TextureLodInformation::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}
void TextureLodInformation::updateWidgetValues(int level)
{
    QString width, height, line_size, texture_size;
    width.setNum(MCD->texture[id].get_lod_data(level)->lod_info->width);
    height.setNum(MCD->texture[id].get_lod_data(level)->lod_info->height);
    line_size.setNum(MCD->texture[id].get_lod_data(level)->lod_info->line_size);
    texture_size.setNum(MCD->texture[id].get_lod_data(level)->lod_info->data_size);
    m_ui->Width->setText(width);
    m_ui->Height->setText(height);
    m_ui->LineSize->setText(line_size);
    m_ui->TextureSize->setText(texture_size);
}

void TextureLodInformation::textureLoaded(int subid)
{
    id = subid;
    int level = 0;
    m_ui->LODLevelWidget->setValue(level);
    m_ui->LODLevelWidget->setMaximum(MCD->texture[id].get_header()->lod_number);
    updateWidgetValues(level);
}
