texwnd.cpp
来自「quake3工具源码。包括生成bsp文件」· C++ 代码 · 共 2,647 行 · 第 1/5 页
CPP
2,647 行
==============
*/
void Texture_ShowDirectory (int menunum, bool bLinked)
{
struct _finddata_t fileinfo;
int handle;
char name[1024];
char dirstring[1024];
char linkstring[1024];
FILELIST *list = NULL, *temp;
CString strTemp;
//Texture_Flush(false);
//Select_Deselect();
Texture_ClearInuse();
texture_showinuse = false;
strcpy (texture_directory, texture_menunames[menunum-CMD_TEXTUREWAD]);
if (g_pParentWnd->GetPlugInMgr().GetTextureInfo() != NULL)
{
if (g_pParentWnd->GetPlugInMgr().GetTextureInfo()->m_bWadStyle)
return;
}
// new
/*
if (!g_PrefsDlg.m_bShaderTest)
{
g_dontuse = true; // needed because this next piece of code calls Texture_ForName() internally! -slc
LoadDeferred(texture_directory);
g_dontuse = false;
}
*/
if (g_PrefsDlg.m_bHiColorTextures == FALSE)
{
}
g_qeglobals.d_texturewin.originy = 0;
//--if (g_PrefsDlg.m_bUseShaders)
//--{
//-- sprintf (dirstring, "%s/scripts/%s", ValueForKey (g_qeglobals.d_project_entity, "basepath"), texture_directory);
//-- Sys_Printf("loading textures from shader %s\n", dirstring);
//-- LoadShader(dirstring);
//--}
//--else
//--{
Sys_Status("Loading textures\n", 0);
// load all image files
sprintf (linkstring, "%s/textures/%stextureinfo.ini", ValueForKey (g_qeglobals.d_project_entity, "basepath"), texture_menunames[menunum-CMD_TEXTUREWAD]);
for (int nExt = 0; nExt < GetTextureExtensionCount(); nExt++)
{
sprintf (dirstring, "%s/textures/%s*.%s", ValueForKey (g_qeglobals.d_project_entity, "basepath"), texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));
Sys_Printf ("Scanning %s\n", dirstring);
handle = _findfirst (dirstring, &fileinfo);
if (handle == -1)
{
sprintf(dirstring, "%s/%s*.%s", ValueForKey (g_qeglobals.d_project_entity, "texturepath"), texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));
handle = _findfirst (dirstring, &fileinfo);
}
if (handle != -1)
{
do
{
sprintf (name, "%s%s", texture_directory, fileinfo.name);
AddToFileListAlphabetized(&list, name, FROMDISK, 0, false);
} while (_findnext( handle, &fileinfo ) != -1);
_findclose (handle);
}
else
{
sprintf (dirstring, "%s*.%s", texture_menunames[menunum-CMD_TEXTUREWAD],GetTextureExtension(nExt));
GetPackFileList(&list, dirstring);
}
}
g_dontuse = true;
for(temp = list; temp; temp = temp->next)
{
if(temp->offset == -1)
sprintf(name, "%s", temp->filename);
else
sprintf(name, "%s%s", texture_menunames[menunum-CMD_TEXTUREWAD], temp->filename);
StripExtension (name);
strTemp = name;
strTemp.MakeLower();
if ( strTemp.Find(".specular") >= 0 ||
strTemp.Find(".glow") >= 0 ||
strTemp.Find(".bump") >= 0 ||
strTemp.Find(".diffuse") >= 0 ||
strTemp.Find(".blend") >= 0 ||
strTemp.Find(".alpha") >= 0
)
continue;
else
{
Texture_ForName (name, true);
}
}
ClearFileList(&list);
//--}
g_dontuse = false;
if (!bLinked)
{
for (int k = 0; k < 10; k++)
{
sprintf(name, "Path%d", k);
if (GetPrivateProfileString("Include", name, "", dirstring, 1024, linkstring) > 0)
{
Texture_ShowDirectory(dirstring, true);
}
}
LoadShadersFromDir(texture_directory);
SortTextures();
sprintf (name, "Textures: %s", texture_directory);
SetWindowText(g_qeglobals.d_hwndEntity, name);
// select the first texture in the list
if (!g_qeglobals.d_texturewin.texdef.name[0])
SelectTexture (16, g_qeglobals.d_texturewin.height -16, false);
}
}
// this can be combined with the above, but per usual i am in a hurry
//
void Texture_ShowDirectory (char* pPath, bool bLinked)
{
struct _finddata_t fileinfo;
int handle;
char name[1024];
char dirstring[1024];
char linkstring[1024];
FILELIST *list = NULL, *temp;
//Texture_Flush(false);
texture_showinuse = false;
Texture_ClearInuse();
strcpy (texture_directory, pPath);
if (g_PrefsDlg.m_bHiColorTextures == FALSE)
{
}
g_qeglobals.d_texturewin.originy = 0;
Sys_Status("loading all textures\n", 0);
// load all .wal files
for (int nExt = 0; nExt < GetTextureExtensionCount(); nExt++)
{
sprintf(dirstring, "%s*.%s", pPath,GetTextureExtension(nExt));
Sys_Printf ("Scanning %s\n", dirstring);
handle = _findfirst (dirstring, &fileinfo);
if (handle != -1)
{
do
{
sprintf (name, "%s%s", texture_directory, fileinfo.name);
AddToFileListAlphabetized(&list, name, FROMDISK, 0, false);
} while (_findnext( handle, &fileinfo ) != -1);
_findclose (handle);
}
else
{
//sprintf (dirstring, "%s*.wal", texture_menunames[menunum-CMD_TEXTUREWAD]);
//if(!GetPackFileList(&list, dirstring))
return;
}
}
g_dontuse = true;
for(temp = list; temp; temp = temp->next)
{
if(temp->offset == -1)
sprintf(name, "%s", temp->filename);
else
sprintf(name, "%s%s", pPath, temp->filename);
StripExtension (name);
int nLen = strlen(name)-1;
ASSERT(nLen > 0);
while (name[nLen] != '\\')
nLen--;
// found first one
nLen--;
ASSERT(nLen > 0);
while (name[nLen] != '\\')
nLen--;
ASSERT(nLen >= 0);
QE_ConvertDOSToUnixName(name, name);
Texture_ForName(&name[nLen+1]);
}
ClearFileList(&list);
g_dontuse = false;
SortTextures();
if (!bLinked)
{
for (int k = 0; k < 10; k++)
{
sprintf(name, "Path%d", k);
if (GetPrivateProfileString("Include", name, "", dirstring, 1024, linkstring) > 0)
{
Texture_ShowDirectory(dirstring, true);
}
}
sprintf (name, "Textures: %s", texture_directory);
SetWindowText(g_qeglobals.d_hwndEntity, name);
// select the first texture in the list
if (!g_qeglobals.d_texturewin.texdef.name[0])
SelectTexture (16, g_qeglobals.d_texturewin.height -16 ,false);
}
}
void Texture_ResetPosition()
{
SelectTexture (16, g_qeglobals.d_texturewin.height -16 ,false);
g_qeglobals.d_texturewin.originy = 0;
}
/*
==================
Texture_SetInuse
==================
*/
void Texture_SetInuse (void)
{
qtexture_t *q;
for (q=g_qeglobals.d_qtextures ; q ; q=q->next)
{
q->inuse = true;
}
}
/*
==============
Texture_ShowAll
==============
*/
void Texture_ShowAll()
{
Texture_SetInuse();
Sys_Printf("Showing all textures...\n");
Sys_UpdateWindows (W_TEXTURE);
}
/*
==============
Texture_ShowInuse
==============
*/
void Texture_ShowInuse (void)
{
face_t *f;
brush_t *b;
char name[1024];
texture_showinuse = true;
g_dontuse = false;
g_qeglobals.d_texturewin.originy = 0;
Texture_ClearInuse();
Sys_Status("Selecting active textures\n", 0);
for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next)
{
if (b->patchBrush)
{
Texture_ForName(b->pPatch->d_texture->name);
}
else
{
for (f=b->brush_faces ; f ; f=f->next)
{
Texture_ForName (f->texdef.name);
}
}
}
for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next)
{
if (b->patchBrush)
{
Texture_ForName(b->pPatch->d_texture->name);
}
else
{
for (f=b->brush_faces ; f ; f=f->next)
{
Texture_ForName (f->texdef.name);
}
}
}
SortTextures();
//SetInspectorMode(W_TEXTURE);
Sys_UpdateWindows (W_TEXTURE);
sprintf (name, "Textures: in use");
SetWindowText(g_qeglobals.d_hwndEntity, name);
// select the first texture in the list
if (!g_qeglobals.d_texturewin.texdef.name[0])
{
SelectTexture (16, g_qeglobals.d_texturewin.height -16, false);
}
}
/*
============================================================================
TEXTURE LAYOUT
============================================================================
*/
void Texture_StartPos (void)
{
current_texture = g_qeglobals.d_qtextures;
current_x = 8;
current_y = -8;
current_row = 0;
}
qtexture_t *Texture_NextPos (int *x, int *y)
{
qtexture_t *q;
while (1)
{
q = current_texture;
if (!q)
return q;
current_texture = current_texture->next;
if (q->name[0] == '(') // fake color texture
continue;
if (g_bFilterEnabled)
{
CString strName = q->name;
int nPos = strName.Find('\\');
if (nPos == -1)
nPos = strName.Find('/');
if (nPos >= 0)
strName = strName.Right(strName.GetLength() - nPos - 1);
if (strnicmp(g_strFilter.GetBuffer(0), strName, g_strFilter.GetLength()) == 0)
break;
else
continue;
}
if (q->bFromShader && g_PrefsDlg.m_bShowShaders == FALSE)
{
continue;
}
if (q->inuse)
break; // always show in use
if (!texture_showinuse && !strnicmp (q->name, texture_directory, strlen(texture_directory)))
break;
continue;
}
int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;
int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;
if (current_x + nWidth > g_qeglobals.d_texturewin.width-8 && current_row)
{ // go to the next row unless the texture is the first on the row
current_x = 8;
current_y -= current_row + FONT_HEIGHT + 4;
current_row = 0;
}
*x = current_x;
*y = current_y;
// Is our texture larger than the row? If so, grow the
// row height to match it
if (current_row < nHeight)
current_row = nHeight;
// never go less than 64, or the names get all crunched up
current_x += nWidth < 64 ? 64 : nWidth;
current_x += 8;
return q;
}
/*
============================================================================
MOUSE ACTIONS
============================================================================
*/
static int textures_cursorx, textures_cursory;
/*
============
Texture_SetTexture
brushprimit_texdef must be understood as a qtexture_t with width=2 height=2 ( the default one )
============
*/
void Texture_SetTexture (texdef_t *texdef, brushprimit_texdef_t *brushprimit_texdef, bool bFitScale, IPluginTexdef *pTexdef, bool bSetSelection )
{
qtexture_t *q;
int x,y;
if (texdef->name[0] == '(')
{
Sys_Status("Can't select an entity texture\n", 0);
return;
}
g_qeglobals.d_texturewin.texdef = *texdef;
g_qeglobals.d_texturewin.texdef.flags &= ~SURF_KEEP;
g_qeglobals.d_texturewin.texdef.contents &= ~CONTENTS_KEEP;
// store the texture coordinates for new brush primitive mode
// be sure that all the callers are using the default 2x2 texture
if (g_qeglobals.m_bBrushPrimitMode)
{
g_qeglobals.d_texturewin.brushprimit_texdef = *brushprimit_texdef;
}
// surface properties plugin
if (g_qeglobals.bSurfacePropertiesPlugin)
{
if (g_qeglobals.d_texturewin.pTexdef)
{
// decrement reference count
static_cast<IPluginTexdef *>(g_qeglobals.d_texturewin.pTexdef)->DecRef();
g_qeglobals.d_texturewin.pTexdef = NULL;
}
if (pTexdef)
{
g_qeglobals.d_texturewin.pTexdef = pTexdef->Copy();
}
}
Sys_UpdateWindows (W_TEXTURE);
g_dlgFind.updateTextures(texdef->name);
if (!g_dlgFind.isOpen() && bSetSelection)
{
Select_SetTexture(texdef,brushprimit_texdef,bFitScale);
}
//plugins: send a message telling that the selected texture may have changed
DispatchRadiantMsg( RADIANT_TEXTURE );
// scroll origin so the texture is completely on screen
Texture_StartPos ();
while (1)
{
q = Texture_NextPos (&x, &y);
if (!q)
break;
int nWidth = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->width * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->width;
int nHeight = (g_PrefsDlg.m_bHiColorTextures == TRUE) ? q->height * ((float)g_PrefsDlg.m_nTextureScale / 100) : q->height;
if (!strcmpi(texdef->name, q->name))
{
if (y > g_qeglobals.d_texturewin.originy)
{
g_qeglobals.d_texturewin.originy = y;
Sys_UpdateWindows (W_TEXTURE);
return;
}
if (y-nHeight-2*FONT_HEIGHT < g_qeglobals.d_texturewin.originy-g_qeglobals.d_texturewin.height)
{
g_qeglobals.d_texturewin.originy = y-nHeight-2*FONT_HEIGHT+g_qeglobals.d_texturewin.height;
Sys_UpdateWindows (W_TEXTURE);
return;
}
return;
}
}
}
HWND FindEditWindow()
{
HWND hwnd = FindWindow("TEditPadForm", NULL);
HWND hwndEdit = NULL;
if (hwnd != NULL)
{
HWND hwndTab = FindWindowEx(hwnd, NULL, "TTabControl", NULL);
if (hwndTab != NULL)
{
hwndEdit = FindWindowEx(hwndTab, NULL, "TRicherEdit", NULL);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?