Exemple #1
0
void VoiceActingManager::OnGenerateScript()
{
	int i;
	char pathname[256];

	// stuff data to variables
	UpdateData(TRUE);

	// prompt to save script
	CFileDialog dlg(FALSE, "txt", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text files (*.txt)|*.txt||");
	if (dlg.DoModal() != IDOK)
		return;

	CString dlgPathName = dlg.GetPathName( );
	string_copy(pathname, dlgPathName, 256);
	fp = cfopen(pathname, "wt", CFILE_NORMAL);
	if (!fp)
	{
		MessageBox("Can't open file to save.", "Error!");
		return;
	}

	fout("%s\n", Mission_filename);
	fout("%s\n\n", The_mission.name);

	if (m_export_everything || m_export_command_briefings)
	{
		fout("\n\nCommand Briefings\n-----------------\n\n");

		for (i = 0; i < Cmd_briefs[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			cmd_brief_stage *stage = &Cmd_briefs[0].stage[i];
			entry.Replace("$filename", stage->wave_filename);
			entry.Replace("$message", stage->text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");

			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_briefings)
	{
		fout("\n\nBriefings\n---------\n\n");

		for (i = 0; i < Briefings[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			brief_stage *stage = &Briefings[0].stages[i];
			entry.Replace("$filename", stage->voice);
			entry.Replace("$message", stage->new_text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");

			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_debriefings)
	{
		fout("\n\nDebriefings\n-----------\n\n");

		for (i = 0; i < Debriefings[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			debrief_stage *stage = &Debriefings[0].stages[i];
			entry.Replace("$filename", stage->voice);
			entry.Replace("$message", stage->new_text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");
	
			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_messages)
	{
		fout("\n\nMessages\n--------\n\n");

		for (i = 0; i < Num_messages - Num_builtin_messages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			MMessage *message = &Messages[i + Num_builtin_messages];

			// replace file name
			entry.Replace("$filename", message->wave_info.name);

			// determine and replace persona
			entry.Replace("$message", message->message);
			if (message->persona_index >= 0)
				entry.Replace("$persona", Personas[message->persona_index].name);
			else
				entry.Replace("$persona", "<none>");

			// determine sender
			char sender[NAME_LENGTH+1];
			strcpy_s(sender, get_message_sender(message->name));
			int shipnum = ship_name_lookup(sender);

			if (shipnum >= 0)
			{
				ship *shipp = &Ships[shipnum];

				// we may have to use the callsign
				if (*Fred_callsigns[shipnum])
				{
					hud_stuff_ship_callsign(sender, shipp);
				}
				// account for hidden ship names
				else if ( ((Iff_info[shipp->team].flags & IFFF_WING_NAME_HIDDEN) && (shipp->wingnum != -1)) || (shipp->flags2 & SF2_HIDE_SHIP_NAME) )
				{
					hud_stuff_ship_class(sender, shipp);
				}
				// use the regular sender text
				else
				{
					end_string_at_first_hash_symbol(sender);
				}
			}

			// replace sender (but print #Command as Command)
			if (*sender == '#')
				entry.Replace("$sender", &sender[1]);
			else
				entry.Replace("$sender", sender);

			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	cfclose(fp);

	// notify
	MessageBox("Script generation complete.", "Woohoo!");
}
void VoiceActingManager::OnGenerateScript()
{
	int i;
	char pathname[256];

	// stuff data to variables
	UpdateData(TRUE);

	// prompt to save script
	CFileDialog dlg(FALSE, "txt", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Text files (*.txt)|*.txt||");
	if (dlg.DoModal() != IDOK)
		return;

	string_copy(pathname, dlg.GetPathName(), 256);
	fp = cfopen(pathname, "wt", CFILE_NORMAL);
	if (!fp)
	{
		MessageBox("Can't open file to save.", "Error!");
		return;
	}

	fout("%s\n", Mission_filename);
	fout("%s\n\n", The_mission.name);

	if (m_export_everything || m_export_command_briefings)
	{
		fout("\n\nCommand Briefings\n-----------------\n\n");

		for (i = 0; i < Cmd_briefs[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			cmd_brief_stage *stage = &Cmd_briefs[0].stage[i];
			entry.Replace("$filename", stage->wave_filename);
			entry.Replace("$message", stage->text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");

			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_briefings)
	{
		fout("\n\nBriefings\n---------\n\n");

		for (i = 0; i < Briefings[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			brief_stage *stage = &Briefings[0].stages[i];
			entry.Replace("$filename", stage->voice);
			entry.Replace("$message", stage->new_text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");

			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_debriefings)
	{
		fout("\n\nDebriefings\n-----------\n\n");

		for (i = 0; i < Debriefings[0].num_stages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			debrief_stage *stage = &Debriefings[0].stages[i];
			entry.Replace("$filename", stage->voice);
			entry.Replace("$message", stage->new_text);
			entry.Replace("$persona", "<no persona specified>");
			entry.Replace("$sender", "<no sender specified>");
	
			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	if (m_export_everything || m_export_messages)
	{
		fout("\n\nMessages\n--------\n\n");

		for (i = 0; i < Num_messages - Num_builtin_messages; i++)
		{
			CString entry = m_script_entry_format;
			entry.Replace("\r\n", "\n");

			MMessage *message = &Messages[i + Num_builtin_messages];
			entry.Replace("$filename", message->wave_info.name);
			entry.Replace("$message", message->message);
			if (message->persona_index >= 0)
				entry.Replace("$persona", Personas[message->persona_index].name);
			else
				entry.Replace("$persona", "<none>");
			entry.Replace("$sender", get_message_sender(message->name));
	
			fout("%s\n\n\n", (char *) (LPCTSTR) entry);
		}
	}

	cfclose(fp);

	// notify
	MessageBox("Script generation complete.", "Woohoo!");
}