Crossfire Server, Trunk
CREPrePostList.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 <QtWidgets>
14 #include "CREPrePostList.h"
16 
17 PrePostWidget::PrePostWidget(QWidget* parent, Mode mode, const MessageManager* manager) : QWidget(parent), myMode(mode)
18 {
19  myList = new QListWidget(parent);
21  connect(myList, &QListWidget::itemChanged, this, [&] () { emit dataModified(); });
22 
23  QPushButton* addCondition = new QPushButton(tr("add"), this);
24  connect(addCondition, SIGNAL(clicked(bool)), this, SLOT(onAddCondition(bool)));
25 
26  QPushButton* delCondition = new QPushButton(tr("delete"), this);
27  connect(delCondition, SIGNAL(clicked(bool)), this, SLOT(onDeleteCondition(bool)));
28 
29  QPushButton* reset = new QPushButton(tr("reset changes"), this);
30  connect(reset, SIGNAL(clicked(bool)), this, SLOT(onReset(bool)));
31 
32  QHBoxLayout* buttons = new QHBoxLayout();
33  buttons->addWidget(addCondition);
34  buttons->addWidget(delCondition);
35  buttons->addWidget(reset);
36 
37  QVBoxLayout* l = new QVBoxLayout(this);
38  l->addWidget(myList);
39  l->addLayout(buttons);
40  setLayout(l);
41 }
42 
43 QList<QStringList> PrePostWidget::data() const
44 {
45  QList<QStringList> value;
46  for (int i = 0; i < myList->count(); i++)
47  {
48  QListWidgetItem* wi = myList->item(i);
49  QStringList data = wi->data(Qt::UserRole).value<QStringList>();
50  if (myMode == SetWhen)
51  data.pop_front();
52  value.append(data);
53  }
54  return value;
55 }
56 
57 void PrePostWidget::addItem(const QStringList &item)
58 {
59  QStringList display(item);
60  if (myMode == SetWhen)
61  display.pop_front();
62  QListWidgetItem* wi = new QListWidgetItem(display.join(" "));
63  wi->setData(Qt::UserRole, QVariant::fromValue(item));
64  wi->setFlags(wi->flags() | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
65  myList->addItem(wi);
66  emit dataModified();
67 }
68 
69 void PrePostWidget::setData(const QList<QStringList>& data)
70 {
71  myList->clear();
72  for (QStringList item : data)
73  {
74  if (myMode == SetWhen && !item.empty() && item[0] != "quest")
75  item.push_front("quest");
76  addItem(item);
77  }
78  myOriginal = data;
79 }
80 
82 {
83  QStringList item;
84  item << "quest";
85  addItem(item);
86  myList->setCurrentRow(myList->count() - 1);
87  myList->edit(myList->currentIndex());
88  emit dataModified();
89 }
90 
92 {
93  if (myList->currentRow() == -1)
94  return;
95 
96  delete myList->takeItem(myList->currentRow());
97  emit dataModified();
98 }
99 
101 {
102  if (QMessageBox::question(this, "Confirm reset", "Reset the conditions to their initial values, losing all changes?") != QMessageBox::StandardButton::Yes)
103  return;
105  emit dataModified();
106 }
107 
108 CREPrePostList::CREPrePostList(QWidget* parent, PrePostWidget::Mode mode, const MessageManager* manager) : QDialog(parent) {
109  setModal(true);
110  switch (mode) {
112  setWindowTitle(tr("Message pre-conditions"));
113  break;
115  setWindowTitle(tr("Message post-conditions"));
116  break;
118  setWindowTitle(tr("Step set when conditions are met"));
119  break;
120  }
121 
122  auto layout = new QVBoxLayout(this);
123  myWidget = new PrePostWidget(this, mode, manager);
124  layout->addWidget(myWidget);
125 }
PrePostWidget::onAddCondition
void onAddCondition(bool)
Definition: CREPrePostList.cpp:81
CREPrePostList::CREPrePostList
CREPrePostList(QWidget *parent, PrePostWidget::Mode mode, const MessageManager *manager)
Definition: CREPrePostList.cpp:108
banquet.l
l
Definition: banquet.py:164
layout
Definition: main.cpp:84
PrePostWidget::data
QList< QStringList > data
Definition: CREPrePostList.h:24
PrePostWidget
Definition: CREPrePostList.h:21
CREPrePostSingleConditionDelegate
Definition: CREPrePostConditionDelegate.h:23
CREPrePostList::myWidget
PrePostWidget * myWidget
Definition: CREPrePostList.h:64
mode
linux kernel c mode(defun linux-c-mode() "C mode with adjusted defaults for use with the Linux kernel."(interactive)(c-mode)(c-set-style "K&R")(setq c-basic-offset 8))
PrePostWidget::onReset
void onReset(bool)
Definition: CREPrePostList.cpp:100
PrePostWidget::dataModified
void dataModified()
CREPrePostList.h
PrePostWidget::onDeleteCondition
void onDeleteCondition(bool)
Definition: CREPrePostList.cpp:91
navar-midane_time.data
data
Definition: navar-midane_time.py:11
buttons
TIPS on SURVIVING Crossfire is populated with a wealth of different monsters These monsters can have varying immunities and attack types In some of them can be quite a bit smarter than others It will be important for new players to learn the abilities of different monsters and learn just how much it will take to kill them This section discusses how monsters can interact with players Most monsters in the game are out to mindlessly kill and destroy the players These monsters will help boost a player s after he kills them When fighting a large amount of monsters in a single attempt to find a narrower hallway so that you are not being attacked from all sides Charging into a room full of Beholders for instance would not be open the door and fight them one at a time For there are several maps designed for them Find these areas and clear them out All throughout these a player can find signs and books which they can read by stepping onto them and hitting A to apply the book sign These messages will help the player to learn the system One more always keep an eye on your food If your food drops to your character will soon so BE CAREFUL ! NPCs Non Player Character are special monsters which have intelligence Players may be able to interact with these monsters to help solve puzzles and find items of interest To speak with a monster you suspect to be a simply move to an adjacent square to them and push the double ie Enter your and press< Return > You can also use say if you feel like typing a little extra Other NPCs may not speak to but display intelligence with their movement Some monsters can be and may attack the nearest of your enemies Others can be in that they follow you around and help you in your quest to kill enemies and find treasure SPECIAL ITEMS There are many special items which can be found in of these the most important may be the signs all a player must do is apply the handle In the case of buttons
Definition: survival-guide.txt:57
PrePostWidget::PrePostWidget
PrePostWidget(QWidget *parent, Mode mode, const MessageManager *manager)
Definition: CREPrePostList.cpp:17
PrePostWidget::PreConditions
@ PreConditions
Definition: CREPrePostList.h:27
CREPrePostConditionDelegate.h
PrePostWidget::addItem
void addItem(const QStringList &item)
Definition: CREPrePostList.cpp:57
item
Definition: item.py:1
autojail.value
value
Definition: autojail.py:6
PrePostWidget::myMode
Mode myMode
Definition: CREPrePostList.h:46
reset
Python Guilds Quick outline Add a guild(mapmakers) this is still a problem *after dropping the token to gain access to the stove a woodfloor now appears which is Toolshed Token(found in Guild_HQ) *Note also have multiple gates in place to protect players and items from the mana explosion drop x for Jewelers room *Jewelers room works just need to determine what x is drop x for Thaumaturgy room *Thaumaturgy room works just need to determine what x is drop gold dropping the Firestar named fearless allows access to but I suspect that the drop location of the chest is not as intended because the player is in the way once you enter the chest the exit back to the basement is things such as the message et al reside on teleporters which then transport items to the map as they are when the map is reset(which is normal)
PrePostWidget::setData
void setData(const QList< QStringList > &data)
Definition: CREPrePostList.cpp:69
MessageManager
Definition: MessageManager.h:25
say.item
dictionary item
Definition: say.py:149
connect
Definition: connect.py:1
PrePostWidget::PostConditions
@ PostConditions
Definition: CREPrePostList.h:27
PrePostWidget::SetWhen
@ SetWhen
Definition: CREPrePostList.h:27
PrePostWidget::Mode
Mode
Definition: CREPrePostList.h:27
manager
static AssetsManager * manager
Definition: assets.cpp:60
PrePostWidget::myOriginal
QList< QStringList > myOriginal
Definition: CREPrePostList.h:45
PrePostWidget::myList
QListWidget * myList
Definition: CREPrePostList.h:44