Crossfire Server, Trunk
FacePanel.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 "FacePanel.h"
14 #include "CRESmoothFaceMaker.h"
15 #include "LicenseManager.h"
16 #include "assets/AssetModel.h"
17 #include "ResourcesManager.h"
18 
20  myMaps = maps;
21  myResources = resources;
22 
23  myUseModel = new UseFilterAssetModel(this);
24  myUseModel->setSourceModel(model);
25 
26  myUseView = new QTreeView(this);
27  myUseView->setIconSize(QSize(32, 32));
28  myUseView->setModel(myUseModel);
29  myLayout->addWidget(myUseView, 1, 1, 3, 2);
30 
31  myLicenses = new QTreeWidget(this);
32  myLicenses->setColumnCount(2);
33  myLicenses->setHeaderLabels(QStringList(tr("License field")) << tr("Value"));
34  myLicenses->setIconSize(QSize(32, 32));
35  myLicenses->setRootIsDecorated(false);
36  myLayout->addWidget(myLicenses, 1, 3, 3, 2);
37 
38  myColor = new QComboBox(this);
39  myLayout->addWidget(new QLabel(tr("Magicmap color: ")), 4, 1);
40  myLayout->addWidget(myColor, 4, 2, 1, 3);
41 
42  const char *name;
43  for(uint color = 0; strcmp(name = get_colorname(color), "") != 0; color++)
44  myColor->addItem(name, color);
45 
46  myFile = new QLineEdit(this);
47  myFile->setReadOnly(true);
48  myLayout->addWidget(new QLabel(tr("Face file: ")), 5, 1);
49  myLayout->addWidget(myFile, 5, 2, 1, 3);
50 
51  mySave = new QPushButton(tr("Save face"));
52  myLayout->addWidget(mySave, 6, 1);
53  connect(mySave, SIGNAL(clicked(bool)), this, SLOT(saveClicked(bool)));
54 
55  QPushButton* smooth = new QPushButton(tr("Make smooth base"), this);
56  myLayout->addWidget(smooth, 6, 2, 1, 3);
57  connect(smooth, SIGNAL(clicked(bool)), this, SLOT(makeSmooth(bool)));
58 }
59 
61 {
63  myUseView->expandAll();
64 
65  myColor->setCurrentIndex(myItem->magicmap);
66 
67  myLicenses->clear();
68 
69  auto licenses = myResources->licenseManager()->getForFace(myItem->name);
70  for (auto l : licenses) {
71  QTreeWidgetItem *wi = new QTreeWidgetItem(QStringList(QString(l.first.c_str())));
72  for (auto p : l.second) {
73  auto twi = new QTreeWidgetItem(wi, QStringList(p.first.c_str()) << p.second.c_str());
74  twi->setToolTip(1, p.second.c_str());
75  }
76  myLicenses->addTopLevelItem(wi);
77  wi->setExpanded(true);
78  }
79 
80  myFile->setText(QString::fromStdString(myResources->originOf(myItem)));
81 }
83 {
84 }
85 
87 {
88  CRESmoothFaceMaker maker;
89  maker.setSelectedFace(myItem);
90  maker.setAutoClose();
91  maker.exec();
92 }
Face::name
sstring name
Definition: face.h:19
CREFacePanel::myUseView
QTreeView * myUseView
Definition: FacePanel.h:40
banquet.l
l
Definition: banquet.py:164
ResourcesManager::licenseManager
LicenseManager * licenseManager()
Definition: ResourcesManager.h:153
CREFacePanel::mySave
QPushButton * mySave
Definition: FacePanel.h:45
maps
static std::unordered_map< std::string, mapzone * > maps
Definition: citylife.cpp:92
ResourcesManager
Definition: ResourcesManager.h:80
get_colorname
const char * get_colorname(uint8_t index)
Definition: image.cpp:86
smoking_pipe.color
color
Definition: smoking_pipe.py:5
UseFilterAssetModel::setFilter
void setFilter(AssetWrapper *asset)
Definition: AssetModel.cpp:197
CREFacePanel::myUseModel
UseFilterAssetModel * myUseModel
Definition: FacePanel.h:41
LicenseManager.h
CREFacePanel::updateItem
virtual void updateItem() override
Definition: FacePanel.cpp:60
ResourcesManager::originOf
std::string originOf(const archetype *arch) const
Definition: ResourcesManager.h:110
CREFacePanel::CREFacePanel
CREFacePanel(QWidget *parent, AssetModel *model, ResourcesManager *resources, CREMapInformationManager *maps)
Definition: FacePanel.cpp:19
CREFacePanel::myColor
QComboBox * myColor
Definition: FacePanel.h:43
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition: AssetWrapperPanel.h:56
AssetTWrapperPanel
Definition: AssetWrapperPanel.h:92
CREFacePanel::makeSmooth
void makeSmooth(bool)
Definition: FacePanel.cpp:86
AssetWrapperPanel::myAsset
AssetWrapper * myAsset
Definition: AssetWrapperPanel.h:58
UseFilterAssetModel
Definition: AssetModel.h:58
AssetModel
Definition: AssetModel.h:29
FacePanel.h
AssetModel.h
LicenseManager::getForFace
LicenseItems getForFace(const std::string &face)
Definition: LicenseManager.cpp:75
ResourcesManager.h
AssetTWrapperPanel< Face >::myItem
Face * myItem
Definition: AssetWrapperPanel.h:106
CREFacePanel::myFile
QLineEdit * myFile
Definition: FacePanel.h:44
CRESmoothFaceMaker
Definition: CRESmoothFaceMaker.h:23
Face::magicmap
uint8_t magicmap
Definition: face.h:17
CRESmoothFaceMaker::setAutoClose
void setAutoClose(bool autoClose=true)
Definition: CRESmoothFaceMaker.cpp:71
CREFacePanel::myMaps
CREMapInformationManager * myMaps
Definition: FacePanel.h:38
connect
Definition: connect.py:1
CREFacePanel::myResources
ResourcesManager * myResources
Definition: FacePanel.h:42
CRESmoothFaceMaker.h
CREMapInformationManager
Definition: CREMapInformationManager.h:27
CREFacePanel::myLicenses
QTreeWidget * myLicenses
Definition: FacePanel.h:46
CRESmoothFaceMaker::setSelectedFace
void setSelectedFace(const Face *face)
Definition: CRESmoothFaceMaker.cpp:61
give.name
name
Definition: give.py:27
CREFacePanel::saveClicked
void saveClicked(bool)
Definition: FacePanel.cpp:82