added message system
This commit is contained in:
parent
e292902cbd
commit
7911e7bddf
@ -19,14 +19,14 @@ Engine::Engine() :
|
|||||||
m_clock = new sf::Clock();
|
m_clock = new sf::Clock();
|
||||||
m_clock->restart();
|
m_clock->restart();
|
||||||
m_renderer = new SparrowRenderer();
|
m_renderer = new SparrowRenderer();
|
||||||
m_renderer->setCamera(NULL);
|
// m_renderer->setCamera(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine::~Engine()
|
Engine::~Engine()
|
||||||
{
|
{
|
||||||
delete m_clock;
|
delete m_clock;
|
||||||
if(m_window != NULL)
|
if(m_window != NULL)
|
||||||
m_renderer->destroyGL();
|
// m_renderer->destroyGL();
|
||||||
delete m_renderer;
|
delete m_renderer;
|
||||||
if(m_window != NULL)
|
if(m_window != NULL)
|
||||||
{
|
{
|
||||||
|
7
src/message.cpp
Normal file
7
src/message.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "message.h"
|
||||||
|
|
||||||
|
|
||||||
|
Message::Message(std::string id, SystemType sender):m_id(id),m_sender(sender)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
18
src/message.h
Normal file
18
src/message.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef MESSAGE_H
|
||||||
|
#define MESSAGE_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
|
class Message
|
||||||
|
{
|
||||||
|
std::string m_id;
|
||||||
|
SystemType m_sender;
|
||||||
|
public:
|
||||||
|
Message(std::string,SystemType);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MESSAGE_H
|
11
src/messagebus.cpp
Normal file
11
src/messagebus.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "messagebus.h"
|
||||||
|
|
||||||
|
MessageBus::MessageBus()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageBus::postMessage(Message *msg)
|
||||||
|
{
|
||||||
|
message_list.push_back(msg);
|
||||||
|
}
|
18
src/messagebus.h
Normal file
18
src/messagebus.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef MESSAGEBUS_H
|
||||||
|
#define MESSAGEBUS_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Message;
|
||||||
|
|
||||||
|
class MessageBus
|
||||||
|
{
|
||||||
|
std::vector<Message*> message_list; //message file
|
||||||
|
|
||||||
|
public:
|
||||||
|
MessageBus();
|
||||||
|
void postMessage(Message* msg);
|
||||||
|
void handleMessage();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MESSAGEBUS_H
|
7
src/system.cpp
Normal file
7
src/system.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "system.h"
|
||||||
|
|
||||||
|
|
||||||
|
System::System()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
20
src/system.h
Normal file
20
src/system.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef SYSTEM_H
|
||||||
|
#define SYSTEM_H
|
||||||
|
|
||||||
|
class MessageBus;
|
||||||
|
class Message;
|
||||||
|
|
||||||
|
//TODO:complete this part with other existing system,
|
||||||
|
enum SystemType {INPUT_SYSTEM, RENDERER_SYSTEM, IA_SYSTEM};
|
||||||
|
|
||||||
|
class System
|
||||||
|
{
|
||||||
|
SystemType m_type;
|
||||||
|
MessageBus* m_msgBus;
|
||||||
|
|
||||||
|
public:
|
||||||
|
System();
|
||||||
|
virtual void handleMessage(Message* message) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SYSTEM_H
|
@ -18,7 +18,7 @@ public:
|
|||||||
void addNeighbours(GraphNode*,float);
|
void addNeighbours(GraphNode*,float);
|
||||||
void addNeighbours(GraphEdge);
|
void addNeighbours(GraphEdge);
|
||||||
int getNbNeighbours();
|
int getNbNeighbours();
|
||||||
virtual float heuristic(GraphNode*){return 1;};
|
virtual float heuristic(GraphNode*){return 1;}
|
||||||
|
|
||||||
void setValue(int);
|
void setValue(int);
|
||||||
int getValue();
|
int getValue();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
|
#include <cstring>
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
#include <SFML/Graphics/Image.hpp>
|
#include <SFML/Graphics/Image.hpp>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user