Crossfire Server, Trunk
ArtifactsWrapper.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 "ArtifactsWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
16 #include "faces/FaceWrapper.h"
17 
19  : AssetWrapper(parent), myResourcesManager(resourcesManager) {
20  setProperty(tipProperty, tr("Display all artifacts."));
21 }
22 
24  int count = 0;
25  auto list = first_artifactlist;
26  while (list) {
27  count++;
28  list = list->next;
29  }
30  return count;
31 }
32 
34  auto list = first_artifactlist;
35  while (index > 0) {
36  index--;
37  list = list->next;
38  }
39  return myResourcesManager->wrap(list, this);
40 }
41 
43  auto list = first_artifactlist;
44  int index = 0;
45  while (list) {
46  if (myResourcesManager->wrap(list, this) == child) {
47  return index;
48  }
49  list = list->next;
50  index++;
51  }
52  return -1;
53 }
54 
56  if (dynamic_cast<const FaceWrapper *>(asset) || dynamic_cast<const AnimationWrapper *>(asset)) {
57  return ChildrenMayUse;
58  }
59  return DoesntUse;
60 }
ArtifactsWrapper::childIndex
virtual int childIndex(AssetWrapper *) override
Definition: ArtifactsWrapper.cpp:42
ResourcesManager
Definition: ResourcesManager.h:80
AnimationWrapper
Definition: AnimationWrapper.h:24
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
ArtifactsWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ArtifactsWrapper.h:39
guildoracle.list
list
Definition: guildoracle.py:87
ArtifactsWrapper::childrenCount
virtual int childrenCount() const override
Definition: ArtifactsWrapper.cpp:23
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:34
AssetWrapper::ChildrenMayUse
@ ChildrenMayUse
Definition: AssetWrapper.h:32
FaceWrapper
Definition: FaceWrapper.h:24
AssetWrapper
Definition: AssetWrapper.h:25
disinfect.count
int count
Definition: disinfect.py:7
FaceWrapper.h
ArtifactsWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: ArtifactsWrapper.cpp:55
ArtifactsWrapper.h
ResourcesManager.h
npc_dialog.index
int index
Definition: npc_dialog.py:102
first_artifactlist
artifactlist * first_artifactlist
Definition: init.cpp:109
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
CREPixmap.h
ArtifactsWrapper::child
virtual AssetWrapper * child(int) override
Definition: ArtifactsWrapper.cpp:33
ArtifactsWrapper::ArtifactsWrapper
ArtifactsWrapper(AssetWrapper *parent, ResourcesManager *resourcesManager)
Definition: ArtifactsWrapper.cpp:18