| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program 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.
- **
- ** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- // PresetGeneralTab.cpp : implementation file
- //
- #include "stdafx.h"
- #include "leveledit.h"
- #include "PresetGeneralTab.h"
- #include "definition.h"
- #include "preset.h"
- #include "utils.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- //
- // PresetGeneralTabClass
- //
- /////////////////////////////////////////////////////////////////////////////
- PresetGeneralTabClass::PresetGeneralTabClass (PresetClass *preset)
- : m_Preset (preset),
- m_IsReadOnly (false),
- DockableFormClass(PresetGeneralTabClass::IDD)
- {
- //{{AFX_DATA_INIT(PresetGeneralTabClass)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- return ;
- }
- PresetGeneralTabClass::~PresetGeneralTabClass (void)
- {
- return ;
- }
- void
- PresetGeneralTabClass::DoDataExchange (CDataExchange *pDX)
- {
- DockableFormClass::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(PresetGeneralTabClass)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- return ;
- }
- BEGIN_MESSAGE_MAP(PresetGeneralTabClass, DockableFormClass)
- //{{AFX_MSG_MAP(PresetGeneralTabClass)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // PresetGeneralTabClass diagnostics
- #ifdef _DEBUG
- void PresetGeneralTabClass::AssertValid() const
- {
- DockableFormClass::AssertValid();
- }
- void PresetGeneralTabClass::Dump(CDumpContext& dc) const
- {
- DockableFormClass::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- //
- // HandleInitDialog
- //
- /////////////////////////////////////////////////////////////////////////////
- void
- PresetGeneralTabClass::HandleInitDialog (void)
- {
- ASSERT (m_Preset != NULL);
- DefinitionClass *definition = m_Preset->Get_Definition ();
- if (definition != NULL) {
- //
- // Set the text of the respective dialog controls
- //
- SetDlgItemText (IDC_NAME_EDIT, definition->Get_Name ());
- SetDlgItemInt (IDC_PRESET_ID_EDIT, definition->Get_ID ());
- SetDlgItemText (IDC_COMMENTS_EDIT, m_Preset->Get_Comments ());
- }
- if (m_IsReadOnly) {
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_NAME_EDIT), false);
- ::EnableWindow (::GetDlgItem (m_hWnd, IDC_COMMENTS_EDIT), false);
- }
- // Put the focus into the edit control
- ::SetFocus (::GetDlgItem (m_hWnd, IDC_NAME_EDIT));
- return ;
- }
- /////////////////////////////////////////////////////////////////////////////
- //
- // Apply_Changes
- //
- /////////////////////////////////////////////////////////////////////////////
- bool
- PresetGeneralTabClass::Apply_Changes (void)
- {
- // Assume success
- bool retval = true;
- DefinitionClass *definition = m_Preset->Get_Definition ();
- if (definition != NULL) {
- // Pass the new name onto the base
- CString name;
- GetDlgItemText (IDC_NAME_EDIT, name);
-
- // Is the new name valid?
- if (name.GetLength () > 0) {
- definition->Set_Name (name);
- } else {
- // Let the user know they MUST enter a name for the base
- ::Message_Box (m_hWnd, IDS_BASE_INFO_NONAME_MSG, IDS_BASE_INFO_NONAME_TITLE);
-
- // Put the focus back to the control
- ::SetFocus (::GetDlgItem (m_hWnd, IDC_NAME_EDIT));
- retval = false;
- }
- // Pass the new comments onto the base
- CString comments;
- GetDlgItemText (IDC_COMMENTS_EDIT, comments);
- m_Preset->Set_Comments (comments);
- }
-
- // Return true to allow the dialog to close
- return retval;
- }
|