]> icculus.org git repositories - taylor/freespace2.git/blob - include/campaigntreeview.h
Initial revision
[taylor/freespace2.git] / include / campaigntreeview.h
1 // CampaignTreeView.h : header file
2 //
3
4 #include "missioncampaign.h"
5
6 #define MAX_LEVELS      100
7 #define MAX_CAMPAIGN_TREE_LINKS 300
8
9 typedef struct campaign_tree_element {
10         int from_links; // total branches from this mission
11         int to_links;           // total branches that lead to this mission
12         CRect box;                      // coordinates of drawn box
13 } campaign_tree_element;
14
15 typedef struct campaign_tree_link {
16         int from;       // index of source mission
17         int to;         // index of mission link leads to
18         int sexp;       // sexp index of condition that allows this branch
19         int node;       // node tracker when link is in sexp tree window
20         int from_pos;   // from link drawing offset
21         int to_pos;     // to link drawing offset
22         bool mission_loop;      // whether link leads to mission loop
23         char *mission_loop_txt; // text describing mission loop
24         char *mission_loop_brief_anim;  // filename of anim to play in the brief
25         char *mission_loop_brief_sound; // filename of anim to play in the brief
26         CPoint p1;      // coordinates of line last draw for link, from p1 to p2
27         CPoint p2;
28 } campaign_tree_link;
29
30 extern int Total_links;
31 extern int Level_counts[MAX_LEVELS];
32 extern int Sorted[MAX_CAMPAIGN_MISSIONS];
33 extern campaign_tree_element Elements[MAX_CAMPAIGN_MISSIONS];
34 extern campaign_tree_link Links[MAX_CAMPAIGN_TREE_LINKS];
35
36 /////////////////////////////////////////////////////////////////////////////
37 // campaign_tree_view view
38
39 class campaign_tree_view : public CScrollView
40 {
41 protected:
42         campaign_tree_view();           // protected constructor used by dynamic creation
43         DECLARE_DYNCREATE(campaign_tree_view)
44
45 // Attributes
46 public:
47         void drop_mission(int m, CPoint point);
48         int add_link(int from, int to);
49         void remove_mission(int m);
50         void delete_link(int num);
51         int get_root_mission();
52         void horizontally_align_mission(int num, int dir);
53         void correct_position(int num);
54         void free_links();
55         void sort_elements();
56         int query_alternate_pos(const CPoint& p);
57         int query_pos(const CPoint& p);
58         int query_level(const CPoint& p);
59         void sort_links();
60         void realign_tree();
61         int total_levels;
62         int total_width;
63         campaign_tree_link *first_link;
64
65 // Operations
66 public:
67         void construct_tree();
68         void initialize();
69
70 // Overrides
71         // ClassWizard generated virtual function overrides
72         //{{AFX_VIRTUAL(campaign_tree_view)
73         public:
74         virtual void OnInitialUpdate();
75         protected:
76         virtual void OnDraw(CDC* pDC);      // overridden to draw this view
77         //}}AFX_VIRTUAL
78
79 // Implementation
80 protected:
81         virtual ~campaign_tree_view();
82 #ifdef _DEBUG
83         virtual void AssertValid() const;
84         virtual void Dump(CDumpContext& dc) const;
85 #endif
86
87         // Generated message map functions
88 protected:
89         //{{AFX_MSG(campaign_tree_view)
90         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
91         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
92         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
93         afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
94         afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
95         afx_msg void OnRemoveMission();
96         afx_msg void OnDeleteRow();
97         afx_msg void OnInsertRow();
98         afx_msg void OnAddRepeat();
99         afx_msg void OnEndOfCampaign();
100         //}}AFX_MSG
101         DECLARE_MESSAGE_MAP()
102 };
103
104 /////////////////////////////////////////////////////////////////////////////
105
106 extern campaign_tree_view *Campaign_tree_viewp;
107