/** * @brief Mailclient click function callback * @sa UP_OpenMail_f */ static void UP_MailClientClick_f (void) { if (cgi->Cmd_Argc() < 2) return; int cnt = -1; const int num = atoi(cgi->Cmd_Argv(1)); uiMessageListNodeMessage_t* m = cgi->UI_MessageGetStack(); while (m) { switch (m->type) { case MSG_RESEARCH_PROPOSAL: if (!m->pedia->mail[TECHMAIL_PRE].from) break; cnt++; if (cnt == num) { cgi->Cvar_SetValue("mn_uppretext", 1); UP_OpenMailWith(m->pedia->id); return; } break; case MSG_RESEARCH_FINISHED: if (!m->pedia->mail[TECHMAIL_RESEARCHED].from) break; cnt++; if (cnt == num) { cgi->Cvar_SetValue("mn_uppretext", 0); UP_OpenMailWith(m->pedia->id); return; } break; case MSG_NEWS: if (m->pedia->mail[TECHMAIL_PRE].from || m->pedia->mail[TECHMAIL_RESEARCHED].from) { cnt++; if (cnt >= num) { UP_OpenMailWith(m->pedia->id); return; } } break; case MSG_EVENT: cnt++; if (cnt >= num) { UP_OpenEventMail(m->eventMail->id); return; } break; default: break; } m = m->next; } ccs.numUnreadMails = -1; UP_GetUnreadMails(); }
/** * @brief Adds the event mail to the message stack. This message is going to be added to the savegame. */ void CL_EventAddMail (const char *eventMailId) { eventMail_t* eventMail = CL_GetEventMail(eventMailId); if (!eventMail) { Com_Printf("CL_EventAddMail: Could not find eventmail with id '%s'\n", eventMailId); return; } if (eventMail->sent) { return; } if (!eventMail->from || !eventMail->to || !eventMail->subject || !eventMail->body) { Com_Printf("CL_EventAddMail: mail with id '%s' has incomplete data\n", eventMailId); return; } if (!eventMail->date) { dateLong_t date; char dateBuf[MAX_VAR] = ""; CP_DateConvertLong(&ccs.date, &date); Com_sprintf(dateBuf, sizeof(dateBuf), _("%i %s %02i"), date.year, Date_GetMonthName(date.month - 1), date.day); eventMail->date = Mem_PoolStrDup(dateBuf, cp_campaignPool, 0); } eventMail->sent = true; if (!eventMail->skipMessage) { uiMessageListNodeMessage_t *m = MS_AddNewMessage("", va(_("You've got a new mail: %s"), _(eventMail->subject)), MSG_EVENT); if (m) m->eventMail = eventMail; else Com_Printf("CL_EventAddMail: Could not add message with id: %s\n", eventMailId); } UP_OpenEventMail(eventMailId); }