UFO: Alien Invasion
|
UFOpaedia script interpreter. More...
#include "../../cl_shared.h"
#include "../../cl_inventory.h"
#include "../../ui/ui_dataids.h"
#include "../../ui/node/ui_node_option.h"
#include "../../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_time.h"
Go to the source code of this file.
Macros | |
#define | MAX_UPTEXT 4096 |
Enumerations | |
enum | { UFOPEDIA_CHAPTERS, UFOPEDIA_INDEX, UFOPEDIA_ARTICLE, UFOPEDIA_DISPLAYEND } |
Functions | |
static bool | UP_TechGetsDisplayed (const technology_t *tech) |
Checks If a technology/UFOpaedia-entry will be displayed in the UFOpaedia (-list). More... | |
static void | UP_ChangeDisplay (int newDisplay) |
Modify the global display var. More... | |
static const char * | UP_AircraftStatToName (int stat) |
Translate a aircraft statistic integer to a translated string. More... | |
static void | UP_DisplayTechTree (const technology_t *t) |
Displays the tech tree dependencies in the UFOpaedia. More... | |
static void | UP_BuildingDescription (const technology_t *t) |
Prints the UFOpaedia description for buildings. More... | |
void | UP_AircraftItemDescription (const objDef_t *item) |
Prints the (UFOpaedia and other) description for aircraft items. More... | |
void | UP_AircraftDescription (const technology_t *tech) |
Prints the UFOpaedia description for aircraft. More... | |
void | UP_UGVDescription (const ugv_t *ugvType) |
Prints the description for robots/ugvs. More... | |
int | UP_GetUnreadMails (void) |
Sets the amount of unread/new mails. More... | |
static void | UP_SetMailHeader (technology_t *tech, techMailType_t type, eventMail_t *mail) |
Binds the mail header (if needed) to the mn.menuText array. More... | |
static void | UP_DrawAssociatedAmmo (const technology_t *tech) |
Set the ammo model to display to selected ammo (only for a reloadable weapon) More... | |
static void | UP_Article (technology_t *tech, eventMail_t *mail) |
Display only the TEXT_UFOPEDIA part for a given technology. More... | |
void | UP_OpenEventMail (const char *eventMailID) |
static void | UP_OpenMailWith (const char *techID) |
Opens the mail view from everywhere with the entry given through name. More... | |
void | UP_OpenWith (const char *techID) |
Opens the UFOpaedia from everywhere with the entry given through name. More... | |
void | UP_OpenCopyWith (const char *techID) |
Opens the UFOpaedia with the entry given through name, not deleting copies. More... | |
static void | UP_FindEntry_f (void) |
Search and open the UFOpaedia with given id. More... | |
static uiNode_t * | UP_GenerateArticlesSummary (pediaChapter_t *parentChapter) |
Generate a list of options for all allowed articles of a chapter. More... | |
static void | UP_GenerateSummary (void) |
Generate a tree of option for all allowed chapters and articles. More... | |
static void | UP_Content_f (void) |
Displays the chapters in the UFOpaedia. More... | |
static void | UP_Click_f (void) |
Callback when we click on the ufopedia summary. More... | |
static void | UP_TechTreeClick_f (void) |
static void | UP_Update_f (void) |
Redraw the UFOpaedia article. More... | |
static void | UP_MailClientClick_f (void) |
Mailclient click function callback. More... | |
static void | UP_ResearchedLinkClick_f (void) |
Change UFOpaedia article when clicking on the name of associated ammo or weapon. More... | |
static void | UP_OpenMail_f (void) |
Start the mailclient. More... | |
static void | UP_SetAllMailsRead_f (void) |
Marks all mails read in mailclient. More... | |
void | UP_InitStartup (void) |
void | UP_Shutdown (void) |
void | UP_ParseChapter (const char *name, const char **text) |
Parse the UFOpaedia chapters from scripts. More... | |
Variables | |
static cvar_t * | mn_uppretext |
static cvar_t * | mn_uppreavailable |
static pediaChapter_t * | upChaptersDisplayList [MAX_PEDIACHAPTERS] |
static int | numChaptersDisplayList |
static technology_t * | upCurrentTech |
static pediaChapter_t * | currentChapter |
static char | upBuffer [MAX_UPTEXT] |
static int | upDisplay = UFOPEDIA_CHAPTERS |
static const cmdList_t | ufopediaCmds [] |
UFOpaedia script interpreter.
Split the mail code into cl_mailclient.c/h
Remove direct access to nodes
Definition in file cp_ufopedia.cpp.
#define MAX_UPTEXT 4096 |
Definition at line 46 of file cp_ufopedia.cpp.
anonymous enum |
Enumerator | |
---|---|
UFOPEDIA_CHAPTERS | |
UFOPEDIA_INDEX | |
UFOPEDIA_ARTICLE | |
UFOPEDIA_DISPLAYEND |
Definition at line 53 of file cp_ufopedia.cpp.
void UP_AircraftDescription | ( | const technology_t * | tech | ) |
Prints the UFOpaedia description for aircraft.
Definition at line 322 of file cp_ufopedia.cpp.
References _, AIR_AircraftMenuStatsValues(), AIR_GetAircraft(), AIR_GetHangarCapacityType(), AIR_GetOperationRange(), AIR_IsUFO, AIR_STATS_ACCURACY, AIR_STATS_ANTIMATTER, AIR_STATS_DAMAGE, AIR_STATS_FUELSIZE, AIR_STATS_MAX, AIR_STATS_MAXSPEED, AIR_STATS_SPEED, B_GetBuildingTemplateByType(), B_GetBuildingTypeByCapacity(), cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), i, aircraft_s::maxElectronics, aircraft_s::maxTeamSize, aircraft_s::maxWeapons, building_s::name, technology_s::provides, Q_strcat(), RS_Collected_, RS_IsResearched_ptr(), aircraft_s::stats, TEXT_ITEMDESCRIPTION, UP_AircraftStatToName(), UP_DisplayTechTree(), and upBuffer.
Referenced by BS_MarketAircraftDescription(), and UP_Article().
Prints the (UFOpaedia and other) description for aircraft items.
item | The object definition of the item |
Definition at line 227 of file cp_ufopedia.cpp.
References _, AC_ITEM_AMMO, AC_ITEM_BASE_LASER, AC_ITEM_BASE_MISSILE, AC_ITEM_WEAPON, AII_GetItemWeightBySize(), AII_WeightToName(), AIR_AircraftMenuStatsValues(), AIR_STATS_MAX, AIR_STATS_WRANGE, objDef_s::ammo, objDef_s::ammos, cgi, objDef_s::craftitem, cgame_import_s::Cvar_Set(), EQUAL, i, objDef_s::id, objDef_s::isVirtual, technology_s::mdl, objDef_s::name, objDef_s::numAmmos, Q_strcat(), RS_GetTechForItem(), RS_IsResearched_ptr(), craftitem_s::stats, TEXT_ITEMDESCRIPTION, craftitem_s::type, UP_AircraftStatToName(), craftitem_s::weaponDamage, and craftitem_s::weaponDelay.
Referenced by AIM_UpdateItemDescription(), BDEF_SelectItem_f(), BS_ShowInfo_f(), and UP_Article().
|
static |
Translate a aircraft statistic integer to a translated string.
Definition at line 132 of file cp_ufopedia.cpp.
References _, AIR_STATS_ACCURACY, AIR_STATS_ANTIMATTER, AIR_STATS_DAMAGE, AIR_STATS_ECM, AIR_STATS_FUELSIZE, AIR_STATS_MAXSPEED, AIR_STATS_SHIELD, AIR_STATS_SPEED, and AIR_STATS_WRANGE.
Referenced by UP_AircraftDescription(), and UP_AircraftItemDescription().
|
static |
Display only the TEXT_UFOPEDIA part for a given technology.
[in] | tech | The technology_t pointer to print the UFOpaedia article for |
[in] | The mail parameters in case we produce a mail |
Definition at line 592 of file cp_ufopedia.cpp.
References _, eventMail_s::body, cgi, cgame_import_s::Com_GetUGVByIDSilent(), cgame_import_s::csi, cgame_import_s::Cvar_Set(), technology_s::description, ERR_DROP, i, objDef_s::id, technology_s::image, cvar_s::integer, INVSH_GetItemByID(), INVSH_GetItemByIDX(), technology_s::mdl, technology_s::name, technologyDescriptions_s::numDescriptions, csi_s::numODs, technology_s::preDescription, technology_s::provides, Q_streq, RS_ARMOUR, RS_BUILDING, RS_Collected_, RS_CRAFT, RS_CRAFTITEM, RS_GetDescription(), RS_IsResearched_ptr(), RS_TECH, RS_UGV, RS_WEAPON, technology_s::statusResearchable, TECHMAIL_PRE, TECHMAIL_RESEARCHED, TEXT_UFOPEDIA, TEXT_UFOPEDIA_REQUIREMENT, technology_s::type, UFOPEDIA_ARTICLE, UFOPEDIA_CHAPTERS, UFOPEDIA_INDEX, UP_AircraftDescription(), UP_AircraftItemDescription(), UP_BuildingDescription(), UP_ChangeDisplay(), UP_DisplayTechTree(), UP_DrawAssociatedAmmo(), UP_SetMailHeader(), UP_UGVDescription(), technology_s::upChapter, and upDisplay.
Referenced by UP_Click_f(), UP_FindEntry_f(), UP_OpenEventMail(), and UP_Update_f().
|
static |
Prints the UFOpaedia description for buildings.
Definition at line 201 of file cp_ufopedia.cpp.
References _, B_GetBuildingTemplate(), building_s::buildTime, cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), building_s::dependsBuilding, building_s::fixCosts, building_s::name, ngettext, technology_s::provides, Q_strcat(), TEXT_ITEMDESCRIPTION, UP_DisplayTechTree(), upBuffer, and building_s::varCosts.
Referenced by UP_Article().
Modify the global display var.
Definition at line 89 of file cp_ufopedia.cpp.
References _, cgi, cgame_import_s::Cvar_Set(), TEXT_ITEMDESCRIPTION, TEXT_UFOPEDIA, TEXT_UFOPEDIA_MAIL, TEXT_UFOPEDIA_MAILHEADER, TEXT_UFOPEDIA_REQUIREMENT, UFOPEDIA_ARTICLE, UFOPEDIA_CHAPTERS, UFOPEDIA_INDEX, and upDisplay.
Referenced by UP_Article(), UP_Click_f(), and UP_Content_f().
Callback when we click on the ufopedia summary.
Definition at line 878 of file cp_ufopedia.cpp.
References ccs, cgi, cgame_import_s::Cmd_Argv(), ccs_s::numTechnologies, ccs_s::technologies, UFOPEDIA_CHAPTERS, UP_Article(), and UP_ChangeDisplay().
Displays the chapters in the UFOpaedia.
Definition at line 867 of file cp_ufopedia.cpp.
References UFOPEDIA_CHAPTERS, UP_ChangeDisplay(), and UP_GenerateSummary().
|
static |
Displays the tech tree dependencies in the UFOpaedia.
Add support for "requireAND"
re-iterate trough logic blocks (i.e. append the tech-names it references recursively)
Only display tech if it is ok to do so.
Definition at line 164 of file cp_ufopedia.cpp.
References _, cgi, cgame_import_s::Cvar_Set(), ERR_DROP, i, requirement_s::id, requirement_s::link, requirements_s::links, technology_s::name, requirements_s::numLinks, technology_s::requireAND, RS_LINK_TECH, requirement_s::typelink_t::tech, TEXT_UFOPEDIA_REQUIREMENT, requirement_s::type, and UP_TechGetsDisplayed().
Referenced by UP_AircraftDescription(), UP_Article(), and UP_BuildingDescription().
|
static |
Set the ammo model to display to selected ammo (only for a reloadable weapon)
tech | technology_t pointer for the weapon's tech |
Definition at line 576 of file cp_ufopedia.cpp.
References objDef_s::ammos, cgi, cgame_import_s::Cvar_Set(), INVSH_GetItemByID(), technology_s::mdl, objDef_s::numAmmos, technology_s::provides, and RS_GetTechForItem().
Referenced by UP_Article().
Search and open the UFOpaedia with given id.
Definition at line 761 of file cp_ufopedia.cpp.
References cgi, cgame_import_s::Cmd_Argv(), DEBUG_CLIENT, technology_s::redirect, RS_GetTechByID(), and UP_Article().
|
static |
Generate a list of options for all allowed articles of a chapter.
[in] | parentChapter | requested chapter |
Definition at line 797 of file cp_ufopedia.cpp.
References cgi, pediaChapter_s::first, technology_s::idx, technology_s::name, cgame_import_s::UI_AddOption(), UP_TechGetsDisplayed(), technology_s::upNext, and va().
Referenced by UP_GenerateSummary().
Generate a tree of option for all allowed chapters and articles.
Definition at line 819 of file cp_ufopedia.cpp.
References _, ccs, cgi, cgame_import_s::Cvar_Set(), ERR_DROP, pediaChapter_s::first, uiNode_t::firstChild, i, pediaChapter_s::id, pediaChapter_s::name, ccs_s::numChapters, numChaptersDisplayList, OPTION_UFOPEDIA, OPTIONEXTRADATA, cgame_import_s::UI_AddOption(), cgame_import_s::UI_GetSpriteByName(), UP_GenerateArticlesSummary(), UP_TechGetsDisplayed(), ccs_s::upChapters, technology_s::upNext, and va().
Referenced by UP_Content_f().
Sets the amount of unread/new mails.
Definition at line 435 of file cp_ufopedia.cpp.
References ccs, cgi, cgame_import_s::Cvar_Set(), uiMessageListNodeMessage_s::eventMail, techMail_s::from, m, technology_s::mail, MSG_EVENT, MSG_NEWS, MSG_RESEARCH_FINISHED, MSG_RESEARCH_PROPOSAL, uiMessageListNodeMessage_s::next, ccs_s::numUnreadMails, uiMessageListNodeMessage_s::pedia, eventMail_s::read, techMail_s::read, RS_IsResearched_ptr(), TECHMAIL_PRE, TECHMAIL_RESEARCHED, uiMessageListNodeMessage_s::type, and cgame_import_s::UI_MessageGetStack().
Referenced by CP_CampaignRun(), and UP_MailClientClick_f().
Definition at line 1156 of file cp_ufopedia.cpp.
References cgi, cgame_import_s::Cvar_Get(), and cgame_import_s::Cvar_Set().
Referenced by CP_InitStartup().
Mailclient click function callback.
Definition at line 950 of file cp_ufopedia.cpp.
References ccs, cgi, cgame_import_s::Cmd_Argv(), m, MSG_EVENT, MSG_NEWS, MSG_RESEARCH_FINISHED, MSG_RESEARCH_PROPOSAL, ccs_s::numUnreadMails, TECHMAIL_PRE, TECHMAIL_RESEARCHED, cgame_import_s::UI_MessageGetStack(), UP_GetUnreadMails(), UP_OpenEventMail(), and UP_OpenMailWith().
void UP_OpenCopyWith | ( | const char * | techID | ) |
Opens the UFOpaedia with the entry given through name, not deleting copies.
techID | UFOpaedia entry id (technology script id) |
Definition at line 751 of file cp_ufopedia.cpp.
References cgi.
void UP_OpenEventMail | ( | const char * | eventMailID | ) |
Definition at line 707 of file cp_ufopedia.cpp.
References cgi, CL_GetEventMail(), and UP_Article().
Referenced by CL_EventAddMail(), and UP_MailClientClick_f().
Start the mailclient.
Definition at line 1037 of file cp_ufopedia.cpp.
References _, cgi, Com_sprintf(), CP_DateConvertLong(), eventMail_s::date, Date_GetMonthName(), dateLong_s::day, eventMail_s::from, techMail_s::from, eventMail_s::icon, techMail_s::icon, m, dateLong_s::month, MSG_EVENT, MSG_NEWS, MSG_RESEARCH_FINISHED, MSG_RESEARCH_PROPOSAL, eventMail_s::read, techMail_s::read, eventMail_s::subject, techMail_s::subject, TECHMAIL_PRE, TECHMAIL_RESEARCHED, cgame_import_s::UI_MessageGetStack(), and dateLong_s::year.
Referenced by UP_SetAllMailsRead_f().
|
static |
Opens the mail view from everywhere with the entry given through name.
techID | mail entry id (technology script id) |
Definition at line 723 of file cp_ufopedia.cpp.
References cgi.
Referenced by UP_MailClientClick_f().
void UP_OpenWith | ( | const char * | techID | ) |
Opens the UFOpaedia from everywhere with the entry given through name.
techID | UFOpaedia entry id (technology script id) |
Definition at line 737 of file cp_ufopedia.cpp.
References cgi.
Referenced by B_BuildingOpenAfterClick_f(), BS_MarketInfoClick_f(), PR_ProductionListRightClick_f(), RS_ResearchFinish(), UP_ResearchedLinkClick_f(), and UP_TechTreeClick_f().
void UP_ParseChapter | ( | const char * | name, |
const char ** | text | ||
) |
Parse the UFOpaedia chapters from scripts.
[in] | name | Chapter ID |
[in] | text | Text for chapter ID |
Definition at line 1187 of file cp_ufopedia.cpp.
References ccs, cgi, cgame_import_s::Com_EParse(), Com_Parse(), cp_campaignPool, ERR_DROP, pediaChapter_s::id, pediaChapter_s::idx, MAX_PEDIACHAPTERS, pediaChapter_s::name, ccs_s::numChapters, OBJZERO, cgame_import_s::PoolStrDup(), Q_streq, and ccs_s::upChapters.
Referenced by CP_ParseScriptFirst().
Change UFOpaedia article when clicking on the name of associated ammo or weapon.
Definition at line 1009 of file cp_ufopedia.cpp.
References objDef_s::ammos, technology_s::id, INVSH_GetItemByID(), objDef_s::isAmmo(), objDef_s::isReloadable(), technology_s::provides, RS_GetTechForItem(), UP_OpenWith(), UP_TechGetsDisplayed(), objDef_s::weapon, and objDef_s::weapons.
Marks all mails read in mailclient.
Definition at line 1107 of file cp_ufopedia.cpp.
References ccs, cgi, cgame_import_s::Cvar_Set(), uiMessageListNodeMessage_s::eventMail, m, technology_s::mail, MSG_EVENT, MSG_NEWS, MSG_RESEARCH_FINISHED, MSG_RESEARCH_PROPOSAL, uiMessageListNodeMessage_s::next, ccs_s::numUnreadMails, uiMessageListNodeMessage_s::pedia, eventMail_s::read, techMail_s::read, TECHMAIL_PRE, TECHMAIL_RESEARCHED, uiMessageListNodeMessage_s::type, cgame_import_s::UI_MessageGetStack(), and UP_OpenMail_f().
|
static |
Binds the mail header (if needed) to the mn.menuText array.
[in] | tech | The tech to generate a header for. |
[in] | type | The type of mail (research proposal or finished research) |
[in] | The mail descriptor structure |
Definition at line 489 of file cp_ufopedia.cpp.
References _, ccs, cgi, cgame_import_s::CL_Translate(), Com_sprintf(), CP_DateConvertLong(), cgame_import_s::Cvar_Set(), eventMail_s::date, techMail_s::date, Date_GetMonthName(), dateLong_s::day, ERR_DROP, eventMail_s::from, techMail_s::from, technology_s::mail, MAX_VAR, eventMail_s::model, techMail_s::model, dateLong_s::month, technology_s::numTechMails, ccs_s::numUnreadMails, technology_s::preResearchedDate, Q_strncpyz(), eventMail_s::read, techMail_s::read, technology_s::researchedDate, eventMail_s::subject, techMail_s::subject, TECHMAIL_MAX, TECHMAIL_PRE, TECHMAIL_RESEARCHED, TEXT_UFOPEDIA_MAILHEADER, eventMail_s::to, techMail_s::to, type, and dateLong_s::year.
Referenced by UP_Article().
Definition at line 1170 of file cp_ufopedia.cpp.
References cgi.
Referenced by CP_RemoveCampaignCallbackCommands().
|
static |
Checks If a technology/UFOpaedia-entry will be displayed in the UFOpaedia (-list).
UP_Article
Definition at line 69 of file cp_ufopedia.cpp.
References INVSH_GetItemByIDSilent(), objDef_s::isVirtual, technologyDescriptions_s::numDescriptions, technology_s::preDescription, technology_s::provides, technology_s::redirect, RS_Collected_, RS_IsResearched_ptr(), RS_LOGIC, technology_s::statusResearchable, and technology_s::type.
Referenced by UP_DisplayTechTree(), UP_GenerateArticlesSummary(), UP_GenerateSummary(), and UP_ResearchedLinkClick_f().
Definition at line 905 of file cp_ufopedia.cpp.
References cgi, cgame_import_s::Cmd_Argv(), ERR_DROP, i, requirement_s::id, technology_s::id, requirement_s::link, requirements_s::links, requirements_s::numLinks, technology_s::requireAND, RS_LINK_TECH, RS_LINK_TECH_NOT, requirement_s::typelink_t::tech, requirement_s::type, UP_OpenWith(), and technology_s::upChapter.
Prints the description for robots/ugvs.
[in] | ugvType | What type of robot/ugv to print the description for. |
Definition at line 400 of file cp_ufopedia.cpp.
References _, cgi, Com_sprintf(), cgame_import_s::Cvar_Set(), ugv_s::id, technology_s::name, technology_s::provides, RS_Collected_, RS_GetTechByProvided(), RS_IsResearched_ptr(), TEXT_ITEMDESCRIPTION, and ugv_s::weapon.
Referenced by UP_Article().
Redraw the UFOpaedia article.
Definition at line 940 of file cp_ufopedia.cpp.
References UP_Article().
|
static |
Definition at line 44 of file cp_ufopedia.cpp.
|
static |
Definition at line 38 of file cp_ufopedia.cpp.
|
static |
Definition at line 37 of file cp_ufopedia.cpp.
|
static |
Definition at line 41 of file cp_ufopedia.cpp.
Referenced by UP_GenerateSummary().
|
static |
Definition at line 1141 of file cp_ufopedia.cpp.
|
static |
Definition at line 47 of file cp_ufopedia.cpp.
Referenced by UP_AircraftDescription(), and UP_BuildingDescription().
|
static |
Definition at line 40 of file cp_ufopedia.cpp.
|
static |
Definition at line 43 of file cp_ufopedia.cpp.
|
static |
Definition at line 60 of file cp_ufopedia.cpp.
Referenced by UP_Article(), and UP_ChangeDisplay().