Files
tft/person.hpp
T
2023-02-13 22:18:53 +02:00

72 lines
1.6 KiB
C++

#pragma once
#include <string>
#include <fstream>
#include <ncursesw/ncurses.h>
#include "common/basicTypes.h"
struct EventTime
{
enum: I16 { UNKNOWN_DATE=0 };
enum: I8 { UNKNOWN_TIME=-1 };
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 Genders: U8
{
FEMALE = 0,
MALE
};
enum BoxColors: U8 {
COLOR_MALE = 1,
COLOR_FEMALE,
COLOR_SELECTED
};
enum DisplayDimensons: U8 {
BOX_HEIGHT = 5,
LINK_HEIGHT = 3
};
class Person
{
public:
Person() = default;
Person(const char* name, EventTime birth={}, bool sex=true, EventTime death={});
/* Person(Person&&) = default; */
/* Person& operator=(Person&&) = default; */
/* Person& operator=(const Person&) = default; */
bool operator==(const Person &other) const;
void write(std::ofstream &file) const;//
void read(std::ifstream &file);
void rename(const char* newName);
void displayInfo() const;
bool isMale() const;
const EventTime& birth() const { return birth_; };
U16 boxWidth() const;
/* Draw a Person's box on the terminal
drawY,drawX - top left coordinates where to draw (negative if outside the screen)
returns the width of the box*/
void draw(I16 drawY, I16 drawX, bool selected, bool hasSpouse, bool isSpouse, bool hasChildren=false) const;
private:
std::string name_;
EventTime birth_;
bool isMale_;
EventTime death_;
};