1 //------------------------------------------------------------------------ 2 // LEVEL MISC STUFF 3 //------------------------------------------------------------------------ 4 // 5 // Eureka DOOM Editor 6 // 7 // Copyright (C) 2001-2019 Andrew Apted 8 // Copyright (C) 1997-2003 André Majorel et al 9 // 10 // This program is free software; you can redistribute it and/or 11 // modify it under the terms of the GNU General Public License 12 // as published by the Free Software Foundation; either version 2 13 // of the License, or (at your option) any later version. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 //------------------------------------------------------------------------ 21 // 22 // Based on Yadex which incorporated code from DEU 5.21 that was put 23 // in the public domain in 1994 by Raphaël Quinet and Brendon Wyber. 24 // 25 //------------------------------------------------------------------------ 26 27 #ifndef __EUREKA_LEVELS_H__ 28 #define __EUREKA_LEVELS_H__ 29 30 #include <string> 31 32 #include "m_events.h" 33 #include "e_things.h" 34 35 class SaveBucket_c; 36 37 38 typedef enum 39 { 40 SREND_Nothing = 0, 41 SREND_Floor, 42 SREND_Ceiling, 43 SREND_Lighting, 44 SREND_FloorBright, 45 SREND_CeilBright, 46 SREND_SoundProp 47 48 } sector_rendering_mode_e; 49 50 51 // 52 // this holds some important editor state 53 // 54 struct Editor_State_t 55 { 56 obj_type_e mode; // current mode (OBJ_LINEDEFS, OBJ_SECTORS, etc...) 57 58 bool render3d; // 3D view is active 59 60 editor_action_e action; // an in-progress action, usually ACT_NOTHING 61 62 keycode_t sticky_mod; // if != 0, waiting for next key (fake meta) 63 64 bool pointer_in_window; // whether the mouse is over the 2D/3D view 65 double map_x, map_y, map_z; // map coordinates of pointer (no Z in 2D) 66 67 selection_c *Selected; // all selected objects (usually empty) 68 69 Objid highlight; // the highlighted object 70 71 Objid split_line; // linedef which would be split by a new vertex 72 double split_x; 73 double split_y; 74 75 76 /* rendering stuff */ 77 78 bool error_mode; // draw selection in red? 79 80 int sector_render_mode; // one of the SREND_XXX values 81 int thing_render_mode; 82 83 bool show_object_numbers; 84 85 86 /* navigation stuff */ 87 88 bool is_navigating; // user is holding down a navigation key 89 bool is_panning; // user is panning the map (turning in 3D) via RMB 90 91 float nav_fwd, nav_back; 92 float nav_left, nav_right; 93 float nav_up, nav_down; 94 float nav_turn_L, nav_turn_R; 95 bool nav_lax; 96 97 float panning_speed; 98 bool panning_lax; 99 100 101 /* click stuff (ACT_CLICK) */ 102 103 Objid clicked; // object under the pointer when ACT_Click occurred 104 105 int click_screen_x, click_screen_y; // screen coord of the click 106 107 double click_map_x, click_map_y, click_map_z; // location of the click 108 109 bool click_check_drag; 110 bool click_check_select; 111 bool click_force_single; 112 113 114 /* line drawing stuff (ACT_DRAW_LINE) */ 115 116 Objid draw_from; // the vertex we are drawing a line from 117 118 double draw_to_x, draw_to_y; // target coordinate of current line 119 120 121 /* selection-box stuff (ACT_SELBOX) */ 122 123 double selbox_x1, selbox_y1; // map coords 124 double selbox_x2, selbox_y2; 125 126 127 /* transforming state (ACT_TRANSFORM) */ 128 129 double trans_start_x; 130 double trans_start_y; 131 132 transform_keyword_e trans_mode; 133 transform_t trans_param; 134 135 selection_c *trans_lines; 136 137 138 /* dragging state (ACT_DRAG) */ 139 140 Objid dragged; // the object we are dragging, or nil for whole selection 141 142 int drag_screen_dx, drag_screen_dy; 143 144 double drag_start_x, drag_start_y, drag_start_z; 145 double drag_focus_x, drag_focus_y, drag_focus_z; 146 double drag_cur_x, drag_cur_y, drag_cur_z; 147 148 float drag_point_dist; 149 float drag_sector_dz; 150 int drag_other_vert; // used to ratio-lock a dragged vertex 151 152 int drag_thing_num; 153 float drag_thing_floorh; 154 bool drag_thing_up_down; 155 156 selection_c *drag_lines; 157 158 159 /* adjusting state (ACT_ADJUST_OFS) */ 160 161 float adjust_dx, adjust_dy; 162 bool adjust_lax; 163 164 SaveBucket_c * adjust_bucket; 165 166 struct { float x1, y1, x2, y2; } adjust_bbox; 167 }; 168 169 170 extern Editor_State_t edit; 171 172 173 void Editor_Init(); 174 void Editor_DefaultState(); 175 bool Editor_ParseUser(const char ** tokens, int num_tok); 176 void Editor_WriteUser(FILE *fp); 177 178 void Editor_ClearErrorMode(); 179 void Editor_ChangeMode(char mode); 180 void Editor_ChangeMode_Raw(obj_type_e new_mode); 181 182 void UpdateHighlight(); 183 184 void RedrawMap(); 185 void ZoomWholeMap(); 186 187 188 extern double Map_bound_x1; /* minimum X value of map */ 189 extern double Map_bound_y1; /* minimum Y value of map */ 190 extern double Map_bound_x2; /* maximum X value of map */ 191 extern double Map_bound_y2; /* maximum Y value of map */ 192 193 void CalculateLevelBounds(); 194 195 196 void MapStuff_NotifyBegin(); 197 void MapStuff_NotifyInsert(obj_type_e type, int objnum); 198 void MapStuff_NotifyDelete(obj_type_e type, int objnum); 199 void MapStuff_NotifyChange(obj_type_e type, int objnum, int field); 200 void MapStuff_NotifyEnd(); 201 202 203 void ObjectBox_NotifyBegin(); 204 void ObjectBox_NotifyInsert(obj_type_e type, int objnum); 205 void ObjectBox_NotifyDelete(obj_type_e type, int objnum); 206 void ObjectBox_NotifyChange(obj_type_e type, int objnum, int field); 207 void ObjectBox_NotifyEnd(); 208 209 210 void Selection_NotifyBegin(); 211 void Selection_NotifyInsert(obj_type_e type, int objnum); 212 void Selection_NotifyDelete(obj_type_e type, int objnum); 213 void Selection_NotifyChange(obj_type_e type, int objnum, int field); 214 void Selection_NotifyEnd(); 215 216 217 void DumpSelection (selection_c * list); 218 219 void ConvertSelection(selection_c * src, selection_c * dest); 220 221 int Selection_FirstLine(selection_c *list); 222 223 void Selection_Add(Objid& obj); 224 void Selection_Remove(Objid& obj); 225 void Selection_Toggle(Objid& obj); 226 227 void Selection_Clear(bool no_save = false); 228 void Selection_Push(); 229 void Selection_InvalidateLast(); 230 231 typedef enum 232 { 233 SOH_OK = 0, // using selection, nothing else needed 234 SOH_Unselect = 1, // using highlight, must unselect at end 235 SOH_Empty = 2 // both selection or highlight are empty 236 } soh_type_e; 237 238 soh_type_e Selection_Or_Highlight(); 239 240 void SelectObjectsInBox(selection_c *list, int objtype, double x1, double y1, double x2, double y2); 241 242 243 /* commands */ 244 245 void CMD_LastSelection(); 246 247 248 //---------------------------------------------------------------------- 249 // Helper for handling either the highlight or selection 250 //---------------------------------------------------------------------- 251 252 253 254 //---------------------------------------------------------------------- 255 // Recently used textures, flats and things 256 //---------------------------------------------------------------------- 257 258 #define RECENTLY_USED_MAX 32 259 260 class Recently_used 261 { 262 private: 263 int size; 264 int keep_num; 265 266 const char *name_set[RECENTLY_USED_MAX]; 267 268 public: 269 Recently_used(); 270 ~Recently_used(); 271 272 int find(const char *name); 273 int find_number(int val); 274 275 void insert(const char *name); 276 void insert_number(int val); 277 278 void clear(); 279 280 void WriteUser(FILE *fp, char letter); 281 282 private: 283 void erase(int index); 284 void push_front(const char *name); 285 }; 286 287 extern Recently_used recent_textures; 288 extern Recently_used recent_flats; 289 extern Recently_used recent_things; 290 291 void RecUsed_ClearAll(); 292 void RecUsed_WriteUser(FILE *fp); 293 bool RecUsed_ParseUser(const char ** tokens, int num_tok); 294 295 296 #endif /* __EUREKA_LEVELS_H__ */ 297 298 //--- editor settings --- 299 // vi:ts=4:sw=4:noexpandtab 300