mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
Cleanup and doxy a few dialogs
This commit is contained in:
1 parent
0d8e09f136
commit
c062a071fb
6 files changed
+601
-537
No files matched your search
+186
-216
@@ -4,9 +4,6 @@
|
||||
* create based on the source.
|
||||
*/
|
||||
|
||||
// AltShipClassDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "fred.h"
|
||||
#include "AltShipClassDlg.h"
|
||||
@@ -18,9 +15,19 @@
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AltShipClassDlg dialog
|
||||
|
||||
BEGIN_MESSAGE_MAP(AltShipClassDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(AltShipClassDlg)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_ADD, OnAltClassAdd)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_INSERT, OnAltClassInsert)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_DELETE, OnAltClassDelete)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_UP, OnMoveUp)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_DOWN, OnMoveDown)
|
||||
ON_CBN_SELENDOK(IDC_SET_FROM_SHIP_CLASS, OnSelendokSetFromShipClass)
|
||||
ON_CBN_SELENDOK(IDC_SET_FROM_VARIABLES, OnSelendokSetFromVariables)
|
||||
ON_LBN_SELCHANGE(IDC_ALT_CLASS_LIST, OnSelchangeAltClassList)
|
||||
ON_BN_CLICKED(IDC_DEFAULT_TO_CLASS, OnDefaultToClass)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
AltShipClassDlg::AltShipClassDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(AltShipClassDlg::IDD, pParent)
|
||||
@@ -38,6 +45,121 @@ AltShipClassDlg::AltShipClassDlg(CWnd* pParent /*=NULL*/)
|
||||
memset(ship_class_indices, -1, sizeof (int)*MAX_SHIP_CLASSES);
|
||||
}
|
||||
|
||||
void AltShipClassDlg::alt_class_list_rebuild() {
|
||||
int i, j;
|
||||
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
|
||||
|
||||
j = m_alt_class_list.GetCount();
|
||||
for (i = 0; i < j; i++) {
|
||||
m_alt_class_list.DeleteString(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < (int) alt_class_pool.size(); i++) {
|
||||
// Default classes should be at the end of the list
|
||||
if (alt_class_pool[i].default_to_this_class && (i < (int) alt_class_pool.size() - 1)) {
|
||||
// Int3();
|
||||
// @TODO : we should fix this.
|
||||
}
|
||||
|
||||
if (alt_class_pool[i].variable_index != -1) {
|
||||
Assert(alt_class_pool[i].variable_index > -1 && alt_class_pool[i].variable_index < MAX_SEXP_VARIABLES);
|
||||
Assert(Sexp_variables[alt_class_pool[i].variable_index].type & SEXP_VARIABLE_STRING);
|
||||
|
||||
sprintf(buff, "%s[%s]", Sexp_variables[alt_class_pool[i].variable_index].variable_name, Sexp_variables[alt_class_pool[i].variable_index].text);
|
||||
|
||||
// add it to the list
|
||||
m_alt_class_list.AddString(buff);
|
||||
} else {
|
||||
if (alt_class_pool[i].ship_class >= 0 && alt_class_pool[i].ship_class < MAX_SHIP_CLASSES) {
|
||||
m_alt_class_list.AddString(Ship_info[alt_class_pool[i].ship_class].name);
|
||||
} else {
|
||||
m_alt_class_list.AddString("Invalid Ship Class");
|
||||
Int3();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item) {
|
||||
int index;
|
||||
|
||||
// Add a string variable to the list
|
||||
if (num_string_variables && m_set_from_variables.GetCurSel() > 0) {
|
||||
index = string_variable_indices[m_set_from_variables.GetCurSel() - 1];
|
||||
|
||||
Assert(index >= 0);
|
||||
list_item.variable_index = index;
|
||||
list_item.ship_class = ship_info_lookup(Sexp_variables[index].text);
|
||||
}
|
||||
// Add a ship class to the list
|
||||
else {
|
||||
index = m_set_from_ship_class.GetCurSel();
|
||||
|
||||
// Correct the index if the first entry isn't actually a ship class
|
||||
if (num_string_variables) {
|
||||
Assert(index > 0);
|
||||
index--;
|
||||
}
|
||||
|
||||
list_item.variable_index = -1;
|
||||
list_item.ship_class = ship_class_indices[index];
|
||||
}
|
||||
|
||||
// check the default tickbox
|
||||
list_item.default_to_this_class = m_default_to_class.GetCheck() ? true : false;
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassAdd() {
|
||||
alt_class new_list_item;
|
||||
|
||||
alt_class_update_entry(new_list_item);
|
||||
|
||||
alt_class_pool.push_back(new_list_item);
|
||||
alt_class_list_rebuild();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassDelete() {
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// Nothing selected
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Assert(index < (int) alt_class_pool.size());
|
||||
alt_class_pool.erase(alt_class_pool.begin() + index);
|
||||
alt_class_list_rebuild();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassInsert() {
|
||||
int index;
|
||||
alt_class new_list_item;
|
||||
alt_class_update_entry(new_list_item);
|
||||
|
||||
index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// If nothing is selected just add it
|
||||
if (index == -1) {
|
||||
alt_class_pool.push_back(new_list_item);
|
||||
}
|
||||
// Stick it in front of the current selection
|
||||
else {
|
||||
alt_class_pool.insert(alt_class_pool.begin() + index, new_list_item);
|
||||
}
|
||||
|
||||
alt_class_list_rebuild();
|
||||
|
||||
// If we inserted the user will probably want to edit the selection
|
||||
if (index > -1) {
|
||||
m_alt_class_list.SetCurSel(index);
|
||||
}
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnCancel() {
|
||||
// TODO: Add extra cleanup here
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
@@ -52,24 +174,16 @@ void AltShipClassDlg::DoDataExchange(CDataExchange* pDX)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnDefaultToClass() {
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
BEGIN_MESSAGE_MAP(AltShipClassDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(AltShipClassDlg)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_ADD, OnAltClassAdd)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_INSERT, OnAltClassInsert)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_DELETE, OnAltClassDelete)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_UP, OnMoveUp)
|
||||
ON_BN_CLICKED(IDC_ALT_CLASS_DOWN, OnMoveDown)
|
||||
ON_CBN_SELENDOK(IDC_SET_FROM_SHIP_CLASS, OnSelendokSetFromShipClass)
|
||||
ON_CBN_SELENDOK(IDC_SET_FROM_VARIABLES, OnSelendokSetFromVariables)
|
||||
ON_LBN_SELCHANGE(IDC_ALT_CLASS_LIST, OnSelchangeAltClassList)
|
||||
ON_BN_CLICKED(IDC_DEFAULT_TO_CLASS, OnDefaultToClass)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AltShipClassDlg message handlers
|
||||
// Nothing selected
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
alt_class_pool[index].default_to_this_class = m_default_to_class.GetCheck() ? true : false;
|
||||
}
|
||||
|
||||
BOOL AltShipClassDlg::OnInitDialog()
|
||||
{
|
||||
@@ -144,143 +258,6 @@ BOOL AltShipClassDlg::OnInitDialog()
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
void AltShipClassDlg::alt_class_list_rebuild()
|
||||
{
|
||||
int i, j;
|
||||
char buff[TOKEN_LENGTH + TOKEN_LENGTH + 2]; // VariableName[VariableValue]
|
||||
|
||||
j = m_alt_class_list.GetCount();
|
||||
for ( i=0; i < j ; i++) {
|
||||
m_alt_class_list.DeleteString(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)alt_class_pool.size() ; i++) {
|
||||
// Default classes should be at the end of the list
|
||||
if(alt_class_pool[i].default_to_this_class && (i < (int)alt_class_pool.size() - 1) ) {
|
||||
// Int3();
|
||||
// TO DO : we should fix this.
|
||||
}
|
||||
|
||||
if (alt_class_pool[i].variable_index != -1) {
|
||||
Assert (alt_class_pool[i].variable_index > -1 && alt_class_pool[i].variable_index < MAX_SEXP_VARIABLES);
|
||||
Assert (Sexp_variables[alt_class_pool[i].variable_index].type & SEXP_VARIABLE_STRING);
|
||||
|
||||
sprintf(buff, "%s[%s]", Sexp_variables[alt_class_pool[i].variable_index].variable_name, Sexp_variables[alt_class_pool[i].variable_index].text);
|
||||
|
||||
// add it to the list
|
||||
m_alt_class_list.AddString(buff);
|
||||
}
|
||||
else {
|
||||
if (alt_class_pool[i].ship_class >= 0 && alt_class_pool[i].ship_class < MAX_SHIP_CLASSES) {
|
||||
m_alt_class_list.AddString(Ship_info[alt_class_pool[i].ship_class].name);
|
||||
}
|
||||
else {
|
||||
m_alt_class_list.AddString("Invalid Ship Class");
|
||||
Int3();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnCancel()
|
||||
{
|
||||
// TODO: Add extra cleanup here
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
|
||||
for (int i=0; i < num_selected_ships; i++) {
|
||||
Ships[m_selected_ships[i]].s_alt_classes = alt_class_pool;
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassAdd()
|
||||
{
|
||||
alt_class new_list_item;
|
||||
|
||||
alt_class_update_entry(new_list_item);
|
||||
|
||||
alt_class_pool.push_back(new_list_item);
|
||||
alt_class_list_rebuild();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassInsert()
|
||||
{
|
||||
int index;
|
||||
alt_class new_list_item;
|
||||
alt_class_update_entry(new_list_item);
|
||||
|
||||
index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// If nothing is selected just add it
|
||||
if ( index == -1) {
|
||||
alt_class_pool.push_back(new_list_item);
|
||||
}
|
||||
// Stick it in front of the current selection
|
||||
else {
|
||||
alt_class_pool.insert(alt_class_pool.begin() + index, new_list_item );
|
||||
}
|
||||
|
||||
alt_class_list_rebuild();
|
||||
|
||||
// If we inserted the user will probably want to edit the selection
|
||||
if (index > -1) {
|
||||
m_alt_class_list.SetCurSel(index);
|
||||
}
|
||||
}
|
||||
|
||||
// Updates the currently selected list entry
|
||||
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item)
|
||||
{
|
||||
int index;
|
||||
|
||||
// Add a string variable to the list
|
||||
if (num_string_variables && m_set_from_variables.GetCurSel() > 0) {
|
||||
index = string_variable_indices[m_set_from_variables.GetCurSel() -1];
|
||||
|
||||
Assert (index >= 0);
|
||||
list_item.variable_index = index;
|
||||
list_item.ship_class = ship_info_lookup(Sexp_variables[index].text);
|
||||
}
|
||||
// Add a ship class to the list
|
||||
else {
|
||||
index = m_set_from_ship_class.GetCurSel();
|
||||
|
||||
// Correct the index if the first entry isn't actually a ship class
|
||||
if (num_string_variables) {
|
||||
Assert (index > 0);
|
||||
index--;
|
||||
}
|
||||
|
||||
list_item.variable_index = -1;
|
||||
list_item.ship_class = ship_class_indices[index];
|
||||
}
|
||||
|
||||
// check the default tickbox
|
||||
list_item.default_to_this_class = m_default_to_class.GetCheck() ? true:false;
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnAltClassDelete()
|
||||
{
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// Nothing selected
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Assert (index < (int) alt_class_pool.size());
|
||||
alt_class_pool.erase(alt_class_pool.begin()+index);
|
||||
alt_class_list_rebuild();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnMoveUp()
|
||||
{
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
@@ -310,6 +287,56 @@ void AltShipClassDlg::OnMoveDown()
|
||||
m_alt_class_list.SetCurSel(index);
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnOK() {
|
||||
// TODO: Add extra validation here
|
||||
|
||||
for (int i = 0; i < num_selected_ships; i++) {
|
||||
Ships[m_selected_ships[i]].s_alt_classes = alt_class_pool;
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnSelchangeAltClassList() {
|
||||
int i;
|
||||
int variable_selection = 0;
|
||||
int ship_selection = 0;
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// Selected nothing
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have a variable selected
|
||||
if (alt_class_pool[index].variable_index != -1) {
|
||||
for (i = 0; i < MAX_SEXP_VARIABLES; i++) {
|
||||
if (string_variable_indices[i] == alt_class_pool[index].variable_index) {
|
||||
variable_selection = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ship selected
|
||||
else {
|
||||
for (i = 0; i < MAX_SHIP_CLASSES; i++) {
|
||||
if (ship_class_indices[i] == alt_class_pool[index].ship_class) {
|
||||
ship_selection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have string variables in the mission the first entry on the list won't be a ship
|
||||
if (num_string_variables) {
|
||||
ship_selection++;
|
||||
}
|
||||
}
|
||||
|
||||
m_set_from_variables.SetCurSel(variable_selection);
|
||||
m_set_from_ship_class.SetCurSel(ship_selection);
|
||||
m_default_to_class.SetCheck(alt_class_pool[index].default_to_this_class ? 1 : 0);
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnSelendokSetFromShipClass()
|
||||
{
|
||||
int current_selection;
|
||||
@@ -347,60 +374,3 @@ void AltShipClassDlg::OnSelendokSetFromVariables()
|
||||
alt_class_list_rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnSelchangeAltClassList()
|
||||
{
|
||||
int i;
|
||||
int variable_selection = 0;
|
||||
int ship_selection = 0;
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// Selected nothing
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have a variable selected
|
||||
if (alt_class_pool[index].variable_index != -1) {
|
||||
for (i=0; i < MAX_SEXP_VARIABLES; i++)
|
||||
{
|
||||
if (string_variable_indices[i] == alt_class_pool[index].variable_index) {
|
||||
variable_selection = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Ship selected
|
||||
else {
|
||||
for (i=0; i < MAX_SHIP_CLASSES; i++) {
|
||||
if (ship_class_indices[i] == alt_class_pool[index].ship_class) {
|
||||
ship_selection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we have string variables in the mission the first entry on the list won't be a ship
|
||||
if (num_string_variables) {
|
||||
ship_selection++;
|
||||
}
|
||||
}
|
||||
|
||||
m_set_from_variables.SetCurSel(variable_selection);
|
||||
m_set_from_ship_class.SetCurSel(ship_selection);
|
||||
m_default_to_class.SetCheck(alt_class_pool[index].default_to_this_class ? 1:0);
|
||||
}
|
||||
|
||||
void AltShipClassDlg::OnDefaultToClass()
|
||||
{
|
||||
int index = m_alt_class_list.GetCurSel();
|
||||
|
||||
// Nothing selected
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
alt_class_pool[index].default_to_this_class = m_default_to_class.GetCheck() ? true:false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+91
-43
@@ -4,83 +4,131 @@
|
||||
* create based on the source.
|
||||
*/
|
||||
|
||||
#if !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
|
||||
#define AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// AltShipClassDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AltShipClassDlg dialog
|
||||
#ifndef _ALTSHIPCLASSDLG_H
|
||||
#define _ALTSHIPCLASSDLG_H
|
||||
|
||||
/**
|
||||
* @class AltShipClassDlg
|
||||
*
|
||||
* @brief Alternate Ship Class Editor, called from the Alt Ship Class button (Ships Editor)
|
||||
*/
|
||||
class AltShipClassDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
AltShipClassDlg(CWnd* pParent = NULL); // standard constructor
|
||||
/**
|
||||
* @brief Standard constructor, nothing special
|
||||
*
|
||||
* @see OnInitDialog
|
||||
*/
|
||||
AltShipClassDlg(CWnd* pParent = NULL);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(AltShipClassDlg)
|
||||
enum { IDD = IDD_ALT_SHIP_CLASS };
|
||||
CButton m_default_to_class;
|
||||
CListBox m_alt_class_list;
|
||||
CComboBox m_set_from_ship_class;
|
||||
CComboBox m_set_from_variables;
|
||||
int m_selected_variable;
|
||||
int m_selected_class;
|
||||
enum
|
||||
{
|
||||
IDD = IDD_ALT_SHIP_CLASS
|
||||
};
|
||||
|
||||
CButton m_default_to_class; //!< That's no button, its a checkbox! Filled if the selected alt ship type in the class list is considered the default.
|
||||
CListBox m_alt_class_list; //!< Listbox of alternative ship types allowed for the selected ship
|
||||
|
||||
CComboBox m_set_from_ship_class; //!< Choicebox of available ship types
|
||||
int m_selected_class; //!< The selected ship class in the m_set_from_ship_class choicebox
|
||||
|
||||
CComboBox m_set_from_variables; //!< Choicebox of available SEXP variables
|
||||
int m_selected_variable; //!< The selected SEXP variable in the m_set_from_variables choicebox
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(AltShipClassDlg)
|
||||
protected:
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(AltShipClassDlg)
|
||||
/**
|
||||
* @brief Handler for dialog initialization
|
||||
*/
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Cancel button
|
||||
*/
|
||||
virtual void OnCancel();
|
||||
|
||||
/**
|
||||
* @brief Handler for the OK button
|
||||
*/
|
||||
virtual void OnOK();
|
||||
|
||||
/**
|
||||
* @brief Handler for the AltClass::Add button
|
||||
*/
|
||||
afx_msg void OnAltClassAdd();
|
||||
|
||||
/**
|
||||
* @brief Handler for the AltClass::Insert button
|
||||
*/
|
||||
afx_msg void OnAltClassInsert();
|
||||
|
||||
/**
|
||||
* @brief Handler for the AltClass::Delete button
|
||||
*/
|
||||
afx_msg void OnAltClassDelete();
|
||||
|
||||
/**
|
||||
* @brief Handler for the MoveUp button
|
||||
*
|
||||
* @details Moves the selected item up by one
|
||||
*/
|
||||
afx_msg void OnMoveUp();
|
||||
|
||||
/**
|
||||
* @brief Handler for the MoveDown button
|
||||
*
|
||||
* @details Moves the selected item down by one
|
||||
*/
|
||||
afx_msg void OnMoveDown();
|
||||
|
||||
afx_msg void OnSelendokSetFromShipClass();
|
||||
afx_msg void OnSelendokSetFromVariables();
|
||||
afx_msg void OnSelchangeAltClassList();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Default to Class checkbox
|
||||
*/
|
||||
afx_msg void OnDefaultToClass();
|
||||
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
private:
|
||||
|
||||
bool player_ships_only; // Whether we only add player ships to the alt classes or if we can add any ship
|
||||
bool player_ships_only; //!< True if we can only add player ships to the alt classes, false if we can add any
|
||||
|
||||
//! Pool of alt ship classes for the selected item.
|
||||
//! The pool is shown in the m_alt_class_list but this vector is easier to work with internally.
|
||||
SCP_vector<alt_class> alt_class_pool;
|
||||
int num_string_variables; // Number of string variables in the mission
|
||||
int string_variable_indices[MAX_SEXP_VARIABLES]; // maps string variables to their index in Sexp_variables
|
||||
int ship_class_indices[MAX_SHIP_CLASSES]; // maps ships in the ships combobox to their index in Ship_info
|
||||
|
||||
|
||||
// variables to handle selection of multiple ships
|
||||
bool multi_edit;
|
||||
int m_selected_ships[MAX_SHIPS];
|
||||
int num_selected_ships;
|
||||
int num_string_variables; //!< Number of string variables in the mission
|
||||
int string_variable_indices[MAX_SEXP_VARIABLES]; //!< maps string variables to their index in Sexp_variables
|
||||
int ship_class_indices[MAX_SHIP_CLASSES]; //!< maps ships in the ships combobox to their index in Ship_info
|
||||
|
||||
void AltShipClassDlg::alt_class_list_rebuild();
|
||||
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item);
|
||||
//!@
|
||||
//! Multi-edit member.
|
||||
bool multi_edit; //!< True if multiple ships are selected
|
||||
int m_selected_ships[MAX_SHIPS]; //!< Array containing the indices of the selected ships.
|
||||
int num_selected_ships; //!< Number of ships selected
|
||||
//!@}
|
||||
|
||||
/**
|
||||
* @brief Helper function, rebuilds the alt ship pool and repopulates the m_alt_class_list listbox
|
||||
*/
|
||||
void AltShipClassDlg::alt_class_list_rebuild();
|
||||
|
||||
/**
|
||||
* @brief Helper function, updates the selected alt ship entry
|
||||
*/
|
||||
void AltShipClassDlg::alt_class_update_entry(alt_class &list_item);
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_AltShipClassDlg_H__2FE2C917_C7DA_4C05_A11F_DCC46BFB26BB__INCLUDED_)
|
||||
#endif // _ALTSHIPCLASSDLG_H
|
||||
+158
-182
@@ -1,19 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
||||
*
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* source.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
// AddVariableDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "FRED.h"
|
||||
#include "AddVariableDlg.h"
|
||||
#include "parse/sexp.h"
|
||||
#include <parse/sexp.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
@@ -23,32 +21,6 @@ static char THIS_FILE[] = __FILE__;
|
||||
#define NO_RESET_FOCUS 0
|
||||
#define RESET_FOCUS 1
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAddVariableDlg dialog
|
||||
|
||||
|
||||
CAddVariableDlg::CAddVariableDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CAddVariableDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CAddVariableDlg)
|
||||
m_default_value = _T("");
|
||||
m_variable_name = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CAddVariableDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAddVariableDlg)
|
||||
DDX_Text(pDX, IDC_ADD_VARIABLE_DEFAULT_VALUE, m_default_value);
|
||||
DDV_MaxChars(pDX, m_default_value, 31);
|
||||
DDX_Text(pDX, IDC_ADD_VARIABLE_NAME, m_variable_name);
|
||||
DDV_MaxChars(pDX, m_variable_name, 31);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAddVariableDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CAddVariableDlg)
|
||||
ON_BN_CLICKED(IDC_TYPE_NUMBER, OnTypeNumber)
|
||||
@@ -59,54 +31,27 @@ BEGIN_MESSAGE_MAP(CAddVariableDlg, CDialog)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAddVariableDlg message handlers
|
||||
|
||||
void CAddVariableDlg::OnOK()
|
||||
{
|
||||
// validation name
|
||||
validate_variable_name(RESET_FOCUS);
|
||||
|
||||
// validate data
|
||||
if ( m_name_validated ) {
|
||||
validate_data(RESET_FOCUS);
|
||||
}
|
||||
|
||||
// both ok, then store results
|
||||
if ( m_name_validated && m_data_validated ) {
|
||||
// int sexp_add_variable(char *text, char*, int type);
|
||||
// char temp_name[32];
|
||||
// char temp_value[32];
|
||||
// strcpy_s(temp_name, m_variable_name);
|
||||
// strcpy_s(temp_value, m_default_value);
|
||||
// SEXP_VARIABLE_NUMBER SEXP_VARIABLE_STRING
|
||||
// int type;
|
||||
//
|
||||
// if (m_type_number) {
|
||||
// type = SEXP_VARIABLE_NUMBER;
|
||||
// } else {
|
||||
// type = SEXP_VARIABLE_STRING;
|
||||
// }
|
||||
//
|
||||
// // Goober5000
|
||||
// if (m_type_player_persistent) {
|
||||
// type |= SEXP_VARIABLE_PLAYER_PERSISTENT;
|
||||
// } else if (m_type_campaign_persistent) {
|
||||
// type |= SEXP_VARIABLE_CAMPAIGN_PERSISTENT;
|
||||
// }
|
||||
//
|
||||
// m_sexp_var_index = sexp_add_variable(temp_value, temp_name, type);
|
||||
// this get done for free CDialog::OnOk() UpdateData(TRUE);
|
||||
m_create = true;
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
CAddVariableDlg::CAddVariableDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CAddVariableDlg::IDD, pParent) {
|
||||
//{{AFX_DATA_INIT(CAddVariableDlg)
|
||||
m_default_value = _T("");
|
||||
m_variable_name = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
BOOL CAddVariableDlg::OnInitDialog()
|
||||
{
|
||||
void CAddVariableDlg::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CAddVariableDlg)
|
||||
DDX_Text(pDX, IDC_ADD_VARIABLE_DEFAULT_VALUE, m_default_value);
|
||||
DDV_MaxChars(pDX, m_default_value, 31);
|
||||
DDX_Text(pDX, IDC_ADD_VARIABLE_NAME, m_variable_name);
|
||||
DDV_MaxChars(pDX, m_variable_name, 31);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BOOL CAddVariableDlg::OnInitDialog() {
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
m_variable_name = "<Variable Name>";
|
||||
m_default_value = "<Default Value>";
|
||||
@@ -124,39 +69,144 @@ BOOL CAddVariableDlg::OnInitDialog()
|
||||
|
||||
// Send default name and values into dialog box
|
||||
UpdateData(FALSE);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
bool is_sexp_variable_name(const char* temp_name)
|
||||
{
|
||||
for (int i=0; i<MAX_SEXP_VARIABLES; i++) {
|
||||
if (Sexp_variables[i].type & SEXP_VARIABLE_SET) {
|
||||
if ( !strcmp(Sexp_variables[i].text, temp_name) ) {
|
||||
return false;
|
||||
void CAddVariableDlg::OnOK() {
|
||||
// validation name
|
||||
validate_variable_name(RESET_FOCUS);
|
||||
|
||||
// validate data
|
||||
if (m_name_validated) {
|
||||
validate_data(RESET_FOCUS);
|
||||
}
|
||||
|
||||
// both ok, then store results
|
||||
if (m_name_validated && m_data_validated) {
|
||||
// int sexp_add_variable(char *text, char*, int type);
|
||||
// char temp_name[32];
|
||||
// char temp_value[32];
|
||||
// strcpy_s(temp_name, m_variable_name);
|
||||
// strcpy_s(temp_value, m_default_value);
|
||||
// SEXP_VARIABLE_NUMBER SEXP_VARIABLE_STRING
|
||||
// int type;
|
||||
//
|
||||
// if (m_type_number) {
|
||||
// type = SEXP_VARIABLE_NUMBER;
|
||||
// } else {
|
||||
// type = SEXP_VARIABLE_STRING;
|
||||
// }
|
||||
//
|
||||
// // Goober5000
|
||||
// if (m_type_player_persistent) {
|
||||
// type |= SEXP_VARIABLE_PLAYER_PERSISTENT;
|
||||
// } else if (m_type_campaign_persistent) {
|
||||
// type |= SEXP_VARIABLE_CAMPAIGN_PERSISTENT;
|
||||
// }
|
||||
//
|
||||
// m_sexp_var_index = sexp_add_variable(temp_value, temp_name, type);
|
||||
// this get done for free CDialog::OnOk() UpdateData(TRUE);
|
||||
m_create = true;
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeCampaignPersistent() {
|
||||
m_type_campaign_persistent = ((CButton *) GetDlgItem(IDC_TYPE_CAMPAIGN_PERSISTENT))->GetCheck() ? true : false;
|
||||
|
||||
if (m_type_campaign_persistent)
|
||||
m_type_player_persistent = false;
|
||||
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeNetworkVariable() {
|
||||
m_type_network_variable = ((CButton *) GetDlgItem(IDC_TYPE_NETWORK_VARIABLE))->GetCheck() ? true : false;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeNumber() {
|
||||
m_type_number = true;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypePlayerPersistent() {
|
||||
m_type_player_persistent = ((CButton *) GetDlgItem(IDC_TYPE_PLAYER_PERSISTENT))->GetCheck() ? true : false;
|
||||
|
||||
if (m_type_player_persistent)
|
||||
m_type_campaign_persistent = false;
|
||||
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeString() {
|
||||
m_type_number = false;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::set_variable_type() {
|
||||
|
||||
CButton *button_string = (CButton *) GetDlgItem(IDC_TYPE_STRING);
|
||||
CButton *button_number = (CButton *) GetDlgItem(IDC_TYPE_NUMBER);
|
||||
|
||||
button_number->SetCheck(m_type_number);
|
||||
button_string->SetCheck(!m_type_number);
|
||||
|
||||
((CButton *) GetDlgItem(IDC_TYPE_CAMPAIGN_PERSISTENT))->SetCheck(m_type_campaign_persistent);
|
||||
((CButton *) GetDlgItem(IDC_TYPE_PLAYER_PERSISTENT))->SetCheck(m_type_player_persistent);
|
||||
((CButton *) GetDlgItem(IDC_TYPE_NETWORK_VARIABLE))->SetCheck(m_type_network_variable);
|
||||
}
|
||||
|
||||
void CAddVariableDlg::validate_data(int set_focus) {
|
||||
CString temp_data;
|
||||
|
||||
CEdit *edit = (CEdit *) GetDlgItem(IDC_ADD_VARIABLE_DEFAULT_VALUE);
|
||||
edit->GetWindowText(temp_data);
|
||||
|
||||
// check for 0 string length
|
||||
if (strlen(temp_data) == 0) { //-V805
|
||||
m_data_validated = false;
|
||||
} else {
|
||||
if (m_type_number) {
|
||||
// verify valid number
|
||||
int temp_num = atoi(temp_data);
|
||||
char buf[TOKEN_LENGTH];
|
||||
sprintf(buf, "%d", temp_num);
|
||||
|
||||
if (stricmp(buf, temp_data)) {
|
||||
m_data_validated = false;
|
||||
} else {
|
||||
m_data_validated = true;
|
||||
}
|
||||
} else {
|
||||
m_data_validated = true;
|
||||
}
|
||||
}
|
||||
// name not found
|
||||
return true;
|
||||
|
||||
// Display message and reset focus
|
||||
if ((!m_data_validated) && (set_focus == RESET_FOCUS)) {
|
||||
MessageBox("Invalid Default Value.");
|
||||
edit->SetFocus();
|
||||
edit->SetSel(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check variable name (1) changed (2) > 0 length (3) does not already exist
|
||||
void CAddVariableDlg::validate_variable_name(int set_focus)
|
||||
{
|
||||
void CAddVariableDlg::validate_variable_name(int set_focus) {
|
||||
CString temp_name;
|
||||
|
||||
CEdit *edit = (CEdit *) GetDlgItem(IDC_ADD_VARIABLE_NAME);
|
||||
edit->GetWindowText(temp_name);
|
||||
|
||||
// Check if any change and not already in list
|
||||
if ( stricmp(temp_name, "<Variable Name>") ) {
|
||||
if ( (strlen(temp_name) > 0) && (get_index_sexp_variable_name(LPCTSTR(temp_name)) == -1) ) { //not already in list and length > 0 { //-V805
|
||||
if (stricmp(temp_name, "<Variable Name>")) {
|
||||
size_t len = strlen(temp_name);
|
||||
|
||||
if ((len > 0) && (get_index_sexp_variable_name(LPCTSTR(temp_name)) == -1)) { //not already in list and length > 0 { //-V805
|
||||
// Goober5000 - replace spaces with hyphens
|
||||
if (strchr(temp_name, ' ') != NULL)
|
||||
{
|
||||
if (strchr(temp_name, ' ') != NULL) {
|
||||
// display msg
|
||||
MessageBox("Variable names cannot contain spaces. Replacing with hyphens.");
|
||||
|
||||
@@ -174,12 +224,16 @@ void CAddVariableDlg::validate_variable_name(int set_focus)
|
||||
m_name_validated = true;
|
||||
} else {
|
||||
// conflicting variable name
|
||||
if (strlen(temp_name) == 0) { //-V805
|
||||
if (len == 0) {
|
||||
edit->SetWindowText("<Variable Name>");
|
||||
}
|
||||
m_name_validated = false;
|
||||
if (set_focus == RESET_FOCUS) {
|
||||
MessageBox("Conflicting variable name");
|
||||
if (len == 0) {
|
||||
MessageBox("Variables must have a unique name.");
|
||||
} else {
|
||||
MessageBox("Another variable has this name already. Please choose another.");
|
||||
}
|
||||
edit->SetFocus();
|
||||
edit->SetSel(0, -1);
|
||||
}
|
||||
@@ -196,92 +250,14 @@ void CAddVariableDlg::validate_variable_name(int set_focus)
|
||||
|
||||
}
|
||||
|
||||
void CAddVariableDlg::validate_data(int set_focus)
|
||||
{
|
||||
CString temp_data;
|
||||
|
||||
CEdit *edit = (CEdit *) GetDlgItem(IDC_ADD_VARIABLE_DEFAULT_VALUE);
|
||||
edit->GetWindowText(temp_data);
|
||||
|
||||
// check for 0 string length
|
||||
if (strlen(temp_data) == 0) { //-V805
|
||||
m_data_validated = false;
|
||||
} else {
|
||||
if (m_type_number) {
|
||||
// verify valid number
|
||||
int temp_num = atoi(temp_data);
|
||||
char buf[TOKEN_LENGTH];
|
||||
sprintf(buf, "%d", temp_num);
|
||||
|
||||
if ( stricmp(buf, temp_data) ) {
|
||||
m_data_validated = false;
|
||||
} else {
|
||||
m_data_validated = true;
|
||||
bool is_sexp_variable_name(const char* temp_name) {
|
||||
for (int i = 0; i < MAX_SEXP_VARIABLES; i++) {
|
||||
if (Sexp_variables[i].type & SEXP_VARIABLE_SET) {
|
||||
if (!strcmp(Sexp_variables[i].text, temp_name)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
m_data_validated = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Display message and reset focus
|
||||
if ( (!m_data_validated) && (set_focus == RESET_FOCUS) ) {
|
||||
MessageBox("Invalid Default Value.");
|
||||
edit->SetFocus();
|
||||
edit->SetSel(0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
// Set type to number
|
||||
void CAddVariableDlg::OnTypeNumber()
|
||||
{
|
||||
m_type_number = true;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
// Set type to string
|
||||
void CAddVariableDlg::OnTypeString()
|
||||
{
|
||||
m_type_number = false;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypePlayerPersistent()
|
||||
{
|
||||
m_type_player_persistent = ((CButton *) GetDlgItem(IDC_TYPE_PLAYER_PERSISTENT))->GetCheck() ? true : false;
|
||||
|
||||
if (m_type_player_persistent)
|
||||
m_type_campaign_persistent = false;
|
||||
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeCampaignPersistent()
|
||||
{
|
||||
m_type_campaign_persistent = ((CButton *) GetDlgItem(IDC_TYPE_CAMPAIGN_PERSISTENT))->GetCheck() ? true : false;
|
||||
|
||||
if (m_type_campaign_persistent)
|
||||
m_type_player_persistent = false;
|
||||
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
void CAddVariableDlg::OnTypeNetworkVariable()
|
||||
{
|
||||
m_type_network_variable = ((CButton *) GetDlgItem(IDC_TYPE_NETWORK_VARIABLE))->GetCheck() ? true : false;
|
||||
set_variable_type();
|
||||
}
|
||||
|
||||
// Set type check boxes
|
||||
void CAddVariableDlg::set_variable_type()
|
||||
{
|
||||
|
||||
CButton *button_string = (CButton *) GetDlgItem(IDC_TYPE_STRING);
|
||||
CButton *button_number = (CButton *) GetDlgItem(IDC_TYPE_NUMBER);
|
||||
|
||||
button_number->SetCheck( m_type_number);
|
||||
button_string->SetCheck(!m_type_number);
|
||||
|
||||
((CButton *) GetDlgItem(IDC_TYPE_CAMPAIGN_PERSISTENT))->SetCheck(m_type_campaign_persistent);
|
||||
((CButton *) GetDlgItem(IDC_TYPE_PLAYER_PERSISTENT))->SetCheck(m_type_player_persistent);
|
||||
((CButton *) GetDlgItem(IDC_TYPE_NETWORK_VARIABLE))->SetCheck(m_type_network_variable);
|
||||
// name not found
|
||||
return true;
|
||||
}
|
||||
+93
-37
@@ -1,68 +1,124 @@
|
||||
/*
|
||||
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
||||
*
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* source.
|
||||
*
|
||||
*/
|
||||
#ifndef _ADDVARIABLEDLG_H
|
||||
#define _ADDVARIABLEDLG_H
|
||||
|
||||
/**
|
||||
* @class CAddVariableDlg
|
||||
*
|
||||
* @brief The Add Variable dialog, created when adding a new variable to a sexp in the Mission Event editor
|
||||
*/
|
||||
|
||||
|
||||
#if !defined(AFX_ADDVARIABLEDLG_H__0F668CB5_AAEE_11D2_A899_0060088FAE88__INCLUDED_)
|
||||
#define AFX_ADDVARIABLEDLG_H__0F668CB5_AAEE_11D2_A899_0060088FAE88__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// AddVariableDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CAddVariableDlg dialog
|
||||
|
||||
class CAddVariableDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CAddVariableDlg(CWnd* pParent = NULL); // standard constructor
|
||||
/**
|
||||
* @brief Standard constructor.
|
||||
*
|
||||
* @see CAddVariableDlg::OnInitDialog()
|
||||
*/
|
||||
CAddVariableDlg(CWnd* pParent = NULL);
|
||||
|
||||
// Dialog Data
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CAddVariableDlg)
|
||||
enum { IDD = IDD_ADD_VARIABLE };
|
||||
CString m_default_value;
|
||||
CString m_variable_name;
|
||||
bool m_name_validated;
|
||||
bool m_data_validated;
|
||||
bool m_type_number;
|
||||
bool m_type_campaign_persistent;
|
||||
bool m_type_player_persistent;
|
||||
bool m_type_network_variable;
|
||||
bool m_create;
|
||||
int m_sexp_var_index;
|
||||
enum
|
||||
{
|
||||
IDD = IDD_ADD_VARIABLE
|
||||
};
|
||||
|
||||
CString m_default_value; //!< The default value for the new variable
|
||||
CString m_variable_name; //!< The name of the new variable
|
||||
bool m_name_validated; //!< True if the name has been validated
|
||||
bool m_data_validated; //!< True if the data has been validated
|
||||
|
||||
// Radiobutton group
|
||||
bool m_type_number; //!< True if the type is a number, false if the type is a string
|
||||
|
||||
// Checkbox group
|
||||
bool m_type_campaign_persistent; //!< True if the variable is campaign persistant
|
||||
bool m_type_player_persistent; //!< True if the variable is player persistant
|
||||
bool m_type_network_variable; //!< True if the variable is a network variable (multiplayer)
|
||||
|
||||
bool m_create; //!< True if the variable should be created upon the dialog's closure
|
||||
|
||||
int m_sexp_var_index;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CAddVariableDlg)
|
||||
protected:
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CAddVariableDlg)
|
||||
/**
|
||||
* @brief Handler for the OK button
|
||||
*/
|
||||
virtual void OnOK();
|
||||
|
||||
/**
|
||||
* @brief Handler for dialog initialization.
|
||||
*/
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
/**
|
||||
* @brief Validates the new variable name
|
||||
*
|
||||
* @param[in] set_focus If equal to @p SET_FOCUS a message box will inform the user of the error.
|
||||
*
|
||||
* @details Checks if the variable name's value has changed, nonzero length, and does not already exist
|
||||
*/
|
||||
afx_msg void validate_variable_name(int set_focus);
|
||||
|
||||
/**
|
||||
* @brief Validates the new variable's data
|
||||
*
|
||||
* @param[in] set_focus If equal to @p SET_FOCUS a message box will inform the user of the error.
|
||||
*
|
||||
* @details Checks if the data string's value is nonzero length, and (if a number type) is a valid number string
|
||||
*/
|
||||
afx_msg void validate_data(int set_focus);
|
||||
|
||||
/**
|
||||
* @brief Handler for the Type::Number radio button
|
||||
*/
|
||||
afx_msg void OnTypeNumber();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Type::String radio button
|
||||
*/
|
||||
afx_msg void OnTypeString();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Player Persistent radio checkbox
|
||||
*
|
||||
* @details A variable may be player persistent, campaign persitent, or not persetent.
|
||||
*/
|
||||
afx_msg void OnTypePlayerPersistent();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Campaign Persistent radio checkbox
|
||||
*
|
||||
* @details A variable may be player persistent, campaign persitent, or not persetent.
|
||||
*/
|
||||
afx_msg void OnTypeCampaignPersistent();
|
||||
|
||||
/**
|
||||
* @brief Handler for the Network Variable checkbox
|
||||
*/
|
||||
afx_msg void OnTypeNetworkVariable();
|
||||
|
||||
/**
|
||||
* @brief Handler for the type checkboxes and radio buttons.
|
||||
*
|
||||
* @details Sets each of the widget's Check state according to the member values
|
||||
*/
|
||||
afx_msg void set_variable_type();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
@@ -71,4 +127,4 @@ protected:
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_ADDVARIABLEDLG_H__0F668CB5_AAEE_11D2_A899_0060088FAE88__INCLUDED_)
|
||||
#endif // _ADDVARIABLEDLG_H
|
||||
+19
-32
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
||||
*
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* source.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -19,12 +19,16 @@
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// adjust_grid_dlg dialog
|
||||
BEGIN_MESSAGE_MAP(adjust_grid_dlg, CDialog)
|
||||
//{{AFX_MSG_MAP(adjust_grid_dlg)
|
||||
ON_BN_CLICKED(IDC_XY_PLANE, OnXyPlane)
|
||||
ON_BN_CLICKED(IDC_XZ_PLANE, OnXzPlane)
|
||||
ON_BN_CLICKED(IDC_YZ_PLANE, OnYzPlane)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
adjust_grid_dlg::adjust_grid_dlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(adjust_grid_dlg::IDD, pParent)
|
||||
{
|
||||
: CDialog(adjust_grid_dlg::IDD, pParent) {
|
||||
//{{AFX_DATA_INIT(adjust_grid_dlg)
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
@@ -32,8 +36,7 @@ adjust_grid_dlg::adjust_grid_dlg(CWnd* pParent /*=NULL*/)
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
void adjust_grid_dlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
void adjust_grid_dlg::DoDataExchange(CDataExchange* pDX) {
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(adjust_grid_dlg)
|
||||
DDX_Control(pDX, IDC_SPIN_Z, m_spinz);
|
||||
@@ -45,19 +48,7 @@ void adjust_grid_dlg::DoDataExchange(CDataExchange* pDX)
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
BEGIN_MESSAGE_MAP(adjust_grid_dlg, CDialog)
|
||||
//{{AFX_MSG_MAP(adjust_grid_dlg)
|
||||
ON_BN_CLICKED(IDC_XY_PLANE, OnXyPlane)
|
||||
ON_BN_CLICKED(IDC_XZ_PLANE, OnXzPlane)
|
||||
ON_BN_CLICKED(IDC_YZ_PLANE, OnYzPlane)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// adjust_grid_dlg message handlers
|
||||
|
||||
BOOL adjust_grid_dlg::OnInitDialog()
|
||||
{
|
||||
BOOL adjust_grid_dlg::OnInitDialog() {
|
||||
m_x = (int) The_grid->center.xyz.x;
|
||||
m_y = (int) The_grid->center.xyz.y;
|
||||
m_z = (int) The_grid->center.xyz.z;
|
||||
@@ -84,18 +75,17 @@ BOOL adjust_grid_dlg::OnInitDialog()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void adjust_grid_dlg::OnOK()
|
||||
{
|
||||
void adjust_grid_dlg::OnOK() {
|
||||
UpdateData(TRUE);
|
||||
The_grid->center.xyz.x = (float) m_x;
|
||||
The_grid->center.xyz.y = (float) m_y;
|
||||
The_grid->center.xyz.z = (float) m_z;
|
||||
|
||||
if (((CButton *) GetDlgItem(IDC_XY_PLANE)) -> GetCheck()) {
|
||||
if (((CButton *) GetDlgItem(IDC_XY_PLANE))->GetCheck()) {
|
||||
The_grid->gmatrix.vec.fvec = vmd_x_vector;
|
||||
The_grid->gmatrix.vec.rvec = vmd_y_vector;
|
||||
|
||||
} else if (((CButton *) GetDlgItem(IDC_YZ_PLANE)) -> GetCheck()) {
|
||||
} else if (((CButton *) GetDlgItem(IDC_YZ_PLANE))->GetCheck()) {
|
||||
The_grid->gmatrix.vec.fvec = vmd_y_vector;
|
||||
The_grid->gmatrix.vec.rvec = vmd_z_vector;
|
||||
|
||||
@@ -108,8 +98,7 @@ void adjust_grid_dlg::OnOK()
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void adjust_grid_dlg::OnXyPlane()
|
||||
{
|
||||
void adjust_grid_dlg::OnXyPlane() {
|
||||
GetDlgItem(IDC_EDIT_X)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_SPIN_X)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_EDIT_Y)->EnableWindow(FALSE);
|
||||
@@ -118,8 +107,7 @@ void adjust_grid_dlg::OnXyPlane()
|
||||
GetDlgItem(IDC_SPIN_Z)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
void adjust_grid_dlg::OnXzPlane()
|
||||
{
|
||||
void adjust_grid_dlg::OnXzPlane() {
|
||||
GetDlgItem(IDC_EDIT_X)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_SPIN_X)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_EDIT_Y)->EnableWindow(TRUE);
|
||||
@@ -128,8 +116,7 @@ void adjust_grid_dlg::OnXzPlane()
|
||||
GetDlgItem(IDC_SPIN_Z)->EnableWindow(FALSE);
|
||||
}
|
||||
|
||||
void adjust_grid_dlg::OnYzPlane()
|
||||
{
|
||||
void adjust_grid_dlg::OnYzPlane() {
|
||||
GetDlgItem(IDC_EDIT_X)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_SPIN_X)->EnableWindow(TRUE);
|
||||
GetDlgItem(IDC_EDIT_Y)->EnableWindow(FALSE);
|
||||
|
||||
+54
-27
@@ -1,51 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
||||
*
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* All source code herein is the property of Volition, Inc. You may not sell
|
||||
* or otherwise commercially exploit the source or things you created based on the
|
||||
* source.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// adjust_grid_dlg dialog
|
||||
*/
|
||||
#ifndef _ADJUSTGRIDDLG_H
|
||||
#define _ADJUSTGRIDDLG_H
|
||||
|
||||
/**
|
||||
* @class adjust_grid_dlg
|
||||
*
|
||||
* @brief Dialog for the mission grid properties.
|
||||
*/
|
||||
class adjust_grid_dlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void OnOK();
|
||||
adjust_grid_dlg(CWnd* pParent = NULL); // standard constructor
|
||||
/**
|
||||
* @brief Standard constructor, nothing special
|
||||
*
|
||||
* @see adjust_grid_dlg::OnInitDialog
|
||||
*/
|
||||
adjust_grid_dlg(CWnd* pParent = NULL);
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(adjust_grid_dlg)
|
||||
enum { IDD = IDD_ADJUST_GRID };
|
||||
CSpinButtonCtrl m_spinz;
|
||||
CSpinButtonCtrl m_spiny;
|
||||
CSpinButtonCtrl m_spinx;
|
||||
int m_x;
|
||||
int m_y;
|
||||
int m_z;
|
||||
/**
|
||||
* @brief Handler for the OK button.
|
||||
*
|
||||
* @details Transfers the X, Y, Z value from the spin control to the appropriate grid value and then exchanges data. The type of grid that is drawn (XZ, XY, YZ) is controlled by which button is active.
|
||||
*/
|
||||
void OnOK();
|
||||
|
||||
enum
|
||||
{
|
||||
IDD = IDD_ADJUST_GRID
|
||||
};
|
||||
|
||||
CSpinButtonCtrl m_spinx; //!< Spin control X value
|
||||
CSpinButtonCtrl m_spiny; //!< Spin control Y value
|
||||
CSpinButtonCtrl m_spinz; //!< Spin control Z value
|
||||
|
||||
int m_x; //!< Grid's X value
|
||||
int m_y; //!< Grid's Y value
|
||||
int m_z; //!< Grid's Z value
|
||||
//}}AFX_DATA
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(adjust_grid_dlg)
|
||||
protected:
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(adjust_grid_dlg)
|
||||
|
||||
/**
|
||||
* @brief Handler for dialog initialization.
|
||||
*/
|
||||
virtual BOOL OnInitDialog();
|
||||
|
||||
/**
|
||||
* @brief Handler for the XY button
|
||||
*/
|
||||
afx_msg void OnXyPlane();
|
||||
|
||||
/**
|
||||
* @brief Handler for the XZ button
|
||||
*/
|
||||
afx_msg void OnXzPlane();
|
||||
|
||||
/**
|
||||
* @brief Handler for the YZ button
|
||||
*/
|
||||
afx_msg void OnYzPlane();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
#endif // _ADJUSTGRIDDLG_H
|
||||
Reference in new issue
Block a user