// select the n'th command droid void selCommander(int n) { for (DROID *psCurr = apsDroidLists[selectedPlayer]; psCurr; psCurr = psCurr->psNext) { if (droidIsCommanderNum(psCurr, n)) { if (!psCurr->selected) { clearSelection(); psCurr->selected = true; } else { clearSelection(); psCurr->selected = true; // this horrible bit of code is taken from activateGroupAndMove // and sets the camera position to that of the commander if (getWarCamStatus()) { camToggleStatus(); // messy - fix this processWarCam(); // odd, but necessary camToggleStatus(); // messy - FIXME } else { /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psCurr->pos.x), map_coord(psCurr->pos.y), true); } } return; } } }
void kdvi::makeToolBar2(QWidget *parent) { QPixmap pm; toolBar2 = new QFrame( parent ); QBoxLayout * gl = new QBoxLayout( toolBar2, QBoxLayout::Down ); sbox = new ScrollBox( toolBar2 ); connect( sbox, SIGNAL(valueChanged(QPoint)), dviwin, SLOT(scroll(QPoint)) ); connect( sbox, SIGNAL(button3Pressed()), dviwin, SLOT(nextPage()) ); connect( sbox, SIGNAL(button2Pressed()), dviwin, SLOT(prevPage()) ); connect( dviwin, SIGNAL(pageSizeChanged( QSize )), sbox, SLOT(setPageSize( QSize )) ); connect( dviwin, SIGNAL(viewSizeChanged( QSize )), sbox, SLOT(setViewSize( QSize )) ); connect( dviwin, SIGNAL(currentPosChanged( QPoint )), sbox, SLOT(setViewPos( QPoint )) ); QToolTip::add( sbox, 0, tipgroup, i18n("Scroll window and switch the page") ); sbox->setFixedSize(70,80); gl->addWidget( sbox ); // Create a MarkList marklist = new MarkList( toolBar2 ); connect( marklist, SIGNAL(selected(const char *)), SLOT(pageActivated(const char *)) ); QToolTip::add( marklist, 0, tipgroup, i18n("Select page and mark pages for printing") ); gl->addWidget( marklist ); gl->activate(); sbox->setPageSize( dviwin->pageSize() ); }
static QScriptValue js_centreView(QScriptContext *context, QScriptEngine *engine) { int x = context->argument(0).toInt32(); int y = context->argument(1).toInt32(); setViewPos(map_coord(x), map_coord(y), false); Q_UNUSED(engine); return QScriptValue(); }
// --------------------------------------------------------------------- void selNextSpecifiedBuilding(STRUCTURE_TYPE structType) { STRUCTURE *psResult = nullptr, *psOldStruct = nullptr, *psFirst = nullptr; bool bLaterInList = false; /* Firstly, start coughing if the type is invalid */ ASSERT(structType <= NUM_DIFF_BUILDINGS, "Invalid structure type %u", structType); for (STRUCTURE *psCurr = apsStructLists[selectedPlayer]; psCurr && !psResult; psCurr = psCurr->psNext) { if ((psCurr->pStructureType->type == structType) && (psCurr->status == SS_BUILT)) { if (!psFirst) { psFirst = psCurr; } if (psCurr->selected) { bLaterInList = true; psOldStruct = psCurr; } else if (bLaterInList) { psResult = psCurr; } } } if (!psResult && psFirst) { psResult = psFirst; } if (psResult && !psResult->died) { if (getWarCamStatus()) { camToggleStatus(); } setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), false); if (psOldStruct) { psOldStruct->selected = false; } psResult->selected = true; triggerEventSelected(); jsDebugSelected(psResult); } else { // Can't find required building addConsoleMessage("Cannot find required building!", LEFT_JUSTIFY, SYSTEM_MESSAGE); } }
// //////////////////////////////////////////////////////////////////////////// // probably temporary. Places the camera on the players 1st droid or struct. Vector3i cameraToHome(UDWORD player,bool scroll) { Vector3i res; UDWORD x,y; STRUCTURE *psBuilding; for (psBuilding = apsStructLists[player]; psBuilding && (psBuilding->pStructureType->type != REF_HQ); psBuilding= psBuilding->psNext) {} if(psBuilding) { x= map_coord(psBuilding->pos.x); y= map_coord(psBuilding->pos.y); } else if (apsDroidLists[player]) // or first droid { x= map_coord(apsDroidLists[player]->pos.x); y= map_coord(apsDroidLists[player]->pos.y); } else if (apsStructLists[player]) // center on first struct { x= map_coord(apsStructLists[player]->pos.x); y= map_coord(apsStructLists[player]->pos.y); } else //or map center. { x= mapWidth/2; y= mapHeight/2; } if(scroll) { requestRadarTrack(world_coord(x), world_coord(y)); } else { setViewPos(x,y,true); } res.x = world_coord(x); res.y = map_TileHeight(x,y); res.z = world_coord(y); return res; }
// --------------------------------------------------------------------- void selNextSpecifiedBuilding(UDWORD structType) { STRUCTURE *psCurr; STRUCTURE *psResult; STRUCTURE *psOldStruct; STRUCTURE *psFirst; BOOL bLaterInList; /* Firstly, start coughing if the type is invalid */ ASSERT( structType>=REF_HQ && structType<=NUM_DIFF_BUILDINGS, "Invalid structure type in selNextSpecifiedBuilding" ); for(psCurr = apsStructLists[selectedPlayer], psFirst = NULL,psResult = NULL,psOldStruct=NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { if( (psCurr->pStructureType->type == structType) && (psCurr->status == SS_BUILT) ) { if(!psFirst) { psFirst = psCurr; } if(psCurr->selected) { bLaterInList = true; psOldStruct=psCurr; } else if(bLaterInList) { psResult = psCurr; } } } if(!psResult) { if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { if(getWarCamStatus()) { camToggleStatus(); } setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), false); if(psOldStruct) { psOldStruct->selected = false; } psResult->selected = true; } else { // Can't find required building addConsoleMessage("Cannot find required building!",LEFT_JUSTIFY,SYSTEM_MESSAGE); } }
// --------------------------------------------------------------------- void selNextUnassignedUnit( void ) { DROID *psCurr; DROID *psResult; DROID *psFirst; BOOL bLaterInList; for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { /* Only look at unselected ones */ if(psCurr->group==UBYTE_MAX) { /* Keep a record of first one */ if(!psFirst) { psFirst = psCurr; } if(psCurr == psOldNS) { bLaterInList = true; } /* First one...? */ if(!psOldNS) { psResult = psCurr; } /* Dont choose same one again */ else if(psCurr!=psOldNS && bLaterInList) { psResult = psCurr; } } } /* If we didn't get one - then select first one */ if(!psResult) { if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { selDroidDeselect(selectedPlayer); // psResult->selected = true; SelectDroid(psResult); if(getWarCamStatus()) { camToggleStatus(); // messy - fix this // setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y)); processWarCam(); //odd, but necessary camToggleStatus(); // messy - FIXME } else if(!getWarCamStatus()) { // camToggleStatus(); /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true); } psOldNS = psResult; } else { addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); } }
// ffs am // --------------------------------------------------------------------- void selNextSpecifiedUnit(UDWORD unitType) { DROID *psCurr; DROID *psResult; DROID *psFirst; BOOL bLaterInList, bMatch; for(psCurr = apsDroidLists[selectedPlayer],psFirst = NULL,psResult = NULL,bLaterInList = false; psCurr && !psResult; psCurr = psCurr->psNext) { //if( psCurr->droidType == (SDWORD)unitType ) //exceptions - as always... bMatch = false; if (unitType == DROID_CONSTRUCT) { if (psCurr->droidType == DROID_CONSTRUCT || psCurr->droidType == DROID_CYBORG_CONSTRUCT) { bMatch = true; } } else if (unitType == DROID_REPAIR) { if (psCurr->droidType == DROID_REPAIR || psCurr->droidType == DROID_CYBORG_REPAIR) { bMatch = true; } } else if(psCurr->droidType == (SDWORD)unitType) { bMatch = true; } if (bMatch) { /* Always store away the first one we find */ if(!psFirst) { psFirst = psCurr; } if(psCurr == psOldRD) { bLaterInList = true; } /* Nothing previously found... */ if(!psOldRD) { psResult = psCurr; } /* Only select is this isn't the old one and it's further on in list */ else if(psCurr!=psOldRD && bLaterInList) { psResult = psCurr; } } } /* Did we get one? */ if(!psResult) { /* was there at least one - the first one? Resetting */ if(psFirst) { psResult = psFirst; } } if(psResult && !psResult->died) { selDroidDeselect(selectedPlayer); // psResult->selected = true; SelectDroid(psResult); if(getWarCamStatus()) { camToggleStatus(); // messy - fix this // setViewPos(map_coord(psCentreDroid->pos.x), map_coord(psCentreDroid->pos.y)); processWarCam(); //odd, but necessary camToggleStatus(); // messy - FIXME } else if(!getWarCamStatus()) { // camToggleStatus(); /* Centre display on him if warcam isn't active */ setViewPos(map_coord(psResult->pos.x), map_coord(psResult->pos.y), true); } psOldRD = psResult; } else { switch(unitType) { case DROID_REPAIR: addConsoleMessage(_("Unable to locate any repair units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_CONSTRUCT: addConsoleMessage(_("Unable to locate any Trucks!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_SENSOR: addConsoleMessage(_("Unable to locate any Sensor Units!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; case DROID_COMMAND: addConsoleMessage(_("Unable to locate any Commanders!"),LEFT_JUSTIFY,SYSTEM_MESSAGE); break; } } }
void djvImageView::viewCenter() { setViewPos(djvVector2f(width(), height()) / 2.0 - bbox().size / 2.0); }