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 #include "global.h"
18 #include "map.h"
19 
21 
22 class ResourcesManager;
23 class CREMapInformation;
24 
25 class RegionWrapper : public AssetTWrapper<region> {
26  Q_OBJECT
27  Q_PROPERTY(QString shortName READ shortName)
28  Q_PROPERTY(QString longName READ longName)
29  Q_PROPERTY(QString message READ message)
30  Q_PROPERTY(QString jailPath READ jailPath)
31  Q_PROPERTY(int jailX READ jailX);
32  Q_PROPERTY(int jailY READ jailY);
33 
34 public:
35  RegionWrapper(AssetWrapper *parent, region *reg, ResourcesManager *resources);
36 
37  virtual QString displayName() const override { return myWrappedItem->longname; }
38  virtual int childrenCount() const override;
39  virtual AssetWrapper *child(int index) override;
40  virtual int childIndex(AssetWrapper *child) override;
41 
42  virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override;
43 
44  QString shortName() const { return myWrappedItem->name; }
45  QString longName() const { return get_region_longname(myWrappedItem); }
46  QString message() const { return get_region_msg(myWrappedItem); }
47  QString jailPath() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jailmap : ""; }
48  int jailX() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jailx : 0; }
49  int jailY() const { auto reg = myWrappedItem; while (reg && !reg->jailmap) { reg = reg->parent; } return reg ? reg->jaily : 0; }
50 
51 protected:
53  QList<CREMapInformation *> myMaps;
54 
55 protected slots:
57 };
58 
59 #endif /* REGION_WRAPPER_H */
AssetTWrapper< region >::myWrappedItem
region * myWrappedItem
Definition: AssetWrapper.h:104
global.h
RegionWrapper
Definition: RegionWrapper.h:25
AssetWrapper.h
ResourcesManager
Definition: ResourcesManager.h:80
AssetWrapper::PossibleUse
PossibleUse
Definition: AssetWrapper.h:32
RegionWrapper::shortName
QString shortName() const
Definition: RegionWrapper.h:44
RegionWrapper::jailPath
QString jailPath
Definition: RegionWrapper.h:30
RegionWrapper::message
QString message() const
Definition: RegionWrapper.h:46
region::name
char * name
Definition: map.h:273
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:210
RegionWrapper::shortName
QString shortName
Definition: RegionWrapper.h:27
RegionWrapper::mapAdded
void mapAdded(CREMapInformation *map)
Definition: RegionWrapper.cpp:50
region::longname
char * longname
Definition: map.h:279
RegionWrapper::longName
QString longName
Definition: RegionWrapper.h:28
CREMapInformation
Definition: CREMapInformation.h:27
RegionWrapper::childIndex
virtual int childIndex(AssetWrapper *child) override
Definition: RegionWrapper.cpp:32
RegionWrapper::message
QString message
Definition: RegionWrapper.h:29
disinfect.map
map
Definition: disinfect.py:4
AssetWrapper
Definition: AssetWrapper.h:25
region::parent
region * parent
Definition: map.h:274
get_region_msg
const char * get_region_msg(const region *r)
Definition: region.cpp:231
region::jailmap
char * jailmap
Definition: map.h:285
RegionWrapper::myMaps
QList< CREMapInformation * > myMaps
Definition: RegionWrapper.h:53
RegionWrapper::displayName
virtual QString displayName() const override
Definition: RegionWrapper.h:37
RegionWrapper::jailY
int jailY
Definition: RegionWrapper.h:31
map.h
AssetWrapperPanel.h
RegionWrapper::jailPath
QString jailPath() const
Definition: RegionWrapper.h:47
region
Definition: map.h:272
RegionWrapper::longName
QString longName() const
Definition: RegionWrapper.h:45
RegionWrapper::jailY
int jailY() const
Definition: RegionWrapper.h:49
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:52
RegionWrapper::jailX
int jailX() const
Definition: RegionWrapper.h:48
RegionWrapper::uses
virtual PossibleUse uses(const AssetWrapper *asset, std::string &) const override
Definition: RegionWrapper.cpp:41
RegionWrapper::jailX
int jailX
Definition: RegionWrapper.h:31
region::jaily
int16_t jaily
Definition: map.h:286
region::jailx
int16_t jailx
Definition: map.h:286
AssetTWrapper
Definition: AssetWrapper.h:94