win_ent.cpp

来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 1,391 行 · 第 1/3 页

CPP
1,391 行
字号
    col = iWidth;
  }

  if (g_pParentWnd->CurrentStyle() > 0 && g_pParentWnd->CurrentStyle() < 3)
	  MOVE(g_qeglobals.d_hwndTexture,	DlgXBorder, DlgYBorder, iWidth - (2 * DlgXBorder), iHeight - (2 * DlgYBorder) );

  if (inspector_mode == W_GROUP)
  {
    col = 0;
  }
  else
  {
    col = iWidth;
  }

  MOVE(g_qeglobals.d_hwndGroup,	DlgXBorder, DlgYBorder, iWidth - (2 * DlgXBorder), iHeight - (2 * DlgYBorder) );

	//==========================================

	//
	// entity controls
	//
  if (inspector_mode == W_ENTITY)
  {
    col = 0;
  }
  else
  {
    col = iWidth;
  }



	// top half includes the entity list (2/3) and the 
	// comments (1/3) - 2 gaps, above and below.

	y = iHeight/2;
	y -= 2 * DlgYBorder;
	y = y / 3;
	w = iWidth - (2 * DlgXBorder);
	MOVE(hwndEnt[EntList], DlgXBorder, DlgYBorder, w, 2 * y);
	
	MOVE(hwndEnt[EntComment], DlgXBorder, 2 * DlgYBorder + 2 * y, w, y - (2 * DlgYBorder));

	// bottom half includes flags (fixed), k/v pairs,
	// and buttons (fixed).

	// xCheck = width of a single check box
	// yCheck = distance from top of one check to the next

	xCheck = (iWidth - (2 * DlgXBorder)) / 3;
	yCheck = 18;

	x = DlgXBorder;

	for (iRow = 0; iRow <= 12; iRow += 4)
	{
		y = iHeight/2;
	
		for (i = 0; i < 4; i++)
		{
			MOVE(hwndEnt[EntCheck1 + i + iRow],
				x, y, xCheck, yCheck);
			y += yCheck;
		}

		x += xCheck;
	}

	//
	// properties scroll box
	//
	y = iHeight/2 + 4 * yCheck;

	w = iWidth - (2 * DlgXBorder);
	h = (iHeight - (yCheck * 5 + 2 * DlgYBorder) ) - y;

	MOVE(hwndEnt[EntProps], DlgXBorder, y, w, h);

	y += h + DlgYBorder;
	
	//
	// key / value fields
	//
	w = iWidth-(DlgXBorder+45);
	MOVE(hwndEnt[EntKeyLabel], DlgXBorder, y, 40, yCheck);
	MOVE(hwndEnt[EntKeyField], DlgXBorder+40, y, w, yCheck);
	y += yCheck;		

	MOVE(hwndEnt[EntValueLabel], DlgXBorder, y, 40, yCheck);
	MOVE(hwndEnt[EntValueField], DlgXBorder+40, y, w, yCheck);
	y += yCheck;		

	//
	// angle check boxes
	//
  y += 2;
	i = y;
	x = DlgXBorder;

	xCheck = yCheck*2;

	MOVE(hwndEnt[EntDir135], x, y, xCheck, yCheck);
	y += yCheck;		
	
	MOVE(hwndEnt[EntDir180], x, y, xCheck, yCheck);
	y += yCheck;		
	
	MOVE(hwndEnt[EntDir225], x, y, xCheck, yCheck);

	y = i;
	x += xCheck;

	
	MOVE(hwndEnt[EntDir90], x, y, xCheck, yCheck);
	y += yCheck;		
	y += yCheck;		
	
	MOVE(hwndEnt[EntDir270], x, y, xCheck, yCheck);

	y = i;
	x += xCheck;

	
	MOVE(hwndEnt[EntDir45], x, y, xCheck, yCheck);
	y += yCheck;		
	
	MOVE(hwndEnt[EntDir0], x, y, xCheck, yCheck);
	y += yCheck;		
	
	MOVE(hwndEnt[EntDir315], x, y, xCheck, yCheck);

	y = i + yCheck/2;
	x += xCheck + xCheck/2;

	
	MOVE(hwndEnt[EntDirUp], x, y, xCheck, yCheck);
	y += yCheck;		
	
	MOVE(hwndEnt[EntDirDown], x, y, xCheck, yCheck);

	y = i;
	x += 1.5 * xCheck;
	
	MOVE(hwndEnt[EntDelProp], x, y, xCheck*2, yCheck);
	y += yCheck + 4;		

  MOVE(hwndEnt[EntAssignSounds], x, y, xCheck*2, yCheck);
	y += yCheck;		
  MOVE(hwndEnt[EntAssignModels], x, y, xCheck*2, yCheck);

  // tab selector is always visible
  col = 0;
  iHeight += 24;
  MOVE(hwndEnt[EntTab], 0,0,iWidth,iHeight, HWND_BOTTOM, SWP_NOACTIVATE | SWP_NOCOPYBITS);

	SendMessage( g_qeglobals.d_hwndEntity, WM_SETREDRAW, 1, 0);
//	InvalidateRect(entwindow, NULL, TRUE);
}

void AssignSound()
{
  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
  AddSlash(strBasePath);
  CString strPath = strBasePath;
  strPath += "sound\\";

  CWaveOpen dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Sound files (*.wav)|*.wav||", g_pParentWnd);
  dlgFile.m_ofn.lpstrInitialDir = strPath;
  if (dlgFile.DoModal() == IDOK)
  {
	  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)"noise");	
    CString str = dlgFile.GetPathName().GetBuffer(0);
    str.MakeLower();
    strBasePath.MakeLower();
    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));
    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));
    int n = str.Find(strBasePath);
    if (n == 0)
    {
      str = str.Right(str.GetLength() - strBasePath.GetLength());
    }

	  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));	
    AddProp();
    g_pParentWnd->GetXYWnd()->SetFocus();
  }
}

void AssignModel()
{
  CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
  AddSlash(strBasePath);
  CString strPath = strBasePath;
  strPath += "models\\mapobjects\\";

  CFileDialog dlgFile(TRUE, NULL, NULL, OFN_OVERWRITEPROMPT, "Model files (*.md3)|*.md3||", g_pParentWnd);
  dlgFile.m_ofn.lpstrInitialDir = strPath;
  if (dlgFile.DoModal() == IDOK)
  {
	  SendMessage(hwndEnt[EntKeyField], WM_SETTEXT, 0, (LPARAM)"model");
    CString str = dlgFile.GetPathName().GetBuffer(0);
    str.MakeLower();
    strBasePath.MakeLower();
    QE_ConvertDOSToUnixName(str.GetBuffer(0), str.GetBuffer(0));
    QE_ConvertDOSToUnixName(strBasePath.GetBuffer(0), strBasePath.GetBuffer(0));
    int n = str.Find(strBasePath);
    if (n == 0)
    {
      str = str.Right(str.GetLength() - strBasePath.GetLength());
    }

	  SendMessage(hwndEnt[EntValueField], WM_SETTEXT, 0, (LPARAM)str.GetBuffer(0));	
    AddProp();
    edit_entity->md3Class = NULL;
    edit_entity->brushes.onext->bModelFailed = false;
    g_pParentWnd->GetXYWnd()->SetFocus();
  }
}


/*
=========================
EntityWndProc
=========================
*/
BOOL CALLBACK EntityWndProc(
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,		// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam)	// second message parameter
{
  LPNMHDR lpnmh = NULL;
	RECT	rc;

	GetClientRect(hwndDlg, &rc);

    switch (uMsg)
    {

      case WM_CHAR :
      {
        char c = toupper(LOWORD(wParam));
        // escape: hide the window
		    if (c == 27)
			    ShowWindow(hwndDlg, SW_HIDE);
        if (c == 'N')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_ENTITY, 0);
        else
        if (c == 'O')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_CONSOLE, 0);
        else
        if (c == 'T')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_TEXTURE, 0);
        else
        if (c == 'G')
          g_pParentWnd->PostMessage(WM_COMMAND, ID_VIEW_GROUPS, 0);
        else
			    DefWindowProc (hwndDlg, uMsg, wParam, lParam);
        break;
      }

      case WM_NOTIFY:
        lpnmh = reinterpret_cast<LPNMHDR>(lParam);
        if (lpnmh->hwndFrom == g_wndTabs.GetSafeHwnd()) {
          if ( lpnmh->code == TCN_SELCHANGE)
          {
            int n = g_wndTabs.GetCurSel();
            if (g_pParentWnd->CurrentStyle() == 2 || g_pParentWnd->CurrentStyle() == 1)
            {
              if (n == 0) {
                SetInspectorMode(W_ENTITY);
              } else if (n == 1) {
                SetInspectorMode(W_TEXTURE);
              } else if (n == 2) {
                SetInspectorMode(W_CONSOLE);
              } else {
                SetInspectorMode(W_GROUP);
              }
            }
            else
            {
              if (n == 0) {
                SetInspectorMode(W_ENTITY);
              } else if (n == 1) {
                SetInspectorMode(W_GROUP);
              }
            }
          }
        }
        break;
        
	case WM_SIZE:

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);
      break;

  case WM_DESTROY:
      SaveWindowPlacement(g_qeglobals.d_hwndEntity, "EntityWindowPlace");
      DefWindowProc(hwndDlg, uMsg, wParam, lParam);
      break;

	case WM_GETMINMAXINFO:
		{
			LPMINMAXINFO	lpmmi;

			lpmmi = (LPMINMAXINFO) lParam;
			lpmmi->ptMinTrackSize.x = 320;
			lpmmi->ptMinTrackSize.y = 500;
		}
		return 0;

	case WM_WINDOWPOSCHANGING:
		{
			LPWINDOWPOS	lpwp;
			lpwp = (LPWINDOWPOS) lParam;

			DefWindowProc (hwndDlg, uMsg, wParam, lParam);

			lpwp->flags |= SWP_NOCOPYBITS;
			SizeEntityDlg(lpwp->cx-8, lpwp->cy-32);
			return 0;

		}
		return 0;


	case WM_COMMAND: 
		switch (LOWORD(wParam)) { 

    case IDC_BTN_ASSIGNSOUND:
      AssignSound();
      break;

    case IDC_BTN_ASSIGNMODEL:
      AssignModel();
      break;

		case IDC_E_DELPROP:
			DelProp();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;

		case IDC_E_0:
			SetKeyValue (edit_entity, "angle", "360");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_45:
			SetKeyValue (edit_entity, "angle", "45");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_90:
			SetKeyValue (edit_entity, "angle", "90");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_135:
			SetKeyValue (edit_entity, "angle", "135");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_180:
			SetKeyValue (edit_entity, "angle", "180");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_225:
			SetKeyValue (edit_entity, "angle", "225");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_270:
			SetKeyValue (edit_entity, "angle", "270");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_315:
			SetKeyValue (edit_entity, "angle", "315");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_UP:
			SetKeyValue (edit_entity, "angle", "-1");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;
		case IDC_E_DOWN:
			SetKeyValue (edit_entity, "angle", "-2");
			SetFocus (g_qeglobals.d_hwndCamera);
			SetKeyValuePairs ();
			break;

    case IDC_BTN_HIDE:
      ::PostMessage(g_qeglobals.d_hwndMain, WM_COMMAND, ID_VIEW_CAMERATOGGLE, 0);
      break;

		case IDC_CHECK1:
		case IDC_CHECK2:
		case IDC_CHECK3:
		case IDC_CHECK4:
		case IDC_CHECK5:
		case IDC_CHECK6:
		case IDC_CHECK7:
		case IDC_CHECK8:
		case IDC_CHECK9:
		case IDC_CHECK10:
		case IDC_CHECK11:
		case IDC_CHECK12:
			GetSpawnFlags();
			SetFocus (g_qeglobals.d_hwndCamera);
			break;


		case IDC_E_PROPS: 
			switch (HIWORD(wParam))
			{ 
			case LBN_SELCHANGE:

				EditProp();
				return TRUE; 
			}
			break;

		case IDC_E_LIST: 
	   
			switch (HIWORD(wParam)) { 
			
			case LBN_SELCHANGE: 
			{
				int iIndex;
				eclass_t *pec;
				
				iIndex = SendMessage(hwndEnt[EntList], LB_GETCURSEL, 0, 0);	
				pec = (eclass_t *)SendMessage(hwndEnt[EntList], LB_GETITEMDATA, 
						iIndex, 0); 
			
				UpdateSel(iIndex, pec);

				return TRUE; 
				break; 
			}

			case LBN_DBLCLK: 
				CreateEntity ();
				SetFocus (g_qeglobals.d_hwndCamera);
				break; 
			} 
            break; 


            default: 
              return DefWindowProc( hwndDlg, uMsg, wParam, lParam ); 
        } 

		return 0;
	}

    return DefWindowProc (hwndDlg, uMsg, wParam, lParam);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?