/**
 * @brief Opens the UFOpedia for the current selected item/aircraft.
 * @note called by market_openpedia
 */
static void BS_MarketInfoClick_f (void)
{
	const technology_t *tech = RS_GetTechByProvided(Cvar_GetString("mn_item"));

	if (tech)
		UP_OpenWith(tech->id);
}
Beispiel #2
0
/**
 * @todo The "num" value and the link-index will most probably not match.
 */
static void UP_TechTreeClick_f (void)
{
	if (cgi->Cmd_Argc() < 2)
		return;

	int num = atoi(cgi->Cmd_Argv(1));

	if (!upCurrentTech)
		return;

	const requirements_t* required_AND = &upCurrentTech->requireAND;
	if (num < 0 || num >= required_AND->numLinks)
		return;

	/* skip every tech which have not been displayed in techtree */
	for (int i = 0; i <= num; i++) {
		const requirement_t* r = &required_AND->links[i];
		if (r->type != RS_LINK_TECH && r->type != RS_LINK_TECH_NOT)
			num++;
	}

	const technology_t* techRequired = required_AND->links[num].link.tech;
	if (!techRequired)
		cgi->Com_Error(ERR_DROP, "Could not find the tech for '%s'", required_AND->links[num].id);

	/* maybe there is no UFOpaedia chapter assigned - this tech should not be opened at all */
	if (!techRequired->upChapter)
		return;

	UP_OpenWith(techRequired->id);
}
/**
 * @brief Opens the UFOpedia for the current selected building.
 */
static void B_BuildingInfoClick_f (void)
{
	base_t *base = B_GetCurrentSelectedBase();

	if (!base)
		return;

	if (base->buildingCurrent)
		UP_OpenWith(base->buildingCurrent->pedia);
}
Beispiel #4
0
/**
 * @brief Change UFOpaedia article when clicking on the name of associated ammo or weapon
 */
static void UP_ResearchedLinkClick_f (void)
{
	const objDef_t* od;

	if (!upCurrentTech) /* if called from console */
		return;

	od = INVSH_GetItemByID(upCurrentTech->provides);
	assert(od);

	if (od->isAmmo()) {
		const technology_t* t = RS_GetTechForItem(od->weapons[0]);
		if (UP_TechGetsDisplayed(t))
			UP_OpenWith(t->id);
	} else if (od->weapon && od->isReloadable()) {
		const technology_t* t = RS_GetTechForItem(od->ammos[0]);
		if (UP_TechGetsDisplayed(t))
			UP_OpenWith(t->id);
	}
}
/**
 * @brief Call UFOpedia for selected alien.
 */
static void AC_OpenUFOpedia_f (void)
{
	const technology_t *tech;

	/* Can be called from everywhere. */
	if (!aliencontCurrent)
		return;

	tech = aliencontCurrent->tech;

	/* Should never happen. */
	if (!tech) {
		Com_Printf("AC_OpenUFOpedia_f: No tech pointer set!\n");
		return;
	}

	UP_OpenWith(tech->id);
}