|
|
|
@ -38,10 +38,10 @@ PlayGround::PlayGround(TopLevel *tqparent, const char *name, uint selectedGamebo
|
|
|
|
|
|
|
|
|
|
setBackgroundColor(white);
|
|
|
|
|
|
|
|
|
|
TQDomDocument tqlayoutsDocument;
|
|
|
|
|
bool ok = topLevel->loadLayout(tqlayoutsDocument);
|
|
|
|
|
if (ok) ok = registerPlayGrounds(tqlayoutsDocument);
|
|
|
|
|
if (ok) ok = loadPlayGround(tqlayoutsDocument, selectedGameboard);
|
|
|
|
|
TQDomDocument layoutsDocument;
|
|
|
|
|
bool ok = topLevel->loadLayout(layoutsDocument);
|
|
|
|
|
if (ok) ok = registerPlayGrounds(layoutsDocument);
|
|
|
|
|
if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard);
|
|
|
|
|
if (!ok) loadFailure();
|
|
|
|
|
|
|
|
|
|
currentAction = 0;
|
|
|
|
@ -71,9 +71,9 @@ void PlayGround::reset()
|
|
|
|
|
// Change the gameboard
|
|
|
|
|
void PlayGround::change(uint selectedGameboard)
|
|
|
|
|
{
|
|
|
|
|
TQDomDocument tqlayoutsDocument;
|
|
|
|
|
bool ok = topLevel->loadLayout(tqlayoutsDocument);
|
|
|
|
|
if (ok) ok = loadPlayGround(tqlayoutsDocument, selectedGameboard);
|
|
|
|
|
TQDomDocument layoutsDocument;
|
|
|
|
|
bool ok = topLevel->loadLayout(layoutsDocument);
|
|
|
|
|
if (ok) ok = loadPlayGround(layoutsDocument, selectedGameboard);
|
|
|
|
|
if (!ok) loadFailure();
|
|
|
|
|
|
|
|
|
|
toDraw.clear();
|
|
|
|
@ -221,7 +221,7 @@ void PlayGround::drawGameboard( TQPainter &artist, const TQRect &area ) const
|
|
|
|
|
for (TQPtrListIterator<ToDraw> currentObject(toDraw);
|
|
|
|
|
currentObject.current();
|
|
|
|
|
++currentObject)
|
|
|
|
|
currentObject.current()->draw(artist, area, objectsLayout, &gameboard, &tqmasks);
|
|
|
|
|
currentObject.current()->draw(artist, area, objectsLayout, &gameboard, &masks);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Painting event
|
|
|
|
@ -257,7 +257,7 @@ void PlayGround::mousePressEvent( TQMouseEvent *event )
|
|
|
|
|
TQPixmap object(objectsLayout[draggedNumber].size());
|
|
|
|
|
TQBitmap tqshape(objectsLayout[draggedNumber].size());
|
|
|
|
|
bitBlt(&object, TQPoint(0, 0), &gameboard, objectsLayout[draggedNumber], TQt::CopyROP);
|
|
|
|
|
bitBlt(&tqshape, TQPoint(0, 0), &tqmasks, objectsLayout[draggedNumber], TQt::CopyROP);
|
|
|
|
|
bitBlt(&tqshape, TQPoint(0, 0), &masks, objectsLayout[draggedNumber], TQt::CopyROP);
|
|
|
|
|
object.setMask(tqshape);
|
|
|
|
|
|
|
|
|
|
draggedCursor = new TQCursor(object, position.x(), position.y());
|
|
|
|
@ -325,13 +325,13 @@ void PlayGround::mouseReleaseEvent( TQMouseEvent *event )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register the various playgrounds
|
|
|
|
|
bool PlayGround::registerPlayGrounds(TQDomDocument &tqlayoutDocument)
|
|
|
|
|
bool PlayGround::registerPlayGrounds(TQDomDocument &layoutDocument)
|
|
|
|
|
{
|
|
|
|
|
TQDomNodeList playGroundsList, menuItemsList, labelsList;
|
|
|
|
|
TQDomElement playGroundElement, menuItemElement, labelElement;
|
|
|
|
|
TQDomAttr actionAttribute;
|
|
|
|
|
|
|
|
|
|
playGroundsList = tqlayoutDocument.elementsByTagName("playground");
|
|
|
|
|
playGroundsList = layoutDocument.elementsByTagName("playground");
|
|
|
|
|
if (playGroundsList.count() < 1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
@ -357,20 +357,20 @@ bool PlayGround::registerPlayGrounds(TQDomDocument &tqlayoutDocument)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load background and draggable objects tqmasks
|
|
|
|
|
bool PlayGround::loadPlayGround(TQDomDocument &tqlayoutDocument, uint toLoad)
|
|
|
|
|
// Load background and draggable objects masks
|
|
|
|
|
bool PlayGround::loadPlayGround(TQDomDocument &layoutDocument, uint toLoad)
|
|
|
|
|
{
|
|
|
|
|
TQDomNodeList playGroundsList,
|
|
|
|
|
editableAreasList, categoriesList, objectsList,
|
|
|
|
|
gameAreasList, tqmaskAreasList, soundNamesList, labelsList;
|
|
|
|
|
gameAreasList, maskAreasList, soundNamesList, labelsList;
|
|
|
|
|
TQDomElement playGroundElement,
|
|
|
|
|
editableAreaElement, categoryElement, objectElement,
|
|
|
|
|
gameAreaElement, tqmaskAreaElement, soundNameElement, labelElement;
|
|
|
|
|
TQDomAttr gameboardAttribute, tqmasksAttribute,
|
|
|
|
|
gameAreaElement, maskAreaElement, soundNameElement, labelElement;
|
|
|
|
|
TQDomAttr gameboardAttribute, masksAttribute,
|
|
|
|
|
leftAttribute, topAttribute, rightAttribute, bottomAttribute,
|
|
|
|
|
refAttribute;
|
|
|
|
|
|
|
|
|
|
playGroundsList = tqlayoutDocument.elementsByTagName("playground");
|
|
|
|
|
playGroundsList = layoutDocument.elementsByTagName("playground");
|
|
|
|
|
if (toLoad >= playGroundsList.count())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
@ -380,8 +380,8 @@ bool PlayGround::loadPlayGround(TQDomDocument &tqlayoutDocument, uint toLoad)
|
|
|
|
|
if (!gameboard.load(locate("data", "ktuberling/pics/" + gameboardAttribute.value())))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
tqmasksAttribute = playGroundElement.attributeNode("tqmasks");
|
|
|
|
|
if (!tqmasks.load(locate("data", "ktuberling/pics/" + tqmasksAttribute.value())))
|
|
|
|
|
masksAttribute = playGroundElement.attributeNode("masks");
|
|
|
|
|
if (!masks.load(locate("data", "ktuberling/pics/" + masksAttribute.value())))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
editableAreasList = playGroundElement.elementsByTagName("editablearea");
|
|
|
|
@ -550,7 +550,7 @@ bool PlayGround::zone(TQPoint &position)
|
|
|
|
|
TQBitmap tqshape(objectsLayout[draggedNumber].size());
|
|
|
|
|
TQPoint relative(position.x() - toUpdate.x(),
|
|
|
|
|
position.y() - toUpdate.y());
|
|
|
|
|
bitBlt(&tqshape, TQPoint(0, 0), &tqmasks, objectsLayout[draggedNumber], TQt::CopyROP);
|
|
|
|
|
bitBlt(&tqshape, TQPoint(0, 0), &masks, objectsLayout[draggedNumber], TQt::CopyROP);
|
|
|
|
|
if (!tqshape.convertToImage().pixelIndex(relative.x(), relative.y())) continue;
|
|
|
|
|
|
|
|
|
|
toDraw.remove(draggedZOrder);
|
|
|
|
|