Crossfire Server, Trunk
RecipeListWrapper.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 "RecipeWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
16 #include "RecipeListWrapper.h"
17 #include "../archetypes/ArchetypeWrapper.h"
18 
20  : AssetTWrapper(parent, "RecipeList", list), myResourcesManager(resources) {
21 }
22 
24  int count = 0;
25  auto item = myWrappedItem->items;
26  while (item) {
27  count++;
28  item = item->next;
29  }
30  return count;
31 }
32 
34  auto item = myWrappedItem->items;
35  while (index > 0) {
36  index--;
37  item = item->next;
38  }
39  return myResourcesManager->wrap(item, this);
40 }
41 
43  auto item = myWrappedItem->items;
44  int index = 0;
45  while (item) {
46  if (myResourcesManager->wrap(item, this) == child) {
47  return index;
48  }
49  item = item->next;
50  index++;
51  }
52  return -1;
53 }
54 
56  return dynamic_cast<const ArchetypeWrapper *>(asset) ? ChildrenMayUse : DoesntUse;
57 }
AssetTWrapper< const recipelist >::myWrappedItem
const recipelist * myWrappedItem
Definition: AssetWrapper.h:104
ResourcesManager
Definition: ResourcesManager.h:80
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
guildoracle.list
list
Definition: guildoracle.py:87
recipelist::items
recipe * items
Definition: recipe.h:40
RecipeWrapper.h
AssetWrapper::ChildrenMayUse
@ ChildrenMayUse
Definition: AssetWrapper.h:32
recipelist
Definition: recipe.h:37
AssetWrapper
Definition: AssetWrapper.h:25
RecipeListWrapper::childrenCount
virtual int childrenCount() const override
Definition: RecipeListWrapper.cpp:23
disinfect.count
int count
Definition: disinfect.py:7
RecipeListWrapper.h
ResourcesManager.h
RecipeListWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: RecipeListWrapper.cpp:55
item
Definition: item.py:1
ArchetypeWrapper
Definition: ArchetypeWrapper.h:25
npc_dialog.index
int index
Definition: npc_dialog.py:102
RecipeListWrapper::child
virtual AssetWrapper * child(int) override
Definition: RecipeListWrapper.cpp:33
RecipeListWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: RecipeListWrapper.h:37
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:32
RecipeListWrapper::RecipeListWrapper
RecipeListWrapper(AssetWrapper *parent, const recipelist *list, ResourcesManager *resources)
Definition: RecipeListWrapper.cpp:19
RecipeListWrapper::childIndex
virtual int childIndex(AssetWrapper *) override
Definition: RecipeListWrapper.cpp:42
CREPixmap.h
AssetTWrapper
Definition: AssetWrapper.h:94