Esempio n. 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!");
}
Esempio n. 2
0
// draw the shield icon and integrity for the escort ship
void hud_escort_show_icon(int x, int y, int index)
{
	if ((Game_mode & GM_MULTIPLAYER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT) && index <= 2)
	{
		hud_escort_show_icon_dogfight(x, y, index);
		return;
	}

	float shields, integrity;
	int screen_integrity, offset;
	char buf[255];

	object* objp = &Objects[Escort_ships[index].objnum];
	ship* sp = &Ships[objp->instance];

	// determine if its "friendly" or not	
	// Goober5000 - changed in favor of just passing the team
	hud_escort_set_gauge_color(index, sp->team);
	/*
	if(Player_ship != NULL){
		hud_escort_set_gauge_color(index, (sp->team == Player_ship->team) ? 1 : 0);
	} else {
		hud_escort_set_gauge_color(index, 1);
	}
	*/

	// draw a 'D' if a ship is disabled
	if ((sp->flags & SF_DISABLED) || (ship_subsys_disrupted(sp, SUBSYSTEM_ENGINE)))
	{
		emp_hud_string(x + current_hud->Escort_status[0], y + current_hud->Escort_status[1], EG_NULL, XSTR("D", 284));
	}

	// print out ship name
	if (sp->callsign_index >= 0)
	{
		hud_stuff_ship_callsign(buf, sp);
	}
	else if (((Iff_info[sp->team].flags & IFFF_WING_NAME_HIDDEN) && (sp->wingnum != -1)) || (sp->flags2 &
																							 SF2_HIDE_SHIP_NAME))
	{
		hud_stuff_ship_class(buf, sp);
	}
	else
	{
		hud_stuff_ship_name(buf, sp);
	}

	gr_force_fit_string(buf, 255, 100);

	emp_hud_string(x + current_hud->Escort_name[0], y + current_hud->Escort_name[1], EG_ESCORT1 + index, buf);

	// show ship integrity
	hud_get_target_strength(objp, &shields, &integrity);
	screen_integrity = fl2i(integrity * 100 + 0.5f);
	offset = 0;
	if (screen_integrity < 100)
	{
		offset = 2;
		if (screen_integrity == 0)
		{
			if (integrity > 0)
			{
				screen_integrity = 1;
			}
		}
	}
	emp_hud_printf(x + current_hud->Escort_integrity[0] + offset, y + current_hud->Escort_integrity[1], EG_NULL, "%d",
		screen_integrity);

	//Let's be nice.
	hud_set_gauge_color(HUD_ESCORT_VIEW);
}