Crossfire Server, Trunk
RecipesWrapper.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 "RecipesWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
17 #include "../archetypes/ArchetypeWrapper.h"
18 
20  : AssetWrapper(parent), myResourcesManager(resourcesManager) {
21  setProperty(tipProperty, tr("Display all recipes."));
22 }
23 
26 }
27 
29  return myResourcesManager->wrap(get_formulalist(index + 1), this);
30 }
31 
33  int index = 0;
34  while (index < myResourcesManager->recipeMaxIngredients()) {
35  if (myResourcesManager->wrap(get_formulalist(index + 1), this) == child) {
36  return index;
37  }
38  index++;
39  }
40  return -1;
41 }
42 
43 AssetWrapper::PossibleUse RecipesWrapper::uses(const AssetWrapper *asset, std::string &) const {
44  return dynamic_cast<const ArchetypeWrapper *>(asset) ? ChildrenMayUse : DoesntUse;
45 }
get_formulalist
recipelist * get_formulalist(int i)
Definition: recipe.cpp:97
ResourcesManager
Definition: ResourcesManager.h:80
RecipesWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: RecipesWrapper.cpp:43
RecipesWrapper::childrenCount
virtual int childrenCount() const override
Definition: RecipesWrapper.cpp:24
RecipesWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: RecipesWrapper.h:39
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:31
ResourcesManager::wrap
ArchetypeWrapper * wrap(archt *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:126
RecipesWrapper::RecipesWrapper
RecipesWrapper(AssetWrapper *parent, ResourcesManager *resourcesManager)
Definition: RecipesWrapper.cpp:19
ResourcesManager::recipeMaxIngredients
int recipeMaxIngredients() const
Definition: ResourcesManager.cpp:118
AssetWrapper::tipProperty
static const char * tipProperty
Definition: AssetWrapper.h:33
AssetWrapper::ChildrenMayUse
@ ChildrenMayUse
Definition: AssetWrapper.h:31
RecipesWrapper::childIndex
virtual int childIndex(AssetWrapper *) override
Definition: RecipesWrapper.cpp:32
RecipesWrapper.h
AssetWrapper
Definition: AssetWrapper.h:25
RecipesWrapper::child
virtual AssetWrapper * child(int) override
Definition: RecipesWrapper.cpp:28
ArtifactsWrapper.h
ResourcesManager.h
ArchetypeWrapper
Definition: ArchetypeWrapper.h:25
npc_dialog.index
int index
Definition: npc_dialog.py:102
AssetWrapper::DoesntUse
@ DoesntUse
Definition: AssetWrapper.h:31
CREPixmap.h