Crossfire Server, Trunk
RegionWrapper.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 REGION_WRAPPER_H
14 #define REGION_WRAPPER_H
15 
16 #include "assets/AssetWrapper.h"
17 extern "C" {
18 #include "global.h"
19 #include "map.h"
20 }
21 
23 
24 class ResourcesManager;
25 class CREMapInformation;
26 
27 class RegionWrapper : public AssetTWrapper<region> {
28  Q_OBJECT
29  Q_PROPERTY(QString shortName READ shortName)
30  Q_PROPERTY(QString longName READ longName)
31  Q_PROPERTY(QString message READ message)
32  Q_PROPERTY(QString jailPath READ jailPath)
33  Q_PROPERTY(int jailX READ jailX);
34  Q_PROPERTY(int jailY READ jailY);
35 
36 public:
37  RegionWrapper(AssetWrapper *parent, region *reg, ResourcesManager *resources);
38 
39  virtual QString displayName() const override { return myWrappedItem->longname; }
40  virtual int childrenCount() const override;
41  virtual AssetWrapper *child(int index) override;
42  virtual int childIndex(AssetWrapper *child) override;
43 
44  virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override;
45 
46  QString shortName() const { return myWrappedItem->name; }
47  QString longName() const { return get_region_longname(myWrappedItem); }
48  QString message() const { return get_region_msg(myWrappedItem); }
49  QString jailPath() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jailmap : ""; }
50  int jailX() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jailx : 0; }
51  int jailY() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jaily : 0; }
52 
53 protected:
55  QList<CREMapInformation *> myMaps;
56 
57 protected slots:
59 };
60 
61 #endif /* REGION_WRAPPER_H */
AssetTWrapper< region >::myWrappedItem
region * myWrappedItem
Definition: AssetWrapper.h:97
global.h
RegionWrapper
Definition: RegionWrapper.h:27
AssetWrapper.h
ResourcesManager
Definition: ResourcesManager.h:79
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:28
RegionWrapper::shortName
QString shortName() const
Definition: RegionWrapper.h:46
regiondef::jailx
int16_t jailx
Definition: map.h:290
RegionWrapper::jailPath
QString jailPath
Definition: RegionWrapper.h:32
RegionWrapper::message
QString message() const
Definition: RegionWrapper.h:48
RegionWrapper::child
virtual AssetWrapper * child(int index) override
Definition: RegionWrapper.cpp:28
get_region_longname
const char * get_region_longname(const region *r)
Definition: region.cpp:216
RegionWrapper::shortName
QString shortName
Definition: RegionWrapper.h:29
RegionWrapper::mapAdded
void mapAdded(CREMapInformation *map)
Definition: RegionWrapper.cpp:50
RegionWrapper::longName
QString longName
Definition: RegionWrapper.h:30
CREMapInformation
Definition: CREMapInformation.h:27
RegionWrapper::childIndex
virtual int childIndex(AssetWrapper *child) override
Definition: RegionWrapper.cpp:32
RegionWrapper::message
QString message
Definition: RegionWrapper.h:31
disinfect.map
map
Definition: disinfect.py:4
regiondef::jaily
int16_t jaily
Definition: map.h:290
AssetWrapper
Definition: AssetWrapper.h:22
get_region_msg
const char * get_region_msg(const region *r)
Definition: region.cpp:237
regiondef::name
char * name
Definition: map.h:277
RegionWrapper::myMaps
QList< CREMapInformation * > myMaps
Definition: RegionWrapper.h:55
RegionWrapper::displayName
virtual QString displayName() const override
Definition: RegionWrapper.h:39
RegionWrapper::jailY
int jailY
Definition: RegionWrapper.h:33
map.h
AssetWrapperPanel.h
RegionWrapper::jailPath
QString jailPath() const
Definition: RegionWrapper.h:49
regiondef::parent
struct regiondef * parent
Definition: map.h:278
regiondef::jailmap
char * jailmap
Definition: map.h:289
RegionWrapper::longName
QString longName() const
Definition: RegionWrapper.h:47
RegionWrapper::jailY
int jailY() const
Definition: RegionWrapper.h:51
npc_dialog.index
int index
Definition: npc_dialog.py:102
RegionWrapper::childrenCount
virtual int childrenCount() const override
Definition: RegionWrapper.cpp:24
RegionWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: RegionWrapper.h:54
RegionWrapper::jailX
int jailX() const
Definition: RegionWrapper.h:50
RegionWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: RegionWrapper.cpp:41
RegionWrapper::jailX
int jailX
Definition: RegionWrapper.h:33
regiondef::longname
char * longname
Definition: map.h:283
AssetTWrapper
Definition: AssetWrapper.h:87
regiondef
Definition: map.h:275