// // ======================================================================================================================= // CreateEntity Creates a new entity based on the currently selected brush and entity type. // ======================================================================================================================= // void CEntityDlg::CreateEntity() { entity_t *petNew; bool forceFixed = false; // check to make sure we have a brush CXYWnd *pWnd = g_pParentWnd->ActiveXY(); if (pWnd) { CRect rctZ; pWnd->GetClientRect(rctZ); brush_t *pBrush; if (selected_brushes.next == &selected_brushes) { pBrush = CreateEntityBrush(g_nSmartX, rctZ.Height() - 1 - g_nSmartY, pWnd); forceFixed = true; } } else { if (selected_brushes.next == &selected_brushes) { MessageBox("You must have a selected brush to create an entity", "info", 0); return; } } int index = comboClass.GetCurSel(); if (index == LB_ERR) { MessageBox("You must have a selected class to create an entity", "info", 0); return; } CString str; comboClass.GetLBText(index, str); if (!stricmp(str, "worldspawn")) { MessageBox("Can't create an entity with worldspawn.", "info", 0); return; } eclass_t *pecNew = Eclass_ForName (str, false); // create it if ((GetAsyncKeyState(VK_CONTROL) & 0x8000)) { // MAJOR hack for xian extern void Brush_CopyList(brush_t *pFrom, brush_t *pTo); brush_t temp_brushes; temp_brushes.next = &temp_brushes; Brush_CopyList(&selected_brushes, &temp_brushes); Select_Deselect(); brush_t *pBrush = temp_brushes.next; while (pBrush != NULL && pBrush != &temp_brushes) { brush_t *pNext = pBrush->next; Brush_RemoveFromList(pBrush); Brush_AddToList(pBrush, &selected_brushes); pBrush = pNext; petNew = Entity_Create(pecNew, forceFixed); Select_Deselect(); } } else if ((GetAsyncKeyState(VK_SHIFT) & 0x8000)) { Select_Ungroup(); petNew = Entity_Create(pecNew, forceFixed); } else { petNew = Entity_Create(pecNew, forceFixed); } if (petNew == NULL) { MessageBox("Failed to create entity.", "info", 0); return; } if (selected_brushes.next == &selected_brushes) { editEntity = world_entity; } else { editEntity = selected_brushes.next->owner; } SetKeyValPairs(); Select_Deselect(); Select_Brush(editEntity->brushes.onext); Sys_UpdateWindows(W_ALL); }
/* handle all WM_COMMAND messages here */ LONG WINAPI CommandHandler ( HWND hWnd, WPARAM wParam, LPARAM lParam) { HMENU hMenu; switch (LOWORD(wParam)) { // // file menu // case ID_FILE_EXIT: /* exit application */ if (!ConfirmModified()) return TRUE; PostMessage (hWnd, WM_CLOSE, 0, 0L); break; case ID_FILE_OPEN: if (!ConfirmModified()) return TRUE; OpenDialog (); break; case ID_FILE_NEW: if (!ConfirmModified()) return TRUE; Map_New (); break; case ID_FILE_SAVE: if (!strcmp(currentmap, "unnamed.map")) SaveAsDialog (); else Map_SaveFile (currentmap, false); // ignore region break; case ID_FILE_SAVEAS: SaveAsDialog (); break; case ID_FILE_LOADPROJECT: if (!ConfirmModified()) return TRUE; ProjectDialog (); break; case ID_FILE_POINTFILE: if (g_qeglobals.d_pointfile_display_list) Pointfile_Clear (); else Pointfile_Check (); break; // // view menu // case ID_VIEW_ENTITY: SetInspectorMode(W_ENTITY); break; case ID_VIEW_CONSOLE: SetInspectorMode(W_CONSOLE); break; case ID_VIEW_TEXTURE: SetInspectorMode(W_TEXTURE); break; case ID_VIEW_100: g_qeglobals.d_xy.scale = 1; Sys_UpdateWindows (W_XY|W_XY_OVERLAY); break; case ID_VIEW_ZOOMIN: g_qeglobals.d_xy.scale *= 5.0/4; if (g_qeglobals.d_xy.scale > 16) g_qeglobals.d_xy.scale = 16; Sys_UpdateWindows (W_XY|W_XY_OVERLAY); break; case ID_VIEW_ZOOMOUT: g_qeglobals.d_xy.scale *= 4.0/5; if (g_qeglobals.d_xy.scale < 0.1) g_qeglobals.d_xy.scale = 0.1; Sys_UpdateWindows (W_XY|W_XY_OVERLAY); break; case ID_VIEW_Z100: z.scale = 1; Sys_UpdateWindows (W_Z|W_Z_OVERLAY); break; case ID_VIEW_ZZOOMIN: z.scale *= 5.0/4; if (z.scale > 4) z.scale = 4; Sys_UpdateWindows (W_Z|W_Z_OVERLAY); break; case ID_VIEW_ZZOOMOUT: z.scale *= 4.0/5; if (z.scale < 0.125) z.scale = 0.125; Sys_UpdateWindows (W_Z|W_Z_OVERLAY); break; case ID_VIEW_CENTER: camera.angles[ROLL] = camera.angles[PITCH] = 0; camera.angles[YAW] = 22.5 * floor( (camera.angles[YAW]+11)/22.5 ); Sys_UpdateWindows (W_CAMERA|W_XY_OVERLAY); break; case ID_VIEW_UPFLOOR: Cam_ChangeFloor (true); break; case ID_VIEW_DOWNFLOOR: Cam_ChangeFloor (false); break; case ID_VIEW_SHOWNAMES: g_qeglobals.d_savedinfo.show_names = !g_qeglobals.d_savedinfo.show_names; CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWNAMES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_names ? MF_CHECKED : MF_UNCHECKED) ); Map_BuildBrushData(); Sys_UpdateWindows (W_XY); break; case ID_VIEW_SHOWCOORDINATES: g_qeglobals.d_savedinfo.show_coordinates ^= 1; CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCOORDINATES, MF_BYCOMMAND | (g_qeglobals.d_savedinfo.show_coordinates ? MF_CHECKED : MF_UNCHECKED) ); Sys_UpdateWindows (W_XY); break; case ID_VIEW_SHOWBLOCKS: g_qeglobals.show_blocks ^= 1; CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWBLOCKS, MF_BYCOMMAND | (g_qeglobals.show_blocks ? MF_CHECKED : MF_UNCHECKED) ); Sys_UpdateWindows (W_XY); break; case ID_VIEW_SHOWLIGHTS: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_LIGHTS ) & EXCLUDE_LIGHTS ) CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_UNCHECKED ); else CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWLIGHTS, MF_BYCOMMAND | MF_CHECKED ); Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWPATH: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_PATHS ) & EXCLUDE_PATHS ) CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_UNCHECKED ); else CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWPATH, MF_BYCOMMAND | MF_CHECKED ); Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWENT: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_ENT ) & EXCLUDE_ENT ) CheckMenuItem( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_UNCHECKED); else CheckMenuItem( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWENT, MF_BYCOMMAND | MF_CHECKED); Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWWATER: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WATER ) & EXCLUDE_WATER ) CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_UNCHECKED ); else CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWATER, MF_BYCOMMAND | MF_CHECKED ); Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWCLIP: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_CLIP ) & EXCLUDE_CLIP ) CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_UNCHECKED ); else CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWCLIP, MF_BYCOMMAND | MF_CHECKED ); Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWDETAIL: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_DETAIL ) & EXCLUDE_DETAIL ) { CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_UNCHECKED ); SetWindowText (g_qeglobals.d_hwndCamera, "Camera View (DETAIL EXCLUDED)"); } else { CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWDETAIL, MF_BYCOMMAND | MF_CHECKED ); SetWindowText (g_qeglobals.d_hwndCamera, "Camera View"); } Sys_UpdateWindows (W_XY|W_CAMERA); break; case ID_VIEW_SHOWWORLD: if ( ( g_qeglobals.d_savedinfo.exclude ^= EXCLUDE_WORLD ) & EXCLUDE_WORLD ) CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_UNCHECKED ); else CheckMenuItem ( GetMenu(g_qeglobals.d_hwndMain), ID_VIEW_SHOWWORLD, MF_BYCOMMAND | MF_CHECKED ); Sys_UpdateWindows (W_XY|W_CAMERA); break; // // grid menu // case ID_GRID_1: case ID_GRID_2: case ID_GRID_4: case ID_GRID_8: case ID_GRID_16: case ID_GRID_32: case ID_GRID_64: { hMenu = GetMenu(hWnd); CheckMenuItem(hMenu, ID_GRID_1, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_2, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_4, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_8, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_16, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_32, MF_BYCOMMAND | MF_UNCHECKED); CheckMenuItem(hMenu, ID_GRID_64, MF_BYCOMMAND | MF_UNCHECKED); switch (LOWORD(wParam)) { case ID_GRID_1: g_qeglobals.d_gridsize = 0; break; case ID_GRID_2: g_qeglobals.d_gridsize = 1; break; case ID_GRID_4: g_qeglobals.d_gridsize = 2; break; case ID_GRID_8: g_qeglobals.d_gridsize = 3; break; case ID_GRID_16: g_qeglobals.d_gridsize = 4; break; case ID_GRID_32: g_qeglobals.d_gridsize = 5; break; case ID_GRID_64: g_qeglobals.d_gridsize = 6; break; } g_qeglobals.d_gridsize = 1 << g_qeglobals.d_gridsize; CheckMenuItem(hMenu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED); Sys_UpdateWindows (W_XY|W_Z); break; } // // texture menu // case ID_VIEW_NEAREST: case ID_VIEW_NEARESTMIPMAP: case ID_VIEW_LINEAR: case ID_VIEW_BILINEAR: case ID_VIEW_BILINEARMIPMAP: case ID_VIEW_TRILINEAR: case ID_TEXTURES_WIREFRAME: case ID_TEXTURES_FLATSHADE: Texture_SetMode (LOWORD(wParam)); break; case ID_TEXTURES_SHOWINUSE: Sys_BeginWait (); Texture_ShowInuse (); SetInspectorMode(W_TEXTURE); break; case ID_TEXTURES_INSPECTOR: DoSurface (); break; case CMD_TEXTUREWAD: case CMD_TEXTUREWAD+1: case CMD_TEXTUREWAD+2: case CMD_TEXTUREWAD+3: case CMD_TEXTUREWAD+4: case CMD_TEXTUREWAD+5: case CMD_TEXTUREWAD+6: case CMD_TEXTUREWAD+7: case CMD_TEXTUREWAD+8: case CMD_TEXTUREWAD+9: case CMD_TEXTUREWAD+10: case CMD_TEXTUREWAD+11: case CMD_TEXTUREWAD+12: case CMD_TEXTUREWAD+13: case CMD_TEXTUREWAD+14: case CMD_TEXTUREWAD+15: case CMD_TEXTUREWAD+16: case CMD_TEXTUREWAD+17: case CMD_TEXTUREWAD+18: case CMD_TEXTUREWAD+19: case CMD_TEXTUREWAD+20: case CMD_TEXTUREWAD+21: case CMD_TEXTUREWAD+22: case CMD_TEXTUREWAD+23: case CMD_TEXTUREWAD+24: case CMD_TEXTUREWAD+25: case CMD_TEXTUREWAD+26: case CMD_TEXTUREWAD+27: case CMD_TEXTUREWAD+28: case CMD_TEXTUREWAD+29: case CMD_TEXTUREWAD+30: case CMD_TEXTUREWAD+31: Sys_BeginWait (); Texture_ShowDirectory (LOWORD(wParam)); SetInspectorMode(W_TEXTURE); break; // // bsp menu // case CMD_BSPCOMMAND: case CMD_BSPCOMMAND+1: case CMD_BSPCOMMAND+2: case CMD_BSPCOMMAND+3: case CMD_BSPCOMMAND+4: case CMD_BSPCOMMAND+5: case CMD_BSPCOMMAND+6: case CMD_BSPCOMMAND+7: case CMD_BSPCOMMAND+8: case CMD_BSPCOMMAND+9: case CMD_BSPCOMMAND+10: case CMD_BSPCOMMAND+11: case CMD_BSPCOMMAND+12: case CMD_BSPCOMMAND+13: case CMD_BSPCOMMAND+14: case CMD_BSPCOMMAND+15: case CMD_BSPCOMMAND+16: case CMD_BSPCOMMAND+17: case CMD_BSPCOMMAND+18: case CMD_BSPCOMMAND+19: case CMD_BSPCOMMAND+20: case CMD_BSPCOMMAND+21: case CMD_BSPCOMMAND+22: case CMD_BSPCOMMAND+23: case CMD_BSPCOMMAND+24: case CMD_BSPCOMMAND+25: case CMD_BSPCOMMAND+26: case CMD_BSPCOMMAND+27: case CMD_BSPCOMMAND+28: case CMD_BSPCOMMAND+29: case CMD_BSPCOMMAND+30: case CMD_BSPCOMMAND+31: { extern char *bsp_commands[256]; RunBsp (bsp_commands[LOWORD(wParam-CMD_BSPCOMMAND)]); } break; // // misc menu // case ID_MISC_BENCHMARK: SendMessage ( g_qeglobals.d_hwndCamera, WM_USER+267, 0, 0); break; case ID_TEXTUREBK: DoColor(COLOR_TEXTUREBACK); Sys_UpdateWindows (W_ALL); break; case ID_MISC_SELECTENTITYCOLOR: { extern int inspector_mode; if ( ( inspector_mode == W_ENTITY ) && DoColor(COLOR_ENTITY) == true ) { extern void AddProp( void ); char buffer[100]; sprintf( buffer, "%f %f %f", g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][0], g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][1], g_qeglobals.d_savedinfo.colors[COLOR_ENTITY][2] ); SetWindowText( hwndEnt[EntValueField], buffer ); SetWindowText( hwndEnt[EntKeyField], "_color" ); AddProp(); } Sys_UpdateWindows( W_ALL ); } break; case ID_MISC_PRINTXY: WXY_Print(); break; case ID_COLORS_XYBK: DoColor(COLOR_GRIDBACK); Sys_UpdateWindows (W_ALL); break; case ID_COLORS_MAJOR: DoColor(COLOR_GRIDMAJOR); Sys_UpdateWindows (W_ALL); break; case ID_COLORS_MINOR: DoColor(COLOR_GRIDMINOR); Sys_UpdateWindows (W_ALL); break; case ID_MISC_GAMMA: DoGamma(); break; case ID_MISC_FINDBRUSH: DoFind(); break; case ID_MISC_NEXTLEAKSPOT: Pointfile_Next(); break; case ID_MISC_PREVIOUSLEAKSPOT: Pointfile_Prev(); break; // // brush menu // case ID_BRUSH_3SIDED: Brush_MakeSided (3); break; case ID_BRUSH_4SIDED: Brush_MakeSided (4); break; case ID_BRUSH_5SIDED: Brush_MakeSided (5); break; case ID_BRUSH_6SIDED: Brush_MakeSided (6); break; case ID_BRUSH_7SIDED: Brush_MakeSided (7); break; case ID_BRUSH_8SIDED: Brush_MakeSided (8); break; case ID_BRUSH_9SIDED: Brush_MakeSided (9); break; case ID_BRUSH_ARBITRARYSIDED: DoSides (); break; // // select menu // case ID_BRUSH_FLIPX: Select_FlipAxis (0); break; case ID_BRUSH_FLIPY: Select_FlipAxis (1); break; case ID_BRUSH_FLIPZ: Select_FlipAxis (2); break; case ID_BRUSH_ROTATEX: Select_RotateAxis (0, 90); break; case ID_BRUSH_ROTATEY: Select_RotateAxis (1, 90); break; case ID_BRUSH_ROTATEZ: Select_RotateAxis (2, 90); break; case ID_SELECTION_ARBITRARYROTATION: DoRotate (); break; case ID_SELECTION_UNGROUPENTITY: Select_Ungroup (); break; case ID_SELECTION_CONNECT: ConnectEntities (); break; case ID_SELECTION_DRAGVERTECIES: if (g_qeglobals.d_select_mode == sel_vertex) { g_qeglobals.d_select_mode = sel_brush; Sys_UpdateWindows (W_ALL); } else { SetupVertexSelection (); if (g_qeglobals.d_numpoints) g_qeglobals.d_select_mode = sel_vertex; } break; case ID_SELECTION_DRAGEDGES: if (g_qeglobals.d_select_mode == sel_edge) { g_qeglobals.d_select_mode = sel_brush; Sys_UpdateWindows (W_ALL); } else { SetupVertexSelection (); if (g_qeglobals.d_numpoints) g_qeglobals.d_select_mode = sel_edge; } break; case ID_SELECTION_SELECTPARTIALTALL: Select_PartialTall (); break; case ID_SELECTION_SELECTCOMPLETETALL: Select_CompleteTall (); break; case ID_SELECTION_SELECTTOUCHING: Select_Touching (); break; case ID_SELECTION_SELECTINSIDE: Select_Inside (); break; case ID_SELECTION_CSGSUBTRACT: CSG_Subtract (); break; case ID_SELECTION_MAKEHOLLOW: CSG_MakeHollow (); break; case ID_SELECTION_CLONE: Select_Clone (); break; case ID_SELECTION_DELETE: Select_Delete (); break; case ID_SELECTION_DESELECT: Select_Deselect (); break; case ID_SELECTION_MAKE_DETAIL: Select_MakeDetail (); break; case ID_SELECTION_MAKE_STRUCTURAL: Select_MakeStructural (); break; // // region menu // case ID_REGION_OFF: Map_RegionOff (); break; case ID_REGION_SETXY: Map_RegionXY (); break; case ID_REGION_SETTALLBRUSH: Map_RegionTallBrush (); break; case ID_REGION_SETBRUSH: Map_RegionBrush (); break; case ID_REGION_SETSELECTION: Map_RegionSelectedBrushes (); break; case IDMRU+1: case IDMRU+2: case IDMRU+3: case IDMRU+4: case IDMRU+5: case IDMRU+6: case IDMRU+7: case IDMRU+8: case IDMRU+9: DoMru(hWnd,LOWORD(wParam)); break; // // help menu // case ID_HELP_ABOUT: DoAbout(); break; default: return FALSE; } return TRUE; }