void UnitBase::setPickedUp(UnitBase* newCarrier) { if(selected) { removeFromSelectionLists(); } currentGameMap->removeObjectFromMap(getObjectID()); if(goingToRepairYard) { ((RepairYard*)target.getObjPointer())->unBook(); } if(getItemID() == Unit_Harvester) { Harvester* harvester = (Harvester*) this; if(harvester->isReturning() && target && (target.getObjPointer()!= NULL) && (target.getObjPointer()->getItemID() == Structure_Refinery)) { ((Refinery*)target.getObjPointer())->unBook(); } } target.pointTo(newCarrier); goingToRepairYard = false; forced = false; moving = false; pickedUp = true; respondable = false; setActive(false); setVisible(VIS_ALL, false); clearPath(); }
UINT TrackbarWindow::getTrackbarValue(const std::string& itemName) const { const int id = getItemID(itemName); if (id != -1) return (UINT)SendMessage(GetDlgItem(m_hWnd, id), TBM_GETPOS, NULL, NULL); return 0; }
bool UnitBase::isInAttackRange(const ObjectBase* pObject) const { int checkRange; switch(attackMode) { case GUARD: { checkRange = getWeaponRange(); } break; case AREAGUARD: { checkRange = getAreaGuardRange() + getWeaponRange() + 1; } break; case AMBUSH: { checkRange = getViewRange() + 1; } break; case HUNT: { return true; } break; case STOP: default: { return false; } break; } if(getItemID() == Unit_Sandworm) { checkRange = getViewRange() + 1; } return (blockDistance(guardPoint*TILESIZE + Coord(TILESIZE/2, TILESIZE/2), pObject->getCenterPoint()) <= checkRange*TILESIZE); }
void UnitBase::doAttackObject(const ObjectBase* pTargetObject, bool bForced) { if (pTargetObject == NULL) { return; } if(pTargetObject->getObjectID() == getObjectID() || (!canAttack() && getItemID() != Unit_Harvester)) { return; } if(attackMode == CAPTURE) { doSetAttackMode(GUARD); } setDestination(INVALID_POS,INVALID_POS); setTarget(pTargetObject); // hack to make it possible to attack own repair yard if(goingToRepairYard && target && (target.getObjPointer()->getItemID() == Structure_RepairYard)) { ((RepairYard*)target.getObjPointer())->unBook(); goingToRepairYard = false; } setForced(bForced); clearPath(); findTargetTimer = 0; }
void GanonIntro::activate() { loaded_guys=true; loaditem(); link.dir=down; link.setAction(landhold2); link.setHeldItem(getItemID(itemsbuf, itype_triforcepiece, 1)); }
void UnitBase::idleAction() { //not moving and not wanting to go anywhere, do some random turning if(isAGroundUnit() && (getItemID() != Unit_Harvester) && (getAttackMode() == GUARD)) { // we might turn this cylce with 20% chance if(currentGame->randomGen.rand(0, 4) == 0) { // choose a random one of the eight possible angles nextSpotAngle = currentGame->randomGen.rand(0, 7); } } }
__MSSHELL_WRAPPER_ __WINCALL static void _MS__private __lmp_prog editLog(const sel_typ argc, char ** argv) { dim_typ which_log; if((which_log = argc ? getItemID(argv[0], &logs_manager[LOGS_EDIT], LOGS) : itemSelect(LOGS)) == NULL_ITEM(LOGS)) return; char name[MAX_PATH_LENGTH] = NULL_CHAR; strcpy(name, listNo(which_log, LOGS)->path); _editLog(name); return; }
int ReimportTest::doTest() { QList<QUrl> files; files << setupFilePathForTest("images-for-tests/vector/026.jpg"); VERIFY(m_TestsApp.addFilesForTest(files), "Failed to add files"); auto artwork = m_TestsApp.getArtwork(0); const Common::ID_t id = artwork->getItemID(); const QString originalDescription = artwork->getDescription(); const QString originalTitle = artwork->getTitle(); const QStringList originalKeywords = artwork->getKeywords(); QStringList keywords; keywords << "picture" << "seagull" << "bird"; QString title = "Brand new title"; QString description = "Brand new description"; artwork->setDescription(description); artwork->setTitle(title); artwork->getBasicModel().setKeywords(keywords); SignalWaiter waiter; m_TestsApp.connectWaiterForImport(waiter); m_TestsApp.selectAllArtworks(); m_TestsApp.dispatch(QMLExtensions::UICommandID::SetupReimportMetadata); VERIFY(m_TestsApp.continueReading(waiter), "Failed to reimport metadata"); const QStringList &actualKeywords = artwork->getKeywords(); const QString &actualTitle = artwork->getTitle(); const QString &actualDescription = artwork->getDescription(); VERIFY(id == artwork->getItemID(), "ID should match"); VERIFY(actualKeywords == originalKeywords, "Original keywords are not the same"); VERIFY(actualTitle == originalTitle, "Original title is not the same"); VERIFY(actualDescription == originalDescription, "Original description is not the same"); return 0; }
void Tree::dropEvent(QDropEvent *event) { mainWindow->prepareNewAction(); if (event->mimeData()->hasUrls() && event->source() == NULL) { int numSf2 = -1; int commandCopy = 0; this->clearSelection(); for (int i = 0; i < event->mimeData()->urls().count(); i++) { QString path = QUrl::fromPercentEncoding(event->mimeData()->urls().at(i).toEncoded()); if (!path.isEmpty()) { QString extension = path.split(".").last().toLower(); if (extension == "sfz" || extension == "sf2" || extension == "sfark") mainWindow->dragAndDrop(path, getItemID(itemAt(event->pos())), &numSf2); else if (extension == "wav") mainWindow->dragAndDrop(path, getItemID(itemAt(event->pos())), &commandCopy); } } this->mainWindow->updateActions(); } else { // Destination EltID idDest = this->getItemID(this->itemAt(event->pos())); // Constitution de la liste des éléments à copier / lier QList<EltID> liste = this->getAllIDs(); mainWindow->dragAndDrop(idDest, liste); } mainWindow->updateDo(); }
EltID Tree::getNextID(bool closeFile) { // Cette fonction est appelée avant une suppression ou une fermeture de fichier // Elle permet de connaitre le prochain élément à sélectionner dans l'arborescence // closeFile si une fermeture est demandée, sinon il s'agit d'une suppression d'éléments EltID idRet(elementUnknown, -1, -1, -1, -1); if (this->getSelectedItemsNumber() == 0) return idRet; if (closeFile) { if (!isSelectedItemsSf2Unique()) return idRet; // Liste des idSf2 dans l'ordre QList<EltID> listSf2; int nbSf2 = this->topLevelItemCount(); for (int i = 0; i < nbSf2; i++) listSf2 << getItemID(this->topLevelItem(i)); if (listSf2.size() >= 2) { // Sf2 sélectionné actuellement EltID idCurrentSf2 = getFirstID(); idCurrentSf2.typeElement = elementSf2; // Prochain sf2 int iTmp = listSf2.indexOf(idCurrentSf2); if (iTmp != -1) { if (iTmp >= listSf2.size() - 1) idRet = listSf2.at(listSf2.size() - 2); else idRet = listSf2.at(iTmp + 1); if (idRet.indexSf2 > idCurrentSf2.indexSf2) idRet.indexSf2--; } } } else { if (!isSelectedItemsTypeUnique() || !isSelectedItemsFamilyUnique() || !isSelectedItemsSf2Unique()) return idRet; } return idRet; }
void UnitBase::setGuardPoint(int newX, int newY) { if(currentGameMap->tileExists(newX, newY) || ((newX == INVALID_POS) && (newY == INVALID_POS))) { guardPoint.x = newX; guardPoint.y = newY; if((getItemID() == Unit_Harvester) && guardPoint.isValid()) { if(currentGameMap->getTile(newX, newY)->hasSpice()) { if(attackMode == STOP) { attackMode = GUARD; } } else { if(attackMode != STOP) { attackMode = STOP; } } } } }
EltID Tree::getElementToSelectAfterDeletion() { // Liste des éléments sélectionnés (ne doit pas être vide) QList<QTreeWidgetItem *> listSelectedItems = this->selectedItems(); if (listSelectedItems.isEmpty()) return EltID(); // Vérification que le parent est le même pour tous les éléments QTreeWidgetItem * itemParent = listSelectedItems.first()->parent(); if (!itemParent) return EltID(); foreach (QTreeWidgetItem * item, listSelectedItems) { if (item->parent() != itemParent) return EltID(); } // Récupération de la liste des enfants QList<QTreeWidgetItem *> listChildItems; for (int i = 0; i < itemParent->childCount(); i++) if (!itemParent->child(i)->isHidden()) listChildItems << itemParent->child(i); // Séparation en 2 listes, d'après le dernier élément sélectionné int indexMid = listChildItems.indexOf(listSelectedItems.last()); QList<QTreeWidgetItem *> listDebut = listChildItems.mid(0, indexMid + 1); QList<QTreeWidgetItem *> listFin = listChildItems.mid(indexMid + 1, -1); // Suppression de toutes les occurences des éléments sélectionnés dans la 1ère liste foreach (QTreeWidgetItem * item, listSelectedItems) listDebut.removeAll(item); // Détermination de l'élément à sélectionner QTreeWidgetItem * itemToSelect = itemParent; if (!listFin.isEmpty()) itemToSelect = listFin.first(); else if (!listDebut.isEmpty()) itemToSelect = listDebut.last(); // Récupération de l'identifiant return getItemID(itemToSelect); }
POINT NewTerrainWindow::getDropdownListPairValues(const std::string& name) const { POINT value; UINT id = getItemID(name); if (id >= 0) { char buffer[32]; ComboBox_GetText(GetDlgItem(m_hWnd, id), buffer, 31); value.x = atoi(buffer); ComboBox_GetText(GetDlgItem(m_hWnd, id + 1), buffer, 31); value.y = atoi(buffer); } else { value.x = -1; value.y = -1; } return value; }
void UnitBase::targeting() { if(findTargetTimer == 0) { if(attackMode != STOP) { if(!target && !attackPos && !moving && !justStoppedMoving && !forced) { // we have no target, we have stopped moving and we weren't forced to do anything else const ObjectBase* pNewTarget = findTarget(); if(pNewTarget != NULL && isInGuardRange(pNewTarget)) { // we have found a new target => attack it if(attackMode == AMBUSH) { doSetAttackMode(HUNT); } doAttackObject(pNewTarget, false); if(getItemID() == Unit_Sandworm) { if(pNewTarget->getOwner() == pLocalHouse) { soundPlayer->playVoice(WarningWormSign, pLocalHouse->getHouseID()); } doSetAttackMode(HUNT); } } else if(attackMode == HUNT) { setGuardPoint(location); doSetAttackMode(GUARD); } // reset target timer findTargetTimer = 100; } } } engageTarget(); }
__MSSHELL_WRAPPER_ static inline void _MS__private __lmp_prog relLog(const sel_typ argc, char ** argv) { relItem(argc ? getItemID(argv[0], &logs_manager[LOGS_RELOAD], LOGS) : getItemsListNo(LOGS), LOGS); return; }
void LLPreviewTexture::init() { sInstance = this; LLUICtrlFactory::getInstance()->buildFloater(sInstance,"floater_preview_texture.xml"); childSetVisible("desc", !mCopyToInv); // Hide description field for embedded textures childSetVisible("desc txt", !mCopyToInv); childSetVisible("Copy To Inventory", mCopyToInv); childSetVisible("Keep", mShowKeepDiscard); childSetVisible("Discard", mShowKeepDiscard); childSetAction("openprofile", onClickProfile, this); if (mCopyToInv) { childSetAction("Copy To Inventory",LLPreview::onBtnCopyToInv,this); } else if (mShowKeepDiscard) { childSetAction("Keep",onKeepBtn,this); childSetAction("Discard",onDiscardBtn,this); } else { // If the buttons are hidden move stuff down to use the space. LLRect keep_rect, old_rect, new_rect; S32 diff; childGetRect("Keep", keep_rect); childGetRect("combo_aspect_ratio", old_rect); diff = old_rect.mBottom - keep_rect.mBottom; new_rect.setOriginAndSize(old_rect.mLeft, old_rect.mBottom - diff, old_rect.getWidth(), old_rect.getHeight()); childSetRect("combo_aspect_ratio", new_rect); childGetRect("aspect_ratio", old_rect); new_rect.setOriginAndSize(old_rect.mLeft, old_rect.mBottom - diff, old_rect.getWidth(), old_rect.getHeight()); childSetRect("aspect_ratio", new_rect); childGetRect("dimensions", old_rect); new_rect.setOriginAndSize(old_rect.mLeft, old_rect.mBottom - diff, old_rect.getWidth(), old_rect.getHeight()); childSetRect("dimensions", new_rect); } if (!mCopyToInv) { const LLInventoryItem* item = getItem(); if (item) { mCreatorKey = item->getCreatorUUID(); childSetCommitCallback("desc", LLPreview::onText, this); childSetText("desc", item->getDescription()); getChild<LLLineEditor>("desc")->setPrevalidate(&LLLineEditor::prevalidatePrintableNotPipe); childSetText("uuid", getItemID().asString()); childSetText("uploader", getItemCreatorName()); childSetText("uploadtime", getItemCreationDate()); childSetText("alphanote", LLTrans::getString("LoadingData")); } } childSetCommitCallback("combo_aspect_ratio", onAspectRatioCommit, this); LLComboBox* combo = getChild<LLComboBox>("combo_aspect_ratio"); combo->setCurrentByIndex(0); }
void GanonIntro::update() { /* ************************ * GANON INTRO SEQUENCE * ************************ -25 DOT updates -24 LINK in 0 TRIFORCE overhead - code begins at this point (counter == 0) 47 GANON in 58 LIGHT step 68 LIGHT step 78 LIGHT step 255 TRIFORCE out 256 TRIFORCE in 270 TRIFORCE out 271 GANON out, LINK face up */ if(counter==47) { music_stop(); stop_sfx(WAV_ROAR); sfx(WAV_GASP); sfx(WAV_GANON); int Id=0; for(int i=0; i<eMAXGUYS; i++) { if(guysbuf[i].flags2&eneflag_ganon) { Id=i; break; } } if(current_item(itype_ring)) addenemy(160,96,Id,0); else addenemy(80,32,Id,0); } else if(counter==48) { lighting(true,true); // Hmm. -L counter += 30; } //NES Z1, the triforce vanishes for one frame in two cases //while still showing Link's two-handed overhead sprite. else if(counter==255 || counter==270) link.setHeldItem(-1); else if(counter==256) link.setHeldItem(getItemID(itemsbuf,itype_triforcepiece,1)); counter++; if(counter<271) return; link.setAction(none); link.dir=up; if(!getmapflag() && (tunes[MAXMIDIS-1].data)) jukebox(MAXMIDIS-1); else playLevelMusic(); currcset=DMaps[currdmap].color; showCurrentDMapIntro(); cont_sfx(WAV_ROAR); finish(); }
__MSSHELL_WRAPPER_ static inline void _MS__private __lmp_prog setCurLog(const sel_typ argc, char ** argv) { setCurItem(argc ? getItemID(argv[0], &logs_manager[LOGS_SETCURRENT], LOGS) : getItemsListNo(LOGS), LOGS); return; }
void UnitBase::attack() { if(numWeapons) { Coord targetCenterPoint; Coord centerPoint = getCenterPoint(); bool bAirBullet; if(target.getObjPointer() != NULL) { targetCenterPoint = target.getObjPointer()->getClosestCenterPoint(location); bAirBullet = target.getObjPointer()->isAFlyingUnit(); } else { targetCenterPoint = currentGameMap->getTile(attackPos)->getCenterPoint(); bAirBullet = false; } int currentBulletType = bulletType; Sint32 currentWeaponDamage = currentGame->objectData.data[itemID][originalHouseID].weapondamage; if(getItemID() == Unit_Trooper) { // Troopers change weapon type depending on distance float distance = distanceFrom(centerPoint, targetCenterPoint); if(distance > 2*TILESIZE) { currentBulletType = Bullet_SmallRocket; } } if(primaryWeaponTimer == 0) { bulletList.push_back( new Bullet( objectID, ¢erPoint, &targetCenterPoint, currentBulletType, currentWeaponDamage, bAirBullet) ); playAttackSound(); primaryWeaponTimer = getWeaponReloadTime(); secondaryWeaponTimer = 15; if(attackPos && getItemID() != Unit_SonicTank && currentGameMap->getTile(attackPos)->isSpiceBloom()) { setDestination(location); forced = false; attackPos.invalidate(); } // shorten deviation time if(deviationTimer > 0) { deviationTimer = std::max(0,deviationTimer - MILLI2CYCLES(20*1000)); } } if((numWeapons == 2) && (secondaryWeaponTimer == 0) && (isBadlyDamaged() == false)) { bulletList.push_back( new Bullet( objectID, ¢erPoint, &targetCenterPoint, currentBulletType, currentWeaponDamage, bAirBullet) ); playAttackSound(); secondaryWeaponTimer = -1; if(attackPos && getItemID() != Unit_SonicTank && currentGameMap->getTile(attackPos)->isSpiceBloom()) { setDestination(location); forced = false; attackPos.invalidate(); } // shorten deviation time if(deviationTimer > 0) { deviationTimer = std::max(0,deviationTimer - MILLI2CYCLES(20*1000)); } } } }
void UnitBase::navigate() { if(isAFlyingUnit() || (((currentGame->getGameCycleCount() + getObjectID()*1337) % 5) == 0)) { // navigation is only performed every 5th frame if(!moving && !justStoppedMoving) { if(location != destination) { if(nextSpotFound == false) { if(pathList.empty() && (recalculatePathTimer == 0)) { recalculatePathTimer = 100; if(!SearchPathWithAStar() && (++noCloserPointCount >= 3) && (location != oldLocation)) { //try searching for a path a number of times then give up if (target.getObjPointer() != NULL && targetFriendly && (target.getObjPointer()->getItemID() != Structure_RepairYard) && ((target.getObjPointer()->getItemID() != Structure_Refinery) || (getItemID() != Unit_Harvester))) { setTarget(NULL); } setDestination(location); //can't get any closer, give up forced = false; } } if(!pathList.empty()) { nextSpot = pathList.front(); pathList.pop_front(); nextSpotFound = true; recalculatePathTimer = 0; noCloserPointCount = 0; } } else { int tempAngle = currentGameMap->getPosAngle(location, nextSpot); if(tempAngle != INVALID) { nextSpotAngle = tempAngle; } if(!canPass(nextSpot.x, nextSpot.y)) { clearPath(); } else { if (drawnAngle == nextSpotAngle) { moving = true; nextSpotFound = false; assignToMap(nextSpot); angle = drawnAngle; setSpeeds(); } } } } else if(!target) { if(((currentGame->getGameCycleCount() + getObjectID()*1337) % MILLI2CYCLES(UNITIDLETIMER)) == 0) { idleAction(); } } } } }