mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-12 08:11:10 +02:00
1577 lines
46 KiB
C++
1577 lines
46 KiB
C++
/*
|
|
===========================================================================
|
|
|
|
IceTech GPL Source Code
|
|
Copyright (C) 2026 Justin Marshall
|
|
|
|
This file is part of the IceTech GPL Source Code (?IceTech Source Code?).
|
|
|
|
IceTech Source Code is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
IceTech Source Code is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with IceTech Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
In addition, the IceTech 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 IceTech Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing Justin Marshall, justinmarshall20@gmail.com
|
|
|
|
===========================================================================
|
|
*/
|
|
|
|
#include "precompiled.h"
|
|
#pragma hdrstop
|
|
|
|
#include "qe3.h"
|
|
#include "Radiant.h"
|
|
#include "WaitDlg.h"
|
|
#include "DialogTextures.h"
|
|
#include "DialogInfo.h"
|
|
#include "EditViewDlg.h"
|
|
#include <commctrl.h>
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
// IceTech dark MFC/common-control helper
|
|
// --------------------------------------------------------------------------
|
|
#ifndef BS_TYPEMASK
|
|
#define BS_TYPEMASK 0x0000000F
|
|
#endif
|
|
|
|
static const COLORREF ICE_DARK_BG = RGB(17, 19, 23);
|
|
static const COLORREF ICE_DARK_PANEL = RGB(24, 27, 32);
|
|
static const COLORREF ICE_DARK_PANEL_ALT = RGB(29, 33, 39);
|
|
static const COLORREF ICE_DARK_FIELD = RGB(14, 16, 20);
|
|
static const COLORREF ICE_DARK_BORDER = RGB(55, 62, 72);
|
|
static const COLORREF ICE_DARK_BORDER_HOT = RGB(87, 166, 255);
|
|
static const COLORREF ICE_DARK_TEXT = RGB(226, 232, 240);
|
|
static const COLORREF ICE_DARK_TEXT_MUTED = RGB(151, 163, 184);
|
|
static const COLORREF ICE_DARK_TEXT_DISABLED = RGB(103, 112, 128);
|
|
static const COLORREF ICE_DARK_ACCENT = RGB(87, 166, 255);
|
|
|
|
static const char* ICE_DARK_PARENT_OLDPROC = "IceTech.Dark.ParentOldProc";
|
|
static const char* ICE_DARK_CONTROL_OLDPROC = "IceTech.Dark.ControlOldProc";
|
|
|
|
static int IceDark_MaxInt(int a, int b) {
|
|
return (a > b) ? a : b;
|
|
}
|
|
|
|
static HBRUSH IceDark_BgBrush() {
|
|
static HBRUSH hBrush = ::CreateSolidBrush(ICE_DARK_BG);
|
|
return hBrush;
|
|
}
|
|
|
|
static HBRUSH IceDark_PanelBrush() {
|
|
static HBRUSH hBrush = ::CreateSolidBrush(ICE_DARK_PANEL);
|
|
return hBrush;
|
|
}
|
|
|
|
static HBRUSH IceDark_FieldBrush() {
|
|
static HBRUSH hBrush = ::CreateSolidBrush(ICE_DARK_FIELD);
|
|
return hBrush;
|
|
}
|
|
|
|
static void IceDark_FillRect(HDC hDC, const RECT& rc, COLORREF color) {
|
|
HBRUSH brush = ::CreateSolidBrush(color);
|
|
::FillRect(hDC, &rc, brush);
|
|
::DeleteObject(brush);
|
|
}
|
|
|
|
static void IceDark_FrameRect(HDC hDC, const RECT& rc, COLORREF color) {
|
|
HBRUSH brush = ::CreateSolidBrush(color);
|
|
::FrameRect(hDC, &rc, brush);
|
|
::DeleteObject(brush);
|
|
}
|
|
|
|
static void IceDark_ApplyNativeTheme(HWND hWnd) {
|
|
if (!hWnd) {
|
|
return;
|
|
}
|
|
|
|
typedef HRESULT (WINAPI *SetWindowThemeProc)(HWND, LPCWSTR, LPCWSTR);
|
|
typedef BOOL (WINAPI *AllowDarkModeForWindowProc)(HWND, BOOL);
|
|
|
|
static HMODULE hUxTheme = ::LoadLibraryA("uxtheme.dll");
|
|
static SetWindowThemeProc pSetWindowTheme = hUxTheme ? (SetWindowThemeProc)::GetProcAddress(hUxTheme, "SetWindowTheme") : NULL;
|
|
static AllowDarkModeForWindowProc pAllowDarkModeForWindow = hUxTheme ? (AllowDarkModeForWindowProc)::GetProcAddress(hUxTheme, MAKEINTRESOURCEA(133)) : NULL;
|
|
|
|
if (pAllowDarkModeForWindow) {
|
|
pAllowDarkModeForWindow(hWnd, TRUE);
|
|
}
|
|
if (pSetWindowTheme) {
|
|
pSetWindowTheme(hWnd, L"DarkMode_Explorer", NULL);
|
|
}
|
|
::SendMessage(hWnd, WM_THEMECHANGED, 0, 0);
|
|
}
|
|
|
|
static void IceDark_RemoveClientEdge(HWND hWnd) {
|
|
if (!hWnd) {
|
|
return;
|
|
}
|
|
LONG exStyle = ::GetWindowLong(hWnd, GWL_EXSTYLE);
|
|
if (exStyle & WS_EX_CLIENTEDGE) {
|
|
::SetWindowLong(hWnd, GWL_EXSTYLE, exStyle & ~WS_EX_CLIENTEDGE);
|
|
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
|
|
}
|
|
}
|
|
|
|
static void IceDark_DrawFrame(HWND hWnd, COLORREF color) {
|
|
HDC hDC = ::GetWindowDC(hWnd);
|
|
if (!hDC) {
|
|
return;
|
|
}
|
|
RECT rc;
|
|
::GetWindowRect(hWnd, &rc);
|
|
::OffsetRect(&rc, -rc.left, -rc.top);
|
|
IceDark_FrameRect(hDC, rc, color);
|
|
::ReleaseDC(hWnd, hDC);
|
|
}
|
|
|
|
static void IceDark_DrawButton(HWND hWnd, HDC hDC) {
|
|
RECT rc;
|
|
::GetClientRect(hWnd, &rc);
|
|
|
|
const UINT style = (UINT)::GetWindowLong(hWnd, GWL_STYLE);
|
|
const UINT type = style & BS_TYPEMASK;
|
|
const bool enabled = ::IsWindowEnabled(hWnd) ? true : false;
|
|
const bool pushed = (::SendMessage(hWnd, BM_GETSTATE, 0, 0) & BST_PUSHED) != 0;
|
|
const bool checked = (::SendMessage(hWnd, BM_GETCHECK, 0, 0) == BST_CHECKED);
|
|
const bool isCheck = (type == BS_CHECKBOX || type == BS_AUTOCHECKBOX || type == BS_3STATE || type == BS_AUTO3STATE);
|
|
const bool isRadio = (type == BS_RADIOBUTTON || type == BS_AUTORADIOBUTTON);
|
|
const bool isGroup = (type == BS_GROUPBOX);
|
|
|
|
char text[512];
|
|
text[0] = '\0';
|
|
::GetWindowTextA(hWnd, text, sizeof(text));
|
|
|
|
HFONT font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0);
|
|
HFONT oldFont = font ? (HFONT)::SelectObject(hDC, font) : NULL;
|
|
::SetBkMode(hDC, TRANSPARENT);
|
|
::SetTextColor(hDC, enabled ? ICE_DARK_TEXT : ICE_DARK_TEXT_DISABLED);
|
|
|
|
if (isGroup) {
|
|
IceDark_FillRect(hDC, rc, ICE_DARK_BG);
|
|
RECT textRect = rc;
|
|
textRect.left += 10;
|
|
textRect.right -= 8;
|
|
textRect.bottom = textRect.top + 18;
|
|
SIZE textSize;
|
|
textSize.cx = textSize.cy = 0;
|
|
::GetTextExtentPoint32A(hDC, text, (int)strlen(text), &textSize);
|
|
RECT frame = rc;
|
|
frame.top += 8;
|
|
HPEN pen = ::CreatePen(PS_SOLID, 1, ICE_DARK_BORDER);
|
|
HPEN oldPen = (HPEN)::SelectObject(hDC, pen);
|
|
HBRUSH oldBrush = (HBRUSH)::SelectObject(hDC, ::GetStockObject(NULL_BRUSH));
|
|
::RoundRect(hDC, frame.left, frame.top, frame.right, frame.bottom, 8, 8);
|
|
::SelectObject(hDC, oldBrush);
|
|
::SelectObject(hDC, oldPen);
|
|
::DeleteObject(pen);
|
|
RECT fillLabel = textRect;
|
|
fillLabel.right = fillLabel.left + textSize.cx + 8;
|
|
IceDark_FillRect(hDC, fillLabel, ICE_DARK_BG);
|
|
::SetTextColor(hDC, ICE_DARK_TEXT_MUTED);
|
|
::DrawTextA(hDC, text, -1, &textRect, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_END_ELLIPSIS);
|
|
}
|
|
else if (isCheck || isRadio) {
|
|
IceDark_FillRect(hDC, rc, ICE_DARK_BG);
|
|
|
|
RECT box = rc;
|
|
box.left += 3;
|
|
box.right = box.left + 15;
|
|
box.top += IceDark_MaxInt(0, (rc.bottom - rc.top - 15) / 2);
|
|
box.bottom = box.top + 15;
|
|
|
|
if (isRadio) {
|
|
HPEN pen = ::CreatePen(PS_SOLID, 1, checked ? ICE_DARK_ACCENT : ICE_DARK_BORDER);
|
|
HPEN oldPen = (HPEN)::SelectObject(hDC, pen);
|
|
HBRUSH brush = ::CreateSolidBrush(enabled ? ICE_DARK_FIELD : RGB(20, 22, 26));
|
|
HBRUSH oldBrush = (HBRUSH)::SelectObject(hDC, brush);
|
|
::Ellipse(hDC, box.left, box.top, box.right, box.bottom);
|
|
::SelectObject(hDC, oldBrush);
|
|
::DeleteObject(brush);
|
|
::SelectObject(hDC, oldPen);
|
|
::DeleteObject(pen);
|
|
if (checked) {
|
|
RECT dot = box;
|
|
::InflateRect(&dot, -4, -4);
|
|
HBRUSH dotBrush = ::CreateSolidBrush(enabled ? ICE_DARK_ACCENT : ICE_DARK_TEXT_DISABLED);
|
|
HBRUSH oldDotBrush = (HBRUSH)::SelectObject(hDC, dotBrush);
|
|
HPEN dotPen = ::CreatePen(PS_SOLID, 1, enabled ? ICE_DARK_ACCENT : ICE_DARK_TEXT_DISABLED);
|
|
HPEN oldDotPen = (HPEN)::SelectObject(hDC, dotPen);
|
|
::Ellipse(hDC, dot.left, dot.top, dot.right, dot.bottom);
|
|
::SelectObject(hDC, oldDotPen);
|
|
::DeleteObject(dotPen);
|
|
::SelectObject(hDC, oldDotBrush);
|
|
::DeleteObject(dotBrush);
|
|
}
|
|
}
|
|
else {
|
|
IceDark_FillRect(hDC, box, enabled ? ICE_DARK_FIELD : RGB(20, 22, 26));
|
|
IceDark_FrameRect(hDC, box, checked ? ICE_DARK_ACCENT : ICE_DARK_BORDER);
|
|
if (checked) {
|
|
HPEN pen = ::CreatePen(PS_SOLID, 2, enabled ? ICE_DARK_ACCENT : ICE_DARK_TEXT_DISABLED);
|
|
HPEN oldPen = (HPEN)::SelectObject(hDC, pen);
|
|
::MoveToEx(hDC, box.left + 3, box.top + 7, NULL);
|
|
::LineTo(hDC, box.left + 6, box.top + 10);
|
|
::LineTo(hDC, box.right - 3, box.top + 3);
|
|
::SelectObject(hDC, oldPen);
|
|
::DeleteObject(pen);
|
|
}
|
|
}
|
|
|
|
RECT textRect = rc;
|
|
textRect.left = box.right + 7;
|
|
textRect.right -= 2;
|
|
::DrawTextA(hDC, text, -1, &textRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
|
|
}
|
|
else {
|
|
COLORREF face = pushed ? RGB(22, 25, 30) : ICE_DARK_PANEL_ALT;
|
|
IceDark_FillRect(hDC, rc, face);
|
|
IceDark_FrameRect(hDC, rc, enabled ? ICE_DARK_BORDER : RGB(39, 44, 52));
|
|
RECT inner = rc;
|
|
::InflateRect(&inner, -1, -1);
|
|
if (!pushed) {
|
|
IceDark_FrameRect(hDC, inner, RGB(35, 40, 47));
|
|
}
|
|
RECT textRect = rc;
|
|
if (pushed) {
|
|
::OffsetRect(&textRect, 1, 1);
|
|
}
|
|
::DrawTextA(hDC, text, -1, &textRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
|
|
}
|
|
|
|
if (oldFont) {
|
|
::SelectObject(hDC, oldFont);
|
|
}
|
|
}
|
|
|
|
static LRESULT CALLBACK IceDark_ButtonProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
WNDPROC oldProc = (WNDPROC)::GetPropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
if (!oldProc) {
|
|
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
switch (uMsg) {
|
|
case WM_ERASEBKGND:
|
|
return 1;
|
|
case WM_PAINT:
|
|
{
|
|
UINT style = (UINT)::GetWindowLong(hWnd, GWL_STYLE);
|
|
if (style & (BS_BITMAP | BS_ICON)) {
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
IceDark_DrawFrame(hWnd, ICE_DARK_BORDER);
|
|
return result;
|
|
}
|
|
PAINTSTRUCT ps;
|
|
HDC hDC = ::BeginPaint(hWnd, &ps);
|
|
IceDark_DrawButton(hWnd, hDC);
|
|
::EndPaint(hWnd, &ps);
|
|
return 0;
|
|
}
|
|
case WM_PRINTCLIENT:
|
|
IceDark_DrawButton(hWnd, (HDC)wParam);
|
|
return 0;
|
|
case WM_MOUSEMOVE:
|
|
case WM_LBUTTONDOWN:
|
|
case WM_LBUTTONUP:
|
|
case WM_ENABLE:
|
|
case WM_SETTEXT:
|
|
case BM_SETCHECK:
|
|
case BM_SETSTATE:
|
|
{
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
::InvalidateRect(hWnd, NULL, FALSE);
|
|
return result;
|
|
}
|
|
case WM_NCDESTROY:
|
|
{
|
|
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)oldProc);
|
|
::RemovePropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
static void IceDark_DrawCombo(HWND hWnd, HDC hDC) {
|
|
RECT rc;
|
|
::GetClientRect(hWnd, &rc);
|
|
const bool enabled = ::IsWindowEnabled(hWnd) ? true : false;
|
|
const bool focused = (::GetFocus() == hWnd || ::IsChild(hWnd, ::GetFocus())) ? true : false;
|
|
|
|
IceDark_FillRect(hDC, rc, enabled ? ICE_DARK_FIELD : RGB(20, 22, 26));
|
|
IceDark_FrameRect(hDC, rc, focused ? ICE_DARK_BORDER_HOT : ICE_DARK_BORDER);
|
|
|
|
RECT arrow = rc;
|
|
arrow.left = arrow.right - 22;
|
|
IceDark_FillRect(hDC, arrow, ICE_DARK_PANEL_ALT);
|
|
IceDark_FrameRect(hDC, arrow, ICE_DARK_BORDER);
|
|
|
|
POINT pts[3];
|
|
int cx = arrow.left + (arrow.right - arrow.left) / 2;
|
|
int cy = arrow.top + (arrow.bottom - arrow.top) / 2 + 1;
|
|
pts[0].x = cx - 4; pts[0].y = cy - 2;
|
|
pts[1].x = cx + 4; pts[1].y = cy - 2;
|
|
pts[2].x = cx; pts[2].y = cy + 3;
|
|
HBRUSH arrowBrush = ::CreateSolidBrush(enabled ? ICE_DARK_TEXT : ICE_DARK_TEXT_DISABLED);
|
|
HBRUSH oldBrush = (HBRUSH)::SelectObject(hDC, arrowBrush);
|
|
HPEN arrowPen = ::CreatePen(PS_SOLID, 1, enabled ? ICE_DARK_TEXT : ICE_DARK_TEXT_DISABLED);
|
|
HPEN oldPen = (HPEN)::SelectObject(hDC, arrowPen);
|
|
::Polygon(hDC, pts, 3);
|
|
::SelectObject(hDC, oldPen);
|
|
::DeleteObject(arrowPen);
|
|
::SelectObject(hDC, oldBrush);
|
|
::DeleteObject(arrowBrush);
|
|
|
|
char text[512];
|
|
text[0] = '\0';
|
|
int sel = (int)::SendMessage(hWnd, CB_GETCURSEL, 0, 0);
|
|
if (sel >= 0) {
|
|
::SendMessageA(hWnd, CB_GETLBTEXT, (WPARAM)sel, (LPARAM)text);
|
|
}
|
|
else {
|
|
::GetWindowTextA(hWnd, text, sizeof(text));
|
|
}
|
|
|
|
HFONT font = (HFONT)::SendMessage(hWnd, WM_GETFONT, 0, 0);
|
|
HFONT oldFont = font ? (HFONT)::SelectObject(hDC, font) : NULL;
|
|
::SetBkMode(hDC, TRANSPARENT);
|
|
::SetTextColor(hDC, enabled ? ICE_DARK_TEXT : ICE_DARK_TEXT_DISABLED);
|
|
RECT textRect = rc;
|
|
textRect.left += 7;
|
|
textRect.right = arrow.left - 3;
|
|
::DrawTextA(hDC, text, -1, &textRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
|
|
if (oldFont) {
|
|
::SelectObject(hDC, oldFont);
|
|
}
|
|
}
|
|
|
|
static LRESULT CALLBACK IceDark_ComboProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
WNDPROC oldProc = (WNDPROC)::GetPropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
if (!oldProc) {
|
|
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
switch (uMsg) {
|
|
case WM_ERASEBKGND:
|
|
return 1;
|
|
case WM_PAINT:
|
|
{
|
|
UINT comboType = (UINT)::GetWindowLong(hWnd, GWL_STYLE) & 0x00000003;
|
|
if (comboType == CBS_DROPDOWNLIST) {
|
|
PAINTSTRUCT ps;
|
|
HDC hDC = ::BeginPaint(hWnd, &ps);
|
|
IceDark_DrawCombo(hWnd, hDC);
|
|
::EndPaint(hWnd, &ps);
|
|
return 0;
|
|
}
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
IceDark_DrawFrame(hWnd, (::GetFocus() == hWnd || ::IsChild(hWnd, ::GetFocus())) ? ICE_DARK_BORDER_HOT : ICE_DARK_BORDER);
|
|
return result;
|
|
}
|
|
case WM_SETFOCUS:
|
|
case WM_KILLFOCUS:
|
|
case WM_ENABLE:
|
|
case WM_SETTEXT:
|
|
case CB_SETCURSEL:
|
|
case CB_ADDSTRING:
|
|
case CB_DELETESTRING:
|
|
case CB_RESETCONTENT:
|
|
{
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
::InvalidateRect(hWnd, NULL, FALSE);
|
|
return result;
|
|
}
|
|
case WM_NCDESTROY:
|
|
{
|
|
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)oldProc);
|
|
::RemovePropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
static LRESULT CALLBACK IceDark_FieldProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
WNDPROC oldProc = (WNDPROC)::GetPropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
if (!oldProc) {
|
|
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
switch (uMsg) {
|
|
case WM_NCPAINT:
|
|
case WM_PAINT:
|
|
{
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
IceDark_DrawFrame(hWnd, (::GetFocus() == hWnd) ? ICE_DARK_BORDER_HOT : ICE_DARK_BORDER);
|
|
return result;
|
|
}
|
|
case WM_SETFOCUS:
|
|
case WM_KILLFOCUS:
|
|
case WM_ENABLE:
|
|
{
|
|
LRESULT result = ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
::RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
|
|
return result;
|
|
}
|
|
case WM_NCDESTROY:
|
|
{
|
|
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)oldProc);
|
|
::RemovePropA(hWnd, ICE_DARK_CONTROL_OLDPROC);
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
static LRESULT CALLBACK IceDark_ParentProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|
WNDPROC oldProc = (WNDPROC)::GetPropA(hWnd, ICE_DARK_PARENT_OLDPROC);
|
|
if (!oldProc) {
|
|
return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
switch (uMsg) {
|
|
case WM_ERASEBKGND:
|
|
{
|
|
RECT rc;
|
|
::GetClientRect(hWnd, &rc);
|
|
IceDark_FillRect((HDC)wParam, rc, ICE_DARK_BG);
|
|
return 1;
|
|
}
|
|
case WM_CTLCOLORDLG:
|
|
return (LRESULT)IceDark_BgBrush();
|
|
case WM_CTLCOLORSTATIC:
|
|
{
|
|
HDC hDC = (HDC)wParam;
|
|
::SetTextColor(hDC, ICE_DARK_TEXT_MUTED);
|
|
::SetBkMode(hDC, TRANSPARENT);
|
|
return (LRESULT)IceDark_BgBrush();
|
|
}
|
|
case WM_CTLCOLOREDIT:
|
|
case WM_CTLCOLORLISTBOX:
|
|
{
|
|
HDC hDC = (HDC)wParam;
|
|
::SetTextColor(hDC, ICE_DARK_TEXT);
|
|
::SetBkColor(hDC, ICE_DARK_FIELD);
|
|
return (LRESULT)IceDark_FieldBrush();
|
|
}
|
|
case WM_CTLCOLORBTN:
|
|
{
|
|
HDC hDC = (HDC)wParam;
|
|
::SetTextColor(hDC, ICE_DARK_TEXT);
|
|
::SetBkColor(hDC, ICE_DARK_BG);
|
|
return (LRESULT)IceDark_BgBrush();
|
|
}
|
|
case WM_NCDESTROY:
|
|
{
|
|
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)oldProc);
|
|
::RemovePropA(hWnd, ICE_DARK_PARENT_OLDPROC);
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
}
|
|
|
|
return ::CallWindowProc(oldProc, hWnd, uMsg, wParam, lParam);
|
|
}
|
|
|
|
static void IceDark_Subclass(HWND hWnd, WNDPROC proc, const char* propName) {
|
|
if (!hWnd || ::GetPropA(hWnd, propName)) {
|
|
return;
|
|
}
|
|
WNDPROC oldProc = (WNDPROC)::GetWindowLongPtr(hWnd, GWLP_WNDPROC);
|
|
::SetPropA(hWnd, propName, (HANDLE)oldProc);
|
|
::SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)proc);
|
|
}
|
|
|
|
static bool IceDark_IsClass(HWND hWnd, const char* className) {
|
|
char actual[128];
|
|
actual[0] = '\0';
|
|
::GetClassNameA(hWnd, actual, sizeof(actual));
|
|
return ::lstrcmpiA(actual, className) == 0;
|
|
}
|
|
|
|
static bool IceDark_IsKnownControl(HWND hWnd) {
|
|
return IceDark_IsClass(hWnd, "Button") ||
|
|
IceDark_IsClass(hWnd, "Edit") ||
|
|
IceDark_IsClass(hWnd, "ComboBox") ||
|
|
IceDark_IsClass(hWnd, "ListBox") ||
|
|
IceDark_IsClass(hWnd, "SysTreeView32") ||
|
|
IceDark_IsClass(hWnd, "SysListView32") ||
|
|
IceDark_IsClass(hWnd, "msctls_trackbar32") ||
|
|
IceDark_IsClass(hWnd, "msctls_updown32") ||
|
|
IceDark_IsClass(hWnd, "ScrollBar") ||
|
|
IceDark_IsClass(hWnd, "SysTabControl32");
|
|
}
|
|
|
|
static void IceDark_ApplyToWindowAndChildren(HWND hWnd) {
|
|
if (!hWnd) {
|
|
return;
|
|
}
|
|
|
|
IceDark_ApplyNativeTheme(hWnd);
|
|
IceDark_RemoveClientEdge(hWnd);
|
|
|
|
if (IceDark_IsClass(hWnd, "Button")) {
|
|
IceDark_Subclass(hWnd, IceDark_ButtonProc, ICE_DARK_CONTROL_OLDPROC);
|
|
}
|
|
else if (IceDark_IsClass(hWnd, "ComboBox")) {
|
|
IceDark_Subclass(hWnd, IceDark_ComboProc, ICE_DARK_CONTROL_OLDPROC);
|
|
}
|
|
else if (IceDark_IsClass(hWnd, "Edit") || IceDark_IsClass(hWnd, "ListBox") || IceDark_IsClass(hWnd, "SysTreeView32") || IceDark_IsClass(hWnd, "SysListView32")) {
|
|
IceDark_Subclass(hWnd, IceDark_FieldProc, ICE_DARK_CONTROL_OLDPROC);
|
|
}
|
|
else if (!IceDark_IsKnownControl(hWnd)) {
|
|
IceDark_Subclass(hWnd, IceDark_ParentProc, ICE_DARK_PARENT_OLDPROC);
|
|
}
|
|
|
|
if (IceDark_IsClass(hWnd, "SysTreeView32")) {
|
|
::SendMessage(hWnd, TVM_SETBKCOLOR, 0, (LPARAM)ICE_DARK_FIELD);
|
|
::SendMessage(hWnd, TVM_SETTEXTCOLOR, 0, (LPARAM)ICE_DARK_TEXT);
|
|
}
|
|
if (IceDark_IsClass(hWnd, "SysListView32")) {
|
|
::SendMessage(hWnd, LVM_SETBKCOLOR, 0, (LPARAM)ICE_DARK_FIELD);
|
|
::SendMessage(hWnd, LVM_SETTEXTBKCOLOR, 0, (LPARAM)ICE_DARK_FIELD);
|
|
::SendMessage(hWnd, LVM_SETTEXTCOLOR, 0, (LPARAM)ICE_DARK_TEXT);
|
|
}
|
|
|
|
for (HWND child = ::GetWindow(hWnd, GW_CHILD); child != NULL; child = ::GetWindow(child, GW_HWNDNEXT)) {
|
|
IceDark_ApplyToWindowAndChildren(child);
|
|
}
|
|
|
|
::InvalidateRect(hWnd, NULL, TRUE);
|
|
}
|
|
|
|
static void IceDark_ApplyToDialog(CWnd* wnd) {
|
|
if (wnd && wnd->GetSafeHwnd()) {
|
|
IceDark_ApplyToWindowAndChildren(wnd->GetSafeHwnd());
|
|
}
|
|
}
|
|
HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent);
|
|
extern void Select_SetKeyVal(const char *key, const char *val);
|
|
|
|
const char *CDialogTextures::TypeNames[] = {
|
|
"None",
|
|
"Textures",
|
|
"Materials",
|
|
"Models",
|
|
"Scripts",
|
|
"Sounds",
|
|
"SoundParent",
|
|
"Guis",
|
|
"Particles",
|
|
"Fx"
|
|
};
|
|
|
|
//
|
|
// =======================================================================================================================
|
|
// CDialogTextures dialog
|
|
// =======================================================================================================================
|
|
//
|
|
CDialogTextures::CDialogTextures(CWnd *pParent /* =NULL */ ) :
|
|
CDialog(CDialogTextures::IDD, pParent) {
|
|
setTexture = true;
|
|
ignoreCollapse = false;
|
|
mode = TEXTURES;
|
|
editMaterial = NULL;
|
|
editGui = "";
|
|
//{{AFX_DATA_INIT(CDialogTextures)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::DoDataExchange(CDataExchange *pDX) {
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDialogTextures)
|
|
DDX_Control(pDX, IDC_CHECK_HIDEROOT, m_chkHideRoot);
|
|
DDX_Control(pDX, IDC_REFRESH, m_btnRefresh);
|
|
DDX_Control(pDX, IDC_LOAD, m_btnLoad);
|
|
DDX_Control(pDX, IDC_PREVIEW, m_wndPreview);
|
|
DDX_Control(pDX, IDC_TREE_TEXTURES, m_treeTextures);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CDialogTextures, CDialog)
|
|
//{{AFX_MSG_MAP(CDialogTextures)
|
|
ON_BN_CLICKED(IDC_LOAD, OnLoad)
|
|
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
|
|
ON_NOTIFY(NM_CLICK, IDC_TREE_TEXTURES, OnClickTreeTextures)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_TEXTURES, OnSelchangedTreeTextures)
|
|
ON_NOTIFY(NM_DBLCLK, IDC_TREE_TEXTURES, OnDblclkTreeTextures)
|
|
ON_BN_CLICKED(IDC_PREVIEW, OnPreview)
|
|
ON_WM_CREATE()
|
|
ON_WM_SIZE()
|
|
ON_BN_CLICKED(IDC_CHECK_HIDEROOT, OnCheckHideroot)
|
|
ON_COMMAND(ID_MATERIAL_EDIT, OnMaterialEdit)
|
|
ON_COMMAND(ID_MATERIAL_INFO, OnMaterialInfo)
|
|
//}}AFX_MSG_MAP
|
|
ON_WM_SETFOCUS()
|
|
ON_NOTIFY(NM_RCLICK, IDC_TREE_TEXTURES, OnNMRclickTreeTextures)
|
|
END_MESSAGE_MAP()
|
|
//
|
|
// =======================================================================================================================
|
|
// CDialogTextures message handlers
|
|
// =======================================================================================================================
|
|
//
|
|
void CDialogTextures::OnOK() {
|
|
//CDialog::OnOK();
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
BOOL CDialogTextures::OnInitDialog() {
|
|
CDialog::OnInitDialog();
|
|
|
|
IceDark_ApplyToDialog(this);
|
|
|
|
m_image.Create(IDB_BITMAP_MATERIAL, 16, 1, RGB(255, 255, 255));
|
|
m_treeTextures.SetImageList(&m_image, TVSIL_NORMAL);
|
|
m_treeTextures.SetBkColor(ICE_DARK_FIELD);
|
|
m_treeTextures.SetTextColor(ICE_DARK_TEXT);
|
|
|
|
// m_wndPreview.SubclassDlgItem(IDC_PREVIEW, this);
|
|
m_wndPreview.setDrawable(&m_testDrawable);
|
|
BuildTree();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
bool CDialogTextures::loadTree( HTREEITEM item, const idStr &name, CWaitDlg *dlg ) {
|
|
|
|
if ( item == NULL ) {
|
|
return true;
|
|
}
|
|
|
|
if ( m_treeTextures.ItemHasChildren( item ) ) {
|
|
|
|
idStr childName;
|
|
HTREEITEM nextItem;
|
|
HTREEITEM childItem = m_treeTextures.GetChildItem(item);
|
|
|
|
while ( childItem != NULL ) {
|
|
|
|
nextItem = m_treeTextures.GetNextItem( childItem, TVGN_NEXT );
|
|
childName = name + "/" + (const char *)m_treeTextures.GetItemText( childItem );
|
|
|
|
if ( m_treeTextures.ItemHasChildren( childItem ) ) {
|
|
if ( !loadTree( childItem, childName, dlg ) ) {
|
|
return false;
|
|
}
|
|
} else {
|
|
DWORD dw = m_treeTextures.GetItemData( childItem );
|
|
if ( dw == TEXTURES || dw == MATERIALS ) {
|
|
if ( dw == TEXTURES ) {
|
|
childName = "textures/" + childName;
|
|
}
|
|
dlg->SetText( childName.c_str() );
|
|
Texture_ForName( childName );
|
|
}
|
|
}
|
|
if ( dlg->CancelPressed() ) {
|
|
return false;
|
|
}
|
|
|
|
childItem = nextItem;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
HTREEITEM CDialogTextures::findItem(const char *name, HTREEITEM item, HTREEITEM *foundItem) {
|
|
if (*foundItem || item == NULL) {
|
|
return *foundItem;
|
|
}
|
|
if (m_treeTextures.ItemHasChildren(item)) {
|
|
HTREEITEM nextItem;
|
|
HTREEITEM childItem = m_treeTextures.GetChildItem(item);
|
|
while (childItem != NULL && *foundItem == NULL) {
|
|
nextItem = childItem;
|
|
if (m_treeTextures.ItemHasChildren(nextItem)) {
|
|
findItem(name, nextItem, foundItem);
|
|
} else {
|
|
DWORD dw = m_treeTextures.GetItemData(nextItem);
|
|
if (dw == TEXTURES) {
|
|
const char *matName = buildItemName(nextItem, TypeNames[TEXTURES]);
|
|
if ( !idStr::Icmpn( name, "textures/", 9 ) && stricmp(name + 9, matName) == 0) {
|
|
*foundItem = nextItem;
|
|
return *foundItem;
|
|
}
|
|
} else if (dw == MATERIALS) {
|
|
const char *matName = buildItemName(nextItem, TypeNames[MATERIALS]);
|
|
if (stricmp(name, matName) == 0) {
|
|
*foundItem = nextItem;
|
|
return *foundItem;
|
|
}
|
|
} else if (dw == SOUNDS) {
|
|
if (stricmp(name, m_treeTextures.GetItemText(nextItem)) == 0) {
|
|
*foundItem = nextItem;
|
|
return *foundItem;
|
|
}
|
|
}
|
|
}
|
|
childItem = m_treeTextures.GetNextItem(childItem, TVGN_NEXT);
|
|
//childItem = nextItem;
|
|
}
|
|
}
|
|
return *foundItem;
|
|
}
|
|
|
|
void CDialogTextures::CollapseChildren(HTREEITEM parent) {
|
|
HTREEITEM nextItem;
|
|
HTREEITEM childItem = m_treeTextures.GetChildItem(parent);
|
|
while (childItem) {
|
|
nextItem = m_treeTextures.GetNextItem(childItem, TVGN_NEXT);
|
|
if (m_treeTextures.ItemHasChildren(childItem)) {
|
|
CollapseChildren(childItem);
|
|
m_treeTextures.Expand(childItem, TVE_COLLAPSE);
|
|
}
|
|
childItem = nextItem;
|
|
}
|
|
}
|
|
|
|
void CDialogTextures::SelectCurrentItem(bool collapse, const char *name, int id) {
|
|
HTREEITEM root = m_treeTextures.GetRootItem();
|
|
idStr qt;
|
|
if ((id == TEXTURES) || (id == MATERIALS)) {
|
|
HTREEITEM matItem = NULL;
|
|
HTREEITEM *matPtr = &matItem;
|
|
|
|
// FIXME: This is a hack. How should this really work?
|
|
if (id == MATERIALS && !idStr::Icmpn( name, "textures/", 9 ) ) {
|
|
// Texture_SetTexture calls SelectCurrentItem with id == MATERIALS
|
|
id = TEXTURES;
|
|
}
|
|
setTexture = false;
|
|
if (root) {
|
|
if (collapse && !ignoreCollapse) {
|
|
CollapseChildren(root);
|
|
}
|
|
|
|
HTREEITEM *check = NULL;
|
|
qt = TypeNames[id];
|
|
qt += "/";
|
|
if (id == TEXTURES && !idStr::Icmpn( name, "textures/", 9 ) ) {
|
|
// strip off "textures/"
|
|
qt += name + 9;
|
|
} else {
|
|
qt += name;
|
|
}
|
|
if (quickTree.Get(qt, &check)) {
|
|
matItem = *check;
|
|
}
|
|
if (matItem == NULL) {
|
|
matItem = findItem(name, root, matPtr);
|
|
}
|
|
if (matItem) {
|
|
m_treeTextures.SelectItem(matItem);
|
|
}
|
|
}
|
|
setTexture = true;
|
|
} else if (id == SOUNDS) {
|
|
if (root) {
|
|
if (collapse && !ignoreCollapse) {
|
|
CollapseChildren(root);
|
|
}
|
|
HTREEITEM sel = FindTreeItem(&m_treeTextures, root, name, NULL);
|
|
if (sel) {
|
|
m_treeTextures.SelectItem(sel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CDialogTextures::OnLoad() {
|
|
CWaitCursor cursor;
|
|
CWaitDlg dlg;
|
|
dlg.AllowCancel( true );
|
|
dlg.SetWindowText( "Loading textures..." );
|
|
Texture_HideAll();
|
|
HTREEITEM item = m_treeTextures.GetSelectedItem();
|
|
idStr name = buildItemName( item, TypeNames[TEXTURES] );
|
|
if ( !name.Cmpn( TypeNames[MATERIALS], strlen( TypeNames[MATERIALS] ) ) ) {
|
|
name = buildItemName( item, TypeNames[MATERIALS] );
|
|
}
|
|
loadTree( item, name, &dlg );
|
|
}
|
|
|
|
const char *CDialogTextures::buildItemName(HTREEITEM item, const char *rootName) {
|
|
itemName = m_treeTextures.GetItemText(item);
|
|
|
|
// have to build the name back up
|
|
HTREEITEM parent = m_treeTextures.GetParentItem(item);
|
|
while (true) {
|
|
idStr strParent = m_treeTextures.GetItemText(parent);
|
|
if ( idStr::Icmp(strParent, rootName) == 0 ) {
|
|
break;
|
|
}
|
|
strParent += "/";
|
|
strParent += itemName;
|
|
itemName = strParent;
|
|
parent = m_treeTextures.GetParentItem(parent);
|
|
if (parent == NULL) {
|
|
break;
|
|
}
|
|
}
|
|
return itemName;
|
|
}
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::OnRefresh() {
|
|
quickTree.Clear();
|
|
|
|
addModels( true );
|
|
|
|
if (mode == TEXTURES) {
|
|
idStrList textures(1024);
|
|
int count = declManager->GetNumDecls( DECL_MATERIAL );
|
|
int i;
|
|
const idMaterial *mat;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
mat = declManager->MaterialByIndex(i, false);
|
|
if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && !idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
|
|
textures.Append(mat->GetName());
|
|
}
|
|
}
|
|
|
|
declManager->Reload( false );
|
|
|
|
BuildTree();
|
|
count = textures.Num();
|
|
for (i = 0; i < count; i++) {
|
|
mat = declManager->FindMaterial(textures[i].c_str());
|
|
if ( mat ) {
|
|
mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
|
|
}
|
|
}
|
|
SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::TEXTURES);
|
|
} else if (mode == MATERIALS) {
|
|
idStrList textures(1024);
|
|
int count = declManager->GetNumDecls( DECL_MATERIAL );
|
|
int i;
|
|
const idMaterial *mat;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
mat = declManager->MaterialByIndex(i, false);
|
|
if ( mat->IsValid() && mat->TestMaterialFlag(MF_EDITOR_VISIBLE) && idStr::Icmpn( mat->GetName(), "textures/", 9 ) ) {
|
|
textures.Append(mat->GetName());
|
|
}
|
|
}
|
|
|
|
declManager->Reload( false );
|
|
|
|
BuildTree();
|
|
count = textures.Num();
|
|
for (i = 0; i < count; i++) {
|
|
mat = declManager->FindMaterial(textures[i].c_str());
|
|
if ( mat ) {
|
|
mat->SetMaterialFlag(MF_EDITOR_VISIBLE);
|
|
}
|
|
}
|
|
SelectCurrentItem(false, g_qeglobals.d_texturewin.texdef.name, CDialogTextures::MATERIALS);
|
|
} else if (mode == SOUNDS || mode == SOUNDPARENT) {
|
|
HTREEITEM root = m_treeTextures.GetRootItem();
|
|
HTREEITEM sib = m_treeTextures.GetNextItem(root, TVGN_ROOT);
|
|
while (sib) {
|
|
idStr str = m_treeTextures.GetItemText(sib);
|
|
if (str.Icmp(TypeNames[SOUNDS]) == 0) {
|
|
CWaitCursor cursor;
|
|
m_treeTextures.DeleteItem(sib);
|
|
|
|
declManager->Reload( false );
|
|
bool rootItems = m_chkHideRoot.GetCheck() == 0;
|
|
addSounds(rootItems);
|
|
return;
|
|
}
|
|
sib = m_treeTextures.GetNextSiblingItem(sib);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
HTREEITEM FindTreeItem(CTreeCtrl *tree, HTREEITEM root, const char *text, HTREEITEM forceParent) {
|
|
HTREEITEM theItem = NULL;
|
|
if (root) {
|
|
if ((theItem = tree->GetNextSiblingItem(root)) != NULL) {
|
|
theItem = FindTreeItem(tree, theItem, text, NULL);
|
|
if (theItem) {
|
|
if (forceParent) {
|
|
if (tree->GetParentItem(theItem) == forceParent) {
|
|
return theItem;
|
|
}
|
|
} else {
|
|
return theItem;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((theItem = tree->GetChildItem(root)) != NULL) {
|
|
theItem = FindTreeItem(tree, theItem, text, NULL);
|
|
if (theItem) {
|
|
if (forceParent) {
|
|
if (tree->GetParentItem(theItem) == forceParent) {
|
|
return theItem;
|
|
}
|
|
} else {
|
|
return theItem;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (text && idStr::Icmp(tree->GetItemText(root), text) == 0 ) {
|
|
return root;
|
|
}
|
|
|
|
if (theItem && forceParent) {
|
|
if (tree->GetParentItem(theItem) != forceParent) {
|
|
theItem = NULL;
|
|
}
|
|
}
|
|
return theItem;
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::BuildTree() {
|
|
CWaitCursor cursor;
|
|
m_treeTextures.DeleteAllItems();
|
|
bool rootItems = m_chkHideRoot.GetCheck() == 0;
|
|
|
|
idTimer timer;
|
|
|
|
timer.Start();
|
|
|
|
addMaterials( rootItems );
|
|
// _D3XP removed
|
|
//addModels( rootItems );
|
|
addScripts( rootItems );
|
|
addSounds( rootItems );
|
|
addGuis( rootItems );
|
|
addParticles( rootItems );
|
|
|
|
timer.Stop();
|
|
|
|
common->Printf( "CDialogTextures::BuildTree() took %.0f milliseconds\n", timer.Milliseconds() );
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::OnClickTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
|
|
*pResult = 0;
|
|
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
m_treeTextures.ScreenToClient(&pt);
|
|
HTREEITEM item = m_treeTextures.HitTest(pt);
|
|
|
|
if (item) {
|
|
DWORD dw = m_treeTextures.GetItemData(item);
|
|
mode = dw;
|
|
if (mode == SOUNDS) {
|
|
idStr loadName;
|
|
if (!m_treeTextures.ItemHasChildren(item)) {
|
|
loadName = m_treeTextures.GetItemText(item);
|
|
idStr actionName = m_treeTextures.GetItemText(item);
|
|
soundSystem->SetMute( false );
|
|
g_qeglobals.sw->PlayShaderDirectly(actionName);
|
|
} else {
|
|
loadName = m_treeTextures.GetItemText(item);
|
|
}
|
|
|
|
} else {
|
|
g_qeglobals.sw->StopAllSounds();
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::OnSelchangedTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
|
|
NM_TREEVIEW *pNMTreeView = (NM_TREEVIEW *) pNMHDR;
|
|
*pResult = 0;
|
|
|
|
editMaterial = NULL;
|
|
editGui = "";
|
|
mediaName = "";
|
|
currentFile.Empty();
|
|
m_wndPreview.setDrawable(&m_testDrawable);
|
|
HTREEITEM item = m_treeTextures.GetSelectedItem();
|
|
if (item) {
|
|
DWORD dw = m_treeTextures.GetItemData(item);
|
|
mode = dw;
|
|
if ((dw == TEXTURES) || (dw == MATERIALS)) {
|
|
idStr matName = m_treeTextures.GetItemText(item);
|
|
|
|
// have to build the name back up
|
|
HTREEITEM parent = m_treeTextures.GetParentItem(item);
|
|
while (true) {
|
|
idStr strParent = m_treeTextures.GetItemText(parent);
|
|
if ( idStr::Icmp(strParent, TypeNames[dw]) == 0 ) {
|
|
break;
|
|
}
|
|
strParent += "/";
|
|
strParent += matName;
|
|
matName = strParent;
|
|
parent = m_treeTextures.GetParentItem(parent);
|
|
if (parent == NULL) {
|
|
break;
|
|
}
|
|
}
|
|
if ( dw == TEXTURES ) {
|
|
matName = "textures/" + matName;
|
|
}
|
|
|
|
const idMaterial *mat = Texture_ForName(matName);
|
|
editMaterial = mat;
|
|
m_drawMaterial.setMedia(matName);
|
|
m_wndPreview.setDrawable(&m_drawMaterial);
|
|
m_wndPreview.RedrawWindow();
|
|
|
|
ignoreCollapse = true;
|
|
Select_SetDefaultTexture(mat, false, setTexture);
|
|
ignoreCollapse = false;
|
|
} else if (dw == MODELS) {
|
|
idStr strParent;
|
|
idStr modelName = m_treeTextures.GetItemText(item);
|
|
// have to build the name back up
|
|
HTREEITEM parent = m_treeTextures.GetParentItem(item);
|
|
while (true) {
|
|
strParent = m_treeTextures.GetItemText(parent);
|
|
if ( idStr::Icmp(strParent, TypeNames[MODELS]) == 0 ) {
|
|
break;
|
|
}
|
|
strParent += "/";
|
|
strParent += modelName;
|
|
modelName = strParent;
|
|
parent = m_treeTextures.GetParentItem(parent);
|
|
if (parent == NULL) {
|
|
break;
|
|
}
|
|
}
|
|
strParent = "models/";
|
|
strParent += modelName;
|
|
m_drawModel.setMedia(strParent);
|
|
mediaName = strParent;
|
|
m_wndPreview.setDrawable(&m_drawModel);
|
|
m_drawModel.SetRealTime(0);
|
|
m_wndPreview.RedrawWindow();
|
|
} else if (dw == SCRIPTS) {
|
|
} else if (dw == SOUNDS) {
|
|
} else if (dw == PARTICLES) {
|
|
idStr strParent;
|
|
idStr modelName = m_treeTextures.GetItemText(item);
|
|
// have to build the name back up
|
|
HTREEITEM parent = m_treeTextures.GetParentItem(item);
|
|
while (true) {
|
|
strParent = m_treeTextures.GetItemText(parent);
|
|
if ( idStr::Icmp(strParent, TypeNames[PARTICLES]) == 0 ) {
|
|
break;
|
|
}
|
|
strParent += "/";
|
|
strParent += modelName;
|
|
modelName = strParent;
|
|
parent = m_treeTextures.GetParentItem(parent);
|
|
if (parent == NULL) {
|
|
break;
|
|
}
|
|
}
|
|
strParent = modelName;
|
|
mediaName = strParent;
|
|
mediaName += ".prt";
|
|
m_drawModel.setMedia(mediaName);
|
|
m_drawModel.SetRealTime(50);
|
|
m_wndPreview.setDrawable(&m_drawModel);
|
|
m_wndPreview.RedrawWindow();
|
|
} else if (dw == GUIS) {
|
|
idStr strParent;
|
|
idStr modelName = m_treeTextures.GetItemText(item);
|
|
// have to build the name back up
|
|
HTREEITEM parent = m_treeTextures.GetParentItem(item);
|
|
while (true) {
|
|
strParent = m_treeTextures.GetItemText(parent);
|
|
if ( idStr::Icmp(strParent, TypeNames[GUIS]) == 0 ) {
|
|
break;
|
|
}
|
|
strParent += "/";
|
|
strParent += modelName;
|
|
modelName = strParent;
|
|
parent = m_treeTextures.GetParentItem(parent);
|
|
if (parent == NULL) {
|
|
break;
|
|
}
|
|
}
|
|
strParent = "guis/";
|
|
strParent += modelName;
|
|
const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
|
|
mat->SetGui(strParent);
|
|
editGui = strParent;
|
|
m_drawMaterial.setMedia("guisurfs/guipreview");
|
|
m_drawMaterial.setScale(4.4f);
|
|
m_wndPreview.setDrawable(&m_drawMaterial);
|
|
m_wndPreview.RedrawWindow();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::addMaterials( bool rootItems ) {
|
|
idStrList textures(1024);
|
|
idStrList materials(1024);
|
|
|
|
textures.SetGranularity( 1024 );
|
|
materials.SetGranularity( 1024 );
|
|
|
|
int count = declManager->GetNumDecls( DECL_MATERIAL );
|
|
if ( count > 0 ) {
|
|
for ( int i = 0; i < count; i++ ) {
|
|
const idMaterial *mat = declManager->MaterialByIndex( i, false );
|
|
if ( !rootItems ) {
|
|
if ( strchr( mat->GetName(), '/' ) == NULL && strchr( mat->GetName(), '\\' ) == NULL ) {
|
|
continue;
|
|
}
|
|
}
|
|
// add everything except the textures/ materials
|
|
if ( idStr::Icmpn( mat->GetName(), "textures/", 9 ) == 0 ) {
|
|
textures.Append( mat->GetName() );
|
|
} else {
|
|
materials.Append( mat->GetName() );
|
|
}
|
|
}
|
|
idStrListSortPaths( textures );
|
|
addStrList( TypeNames[TEXTURES], textures, TEXTURES );
|
|
idStrListSortPaths( materials );
|
|
addStrList( TypeNames[MATERIALS], materials, MATERIALS );
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::addParticles( bool rootItems ) {
|
|
idStrList list(1024);
|
|
int count = declManager->GetNumDecls( DECL_PARTICLE );
|
|
if (count > 0) {
|
|
for (int i = 0; i < count; i++) {
|
|
const idDecl *ips = declManager->DeclByIndex( DECL_PARTICLE, i, false );
|
|
if (!rootItems) {
|
|
if (strchr(ips->GetName(), '/') == NULL && strchr(ips->GetName(), '\\') == NULL) {
|
|
continue;
|
|
}
|
|
}
|
|
list.Append(ips->GetName());
|
|
}
|
|
idStrListSortPaths( list );
|
|
addStrList( TypeNames[PARTICLES], list, PARTICLES );
|
|
}
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::addSounds(bool rootItems) {
|
|
int i, j;
|
|
idStrList list(1024);
|
|
idStrList list2(1024);
|
|
HTREEITEM base = m_treeTextures.InsertItem(TypeNames[SOUNDS]);
|
|
|
|
for(i = 0; i < declManager->GetNumDecls( DECL_SOUND ); i++) {
|
|
const idSoundShader *poo = declManager->SoundByIndex(i, false);
|
|
list.AddUnique( poo->GetFileName() );
|
|
}
|
|
idStrListSortPaths( list );
|
|
|
|
for (i = 0; i < list.Num(); i++) {
|
|
HTREEITEM child = m_treeTextures.InsertItem(list[i], base);
|
|
m_treeTextures.SetItemData(child, SOUNDPARENT);
|
|
m_treeTextures.SetItemImage(child, 0, 1);
|
|
list2.Clear();
|
|
for (j = 0; j < declManager->GetNumDecls( DECL_SOUND ); j++) {
|
|
const idSoundShader *poo = declManager->SoundByIndex(j, false);
|
|
if ( idStr::Icmp( list[i], poo->GetFileName() ) == 0 ) {
|
|
list2.Append( poo->GetName() );
|
|
}
|
|
}
|
|
idStrListSortPaths( list2 );
|
|
for (j = 0; j < list2.Num(); j++) {
|
|
HTREEITEM child2 = m_treeTextures.InsertItem( list2[j], child );
|
|
m_treeTextures.SetItemData(child2, SOUNDS);
|
|
m_treeTextures.SetItemImage(child2, 2, 2);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
void CDialogTextures::addStrList( const char *root, const idStrList &list, int id ) {
|
|
idStr out, path;
|
|
|
|
HTREEITEM base = m_treeTextures.GetRootItem();
|
|
while (base) {
|
|
out = m_treeTextures.GetItemText(base);
|
|
if (stricmp(root, out) == 0) {
|
|
break;
|
|
}
|
|
base = m_treeTextures.GetNextSiblingItem(base);
|
|
}
|
|
|
|
if (base == NULL) {
|
|
base = m_treeTextures.InsertItem(root);
|
|
}
|
|
|
|
HTREEITEM item = base;
|
|
HTREEITEM add;
|
|
|
|
int count = list.Num();
|
|
|
|
idStr last, qt;
|
|
for (int i = 0; i < count; i++) {
|
|
idStr name = list[i];
|
|
|
|
// now break the name down convert to slashes
|
|
name.BackSlashesToSlashes();
|
|
name.Strip(' ');
|
|
|
|
int index;
|
|
int len = last.Length();
|
|
if (len == 0) {
|
|
index = name.Last('/');
|
|
if (index >= 0) {
|
|
name.Left(index, last);
|
|
}
|
|
}
|
|
else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
|
|
name.Right(name.Length() - len - 1, out);
|
|
add = m_treeTextures.InsertItem(out, item);
|
|
qt = root;
|
|
qt += "/";
|
|
qt += name;
|
|
quickTree.Set(qt, add);
|
|
m_treeTextures.SetItemData(add, id);
|
|
m_treeTextures.SetItemImage(add, 2, 2);
|
|
continue;
|
|
}
|
|
else {
|
|
last.Empty();
|
|
}
|
|
|
|
index = 0;
|
|
item = base;
|
|
path = "";
|
|
while (index >= 0) {
|
|
index = name.Find('/');
|
|
if (index >= 0) {
|
|
HTREEITEM newItem = NULL;
|
|
HTREEITEM *check = NULL;
|
|
name.Left( index, out );
|
|
path += out;
|
|
qt = root;
|
|
qt += "/";
|
|
qt += path;
|
|
if (quickTree.Get(qt, &check)) {
|
|
newItem = *check;
|
|
}
|
|
//HTREEITEM newItem = FindTreeItem(&m_treeTextures, item, name.Left(index, out), item);
|
|
if (newItem == NULL) {
|
|
newItem = m_treeTextures.InsertItem(out, item);
|
|
qt = root;
|
|
qt += "/";
|
|
qt += path;
|
|
quickTree.Set(qt, newItem);
|
|
m_treeTextures.SetItemImage(newItem, 0, 1);
|
|
}
|
|
|
|
assert(newItem);
|
|
item = newItem;
|
|
name.Right( name.Length() - index - 1, out );
|
|
name = out;
|
|
path += "/";
|
|
}
|
|
else {
|
|
add = m_treeTextures.InsertItem(name, item);
|
|
qt = root;
|
|
qt += "/";
|
|
qt += path;
|
|
qt += name;
|
|
quickTree.Set(qt, add);
|
|
m_treeTextures.SetItemData(add, id);
|
|
m_treeTextures.SetItemImage(add, 2, 2);
|
|
path = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::addModels(bool rootItems) {
|
|
idFileList *files;
|
|
|
|
files = fileSystem->ListFilesTree( "models", ".ase|.lwo|.ma", true );
|
|
|
|
if ( files->GetNumFiles() ) {
|
|
addStrList( TypeNames[MODELS], files->GetList(), MODELS );
|
|
}
|
|
|
|
fileSystem->FreeFileList( files );
|
|
}
|
|
|
|
void CDialogTextures::addGuis( bool rootItems ) {
|
|
idFileList *files;
|
|
|
|
files = fileSystem->ListFilesTree( "guis", ".gui", true );
|
|
|
|
if ( files->GetNumFiles() ) {
|
|
addStrList( TypeNames[GUIS], files->GetList(), GUIS );
|
|
}
|
|
|
|
fileSystem->FreeFileList( files );
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::addScripts(bool rootItems) {
|
|
/*
|
|
idFileList *files;
|
|
|
|
files = fileSystem->ListFilesExt( "def", ".script" );
|
|
|
|
if ( files->GetNumFiles() ) {
|
|
addStrList("Scripts", files->GetList(), 3);
|
|
}
|
|
*/
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::OnDblclkTreeTextures(NMHDR *pNMHDR, LRESULT *pResult) {
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
m_treeTextures.ScreenToClient(&pt);
|
|
HTREEITEM item = m_treeTextures.HitTest(pt);
|
|
if (item) {
|
|
DWORD dw = m_treeTextures.GetItemData(item);
|
|
mode = dw;
|
|
if (mode == SOUNDS) {
|
|
if (!m_treeTextures.ItemHasChildren(item)) {
|
|
idStr shaderName = m_treeTextures.GetItemText(item);
|
|
Select_SetKeyVal("s_shader", shaderName);
|
|
entity_t *ent = selected_brushes.next->owner;
|
|
if (ent) {
|
|
g_Inspectors->UpdateEntitySel(ent->eclass);
|
|
MessageBeep(MB_OK);
|
|
}
|
|
}
|
|
} else if (mode == MODELS || mode == PARTICLES ) {
|
|
if (mediaName.Length()) {
|
|
g_Inspectors->entityDlg.UpdateKeyVal("model", mediaName);
|
|
}
|
|
} else if (mode <= MATERIALS) {
|
|
OnLoad();
|
|
}
|
|
}
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
/*
|
|
=======================================================================================================================
|
|
=======================================================================================================================
|
|
*/
|
|
void CDialogTextures::OnPreview() {
|
|
// TODO: Add your control notification handler code here
|
|
}
|
|
|
|
|
|
//void CDialogTextures::OnSave()
|
|
//{
|
|
/*
|
|
CString str;
|
|
m_wndEditShader.GetWindowText(str);
|
|
if (currentFile.length() && str.GetLength()) {
|
|
fileSystem->WriteFile(currentFile, str.GetBuffer(0), str.GetLength());
|
|
}
|
|
*/
|
|
//}
|
|
|
|
int CDialogTextures::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
{
|
|
if (CDialog::OnCreate(lpCreateStruct) == -1)
|
|
return -1;
|
|
|
|
// TODO: Add your specialized creation code here
|
|
|
|
return 0;
|
|
}
|
|
|
|
void CDialogTextures::OnSize(UINT nType, int cx, int cy)
|
|
{
|
|
CDialog::OnSize(nType, cx, cy);
|
|
|
|
if (m_btnLoad.GetSafeHwnd() == NULL) {
|
|
return;
|
|
}
|
|
|
|
CRect rect, rect2, rect3;
|
|
GetClientRect(rect);
|
|
m_btnLoad.GetWindowRect(rect2);
|
|
|
|
m_btnLoad.SetWindowPos(NULL, rect.left + 4, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
m_btnRefresh.SetWindowPos(NULL, rect.left + rect2.Width() + 4, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
|
|
|
|
int right = rect.right - 4 - rect3.Width() - 4;
|
|
|
|
|
|
right = rect3.right - 4 - rect3.Width() - 4;
|
|
|
|
m_chkHideRoot.GetWindowRect(rect3);
|
|
m_chkHideRoot.SetWindowPos(NULL, right - rect3.Width() * 2, rect.top + 4, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
|
|
m_chkHideRoot.ShowWindow(SW_HIDE);
|
|
|
|
int verticalSpace = (rect.Height() - rect2.Height() - 12) / 2;
|
|
|
|
m_treeTextures.SetWindowPos(NULL, rect.left + 4, rect.top + 8 + rect2.Height(), (rect.Width() - 8), verticalSpace, SWP_SHOWWINDOW);
|
|
m_wndPreview.SetWindowPos(NULL, rect.left + 4, rect.top + 12 + rect2.Height() + verticalSpace, (rect.Width() - 8), verticalSpace, SWP_SHOWWINDOW);
|
|
|
|
RedrawWindow();
|
|
}
|
|
|
|
BOOL CDialogTextures::PreCreateWindow(CREATESTRUCT& cs)
|
|
{
|
|
return CDialog::PreCreateWindow(cs);
|
|
}
|
|
|
|
void CDialogTextures::OnCheckHideroot()
|
|
{
|
|
BuildTree();
|
|
}
|
|
|
|
void CDialogTextures::CollapseEditor() {
|
|
if (g_qeglobals.d_savedinfo.editorExpanded) {
|
|
}
|
|
}
|
|
|
|
|
|
void CDialogTextures::OnCancel() {
|
|
}
|
|
|
|
|
|
BOOL CDialogTextures::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_RETURN)) {
|
|
if (pMsg->wParam == VK_ESCAPE) {
|
|
g_pParentWnd->GetCamera()->SetFocus();
|
|
Select_Deselect();
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CDialogTextures::OnSetFocus(CWnd* pOldWnd)
|
|
{
|
|
CDialog::OnSetFocus(pOldWnd);
|
|
RedrawWindow();
|
|
}
|
|
|
|
void CDialogTextures::OnNMRclickTreeTextures(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
*pResult = 0;
|
|
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
m_treeTextures.ScreenToClient(&pt);
|
|
HTREEITEM item = m_treeTextures.HitTest(pt);
|
|
|
|
if (item) {
|
|
DWORD dw = m_treeTextures.GetItemData(item);
|
|
mode = dw;
|
|
if (mode == TEXTURES || mode == MATERIALS || mode == GUIS) {
|
|
m_treeTextures.SelectItem(item);
|
|
HandlePopup(this, IDR_POPUP_MATERIAL);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CDialogTextures::OnMaterialEdit() {
|
|
CEditViewDlg dlg;
|
|
if ((mode == TEXTURES || mode == MATERIALS) && editMaterial) {
|
|
dlg.SetMode(CEditViewDlg::MATERIALS);
|
|
dlg.SetMaterialInfo(editMaterial->GetName(), editMaterial->GetFileName(), editMaterial->GetLineNum());
|
|
dlg.DoModal();
|
|
} else if (mode == GUIS && editGui.Length()) {
|
|
dlg.SetMode(CEditViewDlg::GUIS);
|
|
dlg.SetGuiInfo(editGui);
|
|
dlg.DoModal();
|
|
}
|
|
}
|
|
|
|
void CDialogTextures::OnMaterialInfo() {
|
|
/*
|
|
idStr str;
|
|
if (editMaterial) {
|
|
str = "File: ";
|
|
str += editMaterial->getFileName();
|
|
str += "\r\nName: ";
|
|
str = editMaterial->getName();
|
|
ShowInfoDialog(str);
|
|
} else if (editGui.Length()) {
|
|
str = "File: ";
|
|
str += editGui;
|
|
ShowInfoDialog(str);
|
|
}
|
|
*/
|
|
}
|