Crossfire Server, Trunk
RecipePanel.cpp
Go to the documentation of this file.
1 #include "RecipePanel.h"
2 #include <Qt>
3 #include <QtWidgets>
4 
5 #include "assets.h"
6 #include "AssetsManager.h"
7 
8 #include "CREUtils.h"
9 #include "RecipeWrapper.h"
10 
11 RecipePanel::RecipePanel(QWidget* parent) : AssetWrapperPanel(parent) {
12  addLineEdit(tr("Title:"), "title");
13  addLineEdit(tr("Skill:"), "skill");
14  addLineEdit(tr("Cauldron:"), "cauldron");
15  addLineEdit(tr("Yield:"), "yield");
16  addLineEdit(tr("Chance:"), "chance");
17  addLineEdit(tr("Experience:"), "experience");
18  addLineEdit(tr("Difficulty:"), "difficulty");
19  addCheckBox(tr("Transmutation"), "transmute");
20  addLineEdit(tr("Index:"), "index");
21  myIngredients = addTextEdit(tr("Ingredients:"), nullptr);
22 
23  myArchetypes = new QTreeWidget(this);
24  myArchetypes->setHeaderLabel(tr("Archetypes:"));
25  myArchetypes->setRootIsDecorated(false);
26  myArchetypes->setIconSize(QSize(32, 32));
27  myLayout->addWidget(myArchetypes, myLayout->rowCount(), 0, 1, 2);
28 }
29 
32 
33  auto recipe = dynamic_cast<RecipeWrapper *>(asset);
34  Q_ASSERT(recipe);
35 
36  myArchetypes->clear();
37  for (auto name : recipe->archs()) {
38  auto arch = getManager()->archetypes()->find(name.toLocal8Bit().data());
39  if (arch) {
40  myArchetypes->addTopLevelItem(CREUtils::archetypeNode(arch, NULL));
41  }
42  }
43  myIngredients->setPlainText(recipe->ingredients().join("\n"));
44 }
AssetWrapperPanel
Definition: AssetWrapperPanel.h:16
AssetWrapperPanel::addTextEdit
QTextEdit * addTextEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:49
archininventory.arch
arch
DIALOGCHECK MINARGS 1 MAXARGS 1
Definition: archininventory.py:16
AssetsManager.h
AssetWrapperPanel::addLineEdit
QLineEdit * addLineEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:39
RecipeWrapper
Definition: RecipeWrapper.h:15
CREUtils::archetypeNode
static QTreeWidgetItem * archetypeNode(QTreeWidgetItem *parent)
Definition: CREUtils.cpp:14
CREUtils.h
AssetWrapperPanel::setItem
virtual void setItem(AssetWrapper *item) override
Definition: AssetWrapperPanel.cpp:13
RecipeWrapper.h
RecipePanel::myIngredients
QTextEdit * myIngredients
Definition: RecipePanel.h:19
getManager
AssetsManager * getManager()
Definition: assets.cpp:333
RecipePanel.h
AssetsCollection::find
T * find(const Key &name)
Definition: AssetsCollection.h:85
recipestruct
Definition: recipe.h:10
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition: AssetWrapperPanel.h:37
AssetWrapper
Definition: AssetWrapper.h:11
RecipePanel::RecipePanel
RecipePanel(QWidget *parent)
Definition: RecipePanel.cpp:11
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
RecipePanel::setItem
virtual void setItem(AssetWrapper *asset) override
Definition: RecipePanel.cpp:30
assets.h
RecipePanel::myArchetypes
QTreeWidget * myArchetypes
Definition: RecipePanel.h:18
AssetWrapperPanel::addCheckBox
QCheckBox * addCheckBox(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:59
give.name
name
Definition: give.py:27