1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +02:00

Add more objects into inspector

This commit is contained in:
nordsoft 2022-09-07 02:21:00 +04:00
parent 0849f93d88
commit 9429cb4340
5 changed files with 119 additions and 20 deletions

View File

@ -445,7 +445,7 @@ public:
}
};
class CGShipyard : public CGObjectInstance, public IShipyard
class DLL_LINKAGE CGShipyard : public CGObjectInstance, public IShipyard
{
public:
void getOutOffsets(std::vector<int3> &offsets) const override; //offsets to obj pos when we boat can be placed

View File

@ -13,11 +13,41 @@ Initializer::Initializer(CMap * m, CGObjectInstance * o) : map(m)
INIT_OBJ_TYPE(CGResource);
INIT_OBJ_TYPE(CGArtifact);
INIT_OBJ_TYPE(CArmedInstance);
INIT_OBJ_TYPE(CGShipyard);
INIT_OBJ_TYPE(CGGarrison);
INIT_OBJ_TYPE(CGMine);
INIT_OBJ_TYPE(CGDwelling);
INIT_OBJ_TYPE(CGTownInstance);
INIT_OBJ_TYPE(CGHeroInstance);
}
void Initializer::initialize(CArmedInstance * o)
{
if(!o) return;
}
void Initializer::initialize(CGDwelling * o)
{
if(!o) return;
o->tempOwner = PlayerColor::NEUTRAL;
}
void Initializer::initialize(CGGarrison * o)
{
if(!o) return;
o->tempOwner = PlayerColor::NEUTRAL;
}
void Initializer::initialize(CGShipyard * o)
{
if(!o) return;
o->tempOwner = PlayerColor::NEUTRAL;
}
void Initializer::initialize(CGHeroInstance * o)
{
if(!o) return;
@ -80,11 +110,38 @@ void Inspector::updateProperties(CArmedInstance * o)
addProperty("Owner", o->tempOwner);
}
void Inspector::updateProperties(CGTownInstance * o)
void Inspector::updateProperties(CGDwelling * o)
{
if(!o) return;
addProperty("Owner", o->tempOwner, false);
}
void Inspector::updateProperties(CGGarrison * o)
{
if(!o) return;
addProperty("Owner", o->tempOwner, false);
}
void Inspector::updateProperties(CGShipyard * o)
{
if(!o) return;
addProperty("Owner", o->tempOwner, false);
}
void Inspector::updateProperties(CGHeroInstance * o)
{
if(!o) return;
addProperty("Owner", o->tempOwner, o->ID == Obj::PRISON); //field is not editable for prison
}
void Inspector::updateProperties(CGTownInstance * o)
{
if(!o) return;
addProperty("Town name", o->name, false);
}
@ -109,6 +166,8 @@ void Inspector::updateProperties(CGResource * o)
addProperty("Amount", o->amount, false);
}
void Inspector::updateProperties()
{
if(!obj)
@ -125,10 +184,14 @@ void Inspector::updateProperties()
addProperty("IsStatic", factory->isStaticObject());
UPDATE_OBJ_PROPERTIES(CArmedInstance);
UPDATE_OBJ_PROPERTIES(CGTownInstance);
UPDATE_OBJ_PROPERTIES(CGResource);
UPDATE_OBJ_PROPERTIES(CGArtifact);
UPDATE_OBJ_PROPERTIES(CGMine);
UPDATE_OBJ_PROPERTIES(CGResource);
UPDATE_OBJ_PROPERTIES(CGGarrison);
UPDATE_OBJ_PROPERTIES(CGShipyard);
UPDATE_OBJ_PROPERTIES(CGDwelling);
UPDATE_OBJ_PROPERTIES(CGTownInstance);
UPDATE_OBJ_PROPERTIES(CGHeroInstance);
table->show();
}
@ -139,18 +202,6 @@ void Inspector::setProperty(const QString & key, const QVariant & value)
if(!obj)
return;
SET_PROPERTIES(CArmedInstance);
SET_PROPERTIES(CGTownInstance);
SET_PROPERTIES(CGArtifact);
SET_PROPERTIES(CGMine);
SET_PROPERTIES(CGResource);
}
void Inspector::setProperty(CArmedInstance * object, const QString & key, const QVariant & value)
{
if(!object)
return;
if(key == "Owner")
{
PlayerColor owner(value.toString().toInt());
@ -158,9 +209,24 @@ void Inspector::setProperty(CArmedInstance * object, const QString & key, const
owner = PlayerColor::NEUTRAL;
if(value == "UNFLAGGABLE")
owner = PlayerColor::UNFLAGGABLE;
object->tempOwner = owner;
return;
obj->tempOwner = owner;
}
SET_PROPERTIES(CArmedInstance);
SET_PROPERTIES(CGTownInstance);
SET_PROPERTIES(CGArtifact);
SET_PROPERTIES(CGMine);
SET_PROPERTIES(CGResource);
SET_PROPERTIES(CGDwelling);
SET_PROPERTIES(CGGarrison);
SET_PROPERTIES(CGHeroInstance);
SET_PROPERTIES(CGShipyard);
}
void Inspector::setProperty(CArmedInstance * object, const QString & key, const QVariant & value)
{
if(!object)
return;
}
void Inspector::setProperty(CGTownInstance * object, const QString & key, const QVariant & value)
@ -187,6 +253,30 @@ void Inspector::setProperty(CGArtifact * object, const QString & key, const QVar
return;
}
void Inspector::setProperty(CGDwelling * object, const QString & key, const QVariant & value)
{
if(!object)
return;
}
void Inspector::setProperty(CGGarrison * object, const QString & key, const QVariant & value)
{
if(!object)
return;
}
void Inspector::setProperty(CGHeroInstance * object, const QString & key, const QVariant & value)
{
if(!object)
return;
}
void Inspector::setProperty(CGShipyard * object, const QString & key, const QVariant & value)
{
if(!object)
return;
}
void Inspector::setProperty(CGResource * object, const QString & key, const QVariant & value)
{
if(!object)

View File

@ -24,10 +24,14 @@ class Initializer
public:
//===============DECLARE MAP OBJECTS======================================
DECLARE_OBJ_TYPE(CArmedInstance);
DECLARE_OBJ_TYPE(CGShipyard);
DECLARE_OBJ_TYPE(CGTownInstance);
DECLARE_OBJ_TYPE(CGArtifact);
DECLARE_OBJ_TYPE(CGMine);
DECLARE_OBJ_TYPE(CGResource);
DECLARE_OBJ_TYPE(CGDwelling);
DECLARE_OBJ_TYPE(CGGarrison);
DECLARE_OBJ_TYPE(CGHeroInstance);
Initializer(CMap *, CGObjectInstance *);
@ -42,9 +46,13 @@ protected:
//===============DECLARE PROPERTIES SETUP=================================
DECLARE_OBJ_PROPERTY_METHODS(CArmedInstance);
DECLARE_OBJ_PROPERTY_METHODS(CGTownInstance);
DECLARE_OBJ_PROPERTY_METHODS(CGShipyard);
DECLARE_OBJ_PROPERTY_METHODS(CGArtifact);
DECLARE_OBJ_PROPERTY_METHODS(CGMine);
DECLARE_OBJ_PROPERTY_METHODS(CGResource);
DECLARE_OBJ_PROPERTY_METHODS(CGDwelling);
DECLARE_OBJ_PROPERTY_METHODS(CGGarrison);
DECLARE_OBJ_PROPERTY_METHODS(CGHeroInstance);
//===============DECLARE PROPERTY VALUE TYPE==============================
QTableWidgetItem * addProperty(unsigned int value);

View File

@ -75,6 +75,7 @@ void MapController::setMap(std::unique_ptr<CMap> cmap)
dynamic_cast<CGDwelling*>(obj.get()) ||
dynamic_cast<CGTownInstance*>(obj.get()) ||
dynamic_cast<CGGarrison*>(obj.get()) ||
dynamic_cast<CGShipyard*>(obj.get()) ||
dynamic_cast<CGHeroInstance*>(obj.get()))
obj->tempOwner = PlayerColor::NEUTRAL;

View File

@ -143,8 +143,8 @@ void setPlayerColor(QImage * sur, PlayerColor player)
if(sur->format() == QImage::Format_Indexed8)
{
QRgb color = graphics->neutralColor;
if(player != PlayerColor::NEUTRAL)
color = graphics->playerColors[player.getNum()];
if(player != PlayerColor::NEUTRAL && player < PlayerColor::PLAYER_LIMIT)
color = graphics->playerColors.at(player.getNum());
sur->setColor(5, color);
}