diff options
Diffstat (limited to 'config.h')
-rw-r--r-- | config.h | 174 |
1 files changed, 174 insertions, 0 deletions
diff --git a/config.h b/config.h new file mode 100644 index 0000000..46a3cfc --- /dev/null +++ b/config.h @@ -0,0 +1,174 @@ +// +// glgrav - OpenGL N-Body gravity simulator +// +// Copyright (C) 2003 Ian Cowburn (ianc@noddybox.demon.co.uk) +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// ------------------------------------------------------------------------- +// +// Data file handling +// +// $Id$ +// +#ifndef CONFIG_H + +#define CONFIG_H + +#include "global.h" +#include <fstream> +#include "mass.h" + +class Config + { + public: + enum Flag {solid, lighting, texture, fog, num_flags}; + enum Collide {none, merge, delta_merge, shatter}; + + Config(); + virtual ~Config(); + + // Note that the vector is added to. It must be cleared beforehand + // if required. + // + bool read(const string& file, vector<Mass>& mass); + + void getCamera(GLfloat& x, GLfloat& y, GLfloat& z, GLfloat& yaw) const; + + bool enabled(Flag flag) const; + Collide collide() const; + string light(GLfloat v[4]) const; + double gravConst() const; + double scale() const; + + void windowSize(int& w,int& h) const; + + void getShatter(int& num, double& delta, + double& min_mass, double& max_mass, + int& shield) const; + + bool sparksDefined() const; + + void getSparks(int& num, GLfloat& alpha_dec, GLfloat& alpha_min, + int& length, GLfloat& delta) const; + + size_t maxMass() const; + + // Args set to -1 if undefined + // + void getLookAndTravel(int& look, int &travel) const; + + bool particlesDefined() const; + + void getParticles(GLfloat& alpha_dec, GLfloat& alpha_min, + GLfloat& size) const; + + void getFog(GLfloat& dist, GLfloat& r, GLfloat& g, GLfloat& b, + bool& fog_light); + + void look(vector<string>& l) const; + + string error() const; + + private: + enum Plane {xy_plane, xz_plane, yz_plane}; + + Plane m_plane; + + string m_error; + bool m_flag[num_flags]; + Collide m_collide; + double m_const; + GLfloat m_x,m_y,m_z,m_pitch,m_yaw; + + double m_scale; + + string m_light; + GLfloat m_lr,m_lg,m_lb; + + vector<string> m_look; + int m_look_at; + int m_travel_as; + + bool m_particles; + GLfloat m_p_adec; + GLfloat m_p_amin; + GLfloat m_p_size; + + GLuint *m_glid; + int m_glid_no; + int m_glid_idx; + + int m_s_no; + double m_s_delta; + double m_s_min; + double m_s_max; + int m_s_shield; + + bool m_sparks; + int m_sp_no; + GLfloat m_sp_adec; + GLfloat m_sp_amin; + int m_sp_length; + GLfloat m_sp_delta; + + int m_winw; + int m_winh; + + size_t m_max_mass; + + GLfloat m_fog_dist; + GLfloat m_fog_r; + GLfloat m_fog_g; + GLfloat m_fog_b; + bool m_fog_light; + + enum Command {enable_cmd, disable_cmd, collide_cmd, const_cmd, + body_cmd, radial_cmd, light_cmd, camera_cmd, look_cmd, + texture_cmd, num_texture_cmd, reuse_cmd, particles_cmd, + shatter_cmd, multiple_cmd, mreuse_cmd, plane_cmd, + scale_cmd, look_at_cmd, travel_as_cmd, window_size_cmd, + sparks_cmd, max_mass_cmd, mlook_cmd, + ring_cmd, mring_cmd, ring_texture_cmd, ring_reuse_cmd, + ring_mreuse_cmd, fog_cmd, + cmd_eof, cmd_error}; + + enum GetWordStatus {GWOK, GWEof, GWSyntax, + GWTooFewArgs, GWTooManyArgs}; + + bool CompareNoCase(const string& s1, const string& s2); + GetWordStatus getWord(ifstream& fp, string& word, + const string& ignore, const string& term); + bool getCommand(ifstream& fp, Command& cmd, vector<string>& val); + + void genRadial(Mass **newMass, const Mass& parent, + const string& name, double mass, + double dist, double ang, double spd, + GLfloat r, GLfloat g, GLfloat b, double rot); + + double toDouble(const string& s); + GLfloat toGLfloat(const string& s); + int toInt(const string& s); + size_t toSize(const string& s); + bool toYesNo(const string& s); + + bool bindTexture(const string& name, int w, int h, GLuint id); + + string makeName(string& name, int no); + }; + +#endif + +// END OF FILE // |