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