void CollapsibleGroup::slotSaveGroup() { QString name = QInputDialog::getText(this, i18n("Save Group"), i18n("Name for saved group: "), QLineEdit::Normal, m_title->text()); if (name.isEmpty()) return; QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/effects/"); if (!dir.exists()) { dir.mkpath(QStringLiteral(".")); } if (dir.exists(name + ".xml")) if (KMessageBox::questionYesNo(this, i18n("File %1 already exists.\nDo you want to overwrite it?", name + ".xml")) == KMessageBox::No) return; QDomDocument doc = effectsData(); QDomElement base = doc.documentElement(); QDomNodeList effects = base.elementsByTagName(QStringLiteral("effect")); for (int i = 0; i < effects.count(); ++i) { QDomElement eff = effects.at(i).toElement(); eff.removeAttribute(QStringLiteral("kdenlive_ix")); EffectInfo info; info.fromString(eff.attribute(QStringLiteral("kdenlive_info"))); // Make sure all effects have the correct new group name info.groupName = name; // Saved effect group should have a group index of -1 info.groupIndex = -1; eff.setAttribute(QStringLiteral("kdenlive_info"), info.toString()); } base.setAttribute(QStringLiteral("name"), name); base.setAttribute(QStringLiteral("id"), name); base.setAttribute(QStringLiteral("type"), QStringLiteral("custom")); QFile file(dir.absoluteFilePath(name + ".xml")); if (file.open(QFile::WriteOnly | QFile::Truncate)) { QTextStream out(&file); out << doc.toString(); } file.close(); emit reloadEffects(); }
int doRes(Creature* caster, cmd* cmnd, bool res) { // if ress=false, it's a bloodfusion Player *player = caster->getAsPlayer(); int prevLevel=0; bool full=false; long t=0; Player *target=0; BaseRoom *newRoom=0; if(player && !player->isDm()) { if(player->getNegativeLevels()) { player->print("You cannot do that without your full life essence.\n"); return(0); } if(player->mp.getCur() < player->mp.getMax()) { player->print("You must have full MP to cast that spell.\n"); return(0); } } else { // a DM can set to a 100% restore instead of 80% if(cmnd->num == 4 && !strcasecmp(cmnd->str[3], "-full")) full = true; } if(cmnd->num < 2) { caster->print("%s?\n", res ? "Resurrect whom" : "Fuse whom with new blood"); return(0); } cmnd->str[2][0] = up(cmnd->str[2][0]); target = gServer->findPlayer(cmnd->str[2]); if(!target) { caster->print("That player is not online.\n"); return(0); } if(target->isDm() && target->flagIsSet(P_DM_INVIS) && !caster->isDm()) { caster->print("That player is not online.\n"); return(0); } if(target->isStaff()) { caster->print("Staff characters do not need to be %s.\n", res ? "resurrected" : "fused with blood"); return(0); } if(checkRefusingMagic(caster, target)) return(0); if(Move::tooFarAway(caster, target, res ? "resurrect" : "fuse with new blood")) return(0); if(res) { if(target->isUndead()) { caster->print("Undead players cannot be resurrected.\n"); return(0); } } else { if(!target->isUndead()) { caster->print("Only undead players can be fused with new blood.\n"); return(0); } } if(!caster->isDm()) { if(target->getLocation() != target->getLimboRoom()) { caster->print("%s is not in limbo! How can you %s %s?\n", target->getCName(), res ? "resurrect" : "bloodfuse", target->himHer()); return(0); } if(target->getLevel() < 7) { caster->print("%s is not yet powerful enough to be %s.\n", target->getCName(), res ? "resurrected" : "fused with blood"); return(0); } if(!target->flagIsSet(P_KILLED_BY_MOB)) { caster->print("%s does not need to be %s.\n", target->getCName(), res ? "resurrected" : "fused with new blood"); return(0); } } if(target == caster) { caster->print("You cannot %s.\n", res ? "resurrect yourself" : "fuse yourself with new blood"); return(0); } if(player && !player->isDm() && player->daily[DL_RESURRECT].cur == 0) { player->print("You have done that enough times for today.\n"); return(0); } if(!caster->isDm() && target->daily[DL_RESURRECT].cur == 0) { caster->print("Players can only be %s once per 24 hours real time.\n", res ? "resurrected" : "fused with new blood"); return(0); } caster->print("You cast a %s spell on %N.\n", res ? "resurrection" : "bloodfusion", target); prevLevel = target->getLevel(); long expGain = full ? (target->statistics.getLastExperienceLoss()*4/5) : (target->statistics.getLastExperienceLoss()); EffectInfo *effect = target->getEffect("death-sickness"); if(effect) { if(full) target->removeEffect("death-sickness"); else effect->setDuration(effect->getDuration() / 3); } target->cureDisease(); target->curePoison(); target->removeEffect("hold-person"); target->removeEffect("petrification"); target->removeEffect("confusion"); target->removeEffect("drunkenness"); target->clearFlag(P_KILLED_BY_MOB); target->setTickDamage(0); if(player) dec_daily(&player->daily[DL_RESURRECT]); dec_daily(&target->daily[DL_RESURRECT]); broadcast(caster->getSock(), caster->getRoomParent(), "%M casts a %s spell on %N.", caster, res ? "resurrection" : "bloodfusion", target); logn("log.resurrect", "%s(L:%d) %s %s(L%d:%d) %s.\n", caster->getCName(), caster->getLevel(), res ? "resurrected" : "fused", target->getCName(), prevLevel, target->getLevel(), res ? "from the dead" : "with new blood"); if(res) broadcast("^R### %M just resurrected %s from the dead!", caster, target->getCName()); else broadcast("^R### %M just fused %s with new blood!", caster, target->getCName()); if(player && !player->isDm()) { t = time(0); caster->setFlag(P_NO_TICK_MP); // caster cannot tick MP for 20 mins online time caster->lasttime[LT_NOMPTICK].ltime = t; caster->lasttime[LT_NOMPTICK].interval = 120L; broadcast(caster->getSock(), caster->getRoomParent(), "%M collapses from exhaustion.", caster); caster->print("You collapse from exhaustion.\n"); caster->knockUnconscious(120); caster->mp.setCur(0); } newRoom = target->getRecallRoom().loadRoom(target); if(newRoom) { target->deleteFromRoom(); target->addToRoom(newRoom); target->doPetFollow(); } target->print("You have been %s!\n", res ? "resurrected from the dead" : "fused with new blood"); // Gain back 80% of lost experience target->addExperience(expGain); // See if we need to relevel target->checkLevel(); target->hp.restore(); target->mp.restore(); target->pp.restore(); target->computeAttackPower(); target->computeAC(); target->clearAsEnemy(); target->save(true); updateRecentActivity(); return(1); }
void CollapsibleGroup::dropEvent(QDropEvent *event) { frame->setProperty("target", false); frame->setStyleSheet(frame->styleSheet()); const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist")); //event->acceptProposedAction(); QDomDocument doc; doc.setContent(effects, true); QDomElement e = doc.documentElement(); int ix = e.attribute("kdenlive_ix").toInt(); if (ix == 0 || e.tagName() == "effectgroup") { if (e.tagName() == "effectgroup") { // dropped a group on another group QDomNodeList pastedEffects = e.elementsByTagName("effect"); if (pastedEffects.isEmpty() || m_subWidgets.isEmpty()) { // Buggy groups, should not happen event->ignore(); return; } QList <int> pastedEffectIndexes; QList <int> currentEffectIndexes; EffectInfo pasteInfo; pasteInfo.fromString(pastedEffects.at(0).toElement().attribute("kdenlive_info")); if (pasteInfo.groupIndex == -1) { // Group dropped from effects list, add effect e.setAttribute("kdenlive_ix", m_subWidgets.last()->effectIndex()); emit addEffect(e); event->setDropAction(Qt::CopyAction); event->accept(); return; } // Moving group for (int i = 0; i < pastedEffects.count(); i++) { pastedEffectIndexes << pastedEffects.at(i).toElement().attribute("kdenlive_ix").toInt(); } for (int i = 0; i < m_subWidgets.count(); i++) { currentEffectIndexes << m_subWidgets.at(i)->effectIndex(); } kDebug()<<"PASTING: "<<pastedEffectIndexes<<" TO "<<currentEffectIndexes; if (pastedEffectIndexes.at(0) < currentEffectIndexes.at(0)) { // Pasting group after current one: emit moveEffect(pastedEffectIndexes, currentEffectIndexes.last(), pasteInfo.groupIndex, pasteInfo.groupName); } else { // Group moved before current one emit moveEffect(pastedEffectIndexes, currentEffectIndexes.first(), pasteInfo.groupIndex, pasteInfo.groupName); } event->setDropAction(Qt::MoveAction); event->accept(); return; } // effect dropped from effects list, add it e.setAttribute("kdenlive_info", m_info.toString()); if (!m_subWidgets.isEmpty()) { e.setAttribute("kdenlive_ix", m_subWidgets.at(0)->effectIndex()); } emit addEffect(e); event->setDropAction(Qt::CopyAction); event->accept(); return; } if (m_subWidgets.isEmpty()) return; int new_index = m_subWidgets.last()->effectIndex(); emit moveEffect(QList <int> () <<ix, new_index, m_info.groupIndex, m_title->text()); event->setDropAction(Qt::MoveAction); event->accept(); }