bsp
settings.h
00001 #ifndef _SETTINGS_H_
00002 #define _SETTINGS_H_
00003 
00004 // BSP Settings
00005 
00006 #include "bsphdr.h"
00007 
00008 #define FONT_NAME_LEN 64
00009 
00010 class BSPSettings
00011 {
00012 public:
00013     BSPSettings();
00014     ~BSPSettings();
00015 
00016     // game.cfg settings
00017     int game;
00018     char default_mapfile[MAX_PATH];
00019     char entity_directory[MAX_PATH];
00020     char entity_file[MAX_PATH];
00021     char texture_path[MAX_PATH];
00022     char pak_file[MAX_PATH];
00023     char wad_directory[MAX_PATH];
00024     char default_wad[MAX_PATH];
00025     char map_directory[MAX_PATH];
00026     char bat_directory[MAX_PATH];
00027     char palette_file[MAX_PATH];
00028     char model_file[MAX_PATH];
00029     int sort_entities;
00030     int no_models;
00031     float gamma;
00032     float world_minmax;
00033     int fake_colormap;
00034     char apptitle[MAX_PATH];
00035     int gl_highres;
00036     char *gl_highres_path;
00037     int gl_trans_ents;
00038 
00039 
00040     // general
00041     int draw_old_style;
00042     int query_wall_width;
00043     int caption_percent;
00044     int caption_font_size;
00045     char caption_font[FONT_NAME_LEN];
00046     char help_font[FONT_NAME_LEN];
00047     int help_font_size;
00048     int nothresholdundo;
00049     int undo_threshold;
00050     int bsp_font_size;
00051     char bsp_font[FONT_NAME_LEN];
00052     int num_recent;
00053     char game_directory[MAX_PATH];
00054     char console_font[FONT_NAME_LEN];
00055     int console_font_size;
00056 
00057     // GL
00058     int gl_model_bbox;
00059     int gl_mode_default;
00060     int gl_shading;
00061     int gl_fog;
00062     int gl_fog_near;
00063     int gl_fog_far;
00064     int gl_fog_match_bg;
00065     COLORREF gl_fog_color;
00066     COLORREF gl_light_color;
00067     COLORREF gl_ambient_color;
00068     int gl_alpha_level;
00069     int gl_full_res_texture;
00070     int gl_wire_use_groupcolor;
00071     char gl_texturemode[64];
00072     int gl_brightness;
00073     int gl_selection_wiremode;
00074     int gl_enable_stencil;
00075     int gl_skybox;
00076     int gl_skybox_auto;
00077     char gl_skybox_path[MAX_PATH];
00078     char gl_skybox_name[64];
00079 
00080     //groups
00081     int group_font_size;
00082     int group_toolbar;
00083     int group_mode;
00084 
00085     //entity
00086     int entity_button_size;
00087     int entity_font_size;
00088     int entity_window_width;
00089     int entity_comment_size;
00090     int entity_keypair_size;
00091     int entity_inline_help;
00092 
00093     //texture
00094     int texture_width;
00095     int texture_height;
00096     int stretch_textures;
00097     int show_favorites;
00098     int show_frequent;
00099     int tex_numfav;
00100     int tex_numfrq;
00101     int height_fav;
00102     int height_frq;
00103     int tex_field_width;
00104     int show_tex_names;
00105     int texture_alignment;
00106     int texture_list_width;
00107     int nosmallstretch;
00108     int tex_animate;
00109     int tex_timerdelay;
00110     int tex_small_height;
00111     int tex_small_width;
00112     int tex_animatesky;
00113     int tex_skyspeed;
00114     int autocalc_frequents;
00115     int animate_models;
00116     int texlist_size;
00117     float tex_shiftstep;
00118     float tex_scalestep;
00119     float tex_rotatestep;
00120 
00121 
00122     // cameras
00123     int show_camera_angle;
00124     int show_cameras;
00125     int camera_angle_length;
00126     int lock_cameras;
00127     vec3_t lock_camera_offset;
00128     int camera_size;
00129     int camera_font_size;
00130 
00131 
00132     //colors
00133     COLORREF color_3dbackground;
00134     COLORREF color_gridmajor;
00135     COLORREF color_gridminor;
00136     COLORREF color_foreground;
00137     COLORREF color_background;
00138     COLORREF color_otherclipface;
00139     COLORREF color_currentclipface;
00140     COLORREF color_clipborder;
00141     COLORREF color_connection;
00142     COLORREF color_selection;
00143     COLORREF color_otherbrush;
00144     COLORREF color_curface;
00145     COLORREF color_hitbrush;
00146     COLORREF color_gridlabel;
00147     COLORREF color_eyemarker;
00148     COLORREF color_activecamera;
00149     COLORREF color_othercamera;
00150     COLORREF color_textureselection;
00151     COLORREF color_lock;
00152     COLORREF color_texturewindow;
00153     COLORREF color_3dgrid;
00154     COLORREF color_selectedtexture;
00155     COLORREF color_selectoutline;
00156     COLORREF color_faceoutline;
00157     COLORREF color_brushoutline;
00158     COLORREF color_consolefg;
00159     COLORREF color_consolebg;
00160 
00161 
00162     //clippers
00163     int animate_clip_points;
00164     int undo_clipper;
00165     int clipper_show_outline;
00166     int track_clippers;
00167     int clipper_autoflip;
00168     int clipper_mode;
00169     int clippers_stay;
00170     int querysplits;
00171 
00172 
00173     //editing
00174     int clone_delta_x;
00175     int clone_delta_y;
00176     int clone_delta_disable;
00177     int snap_back;                                      //snap vertices back to grid if they are not on it when manip
00178     int look_at_sel;                            // camera will lock onto selection
00179     int new_brush_depth;
00180     int extrude_depth;
00181     int disable_rotation_texlock;
00182     int edge_use_grid;
00183     int multi_select;
00184     float max_face_gap;
00185     float min_epsilon;
00186     float max_epsilon;
00187     float max_normal_delta;
00188     float max_point_distance;
00189     float on_plane_epsilon;
00190     float multi_face_normal_eps;
00191     float multi_face_distance_eps;
00192     int vertex_select_mode;
00193     int vertex_drag_sensitivity;
00194     float face_drag;
00195     int select_delta;
00196     int vertex_use_grid;
00197     float distance_epsilon;
00198 
00199 
00200     //display
00201     int draw_models;
00202     int texture_models;
00203     int gridsize;
00204     int wire_ents;
00205     int use_crosshair;
00206     int outline_use_group;
00207     int select_delay;
00208     int drag_brushes;
00209     float scale;
00210     int steps_per_turn;
00211     float stepsize;
00212     int mlook_vert_step;
00213     int mlook_horiz_step;
00214     int xy_drag_move;
00215     int rotate_step;
00216     int grid_smallmajor;                                        //user smaller major grid dots in dot grid mode
00217     int grid_style;                                                     //0=lines, 1=dots
00218     int angle_control;
00219     int show_grid;
00220     int show_coordinates;
00221     int show_names;
00222     int show_hits;
00223     float fov;
00224     int flymode;
00225     int ghosts_3d;
00226     int ghosts_xy;
00227     int track3dinxy;
00228     int trackxyin3d;
00229     int track3dincurrentxy;
00230     int warn_spaces;                                            // warn if spaces in map name
00231     int zero_crosshair;
00232     int region_clip_grid;
00233     int region_ignore;
00234     int color_wire;
00235     int cull_wire;
00236     int selection_thickness;
00237     int flats_like_texture;
00238     int center_knobs_xy;
00239     int center_knobs_3d;
00240     int center_knobs_use_x;
00241     float center_knobs_scale;
00242     int facelighting;
00243     float lightintensity;
00244     float ambientintensity;
00245     int flatlevel;
00246     int shadeflats;
00247     int shadetextures;
00248     int drawmode;
00249     int render_width;
00250     int render_height;
00251     int render_auto;
00252     int render_trans;   //0=off,1=lines,2=dots
00253 
00254 
00255 
00259     int game_mode;
00260     int gl_texturemode_value;
00261     bool gl_skynames_loaded;
00262     // For 256 Color modes...
00263     int outlineIndex;
00264     int selectedIndex;
00265     int faceIndex;
00266     int lockIndex;
00267     //  For RGB Color Modes...
00268 
00269     // Window Positions
00270     int curCfg;
00271 
00272 
00273 
00274     int show_texturedrag;
00275     int track_leaks;
00276     int track_portals;
00277     int show_results;
00278     int region_mode;
00279     int render_connections;
00280     int show_connections;
00281     int show_drag;
00282     int redrawxy;
00283     int redrawedit;
00284     int Map_Read;
00285     int outline;
00286     int show_eye;
00287 
00288     // XY View Settings
00289 
00290 
00291 
00292     int xyViews;
00293     int curxy;
00294 
00295 
00296     // Renderer Settings;
00297     float ppd;
00298     float mag;
00299     bool auto_init;
00300     int lastw, lasth;
00301     float angstep;
00302     float Q[4][4];
00303     float R[4][4];
00304     int currentMode;
00305     // Texture Settings
00306     char rgborder[4];
00307     char rgb16order[4];
00308 
00309     int loadInUse;
00310     // Directories/Filenames
00311     char gfx_dir[MAX_PATH];
00312     char loadfile[MAX_PATH];
00313     char main_dir[MAX_PATH];
00314 
00315 
00316     // QII Stuff
00317     int pakOk;
00318     // Map Settings
00319     int filter_detail;
00320     int filter_hint;
00321     int filter_unselected;
00322     int filter_light;
00323     int filter_entities;
00324     int filter_world;
00325     int filter_clip_brushes;
00326     int filter_water_brushes;
00327     int filter_path;
00328     int filter_target;
00329     int filter_sky;
00330     int nummaps;
00331     int curmap;
00332     int show_3d_grid;
00333     int show_world_axes;
00334 
00335     // Misc
00336     int scx, scy;
00337     int autoSaveCounter;
00338     int autoSaveMinutes;
00339     char szAutoLoadFile[MAX_PATH];
00340 
00341     // Stuff for the run mode...
00342     int run_mode;
00343     float gravity;
00344     float forward_velocity;
00345     float side_velocity;
00346     float vertical_velocity;     // vertical is part of gravity...
00347     float forward_attenuation;   // bleed off velocity...
00348     float side_attenuation;      // bleed off velocity...
00349 
00350     // impulse values...
00351     float impulse_forward;
00352     float impulse_side;
00353     float impulse_vertical;
00354 
00355     // absolute values...
00356     float max_forward_velocity;
00357     float max_side_velocity;
00358     float max_vertical_velocity;
00359 
00360     char default_gamedir[MAX_PATH];
00361 
00362     int glBsp;
00363     int sinBsp;
00364     int valveBsp;
00365 
00366     // DATA
00367     float far_clip_distance;
00368     float near_clip_distance;
00369 
00370     HFONT font_ui,font_ui_bold, font9,font10,font12;
00371 
00372     unsigned char pal[768+4];
00373     RGBQUAD cTable[256];
00374 
00375     char rel_path_separator;
00376 };
00377 
00378 extern BSPSettings set;
00379 
00380 //SETINFO
00381 class cset_t;
00382 typedef void (*Cset_OnChange) (cset_t* cset,char *value);
00383 
00384 class setinfo_value
00385 {
00386 public:
00387     setinfo_value() : value(0), info(0) {}
00388     ~setinfo_value()
00389     {
00390         delete [] value;
00391         delete [] info;
00392     }
00393     char *value;
00394     char *info;
00395 };
00396 class setinfo_item
00397 {
00398 public:
00399     setinfo_item()
00400     {
00401         memset(this,0,sizeof(setinfo_item));
00402     }
00403     ~setinfo_item()
00404     {
00405         delete [] info;
00406         delete values;
00407     }
00408     int type;
00409     char *info;                                         //info text
00410     list<setinfo_value*> *values;       //list of allowed values
00411     int imin,imax;                                      //range for int type
00412     float fmin,fmax;                            //range for float type
00413     bool hasmin, hasmax;                        //range enablers
00414 };
00415 
00416 extern void SetInfo_Parse(char *file);
00417 
00418 //CSET - user access to settings
00419 
00420 enum DataType
00421 {
00422     CSET_FLOAT,
00423     CSET_INT,
00424     CSET_STRING,
00425     CSET_COLOR, //???  instead of these types, maybe have onchange handler specific to all colors, all paths, etc?
00426     CSET_VECTOR,
00427     CSET_PATH //?necessary??
00428 };
00429 
00430 #define CSET_FLAG_STRPTR 0x01
00431 
00432 //todo: allow side-by-side user variables? aliases?
00433 struct cset_group_s;
00434 
00435 class cset_t
00436 {
00437 public:
00438     cset_t(char *name, DataType type, void *value, Cset_OnChange OnChange)
00439     {
00440         this->name = name;
00441         this->type = type;
00442         this->value = value;
00443         this->OnChange = OnChange;
00444         setinfo = 0;
00445         flags = 0;
00446     }
00447     ~cset_t()
00448     {
00449         delete setinfo;
00450     }
00451     char *name;
00452     int namelen;
00453     DataType type;
00454     int flags;
00455     void *value;
00456     setinfo_item *setinfo;
00457     Cset_OnChange OnChange;
00458     cset_group_s *group;        //this group
00459     cset_t *next_in_group;      //group
00460     cset_t *hash_next;          //hash
00461     cset_t *next;                       //all
00463     void setInt(int i);
00464     void setFloat(float f);
00465     void setVector(float *v);
00466     void setString(char *str,int maxlen);
00467 };
00468 
00469 typedef struct cset_group_s
00470 {
00471     char        name[40];
00472     int         count;
00473     cset_t      *head;
00474     struct cset_group_s *next;
00475 } cset_group_t;
00476 
00477 #define Cset_Register(name,onChange) Cset_RegisterFn(&set.name,#name,onChange)
00478 #define Cset_RegisterStr(name,onChange) Cset_RegisterFn((char**)&set.name,#name,onChange,0)
00479 #define Cset_RegisterStrPtr(name,onChange) Cset_RegisterFn((char**)&set.name,#name,onChange,CSET_FLAG_STRPTR)
00480 
00481 extern cset_t *cset_all;
00482 extern cset_group_t *cset_groups;
00483 
00484 extern bool Cset_LoadConfig(char *filename);
00485 extern bool Cset_SaveConfig(char *filename, bool game);
00486 extern void Cset_Initialize(void);
00487 extern cset_t *Cset_FindSet(char *key);
00488 extern void Cset_Unload();
00489 extern bool Cset_SetValue(char *key, char *value);
00490 extern void Cset_PrintValue(cset_t *s);
00491 extern bool Cset_GetValueString(cset_t *c, char *out, int outlen);
00492 
00493 extern int Cset_Complete(char *prefix, char *out, int outlen, list<char*> *matches);
00494 
00495 #endif  //_SETTINGS_H_
 All Classes Functions