1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
// $Id: Application.cpp,v 1.23 2002/10/14 05:14:41 mrq Exp $
#include <fstream>
#include <map>
#include <Ark/ArkDataClass.h>
#include <Ark/ArkConfig.h>
#include <Ark/ArkRenderer.h>
#include <Ark/ArkSystem.h>
#include <Ark/ArkCollision.h>
#include <Modules/Renderer/GLRenderer.h>
#include "Application.h"
#include "HeightOps.h"
#include "Tool.h"
#include "CommandStack.h"
static void LoadClassList(const std::string&, Ark::Config*, Ark::ClassList*);
//=============================================================================
// Application Singleton
Application *g_Application = 0;
Application*
Application::GetApplication()
{
assert (g_Application != 0);
return g_Application;
}
//=============================================================================
Application::Application (UI *ui) :
m_UI (ui)
{
g_Application = this;
m_View = new TerrainView();
Ark::String elib = Ark::Sys()->Cfg()->GetStr
("server::EntityLib",
"{game}/scripts/entities.lib");
Ark::Config cfg;
cfg.Load (elib);
m_Classes = new Ark::ClassList();
LoadClassList("Entity", &cfg, m_Classes);
}
Application::~Application ()
{
delete m_Classes;
delete m_View;
}
//=============================================================================
//=============================================================================
void
Application::SetView(ViewWidget* view)
{
m_View->SetView(view);
ToolHelper::SetView (view);
WorldHelper::SetView (view);
if (GetWorld())
{
m_View->Center();
m_View->Update();
}
}
static void LoadClassList(const std::string& name,
Ark::Config *cfg,
Ark::ClassList *classlist)
{
std::string filename;
Ark::String fname;
filename = name + "::ClassDef";
fname = filename.c_str();
Ark::String datadef = cfg->GetStr(fname, "");
if (datadef != "")
{
classlist->Load(datadef);
}
filename = name + "::Templates";
fname = filename.c_str();
Ark::String templates = cfg->GetStr(fname, "");
if (templates != "")
{
classlist->LoadTemplates(templates);
}
}
|