cp_ufopedia.c File Reference

UFOpaedia script interpreter. More...

#include "../cl_shared.h"
#include "../cl_inventory.h"
#include "../ui/ui_main.h"
#include "../ui/ui_icon.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_time.h"
Include dependency graph for cp_ufopedia.c:

Go to the source code of this file.

Defines

#define MAX_UPTEXT   4096
#define MAIL_LENGTH   256
#define MAIL_BUFFER_SIZE   0x4000
#define CHECK_MAIL_EOL   if (tempBuf[MAIL_LENGTH-3] != '\n') tempBuf[MAIL_LENGTH-2] = '\n';
#define MAIL_CLIENT_LINES   15

Enumerations

enum  { UFOPEDIA_CHAPTERS, UFOPEDIA_INDEX, UFOPEDIA_ARTICLE, UFOPEDIA_DISPLAYEND }

Functions

static qboolean UP_TechGetsDisplayed (const technology_t *tech)
 Checks If a technology/UFOpaedia-entry will be displayed in the UFOpaedia (-list).
static void UP_ChangeDisplay (int newDisplay)
 Modify the global display var.
static const char * CL_AircraftStatToName (int stat)
 Translate a aircraft statistic integer to a translated string.
static const char * CL_AircraftSizeToName (int aircraftSize)
 Translate a aircraft size integer to a translated string.
static void UP_DisplayTechTree (const technology_t *t)
 Displays the tech tree dependencies in the UFOpaedia.
static void UP_BuildingDescription (const technology_t *t)
 Prints the UFOpaedia description for buildings.
void UP_AircraftItemDescription (const objDef_t *item)
 Prints the (UFOpaedia and other) description for aircraft items.
void UP_AircraftDescription (const technology_t *tech)
 Prints the UFOpaedia description for aircraft.
void UP_UGVDescription (const ugv_t *ugvType)
 Prints the description for robots/ugvs.
int UP_GetUnreadMails (void)
 Sets the amount of unread/new mails.
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 void UP_DrawAssociatedAmmo (const technology_t *tech)
 Set the ammo model to display to selected ammo (only for a reloadable weapon).
static void UP_Article (technology_t *tech, eventMail_t *mail)
 Display only the TEXT_UFOPEDIA part for a given technology.
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.
void UP_OpenWith (const char *techID)
 Opens the UFOpaedia from everywhere with the entry given through name.
void UP_OpenCopyWith (const char *techID)
 Opens the UFOpaedia with the entry given through name, not deleting copies.
static void UP_FindEntry_f (void)
 Search and open the UFOpaedia with given id.
static uiNode_tUP_GenerateArticlesSummary (pediaChapter_t *parentChapter)
 Generate a list of options for all allowed articles of a chapter.
static void UP_GenerateSummary (void)
 Generate a tree of option for all allowed chapters and articles.
static void UP_Content_f (void)
 Displays the chapters in the UFOpaedia.
static void UP_Click_f (void)
 Callback when we click on the ufopedia summary.
static void UP_TechTreeClick_f (void)
static void UP_Update_f (void)
 Redraw the UFOpaedia article.
static void UP_MailClientClick_f (void)
 Mailclient click function callback.
static void UP_ResearchedLinkClick_f (void)
 Change UFOpaedia article when clicking on the name of associated ammo or weapon.
static void UP_SetMailButtons_f (void)
 Set up mail icons.
static void UP_OpenMail_f (void)
 Start the mailclient.
static void UP_SetAllMailsRead_f (void)
 Marks all mails read in mailclient.
void UP_InitStartup (void)
void UP_Shutdown (void)
void UP_ParseChapters (const char *name, const char **text)
 Parse the UFOpaedia chapters from scripts.

Variables

static cvar_tmn_uppretext
static cvar_tmn_uppreavailable
static pediaChapter_tupChaptersDisplayList [MAX_PEDIACHAPTERS]
static int numChaptersDisplayList
static technology_tupCurrentTech
static pediaChapter_tcurrentChapter
static char upBuffer [MAX_UPTEXT]
static char mailBuffer [MAIL_BUFFER_SIZE]
static int upDisplay = UFOPEDIA_CHAPTERS

Detailed Description

UFOpaedia script interpreter.

Todo:

Split the mail code into cl_mailclient.c/h

Remove direct access to nodes

Definition in file cp_ufopedia.c.


Define Documentation

#define CHECK_MAIL_EOL   if (tempBuf[MAIL_LENGTH-3] != '\n') tempBuf[MAIL_LENGTH-2] = '\n';

Definition at line 52 of file cp_ufopedia.c.

Referenced by UP_OpenMail_f().

#define MAIL_BUFFER_SIZE   0x4000

Definition at line 50 of file cp_ufopedia.c.

#define MAIL_CLIENT_LINES   15

Definition at line 53 of file cp_ufopedia.c.

Referenced by UP_SetMailButtons_f().

#define MAIL_LENGTH   256

Definition at line 49 of file cp_ufopedia.c.

Referenced by UP_OpenMail_f().

#define MAX_UPTEXT   4096

Definition at line 46 of file cp_ufopedia.c.


Enumeration Type Documentation

anonymous enum
Note:
don't change the order or you have to change the if statements about mn_updisplay cvar in menu_ufopedia.ufo, too
Enumerator:
UFOPEDIA_CHAPTERS 
UFOPEDIA_INDEX 
UFOPEDIA_ARTICLE 
UFOPEDIA_DISPLAYEND 

Definition at line 59 of file cp_ufopedia.c.


Function Documentation

static const char* CL_AircraftSizeToName ( int  aircraftSize  )  [static]

Translate a aircraft size integer to a translated string.

See also:
aircraftSize_t

Definition at line 166 of file cp_ufopedia.c.

References _, AIRCRAFT_LARGE, and AIRCRAFT_SMALL.

Referenced by UP_AircraftDescription().

static const char* CL_AircraftStatToName ( int  stat  )  [static]
void UP_AircraftDescription ( const technology_t tech  ) 
void UP_AircraftItemDescription ( const objDef_t item  ) 

Prints the (UFOpaedia and other) description for aircraft items.

Parameters:
item The object definition of the item
See also:
UP_Article Not only called from UFOpaedia but also from other places to display
Todo:
Don't display things like speed for base defence items - a missile facility isn't getting slower or faster due a special weapon or ammunition

Definition at line 248 of file cp_ufopedia.c.

References _, AC_ITEM_AMMO, AC_ITEM_WEAPON, AII_GetItemWeightBySize(), AII_WeightToName(), AIR_STATS_MAX, AIR_STATS_WRANGE, objDef_s::ammo, CL_AircraftMenuStatsValues(), CL_AircraftStatToName(), objDef_s::craftitem, Cvar_Set(), i, objDef_s::id, INV_ItemDescription(), technology_s::mdl, technology_s::name, Q_strcat(), RS_GetTechForItem(), RS_IsResearched_ptr(), craftitem_s::stats, TEXT_ITEMDESCRIPTION, craftitem_s::type, UI_RegisterText(), UI_ResetData(), va(), craftitem_s::weaponDamage, and craftitem_s::weaponDelay.

Referenced by AIM_UpdateItemDescription(), BDEF_SelectItem_f(), BS_BuyType(), BS_MarketClick_f(), and UP_Article().

static void UP_Article ( technology_t tech,
eventMail_t mail 
) [static]
static void UP_BuildingDescription ( const technology_t t  )  [static]
static void UP_ChangeDisplay ( int  newDisplay  )  [static]
static void UP_Click_f ( void   )  [static]

Callback when we click on the ufopedia summary.

Note:
when we click on a chapter, param=chapterId, when we click on an article, param='@'+techIdx

Definition at line 849 of file cp_ufopedia.c.

References ccs, Cmd_Argc(), Cmd_Argv(), ccs_s::numTechnologies, ccs_s::technologies, UFOPEDIA_CHAPTERS, UI_ExecuteConfunc(), UP_Article(), and UP_ChangeDisplay().

Referenced by UP_InitStartup().

static void UP_Content_f ( void   )  [static]

Displays the chapters in the UFOpaedia.

Definition at line 838 of file cp_ufopedia.c.

References UFOPEDIA_CHAPTERS, UP_ChangeDisplay(), and UP_GenerateSummary().

Referenced by UP_InitStartup().

static void UP_DisplayTechTree ( const technology_t t  )  [static]

Displays the tech tree dependencies in the UFOpaedia.

See also:
UP_Article
Todo:

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.

Todo:
If it is one (a logic tech) we may want to re-iterate from its requirements?

Definition at line 184 of file cp_ufopedia.c.

References _, Com_Error(), Cvar_Set(), ERR_DROP, i, requirement_s::id, requirement_s::link, requirements_s::links, LIST_AddString(), technology_s::name, requirements_s::numLinks, technology_s::requireAND, RS_LINK_TECH, TEXT_UFOPEDIA_REQUIREMENT, requirement_s::type, UI_RegisterLinkedListText(), and UP_TechGetsDisplayed().

Referenced by UP_AircraftDescription(), UP_Article(), and UP_BuildingDescription().

static void UP_DrawAssociatedAmmo ( const technology_t tech  )  [static]

Set the ammo model to display to selected ammo (only for a reloadable weapon).

Parameters:
tech technology_t pointer for the weapon's tech
See also:
UP_Article

Definition at line 551 of file cp_ufopedia.c.

References objDef_s::ammos, Cvar_Set(), INVSH_GetItemByID(), technology_s::mdl, objDef_s::numAmmos, technology_s::provides, and RS_GetTechForItem().

Referenced by UP_Article().

static void UP_FindEntry_f ( void   )  [static]

Search and open the UFOpaedia with given id.

Definition at line 737 of file cp_ufopedia.c.

References Cmd_Argc(), Cmd_Argv(), Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, id, technology_s::redirect, RS_GetTechByID(), and UP_Article().

Referenced by UP_InitStartup().

static uiNode_t* UP_GenerateArticlesSummary ( pediaChapter_t parentChapter  )  [static]

Generate a list of options for all allowed articles of a chapter.

Parameters:
[in] parentChapter requested chapter
Returns:
The first option of the list, else NULL if no articles

Definition at line 773 of file cp_ufopedia.c.

References pediaChapter_s::first, technology_s::idx, technology_s::name, UI_AddOption(), UI_SortOptions(), UP_TechGetsDisplayed(), technology_s::upNext, and va().

Referenced by UP_GenerateSummary().

static void UP_GenerateSummary ( void   )  [static]
int UP_GetUnreadMails ( void   ) 

Sets the amount of unread/new mails.

Note:
This is called every campaign frame - to update ccs.numUnreadMails just set it to -1 before calling this function
See also:
CL_CampaignRun

Definition at line 414 of file cp_ufopedia.c.

References ccs, cp_messageStack, Cvar_Set(), message_s::eventMail, techMail_s::from, m, technology_s::mail, MSG_EVENT, MSG_NEWS, MSG_RESEARCH_FINISHED, MSG_RESEARCH_PROPOSAL, message_s::next, ccs_s::numUnreadMails, message_s::pedia, eventMail_s::read, techMail_s::read, RS_IsResearched_ptr(), TECHMAIL_PRE, TECHMAIL_RESEARCHED, message_s::type, and va().

Referenced by CL_CampaignRun().

void UP_InitStartup ( void   ) 
static void UP_MailClientClick_f ( void   )  [static]
void UP_OpenCopyWith ( const char *  techID  ) 

Opens the UFOpaedia with the entry given through name, not deleting copies.

Parameters:
techID UFOpaedia entry id (technology script id)
See also:
UP_FindEntry_f

Definition at line 727 of file cp_ufopedia.c.

References Cbuf_AddText(), Cmd_ExecuteString(), and va().

Referenced by RS_ShowPedia_f().

void UP_OpenEventMail ( const char *  eventMailID  ) 
See also:
CL_EventAddMail_f

Definition at line 683 of file cp_ufopedia.c.

References CL_GetEventMail(), qfalse, UI_PushWindow(), and UP_Article().

Referenced by UP_MailClientClick_f().

static void UP_OpenMail_f ( void   )  [static]
static void UP_OpenMailWith ( const char *  techID  )  [static]

Opens the mail view from everywhere with the entry given through name.

Parameters:
techID mail entry id (technology script id)
See also:
UP_FindEntry_f

Definition at line 699 of file cp_ufopedia.c.

References Cbuf_AddText(), UI_PushWindow(), and va().

Referenced by UP_MailClientClick_f().

void UP_OpenWith ( const char *  techID  ) 

Opens the UFOpaedia from everywhere with the entry given through name.

Parameters:
techID UFOpaedia entry id (technology script id)
See also:
UP_FindEntry_f

Definition at line 713 of file cp_ufopedia.c.

References Cbuf_AddText(), UI_PushWindow(), and va().

Referenced by AC_OpenUFOpedia_f(), B_BuildingInfoClick_f(), B_BuildingOpenAfterClick(), BS_MarketInfoClick_f(), PR_ProductionListRightClick_f(), UP_ResearchedLinkClick_f(), and UP_TechTreeClick_f().

void UP_ParseChapters ( const char *  name,
const char **  text 
)

Parse the UFOpaedia chapters from scripts.

Parameters:
[in] name Chapter ID
[in] text Text for chapter ID
See also:
CL_ParseFirstScript

Definition at line 1269 of file cp_ufopedia.c.

References ccs, Com_EParse(), Com_Parse(), Com_Printf(), cp_campaignPool, pediaChapter_s::id, pediaChapter_s::idx, MAX_PEDIACHAPTERS, Mem_PoolStrDup, pediaChapter_s::name, ccs_s::numChapters, and ccs_s::upChapters.

Referenced by CL_ParseScriptFirst().

static void UP_ResearchedLinkClick_f ( void   )  [static]

Change UFOpaedia article when clicking on the name of associated ammo or weapon.

Definition at line 984 of file cp_ufopedia.c.

References objDef_s::ammos, technology_s::id, INV_IsAmmo, INVSH_GetItemByID(), technology_s::provides, objDef_s::reload, RS_GetTechForItem(), UP_OpenWith(), UP_TechGetsDisplayed(), objDef_s::weapon, and objDef_s::weapons.

Referenced by UP_InitStartup().

static void UP_SetAllMailsRead_f ( void   )  [static]
static void UP_SetMailButtons_f ( void   )  [static]
static void UP_SetMailHeader ( technology_t tech,
techMailType_t  type,
eventMail_t mail 
) [static]
void UP_Shutdown ( void   ) 
See also:
UI_InitStartup

Definition at line 1243 of file cp_ufopedia.c.

References Cmd_RemoveCommand(), and Cvar_Delete().

Referenced by CP_RemoveCampaignCallbackCommands().

static qboolean UP_TechGetsDisplayed ( const technology_t tech  )  [static]

Checks If a technology/UFOpaedia-entry will be displayed in the UFOpaedia (-list).

Note:
This does not check for different display modes (only pre-research text, what statistics, etc...). The content is mostly checked in UP_Article
Returns:
qtrue if the tech gets displayed at all, otherwise qfalse.
See also:
UP_Article

Definition at line 75 of file cp_ufopedia.c.

References INVSH_GetItemByIDSilent(), objDef_s::isVirtual, descriptions_s::numDescriptions, technology_s::preDescription, technology_s::provides, qfalse, 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().

static void UP_TechTreeClick_f ( void   )  [static]
void UP_UGVDescription ( const ugv_t ugvType  ) 

Prints the description for robots/ugvs.

Parameters:
[in] ugvType What type of robot/ugv to print the description for.
See also:
BS_MarketClick_f
UP_Article

Todo:
make me shiny
Todo:
Display crippled info and pre-research text here

Definition at line 379 of file cp_ufopedia.c.

References _, Com_sprintf(), Cvar_Set(), ugv_s::id, INV_ItemDescription(), technology_s::name, technology_s::provides, RS_Collected_(), RS_GetTechByProvided(), RS_IsResearched_ptr(), TEXT_ITEMDESCRIPTION, UI_RegisterText(), and ugv_s::weapon.

static void UP_Update_f ( void   )  [static]

Redraw the UFOpaedia article.

Definition at line 915 of file cp_ufopedia.c.

References UP_Article().

Referenced by UP_InitStartup().


Variable Documentation

Definition at line 44 of file cp_ufopedia.c.

char mailBuffer[MAIL_BUFFER_SIZE] [static]

Definition at line 51 of file cp_ufopedia.c.

Referenced by UP_OpenMail_f().

Definition at line 38 of file cp_ufopedia.c.

cvar_t* mn_uppretext [static]

Definition at line 37 of file cp_ufopedia.c.

int numChaptersDisplayList [static]

Definition at line 41 of file cp_ufopedia.c.

Referenced by UP_GenerateSummary().

char upBuffer[MAX_UPTEXT] [static]

Definition at line 47 of file cp_ufopedia.c.

Referenced by UP_AircraftDescription(), and UP_BuildingDescription().

pediaChapter_t* upChaptersDisplayList[MAX_PEDIACHAPTERS] [static]

Definition at line 40 of file cp_ufopedia.c.

Definition at line 43 of file cp_ufopedia.c.

int upDisplay = UFOPEDIA_CHAPTERS [static]

Definition at line 66 of file cp_ufopedia.c.

Referenced by UP_Article(), and UP_ChangeDisplay().


Generated by  doxygen 1.6.2