📄 keyeditdlg.cpp
字号:
pValue(pValS), m_pEntityTable(pEntTable)
{
//{{AFX_DATA_INIT(CStructKeyEditDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CStructKeyEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStructKeyEditDlg)
DDX_Control(pDX, IDC_STRUCTLIST, m_StructList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStructKeyEditDlg, CDialog)
//{{AFX_MSG_MAP(CStructKeyEditDlg)
ON_LBN_DBLCLK(IDC_STRUCTLIST, OnDblclkStructlist)
ON_WM_VKEYTOITEM()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStructKeyEditDlg message handlers
static void stripQuotes
(
CString &str
)
/*
This function is in this module, and also in EntitiesDialog.
It should probably be in a utility module.
It wouldn't be necessary here or in EntitiesDialog if the strings
were de-quoted when they're loaded from the map file...
*/
{
char *temp = Util_Strdup (str);
if (*temp == '"')
{
strcpy (temp, temp+1);
}
if (temp[strlen (temp) - 1] == '"')
{
temp[strlen (temp) - 1] = '\0';
}
str = temp;
geRam_Free (temp);
}
BOOL CStructKeyEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
this->SetWindowText (Key);
// get the type name of the current key...
CString KeyTypeName = EntityTable_GetEntityPropertyTypeName (m_pEntityTable, Ent.GetClassname (), Key);
// Fill the listbox with those values
// And set the current selection to the current value (if selected).
this->m_StructList.ResetContent ();
{
// add <null> entry
CString EntityName = "<null>";
int Index = m_StructList.AddString (EntityName);
if (stricmp (*pValue, EntityName) == 0)
{
m_StructList.SetCurSel (Index);
}
}
// Get a list of all entities of this type...
for (int Current = 0; Current < (*mEntityArray).GetSize(); ++Current)
{
CEntity &Ent = (*mEntityArray)[Current];
if (KeyTypeName == Ent.GetClassname ())
{
CString EntityName;
if (!Ent.GetKeyValue ("%name%", EntityName))
{
EntityName = "Unnamed";
}
stripQuotes (EntityName);
// add the item....
int Index = m_StructList.AddString (EntityName);
if (stricmp (*pValue, EntityName) == 0)
{
m_StructList.SetCurSel (Index);
}
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStructKeyEditDlg::OnDblclkStructlist()
{
this->OnOK ();
}
void CStructKeyEditDlg::OnOK()
{
int CurSel = m_StructList.GetCurSel ();
if (CurSel != LB_ERR)
{
m_StructList.GetText (CurSel, *pValue);
}
CDialog::OnOK();
}
int CStructKeyEditDlg::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
switch (nKey)
{
case VK_SPACE :
this->OnOK ();
return -2;
default :
return CDialog::OnVKeyToItem(nKey, pListBox, nIndex);
}
}
/////////////////////////////////////////////////////////////////////////////
// CModelKeyEditDlg dialog
CModelKeyEditDlg::CModelKeyEditDlg(CWnd* pParent, ModelList *pModels, CString const KeyS, CString *pValS)
: CDialog(CModelKeyEditDlg::IDD, pParent),
Models(pModels), Key(KeyS), pValue(pValS)
{
//{{AFX_DATA_INIT(CModelKeyEditDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CModelKeyEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModelKeyEditDlg)
DDX_Control(pDX, IDC_MODELLIST, m_ModelList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModelKeyEditDlg, CDialog)
//{{AFX_MSG_MAP(CModelKeyEditDlg)
ON_LBN_DBLCLK(IDC_MODELLIST, OnDblclkModellist)
ON_WM_VKEYTOITEM()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModelKeyEditDlg message handlers
BOOL CModelKeyEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
this->SetWindowText (Key);
// get model ID of current model.
int ValueModelId;
Model *pModel;
pModel = ModelList_FindByName (Models, *pValue);
if (pModel == NULL)
{
ValueModelId = 0;
}
else
{
ValueModelId = Model_GetId (pModel);
}
// fill list box with existing models.
// set current selection to item containing pValue
m_ModelList.ResetContent ();
m_ModelList.SetCurSel (0);
{
// add <null> entry
CString EntityName = "<null>";
int Index = m_ModelList.AddString (EntityName);
m_ModelList.SetItemData (Index, 0);
if (stricmp (*pValue, EntityName) == 0)
{
m_ModelList.SetCurSel (Index);
}
}
ModelIterator mi;
pModel = ModelList_GetFirst (Models, &mi);
while (pModel != NULL)
{
char const * ModelName;
int Index;
int ModelId;
ModelId = Model_GetId (pModel);
ModelName = Model_GetName (pModel);
Index = m_ModelList.AddString (ModelName);
m_ModelList.SetItemData (Index, ModelId);
if (ModelId == ValueModelId)
{
m_ModelList.SetCurSel (Index);
}
pModel = ModelList_GetNext (Models, &mi);
}
return TRUE;
}
void CModelKeyEditDlg::OnDblclkModellist()
{
this->OnOK ();
}
void CModelKeyEditDlg::OnOK()
{
int CurSel = m_ModelList.GetCurSel ();
if (CurSel != LB_ERR)
{
m_ModelList.GetText (CurSel, *pValue);
}
CDialog::OnOK();
}
int CModelKeyEditDlg::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
switch (nKey)
{
case VK_SPACE :
this->OnOK ();
return -2;
default :
return CDialog::OnVKeyToItem(nKey, pListBox, nIndex);
}
}
/////////////////////////////////////////////////////////////////////////////
// CBoolKeyEditDlg dialog
CBoolKeyEditDlg::CBoolKeyEditDlg
(
CWnd* pParent,
CString const KeyS,
CString *pValS
) : CDialog(CBoolKeyEditDlg::IDD, pParent),
Key(KeyS), pValue(pValS)
{
//{{AFX_DATA_INIT(CBoolKeyEditDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CBoolKeyEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBoolKeyEditDlg)
DDX_Control(pDX, IDC_BOOLLIST, m_BoolList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBoolKeyEditDlg, CDialog)
//{{AFX_MSG_MAP(CBoolKeyEditDlg)
ON_LBN_DBLCLK(IDC_BOOLLIST, OnDblclkBoollist)
ON_WM_VKEYTOITEM()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBoolKeyEditDlg message handlers
void CBoolKeyEditDlg::OnDblclkBoollist()
{
this->OnOK ();
}
void CBoolKeyEditDlg::OnOK()
{
int CurSel = m_BoolList.GetCurSel ();
if (CurSel != LB_ERR)
{
m_BoolList.GetText (CurSel, *pValue);
}
CDialog::OnOK();
}
BOOL CBoolKeyEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
this->m_BoolList.ResetContent ();
m_BoolList.AddString ("False");
m_BoolList.AddString ("True");
if (stricmp (*pValue, "True") == 0)
{
m_BoolList.SetCurSel (1);
}
else
{
m_BoolList.SetCurSel (0);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
int CBoolKeyEditDlg::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex)
{
switch (nKey)
{
case VK_SPACE :
this->OnOK ();
return -2;
default :
return CDialog::OnVKeyToItem(nKey, pListBox, nIndex);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -