Crossfire Resources Editor
RegionWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "RegionWrapper.h"
14 #include "../ResourcesManager.h"
15 #include "../CREMapInformationManager.h"
16 #include "../scripts/ScriptFile.h"
17 #include "../archetypes/ArchetypeWrapper.h"
18 
19 RegionWrapper::RegionWrapper(AssetWrapper *parent, region *reg, ResourcesManager *resources) : AssetTWrapper(parent, "Region", reg),
20  myResourcesManager(resources) {
21  connect(resources->getMapInformationManager(), SIGNAL(finished()), this, SLOT(mapBrowsingFinished()));
22 }
23 
25  return myMaps.size();
26 }
27 
29  return myMaps[index];
30 }
31 
33  for (int idx = 0; idx < myMaps.size(); idx++) {
34  if (myMaps[idx] == child) {
35  return idx;
36  }
37  }
38  return -1;
39 }
40 
41 AssetWrapper::PossibleUse RegionWrapper::uses(const AssetWrapper *asset, std::string &) const {
42  return (dynamic_cast<const QuestWrapper *>(asset)
43  || dynamic_cast<const FaceWrapper *>(asset)
44  || dynamic_cast<const AnimationWrapper *>(asset)
45  || dynamic_cast<const ScriptFile *>(asset)
46  || dynamic_cast<const ArchetypeWrapper *>(asset)
48 }
49 
53  std::sort(myMaps.begin(), myMaps.end(), [] (const auto& left, const auto& right) {
54  return (left->name().compare(right->name(), Qt::CaseInsensitive) < 0) ||
55  (left->name().compare(right->name(), Qt::CaseInsensitive) == 0 &&
56  left->path().compare(right->path(), Qt::CaseInsensitive) < 0);
57  });
59 }
AssetTWrapper< region >::myWrappedItem
region * myWrappedItem
Definition: AssetWrapper.h:110
AssetWrapper::AfterLayoutChange
@ AfterLayoutChange
Definition: AssetWrapper.h:33
RegionWrapper::RegionWrapper
RegionWrapper(AssetWrapper *parent, region *reg, ResourcesManager *resources)
Definition: RegionWrapper.cpp:19
ResourcesManager
Class managing all assets, tracking in which file they are, which are modified, and such.
Definition: ResourcesManager.h:80
AnimationWrapper
Definition: AnimationWrapper.h:24
QuestWrapper
Definition: QuestWrapper.h:66
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
RegionWrapper::child
virtual AssetWrapper * child(int index) override
Definition: RegionWrapper.cpp:28
AssetWrapper::ChildrenMayUse
@ ChildrenMayUse
Definition: AssetWrapper.h:32
ResourcesManager::getMapInformationManager
CREMapInformationManager * getMapInformationManager()
Definition: ResourcesManager.h:91
RegionWrapper::childIndex
virtual int childIndex(AssetWrapper *child) override
Definition: RegionWrapper.cpp:32
FaceWrapper
Definition: FaceWrapper.h:24
AssetWrapper
Base class for all assets that can be displayed or edited by CRE.
Definition: AssetWrapper.h:25
RegionWrapper::myMaps
QList< CREMapInformation * > myMaps
Definition: RegionWrapper.h:53
RegionWrapper.h
CREMapInformationManager::getMapsForRegion
QList< CREMapInformation * > getMapsForRegion(const QString &region)
Definition: CREMapInformationManager.cpp:793
ScriptFile
Information about a script file.
Definition: ScriptFile.h:48
RegionWrapper::mapBrowsingFinished
void mapBrowsingFinished()
Definition: RegionWrapper.cpp:50
ArchetypeWrapper
Definition: ArchetypeWrapper.h:25
AssetWrapper::BeforeLayoutChange
@ BeforeLayoutChange
Definition: AssetWrapper.h:33
RegionWrapper::childrenCount
virtual int childrenCount() const override
Definition: RegionWrapper.cpp:24
RegionWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: RegionWrapper.h:52
AssetWrapper::markModified
void markModified(ChangeType change, int extra=0)
Definition: AssetWrapper.h:57
RegionWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: RegionWrapper.cpp:41
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
AssetTWrapper
Base class for assets mapping to a native Crossfire structure.
Definition: AssetWrapper.h:100