MercDataEd.cpp
arcaed/MercDataEd.cpp · 4.9 KB
From the archive arcaed_source.zip
Download the archive « Back to the archive contents
/*
* Arcanum Editor - ROM area editor
* Copyright (C) 1999 Lucas Wall <kthulhu@usa.net>
*
* 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 2 of the License, or
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* If you make changes to the source and want to make the public you can
* mail the diferences to me <kthulhu@usa.net> and I'll add them to the
* main distribution. Of course your name will be added to the program with
* information about the changes you made.
*
*
* Packed on Thu Aug 19 03:02:20 1999
*
*/
/*
* File: MercDataEd.cpp
*
* Changes:
*
* 19/08/99 Lucas Wall <kthulhu@usa.net>
* First source release. Its quite messy and has no
* comments. I never planed to release the source code... :-)
*
*/
// MercDataEd.cpp : implementation file
//
#include "stdafx.h"
#include "arcaed.h"
#include "MercDataEd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMercDataEd dialog
CMercDataEd::CMercDataEd(CWnd* pParent /*=NULL*/)
: CDialog(CMercDataEd::IDD, pParent)
{
//{{AFX_DATA_INIT(CMercDataEd)
m_Clan = _T("");
m_Rank = 0;
m_SkillNum = 0;
m_Msg = _T("");
//}}AFX_DATA_INIT
}
void CMercDataEd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMercDataEd)
DDX_Control(pDX, IDC_MERCED_MERCMSGLIST, m_MsgList);
DDX_Control(pDX, IDC_MERCED_SKILL_NUM_SPIN, m_SkillNumSpin);
DDX_Control(pDX, IDC_MERCED_SKILL_LIST, m_SkillList);
DDX_Control(pDX, IDC_MERCED_RANK_SPIN, m_RankSpin);
DDX_Text(pDX, IDC_MERCED_CLAN, m_Clan);
DDX_Text(pDX, IDC_MERCED_RANK, m_Rank);
DDV_MinMaxInt(pDX, m_Rank, 1, 32767);
DDX_Text(pDX, IDC_MERCED_SKILL_NUM, m_SkillNum);
DDV_MinMaxInt(pDX, m_SkillNum, 0, 100);
DDX_Text(pDX, IDC_MERCED_MERCMSG, m_Msg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMercDataEd, CDialog)
//{{AFX_MSG_MAP(CMercDataEd)
ON_LBN_SELCHANGE(IDC_MERCED_SKILL_LIST, OnSelchangeMercedSkillList)
ON_EN_CHANGE(IDC_MERCED_SKILL_NUM, OnChangeMercedSkillNum)
ON_CBN_SELCHANGE(IDC_MERCED_MERCMSGLIST, OnSelchangeMercedMercmsglist)
ON_EN_CHANGE(IDC_MERCED_MERCMSG, OnChangeMercedMercmsg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMercDataEd message handlers
BOOL CMercDataEd::OnInitDialog()
{
CDialog::OnInitDialog();
int i, index;
m_RankSpin.SetBuddy( GetDlgItem( IDC_MERCED_RANK ) );
m_RankSpin.SetRange( 1, 32767 );
m_SkillNumSpin.SetBuddy( GetDlgItem( IDC_MERCED_SKILL_NUM ) );
m_SkillNumSpin.SetRange( 0, 100 );
for ( i = 0; i < m_skills.GetSize(); i++ )
{
index = m_SkillList.AddString( m_skills[i]->m_skill );
ASSERT( index != LB_ERR && index != LB_ERRSPACE );
m_SkillList.SetItemData( index, i );
}
m_SkillList.SetCurSel( 0 );
OnSelchangeMercedSkillList();
for ( i = 0; i < tables.m_mercmsg.GetSize(); i++ )
{
index = m_MsgList.AddString( tables.m_mercmsg[i]->m_text );
ASSERT( index != CB_ERR && index != CB_ERRSPACE );
m_MsgList.SetItemData( index, i );
}
m_MsgList.SetCurSel( 0 );
OnSelchangeMercedMercmsglist();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMercDataEd::OnSelchangeMercedSkillList()
{
int sel;
if ( ( sel = m_SkillList.GetCurSel() ) == LB_ERR )
return;
int i = m_SkillList.GetItemData( sel );
m_SkillNumSpin.SetPos( m_skills[i]->m_percent );
}
void CMercDataEd::OnChangeMercedSkillNum()
{
int sel;
UpdateData( TRUE );
if ( ( sel = m_SkillList.GetCurSel() ) == LB_ERR )
{
m_SkillNumSpin.SetPos( 0 );
return;
}
int i = m_SkillList.GetItemData( sel );
m_skills[i]->m_percent = m_SkillNum;
}
void CMercDataEd::OnSelchangeMercedMercmsglist()
{
int sel;
if ( ( sel = m_MsgList.GetCurSel() ) == LB_ERR )
return;
UpdateData( TRUE );
int i = m_MsgList.GetItemData( sel );
m_Msg = m_mercmsg[i];
UpdateData( FALSE );
}
void CMercDataEd::OnChangeMercedMercmsg()
{
int sel;
UpdateData( TRUE );
if ( ( sel = m_MsgList.GetCurSel() ) == LB_ERR )
{
m_Msg = "";
UpdateData( FALSE );
return;
}
int i = m_MsgList.GetItemData( sel );
m_mercmsg[i] = m_Msg;
}