Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 6af390316d14560df255f7eb3cc7770ca99b0097 (plain)
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
/*
   core/parser.h
   This file is part of the Osirion project and is distributed under
   the terms of the GNU General Public License version 2
*/

#include "core/parser.h"
#include "auxiliary/functions.h"
#include "sys/sys.h"

namespace core {

bool Parser::read_entity_menu(core::Entity *entity, const std::string &menufilename)
{
	filesystem::IniFile inifile;
	inifile.open(menufilename);

	if (!inifile.is_open()) {
		return false;
	}

	con_debug << "  " << inifile.name() << std::endl;

	inifile.close();
	return true;
}

bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity)
{
	std::string shapename;
	std::string strval;
	float direction;
	float pitch;
	float roll;

	if (inifile.got_key_string("shape", shapename)) {

		if (shapename.compare("axis") == 0) {
			entity->entity_shape = core::Entity::Axis;
			return true;
		} else if (shapename.compare("cube") == 0) {
			entity->entity_shape = core::Entity::Cube;
			return true;
		} else if (shapename.compare("diamond") == 0) {
			entity->entity_shape = core::Entity::Diamond;
			return true;
		} else if (shapename.compare("sphere") == 0) {
			entity->entity_shape = core::Entity::Sphere;
			return true;
		} else {
			con_warn << inifile.name() << " unknown shape '" << shapename << "' at line " << inifile.line() << std::endl;
			return false;
		}

	} else if (inifile.got_key_string("label", strval)) {
		entity->set_label(strval);
		return true;
	} else if (inifile.got_key_string("name", strval)) {
		entity->set_name(strval);
		return true;
	} else if (inifile.got_key_string("model", strval)) {
		entity->set_modelname(strval);
		return true;
	} else if (inifile.got_key_angle("direction", direction)) {
		entity->axis().change_direction(direction);
		return true;
	} else if (inifile.got_key_angle("pitch", pitch)) {
		entity->axis().change_pitch(pitch);
		return true;
	} else if (inifile.got_key_angle("roll", roll)) {
		entity->axis().change_roll(roll);
		return true;
	} else if (inifile.got_key_angle("radius", entity->entity_radius)) {
		return true;
	} else if (inifile.got_key_vector3f("location", entity->entity_location)) {
		return true;
	} else if (inifile.got_key_color("color", entity->entity_color)) {
		return true;
	} else if (inifile.got_key_color("colorsecond", entity->entity_color_second)) {
		return true;
	}

	return false;
}

}