예제 #1
0
void LBXDataFile::open(const Common::String &filename) {
	_dataFile.clear();

	if (_dataFile.loadFromFile(filename))
		return;

	// FIXME: try savegames

	error("LBXDataFile::open: couldn't open '%s'", filename.c_str());
}
예제 #2
0
void FontProvider::initFonts() {
	// TODO: Use SystemFontMan instead when it gets merged
	_ttfFileMap["Garamond"] = "Gara.ttf";
	_ttfFileMap["Florentine Script"] = "flornt.TTF";
	_ttfFileMap["Folkard"] = "folkard.ttf";
	_ttfFileMap["Folkard\231"] = "folkard.ttf";
	_ttfFileMap["Arial"] = "ARIAL.TTF";
	_ttfFileMap["Bradley Hand ITC"] = "bradhitc.ttf";
	_ttfFileMap["Slurry"] = "SLURRY.TTF";
	_ttfFileMap["President Cyr"] = "President Cyr Regular.Ttf";
	_ttfFileMap["VictorianCyr"] = "Victorian Cyr.ttf";
	_ttfFileMap["Zapf Chance Italic"] = "Zapf Chance Italic.Ttf";
	_ttfFileMap["Arial_tlj"] = "arial_tlj.ttf";

	// Load the font settings from gui.ini when possible
	Common::INIFile gui;
	if (gui.loadFromFile("gui.ini")) {
		readFontEntry(&gui, _smallFont,        "smallfont", "smallheight");
		readFontEntry(&gui, _bigFont,          "bigfont",   "bigheight");
		readFontEntry(&gui, _customFonts[0],   "font0",     "fontsize0");
		readFontEntry(&gui, _customFonts[1],   "font1",     "fontsize1");
		readFontEntry(&gui, _customFonts[2],   "font2",     "fontsize2");
		readFontEntry(&gui, _customFonts[3],   "font3",     "fontsize3");
		readFontEntry(&gui, _customFonts[4],   "font4",     "fontsize4");
		readFontEntry(&gui, _customFonts[5],   "font5",     "fontsize5");
		readFontEntry(&gui, _customFonts[6],   "font6",     "fontsize6");
		readFontEntry(&gui, _customFonts[7],   "font7",     "fontsize7");
	} else {
		warning("Unable to open 'gui.ini' to read the font settings");
	}

	// Default fonts
	if (!_smallFont._font)      _smallFont      = FontHolder(this, "Garamond", 12);
	if (!_bigFont._font)        _bigFont        = FontHolder(this, "Florentine Script", 19);
	if (!_customFonts[0]._font) _customFonts[0] = FontHolder(this, "Folkard", 20);
	if (!_customFonts[1]._font) _customFonts[1] = FontHolder(this, "Folkard", 12);
	if (!_customFonts[2]._font) _customFonts[2] = FontHolder(this, "Arial", 14);
	if (!_customFonts[3]._font) _customFonts[3] = FontHolder(this, "Bradley Hand ITC", 16);
	if (!_customFonts[4]._font) _customFonts[4] = FontHolder(this, "Bradley Hand ITC", 20);
	if (!_customFonts[5]._font) _customFonts[5] = FontHolder(this, "Bradley Hand ITC", 16);
	if (!_customFonts[6]._font) _customFonts[6] = FontHolder(this, "Bradley Hand ITC", 15);
	if (!_customFonts[7]._font) _customFonts[7] = FontHolder(this, "Florentine Script", 13);
}
예제 #3
0
파일: TerrainApp.cpp 프로젝트: viticm/pap2
bool TerrainApp::Init()
{
	Common::INIFile inif;
	inif.SetFilename(m_sConfigFilename);
	inif.Open();

	Common::String sTemp;

	inif.GetINI("Window", "Title", m_sTitle);
	inif.GetINI("Window", "Width", sTemp);
	m_Width = sTemp.IntValue();
	inif.GetINI("Window", "Height", sTemp);
	m_Height = sTemp.IntValue();

	if(!InitWindow())  // Initialize the window
	{
		return false;
	}
	gLog.WriteLine("Window created OK!");

	// Inititalize the D3D

	Render::RenderCoreDesc rcdesc;
	memset(&rcdesc, 0, sizeof(rcdesc));

	rcdesc.m_hWnd = m_hWnd;  // HWND

	inif.GetINI("Render", "Adapter", sTemp);
	rcdesc.m_Adapter = sTemp.IntValue();  // Adapter

	inif.GetINI("HardwareRequirements", "DeviceType", sTemp);
	rcdesc.m_DeviceType = Render::IntToDevType((unsigned int)sTemp.IntValue());  // D3D device type

	inif.GetINI("Render", "ColorBits", sTemp);
	rcdesc.m_DisplayColorBits = sTemp.IntValue();  // Display color bits

	inif.GetINI("HardwareRequirements", "UsesMixedVertexProcessing", sTemp);
	rcdesc.HR_UsesMixedVP = (bool)sTemp.IntValue();

	inif.GetINI("HardwareRequirements", "MinimumStencilBits", sTemp);
	rcdesc.HR_MinStencilBits = sTemp.IntValue();

	rcdesc.m_PresentParameters.BackBufferWidth = m_Width;
	rcdesc.m_PresentParameters.BackBufferHeight = m_Height;

	rcdesc.m_PresentParameters.hDeviceWindow = m_hWnd;
	inif.GetINI("Render", "IsFullscreen", sTemp);
	rcdesc.m_PresentParameters.Windowed = !((bool)sTemp.IntValue());

	gLog.WriteLine("Try to initialize D3D...");
	if(!g_GetRenderCore()->Init(rcdesc))  //********** ==> Initializing D3D RenderCore
	{
		gLog.WriteLine("D3D initialization failed!");
		return false;
	}

	gLog.WriteLine("D3D initialized OK!");

	inif.GetINI("Terrain", "Name", sTemp);
	g_GetTerrainTree()->SetName(sTemp);

	inif.SetFilename(sTemp + ".ttd");
	inif.Open();
	inif.GetINI("TreeInfo", "CPX", sTemp);
	float cpx = sTemp.FloatValue();
	inif.GetINI("TreeInfo", "CPY", sTemp);
	float cpy = sTemp.FloatValue();
	inif.GetINI("TreeInfo", "CPZ", sTemp);
	float cpz = sTemp.FloatValue();
	g_GetTerrainTree()->CreateD3DResources();
	g_GetTerrainTree()->CreateQuadTree(cpx, cpy, cpz);

	inif.Close();


	m_Camera.Init(Maths::Vector3F(cpx, cpy + 256.f, cpz), Maths::Vector3F(cpx, cpy + 256.f, cpz + 100.f),
		Maths::Vector3F(0.f, 1.f, 0.f), 5.f, 30000.f, PI / 3, (float)m_Height / (float)m_Width);

	m_Camera.GetViewMatrix(m_mtxView);
	m_Camera.GetProjectionMatrix(m_mtxProj);

	m_pVB = g_GetRenderCore()->CreateVertexBuffer(3, sizeof(TEST_VERTEX), TEST_VERTEX_FVF);
	void* pVB = 0;
	m_pVB->Lock(0, 0, &pVB, 0);
	TEST_VERTEX varray[] =
	{
		0,   cpy + 256.f, 0, D3DCOLOR_XRGB(0, 255, 0),
		1024,  cpy + 256.f, -1024,  D3DCOLOR_XRGB(0, 255, 0),
		-1024, cpy + 256.f, -1024,  D3DCOLOR_XRGB(0, 0, 255)
	};

	memcpy(pVB, varray, 3 * sizeof(TEST_VERTEX));
	m_pVB->Unlock();

	return true;
}
예제 #4
0
bool LBXDataFile::call(uint callId, const Common::Array<LBValue> &params, LBValue &result) {
	switch (callId) {
	case kLBXDataFileOpen:
		if (params.size() != 1)
			error("incorrect number of parameters (%d) to LBXDataFile::open", params.size());

		open(params[0].toString());
		return false;

	case kLBXDataFileAddSection:
		if (params.size() != 1)
			error("incorrect number of parameters (%d) to LBXDataFile::addSection", params.size());

		_dataFile.addSection(params[0].toString());
		_curSection = params[0].toString();
		return false;

	case kLBXDataFileGetSectionList:
		{
		Common::SharedPtr<LBList> list = Common::SharedPtr<LBList>(new LBList);
		Common::INIFile::SectionList sections = _dataFile.getSections();
		for (Common::List<Common::INIFile::Section>::const_iterator i = sections.begin(); i != sections.end(); ++i)
			list->array.push_back(LBValue(i->name));
		result = LBValue(list);
		}
		return true;

	case kLBXDataFileSetCurSection:
		if (params.size() != 1)
			error("incorrect number of parameters (%d) to LBXDataFile::setCurSection", params.size());

		_curSection = params[0].toString();
		return false;

	case kLBXDataFileSetKey:
		if (params.size() != 2)
			error("incorrect number of parameters (%d) to LBXDataFile::setKey", params.size());

		_dataFile.setKey(params[0].toString(), _curSection, params[1].toString());
		return false;

	case kLBXDataFileLoadCurSectionVars:
		if (params.size() != 0)
			error("incorrect number of parameters (%d) to LBXDataFile::loadCurSectionVars", params.size());

		{
		const Common::INIFile::SectionKeyList globals = _dataFile.getKeys(_curSection);
		for (Common::INIFile::SectionKeyList::const_iterator i = globals.begin(); i != globals.end(); i++) {
			Common::String command = Common::String::format("%s = %s", i->key.c_str(), i->value.c_str());
			LBCode tempCode(_vm, 0);
			uint offset = tempCode.parseCode(command);
			tempCode.runCode(NULL, offset);
		}
		}
		return false;

	case kLBXDataFileDeleteCurSection:
		if (params.size() != 0)
			error("incorrect number of parameters (%d) to LBXDataFile::deleteCurSection", params.size());

		_dataFile.removeSection(_curSection);
		return false;

	case kLBXDataFileSectionExists:
		if (params.size() != 1)
			error("incorrect number of parameters (%d) to LBXDataFile::sectionExists", params.size());
		if (_dataFile.hasSection(params[0].toString()))
			result = 1;
		else
			result = 0;
		return true;

	default:
		error("LBXDataFile call %d is unknown", callId);
	}
}