123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- #pragma once
- #include <Schrift.h>
- #include <UIMLView.h>
- #include "NetworkAPIProcessor.h"
- class QuestGraphElement : public Framework::UIMLElement
- {
- public:
- QuestGraphElement();
- //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
- //! ist
- bool isApplicableFor(Framework::XML::Element& element) override;
- //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
- Framework::Zeichnung* parseElement(Framework::XML::Element& element,
- Framework::UIMLContainer& generalFactory) override;
- bool updateElement(Framework::XML::Element& element,
- Framework::Zeichnung& z,
- Framework::UIMLContainer& generalFactory) override;
- //! wendet die layout parameter zu einer Zeichnung an
- void layout(Framework::XML::Element& element,
- Framework::Zeichnung& z,
- int pWidth,
- int pHeight,
- Framework::UIMLContainer& generalLayouter) override;
- };
- class QuestGraphItemElement : public Framework::UIMLElement
- {
- public:
- QuestGraphItemElement();
- //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
- //! ist
- bool isApplicableFor(Framework::XML::Element& element) override;
- //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
- Framework::Zeichnung* parseElement(Framework::XML::Element& element,
- Framework::UIMLContainer& generalFactory) override;
- bool updateElement(Framework::XML::Element& element,
- Framework::Zeichnung& z,
- Framework::UIMLContainer& generalFactory) override;
- //! wendet die layout parameter zu einer Zeichnung an
- void layout(Framework::XML::Element& element,
- Framework::Zeichnung& z,
- int pWidth,
- int pHeight,
- Framework::UIMLContainer& generalLayouter) override;
- };
- class QuestGraphItem;
- struct ConnectionInfo
- {
- QuestGraphItem* target;
- int id;
- };
- class AndNode;
- struct ConnectionTarget
- {
- int targetIndex;
- AndNode* zTarget;
- };
- class Connection : public Framework::ReferenceCounter
- {
- private:
- QuestGraphItem* zSource;
- Framework::Array<ConnectionTarget> targets;
- int vx;
- int minY;
- int maxY;
- public:
- Connection(QuestGraphItem* zSource);
- void renderVertical(Framework::Bild& rObj);
- void renderHorizontal(Framework::Bild& rObj);
- void setVx(int vx);
- void addConnectionTarget(ConnectionTarget target);
- void setTargetIndex(AndNode* zTarget, int index);
- void layout();
- bool isActive() const;
- int getOrderNum() const;
- int getTargetCount() const;
- int getVerticalLength() const;
- int getVx() const;
- };
- class AndNode : public Framework::ZeichnungHintergrund
- {
- private:
- Framework::Array<Connection*> connections;
- Framework::TextRenderer tr;
- public:
- AndNode();
- void addConnection(Connection* zConnection);
- void render(Framework::Bild& rObj);
- Framework::Punkt getTargetPosition(int index);
- void layout();
- bool isActive() const;
- int getConnectionCount() const;
- };
- class OrConnection : public Framework::ReferenceCounter
- {
- private:
- Framework::RCArray<AndNode> andNodes;
- QuestGraphItem* zTarget;
- int minY;
- int maxY;
- public:
- OrConnection(QuestGraphItem* zTarget,
- const Framework::Array<ConnectionInfo>& connections);
- void render(Framework::Bild& rObj);
- void layout();
- int getNeededHeight() const;
- bool isActive() const;
- bool isHorizontalLineConflict(int y) const;
- };
- class QuestGraphItem : public Framework::ZeichnungHintergrund
- {
- private:
- int layerIndex;
- int nodeIndex;
- Framework::Array<ConnectionInfo> previousLayersConnections;
- Framework::Array<ConnectionInfo> nextLayersConnections;
- Framework::Text id;
- Framework::Text requirements;
- Framework::Text onClick;
- Connection* outgoingConnection;
- OrConnection* incommingConnection;
- bool finished;
- bool rewarded;
- bool mainQuest;
- bool virtualNode;
- double animationProgress;
- public:
- QuestGraphItem();
- ~QuestGraphItem();
- bool tick(double tickVal);
- void render(Framework::Bild& rObj);
- void renderVerticalConnections(Framework::Bild& rObj);
- void renderHorizontalConnections(Framework::Bild& rObj);
- void replacePreviousConnections(
- QuestGraphItem* zBefore, QuestGraphItem* zAfter);
- const Framework::Text& getId() const;
- const Framework::Text& getRequirements() const;
- bool calculateLaxerIndex();
- int getLayerIndex() const;
- void setVirtual(bool virtualNode);
- void setNodeIndex(int index);
- void addNextLayerRef(ConnectionInfo zItem);
- void addPreviousLayerRef(ConnectionInfo zItem);
- void initializeConnections();
- const Framework::Array<ConnectionInfo>& getNextLayersConnections() const;
- int getNodeIndex() const;
- bool isMainQuest() const;
- bool isVirtual() const;
- bool isFinished() const;
- Connection* zOutgoingConnection() const;
- OrConnection* zIncommingConnection() const;
- friend QuestGraphItemElement;
- };
- class QuestGraphItemLayer : public Framework::ReferenceCounter
- {
- private:
- Framework::RCArray<QuestGraphItem> items;
- public:
- QuestGraphItemLayer();
- bool tick(double tickVal);
- void render(Framework::Bild& rObj);
- void doMausEreignis(Framework::MausEreignis& me);
- void addItem(QuestGraphItem* item);
- bool sortItems();
- int fixItemPositions(int x);
- void sortConnections();
- const Framework::RCArray<QuestGraphItem>& getItems() const;
- int getLeyerHeight() const;
- void centerVertically(int pos);
- void resolveHorizontalConflicts(const QuestGraphItemLayer* zNextLayer);
- bool isHorizontalLineConflict(int y) const;
- };
- class QuestGraph : public Framework::ZeichnungHintergrund
- {
- private:
- Framework::Text id;
- Framework::RCArray<QuestGraphItemLayer> layers;
- QuestGraphItemLayer invalidNodes;
- Framework::Text collectionName;
- public:
- QuestGraph();
- bool tick(double tickVal);
- void render(Framework::Bild& rObj) override;
- void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
- void addVirtualConnectionNodes();
- void sortItems();
- void fixItemPositions();
- void centerVertically();
- void addItem(QuestGraphItem* item);
- friend QuestGraphElement;
- };
|