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