File: fredframe.cpp

package info (click to toggle)
freespace2 3.7.0%2Brepack-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 22,848 kB
  • ctags: 41,897
  • sloc: cpp: 369,931; makefile: 1,060; xml: 129; sh: 112
file content (170 lines) | stat: -rw-r--r-- 4,798 bytes parent folder | download
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * Created by Ian "Goober5000" Warfield for the FreeSpace2 Source Code Project.
 * You may not sell or otherwise commercially exploit the source or things you
 * create based on the source.
 */ 



// precompiled header for compilers that support it
#include <wx/wxprec.h>

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
	#include <wx/wx.h>
#endif

#include "fredframe.h"
#include <wx/xrc/xmlres.h>
#include "asteroidfieldeditor.h"
#include "missionspecseditor.h"
#include "debriefingeditor.h"
#include "shieldsystemeditor.h"
#include "commandbriefingeditor.h"
#include "setglobalshipflagseditor.h"
#include "voiceactingmanagereditor.h"
#include "campaigneditor.h"
#include "aboutbox.h"


BEGIN_EVENT_TABLE(FREDFrame, wxFrame)
	// file menu
	EVT_MENU(XRCID("mnuFileNew"), FREDFrame::OnFileNew)
	EVT_MENU(XRCID("mnuFileOpen"), FREDFrame::OnFileOpen)
	EVT_MENU(XRCID("mnuFileSave"), FREDFrame::OnFileSave)
	EVT_MENU(XRCID("mnuFileSaveAs"), FREDFrame::OnFileSaveAs)
	EVT_MENU(XRCID("mnuFileExit"), FREDFrame::OnFileExit)

	// editor menu
	EVT_MENU(XRCID("mnuEditorsAsteroidField"), FREDFrame::OnEditorsAsteroidField)
	EVT_MENU(XRCID("mnuEditorsMissionSpecs"), FREDFrame::OnEditorsMissionSpecs)
	EVT_MENU(XRCID("mnuEditorsDebriefing"), FREDFrame::OnEditorsDebriefing)
	EVT_MENU(XRCID("mnuEditorsShieldSystem"), FREDFrame::OnEditorsShieldSystem)
	EVT_MENU(XRCID("mnuEditorsCommandBriefing"), FREDFrame::OnEditorsCommandBriefing)
	EVT_MENU(XRCID("mnuEditorsSetGlobalShipFlags"), FREDFrame::OnEditorsSetGlobalShipFlags)
	EVT_MENU(XRCID("mnuEditorsVoiceActingManager"), FREDFrame::OnEditorsVoiceActingManager)
	EVT_MENU(XRCID("mnuEditorsCampaign"), FREDFrame::OnEditorsCampaign)

	// help menu
	EVT_MENU(XRCID("mnuHelpAboutFRED2"), FREDFrame::OnHelpAboutFRED2)
END_EVENT_TABLE()


FREDFrame::FREDFrame(const wxChar *title, int xpos, int ypos, int width, int height, wxFREDMission* current_Mission)
	: wxFrame(NULL, -1, title, wxPoint(xpos, ypos), wxSize(width, height))
{
	the_Mission = current_Mission;
	myMenuBar = wxXmlResource::Get()->LoadMenuBar(_T("FREDMenu"));
	SetMenuBar(myMenuBar);

	CreateStatusBar(5);
	SetStatusText(_T("For Help, press F1"), 0);
}

FREDFrame::~FREDFrame()
{}

void FREDFrame::OnFileNew(wxCommandEvent &WXUNUSED(event))
{
	currentFilename = _T("Untitled.fs2");
}

void FREDFrame::OnFileOpen(wxCommandEvent &WXUNUSED(event))
{
	// standard Open File dialog
	wxFileDialog *dlg = new wxFileDialog(this, "Open", "", "",
		_T("FreesSpace2 Missions (*.fs2)|*.fs2|All files (*.*)|*.*"), wxOPEN, wxDefaultPosition);

	// display it and maybe open the file
	if (dlg->ShowModal() == wxID_OK)
	{
		currentFilename = dlg->GetFilename();
    }
}

void FREDFrame::OnFileSave(wxCommandEvent &WXUNUSED(event))
{
	SetStatusText(currentFilename, 0);
}

void FREDFrame::OnFileSaveAs(wxCommandEvent &WXUNUSED(event))
{
	// standard Save File As dialog
	wxFileDialog *dlg = new wxFileDialog(this, "Save As", "", currentFilename,
		_T("FreesSpace2 Missions (*.fs2)|*.fs2|All files (*.*)|*.*"), wxSAVE|wxOVERWRITE_PROMPT, wxDefaultPosition);

	// display it and maybe save the file
	if (dlg->ShowModal() == wxID_OK)
	{
    }
}

void FREDFrame::OnFileExit(wxCommandEvent &WXUNUSED(event))
{
	Close(true);
}

void FREDFrame::OnEditorsAsteroidField(wxCommandEvent &WXUNUSED(event))
{
	dlgAsteroidFieldEditor *dlg = new dlgAsteroidFieldEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsMissionSpecs(wxCommandEvent &WXUNUSED(event))
{
	dlgMissionSpecsEditor *dlg = new dlgMissionSpecsEditor(this, the_Mission);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsDebriefing(wxCommandEvent &WXUNUSED(event))
{
	dlgDebriefingEditor *dlg = new dlgDebriefingEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsShieldSystem(wxCommandEvent &WXUNUSED(event))
{
	dlgShieldSystemEditor *dlg = new dlgShieldSystemEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsCommandBriefing(wxCommandEvent &WXUNUSED(event))
{
	dlgCommandBriefingEditor *dlg = new dlgCommandBriefingEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsSetGlobalShipFlags(wxCommandEvent &WXUNUSED(event))
{
	dlgSetGlobalShipFlagsEditor *dlg = new dlgSetGlobalShipFlagsEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsVoiceActingManager(wxCommandEvent &WXUNUSED(event))
{
	dlgVoiceActingManagerEditor *dlg = new dlgVoiceActingManagerEditor(this);
	dlg->ShowModal();
	dlg->Destroy();
}

void FREDFrame::OnEditorsCampaign(wxCommandEvent &WXUNUSED(event))
{
	frmCampaignEditor *frm = new frmCampaignEditor(this);
	frm->Show();
}

void FREDFrame::OnHelpAboutFRED2(wxCommandEvent &WXUNUSED(event))
{
	dlgAboutBox *dlg = new dlgAboutBox(this);
	dlg->ShowModal();
	dlg->Destroy();
}