| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program 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 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | // DallasTextureDlg.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include "stdafx.h" |
| 23 | #include "editor.h" |
| 24 | #include "gametexture.h" |
| 25 | #include "DallasTextureDlg.h" |
| 26 | |
| 27 | #ifdef _DEBUG |
| 28 | #define new DEBUG_NEW |
| 29 | #undef THIS_FILE |
| 30 | static char THIS_FILE[] = __FILE__; |
| 31 | #endif |
| 32 | |
| 33 | ///////////////////////////////////////////////////////////////////////////// |
| 34 | // CDallasTextureDlg dialog |
| 35 | |
| 36 | CDallasTextureDlg::CDallasTextureDlg(CWnd *pParent /*=NULL*/) : CDialog(CDallasTextureDlg::IDD, pParent) { |
| 37 | //{{AFX_DATA_INIT(CDallasTextureDlg) |
| 38 | // NOTE: the ClassWizard will add member initialization here |
| 39 | //}}AFX_DATA_INIT |
| 40 | |
| 41 | m_TextureName = ""; |
| 42 | m_TextureIndex = -1; |
| 43 | } |
| 44 | |
| 45 | void CDallasTextureDlg::DoDataExchange(CDataExchange *pDX) { |
| 46 | CDialog::DoDataExchange(pDX); |
| 47 | //{{AFX_DATA_MAP(CDallasTextureDlg) |
| 48 | DDX_Control(pDX, IDC_TEXTURE_LIST, m_TextureList); |
| 49 | //}}AFX_DATA_MAP |
| 50 | } |
| 51 | |
| 52 | BEGIN_MESSAGE_MAP(CDallasTextureDlg, CDialog) |
| 53 | //{{AFX_MSG_MAP(CDallasTextureDlg) |
| 54 | //}}AFX_MSG_MAP |
| 55 | END_MESSAGE_MAP() |
| 56 | |
| 57 | ///////////////////////////////////////////////////////////////////////////// |
| 58 | // CDallasTextureDlg message handlers |
| 59 | |
| 60 | BOOL CDallasTextureDlg::OnInitDialog() { |
| 61 | CDialog::OnInitDialog(); |
| 62 | |
| 63 | FillTextureList(); |
| 64 | |
| 65 | if (!m_TextureName.IsEmpty()) |
| 66 | m_TextureList.SelectString(-1, m_TextureName.GetBuffer(0)); |
| 67 | |
| 68 | return TRUE; // return TRUE unless you set the focus to a control |
| 69 | // EXCEPTION: OCX Property Pages should return FALSE |
| 70 | } |
| 71 | |
| 72 | void CDallasTextureDlg::OnOK() { |
| 73 | int index = m_TextureList.GetCurSel(); |
| 74 | if (index == LB_ERR) |
| 75 | return; |
| 76 | |
| 77 | m_TextureIndex = m_TextureList.GetItemData(index); |
| 78 | |
| 79 | CDialog::OnOK(); |
| 80 | } |
| 81 | |
| 82 | void CDallasTextureDlg::OnCancel() { |
| 83 | // TODO: Add extra cleanup here |
| 84 | |
| 85 | CDialog::OnCancel(); |
| 86 | } |
| 87 | |
| 88 | void CDallasTextureDlg::FillTextureList(void) { |
| 89 | int i; |
| 90 | |
| 91 | // Fill the menus with sounds |
| 92 | for (i = 0; i < MAX_TEXTURES; i++) { |
| 93 | if ((GameTextures[i].used) && (strlen(GameTextures[i].name) > 0)) { |
| 94 | int index; |
| 95 | index = m_TextureList.AddString(GameTextures[i].name); |
| 96 | if (index != LB_ERR) { |
| 97 | m_TextureList.SetItemData(index, i); |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | } |