1
0
forked from 0ad/0ad

Make CGUIManager register a callback function for hotloading instead of specifically calling it.

This was SVN commit r15482.
This commit is contained in:
leper 2014-07-02 23:44:39 +00:00
parent 30e851ab90
commit ffd6e10edf
3 changed files with 11 additions and 7 deletions

View File

@ -47,16 +47,23 @@ InReaction gui_handler(const SDL_Event_* ev)
return g_GUI->HandleEvent(ev);
}
static Status ReloadChangedFileCB(void* param, const VfsPath& path)
{
return static_cast<CGUIManager*>(param)->ReloadChangedFile(path);
}
CGUIManager::CGUIManager()
{
m_ScriptRuntime = g_ScriptRuntime;
m_ScriptInterface.reset(new ScriptInterface("Engine", "GUIManager", m_ScriptRuntime));
m_ScriptInterface->SetCallbackData(this);
m_ScriptInterface->LoadGlobalScripts();
RegisterFileReloadFunc(ReloadChangedFileCB, this);
}
CGUIManager::~CGUIManager()
{
UnregisterFileReloadFunc(ReloadChangedFileCB, this);
}
bool CGUIManager::HasPages()
@ -259,7 +266,7 @@ void CGUIManager::LoadPage(SGUIPage& page)
previousPageScriptInterface.reset();
}
Status CGUIManager::ReloadChangedFiles(const VfsPath& path)
Status CGUIManager::ReloadChangedFile(const VfsPath& path)
{
for (PageStackType::iterator it = m_PageStack.begin(); it != m_PageStack.end(); ++it)
{

View File

@ -88,9 +88,9 @@ public:
void DisplayMessageBox(int width, int height, const CStrW& title, const CStrW& message);
/**
* Call when a file has bee modified, to hotload pages if their .xml files changed.
* Called when a file has been modified, to hotload changes.
*/
Status ReloadChangedFiles(const VfsPath& path);
Status ReloadChangedFile(const VfsPath& path);
/**
* Pass input events to the currently active GUI page.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2014 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -18,7 +18,6 @@
#include "precompiled.h"
#include "Filesystem.h"
#include "gui/GUIManager.h"
#include "ps/CLogger.h"
#include "ps/Profile.h"
@ -84,8 +83,6 @@ Status ReloadChangedFiles()
// Tell each hotloadable system about this file change:
RETURN_STATUS_IF_ERR(g_GUI->ReloadChangedFiles(pathname));
for (size_t j = 0; j < g_ReloadFuncs.size(); ++j)
g_ReloadFuncs[j].first(g_ReloadFuncs[j].second, pathname);