]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/selectedface.cpp
Merge pull request #21 from merlin1991/Q3-gamepack-fix
[xonotic/netradiant.git] / radiant / selectedface.cpp
1 /*
2    Copyright (C) 1999-2007 id Software, Inc. and contributors.
3    For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5    This file is part of GtkRadiant.
6
7    GtkRadiant is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    GtkRadiant is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with GtkRadiant; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 //-----------------------------------------------------------------------------
23 //
24 // DESCRIPTION:
25 // Quick interface hack for selected face interface
26 // this one really needs more work, but I'm in a hurry with TexTool
27
28 #include "stdafx.h"
29
30 int WINAPI QERApp_GetSelectedFaceCount(){
31         return g_ptrSelectedFaces.GetSize();
32 }
33
34 face_t* WINAPI QERApp_GetSelectedFace( int iface ){
35         if ( iface >= g_ptrSelectedFaces.GetSize() ) {
36                 Sys_FPrintf( SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n" );
37                 return NULL;
38         }
39         return reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
40 }
41
42 brush_t* WINAPI QERApp_GetSelectedFaceBrush( int iface ){
43         if ( iface >= g_ptrSelectedFaceBrushes.GetSize() ) {
44                 Sys_FPrintf( SYS_ERR, "QERApp_GetFace: selected faces count exceeded\n" );
45                 return NULL;
46         }
47         return reinterpret_cast<brush_t*>( g_ptrSelectedFaceBrushes.GetAt( iface ) );
48 }
49
50 // NOTE: we expect pWinding to have MAX_POINTS_ON_WINDING points ready for writing
51 int WINAPI QERApp_GetFaceInfo( int iface, _QERFaceData *pFaceData, winding_t *pWinding ){
52         size_t size;
53
54         if ( iface >= g_ptrSelectedFaces.GetSize() ) {
55                 Sys_FPrintf( SYS_ERR, "QERApp_GetFaceInfo: selected faces count exceeded\n" );
56                 return 0;
57         }
58         if ( !g_qeglobals.m_bBrushPrimitMode ) {
59                 Sys_Printf( "Warning: unexpected QERApp_GetFaceInfo out of brush primitive mode\n" );
60                 return 0;
61         }
62         face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
63         strcpy( pFaceData->m_TextureName, selFace->texdef.GetName() );
64         VectorCopy( selFace->planepts[0], pFaceData->m_v1 );
65         VectorCopy( selFace->planepts[1], pFaceData->m_v2 );
66         VectorCopy( selFace->planepts[2], pFaceData->m_v3 );
67         pFaceData->m_bBPrimit = true;
68         memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof( brushprimit_texdef_t ) );
69         size = (size_t)( (winding_t *)0 )->points[selFace->face_winding->numpoints];
70         memcpy( pWinding, selFace->face_winding, size );
71         return 1;
72 }
73
74 int WINAPI QERApp_SetFaceInfo( int iface, _QERFaceData *pFaceData ){
75         if ( iface >= g_ptrSelectedFaces.GetSize() ) {
76                 Sys_FPrintf( SYS_ERR, "QERApp_SetFaceInfo: selected faces count exceeded\n" );
77                 return 0;
78         }
79         if ( !g_qeglobals.m_bBrushPrimitMode ) {
80                 Sys_Printf( "Warning: unexpected QERApp_SetFaceInfo out of brush primitive mode\n" );
81                 return 0;
82         }
83         face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
84         brush_t *selBrush = reinterpret_cast<brush_t*>( g_ptrSelectedFaceBrushes.GetAt( iface ) );
85         //strcpy( selected_face->texdef.name, pFaceData->m_TextureName );
86         selFace->texdef.SetName( pFaceData->m_TextureName );
87         VectorCopy( pFaceData->m_v1, selFace->planepts[0] );
88         VectorCopy( pFaceData->m_v2, selFace->planepts[1] );
89         VectorCopy( pFaceData->m_v3, selFace->planepts[2] );
90         memcpy( &selFace->brushprimit_texdef, &pFaceData->brushprimit_texdef, sizeof( brushprimit_texdef_t ) );
91         Brush_Build( selBrush );
92         Sys_UpdateWindows( W_ALL );
93         return 1;
94 }
95
96 int WINAPI QERApp_ISelectedFace_GetTextureNumber( int iface ){
97         if ( iface >= g_ptrSelectedFaces.GetSize() ) {
98                 Sys_FPrintf( SYS_ERR, "QERApp_ISelectedFace_GetTextureNumber: selected faces count exceeded\n" );
99                 return 0;
100         }
101         face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
102         return selFace->d_texture->texture_number;
103 }
104
105 void WINAPI QERApp_GetTextureSize( int iface, int Size[2] ){
106         if ( iface >= g_ptrSelectedFaces.GetSize() ) {
107                 Sys_FPrintf( SYS_ERR, "QERApp_GetTextureSize: selected faces count exceeded\n" );
108                 return;
109         }
110         face_t *selFace = reinterpret_cast<face_t*>( g_ptrSelectedFaces.GetAt( iface ) );
111         Size[0] = selFace->d_texture->width;
112         Size[1] = selFace->d_texture->height;
113 }