Every single plugin author / maintainer copies the code to save / restore the window settings roughly the same way.
What if we were to move most of the functionality into the base CCustomWnd class?
Code: Select all
CCustomWnd::SaveWindowSettings(char *FileName,char *SectionName);
CCustomWnd::LoadWindowSettings(char *FileName,char *SectionName);
1 - set/save the position
2 - set/save the color
3 - set/save the status bits - locked, fades, alpha, etc.
4 - set/save the title
Instead of going in and changing all the plugins that have a section like :
Code: Select all
void ReadWindowINI(PCSIDLWND pWindow)
{
CHAR Buffer[MAX_STRING] = { 0 };
pWindow->SetLocation({ (LONG)GetPrivateProfileInt("Settings", "ChatLeft", 164, INIFileName),
(LONG)GetPrivateProfileInt("Settings", "ChatTop", 357, INIFileName),
(LONG)GetPrivateProfileInt("Settings", "ChatRight", 375, INIFileName),
(LONG)GetPrivateProfileInt("Settings", "ChatBottom", 620, INIFileName) });
pWindow->SetLocked((GetPrivateProfileInt("Settings", "Locked", 0, INIFileName) ? true : false));
pWindow->SetFades((GetPrivateProfileInt("Settings", "Fades", 1, INIFileName) ? true : false));
pWindow->SetFadeDelay(GetPrivateProfileInt("Settings", "Delay", 2000, INIFileName));
pWindow->SetFadeDuration(GetPrivateProfileInt("Settings", "Duration", 500, INIFileName));
pWindow->SetAlpha(GetPrivateProfileInt("Settings", "Alpha", 255, INIFileName));
pWindow->SetFadeToAlpha(GetPrivateProfileInt("Settings", "FadeToAlpha", 255, INIFileName));
pWindow->SetBGType(GetPrivateProfileInt("Settings", "BGType", 1, INIFileName));
ARGBCOLOR col = { 0 };
col.A = GetPrivateProfileInt("Settings", "BGTint.alpha", 255, INIFileName);
col.R = GetPrivateProfileInt("Settings", "BGTint.red", 0, INIFileName);
col.G = GetPrivateProfileInt("Settings", "BGTint.green", 0, INIFileName);
col.B = GetPrivateProfileInt("Settings", "BGTint.blue", 0, INIFileName);
pWindow->SetBGColor(col.ARGB);
}
void WriteWindowINI(PCSIDLWND pWindow)
{
CHAR szTemp[MAX_STRING] = { 0 };
if (pWindow->IsMinimized())
{
WritePrivateProfileString("Settings", "ChatTop", SafeItoa(pWindow->GetOldLocation().top, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatBottom", SafeItoa(pWindow->GetOldLocation().bottom, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatLeft", SafeItoa(pWindow->GetOldLocation().left, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatRight", SafeItoa(pWindow->GetOldLocation().right, szTemp, 10), INIFileName);
}
else
{
WritePrivateProfileString("Settings", "ChatTop", SafeItoa(pWindow->GetLocation().top, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatBottom", SafeItoa(pWindow->GetLocation().bottom, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatLeft", SafeItoa(pWindow->GetLocation().left, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "ChatRight", SafeItoa(pWindow->GetLocation().right, szTemp, 10), INIFileName);
}
WritePrivateProfileString("Settings", "Locked", SafeItoa(pWindow->IsLocked(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "Fades", SafeItoa(pWindow->GetFades(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "Delay", SafeItoa(pWindow->GetFadeDelay(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "Duration", SafeItoa(pWindow->GetFadeDuration(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "Alpha", SafeItoa(pWindow->GetAlpha(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "FadeToAlpha", SafeItoa(pWindow->GetFadeToAlpha(), szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "BGType", SafeItoa(pWindow->GetBGType(), szTemp, 10), INIFileName);
ARGBCOLOR col = { 0 };
col.ARGB = pWindow->GetBGColor();
WritePrivateProfileString("Settings", "BGTint.alpha", SafeItoa(col.A, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "BGTint.red", SafeItoa(col.R, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "BGTint.green", SafeItoa(col.G, szTemp, 10), INIFileName);
WritePrivateProfileString("Settings", "BGTint.blue", SafeItoa(col.B, szTemp, 10), INIFileName);
}
Code: Select all
pWindow->LoadWindowSettings(INIFileName,"Settings");
pWindow->SaveWindowSettings(INIFileName,"Settings");