Files
tft/person.h
T
2022-12-31 18:54:34 +02:00

69 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <fstream>
#include <ncursesw/ncurses.h>
#include "common/basicTypes.h"
struct EventTime
{
//enum { UNKNOWN_DATE=0, UNKNOWN_TIME=1};
static const I16 UNKNOWN_DATE = 0;
static const I8 UNKNOWN_TIME = -1;
/*explicit*/ EventTime(I16 Year=UNKNOWN_DATE, U8 Month=UNKNOWN_DATE, U16 Day=UNKNOWN_DATE, I8 Hour=UNKNOWN_TIME, I8 Minute=UNKNOWN_TIME);
void print() const;
I16 year; //The year in relation to Chritst's birth - 1 (AD) is the year He was born, -1 (BC) is the previous year. There is no year 0
U8 month;
U16 day;
I8 hour; //0-23
I8 minute; //0-59
};
enum {
COLOR_MALE = 1,
COLOR_FEMALE
};
enum {
BOX_HEIGHT = 5,
LINK_HEIGHT = 3
};
class Person
{
public:
Person() = default;
Person(const char* name, EventTime birth, bool sex, EventTime death);
/* Person(Person&&) = default; */
/* Person& operator=(Person&&) = default; */
/* Person& operator=(const Person&) = default; */
bool operator==(const Person &other)const;
void save(std::ofstream &file)const;//
void load(std::ifstream &file);
void rename(const char* newName);
void print() const;
U16 boxWidth() const;
/* Draw a Person's box on the terminal
drawY,drawX - the coordinates where to draw
returns the width of the box*/
void draw(I16 drawY, I16 drawX, bool hasSpouse, bool isSpouse, bool hasChildren=false) const;
/* WINDOW* createPad()const; */
/* staitc constexpr U8 BOX_HEIGHT = 5; */
friend class Tree;
private:
std::string name_;
unsigned numRel_; //Number of close relatives - mother, father, brother, sister, wife/husband, child, ex-wife/husband
EventTime birth_;
bool isMale_;
EventTime death_;
};