Hangout spot generator
This commit is contained in:
parent
e217587b9c
commit
cae4036778
47
FemMonitor/bool.c
Normal file
47
FemMonitor/bool.c
Normal file
@ -0,0 +1,47 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "bool.h"
|
||||
|
||||
|
||||
static WINDOW* window = NULL;
|
||||
static int height;
|
||||
static int width;
|
||||
static int counter = 0;
|
||||
|
||||
const double MAX_X = 38.13428976038013;
|
||||
const double MIN_Y = -122.61858623117328;
|
||||
const double MIN_X = 37.22568446282394;
|
||||
const double MAX_Y = -121.59685781209097;
|
||||
|
||||
void bool_init(WINDOW* win, int h, int w)
|
||||
{
|
||||
window = win;
|
||||
height = h;
|
||||
width = w;
|
||||
|
||||
mvwprintw(window, 0, START_COL, " Bool Ideas ");
|
||||
wrefresh(window);
|
||||
}
|
||||
|
||||
double drand(double low,double high)
|
||||
{
|
||||
srand((unsigned) time(NULL));
|
||||
return ((double)rand() * (high - low)) / (double)RAND_MAX + low;
|
||||
}
|
||||
|
||||
void* bool_refresh(void* arg)
|
||||
{
|
||||
if (counter++ % 10 == 0)
|
||||
{
|
||||
double x = drand(MIN_X, MAX_X);
|
||||
double y = drand(MIN_Y, MAX_Y);
|
||||
mvwprintw(window, 2, START_COL, "%f, %f", x, y);
|
||||
wrefresh(window);
|
||||
}
|
||||
}
|
||||
|
||||
void bool_destroy()
|
||||
{
|
||||
}
|
10
FemMonitor/bool.h
Normal file
10
FemMonitor/bool.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef bool_h
|
||||
#define bool_h
|
||||
|
||||
#include <ncurses.h>
|
||||
|
||||
void bool_init(WINDOW* win, int h, int w);
|
||||
void* bool_refresh(void* arg);
|
||||
void bool_destroy(void);
|
||||
|
||||
#endif /* bool_h */
|
@ -104,12 +104,18 @@ void* company_refresh(void* arg)
|
||||
// clear line
|
||||
for (int i = START_COL; i < width - 1; ++i)
|
||||
mvwprintw(window, START_ROW+5, i, " ");
|
||||
// print the funny reference
|
||||
mvwprintw(window, START_ROW+5, START_COL, "%s", tagline);
|
||||
// say the funny reference
|
||||
char buf[1024];
|
||||
sprintf(buf, "espeak \"%s\" >/dev/null 2>&1", tagline);
|
||||
system(buf);
|
||||
// truncate reference
|
||||
int max_length = width - 2*START_COL;
|
||||
if (strlen(tagline) > max_length)
|
||||
{
|
||||
tagline[max_length] = 0;
|
||||
}
|
||||
// print the funny reference
|
||||
mvwprintw(window, START_ROW+5, START_COL, "%s", tagline);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "bool.h"
|
||||
#include "booru.h"
|
||||
#include "common.h"
|
||||
#include "company.h"
|
||||
@ -64,12 +65,15 @@ int main(int argc, const char* argv[])
|
||||
|
||||
// setup various status windows
|
||||
// the bottom windows will be one row shorter to fit the status line at the end
|
||||
WINDOW* topleft = create_newwin(LINES/2, COLS, 0, 0);
|
||||
WINDOW* botleft = create_newwin(LINES/2 - 1, COLS/2, LINES/2, 0);
|
||||
WINDOW* topleft = create_newwin(LINES/3, COLS/2, 0, 0);
|
||||
WINDOW* midleft = create_newwin(LINES/3, COLS/2, LINES/3, 0);
|
||||
WINDOW* botleft = create_newwin(LINES/3 - 1, COLS/2, LINES*2/3, 0);
|
||||
WINDOW* topright = create_newwin(LINES/2, COLS/2, 0, COLS/2);
|
||||
WINDOW* botright = create_newwin(LINES/2 - 1, COLS/2, LINES/2, COLS/2);
|
||||
|
||||
company_init(topleft, LINES/2, COLS);
|
||||
mail_init(botleft, LINES/2 - 1, COLS/2);
|
||||
company_init(topleft, LINES/3, COLS/2);
|
||||
bool_init(midleft, LINES/3, COLS/2);
|
||||
mail_init(botleft, LINES/3 - 1, COLS/2);
|
||||
booru_init(botright, LINES/2 - 1, COLS/2);
|
||||
|
||||
time_t t;
|
||||
@ -77,6 +81,7 @@ int main(int argc, const char* argv[])
|
||||
char ch;
|
||||
while ((ch = tolower(getch())) != KEY_QUIT)
|
||||
{
|
||||
bool_refresh(NULL);
|
||||
booru_refresh(NULL);
|
||||
mail_refresh(NULL);
|
||||
company_refresh(NULL);
|
||||
@ -96,6 +101,7 @@ int main(int argc, const char* argv[])
|
||||
}
|
||||
|
||||
// cleanup everything
|
||||
bool_destroy();
|
||||
booru_destroy();
|
||||
mail_destroy();
|
||||
company_destroy();
|
||||
|
Loading…
x
Reference in New Issue
Block a user