// EditVCtx.cpp: CEditVCtx クラスのインプリメンテーション
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "dm2gded.h"
#include "EditVCtx.h"
#include "ILSp.h"
#include "DM2RTextToken.h"

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

//////////////////////////////////////////////////////////////////////
// CEditVCtx

BOOL CEditVCtx::Get6CatItemName(int iCat, int iIdx, CString &strText)
{
	CGDEntry pos = CGDEntry::Min;
	switch (iCat) {
	case rttChests:  pos.c1(0x14); break; // CHESTS
	case rttWeapons: pos.c1(0x10); break; // WEAP
	case rttClothes: pos.c1(0x11); break; // CLOT
	case rttScrolls: pos.c1(0x12); break; // SCRO
	case rttPotions: pos.c1(0x13); break; // POTI
	case rttMisc:    pos.c1(0x15); break; // MISC
	}
	pos.c2((BYTE)iIdx);
	pos.c3(0x05);

	CILSp::GetInlang(m_aOpt.m_inlang).Transform(pos);

	CGDAT &core = m_pEdCtx->GetGDAT();

	if (core.GetDispTextAt(core.GetValueAt(pos), strText)) {
		return TRUE;
	}
	return FALSE;
}

BOOL CEditVCtx::Get4CatItemName(int iCat, int iIdx, CString &strText)
{
	CGDEntry pos = CGDEntry::Min;
	switch (iCat) {
	case rttWeapons: pos.c1(0x10); break;
	case rttClothes: pos.c1(0x11); break;
	case rttMisc:    pos.c1(0x15); break;
	case rttPotions: pos.c1(0x13); break;
	}
	pos.c2((BYTE)iIdx);
	pos.c3(0x05);

	CILSp::GetInlang(m_aOpt.m_inlang).Transform(pos);

	CGDAT &core = m_pEdCtx->GetGDAT();

	if (core.GetDispTextAt(core.GetValueAt(pos), strText)) {
		return TRUE;
	}
	return FALSE;
}

BOOL CEditVCtx::Get1CatItemName(int iCat, int iIdx, CString &strText)
{
	CGDEntry pos = CGDEntry::Min;
	switch (iCat) {
	case rttCreatures: pos.c1(0x0F); break;
	}
	pos.c2((BYTE)iIdx);
	pos.c3(0x05);

	CILSp::GetCnlang(m_aOpt.m_cnlang).Transform(pos);

	CGDAT &core = m_pEdCtx->GetGDAT();

	if (core.GetDispTextAt(core.GetValueAt(pos), strText)) {
		return TRUE;
	}
	return FALSE;
}
