Crossfire Server, Trunk
TreasureListPanel.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 <Qt>
14
15
#include "
global.h
"
16
#include "
treasure.h
"
17
18
#include "
TreasureListPanel.h
"
19
#include "
CREUtils.h
"
20
21
#include "
assets.h
"
22
#include "
AssetsManager.h
"
23
#include "
TreasureListWrapper.h
"
24
#include "
TreasureWrapper.h
"
25
#include "../assets/AssetUseTree.h"
26
#include "
assets/AssetModel.h
"
27
28
CRETreasurePanel::CRETreasurePanel
(
AssetModel
* model, QWidget* parent) :
AssetTWrapperPanel
(parent) {
29
30
addCheckBox
(tr(
"Single item"
),
"isSingleItem"
,
false
);
31
32
myLayout
->addWidget(
new
QLabel(tr(
"Difficulty:"
)), 2, 0);
33
myLayout
->addWidget(
myDifficulty
=
new
QSpinBox(
this
), 2, 1);
34
myDifficulty
->setRange(0, 150);
35
myDifficulty
->setValue(150);
36
QPushButton* generate =
new
QPushButton(tr(
"generate"
),
this
);
37
connect
(generate, SIGNAL(clicked(
bool
)),
this
, SLOT(
onGenerate
(
bool
)));
38
myLayout
->addWidget(generate, 2, 2);
39
myLayout
->addWidget(
myGenerated
=
new
QTreeWidget(
this
), 3, 0, 1, 3);
40
myGenerated
->setHeaderLabel(tr(
"Generation result"
));
41
myGenerated
->setIconSize(QSize(32, 32));
42
43
myLayout
->addWidget(
new
QLabel(tr(
"Used by"
),
this
), 1, 4, 1, 1);
44
auto
use =
addAssetUseTree
(QString(), model,
"self"
);
45
myLayout
->removeWidget(use);
46
myLayout
->addWidget(use, 2, 4, 2, 3);
47
}
48
49
void
CRETreasurePanel::updateItem
() {
50
myGenerated
->clear();
51
}
52
53
void
CRETreasurePanel::onGenerate
(
bool
) {
54
const
int
difficulty =
myDifficulty
->value();
55
myGenerated
->clear();
56
object
*
result
=
object_new
(), *
item
;
57
create_treasure
(
const_cast<
treasurelist
*
>
(
myItem
),
result
, 0, difficulty, 0);
58
while
((
item
=
result
->inv)) {
59
identify
(
result
->inv);
60
myGenerated
->addTopLevelItem(
CREUtils::objectNode
(
item
, NULL));
61
62
object_remove
(
item
);
63
object_free
(
item
, 0);
64
}
65
66
object_free
(
result
, 0);
67
}
global.h
TreasureListPanel.h
AssetsManager.h
CRETreasurePanel::myDifficulty
QSpinBox * myDifficulty
Definition:
TreasureListPanel.h:41
CREUtils.h
AssetWrapperPanel::addAssetUseTree
AssetUseTree * addAssetUseTree(const QString &label, AssetModel *assets, const char *property)
Definition:
AssetWrapperPanel.cpp:150
create_treasure
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
Definition:
treasure.cpp:263
AssetWrapperPanel::myLayout
QGridLayout * myLayout
Definition:
AssetWrapperPanel.h:56
rotate-tower.result
bool result
Definition:
rotate-tower.py:13
AssetTWrapperPanel
Definition:
AssetWrapperPanel.h:92
CRETreasurePanel::onGenerate
void onGenerate(bool pressed)
Definition:
TreasureListPanel.cpp:53
treasurelist
Definition:
treasure.h:85
CRETreasurePanel::updateItem
virtual void updateItem() override
Definition:
TreasureListPanel.cpp:49
AssetModel
Definition:
AssetModel.h:29
object_free
void object_free(object *ob, int flags)
Definition:
object.cpp:1592
AssetModel.h
treasure.h
object_new
object * object_new(void)
Definition:
object.cpp:1273
AssetTWrapperPanel< treasurelist >::myItem
treasurelist * myItem
Definition:
AssetWrapperPanel.h:106
item
Definition:
item.py:1
CREUtils::objectNode
static QTreeWidgetItem * objectNode(const object *op, QTreeWidgetItem *parent)
Definition:
CREUtils.cpp:33
TreasureListWrapper.h
assets.h
CRETreasurePanel::myGenerated
QTreeWidget * myGenerated
Definition:
TreasureListPanel.h:40
object_remove
void object_remove(object *op)
Definition:
object.cpp:1833
say.item
dictionary item
Definition:
say.py:149
connect
Definition:
connect.py:1
AssetWrapperPanel::addCheckBox
QCheckBox * addCheckBox(const QString &label, const char *property, bool readOnly=true)
Definition:
AssetWrapperPanel.cpp:94
CRETreasurePanel::CRETreasurePanel
CRETreasurePanel(AssetModel *model, QWidget *parent)
Definition:
TreasureListPanel.cpp:28
TreasureWrapper.h
identify
object * identify(object *op)
Definition:
item.cpp:1421
crossfire-crossfire-server
utils
cre
treasures
TreasureListPanel.cpp
Generated by
1.8.17