Loading...
Searching...
No Matches
wx_cond.h File Reference

The condition token the phone sends, as a number a face can index its own art by. More...

#include <stdbool.h>
#include "weather/wx_cond.g.h"

Go to the source code of this file.

Functions

WxCond wx_cond_parse (const char *token, bool *night)
 Finds the condition for a token, with or without its "_NIGHT" ending.

Detailed Description

The condition token the phone sends, as a number a face can index its own art by.

The phone sends the sky as a short token, such as "RAIN", with "_NIGHT" on the end after dark. A face that draws its own art for each condition keeps a table indexed by WxCond and reads the token through wx_cond_parse. The numbers and tokens come from the same list the phone sends from, so the two cannot drift.

The face builds the table from WX_COND_EACH rather than writing its rows out. Each condition's row then names a resource after the condition, so a condition added to the list stops the face's build on a resource it has not got, wherever in the list it lands.

#define SKY_ART(name) [WX_COND_##name] = RESOURCE_ID_SKY_##name,
static const uint32_t s_art[WX_COND_COUNT] = {WX_COND_EACH(SKY_ART)};
bool night;
uint32_t art = cond < WX_COND_COUNT ? s_art[cond] : RESOURCE_ID_SKY_NA;
WxCond wx_cond_parse(const char *token, bool *night)
Finds the condition for a token, with or without its "_NIGHT" ending.
Definition wx_cond.c:19
#define WX_COND_EACH(X)
Hands each condition's name to X, in WxCond order.
Definition wx_cond.g.h:60
WxCond
Each weather condition the phone can send, numbered in the order of the shared list.
Definition wx_cond.g.h:32
@ WX_COND_COUNT
How many conditions there are. Not a condition itself.
Definition wx_cond.g.h:45
const char * weather_store_cond(void)
The short word for the sky, or empty if we have not got one yet.
Definition weather_store.c:413