Handles news generation.
More...
#include "news.h"
#include "array.h"
#include "faction.h"
#include "log.h"
#include "nstring.h"
#include "ntime.h"
#include "nxml.h"
#include "toolkit.h"
Go to the source code of this file.
|
| static void | news_render (double bx, double by, double w, double h, void *data) |
| | Renders a news widget.
|
| static void | news_focusLose (unsigned int wid, const char *wgtname) |
| | Called when it's de-focused.
|
| static int | news_mouse (unsigned int wid, const SDL_Event *event, double mx, double my, double w, double h, double rx, double ry, void *data) |
| | News widget mouse event handler.
|
| static int | news_parseArticle (xmlNodePtr parent) |
| | Parses articles.
|
| int | news_saveArticles (xmlTextWriterPtr writer) |
| int | news_loadArticles (xmlNodePtr parent) |
| | Loads the player's active articles from a save, initilizes news.
|
| static void | clear_newslines (void) |
| static int | news_cmp (const void *p1, const void *p2) |
| int | news_add (const char *title, const char *content, const char *faction, const char *tag, ntime_t date, ntime_t date_to_rm, int priority) |
| | makes a new article and puts it into the list
|
| int | news_init (void) |
| | Initiate news linked list with a stack.
|
| void | news_exit (void) |
| | Kills the old news thread.
|
| news_t * | news_get (int id) |
| | gets the article with id ID, else NULL
|
| void | news_free (news_t *n) |
| void | news_rm (int id) |
| int * | generate_news (int faction) |
| | Generates news from newslist from specific faction AND Generic news.
|
| void | news_widget (unsigned int wid, int x, int y, int w, int h) |
| | Creates a news widget.
|
Handles news generation.
Definition in file news.c.
◆ NEWS_MAX_LENGTH
| #define NEWS_MAX_LENGTH 8192 |
Maximum length to print.
Definition at line 26 of file news.c.
◆ NEWS_READ
| #define NEWS_READ |
( |
| elem, |
|
|
| s ) |
Value: xmlr_attr_strd( node, s, elem ); \
if (elem == NULL) { \
WARN( _( "Event is missing '%s', skipping." ), s ); \
goto cleanup; \
}
◆ clear_newslines()
| void clear_newslines |
( |
void | | ) |
|
|
static |
◆ generate_news()
| int * generate_news |
( |
int | faction | ) |
|
Generates news from newslist from specific faction AND Generic news.
- Parameters
-
| faction | the faction of wanted news |
- Returns
- 0 on success
Definition at line 202 of file news.c.
◆ news_add()
| int news_add |
( |
const char * | title, |
|
|
const char * | content, |
|
|
const char * | faction, |
|
|
const char * | tag, |
|
|
ntime_t | date, |
|
|
ntime_t | date_to_rm, |
|
|
int | priority ) |
makes a new article and puts it into the list
- Parameters
-
| title | the article title |
| content | the article content |
| faction | the article faction |
| tag | Tag to set. |
| date | date to put |
| date_to_rm | date to remove the article |
| priority | Priority to use. |
- Returns
- ID of newly added news.
Definition at line 94 of file news.c.
◆ news_cmp()
| int news_cmp |
( |
const void * | p1, |
|
|
const void * | p2 ) |
|
static |
◆ news_exit()
Kills the old news thread.
Definition at line 139 of file news.c.
◆ news_focusLose()
| void news_focusLose |
( |
unsigned int | wid, |
|
|
const char * | wgtname ) |
|
static |
Called when it's de-focused.
Definition at line 323 of file news.c.
◆ news_free()
◆ news_get()
gets the article with id ID, else NULL
Definition at line 169 of file news.c.
◆ news_init()
Initiate news linked list with a stack.
Definition at line 123 of file news.c.
◆ news_loadArticles()
| int news_loadArticles |
( |
xmlNodePtr | parent | ) |
|
Loads the player's active articles from a save, initilizes news.
- Parameters
-
| parent | Node containing the player's active events. |
- Returns
- 0 on success.
Definition at line 487 of file news.c.
◆ news_mouse()
| int news_mouse |
( |
unsigned int | wid, |
|
|
const SDL_Event * | event, |
|
|
double | mx, |
|
|
double | my, |
|
|
double | w, |
|
|
double | h, |
|
|
double | rx, |
|
|
double | ry, |
|
|
void * | data ) |
|
static |
News widget mouse event handler.
- Parameters
-
| wid | Window receiving the mouse events. |
| event | Mouse event being received. |
| mx | X position of the mouse. |
| my | Y position of the mouse. |
| w | Width of the widget. |
| h | Height of the widget. |
| rx | Relative X movement (only valid for motion). |
| ry | Relative Y movement (only valid for motion). |
| data | Unused. |
Definition at line 343 of file news.c.
◆ news_parseArticle()
| int news_parseArticle |
( |
xmlNodePtr | parent | ) |
|
|
static |
Parses articles.
- Parameters
-
| parent | Parent node to parse. |
- Returns
- 0 on success.
Definition at line 516 of file news.c.
◆ news_render()
| void news_render |
( |
double | bx, |
|
|
double | by, |
|
|
double | w, |
|
|
double | h, |
|
|
void * | data ) |
|
static |
Renders a news widget.
- Parameters
-
| bx | Base X position to render at. |
| by | Base Y position to render at. |
| w | Width of the widget. |
| h | Height of the widget. |
| data | Unused. |
Definition at line 393 of file news.c.
◆ news_rm()
◆ news_saveArticles()
| int news_saveArticles |
( |
xmlTextWriterPtr | writer | ) |
|
◆ news_widget()
| void news_widget |
( |
unsigned int | wid, |
|
|
int | x, |
|
|
int | y, |
|
|
int | w, |
|
|
int | h ) |
Creates a news widget.
- Parameters
-
| wid | Window to create news widget on. |
| x | X position of the widget to create. |
| y | Y position of the widget to create. |
| w | Width of the widget. |
| h | Height of the widget. |
Definition at line 273 of file news.c.
◆ buf
News line buffer.
Definition at line 37 of file news.c.
◆ largestID
Save/load
Definition at line 52 of file news.c.
◆ len
◆ news_drag
Is dragging news?
Definition at line 41 of file news.c.
◆ news_font
Font to use.
Definition at line 43 of file news.c.
◆ news_lines
◆ news_list
Linked list containing all articles
Definition at line 31 of file news.c.
◆ news_pos
Position of the news feed.
Definition at line 42 of file news.c.
◆ news_restores
Initial value:Array (array.h) of restorations.
Definition at line 45 of file news.c.
◆ news_tick
| unsigned int news_tick = 0 |
|
static |
Last news tick.
Definition at line 40 of file news.c.
◆ next_id
next number to use as ID
Definition at line 32 of file news.c.
◆ textlength