#include "RefineForm.h"


using namespace ObjDataEdit;
//######################################################################################################
ReaderClass< DB_GameObjDbStruct >* RefineTableForm::ObjReader( )
{
	return GameObjDbStructEx::ObjReader_EqRefineAbility();
}
//主要需要繼承的涵式
void    RefineTableForm::OnActive()
{
	static bool FirstTime = true;

	//設定種族職業資訊
	if( FirstTime  == false )
		return;

	FirstTime = false;

	BaseForm::OnActive();

	CB_AbilityList1->Items->Clear();
	CB_AbilityList2->Items->Clear();
	CB_AbilityList3->Items->Clear();
	CB_AbilityList4->Items->Clear();
	CB_AbilityList5->Items->Clear();

	for( int i = 0 ; i < EM_WearEqType_MaxCount ; i++ )
	{
		String* Str = GameObjDbStructEx::GetWearEqTypeENUMString( (WearEqTypeENUM)i );
		CB_AbilityList1->Items->Add( Str );
		CB_AbilityList2->Items->Add( Str );
		CB_AbilityList3->Items->Add( Str );
		CB_AbilityList4->Items->Add( Str );
		CB_AbilityList5->Items->Add( Str );
	}    
}
void    RefineTableForm::OnSelectObj( bool LockOk )
{
    _ObjDB.GameData.Classification = EM_ObjectClass_EqRefineAbility;
//    panel1->Enabled = LockOk;
	DB_GameObjDbStruct __pin * TempObj = &_ObjDB;

	int Index = TempObj->GameData.GUID - Def_ObjectClass_EqRefineAbility;
	int Type  = Index / 20 + 1;
	int Level = Index % 20 + 1;
	if( Type >= CB_RefineType->Items->Count )
		CB_RefineType->SelectedIndex = 0;
	else
		CB_RefineType->SelectedIndex = Type;
	TB_RefineLevel->Text = String::Format( "{0}" , __box( Level ) );

}
//輸出時額外設定
void    RefineTableForm::OnOutputObjSetting( DB_GameObjDbStruct* TempObj )
{
    TempObj->GameData.Classification = EM_ObjectClass_EqRefineAbility;

	int Index = TempObj->GameData.GUID - Def_ObjectClass_EqRefineAbility;
	int Type  = Index / 20;
	int Level = Index % 20 + 1;

	TempObj->GameData.EqRefineAttribute.Type  = (EqRefineAttributeTypeENUM)Type;
	TempObj->GameData.EqRefineAttribute.Level = Level;
}

void    RefineTableForm::OnTimeProc()
{
    
}
int     RefineTableForm::ObjSize(  )
{
    GameObjDbStruct *P = NULL;
    int Size = sizeof( GameObjDbStruct ) - sizeof( P->Temp ) +  sizeof( P->EqRefineAttribute ) + 3;
    Size = Size & 0xfffffC;
    return Size;
}
void    RefineTableForm::OnValueChange()
{

}
//######################################################################################################

