Crossfire Server, Trunk
AssetWrapperPanel.h
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 #ifndef ASSETWRAPPERPANEL_H
14 #define ASSETWRAPPERPANEL_H
15 
16 #include <QtWidgets>
17 
18 #include "AssetWrapper.h"
19 
21 class ArchetypeComboBox;
22 class AssetUseTree;
23 class AssetModel;
24 class RandomMap;
25 
29 class AssetWrapperPanel : public QWidget {
30  Q_OBJECT
31 public:
32  AssetWrapperPanel(QWidget *parent);
33  virtual ~AssetWrapperPanel();
34 
35  void addTab(const QString &title);
36 
37  virtual void setAsset(AssetWrapper *item);
38 
39  QLabel *addLabel(const QString &label, const char *property, bool wrapText = false);
40  QLineEdit *addLineEdit(const QString &label, const char *property, bool readOnly = true);
41  QTextEdit *addTextEdit(const QString &label, const char *property, bool readOnly = true);
42  QCheckBox *addCheckBox(const QString &label, const char *property, bool readOnly = true);
43  void addFaceChoice(const QString &label, const char *property, bool readOnly = true, bool allowNone = true);
44  void addQuestChoice(const QString &label, const char *property, bool readOnly = true, bool allowNone = true);
45  QSpinBox *addSpinBox(const QString &label, const char *property, int min = 0, int max = 100, bool readOnly = true);
46  TreasureListComboBox *addTreasureList(const QString &label, const char *property, bool readOnly = true, bool allowNone = true);
47  ArchetypeComboBox *addArchetype(const QString &label, const char *property, bool readOnly = false, bool allowNone = true);
48  AssetUseTree *addAssetUseTree(const QString &label, AssetModel *assets, const char *property);
49  void addBottomFiller();
50 
51 protected slots:
52  void dataChanged();
53  void itemChanged();
54 
55 protected:
56  QGridLayout *myLayout;
57  QTabWidget *myTab;
59  bool myInhibit;
60  QMetaObject::Connection myChanged;
61  QMetaObject::Connection myDelete;
62 
63  template<class T>
64  T *addWidget(const QString &label, T *widget, bool sideBySide, const char *property, const char *widgetProperty) {
65  int line = myLayout->rowCount();
66  if (!label.isEmpty()) {
67  myLayout->addWidget(new QLabel(label, this), line, 0, 1, sideBySide ? 1 : 2);
68  if (!sideBySide) {
69  line++;
70  }
71  }
72 
73  myLayout->addWidget(widget, line, sideBySide ? 1 : 0, 1, sideBySide ? 1 : 2);
74  if (property) {
75  myLinks.append({property, widget, widgetProperty});
76  }
77  return widget;
78  }
79 
80  struct PropertyLink {
81  const char *assetPropertyName;
82  QWidget *widget;
83  const char *widgetPropertyName;
84  };
85  QList<PropertyLink> myLinks;
86 };
87 
91 template<typename T>
93 public:
94  AssetTWrapperPanel(QWidget* parent) : AssetWrapperPanel(parent), myItem(nullptr) {};
95 
96  virtual void setAsset(AssetWrapper *asset) override {
98  auto aw = dynamic_cast<AssetTWrapper<T> *>(asset);
99  myItem = aw ? aw->wrappedItem() : nullptr;
100  updateItem();
101  }
103  virtual void updateItem() = 0;
104 
105 protected:
106  T *myItem;
107 };
108 
112 template<typename T>
114 public:
115  AssetSWrapperPanel(QWidget* parent) : AssetWrapperPanel(parent), myItem(nullptr) {};
116 
117  virtual void setAsset(AssetWrapper *asset) override {
119  myItem = dynamic_cast<T *>(asset);
120  updateItem();
121  }
123  virtual void updateItem() = 0;
124 
125 protected:
126  T *myItem;
127 };
128 
129 #endif /* ASSETWRAPPERPANEL_H */
AssetWrapperPanel::addTreasureList
TreasureListComboBox * addTreasureList(const QString &label, const char *property, bool readOnly=true, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:130
AssetWrapperPanel::addTextEdit
QTextEdit * addTextEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:84
AssetWrapperPanel::myTab
QTabWidget * myTab
Definition: AssetWrapperPanel.h:57
AssetWrapperPanel::addBottomFiller
void addBottomFiller()
Definition: AssetWrapperPanel.cpp:154
AssetWrapperPanel::addLabel
QLabel * addLabel(const QString &label, const char *property, bool wrapText=false)
Definition: AssetWrapperPanel.cpp:68
TreasureListComboBox
Definition: TreasureListComboBox.h:23
line
Install Bug reporting Credits so make sure you have version or later There are files involved in the automatic convert convertall and filelist py GuildList has the list of guilds for the server GuildLocations is what is used by the install script for setting up the maps It has columns in the first is the name of the no spaces The second is the region of the the third is the destination folder for the the fourth is the exit the fifth and sixth are the x and y coords within the exit the seventh eighth and ninth are the exit location for the storage hall If field seven is then it uses the same exit map as for the guild hall itself filelist py has a list of which files to process for each guild hall convert py takes all the files in filelist py and customises them to the specific guild then outputs them into a in the same order that they are listed in GuildLocations convertall py reads the lines from GuildLocations and runs line by line
Definition: README.txt:12
AssetWrapperPanel::addArchetype
ArchetypeComboBox * addArchetype(const QString &label, const char *property, bool readOnly=false, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:140
AssetWrapperPanel::addAssetUseTree
AssetUseTree * addAssetUseTree(const QString &label, AssetModel *assets, const char *property)
Definition: AssetWrapperPanel.cpp:150
AssetWrapperPanel::AssetWrapperPanel
AssetWrapperPanel(QWidget *parent)
Definition: AssetWrapperPanel.cpp:23
AssetWrapperPanel::addQuestChoice
void addQuestChoice(const QString &label, const char *property, bool readOnly=true, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:113
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition: AssetWrapperPanel.h:56
AssetWrapperPanel
Definition: AssetWrapperPanel.h:29
AssetWrapperPanel::myChanged
QMetaObject::Connection myChanged
Definition: AssetWrapperPanel.h:60
AssetWrapperPanel::addLineEdit
QLineEdit * addLineEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:74
AssetWrapperPanel::itemChanged
void itemChanged()
Definition: AssetWrapperPanel.cpp:59
AssetWrapper
Definition: AssetWrapper.h:25
AssetWrapperPanel::addCheckBox
QCheckBox * addCheckBox(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:94
ArchetypeComboBox
Definition: ArchetypeComboBox.h:23
RandomMap
Definition: RandomMap.h:24
AssetSWrapperPanel::AssetSWrapperPanel
AssetSWrapperPanel(QWidget *parent)
Definition: AssetWrapperPanel.h:115
AssetUseTree
Definition: AssetUseTree.h:25
AssetWrapperPanel::myAsset
AssetWrapper * myAsset
Definition: AssetWrapperPanel.h:58
AssetTWrapper
Definition: AssetWrapper.h:94
AssetSWrapperPanel::myItem
T * myItem
Definition: AssetWrapperPanel.h:126
AssetWrapperPanel::addSpinBox
QSpinBox * addSpinBox(const QString &label, const char *property, int min=0, int max=100, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:118
AssetWrapperPanel::myInhibit
bool myInhibit
Definition: AssetWrapperPanel.h:59
AssetWrapperPanel::addFaceChoice
void addFaceChoice(const QString &label, const char *property, bool readOnly=true, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:104
AssetWrapperPanel::myLinks
QList< PropertyLink > myLinks
Definition: AssetWrapperPanel.h:85
title
Definition: readable.cpp:108
say.max
dictionary max
Definition: say.py:148
AssetTWrapperPanel::setAsset
virtual void setAsset(AssetWrapper *asset) override
Definition: AssetWrapperPanel.h:96
AssetSWrapperPanel
Definition: AssetWrapperPanel.h:113
AssetTWrapperPanel
Definition: AssetWrapperPanel.h:92
AssetWrapperPanel::addTab
void addTab(const QString &title)
Definition: AssetWrapperPanel.cpp:36
AssetSWrapperPanel::updateItem
virtual void updateItem()=0
AssetWrapperPanel::~AssetWrapperPanel
virtual ~AssetWrapperPanel()
Definition: AssetWrapperPanel.cpp:27
item
Definition: item.py:1
AssetSWrapperPanel::setAsset
virtual void setAsset(AssetWrapper *asset) override
Definition: AssetWrapperPanel.h:117
AssetWrapperPanel::setAsset
virtual void setAsset(AssetWrapper *item)
Definition: AssetWrapperPanel.cpp:46
AssetWrapperPanel::dataChanged
void dataChanged()
Definition: AssetWrapperPanel.cpp:160
AssetWrapperPanel::myDelete
QMetaObject::Connection myDelete
Definition: AssetWrapperPanel.h:61
AssetTWrapperPanel::myItem
T * myItem
Definition: AssetWrapperPanel.h:106
AssetWrapper.h
AssetModel
Definition: AssetModel.h:29
AssetTWrapperPanel::AssetTWrapperPanel
AssetTWrapperPanel(QWidget *parent)
Definition: AssetWrapperPanel.h:94
AssetWrapperPanel::addWidget
T * addWidget(const QString &label, T *widget, bool sideBySide, const char *property, const char *widgetProperty)
Definition: AssetWrapperPanel.h:64
AssetTWrapperPanel::updateItem
virtual void updateItem()=0