Debian Codegraph @

plugins/dm.objectives/ce/ItemComponentEditor.h

raw
1 #pragma once
2
3 #include "ComponentEditorBase.h"
4 #include "ComponentEditorFactory.h"
5 #include "SpecifierEditCombo.h"
6 #include "../ComponentType.h"
7
8 class wxSpinCtrl;
9
10 namespace objectives
11 {
12
13 namespace ce
14 {
15
16 /**
17 * ComponentEditor subclass for COMP_ITEM component type.
18 *
19 * An ITEM component requires that the player acquires or loses an item.
20 */
21 class ItemComponentEditor :
22 public ComponentEditorBase
23 {
24 // Registration class
25 static struct RegHelper
26 {
27 RegHelper() {
28 ComponentEditorFactory::registerType(
29 objectives::ComponentType::COMP_ITEM().getName(),
30 ComponentEditorPtr(new ItemComponentEditor())
31 );
32 }
33 } regHelper;
34
35 // Component to edit
36 Component* _component;
37
38 // SpecifierEditCombo for the item
39 SpecifierEditCombo* _itemSpec;
40
41 // The spin button for the amount of items
42 wxSpinCtrl* _amount;
43
44 /**
45 * Construct a default ItemComponentEditor.
46 */
47 ItemComponentEditor() :
48 _component(NULL),
49 _amount(NULL)
50 {}
51
52 /**
53 * Construct an ItemComponentEditor with a Component object to display and
54 * edit.
55 *
56 * @param component
57 * The Component to edit.
58 */
59 ItemComponentEditor(wxWindow* parent, Component& component);
60
61 public:
62 /* ComponentEditor implementation */
63
64 ComponentEditorPtr create(wxWindow* parent, Component& component) const
65 {
66 return ComponentEditorPtr(new ItemComponentEditor(parent, component));
67 }
68
69 void writeToComponent() const;
70 };
71
72 } // namespace ce
73
74 } // namespace objectives