| 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 | // DallasFlagDlg.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include "stdafx.h" |
| 23 | |
| 24 | #ifdef NEWEDITOR |
| 25 | #include "NewEditor.h" |
| 26 | #else |
| 27 | #include "editor.h" |
| 28 | #endif |
| 29 | |
| 30 | #include "cfile.h" |
| 31 | #include "DallasMainDlg.h" |
| 32 | #include "DallasFlagDlg.h" |
| 33 | |
| 34 | CDallasMainDlg *GetDallasDialogPtr(void); |
| 35 | |
| 36 | #ifdef _DEBUG |
| 37 | #define new DEBUG_NEW |
| 38 | #undef THIS_FILE |
| 39 | static char THIS_FILE[] = __FILE__; |
| 40 | #endif |
| 41 | |
| 42 | ///////////////////////////////////////////////////////////////////////////// |
| 43 | // CDallasFlagDlg dialog |
| 44 | |
| 45 | CDallasFlagDlg::CDallasFlagDlg(CWnd *pParent /*=NULL*/) : CDialog(CDallasFlagDlg::IDD, pParent) { |
| 46 | //{{AFX_DATA_INIT(CDallasFlagDlg) |
| 47 | // NOTE: the ClassWizard will add member initialization here |
| 48 | //}}AFX_DATA_INIT |
| 49 | m_FlagsValue = 0; |
| 50 | m_ValidFlagsMask = 0; |
| 51 | m_FlagsName = ""; |
| 52 | } |
| 53 | |
| 54 | void CDallasFlagDlg::DoDataExchange(CDataExchange *pDX) { |
| 55 | CDialog::DoDataExchange(pDX); |
| 56 | //{{AFX_DATA_MAP(CDallasFlagDlg) |
| 57 | DDX_Control(pDX, IDC_FLAG_LIST, m_FlagListBox); |
| 58 | DDX_Control(pDX, IDC_FLAG_PROMPT_STATIC, m_FlagPromptText); |
| 59 | //}}AFX_DATA_MAP |
| 60 | } |
| 61 | |
| 62 | BEGIN_MESSAGE_MAP(CDallasFlagDlg, CDialog) |
| 63 | //{{AFX_MSG_MAP(CDallasFlagDlg) |
| 64 | //}}AFX_MSG_MAP |
| 65 | END_MESSAGE_MAP() |
| 66 | |
| 67 | ///////////////////////////////////////////////////////////////////////////// |
| 68 | // CDallasFlagDlg message handlers |
| 69 | |
| 70 | BOOL CDallasFlagDlg::OnInitDialog() { |
| 71 | CDialog::OnInitDialog(); |
| 72 | |
| 73 | CDallasMainDlg *m_DallasModelessDlgPtr; |
| 74 | m_DallasModelessDlgPtr = GetDallasDialogPtr(); |
| 75 | |
| 76 | // If Dallas is up, fill in the list box |
| 77 | if (m_DallasModelessDlgPtr != NULL) { |
| 78 | m_DallasModelessDlgPtr->FillFlagValuesBox(&m_FlagListBox, m_FlagsName.GetBuffer(0), m_FlagsValue, m_ValidFlagsMask); |
| 79 | } |
| 80 | |
| 81 | return TRUE; // return TRUE unless you set the focus to a control |
| 82 | // EXCEPTION: OCX Property Pages should return FALSE |
| 83 | } |
| 84 | |
| 85 | void CDallasFlagDlg::OnOK() { |
| 86 | int list_size, j, data; |
| 87 | |
| 88 | // Fill the flags value with checklistbox data |
| 89 | m_FlagsValue = 0; |
| 90 | list_size = m_FlagListBox.GetCount(); |
| 91 | for (j = 0; j < list_size; j++) { |
| 92 | if (m_FlagListBox.GetCheck(j)) { |
| 93 | data = m_FlagListBox.GetItemData(j); |
| 94 | m_FlagsValue |= data; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | CDialog::OnOK(); |
| 99 | } |
| 100 | |
| 101 | void CDallasFlagDlg::OnCancel() { |
| 102 | // TODO: Add extra cleanup here |
| 103 | |
| 104 | CDialog::OnCancel(); |
| 105 | } |