Move::Move(Work& work, MoveNode const* move) :KeyNode(work.key) { //M_ASSERT(!move->atLineStart()); if (work.board.whiteToMove()) { if (work.m_level == 0 && (work.m_displayStyle & display::ColumnStyle)) work.pushBreak(); work.needMoveNo = true; } if (!work.isFolded && move->hasComment(move::Ante)) { db::Comment comment(move->comment(move::Ante)); comment.strip(*work.wantedLanguages); if (!comment.isEmpty()) { if (!move->prev()->hasMark() || move->prev()->hasComment(move::Post)) work.pushSpaceOrParagraph(Spacing::Comment); work.pop(m_list); m_list.push_back(new Comment(comment, move::Ante)); work.m_isVirgin = false; work.pushSpaceOrParagraph(Spacing::Comment); work.needMoveNo = true; } } work.pop(m_list); if (!work.isFolded && move->hasAnnotation()) { m_list.push_back(new Annotation( move->annotation(), bool(work.m_displayStyle & display::ShowDiagrams))); } m_ply = work.needMoveNo ? new Ply(move, work.board.moveNumber()) : new Ply(move); m_list.push_back(m_ply); work.incrPlyCount(); work.needMoveNo = false; work.pushSpace(); if (work.isFolded) return; if (move->hasMark()) { m_list.push_back(new Marks(move->marks())); work.pushSpace(); } mstl::string info; getMoveInfo(work, move, info); bool needSpace = false; if (move->hasComment(move::Post)) { db::Comment comment(move->comment(move::Post)); comment.strip(*work.wantedLanguages); if (!comment.isEmpty()) { bool isShort = info.empty() && comment.length() <= work.linebreakMinCommentLength && bool(work.m_displayStyle & display::CompactStyle); if (isShort) work.pushSpace(); else work.pushSpaceOrParagraph(Spacing::Comment); work.pop(m_list); m_list.push_back(new Comment(comment, move::Post)); if (isShort) work.pushSpace(); else needSpace = true; } } if (!info.empty()) { if (needSpace) work.pushSpace(); else work.pushSpaceOrParagraph(Spacing::Comment); work.pop(m_list); m_list.push_back(new Comment(db::Comment(info, false, false), move::Post, Comment::Finally)); needSpace = true; } if (needSpace) { work.pushSpaceOrParagraph(Spacing::Comment); work.needMoveNo = true; } }
Move::Move(Work& work, MoveNode const* move, bool isEmptyGame, unsigned varNo, unsigned varCount) :KeyNode(work.key) ,m_ply(0) { if (work.m_level == 0) { if (work.isEmpty && isEmptyGame) m_list.push_back(new Space(Empty)); else m_list.push_back(new Space(Start)); } else { if (/*varCount > 1 && */(work.m_displayStyle & display::ShowVariationNumbers)) work.pushOpen(varNo == 1, varNo); else work.pushOpen(varNo == 1); work.pushSpace(); work.needMoveNo = true; } if (work.isFolded) return; if (move->hasMark()) { work.pop(m_list); m_list.push_back(new Marks(move->marks())); work.m_isVirgin = false; work.pushSpace(); } bool needSpace = false; mstl::string info; getMoveInfo(work, move, info); if (move->hasComment(move::Post)) { db::Comment comm(move->comment(move::Post)); comm.strip(*work.wantedLanguages); if (!comm.isEmpty()) { work.pop(m_list); m_list.push_back(new Comment(comm, move::Post, Comment::AtStart)); needSpace = true; } } if (!info.empty()) { if (needSpace) work.pushSpace(); work.pop(m_list); m_list.push_back(new Comment(db::Comment(info, false, false), move::Post, Comment::Finally)); needSpace = true; } if (needSpace) { work.m_isVirgin = false; // work.pushParagraph(Spacing::PreComment); if (!move->hasMark()) work.pushSpaceOrParagraph(Spacing::Comment); work.needMoveNo = true; } }