Commit 5a65ba14 authored by Johannes Bergmeier's avatar Johannes Bergmeier

- Add missing support for values from 10 to 25 in renderer

- Add missing nodes in the artwork
BUG:178818

svn path=/trunk/KDE/kdegames/ksudoku/; revision=911850
parent 9dd59ca9
......@@ -181,10 +181,17 @@ QPixmap Renderer::renderSpecial(SpecialType type, int size) const {
return pix;
}
QPixmap Renderer::renderSymbol(int symbol, int size, SymbolType type) const {
QPixmap Renderer::renderSymbol(int symbol, int size, int max, SymbolType type) const {
if(!m_renderer->isValid() || size == 0) return QPixmap();
QString cacheName = QString("symbol_%1_%2_%3").arg(symbol).arg(size).arg(type);
QString set;
if(max <= 9) {
set = "symbol";
} else {
set = "symbol25";
}
QString cacheName = QString("%1_%2_%3_%4").arg(set).arg(symbol).arg(size).arg(type);
QPixmap pix;
if(!m_cache->find(cacheName, pix)) {
pix = QPixmap(size, size);
......@@ -202,17 +209,17 @@ QPixmap Renderer::renderSymbol(int symbol, int size, SymbolType type) const {
switch(type) {
case SymbolPreset:
if(m_renderer->elementExists(QString("symbol_%1_preset").arg(symbol))) {
m_renderer->render(&p, QString("symbol_%1_preset").arg(symbol), r);
if(m_renderer->elementExists(QString("%1_%2_preset").arg(set).arg(symbol))) {
m_renderer->render(&p, QString("%1_%2_preset").arg(set).arg(symbol), r);
} else {
m_renderer->render(&p, QString("symbol_%1").arg(symbol), r);
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
}
break;
case SymbolEdited:
if(m_renderer->elementExists(QString("symbol_%1_edited").arg(symbol))) {
m_renderer->render(&p, QString("symbol_%1_edited").arg(symbol), r);
if(m_renderer->elementExists(QString("%1_%2_edited").arg(set).arg(symbol))) {
m_renderer->render(&p, QString("%1_%2_edited").arg(set).arg(symbol), r);
} else {
m_renderer->render(&p, QString("symbol_%1").arg(symbol), r);
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
}
break;
}
......@@ -223,9 +230,9 @@ QPixmap Renderer::renderSymbol(int symbol, int size, SymbolType type) const {
return pix;
}
QPixmap Renderer::renderSymbolOn(QPixmap pixmap, int symbol, int color, SymbolType type) const {
QPixmap Renderer::renderSymbolOn(QPixmap pixmap, int symbol, int color, int max, SymbolType type) const {
int size = pixmap.width();
QPixmap symbolPixmap = renderSymbol(symbol, size, type);
QPixmap symbolPixmap = renderSymbol(symbol, size, max, type);
if(color) {
// TODO this does not work, need some other way, maybe hardcode color into NumberType
QPainter p(&symbolPixmap);
......@@ -246,6 +253,23 @@ QPixmap Renderer::renderSymbolOn(QPixmap pixmap, int symbol, int color, SymbolTy
QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
if(!m_renderer->isValid() || size == 0) return QPixmap();
QString set;
if(range <= 9) {
set = "symbol";
} else {
set = "symbol25";
}
// TODO this is a hardcoded list of possible marker-groupings
// replace it with a test for possible markers
if(range <= 9) {
range = 9;
} else if(range <= 16) {
range = 16;
} else {
range = 25;
}
QString groupName = QString("markers%1").arg(range);
QString cacheName = QString("%1_%2_%3").arg(groupName).arg(symbol).arg(size);
......@@ -265,7 +289,7 @@ QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
r.setTopLeft(fromRectToRect(r.topLeft(), from, to));
r.setBottomRight(fromRectToRect(r.bottomRight(), from, to));
m_renderer->render(&p, QString("symbol_%1").arg(symbol), r);
m_renderer->render(&p, QString("%1_%2").arg(set).arg(symbol), r);
p.end();
m_cache->insert(cacheName, pix);
}
......@@ -274,6 +298,8 @@ QPixmap Renderer::renderMarker(int symbol, int range, int size) const {
}
QPixmap Renderer::renderMarkerOn(QPixmap pixmap, int symbol, int range, int color) const {
// TODO maybe it would be good to directly integrate the renderMarker implementation and
// make renderMarker be based on this method. (same for renderSymbol and renderSymbolOn)
int size = pixmap.width();
QPixmap symbolPixmap = renderMarker(symbol, range, size);
if(color) {
......
......@@ -84,8 +84,8 @@ public:
QPixmap renderBorder(int border, GroupTypes type, int size) const;
QPixmap renderSymbol(int symbol, int size, SymbolType type) const;
QPixmap renderSymbolOn(QPixmap pixmap, int symbol, int color, SymbolType type) const;
QPixmap renderSymbol(int symbol, int size, int max, SymbolType type) const;
QPixmap renderSymbolOn(QPixmap pixmap, int symbol, int color, int max, SymbolType type) const;
QPixmap renderMarker(int symbol, int range, int size) const;
QPixmap renderMarkerOn(QPixmap pixmap, int symbol, int range, int color) const;
......
......@@ -136,7 +136,7 @@ void RoxdokuView::initializeGL()
int sz = 64;
QPixmap pic = Renderer::instance()->renderSpecial3D(SpecialCell, sz);
if(i != 0) {
pic = Renderer::instance()->renderSymbolOn(pic, i, 0, SymbolPreset);
pic = Renderer::instance()->renderSymbolOn(pic, i, 0, 9+o*16, SymbolPreset);
}
QImage pix = convertToGLFormat(pic.toImage());
......
......@@ -32,23 +32,26 @@ namespace ksudoku {
class SymbolItem : public QGraphicsPixmapItem {
public:
SymbolItem(int value, ValueListWidget* widget);
SymbolItem(int value, int maxValue, ValueListWidget* widget);
public:
int value() const;
int maxValue() const;
void setSize(double size);
void mousePressEvent(QGraphicsSceneMouseEvent* event);
private:
int m_value;
int m_maxValue;
double m_size;
ValueListWidget* m_widget;
};
SymbolItem::SymbolItem(int value, ValueListWidget* widget)
SymbolItem::SymbolItem(int value, int maxValue, ValueListWidget* widget)
: m_widget(widget)
{
setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
m_value = value;
m_maxValue = maxValue;
}
int SymbolItem::value() const {
......@@ -57,7 +60,7 @@ int SymbolItem::value() const {
void SymbolItem::setSize(double size) {
QPixmap pic = Renderer::instance()->renderSpecial(SpecialListItem, size);
pic = Renderer::instance()->renderSymbolOn(pic, m_value, 0, SymbolPreset);
pic = Renderer::instance()->renderSymbolOn(pic, m_value, 0, m_maxValue, SymbolPreset);
hide();
setPixmap(pic);
......@@ -113,8 +116,6 @@ void SelectionItem::selectValue(int value) {
ValueListWidget::ValueListWidget(QWidget* parent)
: QGraphicsView(parent)
{
// m_table = 0;
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
......@@ -132,11 +133,6 @@ ValueListWidget::ValueListWidget(QWidget* parent)
ValueListWidget::~ValueListWidget() {
}
// SymbolTable* ValueListWidget::currentTable() const {
// return m_table;
// }
// void ValueListWidget::setCurrentTable(SymbolTable* table, int maxValue) {
void ValueListWidget::setMaxValue(int maxValue) {
m_maxValue = maxValue;
......@@ -148,7 +144,7 @@ void ValueListWidget::setMaxValue(int maxValue) {
m_symbols.clear();
for(int i = 0; i < maxValue; ++i) {
item = new SymbolItem(i+1, this);
item = new SymbolItem(i+1, maxValue, this);
item->setSize(20);
item->setPos(0, (i+0.5)*20);
m_scene->addItem(item);
......
......@@ -76,7 +76,7 @@ CellGraphicsItem::CellGraphicsItem(QPoint pos, int id, View2DScene* scene) {
m_scene = scene;
m_id = id;
m_type = SpecialCell;
m_range = 9; // TODO change this hardcoded value
m_range = scene->maxValue();
}
void CellGraphicsItem::resize(int gridSize) {
......@@ -132,12 +132,12 @@ void CellGraphicsItem::updatePixmap() {
case SpecialCell:
case SpecialCellMistake:
if(m_values.size() > 0) {
pic = Renderer::instance()->renderSymbolOn(pic, m_values[0].value, m_values[0].color, SymbolEdited);
pic = Renderer::instance()->renderSymbolOn(pic, m_values[0].value, m_values[0].color, m_range, SymbolEdited);
}
break;
case SpecialCellPreset:
if(m_values.size() > 0) {
pic = Renderer::instance()->renderSymbolOn(pic, m_values[0].value, 0, SymbolPreset);
pic = Renderer::instance()->renderSymbolOn(pic, m_values[0].value, 0, m_range, SymbolPreset);
}
break;
case SpecialCellMarkers: {
......
......@@ -48,6 +48,8 @@ public:
void hover(int cell);
void press(int cell, bool rightButton = false);
inline int maxValue() const { return m_game.order(); }
public slots:
void selectValue(int val);
void enterValue(int val, int cell=-1);
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment