Beispiel #1
0
/*----------------------------------------------------------------------------------------------
	Process notifications from the user.
----------------------------------------------------------------------------------------------*/
bool FmtGenDlg::OnNotifyChild(int ctidFrom, NMHDR * pnmh, long & lnRet)
{
	AssertPtr(pnmh);

	switch (pnmh->code)
	{
	case EN_KILLFOCUS: // Edit control modified.
		// Suppress updating the style from the control when we are trying to update the
		// control from the style.
		if (m_fSuppressLossOfFocus)
			break;

		if (ctidFrom == kctidFgEdName)
		{
			if (!m_pafsd->StyleIsSelected())
				return true;
			StyleInfo & styiSelected = m_pafsd->SelectedStyle();
			StrApp strOldName(styiSelected.m_stuName); // Save old name.
			StrApp strNewName;
			StrUni stuName;

			strNewName = GetName();

			// If the name has not changed, there is nothing to do.
			if (strNewName.Equals(strOldName))
				return true;

			stuName.Assign(strNewName);

			// If the style cannot be named stuName, put the old name back into the control.
			if (!m_pafsd->SetName(styiSelected, stuName))
			{
				::SetDlgItemText(m_hwnd, kctidFgEdName, strOldName.Chars());
				return true;
			}
			// Otherwise update the comboboxes for BasedOn and Next. Also update the edit box
			// to handle stripping of leading/trailing blanks.
			else
			{
				::SetDlgItemText(m_hwnd, kctidFgEdName, strNewName.Chars());
				UpdateComboboxes(strOldName, strNewName);
			}
		}
		return true;

	case CBN_SELCHANGE: // Combo box item changed.
		return OnComboChange(pnmh, lnRet);

	default:
		break;
	}

	return AfWnd::OnNotifyChild(ctidFrom, pnmh, lnRet);
}
SQInteger CSystemNatives::Rename(SQVM * pVM)
{
	const char *oldn, *newn;
	sq_getstring(pVM, 2, &oldn);
	sq_getstring(pVM, 3, &newn);
	String strOldName(oldn);
	String strNewName(newn);
	SharedUtility::RemoveIllegalCharacters(strOldName);
	SharedUtility::RemoveIllegalCharacters(strNewName);

	if(rename(SharedUtility::GetAbsolutePath("files/%s", strOldName.Get()), SharedUtility::GetAbsolutePath("files/%s", strNewName.Get())) == -1)
		return sq_throwerror(pVM, "rename() failed");

	sq_pushbool(pVM, true);
	return 0;
}
Beispiel #3
0
HANDLE WINAPI NewCreateFileA(
	LPCSTR lpFileName,
	DWORD dwDesiredAccess,
	DWORD dwShareMode,
	LPSECURITY_ATTRIBUTES lpSecurityAttributes,
	DWORD dwCreationDisposition,
	DWORD dwFlagsAndAttributes,
	HANDLE hTemplateFile)
{
	if (!lpFileName)
	{
		return INVALID_HANDLE_VALUE;
	}

	string strOldName(lpFileName);
	string strDirName = strOldName.substr(0, strOldName.find_last_of("\\") + 1);
	string strName = strOldName.substr(strOldName.find_last_of("\\") + 1);
	string strNewName;

	if (strName == "scene.int")
	{
		//MessageBoxA(NULL, "Found", "Asuka", MB_OK);
		strNewName = strDirName + "cnscene.int";
	}
	else if (strName == "fes.int")
	{
		strNewName = strDirName + "cnfes.int";
	}
	else
	{
		strNewName = strOldName;
	}
	return ((PfuncCreateFileA)(g_pOldCreateFileA))(
		strNewName.c_str(),
		dwDesiredAccess,
		dwShareMode,
		lpSecurityAttributes,
		dwCreationDisposition,
		dwFlagsAndAttributes,
		hTemplateFile);
}
Beispiel #4
0
/*----------------------------------------------------------------------------------------------
	Get the final values for the dialog controls, after the dialog has been closed.
----------------------------------------------------------------------------------------------*/
void FmtGenDlg::GetDialogValues(StyleInfo & styi, bool & fBasedOnChanged)
{
	StrUni stuName = GetName();
	StrApp strName = stuName;
	achar rgcha[1024];
	Vector<achar> vch;
	achar * pszT;
	memcpy(rgcha, strName.Chars(), strName.Length() * isizeof(achar));
	if (stuName != styi.m_stuName)
	{
		StrApp strOldName(styi.m_stuName);
		StrApp strNewName(stuName);
		if (!m_pafsd->SetName(styi, stuName))
		{
			// Error: restore the old name.
			::SetDlgItemText(m_hwnd, kctidFgEdName, strOldName.Chars());
		}
		// Otherwise update the comboboxes for BasedOn and Next.
		// This allows the later code which reads from them to work correctly,
		// so it is worth doing even here in a read routine.
		// Also update the edit box to handle stripping of leading/trailing blanks.
		else
		{
			::SetDlgItemText(m_hwnd, kctidFgEdName, strNewName.Chars());
			UpdateComboboxes(strOldName, strNewName);
		}
	}

	int iitem = ::SendMessage(m_hwndBasedOn, CB_GETCURSEL, 0,0);
	// <0 means the item is blank (e.g., Normal is not based on anything).
	// But if we pass -1 to CB_GETLBTEXT, we get the text of the first item.
	// This can change Normal to be based on Normal, with bad consequences.
	//
	if (iitem < 0)
	{
		pszT = _T("");
	}
	else
	{
		int cch = ::SendMessage(m_hwndBasedOn, CB_GETLBTEXTLEN, (WPARAM)iitem, 0);
		if (cch < 1024)
		{
			pszT = rgcha;
		}
		else
		{
			vch.Resize(cch + 1);
			pszT = vch.Begin();
		}
		cch = ::SendMessage(m_hwndBasedOn, CB_GETLBTEXT, iitem, (long)pszT);
		if (cch < 0)
			pszT = _T("");
	}
	stuName = pszT;
	HVO hvoBasedOn = m_pafsd->GetHvoOfStyleNamed(stuName);
	if (styi.m_hvoBasedOn != hvoBasedOn)
	{
		m_pafsd->SetBasedOn(styi, hvoBasedOn); // Sets m_fDirty.

		// Note that this is initialised to false in AfStylesDlg::UpdateTabCtrl.
		fBasedOnChanged = true;
	}

	iitem = ::SendMessage(m_hwndNext, CB_GETCURSEL, 0,0);
	if (iitem < 0)
	{
		pszT = _T("");
	}
	else
	{
		int cch = ::SendMessage(m_hwndNext, CB_GETLBTEXTLEN, (WPARAM)iitem, 0);
		if (cch < 1024)
		{
			pszT = rgcha;
		}
		else
		{
			vch.Resize(cch + 1);
			pszT = vch.Begin();
		}
		cch = ::SendMessage(m_hwndNext, CB_GETLBTEXT, iitem, (long)pszT);
		if (cch < 0)
			pszT = _T("");
	}
	stuName = pszT;
	HVO hvoNext = m_pafsd->GetHvoOfStyleNamed(stuName);
	if ((styi.m_hvoNext != hvoNext) && (styi.m_st != kstCharacter))
	{
		m_pafsd->SetNext(styi, hvoNext); // Sets m_fDirty.
	}
} //:> FmtGenDlg::GetDialogValues.