metaforce/Editor/main.cpp

106 lines
2.9 KiB
C++
Raw Normal View History

2015-11-21 01:16:07 +00:00
#include <LogVisor/LogVisor.hpp>
#include <boo/boo.hpp>
#include <Specter/Specter.hpp>
2015-11-22 06:51:25 +00:00
#include <Runtime/CVarManager.hpp>
#include <Runtime/CGameAllocator.hpp>
2015-11-22 08:01:51 +00:00
#include <functional>
2015-11-21 01:16:07 +00:00
namespace RUDE
{
struct Application : boo::IApplicationCallback
{
2015-11-22 04:35:24 +00:00
HECL::Runtime::FileStoreManager m_fileMgr;
Specter::FontCache m_fontCache;
2015-11-21 01:16:07 +00:00
boo::IWindow* m_mainWindow;
2015-11-26 00:25:17 +00:00
Specter::ViewSystem m_viewSystem;
2015-11-30 00:22:21 +00:00
std::unique_ptr<Specter::RootView> m_rootView;
2015-11-26 00:25:17 +00:00
Retro::CVarManager m_cvarManager;
2015-11-22 08:01:51 +00:00
Zeus::CColor m_clearColor;
2015-11-22 04:35:24 +00:00
bool m_running = true;
2015-11-22 08:01:51 +00:00
void onCVarModified(Retro::CVar* cvar)
{
if (cvar == m_cvarManager.findCVar("r_clearColor"))
m_clearColor = cvar->toColor();
}
2015-11-23 08:47:57 +00:00
Application() :
m_fileMgr(_S("rude")),
m_fontCache(m_fileMgr),
2015-11-26 07:38:56 +00:00
m_cvarManager(m_fileMgr) {}
2015-11-22 04:35:24 +00:00
2015-11-21 01:16:07 +00:00
int appMain(boo::IApplication* app)
{
m_mainWindow = app->newWindow(_S("RUDE"));
2015-11-30 00:22:21 +00:00
m_mainWindow->setWaitCursor(true);
2015-11-22 06:51:25 +00:00
m_cvarManager.serialize();
2015-11-22 08:01:51 +00:00
Retro::CVar* tmp = m_cvarManager.findCVar("r_clearcolor");
Retro::CVar::ListenerFunc listen = std::bind(&Application::onCVarModified, this, std::placeholders::_1);
if (tmp)
tmp->addListener(listen);
2015-11-22 04:35:24 +00:00
2015-11-23 08:47:57 +00:00
boo::IGraphicsDataFactory* gf = m_mainWindow->getMainContextDataFactory();
2015-11-26 00:25:17 +00:00
m_viewSystem.init(gf, &m_fontCache);
2015-11-30 00:22:21 +00:00
m_rootView.reset(new Specter::RootView(m_viewSystem, m_mainWindow));
2015-11-26 00:25:17 +00:00
2015-11-27 22:21:19 +00:00
m_mainWindow->showWindow();
2015-11-30 00:22:21 +00:00
m_mainWindow->setWaitCursor(false);
2015-11-26 07:38:56 +00:00
boo::IGraphicsCommandQueue* gfxQ = m_mainWindow->getCommandQueue();
2015-11-22 04:35:24 +00:00
while (m_running)
{
2015-11-30 00:22:21 +00:00
if (m_rootView->isDestroyed())
2015-11-26 23:04:11 +00:00
break;
2015-11-22 08:01:51 +00:00
m_cvarManager.update();
2015-11-22 04:35:24 +00:00
m_mainWindow->waitForRetrace();
2015-11-30 00:22:21 +00:00
m_rootView->draw(gfxQ);
2015-11-26 07:38:56 +00:00
gfxQ->flushBufferUpdates();
gfxQ->execute();
2015-11-22 04:35:24 +00:00
}
2015-11-21 01:16:07 +00:00
return 0;
}
void appQuitting(boo::IApplication*)
{
2015-11-22 04:35:24 +00:00
m_running = false;
2015-11-21 01:16:07 +00:00
}
void appFilesOpen(boo::IApplication*, const std::vector<boo::SystemString>&)
{
}
2015-11-22 04:35:24 +00:00
2015-11-21 01:16:07 +00:00
};
}
#if _WIN32
int wmain(int argc, const boo::SystemChar** argv)
#else
int main(int argc, const boo::SystemChar** argv)
#endif
{
LogVisor::RegisterConsoleLogger();
RUDE::Application appCb;
int ret = ApplicationRun(boo::IApplication::EPlatformType::Auto,
appCb, _S("rude"), _S("RUDE"), argc, argv);
printf("IM DYING!!\n");
return ret;
}
#if _WIN32
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int)
{
int argc = 0;
const boo::SystemChar** argv = (const wchar_t**)(CommandLineToArgvW(lpCmdLine, &argc));
static boo::SystemChar selfPath[1024];
GetModuleFileNameW(nullptr, selfPath, 1024);
static const boo::SystemChar* booArgv[32] = {};
booArgv[0] = selfPath;
for (int i=0 ; i<argc ; ++i)
booArgv[i+1] = argv[i];
LogVisor::CreateWin32Console();
return wmain(argc+1, booArgv);
}
#endif