mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Support placement of spell scrolls
This commit is contained in:
parent
e20b1e275b
commit
cb4a4298c1
@ -3,7 +3,10 @@
|
||||
#include "../lib/mapObjects/CObjectHandler.h"
|
||||
#include "../lib/mapObjects/CObjectClassesHandler.h"
|
||||
#include "../lib/mapObjects/CGTownInstance.h"
|
||||
#include "../lib/mapObjects/MiscObjects.h"
|
||||
#include "../lib/CArtHandler.h"
|
||||
#include "../lib/spells/CSpellHandler.h"
|
||||
#include "../lib/CRandomGenerator.h"
|
||||
|
||||
void Inspector::setProperty(const QString & key, const QVariant & value)
|
||||
{
|
||||
@ -11,7 +14,6 @@ void Inspector::setProperty(const QString & key, const QVariant & value)
|
||||
return;
|
||||
|
||||
setProperty(dynamic_cast<CGTownInstance*>(obj), key, value);
|
||||
|
||||
//updateProperties();
|
||||
}
|
||||
|
||||
@ -49,9 +51,32 @@ CGTownInstance * initialize(CGTownInstance * o)
|
||||
return o;
|
||||
}
|
||||
|
||||
CGArtifact * initialize(CGArtifact * o)
|
||||
{
|
||||
if(!o)
|
||||
return nullptr;
|
||||
|
||||
if(o->ID == Obj::SPELL_SCROLL)
|
||||
{
|
||||
std::vector<SpellID> out;
|
||||
for(auto spell : VLC->spellh->objects) //spellh size appears to be greater (?)
|
||||
{
|
||||
if(/*map.isAllowedSpell(spell->id) && spell->level == i + 1*/ true)
|
||||
{
|
||||
out.push_back(spell->id);
|
||||
}
|
||||
}
|
||||
auto a = CArtifactInstance::createScroll(*RandomGeneratorUtil::nextItem(out, CRandomGenerator::getDefault()));
|
||||
o->storedArtifact = a;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
Initializer::Initializer(CGObjectInstance * o)
|
||||
{
|
||||
initialize(dynamic_cast<CGTownInstance*>(o));
|
||||
initialize(dynamic_cast<CGArtifact*>(o));
|
||||
}
|
||||
|
||||
Inspector::Inspector(CGObjectInstance * o, QTableWidget * t): obj(o), table(t)
|
||||
|
@ -239,9 +239,9 @@ void MapController::commitObjectCreate(int level)
|
||||
auto * newObj = _scenes[level]->selectionObjectsView.newObject;
|
||||
if(!newObj)
|
||||
return;
|
||||
_map->getEditManager()->insertObject(newObj);
|
||||
Initializer init(newObj);
|
||||
|
||||
_map->getEditManager()->insertObject(newObj);
|
||||
main->mapChanged();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user