| 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 | // CreateNewScriptDlg.cpp : implementation file |
| 20 | // |
| 21 | |
| 22 | #include "stdafx.h" |
| 23 | #include "editor.h" |
| 24 | #include "CreateNewScriptDlg.h" |
| 25 | |
| 26 | #ifdef _DEBUG |
| 27 | #define new DEBUG_NEW |
| 28 | #undef THIS_FILE |
| 29 | static char THIS_FILE[] = __FILE__; |
| 30 | #endif |
| 31 | |
| 32 | ///////////////////////////////////////////////////////////////////////////// |
| 33 | // CCreateNewScriptDlg dialog |
| 34 | |
| 35 | CCreateNewScriptDlg::CCreateNewScriptDlg(CWnd *pParent /*=NULL*/) : CDialog(CCreateNewScriptDlg::IDD, pParent) { |
| 36 | //{{AFX_DATA_INIT(CCreateNewScriptDlg) |
| 37 | m_Filename = _T(""); |
| 38 | m_ScriptType = -1; |
| 39 | //}}AFX_DATA_INIT |
| 40 | } |
| 41 | |
| 42 | void CCreateNewScriptDlg::DoDataExchange(CDataExchange *pDX) { |
| 43 | CDialog::DoDataExchange(pDX); |
| 44 | //{{AFX_DATA_MAP(CCreateNewScriptDlg) |
| 45 | DDX_Text(pDX, IDC_FILENAME, m_Filename); |
| 46 | DDX_Radio(pDX, IDC_LEVEL, m_ScriptType); |
| 47 | //}}AFX_DATA_MAP |
| 48 | } |
| 49 | |
| 50 | BEGIN_MESSAGE_MAP(CCreateNewScriptDlg, CDialog) |
| 51 | //{{AFX_MSG_MAP(CCreateNewScriptDlg) |
| 52 | //}}AFX_MSG_MAP |
| 53 | END_MESSAGE_MAP() |
| 54 | |
| 55 | ///////////////////////////////////////////////////////////////////////////// |
| 56 | // CCreateNewScriptDlg message handlers |
| 57 | |
| 58 | void CCreateNewScriptDlg::OnOK() { |
| 59 | UpdateData(true); |
| 60 | |
| 61 | int length = m_Filename.GetLength(); |
| 62 | char *str = m_Filename.GetBuffer(0); |
| 63 | if (length <= 0) { |
| 64 | MessageBox("You must specify a filename", "Error"); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | if ((length <= 4) || stricmp(&str[length - 4], ".cpp")) { |
| 69 | // we need to add a .cpp to the end of the name |
| 70 | m_Filename += ".cpp"; |
| 71 | } |
| 72 | |
| 73 | UpdateData(false); |
| 74 | |
| 75 | CDialog::OnOK(); |
| 76 | } |
| 77 | |
| 78 | BOOL CCreateNewScriptDlg::OnInitDialog() { |
| 79 | CDialog::OnInitDialog(); |
| 80 | |
| 81 | m_ScriptType = 0; |
| 82 | |
| 83 | UpdateData(false); |
| 84 | |
| 85 | return TRUE; |
| 86 | } |