Skip to content

Commit

Permalink
Merge pull request scp-fs2open#6566 from Goober5000/substitute_main_h…
Browse files Browse the repository at this point in the history
…all_fred

add Substitute Main Hall field to FRED campaign editor
  • Loading branch information
Goober5000 authored Feb 4, 2025
2 parents 5f73220 + c1c2079 commit 417ba3b
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 42 deletions.
21 changes: 14 additions & 7 deletions code/mission/missioncampaign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,21 @@ int mission_campaign_load(const char* filename, const char* full_path, player* p
}

// Goober5000 - substitute main hall (like substitute music)
cm->substitute_main_hall = "";
if (optional_string("+Substitute Main Hall:")) {
stuff_string(temp, F_RAW, 32);

// see if this main hall exists
main_hall_defines *mhd = main_hall_get_pointer(temp);
if (mhd != NULL) {
cm->main_hall = temp;
} else {
mprintf(("Substitute main hall '%s' not found\n", temp));
cm->substitute_main_hall = temp;

// if we're running FRED, keep the halls separate (so we can save the campaign file),
// but if we're running FS, replace the main hall with the substitute right now
if (!Fred_running) {
// see if this main hall exists
main_hall_defines* mhd = main_hall_get_pointer(temp);
if (mhd != nullptr) {
cm->main_hall = temp;
} else {
mprintf(("Substitute main hall '%s' not found\n", temp));
}
}
}

Expand Down Expand Up @@ -1228,6 +1234,7 @@ void mission_campaign_clear()
Campaign.missions[i].pos = 0;
Campaign.missions[i].flags = 0;
Campaign.missions[i].main_hall = "";
Campaign.missions[i].substitute_main_hall = "";
Campaign.missions[i].debrief_persona_index = 0;

Campaign.missions[i].stats.init();
Expand Down
1 change: 1 addition & 0 deletions code/mission/missioncampaign.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class cmission
int pos; // what x position on level it's on (Fred)
int flags;
SCP_string main_hall; // which main hall the player is in - converted to SCP_string by CommanderDJ
SCP_string substitute_main_hall; // really only needed for FRED
ubyte debrief_persona_index; // which persona is used for ranks/badges - Goober5000
scoring_struct stats;
};
Expand Down
41 changes: 36 additions & 5 deletions fred2/campaigneditordlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void campaign_editor::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_NUM_PLAYERS, m_num_players);
DDX_Text(pDX, IDC_DESC2, m_desc);
DDV_MaxChars(pDX, m_desc, MISSION_DESC_LENGTH - 1);
DDX_Text(pDX, IDC_MISSISON_LOOP_DESC, m_branch_desc);
DDX_Text(pDX, IDC_MISSION_LOOP_DESC, m_branch_desc);
DDV_MaxChars(pDX, m_branch_desc, MISSION_DESC_LENGTH - 1);
DDX_Text(pDX, IDC_LOOP_BRIEF_ANIM, m_branch_brief_anim);
DDX_Text(pDX, IDC_LOOP_BRIEF_SOUND, m_branch_brief_sound);
Expand All @@ -100,6 +100,7 @@ BEGIN_MESSAGE_MAP(campaign_editor, CFormView)
ON_BN_CLICKED(IDC_LOOP_BRIEF_BROWSE, OnBrowseLoopAni)
ON_BN_CLICKED(IDC_LOOP_BRIEF_SOUND_BROWSE, OnBrowseLoopSound)
ON_EN_CHANGE(IDC_MAIN_HALL, OnChangeMainHall)
ON_EN_CHANGE(IDC_SUBSTITUTE_MAIN_HALL, OnChangeSubstituteMainHall)
ON_EN_CHANGE(IDC_DEBRIEFING_PERSONA, OnChangeDebriefingPersona)
ON_BN_CLICKED(IDC_CUSTOM_TECH_DB, OnCustomTechDB)
//}}AFX_MSG_MAP
Expand Down Expand Up @@ -169,9 +170,23 @@ BOOL campaign_editor::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWOR
}
}

//create tool tip controls
m_SubstituteMainHallToolTip = new CToolTipCtrl();
m_SubstituteMainHallToolTip->Create(this);

CWnd* pWnd = GetDlgItem(IDC_SUBSTITUTE_MAIN_HALL);
m_SubstituteMainHallToolTip->AddTool(pWnd, "Main hall to be used if optional main hall pack is present");
m_SubstituteMainHallToolTip->Activate(TRUE);

return r;
}

BOOL campaign_editor::PreTranslateMessage(MSG* pMsg)
{
m_SubstituteMainHallToolTip->RelayEvent(pMsg);
return CFormView::PreTranslateMessage(pMsg);
}

void campaign_editor::load_campaign(const char *filename, const char *full_path)
{
Cur_campaign_mission = Cur_campaign_link = -1;
Expand Down Expand Up @@ -263,11 +278,12 @@ void campaign_editor::initialize( bool init_files, bool clear_path )

void campaign_editor::mission_selected(int num)
{
CEdit *bc_dialog, *bc_hall, *bc_persona;
CEdit *bc_dialog, *bc_hall, *bc_substitute_hall, *bc_persona;
char personatext[10];

bc_dialog = (CEdit *) GetDlgItem(IDC_BRIEFING_CUTSCENE);
bc_hall = (CEdit *) GetDlgItem(IDC_MAIN_HALL);
bc_substitute_hall = (CEdit *) GetDlgItem(IDC_SUBSTITUTE_MAIN_HALL);
bc_persona = (CEdit *) GetDlgItem(IDC_DEBRIEFING_PERSONA);

// clear out the text for the briefing cutscene, and put in new text if specified
Expand All @@ -277,6 +293,7 @@ void campaign_editor::mission_selected(int num)

// new main hall stuff
bc_hall->SetWindowText(Campaign.missions[num].main_hall.c_str());
bc_substitute_hall->SetWindowText(Campaign.missions[num].substitute_main_hall.c_str());

// new debriefing persona stuff
sprintf(personatext, "%d", Campaign.missions[num].debrief_persona_index);
Expand Down Expand Up @@ -355,14 +372,16 @@ void campaign_editor::load_tree(int save_first)
GetDlgItem(IDC_SEXP_TREE)->EnableWindow(FALSE);
GetDlgItem(IDC_BRIEFING_CUTSCENE)->EnableWindow(FALSE);
GetDlgItem(IDC_MAIN_HALL)->EnableWindow(FALSE);
GetDlgItem(IDC_SUBSTITUTE_MAIN_HALL)->EnableWindow(FALSE);
return;
}

GetDlgItem(IDC_SEXP_TREE)->EnableWindow(TRUE);
GetDlgItem(IDC_BRIEFING_CUTSCENE)->EnableWindow(TRUE);
GetDlgItem(IDC_MAIN_HALL)->EnableWindow(TRUE);
GetDlgItem(IDC_SUBSTITUTE_MAIN_HALL)->EnableWindow(TRUE);

GetDlgItem(IDC_MISSISON_LOOP_DESC)->EnableWindow(FALSE);
GetDlgItem(IDC_MISSION_LOOP_DESC)->EnableWindow(FALSE);
GetDlgItem(IDC_LOOP_BRIEF_ANIM)->EnableWindow(FALSE);
GetDlgItem(IDC_LOOP_BRIEF_SOUND)->EnableWindow(FALSE);
GetDlgItem(IDC_LOOP_BRIEF_BROWSE)->EnableWindow(FALSE);
Expand Down Expand Up @@ -725,7 +744,7 @@ void campaign_editor::update_loop_desc_window()
}

// maybe enable description window
GetDlgItem(IDC_MISSISON_LOOP_DESC)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_MISSION_LOOP_DESC)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_ANIM)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_SOUND)->EnableWindow(enable_branch_desc_window);
GetDlgItem(IDC_LOOP_BRIEF_BROWSE)->EnableWindow(enable_branch_desc_window);
Expand Down Expand Up @@ -879,7 +898,7 @@ void campaign_editor::OnBrowseLoopSound()
}
}

void campaign_editor::OnChangeMainHall()
void campaign_editor::OnChangeMainHall()
{
CString str;
UpdateData(TRUE);
Expand All @@ -891,6 +910,18 @@ void campaign_editor::OnChangeMainHall()
}
}

void campaign_editor::OnChangeSubstituteMainHall()
{
CString str;
UpdateData(TRUE);

if (Cur_campaign_mission >= 0)
{
GetDlgItem(IDC_SUBSTITUTE_MAIN_HALL)->GetWindowText(str);
Campaign.missions[Cur_campaign_mission].substitute_main_hall = SCP_string((LPCTSTR)(str));
}
}

void campaign_editor::OnChangeDebriefingPersona()
{
CString str;
Expand Down
4 changes: 4 additions & 0 deletions fred2/campaigneditordlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class campaign_editor : public CFormView
//{{AFX_VIRTUAL(campaign_editor)
public:
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
Expand All @@ -91,6 +92,8 @@ class campaign_editor : public CFormView
virtual void Dump(CDumpContext& dc) const;
#endif

CToolTipCtrl* m_SubstituteMainHallToolTip;

// Generated message map functions
//{{AFX_MSG(campaign_editor)
afx_msg void OnLoad();
Expand All @@ -109,6 +112,7 @@ class campaign_editor : public CFormView
afx_msg void OnBrowseLoopAni();
afx_msg void OnBrowseLoopSound();
afx_msg void OnChangeMainHall();
afx_msg void OnChangeSubstituteMainHall();
afx_msg void OnChangeDebriefingPersona();
afx_msg void OnCustomTechDB();
//}}AFX_MSG
Expand Down
2 changes: 1 addition & 1 deletion fred2/campaigntreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void campaign_tree_view::OnLButtonDown(UINT nFlags, CPoint point)
// HACK!! UPDATE mission loop/fork desc before changing selections
// save mission loop/fork desc
char buffer[MISSION_DESC_LENGTH];
box = (CEdit *) Campaign_tree_formp->GetDlgItem(IDC_MISSISON_LOOP_DESC);
box = (CEdit *) Campaign_tree_formp->GetDlgItem(IDC_MISSION_LOOP_DESC);
box->GetWindowText(buffer, MISSION_DESC_LENGTH);
if (strlen(buffer)) {
if (Links[Cur_campaign_link].mission_branch_txt) {
Expand Down
56 changes: 29 additions & 27 deletions fred2/fred.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1728,43 +1728,45 @@ IDD_CAMPAIGN DIALOGEX 0, 0, 270, 441
STYLE DS_SETFONT | WS_CHILD
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
LTEXT "Available missions",IDC_STATIC,7,7,58,8
LISTBOX IDC_FILELIST,7,17,254,77,LBS_SORT | LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | WS_HSCROLL | WS_TABSTOP
LTEXT "Campaign name",IDC_STATIC,7,99,52,8
EDITTEXT IDC_NAME,63,98,100,12,ES_AUTOHSCROLL
LTEXT "Type",IDC_STATIC,171,99,17,8
COMBOBOX IDC_CAMPAIGN_TYPE,193,98,68,116,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Campaign description",IDC_STATIC,7,113,68,8
EDITTEXT IDC_DESC2,7,123,254,38,ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL
CONTROL "Reset tech db at start of campaign",IDC_CUSTOM_TECH_DB,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,136,112,122,9
GROUPBOX "Mission options",IDC_MISSION_OPTIONS,7,165,254,58
LTEXT "Briefing cutscene",IDC_STATIC,13,176,56,8
EDITTEXT IDC_BRIEFING_CUTSCENE,73,175,66,12,ES_AUTOHSCROLL
EDITTEXT IDC_MAIN_HALL,73,190,49,12,ES_AUTOHSCROLL
LTEXT "Debriefing persona index",IDC_STATIC,148,176,79,8
EDITTEXT IDC_DEBRIEFING_PERSONA,231,175,21,12,ES_NUMBER,WS_EX_RIGHT
CONTROL "Tree1",IDC_SEXP_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,224,188,111,WS_EX_CLIENTEDGE
PUSHBUTTON "Move Up",IDC_MOVE_UP,206,225,53,14,BS_CENTER,WS_EX_STATICEDGE
PUSHBUTTON "Move Down",IDC_MOVE_DOWN,206,242,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Toggle Loop",IDC_TOGGLE_LOOP,206,259,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Realign Tree",IDC_ALIGN,210,286,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Load Mission",ID_LOAD,210,303,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Close",ID_CPGN_CLOSE,210,320,53,14,0,WS_EX_STATICEDGE
EDITTEXT IDC_HELP_BOX,7,339,255,24,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_MISSISON_LOOP_DESC,7,377,253,24,ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL
EDITTEXT IDC_LOOP_BRIEF_ANIM,69,406,100,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOOP_BRIEF_BROWSE,175,406,53,13,0,WS_EX_STATICEDGE
EDITTEXT IDC_LOOP_BRIEF_SOUND,69,422,100,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOOP_BRIEF_SOUND_BROWSE,175,422,53,13,0,WS_EX_STATICEDGE
LTEXT "Available missions",IDC_STATIC,7,7,58,8
LTEXT "Campaign name",IDC_STATIC,7,99,52,8
LTEXT "Type",IDC_STATIC,171,99,17,8
LTEXT "Branches",IDC_STATIC,7,214,31,8
LTEXT "Briefing cutscene",IDC_STATIC,13,176,56,8
LTEXT "Main hall name",IDC_STATIC,14,192,48,8
EDITTEXT IDC_MAIN_HALL,73,190,66,12,ES_AUTOHSCROLL
LTEXT "Substitute",IDC_STATIC | UDS_ALIGNRIGHT,14,207,58,8
EDITTEXT IDC_SUBSTITUTE_MAIN_HALL,73,205,66,12,ES_AUTOHSCROLL
LTEXT "Branches",IDC_STATIC,7,229,31,8
CONTROL "Tree1",IDC_SEXP_TREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,239,188,111,WS_EX_CLIENTEDGE
GROUPBOX "Branch Options",IDC_STATIC,202,229,61,64
PUSHBUTTON "Move Up",IDC_MOVE_UP,206,239,53,14,BS_CENTER,WS_EX_STATICEDGE
PUSHBUTTON "Move Down",IDC_MOVE_DOWN,206,257,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Toggle Loop",IDC_TOGGLE_LOOP,206,274,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Realign Tree",IDC_ALIGN,210,301,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Load Mission",ID_LOAD,210,318,53,14,0,WS_EX_STATICEDGE
PUSHBUTTON "Close",ID_CPGN_CLOSE,210,335,53,14,0,WS_EX_STATICEDGE
EDITTEXT IDC_HELP_BOX,7,354,255,24,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP,WS_EX_TRANSPARENT
LTEXT "Mission loop description",IDC_STATIC,7,382,76,8
EDITTEXT IDC_MISSION_LOOP_DESC,7,392,253,24,ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL
LTEXT "Loop brief anim",IDC_STATIC,13,423,49,8
EDITTEXT IDC_LOOP_BRIEF_ANIM,69,421,100,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOOP_BRIEF_BROWSE,175,421,53,13,0,WS_EX_STATICEDGE
LTEXT "Loop brief voice",IDC_STATIC,13,438,52,8
EDITTEXT IDC_LOOP_BRIEF_SOUND,69,437,100,12,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOOP_BRIEF_SOUND_BROWSE,175,437,53,13,0,WS_EX_STATICEDGE
LTEXT "Number of Players:",IDC_PLAYERS_LABEL,176,7,60,8
LTEXT "Static",IDC_NUM_PLAYERS,239,7,19,8,0,WS_EX_TRANSPARENT
LTEXT "Campaign description",IDC_STATIC,7,113,68,8
GROUPBOX "Branch Options",IDC_STATIC,202,214,61,64
LTEXT "Mission loop description",IDC_STATIC,7,367,76,8
LTEXT "Loop brief anim",IDC_STATIC,13,408,49,8
LTEXT "Loop brief voice",IDC_STATIC,13,423,52,8
LTEXT "Main hall name",IDC_MAINHALL_LABEL,14,192,48,8
GROUPBOX "Mission options",IDC_MISSION_OPTIONS,7,165,254,43
LTEXT "Debriefing persona index",IDC_STATIC,148,176,79,8
END

IDD_TEXT_VIEW DIALOGEX 0, 0, 299, 124
Expand Down
13 changes: 13 additions & 0 deletions fred2/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,19 @@ int CFred_mission_save::save_campaign_file(const char *pathname)
fout(" %d", flags_to_save | ((Campaign.missions[m].main_hall != "") ? CMISSION_FLAG_BASTION : 0));
}

if (!Campaign.missions[m].substitute_main_hall.empty()) {
fso_comment_push(";;FSO 3.7.2;;");
if (optional_string_fred("+Substitute Main Hall:")) {
parse_comments(1);
fout(" %s", Campaign.missions[m].substitute_main_hall.c_str());
} else {
fout_version("\n+Substitute Main Hall: %s", Campaign.missions[m].substitute_main_hall.c_str());
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.7.2;; +Substitute Main Hall:");
}

if (Campaign.missions[m].debrief_persona_index > 0) {
fso_comment_push(";;FSO 3.6.8;;");
if (optional_string_fred("+Debriefing Persona Index:")) {
Expand Down
4 changes: 2 additions & 2 deletions fred2/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@
#define IDC_SUBSPACE 1493
#define IDC_UPDATE 1494
#define IDC_DESC 1495
#define IDC_MISSISON_LOOP_DESC 1495
#define IDC_MISSION_LOOP_DESC 1495
#define IDC_NO_PROMOTION 1496
#define IDC_DESC2 1496
#define ID_CANCEL 1497
Expand Down Expand Up @@ -1039,7 +1039,7 @@
#define IDC_BEAM_FREE_ALL_BY_DEFAULT 1544
#define IDC_NEB2_TOGGLE_TRAILS 1544
#define IDC_ST_OVERRIDE_NEB 1545
#define IDC_MAINHALL_LABEL 1545
#define IDC_SUBSTITUTE_MAIN_HALL 1545
#define IDC_3D_WARP_EFFECT 1545
#define IDC_NEB2_FOG_R 1545
#define IDC_MISSION_OPTIONS 1546
Expand Down

0 comments on commit 417ba3b

Please sign in to comment.