Implemented first cut at sprite preview area.
This commit is contained in:
parent
9d138bd8eb
commit
53047762c4
|
@ -2723,7 +2723,7 @@ spriteViewerDialog_t::spriteViewerDialog_t(QWidget *parent)
|
||||||
frame->setLayout( vbox );
|
frame->setLayout( vbox );
|
||||||
hbox1->addWidget( frame );
|
hbox1->addWidget( frame );
|
||||||
vbox->addWidget( preView );
|
vbox->addWidget( preView );
|
||||||
frame->hide(); // TODO Hide until preview code is ready
|
//frame->hide(); // TODO Hide until preview code is ready
|
||||||
|
|
||||||
|
|
||||||
updateTimer = new QTimer( this );
|
updateTimer = new QTimer( this );
|
||||||
|
@ -2807,6 +2807,7 @@ void spriteViewerDialog_t::periodicUpdate(void)
|
||||||
tileView->setIndex(idx);
|
tileView->setIndex(idx);
|
||||||
tileView->setIndex(idx);
|
tileView->setIndex(idx);
|
||||||
palView->setIndex(idx);
|
palView->setIndex(idx);
|
||||||
|
preView->setIndex(idx);
|
||||||
|
|
||||||
oamView->update();
|
oamView->update();
|
||||||
tileView->update();
|
tileView->update();
|
||||||
|
@ -3279,6 +3280,11 @@ oamPreview_t::oamPreview_t(QWidget *parent)
|
||||||
oamPreview_t::~oamPreview_t(void)
|
oamPreview_t::~oamPreview_t(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void oamPreview_t::setIndex(int val)
|
||||||
|
{
|
||||||
|
selSprite = val;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
int oamPreview_t::heightForWidth(int w) const
|
int oamPreview_t::heightForWidth(int w) const
|
||||||
|
@ -3294,13 +3300,15 @@ void oamPreview_t::resizeEvent(QResizeEvent *event)
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void oamPreview_t::paintEvent(QPaintEvent *event)
|
void oamPreview_t::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
int w,h;
|
int w,h,i,j,x,y,xx,yy,nt;
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
//QColor color;
|
QColor bgColor(0, 0, 0);
|
||||||
//QPen pen;
|
QPen pen;
|
||||||
//char showSelector;
|
//char showSelector;
|
||||||
|
char spriteRendered[64];
|
||||||
|
struct oamSpriteData_t *spr;
|
||||||
|
|
||||||
//pen = painter.pen();
|
pen = painter.pen();
|
||||||
|
|
||||||
viewWidth = event->rect().width();
|
viewWidth = event->rect().width();
|
||||||
viewHeight = event->rect().height();
|
viewHeight = event->rect().height();
|
||||||
|
@ -3317,5 +3325,62 @@ void oamPreview_t::paintEvent(QPaintEvent *event)
|
||||||
w = h;
|
w = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( palo != NULL )
|
||||||
|
{
|
||||||
|
int p = palcache[0];
|
||||||
|
|
||||||
|
bgColor.setRed( palo[p].r );
|
||||||
|
bgColor.setGreen( palo[p].g );
|
||||||
|
bgColor.setBlue( palo[p].b );
|
||||||
|
}
|
||||||
|
painter.fillRect( 0, 0, w*256, h*240, bgColor );
|
||||||
|
|
||||||
|
nt = ( oamPattern.mode8x16 ) ? 2 : 1;
|
||||||
|
|
||||||
|
for (i=63; i>=0; i--)
|
||||||
|
{
|
||||||
|
spr = &oamPattern.sprite[i];
|
||||||
|
|
||||||
|
spriteRendered[i] = 0;
|
||||||
|
//printf("Sprite: (%i,%i) -> (%02X,%02X) \n", spr->x, spr->y, spr->x, spr->y );
|
||||||
|
|
||||||
|
// Check if sprite is off screen
|
||||||
|
if ( spr->y >= 0xEF )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yy = spr->y * h;
|
||||||
|
|
||||||
|
for (j=0; j<nt; j++)
|
||||||
|
{
|
||||||
|
for (y=0; y<8; y++)
|
||||||
|
{
|
||||||
|
xx = spr->x * w;
|
||||||
|
|
||||||
|
for (x=0; x < 8; x++)
|
||||||
|
{
|
||||||
|
painter.fillRect( xx, yy, w, h, spr->tile[j].pixel[y][x].color );
|
||||||
|
xx += w;
|
||||||
|
}
|
||||||
|
yy += h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spriteRendered[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( spriteRendered[ selSprite ] )
|
||||||
|
{
|
||||||
|
spr = &oamPattern.sprite[selSprite];
|
||||||
|
|
||||||
|
pen.setWidth( 1 );
|
||||||
|
pen.setColor( QColor(128,128,128) );
|
||||||
|
painter.setPen( pen );
|
||||||
|
|
||||||
|
yy = spr->y * h;
|
||||||
|
xx = spr->x * w;
|
||||||
|
|
||||||
|
painter.drawRect( xx, yy, w*8, h*nt*8 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
|
|
@ -402,6 +402,7 @@ class oamPreview_t : public QWidget
|
||||||
oamPreview_t( QWidget *parent = 0);
|
oamPreview_t( QWidget *parent = 0);
|
||||||
~oamPreview_t(void);
|
~oamPreview_t(void);
|
||||||
|
|
||||||
|
void setIndex(int val);
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
@ -410,6 +411,7 @@ class oamPreview_t : public QWidget
|
||||||
private:
|
private:
|
||||||
int viewWidth;
|
int viewWidth;
|
||||||
int viewHeight;
|
int viewHeight;
|
||||||
|
int selSprite;
|
||||||
};
|
};
|
||||||
|
|
||||||
class spriteViewerDialog_t : public QDialog
|
class spriteViewerDialog_t : public QDialog
|
||||||
|
|
Loading…
Reference in New Issue