TextureBar.cpp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "qe3.h"
  23. #include "Radiant.h"
  24. #include "TextureBar.h"
  25. //++timo TODO : the whole CTextureBar has to be modified for the new texture code
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CTextureBar dialog
  33. CTextureBar::CTextureBar()
  34. : CDialogBar()
  35. {
  36. //{{AFX_DATA_INIT(CTextureBar)
  37. m_nHShift = 0;
  38. m_nHScale = 0;
  39. m_nRotate = 0;
  40. m_nVShift = 0;
  41. m_nVScale = 0;
  42. m_nRotateAmt = 45;
  43. //}}AFX_DATA_INIT
  44. }
  45. void CTextureBar::DoDataExchange(CDataExchange* pDX)
  46. {
  47. CDialogBar::DoDataExchange(pDX);
  48. //{{AFX_DATA_MAP(CTextureBar)
  49. DDX_Control(pDX, IDC_SPIN_ROTATE, m_spinRotate);
  50. DDX_Control(pDX, IDC_SPIN_VSCALE, m_spinVScale);
  51. DDX_Control(pDX, IDC_SPIN_VSHIFT, m_spinVShift);
  52. DDX_Control(pDX, IDC_SPIN_HSCALE, m_spinHScale);
  53. DDX_Control(pDX, IDC_SPIN_HSHIFT, m_spinHShift);
  54. DDX_Text(pDX, IDC_HSHIFT, m_nHShift);
  55. DDX_Text(pDX, IDC_HSCALE, m_nHScale);
  56. DDX_Text(pDX, IDC_ROTATE, m_nRotate);
  57. DDX_Text(pDX, IDC_VSHIFT, m_nVShift);
  58. DDX_Text(pDX, IDC_VSCALE, m_nVScale);
  59. DDX_Text(pDX, IDC_EDIT_ROTATEAMT, m_nRotateAmt);
  60. //}}AFX_DATA_MAP
  61. }
  62. BEGIN_MESSAGE_MAP(CTextureBar, CDialogBar)
  63. //{{AFX_MSG_MAP(CTextureBar)
  64. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSHIFT, OnDeltaposSpinHshift)
  65. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSHIFT, OnDeltaposSpinVshift)
  66. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_HSCALE, OnDeltaposSpinHScale)
  67. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_VSCALE, OnDeltaposSpinVScale)
  68. ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_ROTATE, OnDeltaposSpinRotate)
  69. ON_COMMAND(ID_SELECTION_PRINT, OnSelectionPrint)
  70. ON_WM_CREATE()
  71. ON_BN_CLICKED(IDC_BTN_APPLYTEXTURESTUFF, OnBtnApplytexturestuff)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CTextureBar message handlers
  76. void CTextureBar::OnDeltaposSpinHshift(NMHDR* pNMHDR, LRESULT* pResult)
  77. {
  78. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  79. *pResult = 0;
  80. if (pNMUpDown->iDelta < 0)
  81. Select_ShiftTexture(abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  82. else
  83. Select_ShiftTexture(-abs(g_qeglobals.d_savedinfo.m_nTextureTweak), 0);
  84. GetSurfaceAttributes();
  85. }
  86. void CTextureBar::OnDeltaposSpinVshift(NMHDR* pNMHDR, LRESULT* pResult)
  87. {
  88. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  89. // TODO: Add your control notification handler code here
  90. *pResult = 0;
  91. if (pNMUpDown->iDelta < 0)
  92. Select_ShiftTexture(0, abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  93. else
  94. Select_ShiftTexture(0, -abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  95. GetSurfaceAttributes();
  96. }
  97. void CTextureBar::OnDeltaposSpinHScale(NMHDR* pNMHDR, LRESULT* pResult)
  98. {
  99. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  100. // TODO: Add your control notification handler code here
  101. *pResult = 0;
  102. if (pNMUpDown->iDelta < 0)
  103. Select_ScaleTexture((float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  104. else
  105. Select_ScaleTexture((float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak),0);
  106. GetSurfaceAttributes();
  107. }
  108. void CTextureBar::OnDeltaposSpinVScale(NMHDR* pNMHDR, LRESULT* pResult)
  109. {
  110. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  111. // TODO: Add your control notification handler code here
  112. *pResult = 0;
  113. if (pNMUpDown->iDelta < 0)
  114. Select_ScaleTexture(0, (float)abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  115. else
  116. Select_ScaleTexture(0, (float)-abs(g_qeglobals.d_savedinfo.m_nTextureTweak));
  117. GetSurfaceAttributes();
  118. }
  119. void CTextureBar::OnDeltaposSpinRotate(NMHDR* pNMHDR, LRESULT* pResult)
  120. {
  121. NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
  122. *pResult = 0;
  123. UpdateData(TRUE);
  124. if (pNMUpDown->iDelta < 0)
  125. Select_RotateTexture(abs(m_nRotateAmt));
  126. else
  127. Select_RotateTexture(-abs(m_nRotateAmt));
  128. GetSurfaceAttributes();
  129. }
  130. void CTextureBar::OnSelectionPrint()
  131. {
  132. // TODO: Add your command handler code here
  133. }
  134. int CTextureBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
  135. {
  136. if (CDialogBar::OnCreate(lpCreateStruct) == -1)
  137. return -1;
  138. return 0;
  139. }
  140. void CTextureBar::OnBtnApplytexturestuff()
  141. {
  142. SetSurfaceAttributes();
  143. }
  144. void CTextureBar::GetSurfaceAttributes()
  145. {
  146. texdef_t* pt = (g_ptrSelectedFaces.GetSize() > 0) ? &(reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0)))->texdef : &g_qeglobals.d_texturewin.texdef;
  147. if (pt)
  148. {
  149. m_nHShift = pt->shift[0];
  150. m_nVShift = pt->shift[1];
  151. m_nHScale = pt->scale[0];
  152. m_nVScale = pt->scale[1];
  153. m_nRotate = pt->rotate;
  154. UpdateData(FALSE);
  155. }
  156. }
  157. //++timo implement brush primitive here
  158. void CTextureBar::SetSurfaceAttributes()
  159. {
  160. if (g_ptrSelectedFaces.GetSize() > 0)
  161. {
  162. if (g_qeglobals.m_bBrushPrimitMode)
  163. {
  164. common->Printf("Warning : brush primitive mode not implemented in CTextureBar");
  165. }
  166. face_t *selFace = reinterpret_cast<face_t*>(g_ptrSelectedFaces.GetAt(0));
  167. texdef_t* pt = &selFace->texdef;
  168. UpdateData(TRUE);
  169. pt->shift[0] = m_nHShift;
  170. pt->shift[1] = m_nVShift;
  171. pt->scale[0] = m_nHScale;
  172. pt->scale[1] = m_nVScale;
  173. pt->rotate = m_nRotate;
  174. Sys_UpdateWindows(W_CAMERA);
  175. }
  176. }