Descent3/legacy/D3Launch/KeyboardTab.cpp

273 lines
7.2 KiB
C++
Raw Normal View History

/*
2024-06-15 18:13:59 +00:00
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* 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/>.
--- HISTORICAL COMMENTS FOLLOW ---
* $Logfile: /DescentIII/Main/D3Launch/KeyboardTab.cpp $
* $Revision: 1.1.1.1 $
* $Date: 2003-08-26 03:56:51 $
* $Author: kevinb $
*
2024-06-15 18:13:59 +00:00
*
*
* $Log: not supported by cvs2svn $
2024-06-15 18:13:59 +00:00
*
* 11 6/09/99 2:46p Nate
* Minor changes for different builds
2024-06-15 18:13:59 +00:00
*
* 10 5/23/99 1:21a Nate
* Made FindFast Disabling default to "always"
2024-06-15 18:13:59 +00:00
*
* 9 5/22/99 1:39a Nate
* Added Find Fast support
2024-06-15 18:13:59 +00:00
*
* 8 5/07/99 11:24a Nate
* Added support for a launcher config file
2024-06-15 18:13:59 +00:00
*
* 7 5/05/99 11:38p Nate
* Disabled Language selection for US release builds
2024-06-15 18:13:59 +00:00
*
* 6 2/24/99 1:46p Nate
* Added multi-language support
2024-06-15 18:13:59 +00:00
*
* 5 10/13/98 3:03p Nate
* More fixes and changes.
2024-06-15 18:13:59 +00:00
*
* 4 9/22/98 3:33p Nate
* Added conditional compiling to help system (can toggle between HTML and
* standard windows help)
2024-06-15 18:13:59 +00:00
*
* 3 9/21/98 5:40p Nate
* Incorporated the new HTML help system
2024-06-15 18:13:59 +00:00
*
* 2 8/17/98 10:35a Nate
* Added Keyboard Type page to Setup
*
* $NoKeywords: $
*/
// KeyboardTab.cpp : implementation file
//
#include "stdafx.h"
#include "afxpriv.h"
#include "afxext.h"
#include "d3launch.h"
#include "KeyboardTab.h"
#include "OS_Config.h"
#include "LaunchNames.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
2024-06-15 18:13:59 +00:00
#define KEYBOARD_US "United States"
#define KEYBOARD_FRENCH "French"
#define KEYBOARD_GERMAN "German"
/////////////////////////////////////////////////////////////////////////////
// CKeyboardTab property page
IMPLEMENT_DYNCREATE(CKeyboardTab, CPropertyPage)
2024-06-15 18:13:59 +00:00
CKeyboardTab::CKeyboardTab() : CPropertyPage(CKeyboardTab::IDD) {
//{{AFX_DATA_INIT(CKeyboardTab)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
2024-06-15 18:13:59 +00:00
CKeyboardTab::~CKeyboardTab() {}
2024-06-15 18:13:59 +00:00
void CKeyboardTab::DoDataExchange(CDataExchange *pDX) {
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKeyboardTab)
DDX_Control(pDX, IDC_FINDFAST_CHECK, m_FindFastCheck);
DDX_Control(pDX, IDC_LANGUAGE_COMBO, m_LanguageCombo);
DDX_Control(pDX, IDC_COMMANDLINE_EDIT, m_CommandLineEdit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKeyboardTab, CPropertyPage)
2024-06-15 18:13:59 +00:00
//{{AFX_MSG_MAP(CKeyboardTab)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CKeyboardTab message handlers
2024-06-15 18:13:59 +00:00
BOOL CKeyboardTab::OnInitDialog() {
CPropertyPage::OnInitDialog();
// Setup the language selection list
int lang_id;
2024-06-15 18:13:59 +00:00
AddLangToList(IDS_LANG_ENGLISH, LANGUAGE_ENGLISH);
#ifdef USE_MULTI_LANGUAGES
2024-06-15 18:13:59 +00:00
AddLangToList(IDS_LANG_FRENCH, LANGUAGE_FRENCH);
AddLangToList(IDS_LANG_GERMAN, LANGUAGE_GERMAN);
#ifdef ENABLE_ITALIAN
2024-06-15 18:13:59 +00:00
AddLangToList(IDS_LANG_ITALIAN, LANGUAGE_ITALIAN);
#endif
2024-06-15 18:13:59 +00:00
AddLangToList(IDS_LANG_SPANISH, LANGUAGE_SPANISH);
lang_id = os_config_read_uint(szSectionName, "LanguageType", LANGUAGE_ENGLISH);
#else
2024-06-15 18:13:59 +00:00
lang_id = LANGUAGE_ENGLISH;
#endif
2024-06-15 18:13:59 +00:00
SelectLangInList(lang_id);
// Disable the language selection box
if (!LanguageSelectionEnabled) {
m_LanguageCombo.EnableWindow(FALSE);
}
// Setup the keyboard type
char *keyboard_type = KEYBOARD_US;
keyboard_type = os_config_read_string(szSectionName, "KeyboardType", "");
if (!stricmp(keyboard_type, KEYBOARD_FRENCH))
((CButton *)GetDlgItem(IDC_FRENCH_KEYBOARD))->SetCheck(1);
else if (!stricmp(keyboard_type, KEYBOARD_GERMAN))
((CButton *)GetDlgItem(IDC_GERMAN_KEYBOARD))->SetCheck(1);
else {
((CButton *)GetDlgItem(IDC_US_KEYBOARD))->SetCheck(1);
}
// Set the FindFast checkbox
if (os_config_read_uint(szSectionName, "FindFastDisable", 1))
m_FindFastCheck.SetCheck(1);
else
m_FindFastCheck.SetCheck(0);
// Read the command line
char *command_line;
command_line = os_config_read_string(szSectionName, "CmdLineOptions", "");
m_CommandLineEdit.SetWindowText(command_line);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
2024-06-15 18:13:59 +00:00
void CKeyboardTab::OnOK() {
// Get the selected language
int prev_lang_id, lang_id;
lang_id = GetSelectedLangFromList();
if (lang_id < 0)
lang_id = LANGUAGE_ENGLISH;
prev_lang_id = os_config_read_uint(szSectionName, "LanguageType", LANGUAGE_ENGLISH);
if (prev_lang_id != lang_id)
NewLanguageSelected = TRUE;
os_config_write_uint(szSectionName, "LanguageType", lang_id);
// Get the keyboard type
char *keyboard_type = KEYBOARD_US;
if (((CButton *)GetDlgItem(IDC_FRENCH_KEYBOARD))->GetCheck() == 1)
keyboard_type = KEYBOARD_FRENCH;
else if (((CButton *)GetDlgItem(IDC_GERMAN_KEYBOARD))->GetCheck() == 1)
keyboard_type = KEYBOARD_GERMAN;
os_config_write_string(szSectionName, "KeyboardType", keyboard_type);
// save the findfast checkbox setting
if (m_FindFastCheck.GetCheck())
os_config_write_uint(szSectionName, "FindFastDisable", 1);
else
os_config_write_uint(szSectionName, "FindFastDisable", 0);
// write the command line
CString command_line;
m_CommandLineEdit.GetWindowText(command_line);
os_config_write_string(szSectionName, "CmdLineOptions", command_line.GetBuffer(0));
CPropertyPage::OnOK();
}
2024-06-15 18:13:59 +00:00
BOOL CKeyboardTab::OnHelpInfo(HELPINFO *pHelpInfo) {
// TODO: Add your message handler code here and/or call default
#ifdef USE_HTML_HELP_SYSTEM
2024-06-15 18:13:59 +00:00
CWaitCursor wc;
help_launch(KEYBOARDTAB_HELP);
return 1;
#else
2024-06-15 18:13:59 +00:00
return CPropertyPage::OnHelpInfo(pHelpInfo);
#endif
}
// Display the html help file
2024-06-15 18:13:59 +00:00
afx_msg LRESULT CKeyboardTab::OnCommandHelp(WPARAM wParam, LPARAM lParam) {
#ifdef USE_HTML_HELP_SYSTEM
2024-06-15 18:13:59 +00:00
help_launch(KEYBOARDTAB_HELP);
return 1;
#else
2024-06-15 18:13:59 +00:00
return CPropertyPage::OnCommandHelp(wParam, lParam);
#endif
}
2024-06-15 18:13:59 +00:00
bool CKeyboardTab::AddLangToList(int stringID, int langID) {
int index;
CString lang_string;
2024-06-15 18:13:59 +00:00
if (!lang_string.LoadString(stringID))
return FALSE;
2024-06-15 18:13:59 +00:00
index = m_LanguageCombo.AddString(lang_string.GetBuffer(0));
if (index < 0)
return FALSE;
2024-06-15 18:13:59 +00:00
if (m_LanguageCombo.SetItemData(index, langID) == CB_ERR)
return FALSE;
2024-06-15 18:13:59 +00:00
return TRUE;
}
2024-06-15 18:13:59 +00:00
bool CKeyboardTab::SelectLangInList(int langID) {
int index, num_items;
2024-06-15 18:13:59 +00:00
num_items = m_LanguageCombo.GetCount();
for (index = 0; index < num_items; index++) {
int data;
data = m_LanguageCombo.GetItemData(index);
if (data != CB_ERR && data == langID) {
m_LanguageCombo.SetCurSel(index);
return TRUE;
}
}
2024-06-15 18:13:59 +00:00
return FALSE;
}
2024-06-15 18:13:59 +00:00
int CKeyboardTab::GetSelectedLangFromList(void) {
int index, data;
2024-06-15 18:13:59 +00:00
index = m_LanguageCombo.GetCurSel();
if (index < 0)
return (-1);
2024-06-15 18:13:59 +00:00
data = m_LanguageCombo.GetItemData(index);
if (data == CB_ERR)
return (-1);
2024-06-15 18:13:59 +00:00
return (data);
}