Crossfire Server, Trunk
TreasurePanel.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 "TreasurePanel.h"
14 #include <QMimeData>
15 #include "assets.h"
16 #include "AssetsManager.h"
19 #include "MimeUtils.h"
20 #include "HelpManager.h"
21 
22 TreasurePanel::TreasurePanel(QWidget* parent) : AssetWrapperPanel(parent) {
23  addSpinBox(tr("Chance:"), "chance", 0, 255, false);
24  addSpinBox(tr("Magic:"), "magic", 0, 255, false);
25  addSpinBox(tr("Count:"), "nrof", 0, 65535, false);
26  myList = addTreasureList(tr("Treasure:"), "list", false);
27  addSpinBox(tr("Magic to generate with:"), "list_magic_value", std::numeric_limits<uint8_t>::min(), std::numeric_limits<uint8_t>::max(), false);
28  addSpinBox(tr("Magic adjustment:"), "list_magic_adjustment", std::numeric_limits<int8_t>::min(), std::numeric_limits<int8_t>::max(), false);
29  myArch = addArchetype(tr("Archetype:"), "arch");
30  addLineEdit(tr("Artifact:"), "artifact", false);
32  setAcceptDrops(true);
33  HelpManager::setHelpId(this, "treasures");
34 }
35 
36 void TreasurePanel::dragEnterEvent(QDragEnterEvent *event) {
37  if (event->mimeData()->hasFormat(MimeUtils::Archetype) || event->mimeData()->hasFormat(MimeUtils::TreasureList)) {
38  event->acceptProposedAction();
39  }
40 }
41 
42 void TreasurePanel::dragMoveEvent(QDragMoveEvent *event) {
43  event->acceptProposedAction();
44 }
45 
46 void TreasurePanel::dropEvent(QDropEvent *event) {
47  auto archs = MimeUtils::extract(event->mimeData(), MimeUtils::Archetype, getManager()->archetypes());
48  if (!archs.empty()) {
49  myArch->setArch(archs.front());
50  event->acceptProposedAction();
51  }
52  auto lists = MimeUtils::extract(event->mimeData(), MimeUtils::TreasureList, getManager()->treasures());
53  if (!lists.empty()) {
54  myList->setList(lists.front());
55  event->acceptProposedAction();
56  }
57 }
AssetWrapperPanel::addTreasureList
TreasureListComboBox * addTreasureList(const QString &label, const char *property, bool readOnly=true, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:130
AssetWrapperPanel::addBottomFiller
void addBottomFiller()
Definition: AssetWrapperPanel.cpp:154
AssetWrapperPanel::addArchetype
ArchetypeComboBox * addArchetype(const QString &label, const char *property, bool readOnly=false, bool allowNone=true)
Definition: AssetWrapperPanel.cpp:140
ArchetypeComboBox.h
TreasurePanel::dropEvent
virtual void dropEvent(QDropEvent *event) override
Definition: TreasurePanel.cpp:46
TreasurePanel::myArch
ArchetypeComboBox * myArch
Definition: TreasurePanel.h:33
AssetWrapperPanel
Definition: AssetWrapperPanel.h:29
archetypes
other than new code I created new archetypes
Definition: arch-handbook.txt:18
TreasureListComboBox::setList
void setList(const treasurelist *list)
Definition: TreasureListComboBox.cpp:37
AssetWrapperPanel::addLineEdit
QLineEdit * addLineEdit(const QString &label, const char *property, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:74
MimeUtils::TreasureList
static const char * TreasureList
Definition: MimeUtils.h:25
AssetsManager.h
getManager
AssetsManager * getManager()
Definition: assets.cpp:305
TreasurePanel::dragMoveEvent
virtual void dragMoveEvent(QDragMoveEvent *event) override
Definition: TreasurePanel.cpp:42
AssetWrapperPanel::addSpinBox
QSpinBox * addSpinBox(const QString &label, const char *property, int min=0, int max=100, bool readOnly=true)
Definition: AssetWrapperPanel.cpp:118
TreasurePanel::myList
TreasureListComboBox * myList
Definition: TreasurePanel.h:34
TreasurePanel::TreasurePanel
TreasurePanel(QWidget *parent)
Definition: TreasurePanel.cpp:22
say.max
dictionary max
Definition: say.py:148
TreasurePanel.h
TreasureListComboBox.h
MimeUtils::extract
static QList< T * > extract(const QMimeData *data, const QString &mime, AssetsCollection< T > *assets)
Definition: MimeUtils.h:31
assets.h
MimeUtils.h
ArchetypeComboBox::setArch
void setArch(const archetype *arch)
Definition: ArchetypeComboBox.cpp:41
lists
Crossfire Protocol most of the time after the actual code was already omit certain important and possibly make life miserable any new developer or curious player should be able to find most of the relevant information here If inconsistencies are found or this documentation proves to be consider the latest server side protocol code in the public source code repository as the authoritative reference Introduction If you were ever curious enough to telnet or netcat to a Crossfire chances are you were sorely disappointed While the protocol may seem to use plain text at it actually uses a mix of ASCII and binary data This handbook attempts to document various aspects of the Crossfire protocol As consult the README file to find out how to get in touch with helpful people via mailing lists
Definition: protocol.txt:24
TreasurePanel::dragEnterEvent
virtual void dragEnterEvent(QDragEnterEvent *event) override
Definition: TreasurePanel.cpp:36
HelpManager::setHelpId
static void setHelpId(QWidget *widget, const QString &id)
Definition: HelpManager.cpp:58
MimeUtils::Archetype
static const char * Archetype
Definition: MimeUtils.h:24
animate.event
event
DIALOGCHECK MINARGS 1 MAXARGS 2
Definition: animate.py:17
HelpManager.h