Source Code (Use browser search to find items of interest.)
Class Index
ksokoban'ImageData (./kdegames/ksokoban/ImageData.H:38)
ImageData {
public:
virtual ~ImageData();
int resize(int size);
int size() { return size_; }
void wall(QPainter &p, int x, int y, int index, bool left, bool right);
void floor(QPainter &p, int x, int y);
void goal(QPainter &p, int x, int y);
void man(QPainter &p, int x, int y);
void object(QPainter &p, int x, int y);
void saveman(QPainter &p, int x, int y);
void treasure(QPainter &p, int x, int y);
const QPixmap &background() { return background_; }
protected:
ImageData();
void expandIndex(int size);
const QPixmap &upperLarge(int index);
const QPixmap &lowerLarge(int index);
const QPixmap &leftSmall(int index);
const QPixmap &rightSmall(int index);
QImage images_[NO_OF_IMAGES];
QPixmap smallStone_xpm_[SMALL_STONES];
QPixmap largeStone_xpm_[LARGE_STONES];
QPixmap otherPixmaps_[OTHER_IMAGES];
QPixmap background_;
int indexSize_;
Array<char> upperLargeIndex_;
Array<char> lowerLargeIndex_;
Array<char> leftSmallIndex_;
Array<char> rightSmallIndex_;
int size_, halfSize_;
KRandomSequence random;
};
ksokoban'ImageData::ImageData() (./kdegames/ksokoban/ImageData.C:26)
ImageData::ImageData() : indexSize_(0), size_(0), halfSize_(0) {
random.setSeed(0);
}
ksokoban'ImageData::~ImageData() (./kdegames/ksokoban/ImageData.C:30)
ImageData::~ImageData() {
}
void
ksokoban'ImageData::expandIndex() (./kdegames/ksokoban/ImageData.C:34)
ImageData::expandIndex(int size) {
size++;
assert(size < 2500);
upperLargeIndex_.resize(size);
lowerLargeIndex_.resize(size);
leftSmallIndex_.resize(size);
rightSmallIndex_.resize(size);
for (int i=indexSize_; i<size; i++) {
upperLargeIndex_[i] = random.getLong(LARGE_STONES);
lowerLargeIndex_[i] = random.getLong(LARGE_STONES);
leftSmallIndex_[i] = random.getLong(SMALL_STONES);
rightSmallIndex_[i] = random.getLong(SMALL_STONES);
}
indexSize_ = size;
}
const QPixmap &
ksokoban'ImageData::upperLarge() (./kdegames/ksokoban/ImageData.C:54)
ImageData::upperLarge(int index) {
assert(index >= 0);
if (indexSize_ <= index) expandIndex(index);
return largeStone_xpm_[upperLargeIndex_[index]];
}
const QPixmap &
ksokoban'ImageData::lowerLarge() (./kdegames/ksokoban/ImageData.C:61)
ImageData::lowerLarge(int index) {
assert(index >= 0);
if (indexSize_ <= index) expandIndex(index);
return largeStone_xpm_[lowerLargeIndex_[index]];
}
const QPixmap &
ksokoban'ImageData::leftSmall() (./kdegames/ksokoban/ImageData.C:68)
ImageData::leftSmall(int index) {
assert(index >= 0);
if (indexSize_ <= index) expandIndex(index);
return smallStone_xpm_[leftSmallIndex_[index]];
}
const QPixmap &
ksokoban'ImageData::rightSmall() (./kdegames/ksokoban/ImageData.C:75)
ImageData::rightSmall(int index) {
assert(index >= 0);
if (indexSize_ <= index) expandIndex(index);
return smallStone_xpm_[rightSmallIndex_[index]];
}
int
ksokoban'ImageData::resize() (./kdegames/ksokoban/ImageData.C:82)
ImageData::resize(int size) {
assert(size > 0);
size &= ~1u;
if (size == size_) return size;
size_ = size;
halfSize_ = size/2;
for (int i=0; i<SMALL_STONES; i++) {
#if QT_VERSION < 200
smallStone_xpm_[i].convertFromImage(images_[i].smoothScale(halfSize_, halfSize_), ColorOnly|DiffuseDither|DiffuseAlphaDither|AvoidDither);
#else
smallStone_xpm_[i].convertFromImage(images_[i].smoothScale(halfSize_, halfSize_), QPixmap::ColorOnly|QPixmap::DiffuseDither|QPixmap::DiffuseAlphaDither|QPixmap::AvoidDither);
#endif
}
for (int i=0; i<LARGE_STONES; i++) {
#if QT_VERSION < 200
largeStone_xpm_[i].convertFromImage(images_[SMALL_STONES+i].smoothScale(size_, halfSize_) , ColorOnly|DiffuseDither|DiffuseAlphaDither|AvoidDither);
#else
largeStone_xpm_[i].convertFromImage(images_[SMALL_STONES+i].smoothScale(size_, halfSize_) , QPixmap::ColorOnly|QPixmap::DiffuseDither|QPixmap::DiffuseAlphaDither|QPixmap::AvoidDither);
#endif
}
// I don't use DiffuseDither for the objects on the "floor" since
// it gives spurious dots on the floor around them
for (int i=0; i<OTHER_IMAGES; i++) {
#if QT_VERSION < 200
otherPixmaps_[i].convertFromImage(images_[SMALL_STONES+LARGE_STONES+i].smoothScale(size_, size_), ColorOnly|OrderedDither|OrderedAlphaDither|AvoidDither);
#else
otherPixmaps_[i].convertFromImage(images_[SMALL_STONES+LARGE_STONES+i].smoothScale(size_, size_), QPixmap::ColorOnly|QPixmap::OrderedDither|QPixmap::OrderedAlphaDither|QPixmap::AvoidDither);
#endif
}
return size_;
}
void
ksokoban'ImageData::wall() (./kdegames/ksokoban/ImageData.C:121)
ImageData::wall(QPainter &p, int x, int y, int index, bool left, bool right) {
if (left) p.drawPixmap(x, y, upperLarge(index-1), halfSize_);
else p.drawPixmap(x, y, leftSmall(index));
if (right) p.drawPixmap(x+halfSize_, y, upperLarge(index), 0, 0, halfSize_);
else p.drawPixmap(x+halfSize_, y, rightSmall(index));
p.drawPixmap(x, y+halfSize_, lowerLarge(index));
}
void
ksokoban'ImageData::floor() (./kdegames/ksokoban/ImageData.C:132)
ImageData::floor(QPainter &p, int x, int y) {
p.eraseRect(x, y, size_, size_);
}
void
ksokoban'ImageData::goal() (./kdegames/ksokoban/ImageData.C:137)
ImageData::goal(QPainter &p, int x, int y) {
p.drawPixmap(x, y, otherPixmaps_[0]);
}
void
ksokoban'ImageData::man() (./kdegames/ksokoban/ImageData.C:142)
ImageData::man(QPainter &p, int x, int y) {
p.drawPixmap(x, y, otherPixmaps_[1]);
}
void
ksokoban'ImageData::object() (./kdegames/ksokoban/ImageData.C:147)
ImageData::object(QPainter &p, int x, int y) {
p.drawPixmap(x, y, otherPixmaps_[2]);
}
void
ksokoban'ImageData::saveman() (./kdegames/ksokoban/ImageData.C:152)
ImageData::saveman(QPainter &p, int x, int y) {
p.drawPixmap(x, y, otherPixmaps_[3]);
}
void
ksokoban'ImageData::treasure() (./kdegames/ksokoban/ImageData.C:157)
ImageData::treasure(QPainter &p, int x, int y) {
p.drawPixmap(x, y, otherPixmaps_[4]);
}