mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 04:03:59 +02:00
commit
abee08c91a
4 changed files with 45 additions and 3 deletions
|
@ -151,6 +151,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
|
||||
NodeList::getInstance()->addHook(&_voxels);
|
||||
NodeList::getInstance()->addHook(this);
|
||||
NodeList::getInstance()->addDomainListener(this);
|
||||
|
||||
|
||||
// network receive thread and voxel parsing thread are both controlled by the --nonblocking command line
|
||||
|
@ -231,6 +232,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
Application::~Application() {
|
||||
NodeList::getInstance()->removeHook(&_voxels);
|
||||
NodeList::getInstance()->removeHook(this);
|
||||
NodeList::getInstance()->removeDomainListener(this);
|
||||
|
||||
_sharedVoxelSystem.changeTree(new VoxelTree);
|
||||
|
||||
|
@ -309,8 +311,6 @@ void Application::initializeGL() {
|
|||
char title[50];
|
||||
sprintf(title, "Interface: %4.2f seconds\n", startupTime);
|
||||
qDebug("%s", title);
|
||||
_window->setWindowTitle(title);
|
||||
|
||||
const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
|
||||
|
||||
// ask the Logstash class to record the startup time
|
||||
|
@ -3422,6 +3422,11 @@ void Application::attachNewHeadToNode(Node* newNode) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::domainChanged(QString domain) {
|
||||
qDebug("Application title set to: %s.\n", domain.toStdString().c_str());
|
||||
_window->setWindowTitle(domain);
|
||||
}
|
||||
|
||||
void Application::nodeAdded(Node* node) {
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ static const float NODE_KILLED_RED = 1.0f;
|
|||
static const float NODE_KILLED_GREEN = 0.0f;
|
||||
static const float NODE_KILLED_BLUE = 0.0f;
|
||||
|
||||
class Application : public QApplication, public NodeListHook, public PacketSenderNotify {
|
||||
class Application : public QApplication, public NodeListHook, public PacketSenderNotify, public DomainChangeListener {
|
||||
Q_OBJECT
|
||||
|
||||
friend class VoxelPacketProcessor;
|
||||
|
@ -146,6 +146,8 @@ public:
|
|||
virtual void nodeKilled(Node* node);
|
||||
virtual void packetSentNotification(ssize_t length);
|
||||
|
||||
virtual void domainChanged(QString domain);
|
||||
|
||||
VoxelShader& getVoxelShader() { return _voxelShader; }
|
||||
|
||||
public slots:
|
||||
|
|
|
@ -109,6 +109,7 @@ void NodeList::setDomainHostname(const QString& domainHostname) {
|
|||
|
||||
// reset our _domainIP to the null address so that a lookup happens on next check in
|
||||
_domainIP.clear();
|
||||
notifyDomainChanged();
|
||||
}
|
||||
|
||||
void NodeList::timePingReply(sockaddr *nodeAddress, unsigned char *packetData) {
|
||||
|
@ -585,6 +586,7 @@ void NodeList::loadData(QSettings *settings) {
|
|||
|
||||
if (domainServerHostname.size() > 0) {
|
||||
_domainHostname = domainServerHostname;
|
||||
notifyDomainChanged();
|
||||
}
|
||||
|
||||
settings->endGroup();
|
||||
|
@ -678,6 +680,21 @@ void NodeListIterator::skipDeadAndStopIncrement() {
|
|||
}
|
||||
}
|
||||
|
||||
void NodeList::addDomainListener(DomainChangeListener* listener) {
|
||||
_domainListeners.push_back(listener);
|
||||
QString domain = _domainHostname.isEmpty() ? _domainIP.toString() : _domainHostname;
|
||||
listener->domainChanged(domain);
|
||||
}
|
||||
|
||||
void NodeList::removeDomainListener(DomainChangeListener* listener) {
|
||||
for (int i = 0; i < _domainListeners.size(); i++) {
|
||||
if (_domainListeners[i] == listener) {
|
||||
_domainListeners.erase(_domainListeners.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::addHook(NodeListHook* hook) {
|
||||
_hooks.push_back(hook);
|
||||
}
|
||||
|
@ -704,3 +721,9 @@ void NodeList::notifyHooksOfKilledNode(Node* node) {
|
|||
_hooks[i]->nodeKilled(node);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::notifyDomainChanged() {
|
||||
for (int i = 0; i < _domainListeners.size(); i++) {
|
||||
_domainListeners[i]->domainChanged(_domainHostname);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,10 @@ public:
|
|||
virtual void nodeKilled(Node* node) = 0;
|
||||
};
|
||||
|
||||
class DomainChangeListener {
|
||||
public:
|
||||
virtual void domainChanged(QString domain) = 0;
|
||||
};
|
||||
|
||||
class NodeList {
|
||||
public:
|
||||
|
@ -136,6 +140,9 @@ public:
|
|||
void notifyHooksOfAddedNode(Node* node);
|
||||
void notifyHooksOfKilledNode(Node* node);
|
||||
|
||||
void addDomainListener(DomainChangeListener* listener);
|
||||
void removeDomainListener(DomainChangeListener* listener);
|
||||
|
||||
private:
|
||||
static NodeList* _sharedInstance;
|
||||
|
||||
|
@ -167,6 +174,11 @@ private:
|
|||
void timePingReply(sockaddr *nodeAddress, unsigned char *packetData);
|
||||
|
||||
std::vector<NodeListHook*> _hooks;
|
||||
std::vector<DomainChangeListener*> _domainListeners;
|
||||
|
||||
void resetDomainData(char domainField[], const char* domainData);
|
||||
void notifyDomainChanged();
|
||||
void domainLookup();
|
||||
};
|
||||
|
||||
class NodeListIterator : public std::iterator<std::input_iterator_tag, Node> {
|
||||
|
|
Loading…
Reference in a new issue