From f77f55366ebb67fbbfd47e105fbfc7de98f24fae Mon Sep 17 00:00:00 2001 From: Venelin Date: Wed, 28 Dec 2022 15:55:42 +0200 Subject: [PATCH] draw with wife --- compile_debug.sh | 2 +- help.h | 5 ++++ main.cpp | 6 ++--- tree.cpp | 64 +++++++++++++++++++++++++++--------------------- tree.h | 1 + 5 files changed, 46 insertions(+), 32 deletions(-) diff --git a/compile_debug.sh b/compile_debug.sh index cdbd6c8..f7acc73 100755 --- a/compile_debug.sh +++ b/compile_debug.sh @@ -1 +1 @@ -g++ -o bin/debug/famt -std=gnu++20 -g -Og *.cpp -lncursesw +g++ -o bin/debug/famt -std=gnu++20 -g -O0 *.cpp -lncursesw diff --git a/help.h b/help.h index 5a8135c..ca2b394 100644 --- a/help.h +++ b/help.h @@ -6,3 +6,8 @@ unsigned strLen(const char* str); void strCopy(char *to, const char* from); bool strComp(const char* firts, const char* second); //0 - diffrent 1 - same char* mergeStr(const char* first, const char* second); + +inline I32 max(I32 a, I32 b) +{ + return a >= b ? a : b; +} diff --git a/main.cpp b/main.cpp index 7703968..258d7e3 100644 --- a/main.cpp +++ b/main.cpp @@ -20,7 +20,7 @@ int main() test1.addPerson("Rumen", true, Nobody, Nobody, {1968, 8, 9}); test1.addPerson("Nadejda", false, Nobody, Nobody, {1972, 12, 15}); - /* test1.addRelation(0, Husband, 1); */ + test1.addRelation(0, Spouse, 1); test1.addPerson("Venelin", true, 0, 1, {1998, 6, 9}); test1.addPerson("Vasil", true, 0, 1, {2001, 1, 16}); /* test1.addRelation(2, Brother, 3); */ @@ -30,12 +30,12 @@ int main() test2.addPerson("Vasil Dimitrov", true, Nobody, Nobody, {1941, 5, 18}); test2.addPerson("Maria", false); - /* test2.addRelation(0, Husband, 1); */ + test2.addRelation(0, Spouse, 1); test2.addPerson("Dimitar", true, 0, 1); test2.addPerson("Nadejda", false, 0, 1, {1972, 12, 15}); /* test2.addRelation(2, Brother, 3); */ test2.addPerson("Branimira", false); - /* test2.addRelation(2, Husband, 4); */ + test2.addRelation(2, Spouse, 4); test2.addPerson("Ioan", true, 2, 4); test2.addPerson("Rumiana", false, 2, 4); /* test2.addRelation(5, Brother, 6); */ diff --git a/tree.cpp b/tree.cpp index be808ea..d126ea7 100644 --- a/tree.cpp +++ b/tree.cpp @@ -389,7 +389,7 @@ void Tree::draw(person_id focused) const U16 drawY = 0/* (LINES) / 2 */; U16 drawX = 0/* (COLS) / 2 */; - drawLine(focused, drawY, drawX); + drawLineWithWives(focused, drawY, drawX); /* people[0].draw(drawY, drawY); */ /* for(U32 i=0; i children; + for(person_id i = 0; i < rels.gNum(); ++i) + { + if(rels[i].type == RelType::Parent) + children.push_back(rels[i].id); + else if(rels[i].type == RelType::Spouse && spouse == Nobody) + spouse = rels[i].id; + } - /* /\* for(U32 i = 0; i < re *\/ */ + U16 spouse_width = 0; + if(spouse != Nobody) + { + people[spouse].draw(drawY, drawX + person.boxWidth() + spouse_dist); + spouse_width = spouse_dist + people[spouse].boxWidth(); + } - /* std::vector children; */ - /* for(U32 i=0; i