int KGTestMapDisuseResource::FindResInModelset(const char cszResourceName[], set<string>& vecResList)
{
	//参照KG3DRepresentObjectSet::LoadFromIniFile
	int nRetCode = false;
	int nResult  = false;
	IIniFile* pIniFile = NULL;
	char szSourcePathName[MAX_PATH] = {0};

	KG_ASSERT_EXIT(cszResourceName);
	KGLOG_PROCESS_ERROR(cszResourceName[0] != '\0');

	nRetCode = _snprintf_s(szSourcePathName,
		sizeof(szSourcePathName),
		sizeof(szSourcePathName) - 1,
		"%s%s",
		m_szClientPath,
		cszResourceName);
	KGLOG_PROCESS_ERROR(nRetCode > 0);

	pIniFile = g_OpenIniFile(szSourcePathName);
	KGLOG_PROCESS_ERROR(pIniFile);

	int nCount = 0;
	pIniFile->GetInteger("MAIN", "Count", 0, &nCount);

	for (int i = 0; i < nCount; i++)
	{
		char szSecName[MAX_PATH]  = {0};
		char szMeshName[MAX_PATH] = {0};
		char szMtlName[MAX_PATH]  = {0};

		nRetCode = _snprintf_s(szSecName, sizeof(szSecName), sizeof(szSecName) - 1, "Model%d", i);
		KGLOG_PROCESS_ERROR(nRetCode> 0);
		pIniFile->GetString(szSecName, "MeshName", "", szMeshName, sizeof(szMeshName));
		FindResource(szMeshName, vecResList);
		pIniFile->GetString(szSecName, "MtlName", "", szMtlName, sizeof(szMtlName));
		FindResource(szMtlName, vecResList);
	}

	nResult = true;
Exit0:
	if (pIniFile)
	{	
		pIniFile->Release();
		pIniFile = NULL;
	}
	return nResult;
}
Exemple #2
0
LRESULT KGSFXGlobPage::OnColorBkDialogClose(WPARAM w, LPARAM l)
{
    GET_SFX_EDITOR_RET(0);

    TCHAR szIniPath[MAX_PATH];
    g_GetFullPath(szIniPath, TEXT("config.ini"));
    IIniFile* pIniFile = g_OpenIniFile(szIniPath, true, true);

    if (pIniFile)
    {
        pIniFile->WriteStruct(TEXT("SfxEditor"), TEXT("bkcolor"), pScene->GetBkColorPtr(), sizeof(DWORD));
        pIniFile->Save(szIniPath);
        pIniFile->Release();
    }

    return 1;
}
int  KGObjectPropertyEditDlg::ShowPropertyTable(
	CString szNamePlate, CString szTemplate, CString szIniFile
)
{
	m_listProperty.DeleteAllItems();
	m_arrayPropertyListItem.RemoveAll();

	m_szCurIniFileName = szIniFile;
	SetWindowText(m_szWindowTextt + " 正在编辑 : " + m_szCurIniFileName);

	SAFE_RELEASE(m_pIniFile);
	m_pIniFile          = g_OpenIniFile(szTemplate.GetBuffer());
	IIniFile* pIniFile  = g_OpenIniFile(szIniFile);
	IIniFile* pNameFile = g_OpenIniFile(szNamePlate.GetBuffer());

	if (!pNameFile)  return FALSE;
	if (!m_pIniFile) return FALSE;
	if (!pIniFile)   return FALSE;

	char szSection[256] = "";
	char szKey[256]     = "";
	char szPlate[256]   = "";
	char szValue[512]   = "";
	char szType[256]    = "";

	UINT uIndex = 0;

	while (m_pIniFile->GetNextSection(szSection, szSection))
	{
		PropertyListItem item(szSection, szSection);
		m_arrayPropertyListItem.Add(item);
		pNameFile->GetString(
			szSection, "Title", "未知标题", szPlate, sizeof(szPlate)
		);
		m_listProperty.InsertItem (uIndex, NULL);
		m_listProperty.SetItemText(uIndex, 0, szPlate);
		//m_listProperty.SetItemData(uIndex, VALUE_TITLE);
		uIndex++;

		*szKey = '\0';
		while (m_pIniFile->GetNextKey(szSection, szKey, szKey))
		{
			pNameFile->GetString(
				"Globe", szKey, "未知键名", szPlate, sizeof(szPlate)
			);
			if (CString(szPlate) == "未知键名")
			{
				pNameFile->GetString(
					szSection, szKey, "未知键名", szPlate, sizeof(szPlate)
				);
			}

			CString szKeyType = CString(szKey) + CString("Type");

			pNameFile->GetString(
				"Globe", szKeyType.GetBuffer(), "VALUE_UNKNOW",
				szType, sizeof(szType)
			);
			if (CString(szType) == "VALUE_UNKNOW")
			{
				pNameFile->GetString(
					szSection, szKeyType.GetBuffer(), "STRING",
					szType, sizeof(szType)
				);
			}

			m_pIniFile->GetString(
				szSection, szKey, "未知键值", szValue, sizeof(szValue)
			);
			pIniFile->GetString(
				szSection, szKey, szValue, szValue, sizeof(szValue)
			);
			m_pIniFile->WriteString(szSection, szKey, szValue);

			PropertyListItem item(szSection, szKey);
			m_arrayPropertyListItem.Add(item);

			m_listProperty.InsertItem (uIndex, NULL);
			m_listProperty.SetItemText(uIndex, 0, szPlate);
			m_listProperty.SetItemText(uIndex, 1, szValue);
			m_listProperty.SetItemData(uIndex, GetKeyType(CString(szType)));
			uIndex++;
		}
	}

	pIniFile->Release();
	pNameFile->Release();

	return TRUE;
}
int KGObjectPropertyEditDlg::LoadConfig(const TCHAR pcszAbsName[])
{
	int nResult  = false;
	int nRetCode = false;

	TCHAR     szValue[MAX_PATH] = {0};
	CString   szSection;
	IIniFile* pIniFile = NULL;

	CString szPath      = /*g_Work_Directory +*/ CString("\\");
	CString szNamePlate = szPath + "nameplate.ini";
	CString szTemplate  = szPath + "template.ini";

	ASSERT(pcszAbsName);
	KG_PROCESS_ERROR(pcszAbsName);

	pIniFile = g_OpenIniFile(pcszAbsName);
	KG_PROCESS_ERROR(pIniFile);

	switch (m_eEditType)
	{
	case PROPERTY_EDIT_TYPE_EQUIP :
		szSection = "EQUIP";
		break;
	case PROPERTY_EDIT_TYPE_NPC_ANI :
		szSection = "NPC_ANI";
		break;
	case PROPERTY_EDIT_TYPE_PLAYER_ANI :
		szSection = "PLAYER_ANI";
		break;
	default:
		KG_PROCESS_ERROR(false);
		break;
	}

	pIniFile->GetString(
		szSection.GetBuffer(), "Directory", szPath.GetBuffer(),
		szValue, sizeof(szValue)
	);
	m_szDirectory = CString(szValue);

	pIniFile->GetString(
		szSection.GetBuffer(), "Nameplate", szNamePlate.GetBuffer(),
		szValue, sizeof(szValue)
	);
	m_szNamePlate = CString(szValue);

	pIniFile->GetString(
		szSection.GetBuffer(), "Template", szTemplate.GetBuffer(),
		szValue, sizeof(szValue)
	);

	m_szTemplate = CString(szValue);

	nResult = true;
Exit0:
	if (pIniFile)
	{
		pIniFile->Release();
	}
	return nResult;
}