initial port for Cevo game in C++ (libs)
This commit is contained in:
commit
8436242032
375 files changed
+46282
No files matched your search
@@ -0,0 +1,101 @@
|
||||
#include "Cevo/CevoButtonG.h"
|
||||
#include "Cevo/CevoScreenTools.h"
|
||||
|
||||
namespace Cevo {
|
||||
|
||||
ButtonG::ButtonG(QWidget *parent) : ButtonBase(parent) {}
|
||||
|
||||
GraphicSetItem *ButtonG::resolveItem(int index, const QString &name) const
|
||||
{
|
||||
if (!m_graphicSet)
|
||||
return nullptr;
|
||||
if (index != -1 && index < m_graphicSet->items().count())
|
||||
return m_graphicSet->items().at(index);
|
||||
if (!name.isEmpty())
|
||||
return m_graphicSet->searchByName(name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ButtonG::paint(Dpi::Canvas &canvas)
|
||||
{
|
||||
bool drawn = false;
|
||||
Dpi::Bitmap buffer(width(), height());
|
||||
if (m_graphicSet) {
|
||||
GraphicSetItem *back = down() ? resolveItem(m_backgroundDownIndex, m_backgroundDownName)
|
||||
: resolveItem(m_backgroundUpIndex, m_backgroundUpName);
|
||||
if (back) {
|
||||
bitBltBitmap(buffer, 0, 0, back->width, back->height, m_graphicSet->data, back->left, back->top);
|
||||
drawn = true;
|
||||
}
|
||||
GraphicSetItem *glyph = resolveItem(m_glyphIndex, m_glyphName);
|
||||
if (glyph) {
|
||||
bitBltBitmap(buffer, 0, 0, glyph->width, glyph->height, m_graphicSet->mask,
|
||||
glyph->left, glyph->top, RasterOp::And);
|
||||
bitBltBitmap(buffer, 0, 0, glyph->width, glyph->height, m_graphicSet->data,
|
||||
glyph->left, glyph->top, RasterOp::Paint);
|
||||
drawn = true;
|
||||
}
|
||||
}
|
||||
if (drawn) {
|
||||
canvas.draw(0, 0, buffer.image());
|
||||
} else {
|
||||
canvas.brush().setColor(colorFromDelphi(0x0000FF));
|
||||
canvas.frameRect(QRect(0, 0, width() - 1, height() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonG::setBackgroundUpIndex(int value)
|
||||
{
|
||||
if (m_backgroundUpIndex == value)
|
||||
return;
|
||||
m_backgroundUpIndex = value;
|
||||
m_backgroundUpName.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void ButtonG::setBackgroundUpName(const QString &value)
|
||||
{
|
||||
if (m_backgroundUpName == value)
|
||||
return;
|
||||
m_backgroundUpName = value;
|
||||
m_backgroundUpIndex = -1;
|
||||
update();
|
||||
}
|
||||
|
||||
void ButtonG::setBackgroundDownIndex(int value)
|
||||
{
|
||||
if (m_backgroundDownIndex == value)
|
||||
return;
|
||||
m_backgroundDownIndex = value;
|
||||
m_backgroundDownName.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void ButtonG::setBackgroundDownName(const QString &value)
|
||||
{
|
||||
if (m_backgroundDownName == value)
|
||||
return;
|
||||
m_backgroundDownName = value;
|
||||
m_backgroundDownIndex = -1;
|
||||
update();
|
||||
}
|
||||
|
||||
void ButtonG::setGlyphIndex(int value)
|
||||
{
|
||||
if (m_glyphIndex == value)
|
||||
return;
|
||||
m_glyphIndex = value;
|
||||
m_glyphName.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void ButtonG::setGlyphName(const QString &value)
|
||||
{
|
||||
if (m_glyphName == value)
|
||||
return;
|
||||
m_glyphName = value;
|
||||
m_glyphIndex = -1;
|
||||
update();
|
||||
}
|
||||
|
||||
} // namespace Cevo
|
||||
Reference in new issue
Block a user