47#define MAX_UPTEXT 4096
92 if (newDisplay < UFOPEDIA_DISPLAYEND && newDisplay >= 0)
95 cgi->Com_Printf(
"Error in UP_ChangeDisplay (%i)\n", newDisplay);
97 cgi->Cvar_SetValue(
"mn_uppreavailable", 0);
110 cgi->Cvar_Set(
"mn_upmodel_top",
"");
111 cgi->Cvar_Set(
"mn_upmodel_bottom",
"");
112 cgi->Cvar_Set(
"mn_upimage_top",
"base/empty");
113 cgi->UI_ExecuteConfunc(
"mn_up_empty");
114 cgi->Cvar_Set(
"mn_uptitle",
_(
"UFOpaedia"));
117 cgi->Cvar_Set(
"mn_upmodel_top",
"");
118 cgi->Cvar_Set(
"mn_upmodel_bottom",
"");
119 cgi->Cvar_Set(
"mn_upimage_top",
"base/empty");
122 cgi->UI_ExecuteConfunc(
"mn_up_article");
137 return _(
"Cruising speed");
139 return _(
"Maximum speed");
145 return _(
"Hull strength");
147 return _(
"Accuracy");
149 return _(
"Fuel size");
151 return _(
"Weapon range");
153 return _(
"Antimatter need");
171 upTechtree =
nullptr;
174 cgi->LIST_AddString(&upTechtree,
_(
"No requirements"));
181 cgi->Com_Error(
ERR_DROP,
"Could not find the tech for '%s'", req->
id);
188 cgi->LIST_AddString(&upTechtree,
_(techRequired->
name));
194 cgi->Cvar_Set(
"mn_uprequirement",
"1");
215 cgi->Cvar_Set(
"mn_upmetadata",
"1");
230 static char itemText[1024];
234 cgi->INV_ItemDescription(
nullptr);
239 cgi->Cvar_Set(
"mn_item",
"");
240 cgi->Cvar_Set(
"mn_itemname",
"");
241 cgi->Cvar_Set(
"mn_upmodel_top",
"");
248 cgi->Cvar_Set(
"mn_item",
"%s", item->
id);
249 cgi->Cvar_Set(
"mn_itemname",
"%s",
_(item->
name));
251 cgi->Cvar_Set(
"mn_upmodel_top",
"%s", tech->
mdl);
253 cgi->Cvar_Set(
"mn_upmodel_top",
"");
265 Q_strcat(itemText,
sizeof(itemText),
_(
"Weapon for air defence system\n"));
277 if (item->
ammos[
i]->isVirtual) {
285 Q_strcat(itemText,
sizeof(itemText),
_(
"Ammo:\t%i\n"), ammo->
ammo);
310 Q_strcat(itemText,
sizeof(itemText),
_(
"Unknown - need to research this"));
313 cgi->Cvar_Set(
"mn_upmetadata",
"1");
325 cgi->INV_ItemDescription(
nullptr);
357 if (aircraft->
stats[
i] <= 0)
370 if (building !=
nullptr)
390 cgi->Cvar_Set(
"mn_upmetadata",
"1");
403 static char itemText[512];
411 cgi->INV_ItemDescription(
nullptr);
414 cgi->Cvar_Set(
"mn_itemname",
"%s",
_(tech->
name));
417 cgi->Cvar_Set(
"mn_upmetadata",
"1");
423 Com_sprintf(itemText,
sizeof(itemText),
_(
"Unknown - need to research this"));
425 Com_sprintf(itemText,
sizeof(itemText),
_(
"Unknown - need to research this"));
440 if (
ccs.numUnreadMails != -1)
441 return ccs.numUnreadMails;
443 ccs.numUnreadMails = 0;
450 ccs.numUnreadMails++;
455 ccs.numUnreadMails++;
460 ccs.numUnreadMails++;
462 ccs.numUnreadMails++;
465 assert(
m->eventMail);
466 if (!
m->eventMail->read)
467 ccs.numUnreadMails++;
476 cgi->Cvar_Set(
"mn_upunreadmail",
"%i",
ccs.numUnreadMails);
477 return ccs.numUnreadMails;
492 static char mailHeader[8 *
MAX_VAR] =
"";
494 const char* subjectType =
"";
495 const char* from, *to, *subject, *model;
506 ccs.numUnreadMails = -1;
533 cgi->Com_Error(
ERR_DROP,
"UP_SetMailHeader: unhandled techMailType_t %i for date.",
type);
536 if (from !=
nullptr) {
540 ccs.numUnreadMails = -1;
546 subjectType =
_(
"Proposal: ");
549 subjectType =
_(
"Re: ");
552 cgi->Com_Error(
ERR_DROP,
"UP_SetMailHeader: unhandled techMailType_t %i for subject.",
type);
560 from =
cgi->CL_Translate(from);
561 to =
cgi->CL_Translate(to);
562 subject =
cgi->CL_Translate(subject);
563 Com_sprintf(mailHeader,
sizeof(mailHeader),
_(
"FROM: %s\nTO: %s\nDATE: %s"), from, to, dateBuf);
564 cgi->Cvar_Set(
"mn_mail_sender_head",
"%s", model ? model :
"");
565 cgi->Cvar_Set(
"mn_mail_from",
"%s", from);
566 cgi->Cvar_Set(
"mn_mail_subject",
"%s%s", subjectType,
_(subject));
567 cgi->Cvar_Set(
"mn_mail_to",
"%s", to);
568 cgi->Cvar_Set(
"mn_mail_date",
"%s", dateBuf);
583 cgi->Cvar_Set(
"mn_upmodel_bottom",
"%s", associated->
mdl);
599 cgi->Cvar_Set(
"mn_upmodel_top",
"%s", tech->
mdl);
601 cgi->Cvar_Set(
"mn_upmodel_top",
"");
604 cgi->Cvar_Set(
"mn_upimage_top",
"%s", tech->
image);
606 cgi->Cvar_Set(
"mn_upimage_top",
"");
608 cgi->Cvar_Set(
"mn_upmodel_bottom",
"");
612 cgi->Cvar_Set(
"mn_uprequirement",
"");
613 cgi->Cvar_Set(
"mn_upmetadata",
"");
621 cgi->Cvar_SetValue(
"mn_uppreavailable", 0);
633 cgi->UI_ExecuteConfunc(
"itemdesc_view 0 0;");
635 cgi->Cvar_Set(
"mn_uptitle",
_(
"UFOpaedia: %s (complete)"),
_(tech->
name));
646 cgi->Cvar_SetValue(
"mn_uppreavailable", 1);
649 cgi->Cvar_SetValue(
"mn_uppreavailable", 0);
654 switch (tech->
type) {
657 for (
int i = 0;
i <
cgi->csi->numODs;
i++) {
660 cgi->INV_ItemDescription(od);
662 cgi->Cvar_Set(
"mn_upmetadata",
"1");
688 cgi->Cvar_Set(
"mn_uptitle",
_(
"UFOpaedia: %s"),
_(tech->
name));
694 cgi->UI_RegisterText(
TEXT_UFOPEDIA,
_(
"No pre-research description available."));
697 cgi->Cvar_Set(
"mn_uptitle",
_(
"UFOpaedia: %s"),
_(tech->
name));
701 cgi->Com_Error(
ERR_DROP,
"UP_Article: No mail or tech given");
715 cgi->UI_PushWindow(
"mail");
729 cgi->UI_PushWindow(
"mail");
730 cgi->Cbuf_AddText(
"ufopedia %s\n", techID);
743 cgi->UI_PushWindow(
"ufopedia");
744 cgi->Cbuf_AddText(
"ufopedia %s\nupdate_ufopedia_layout\n", techID);
754 cgi->Cmd_ExecuteString(
"ui_push ufopedia");
755 cgi->Cbuf_AddText(
"ufopedia %s\n", techID);
767 if (
cgi->Cmd_Argc() < 2) {
768 cgi->Com_Printf(
"Usage: %s <id>\n",
cgi->Cmd_Argv(0));
773 id =
cgi->Cmd_Argv(1);
777 cgi->Com_Printf(
"UP_FindEntry_f: No UFOpaedia entry given as parameter\n");
783 cgi->Com_DPrintf(
DEBUG_CLIENT,
"UP_FindEntry_f: No UFOpaedia entry found for %s\n",
id);
805 const char*
id =
va(
"@%i", tech->
idx);
806 cgi->UI_AddOption(&first,
id,
va(
"_%s", tech->
name),
id);
811 cgi->UI_SortOptions(&first);
827 for (
int i = 0;
i <
ccs.numChapters;
i++) {
830 if (chapter->
name ==
nullptr)
834 bool researchedEntries =
false;
838 researchedEntries =
true;
845 if (researchedEntries) {
852 chapterOption =
cgi->UI_AddOption(&chapters, chapter->
id,
va(
"_%s", chapter->
name),
va(
"%i", num));
862 cgi->Cvar_Set(
"mn_uptitle",
_(
"UFOpaedia"));
881 if (
cgi->Cmd_Argc() < 2)
885 if (
cgi->Cmd_Argv(1)[0] ==
'@') {
886 const int techId = atoi(
cgi->Cmd_Argv(1) + 1);
889 assert(techId <
ccs.numTechnologies);
890 tech = &
ccs.technologies[techId];
896 cgi->UI_ExecuteConfunc(
"itemdesc_view 0 0;");
908 if (
cgi->Cmd_Argc() < 2)
911 int num = atoi(
cgi->Cmd_Argv(1));
917 if (num < 0 || num >= required_AND->
numLinks)
921 for (
int i = 0;
i <= num;
i++) {
929 cgi->Com_Error(
ERR_DROP,
"Could not find the tech for '%s'", required_AND->
links[num].
id);
953 if (
cgi->Cmd_Argc() < 2)
957 const int num = atoi(
cgi->Cmd_Argv(1));
967 cgi->Cvar_SetValue(
"mn_uppretext", 1);
977 cgi->Cvar_SetValue(
"mn_uppretext", 0);
1003 ccs.numUnreadMails = -1;
1040 cgi->UI_ExecuteConfunc(
"clear_mails");
1044 char headline[256] =
"";
1045 char dateBuf[64] =
"";
1088 assert(
m->eventMail);
1101 cgi->UI_ExecuteConfunc(
"add_mail %i \"%s\" \"%s\" %i \"%s\"", idx++, headline, icon, read, dateBuf);
1128 assert(
m->eventMail);
1129 m->eventMail->read =
true;
1137 ccs.numUnreadMails = 0;
1138 cgi->Cvar_Set(
"mn_upunreadmail",
"%i",
ccs.numUnreadMails);
1143 {
"mn_upcontent",
UP_Content_f,
"Shows the UFOpaedia chapters"},
1144 {
"mn_upupdate",
UP_Update_f,
"Redraw the current UFOpaedia article"},
1145 {
"ufopedia",
UP_FindEntry_f,
"Open the UFOpaedia with the given article"},
1149 {
"ufopedia_openmail",
UP_OpenMail_f,
"Start the mailclient"},
1152 {
nullptr,
nullptr,
nullptr}
1162 mn_uppretext =
cgi->Cvar_Get(
"mn_uppretext",
"0", 0,
"Show the pre-research text in the UFOpaedia");
1163 mn_uppreavailable =
cgi->Cvar_Get(
"mn_uppreavailable",
"0", 0,
"True if there is a pre-research text available");
1164 cgi->Cvar_Set(
"mn_uprequirement",
"");
1165 cgi->Cvar_Set(
"mn_upmetadata",
"");
1176 cgi->Cvar_Delete(
"mn_uppretext");
1177 cgi->Cvar_Delete(
"mn_uppreavailable");
1178 cgi->Cvar_Delete(
"mn_uprequirement");
1179 cgi->Cvar_Delete(
"mn_upmetadata");
1190 const char* errhead =
"UP_ParseChapter: unexpected end of file (names ";
1194 cgi->Com_Error(
ERR_DROP,
"UP_ParseChapter: chapter def \"%s\": Too many chapter defs.\n",
name);
1200 chapter.
idx =
ccs.numChapters;
1204 if (!*text || *token !=
'{') {
1205 cgi->Com_Error(
ERR_DROP,
"UP_ParseChapter: chapter def \"%s\": '{' token expected.\n",
name);
1211 cgi->Com_Error(
ERR_DROP,
"UP_ParseChapter: end of file not expected \"%s\": '{' token expected.\n",
name);
1212 if (token[0] ==
'}')
1217 token =
cgi->Com_EParse(text, errhead,
name);
1218 if (!*text || *token ==
'}') {
1219 cgi->Com_Error(
ERR_DROP,
"UP_ParseChapter: chapter def \"%s\": Name token expected.\n",
name);
1225 cgi->Com_Error(
ERR_DROP,
"UP_ParseChapter: chapter def \"%s\": token \"%s\" not expected.\n",
name, token);
1230 ccs.upChapters[
ccs.numChapters] = chapter;
DateTime class definition.
Header file for inventory handling and Equipment menu.
Share stuff between the different cgame implementations.
int AIR_GetOperationRange(const aircraft_t *aircraft)
Calculates the range an aircraft can fly on the geoscape.
int AIR_AircraftMenuStatsValues(const int value, const int stat)
Some of the aircraft values needs special calculations when they are shown in the menus.
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
#define AIR_IsUFO(aircraft)
buildingType_t B_GetBuildingTypeByCapacity(baseCapacities_t cap)
Get building type by base capacity.
const building_t * B_GetBuildingTemplateByType(buildingType_t type)
Returns the building template in the global building-types list for a buildingType.
building_t * B_GetBuildingTemplate(const char *buildingName)
Returns the building in the global building-types list that has the unique name buildingID.
buildingType_t
All different building types.
memPool_t * cp_campaignPool
Header file for single player campaign control.
const cgame_import_t * cgi
baseCapacities_t
All possible capacities in base.
eventMail_t * CL_GetEventMail(const char *id)
Searches all event mails for a given id.
itemWeight_t AII_GetItemWeightBySize(const objDef_t *od)
Returns craftitem weight based on size.
const char * AII_WeightToName(itemWeight_t weight)
Translate a weight int to a translated string.
Header for slot management related stuff.
const char * RS_GetDescription(technologyDescriptions_t *desc)
returns the currently used description for a technology.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
#define RS_Collected_(tech)
techMailType_t
Types for tech mail definitions - see tech->mail[].
void CP_DateConvertLong(const DateTime &date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
const char * Date_GetMonthName(int month)
Returns the short monthame to the given month index.
Campaign geoscape time header.
static cvar_t * mn_uppreavailable
void UP_OpenWith(const char *techID)
Opens the UFOpaedia from everywhere with the entry given through name.
static void UP_ChangeDisplay(int newDisplay)
Modify the global display var.
static pediaChapter_t * currentChapter
static void UP_Article(technology_t *tech, eventMail_t *mail)
Display only the TEXT_UFOPEDIA part for a given technology.
static void UP_SetMailHeader(technology_t *tech, techMailType_t type, eventMail_t *mail)
Binds the mail header (if needed) to the mn.menuText array.
static technology_t * upCurrentTech
static void UP_DisplayTechTree(const technology_t *t)
Displays the tech tree dependencies in the UFOpaedia.
static void UP_OpenMailWith(const char *techID)
Opens the mail view from everywhere with the entry given through name.
static void UP_TechTreeClick_f(void)
void UP_OpenCopyWith(const char *techID)
Opens the UFOpaedia with the entry given through name, not deleting copies.
static void UP_BuildingDescription(const technology_t *t)
Prints the UFOpaedia description for buildings.
static bool UP_TechGetsDisplayed(const technology_t *tech)
Checks If a technology/UFOpaedia-entry will be displayed in the UFOpaedia (-list).
void UP_OpenEventMail(const char *eventMailID)
static void UP_OpenMail_f(void)
Start the mailclient.
static void UP_Click_f(void)
Callback when we click on the ufopedia summary.
int UP_GetUnreadMails(void)
Sets the amount of unread/new mails.
void UP_UGVDescription(const ugv_t *ugvType)
Prints the description for robots/ugvs.
static uiNode_t * UP_GenerateArticlesSummary(pediaChapter_t *parentChapter)
Generate a list of options for all allowed articles of a chapter.
static void UP_FindEntry_f(void)
Search and open the UFOpaedia with given id.
static int numChaptersDisplayList
static cvar_t * mn_uppretext
void UP_ParseChapter(const char *name, const char **text)
Parse the UFOpaedia chapters from scripts.
static const cmdList_t ufopediaCmds[]
void UP_AircraftDescription(const technology_t *tech)
Prints the UFOpaedia description for aircraft.
static void UP_ResearchedLinkClick_f(void)
Change UFOpaedia article when clicking on the name of associated ammo or weapon.
static void UP_GenerateSummary(void)
Generate a tree of option for all allowed chapters and articles.
static char upBuffer[MAX_UPTEXT]
static void UP_MailClientClick_f(void)
Mailclient click function callback.
static void UP_Content_f(void)
Displays the chapters in the UFOpaedia.
static const char * UP_AircraftStatToName(int stat)
Translate a aircraft statistic integer to a translated string.
static void UP_DrawAssociatedAmmo(const technology_t *tech)
Set the ammo model to display to selected ammo (only for a reloadable weapon).
void UP_AircraftItemDescription(const objDef_t *item)
Prints the (UFOpaedia and other) description for aircraft items.
static void UP_SetAllMailsRead_f(void)
Marks all mails read in mailclient.
static void UP_Update_f(void)
Redraw the UFOpaedia article.
static pediaChapter_t * upChaptersDisplayList[MAX_PEDIACHAPTERS]
void UP_InitStartup(void)
#define MAX_PEDIACHAPTERS
#define ngettext(x, y, cnt)
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
An aircraft with all it's data.
A building with all it's data.
const struct building_s * dependsBuilding
float stats[AIR_STATS_MAX]
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Human readable time information in the game.
available mails for a tech - mail and mail_pre in script files
Defines all attributes of objects used in the inventory.
const struct objDef_s * ammos[MAX_AMMOS_PER_OBJDEF]
bool isReloadable() const
const struct objDef_s * weapons[MAX_WEAPONS_PER_OBJDEF]
struct technology_s * first
union requirement_t::typelink_t link
requirement_t links[MAX_TECHLINKS]
available mails for a tech - mail and mail_pre in script files
This is the technology parsed from research.ufo.
technologyDescriptions_t description
technologyDescriptions_t preDescription
requirements_t requireAND
struct technology_s * redirect
class DateTime preResearchedDate
struct technology_s * upNext
struct pediaChapter_s * upChapter
techMail_t mail[TECHMAIL_MAX]
class DateTime researchedDate
Defines a type of UGV/Robot.
Atomic structure used to define most of the UI.
@ TEXT_UFOPEDIA_MAILHEADER
@ TEXT_UFOPEDIA_REQUIREMENT
#define OPTIONEXTRADATA(node)
const struct technology_s * tech