29 changed files with 271 additions and 67 deletions
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@
@@ -1,2 +1,2 @@
|
||||
#!/bin/bash |
||||
make && ./netrunner http://gyroninja.net/a.html; |
||||
make -j8 && ./netrunner http://motherfuckingwebsite.com/ |
||||
|
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
#include "Component.h" |
||||
|
||||
Component::~Component() { |
||||
} |
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
#ifndef COMPONENT_H |
||||
#define COMPONENT_H |
||||
|
||||
class Component { |
||||
public: |
||||
virtual ~Component(); |
||||
float height; |
||||
}; |
||||
|
||||
#endif |
@ -1,5 +1,27 @@
@@ -1,5 +1,27 @@
|
||||
#include "TagNode.h" |
||||
#include "elements/H1Element.h" |
||||
#include "elements/H2Element.h" |
||||
#include "elements/H3Element.h" |
||||
#include "elements/LIElement.h" |
||||
#include "elements/PElement.h" |
||||
|
||||
const Element TagNode::elements[] = { |
||||
{"h1", &H1Element::render}, |
||||
{"h2", &H2Element::render}, |
||||
{"h3", &H3Element::render}, |
||||
{"li", &LIElement::render}, |
||||
{"p", &PElement::render} |
||||
}; |
||||
|
||||
TagNode::TagNode() : Node(NodeType::TAG) { |
||||
|
||||
} |
||||
} |
||||
|
||||
std::unique_ptr<Component> TagNode::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
for (Element element : elements) { |
||||
if (tag == element.tag) { |
||||
return element.render(node, y, windowWidth, windowHeight); |
||||
} |
||||
} |
||||
return nullptr; |
||||
} |
||||
|
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#include "H1Element.h" |
||||
#include "../TextNode.h" |
||||
#include <iostream> |
||||
|
||||
std::unique_ptr<Component> H1Element::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get()); |
||||
return std::make_unique<TextComponent>(textNode->text, 0, y, 24, true, windowWidth, windowHeight); |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
#ifndef H1ELEMENT_H |
||||
#define H1ELEMENT_H |
||||
|
||||
#include "../../graphics/opengl/components/Component.h" |
||||
#include "../../graphics/opengl/components/TextComponent.h" |
||||
#include "../Node.h" |
||||
|
||||
class H1Element { |
||||
public: |
||||
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight); |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#include "H2Element.h" |
||||
#include "../TextNode.h" |
||||
#include <iostream> |
||||
|
||||
std::unique_ptr<Component> H2Element::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get()); |
||||
return std::make_unique<TextComponent>(textNode->text, 0, y, 18, true, windowWidth, windowHeight); |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
#ifndef H2ELEMENT_H |
||||
#define H2ELEMENT_H |
||||
|
||||
#include "../../graphics/opengl/components/Component.h" |
||||
#include "../../graphics/opengl/components/TextComponent.h" |
||||
#include "../Node.h" |
||||
|
||||
class H2Element { |
||||
public: |
||||
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight); |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#include "H3Element.h" |
||||
#include "../TextNode.h" |
||||
#include <iostream> |
||||
|
||||
std::unique_ptr<Component> H3Element::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get()); |
||||
return std::make_unique<TextComponent>(textNode->text, 0, y, 14, true, windowWidth, windowHeight); // Should be 14.04pt
|
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
#ifndef H3ELEMENT_H |
||||
#define H3ELEMENT_H |
||||
|
||||
#include "../../graphics/opengl/components/Component.h" |
||||
#include "../../graphics/opengl/components/TextComponent.h" |
||||
#include "../Node.h" |
||||
|
||||
class H3Element { |
||||
public: |
||||
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight); |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#include "LIElement.h" |
||||
#include "../TextNode.h" |
||||
#include <iostream> |
||||
|
||||
std::unique_ptr<Component> LIElement::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get()); |
||||
return std::make_unique<TextComponent>("• " + textNode->text, 0, y, 12, false, windowWidth, windowHeight); |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
#ifndef LIELEMENT_H |
||||
#define LIELEMENT_H |
||||
|
||||
#include "../../graphics/opengl/components/Component.h" |
||||
#include "../../graphics/opengl/components/TextComponent.h" |
||||
#include "../Node.h" |
||||
|
||||
class LIElement { |
||||
public: |
||||
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight); |
||||
}; |
||||
|
||||
#endif |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
#include "PElement.h" |
||||
#include "../TextNode.h" |
||||
#include <iostream> |
||||
|
||||
std::unique_ptr<Component> PElement::render(const Node &node, int y, int windowWidth, int windowHeight) { |
||||
TextNode *textNode = dynamic_cast<TextNode*>(node.children[0].get()); |
||||
return std::make_unique<TextComponent>(textNode->text, 0, y, 12, false, windowWidth, windowHeight); |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
#ifndef PELEMENT_H |
||||
#define PELEMENT_H |
||||
|
||||
#include "../../graphics/opengl/components/Component.h" |
||||
#include "../../graphics/opengl/components/TextComponent.h" |
||||
#include "../Node.h" |
||||
|
||||
class PElement { |
||||
public: |
||||
static std::unique_ptr<Component> render(const Node &node, int y, int windowWidth, int windowHeight); |
||||
}; |
||||
|
||||
#endif |
Loading…
Reference in new issue