⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 accountauthority.cpp

📁 网络游戏龙族服务器端管理工具 rmtool 源代码
💻 CPP
字号:
// AccountAuthority.cpp : implementation file
//

#include "stdafx.h"
#include "rmtool.h"
#include "math.h"
#include "AccountAuthority.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAccountAuthority dialog

CAccountAuthority cAuthority;

CAccountAuthority::CAccountAuthority(CWnd* pParent /*=NULL*/)
	: CDialog(CAccountAuthority::IDD, pParent)
{
	m_dwAuthority=0;
	//{{AFX_DATA_INIT(CAccountAuthority)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CAccountAuthority::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAccountAuthority)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP

	UINT uID=IDC_MASK1;	//IDC_MASK1何磐 IDC_MASK_ADMIN鳖瘤 捣促. 
	for(int i=0; i<31 ; i++)
	{		
		DDX_Control( pDX, uID, c_Mask[i] );
		uID++;
//CString szTest;
//szTest.Format( "%d", uID);
//AfxMessageBox( szTest );
	}

}


BEGIN_MESSAGE_MAP(CAccountAuthority, CDialog)
	//{{AFX_MSG_MAP(CAccountAuthority)
	ON_BN_CLICKED(IDOK, OnOk)
	ON_BN_CLICKED(IDC_GET_AUTHORITY, OnGetAuthority)
	ON_BN_CLICKED(IDC_MASK_ADMIN, OnMaskAdmin)
	ON_BN_CLICKED(IDC_MASK_CLEAR, OnMaskClear)
	ON_BN_CLICKED(IDC_CALCULALT, OnCalculalt)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAccountAuthority message handlers
void CAccountAuthority::AllAuthorityCheck(bool bAllCheck)
{

	for( int i=0; i < NUM_MASK_TYPE; i++)
	{
		c_Mask[i].SetCheck( bAllCheck );
	}
}

int CAccountAuthority::SetAuthorityValue()
{
	UpdateData( FALSE );
	int iAuthority = 0;
	for( int i=0; i < NUM_MASK_TYPE-1; i++)
	{
		if( c_Mask[i].GetCheck() )
		{
			iAuthority += (int)pow( 2, i );
//CString szTest;
//szTest.Format( "%d", m_dwAuthority);
//szTest.Format( "%d", i);
//AfxMessageBox( szTest );
		}

	}
	return iAuthority;
}

void CAccountAuthority::OnOk() 
{
	// TODO: Add your control notification handler code here
	UpdateData(FALSE);	//泅犁 静咯柳 蔼捞 拌沥蔼捞促.
	m_dwAuthority = SetAuthorityValue();

	//磊脚狼 鼻茄阑 瘤沥秦林绰 傈开窃荐
#ifdef __KOYANGHI__
	SetUserAuthority( m_dwAuthority );
#endif
//int zz = c_Mask[30].GetCheck();
	
//CString szTest;
//szTest.Format( "%d", m_dwAuthority);
//AfxMessageBox( szTest );
	CDialog::OnOK();	
}

void CAccountAuthority::OnGetAuthority() 
{
	// TODO: Add your control notification handler code here
	int iAuthority = GetUserAuthority(1);
CString szAuthority;
szAuthority.Format( "%d", iAuthority);
AfxMessageBox( szAuthority);
}

BOOL CAccountAuthority::OnInitDialog() 
{
	CDialog::OnInitDialog();
	// TODO: Add extra initialization here

	//NUM_MASK_TYPE-1 篮 MASK_ADMINISTRATOR狼 锅龋捞促.
	//郴 鼻茄阑 箭磊肺 焊咯林绊 
	CString szAuthority;
	int iCkMask = GetUserAuthority( 1 ); // 021016 check
	szAuthority.Format( "%d", iCkMask );
	GetDlgItem( IDC_AUTHORITY_VALUE )->SetWindowText( szAuthority );

	//check滚瓢俊 犬牢矫难霖促. 
	for( int i = 0 ; i < NUM_MASK_TYPE-1 ; i++)
	{
		int iMask = (int)pow( 2, i);
		if( (iCkMask & iMask) == iMask )
			c_Mask[i].SetCheck( TRUE );
	}

	//MASK_ADMINISTRATOR check甫 困秦
	for( i=0;i< NUM_MASK_TYPE-1; i++)
	{
		if( !c_Mask[i].GetCheck() )
			return TRUE;
	}

	c_Mask[ NUM_MASK_TYPE-1 ].SetCheck(TRUE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CAccountAuthority::OnMaskAdmin() 
{
	// TODO: Add your control notification handler code here
	if( c_Mask[ NUM_MASK_TYPE-1 ].GetCheck() )
		AllAuthorityCheck( TRUE );
	else
		AllAuthorityCheck( FALSE );
}

void CAccountAuthority::OnMaskClear() 
{
	// TODO: Add your control notification handler code here
	AllAuthorityCheck( FALSE );
	SetCalculate( 0 );
}

void CAccountAuthority::OnCalculalt() 
{
	// TODO: Add your control notification handler code here
	SetCalculate( 0 );
	SetCalculate( SetAuthorityValue() );		
}

void CAccountAuthority::SetCalculate( const int iCalcul )
{ //甸绢柯 蔼栏肺 IDC_AUTHORITY_VALUE甫 技泼茄促.
	CString szTmp;
	szTmp.Format( "%d", iCalcul );
	GetDlgItem( IDC_AUTHORITY_VALUE )->SetWindowText( szTmp );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -