TextureBar.cpp 5.9 KB

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