| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "Objective.h" |
| 4 |
#include "ObjectiveEntity.h" |
| 5 |
|
| 6 |
#include "icommandsystem.h" |
| 7 |
#include "wxutil/dialog/DialogBase.h" |
| 8 |
#include "wxutil/WindowPosition.h" |
| 9 |
#include "wxutil/XmlResourceBasedWidget.h" |
| 10 |
|
| 11 |
#include "ObjectiveEntityFinder.h" |
| 12 |
|
| 13 |
#include <map> |
| 14 |
#include <string> |
| 15 |
#include "wxutil/dataview/TreeView.h" |
| 16 |
|
| 17 |
/* FORWARD DECLS */ |
| 18 |
class Entity; |
| 19 |
|
| 20 |
namespace objectives |
| 21 |
{ |
| 22 |
|
| 23 |
/** |
| 24 |
* Dialog for adding and manipulating mission objectives in Dark Mod missions. |
| 25 |
*/ |
| 26 |
class ObjectivesEditor : |
| 27 |
public wxutil::DialogBase, |
| 28 |
private wxutil::XmlResourceBasedWidget |
| 29 |
{ |
| 30 |
private: |
| 31 |
// List of target_addobjectives entities |
| 32 |
ObjectiveEntityListColumns _objEntityColumns; |
| 33 |
wxutil::TreeModel::Ptr _objectiveEntityList; |
| 34 |
wxutil::TreeView* _objectiveEntityView; |
| 35 |
|
| 36 |
// List of actual objectives associated with the selected entity |
| 37 |
ObjectivesListColumns _objectiveColumns; |
| 38 |
wxutil::TreeModel::Ptr _objectiveList; |
| 39 |
wxutil::TreeView* _objectiveView; |
| 40 |
|
| 41 |
// Pointer to the worldspawn entity |
| 42 |
Entity* _worldSpawn; |
| 43 |
|
| 44 |
// Map of ObjectiveEntity objectives, indexed by the name of the world |
| 45 |
// entity |
| 46 |
ObjectiveEntityMap _entities; |
| 47 |
|
| 48 |
// Iterators for current entity and current objective |
| 49 |
ObjectiveEntityMap::iterator _curEntity; |
| 50 |
wxDataViewItem _curObjective; |
| 51 |
|
| 52 |
// The list of objective eclasses (defined in the registry) |
| 53 |
std::vector<std::string> _objectiveEClasses; |
| 54 |
|
| 55 |
wxutil::WindowPosition _windowPosition; |
| 56 |
|
| 57 |
private: |
| 58 |
|
| 59 |
// Constructor creates widgets |
| 60 |
ObjectivesEditor(); |
| 61 |
|
| 62 |
// Widget construction helpers |
| 63 |
void setupEntitiesPanel(); |
| 64 |
void setupObjectivesPanel(); |
| 65 |
|
| 66 |
// callbacks |
| 67 |
void _onCancel(wxCommandEvent& ev); |
| 68 |
void _onOK(wxCommandEvent& ev); |
| 69 |
void _onStartActiveCellToggled(wxDataViewEvent& ev); |
| 70 |
void _onEntitySelectionChanged(wxDataViewEvent& ev); |
| 71 |
void _onObjectiveSelectionChanged(wxDataViewEvent& ev); |
| 72 |
void _onObjectiveActivated(wxDataViewEvent& ev); |
| 73 |
void _onAddEntity(wxCommandEvent& ev); |
| 74 |
void _onDeleteEntity(wxCommandEvent& ev); |
| 75 |
void _onAddObjective(wxCommandEvent& ev); |
| 76 |
void _onEditObjective(wxCommandEvent& ev); |
| 77 |
void _onMoveUpObjective(wxCommandEvent& ev); |
| 78 |
void _onMoveDownObjective(wxCommandEvent& ev); |
| 79 |
void _onDeleteObjective(wxCommandEvent& ev); |
| 80 |
void _onClearObjectives(wxCommandEvent& ev); |
| 81 |
void _onEditLogic(wxCommandEvent& ev); |
| 82 |
void _onEditObjConditions(wxCommandEvent& ev); |
| 83 |
|
| 84 |
void handleEntitySelectionChange(); |
| 85 |
void doEditObjective(); |
| 86 |
|
| 87 |
// Populate the dialog widgets with appropriate state from the map |
| 88 |
void populateWidgets(); |
| 89 |
void populateActiveAtStart(); |
| 90 |
|
| 91 |
// Refresh the objectives list from the currently-selected ObjectiveEntity |
| 92 |
void refreshObjectivesList(); |
| 93 |
|
| 94 |
// Return the currently-selected objective |
| 95 |
Objective& getCurrentObjective(); |
| 96 |
|
| 97 |
// Clears the internal containers |
| 98 |
void clear(); |
| 99 |
|
| 100 |
// Select the given objective |
| 101 |
void selectObjectiveByIndex(int index); |
| 102 |
|
| 103 |
void updateObjectiveButtonPanel(); |
| 104 |
void updateEditorButtonPanel(); |
| 105 |
|
| 106 |
public: |
| 107 |
// Override DialogBase::ShowModal |
| 108 |
int ShowModal(); |
| 109 |
|
| 110 |
/** |
| 111 |
* Static method to display the Objectives Editor dialog. |
| 112 |
*/ |
| 113 |
static void DisplayDialog(const cmd::ArgumentList& args); |
| 114 |
}; |
| 115 |
|
| 116 |
} |