Crossfire Server, Trunk
RecipePanel.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 "RecipePanel.h"
14 #include <Qt>
15 #include <QtWidgets>
16 
17 #include "assets.h"
18 #include "AssetsManager.h"
19 
20 #include "CREUtils.h"
21 #include "RecipeWrapper.h"
22 
23 RecipePanel::RecipePanel(QWidget* parent) : AssetTWrapperPanel(parent) {
24  addLineEdit(tr("Title:"), "title");
25  addLineEdit(tr("Skill:"), "skill");
26  addLineEdit(tr("Cauldron:"), "cauldron");
27  addLineEdit(tr("Yield:"), "yield");
28  addLineEdit(tr("Chance:"), "chance");
29  addLineEdit(tr("Experience:"), "experience");
30  addLineEdit(tr("Difficulty:"), "difficulty");
31  addCheckBox(tr("Transmutation"), "transmute");
32  addLineEdit(tr("Index:"), "index");
33  myIngredients = addTextEdit(tr("Ingredients:"), nullptr);
34 
35  myArchetypes = new QTreeWidget(this);
36  myArchetypes->setHeaderLabel(tr("Archetypes:"));
37  myArchetypes->setRootIsDecorated(false);
38  myArchetypes->setIconSize(QSize(32, 32));
39  myLayout->addWidget(myArchetypes, myLayout->rowCount(), 0, 1, 2);
40 }
41 
43  myArchetypes->clear();
44  auto rec = dynamic_cast<RecipeWrapper *>(myAsset);
45  for (auto name : rec->archs()) {
46  auto arch = getManager()->archetypes()->find(name.toLocal8Bit().data());
47  if (arch) {
48  myArchetypes->addTopLevelItem(CREUtils::archetypeNode(arch, NULL));
49  }
50  }
51  myIngredients->setPlainText(rec->ingredients().join("\n"));
52 }
AssetWrapperPanel::addTextEdit
QTextEdit * addTextEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:84
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:74
RecipeWrapper
Definition: RecipeWrapper.h:24
CREUtils.h
RecipeWrapper.h
RecipePanel::myIngredients
QTextEdit * myIngredients
Definition: RecipePanel.h:37
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
CREUtils::archetypeNode
static QTreeWidgetItem * archetypeNode(const archetype *arch, QTreeWidgetItem *parent)
Definition: CREUtils.cpp:26
RecipePanel.h
AssetsCollection::find
T * find(const Key &name)
Definition: AssetsCollection.h:108
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition: AssetWrapperPanel.h:56
AssetTWrapperPanel
Definition: AssetWrapperPanel.h:92
AssetWrapperPanel::myAsset
AssetWrapper * myAsset
Definition: AssetWrapperPanel.h:58
RecipePanel::RecipePanel
RecipePanel(QWidget *parent)
Definition: RecipePanel.cpp:23
AssetsManager::archetypes
Archetypes * archetypes()
Definition: AssetsManager.h:44
assets.h
RecipePanel::myArchetypes
QTreeWidget * myArchetypes
Definition: RecipePanel.h:36
AssetWrapperPanel::addCheckBox
QCheckBox * addCheckBox(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:94
RecipePanel::updateItem
virtual void updateItem() override
Definition: RecipePanel.cpp:42
give.name
name
Definition: give.py:27