Crossfire Server, Trunk
RecipeWrapper.cpp
Go to the documentation of this file.
1 #include "RecipeWrapper.h"
2 #include "ResourcesManager.h"
3 #include "CREPixmap.h"
4 
6  : AssetTWrapper(parent, "Recipe", rp) {
7 }
8 
9 QString RecipeWrapper::title() const
10 {
11  return myWrappedItem->title;
12 }
13 
14 int RecipeWrapper::chance() const
15 {
16  return myWrappedItem->chance;
17 }
18 
19 int RecipeWrapper::difficulty() const
20 {
21  return myWrappedItem->diff;
22 }
23 
24 int RecipeWrapper::experience() const
25 {
26  return myWrappedItem->exp;
27 }
28 
29 QStringList RecipeWrapper::archs() const
30 {
31  QStringList archs;
32  for (size_t i = 0; i < myWrappedItem->arch_names; i++)
33  {
34  archs.append(myWrappedItem->arch_name[i]);
35  }
36  return archs;
37 }
38 
39 QStringList RecipeWrapper::ingredients() const
40 {
41  QStringList ingredients;
42  for (linked_char* ing = myWrappedItem->ingred; ing; ing = ing->next)
43  {
44  ingredients.append(ing->name);
45  }
46  return ingredients;
47 }
48 
49 bool RecipeWrapper::transmute() const
50 {
51  return myWrappedItem->transmute != 0;
52 }
53 
54 int RecipeWrapper::minLevel() const
55 {
56  return myWrappedItem->min_level;
57 }
58 
59 QString RecipeWrapper::keycode() const
60 {
61  return myWrappedItem->keycode;
62 }
63 
64 QString RecipeWrapper::displayName() const {
65  if (myWrappedItem->arch_names == 0) {
66  return QString("%1 (no archetype?)").arg(myWrappedItem->title);
67  }
68  auto base = find_archetype(myWrappedItem->arch_name[0]);
69  if (!base) {
70  return QString("%1 (no archetype?)").arg(myWrappedItem->title);
71  }
72 
73  if (strcmp(myWrappedItem->title, "NONE") == 0) {
74  if (base->clone.title) {
75  return QString("%1 %2").arg(base->clone.name, base->clone.title);
76  }
77  return base->clone.name;
78  }
79  return QString("%1 of %2").arg(base->clone.name, myWrappedItem->title);
80 }
81 
83  const Face *face = recipe_get_face(myWrappedItem);
84  const archt* base = NULL;
85  if (myWrappedItem->arch_names > 0) {
87  }
88  if (!face && base != NULL) {
89  return CREPixmap::getIcon(base->clone.face);
90  }
91  return CREPixmap::getIcon(face);
92 }
93 
94 void RecipeWrapper::displayFillPanel(QWidget *panel) {
95  AssetWrapperPanel *p = static_cast<AssetWrapperPanel *>(panel);
96  p->setItem(this);
97 }
recipestruct::arch_names
size_t arch_names
Definition: recipe.h:12
AssetWrapperPanel
Definition: AssetWrapperPanel.h:16
AssetTWrapper< const recipe >::myWrappedItem
const recipe * myWrappedItem
Definition: AssetWrapper.h:87
Face
Definition: face.h:14
obj::face
const Face * face
Definition: object.h:336
RecipeWrapper::minLevel
int minLevel
Definition: RecipeWrapper.h:26
RecipeWrapper::displayName
virtual QString displayName() const override
Definition: RecipeWrapper.cpp:64
ResourcesManager
Definition: ResourcesManager.h:67
CREPixmap::getIcon
static QIcon getIcon(uint16_t faceNumber)
Definition: CREPixmap.cpp:55
recipestruct::title
sstring title
Definition: recipe.h:11
AssetWrapperPanel::setItem
virtual void setItem(AssetWrapper *item) override
Definition: AssetWrapperPanel.cpp:13
RecipeWrapper.h
recipestruct::chance
int chance
Definition: recipe.h:14
linked_char
Definition: global.h:86
archt
Definition: object.h:470
RecipeWrapper::title
QString title
Definition: RecipeWrapper.h:19
recipestruct
Definition: recipe.h:10
RecipeWrapper::RecipeWrapper
RecipeWrapper(AssetWrapper *parent, const recipe *rp, ResourcesManager *resources)
Definition: RecipeWrapper.cpp:5
RecipeWrapper::displayIcon
virtual QIcon displayIcon() const override
Definition: RecipeWrapper.cpp:82
AssetWrapper
Definition: AssetWrapper.h:11
recipestruct::arch_name
char ** arch_name
Definition: recipe.h:13
recipestruct::exp
int exp
Definition: recipe.h:17
linked_char::next
struct linked_char * next
Definition: global.h:88
recipestruct::keycode
sstring keycode
Definition: recipe.h:25
recipe_get_face
const Face * recipe_get_face(const recipe *rp)
Definition: recipe.c:797
recipestruct::ingred
linked_char * ingred
Definition: recipe.h:22
ResourcesManager.h
RecipeWrapper::transmute
bool transmute
Definition: RecipeWrapper.h:25
archt::clone
object clone
Definition: object.h:474
recipestruct::min_level
int min_level
Definition: recipe.h:30
RecipeWrapper::keycode
QString keycode
Definition: RecipeWrapper.h:27
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:282
recipestruct::diff
int diff
Definition: recipe.h:16
recipestruct::transmute
int transmute
Definition: recipe.h:19
RecipeWrapper::difficulty
int difficulty
Definition: RecipeWrapper.h:21
RecipeWrapper::archs
QStringList archs
Definition: RecipeWrapper.h:23
RecipeWrapper::chance
int chance
Definition: RecipeWrapper.h:20
CREPixmap.h
RecipeWrapper::displayFillPanel
virtual void displayFillPanel(QWidget *panel) override
Definition: RecipeWrapper.cpp:94
RecipeWrapper::ingredients
QStringList ingredients
Definition: RecipeWrapper.h:24
RecipeWrapper::experience
int experience
Definition: RecipeWrapper.h:22
AssetTWrapper
Definition: AssetWrapper.h:72