//this file is part of NeoMule
//Copyright (C)2006 David Xanatos ( Xanatos@Lycos.at / http://neomule.sourceforge.net )
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


#include "stdafx.h"
#include "emule.h"
#include "PPgRelease.h"
#include "Preferences.h"
#include "PartFile.h"
#include "OtherFunctions.h"
#include "Sion/Functions.h"
#include "Sion/GUI/CP/TreeFunctions.h"
#include "Sion/Defaults.h"
#include "UserMsgs.h"
#include "EmuleDlg.h"// NPT
#include "SharedFilesWnd.h" // NPT
#include "SharedFilesCtrl.h" // NPT
#include "KnownFileList.h" // NPT
#include "sharedfilelist.h"

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

// MOD: NPT - [NeoPartTraffic]
#define PT_EXPERT _T("Expert")
#define PT_NORMAL _T("Normal")
#define PT_RED	  _T("Red")
#define PT_BLUE   _T("Blue")

class CPartTrafficStyle : public CTreeOptionsCombo
{
public:
	CPartTrafficStyle();
	virtual ~CPartTrafficStyle();

protected:
	//{{AFX_VIRTUAL(CPartTrafficStyle)
	//}}AFX_VIRTUAL

	//{{AFX_MSG(CPartTrafficStyle)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()

  DECLARE_DYNCREATE(CPartTrafficStyle)
};


IMPLEMENT_DYNCREATE(CPartTrafficStyle, CTreeOptionsCombo)

CPartTrafficStyle::CPartTrafficStyle()
{
}

CPartTrafficStyle::~CPartTrafficStyle()
{
}

BEGIN_MESSAGE_MAP(CPartTrafficStyle, CTreeOptionsCombo)
	//{{AFX_MSG_MAP(CPartTrafficStyle)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


int CPartTrafficStyle::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTreeOptionsCombo::OnCreate(lpCreateStruct) == -1)
		return -1;
	
  //Add strings to the combo
  AddString(PT_EXPERT);
  AddString(PT_NORMAL);
  AddString(PT_BLUE);
  AddString(PT_RED);
	
	return 0;
}
// MOD: NPT END 


///////////////////////////////////////////////////////////////////////////////
// CPPgRelease dialog

IMPLEMENT_DYNAMIC(CPPgRelease, CPropertyPage)

BEGIN_MESSAGE_MAP(CPPgRelease, CPropertyPage)
	ON_WM_TIMER() // MOD: FCFG - [FileConfiguration]
	ON_WM_DESTROY()
	ON_MESSAGE(UM_DATA_CHANGED, OnDataChanged) // MOD: FCFG - [FileConfiguration]
	ON_MESSAGE(WM_TREEOPTSCTRL_NOTIFY, OnTreeOptsCtrlNotify)
	ON_MESSAGE(WM_TREEITEM_HELP, DrawTreeItemHelp)
	ON_WM_HELPINFO()
END_MESSAGE_MAP()

CPPgRelease::CPPgRelease()
	: CPropertyPage(CPPgRelease::IDD)
	, m_ctrlTreeOptions(theApp.m_iDfltImageListColorFlags)
{
	// MOD: FCFG - [FileConfiguration]
	m_bFilePreferences = false;

	m_paFiles = NULL;
	m_bDataChanged = false;
	m_strCaption = GetResString(IDS_X_RELEASE_MENU);
	m_psp.pszTitle = m_strCaption;
	m_psp.dwFlags |= PSP_USETITLE;
	m_timer = 0;
	// MOD: FCFG END
	ClearAllMembers();
	m_ctrlTreeOptions.SetNeoStyle();
}

CPPgRelease::~CPPgRelease()
{
}

void CPPgRelease::ClearAllMembers()
{
	m_bInitializedTreeOpts = false;
	
	m_htiReleaseTweaks = NULL;

		m_htiPartTraffic = NULL; // MOD: NPT - [NeoPartTraffic]

		// MOD: TQ - [TweakUploadQueue]
		m_htiTweakUploadQueue = NULL;
			m_htiSaveUploadQueueWaitTime = NULL; // MOD: SQ - [SaveUploadQueue]
			m_htiUseMultiQueue = NULL; // MOD: MQ - [MultiQueue]
			m_htiUseRandomQueue = NULL; // MOD: RQ - [RandomQueue]
			m_htiInfiniteQueue = NULL;
			m_htiUploadQueueOverFlow = NULL;
				m_htiQueueOverFlowDef = NULL;
				m_htiQueueOverFlowEx = NULL;
				m_htiQueueOverFlowRelease = NULL;
				m_htiQueueOverFlowCF = NULL;
			m_htiOldPrioritySystem = NULL;
		// MOD: TQ END

		// MOD: IPS - [InteligentPartSharing]
		m_htiInteligentPartSharing = NULL;
			m_htiInteligentPartSharingEnable = NULL;
			m_htiInteligentPartSharingTimer = NULL;
			m_htiMaxProzentToHide = NULL;
			m_htiHideOverAvaliblyParts = NULL;
				m_htiHideOverAvaliblyPartsDefault = NULL;
				m_htiHideOverAvaliblyPartsEnable = NULL;
				m_htiHideOverAvaliblyPartsEnableAll = NULL;
				m_htiHideOverAvaliblyPartsDisable = NULL;
				m_htiHideOverAvaliblyValue = NULL;
				m_htiHideOverAvaliblyMode = NULL;
					m_htiHideOverAvaliblyMode0 = NULL;
					m_htiHideOverAvaliblyMode1 = NULL;
					m_htiHideOverAvaliblyMode2 = NULL;
				m_htiBlockHighOverAvaliblyParts = NULL;
					m_htiBlockHighOverAvaliblyPartsDefault = NULL;
					m_htiBlockHighOverAvaliblyPartsEnable = NULL;
					m_htiBlockHighOverAvaliblyPartsEnableAll = NULL;
					m_htiBlockHighOverAvaliblyPartsDisable = NULL;
					m_htiBlockHighOverAvaliblyFactor = NULL;
			m_htiHideOverSharedParts = NULL;
				m_htiHideOverSharedPartsDefault = NULL;
				m_htiHideOverSharedPartsEnable = NULL;
				m_htiHideOverSharedPartsEnableAll = NULL;
				m_htiHideOverSharedPartsDisable = NULL;
				m_htiHideOverSharedValue = NULL;
				m_htiHideOverSharedMode = NULL;
					m_htiHideOverSharedMode0 = NULL;
					m_htiHideOverSharedMode1 = NULL;
					m_htiHideOverSharedMode2 = NULL;
				m_htiDontHideUnderAvaliblyParts = NULL;
					m_htiDontHideUnderAvaliblyPartsDefault = NULL;
					m_htiDontHideUnderAvaliblyPartsEnable = NULL;
					m_htiDontHideUnderAvaliblyPartsEnableAll = NULL;
					m_htiDontHideUnderAvaliblyPartsDisable = NULL;
					m_htiDontHideUnderAvaliblyValue = NULL;
					m_htiDontHideUnderAvaliblyMode = NULL;
						m_htiDontHideUnderAvaliblyMode0 = NULL;
						m_htiDontHideUnderAvaliblyMode1 = NULL;
						m_htiDontHideUnderAvaliblyMode2 = NULL;
				m_htiBlockHighOverSharedParts = NULL;
					m_htiBlockHighOverSharedPartsDefault = NULL;
					m_htiBlockHighOverSharedPartsEnable = NULL;
					m_htiBlockHighOverSharedPartsEnableAll = NULL;
					m_htiBlockHighOverSharedPartsDisable = NULL;
					m_htiBlockHighOverSharedFactor = NULL;
				m_htiHideOverSharedCalc = NULL;
					m_htiHideOverSharedCalcDefault = NULL;
					m_htiHideOverSharedCalcHigh = NULL;
					m_htiHideOverSharedCalcLow = NULL;
			m_htiShowAlwaysNeeded = NULL;
				m_htiShowAlwaysNeededDefault = NULL;
				m_htiShowAlwaysNeededEnable = NULL;
				m_htiShowAlwaysNeededEnableAll = NULL;
				m_htiShowAlwaysNeededDisable = NULL;
				m_htiShowAlwaysNeededValue = NULL;
			m_htiShowAlwaysIncomplete = NULL;
				m_htiShowAlwaysIncompleteDefault = NULL;
				m_htiShowAlwaysIncompleteEnable = NULL;
				m_htiShowAlwaysIncompleteEnableAll = NULL;
				m_htiShowAlwaysIncompleteDisable = NULL;
		// MOD: IPS END

}

void CPPgRelease::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_MOD_OPTS, m_ctrlTreeOptions);
	if (!m_bInitializedTreeOpts)
	{
		int iImgReleaseTweaks = 8;
		int iImgQueue = 8;
		int iImgCS = 8;
		int iImgOverflow = 8;
		int iImgIPS = 8;
		int iImgHideOA = 8;
		int iImgHideOS = 8;
		int iImgShowUA = 8;
		int iImgShowA = 8;
		int iImgShowI = 8;
		int iImgMode = 8;
		int iImgCalc = 8;
        CImageList* piml = m_ctrlTreeOptions.GetImageList(TVSIL_NORMAL);
		if (piml){
			iImgReleaseTweaks = piml->Add(CTempIconLoader(_T("RELEASETWEAKS")));
			iImgQueue = piml->Add(CTempIconLoader(_T("TWEAKQUEUE")));
			iImgCS = piml->Add(CTempIconLoader(_T("TWEAKQUEUECREDIT")));
			iImgOverflow = piml->Add(CTempIconLoader(_T("TWEAKQUEUEOVERFLOW")));
			iImgIPS = piml->Add(CTempIconLoader(_T("IPS")));
			iImgHideOA = piml->Add(CTempIconLoader(_T("HIDEOA")));
			iImgHideOS = piml->Add(CTempIconLoader(_T("HIDEOS")));
			iImgShowUA = piml->Add(CTempIconLoader(_T("SHOWUA")));
			iImgShowA = piml->Add(CTempIconLoader(_T("SHOWA")));
			iImgShowI = piml->Add(CTempIconLoader(_T("SHOWI")));
			iImgMode = piml->Add(CTempIconLoader(_T("IPSMODE")));
			iImgCalc = piml->Add(CTempIconLoader(_T("CALCS")));
		}
		
		SetTreeGroup(m_ctrlTreeOptions,m_htiReleaseTweaks,GetResString(IDS_X_MAIN_RELEASE),iImgReleaseTweaks, TVI_ROOT, GetResString(IDS_X_MAIN_RELEASE_INFO));
		// MOD: NPT - [NeoPartTraffic]
		if(!ForFile()){
			m_htiPartTraffic = m_ctrlTreeOptions.InsertCheckBox(GetResString(IDS_X_PART_TRAFFIC),m_htiReleaseTweaks,m_uPartTraffic,TRUE);
			m_ctrlTreeOptions.AddComboBox(m_htiPartTraffic,RUNTIME_CLASS(CPartTrafficStyle));
			//m_ctrlTreeOptions.SetItemSize(m_htiPartTraffic,8);
			m_ctrlTreeOptions.SetItemInfo(m_htiPartTraffic,GetResString(IDS_X_PART_TRAFFIC_INFO));
		}
		// MOD: NPT END

		if(!ForFile()){
			// MOD: TQ - [TweakUploadQueue]
			SetTreeGroup(m_ctrlTreeOptions,m_htiTweakUploadQueue,GetResString(IDS_X_TWEAK_QUEUE),iImgQueue, m_htiReleaseTweaks, GetResString(IDS_X_TWEAK_QUEUE_INFO));
				SetTreeCheck(m_ctrlTreeOptions,m_htiSaveUploadQueueWaitTime,GetResString(IDS_X_SAVE_QUEUE),m_htiTweakUploadQueue,GetResString(IDS_X_SAVE_QUEUE_INFO),FALSE,m_bSaveUploadQueueWaitTime); // MOD: SQ - [SaveUploadQueue]
				SetTreeCheck(m_ctrlTreeOptions,m_htiUseMultiQueue,GetResString(IDS_X_MULTI_QUEUE),m_htiTweakUploadQueue,GetResString(IDS_X_MULTI_QUEUE_INFO),FALSE,m_bUseMultiQueue); // MOD: MQ - [MultiQueue]
				SetTreeCheck(m_ctrlTreeOptions,m_htiUseRandomQueue,GetResString(IDS_X_RANDOM_QUEUE),m_htiTweakUploadQueue,GetResString(IDS_X_RANDOM_QUEUE_INFO),FALSE,m_bUseRandomQueue); // MOD: RQ - [RandomQueue]
				SetTreeCheck(m_ctrlTreeOptions,m_htiInfiniteQueue,GetResString(IDS_X_UNLIMITED_QUEUE),m_htiTweakUploadQueue,GetResString(IDS_X_UNLIMITED_QUEUE_INFO),FALSE,m_bInfiniteQueue);
				SetTreeGroup(m_ctrlTreeOptions,m_htiUploadQueueOverFlow,GetResString(IDS_X_OVERFLOW_QUEUE),iImgOverflow, m_htiTweakUploadQueue, GetResString(IDS_X_OVERFLOW_QUEUE_INFO));
					SetTreeCheckNumEdit(m_ctrlTreeOptions,m_htiQueueOverFlowRelease,GetResString(IDS_X_OVERFLOW_QUEUE_RELEASE), m_htiUploadQueueOverFlow,GetResString(IDS_X_OVERFLOW_QUEUE_RELEASE_INFO),TRUE, m_uQueueOverFlowRelease);
					SetTreeCheckNumEdit(m_ctrlTreeOptions,m_htiQueueOverFlowEx,GetResString(IDS_X_OVERFLOW_QUEUE_EXTENDED), m_htiUploadQueueOverFlow,GetResString(IDS_X_OVERFLOW_QUEUE_EXTENDED_INFO),TRUE, m_uQueueOverFlowEx);
					SetTreeCheckNumEdit(m_ctrlTreeOptions,m_htiQueueOverFlowDef,GetResString(IDS_X_OVERFLOW_QUEUE_DEFAULT), m_htiUploadQueueOverFlow,GetResString(IDS_X_OVERFLOW_QUEUE_DEFAULT_INFO),TRUE, m_uQueueOverFlowDef);
					SetTreeCheckNumEdit(m_ctrlTreeOptions,m_htiQueueOverFlowCF,GetResString(IDS_X_OVERFLOW_QUEUE_COMFIRND), m_htiUploadQueueOverFlow,GetResString(IDS_X_OVERFLOW_QUEUE_COMFIRND_INFO),TRUE, m_uQueueOverFlowCF);
				SetTreeCheck(m_ctrlTreeOptions,m_htiOldPrioritySystem,GetResString(IDS_X_USEOLDPRIOSYS),m_htiTweakUploadQueue,GetResString(IDS_X_USEOLDPRIOSYS_INFO),FALSE,m_bOldPrioritySystem);
			// MOD: TQ END
		}

		if(!ForFile()){
			m_ctrlTreeOptions.SetItemEnable(m_htiPartTraffic, m_uPartTraffic, TRUE, TRUE); // MOD: NPT - [NeoPartTraffic]

		// MOD: IPS - [InteligentPartSharing]
		SetTreeGroup(m_ctrlTreeOptions,m_htiInteligentPartSharing,GetResString(IDS_X_INTELIGENT_PART_SHARING),iImgIPS, m_htiReleaseTweaks, GetResString(IDS_X_INTELIGENT_PART_SHARING_INFO));
			if(!ForFile()){
				SetTreeCheck(m_ctrlTreeOptions,m_htiInteligentPartSharingEnable,GetResString(IDS_X_INTELIGENT_PART_SHARING_ENABLE),m_htiInteligentPartSharing,GetResString(IDS_X_INTELIGENT_PART_SHARING_ENABLE_INFO),FALSE,m_bInteligentPartSharing);
				SetTreeNumEdit(m_ctrlTreeOptions,m_htiInteligentPartSharingTimer,GetResString(IDS_X_INTELIGENT_PART_SHARING_INTERVAL), m_htiInteligentPartSharing,GetResString(IDS_X_INTELIGENT_PART_SHARING_INTERVAL_INFO));
			}
			SetTreeNumEdit(m_ctrlTreeOptions,m_htiMaxProzentToHide,GetResString(IDS_X_INTELIGENT_PART_SHARING_MAXIMUM), m_htiInteligentPartSharing,GetResString(IDS_X_INTELIGENT_PART_SHARING_MAXIMUM_INFO));
			// OA>
			SetTreeGroup(m_ctrlTreeOptions,m_htiHideOverAvaliblyParts,GetResString(IDS_X_HIDE_OVER_AVALIBLY),iImgHideOA, m_htiInteligentPartSharing, GetResString(IDS_X_HIDE_OVER_AVALIBLY_INFO));
				if(ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyPartsDefault,GetResString(IDS_X_IPS_HIDE_ENABLE_DEFAULT),m_htiHideOverAvaliblyParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DEFAULT_INFO),TRUE,m_iHideOverAvaliblyParts == 0);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyPartsDisable,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE),m_htiHideOverAvaliblyParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE_INFO),FALSE, m_iHideOverAvaliblyParts == 0);
				SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyPartsEnable,GetResString(ForFile() ? IDS_X_IPS_HIDE_ENABLE_ENABLE_FILE : IDS_X_IPS_HIDE_ENABLE_ENABLE),m_htiHideOverAvaliblyParts,GetResString(ForFile() ? IDS_X_IPS_HIDE_ENABLE_ENABLE_FILE_INFO : IDS_X_IPS_HIDE_ENABLE_ENABLE_INFO),ForFile(), m_iHideOverAvaliblyParts == 1);
				if(!ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyPartsEnableAll,GetResString(IDS_X_IPS_HIDE_ENABLE_ENABLE_ALL),m_htiHideOverAvaliblyParts,GetResString(IDS_X_IPS_HIDE_ENABLE_ENABLE_ALL_INFO),FALSE, m_iHideOverAvaliblyParts == 2);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyPartsDisable,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE),m_htiHideOverAvaliblyParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE_INFO),TRUE, m_iHideOverAvaliblyParts == 2);

				SetTreeNumEdit(m_ctrlTreeOptions,m_htiHideOverAvaliblyValue,GetResString(IDS_X_HIDE_OVER_AVALIBLY_VALUE), m_htiHideOverAvaliblyParts,GetResString(IDS_X_HIDE_OVER_AVALIBLY_VALUE_INFO));
				SetTreeGroup(m_ctrlTreeOptions,m_htiHideOverAvaliblyMode,GetResString(IDS_X_IPS_MODE),iImgMode, m_htiHideOverAvaliblyParts, GetResString(IDS_X_IPS_MODE_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyMode0,GetResString(IDS_X_IPS_MODE_DEFAULT),m_htiHideOverAvaliblyMode,GetResString(IDS_X_IPS_MODE_DEFAULT_INFO),TRUE,m_iHideOverAvaliblyMode == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyMode1,GetResString(IDS_X_IPS_MODE_MULTI),m_htiHideOverAvaliblyMode,GetResString(IDS_X_IPS_MODE_MULTI_INFO),ForFile(),m_iHideOverAvaliblyMode == (ForFile() ? 1 : 0));
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverAvaliblyMode2,GetResString(IDS_X_IPS_MODE_ADD),m_htiHideOverAvaliblyMode,GetResString(IDS_X_IPS_MODE_ADD_INFO),ForFile(),m_iHideOverAvaliblyMode == (ForFile() ? 2 : 1));

				SetTreeGroup(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_IPS_BLOCK_PARTS),iImgMode, m_htiHideOverAvaliblyParts, GetResString(IDS_X_IPS_BLOCK_PARTS_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyPartsDefault,GetResString(IDS_X_IPS_BLOCK_ENABLE_DEFAULT),m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DEFAULT_INFO),TRUE,m_iBlockHighOverAvaliblyParts == 0);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyPartsDisable,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE),m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE_INFO),FALSE, m_iBlockHighOverAvaliblyParts == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyPartsEnable,GetResString(ForFile() ? IDS_X_IPS_BLOCK_ENABLE_ENABLE_FILE : IDS_X_IPS_BLOCK_ENABLE_ENABLE),m_htiBlockHighOverAvaliblyParts,GetResString(ForFile() ? IDS_X_IPS_BLOCK_ENABLE_ENABLE_FILE_INFO : IDS_X_IPS_BLOCK_ENABLE_ENABLE_INFO),ForFile(), m_iBlockHighOverAvaliblyParts == 1);
					if(!ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyPartsEnableAll,GetResString(IDS_X_IPS_BLOCK_ENABLE_ENABLE_ALL),m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_ENABLE_ALL_INFO),FALSE, m_iBlockHighOverAvaliblyParts == 2);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyPartsDisable,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE),m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE_INFO),TRUE, m_iBlockHighOverAvaliblyParts == 2);

					SetTreeNumEdit(m_ctrlTreeOptions,m_htiBlockHighOverAvaliblyFactor,GetResString(IDS_X_BLOCK_OVER_AVALIBLY_VALUE), m_htiBlockHighOverAvaliblyParts,GetResString(IDS_X_BLOCK_OVER_AVALIBLY_VALUE_INFO));

			// <OA
			// OS>
			SetTreeGroup(m_ctrlTreeOptions,m_htiHideOverSharedParts,GetResString(IDS_X_HIDE_OVER_SHARED),iImgHideOS, m_htiInteligentPartSharing, GetResString(IDS_X_HIDE_OVER_SHARED_INFO));
				if(ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedPartsDefault,GetResString(IDS_X_IPS_HIDE_ENABLE_DEFAULT),m_htiHideOverSharedParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DEFAULT_INFO),TRUE,m_iHideOverSharedParts == 0);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedPartsDisable,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE),m_htiHideOverSharedParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE_INFO),FALSE, m_iHideOverSharedParts == 0);
				SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedPartsEnable,GetResString(ForFile() ? IDS_X_IPS_HIDE_ENABLE_ENABLE_FILE : IDS_X_IPS_HIDE_ENABLE_ENABLE),m_htiHideOverSharedParts,GetResString(ForFile() ? IDS_X_IPS_HIDE_ENABLE_ENABLE_FILE_INFO : IDS_X_IPS_HIDE_ENABLE_ENABLE_INFO),ForFile(), m_iHideOverSharedParts == 1);
				if(!ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedPartsEnableAll,GetResString(IDS_X_IPS_HIDE_ENABLE_ENABLE_ALL),m_htiHideOverSharedParts,GetResString(IDS_X_IPS_HIDE_ENABLE_ENABLE_ALL_INFO),FALSE, m_iHideOverSharedParts == 2);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedPartsDisable,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE),m_htiHideOverSharedParts,GetResString(IDS_X_IPS_HIDE_ENABLE_DISABLE_INFO),TRUE, m_iHideOverSharedParts == 2);

				SetTreeNumEdit(m_ctrlTreeOptions,m_htiHideOverSharedValue,GetResString(IDS_X_HIDE_OVER_SHARED_VALUE), m_htiHideOverSharedParts,GetResString(IDS_X_HIDE_OVER_SHARED_VALUE_INFO));
				SetTreeGroup(m_ctrlTreeOptions,m_htiHideOverSharedMode,GetResString(IDS_X_IPS_MODE),iImgMode, m_htiHideOverSharedParts, GetResString(IDS_X_IPS_MODE_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedMode0,GetResString(IDS_X_IPS_MODE_DEFAULT),m_htiHideOverSharedMode,GetResString(IDS_X_IPS_MODE_DEFAULT_INFO),TRUE,m_iHideOverSharedMode == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedMode1,GetResString(IDS_X_IPS_MODE_MULTI),m_htiHideOverSharedMode,GetResString(IDS_X_IPS_MODE_MULTI_INFO),ForFile(),m_iHideOverSharedMode == (ForFile() ? 1 : 0));
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedMode2,GetResString(IDS_X_IPS_MODE_ADD),m_htiHideOverSharedMode,GetResString(IDS_X_IPS_MODE_ADD_INFO),ForFile(),m_iHideOverSharedMode == (ForFile() ? 2 : 1));

				// UA>
				SetTreeGroup(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_SHOW_UNDER_AVALIBLY),iImgShowUA, m_htiHideOverSharedParts, GetResString(IDS_X_SHOW_UNDER_AVALIBLY_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsDefault,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT),m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT_INFO),TRUE,m_iDontHideUnderAvaliblyParts == 0);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),FALSE, m_iDontHideUnderAvaliblyParts == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsEnable,GetResString(ForFile() ? IDS_X_IPS_SHOW_ENABLE_ENABLE_FILE : IDS_X_IPS_SHOW_ENABLE_ENABLE),m_htiDontHideUnderAvaliblyParts,GetResString(ForFile() ? IDS_X_IPS_SHOW_ENABLE_ENABLE_FILE_INFO : IDS_X_IPS_SHOW_ENABLE_ENABLE_INFO),ForFile(), m_iDontHideUnderAvaliblyParts == 1);
					if(!ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsEnableAll,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL),m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL_INFO),FALSE, m_iDontHideUnderAvaliblyParts == 2);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),TRUE, m_iDontHideUnderAvaliblyParts == 2);

					SetTreeNumEdit(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyValue,GetResString(IDS_X_SHOW_UNDER_AVALIBLY_VALUE), m_htiDontHideUnderAvaliblyParts,GetResString(IDS_X_SHOW_UNDER_AVALIBLY_VALUE_INFO));
					SetTreeGroup(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyMode,GetResString(IDS_X_IPS_MODE),iImgMode, m_htiDontHideUnderAvaliblyParts, GetResString(IDS_X_IPS_MODE_INFO));

						if(ForFile())
							SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyMode0,GetResString(IDS_X_IPS_MODE_DEFAULT),m_htiDontHideUnderAvaliblyMode,GetResString(IDS_X_IPS_MODE_DEFAULT_INFO),TRUE,m_iDontHideUnderAvaliblyMode == 0);
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyMode1,GetResString(IDS_X_IPS_MODE_MULTI),m_htiDontHideUnderAvaliblyMode,GetResString(IDS_X_IPS_MODE_MULTI_INFO),ForFile(),m_iDontHideUnderAvaliblyMode == (ForFile() ? 1 : 0));
						SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyMode2,GetResString(IDS_X_IPS_MODE_ADD),m_htiDontHideUnderAvaliblyMode,GetResString(IDS_X_IPS_MODE_ADD_INFO),ForFile(),m_iDontHideUnderAvaliblyMode == (ForFile() ? 2 : 1));
				// <UA

				SetTreeGroup(m_ctrlTreeOptions,m_htiBlockHighOverSharedParts,GetResString(IDS_X_IPS_BLOCK_PARTS),iImgMode, m_htiHideOverSharedParts, GetResString(IDS_X_IPS_BLOCK_PARTS_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverSharedPartsDefault,GetResString(IDS_X_IPS_BLOCK_ENABLE_DEFAULT),m_htiBlockHighOverSharedParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DEFAULT_INFO),TRUE,m_iBlockHighOverSharedParts == 0);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverSharedPartsDisable,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE),m_htiBlockHighOverSharedParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE_INFO),FALSE, m_iBlockHighOverSharedParts == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverSharedPartsEnable,GetResString(ForFile() ? IDS_X_IPS_BLOCK_ENABLE_ENABLE_FILE : IDS_X_IPS_BLOCK_ENABLE_ENABLE),m_htiBlockHighOverSharedParts,GetResString(ForFile() ? IDS_X_IPS_BLOCK_ENABLE_ENABLE_FILE_INFO : IDS_X_IPS_BLOCK_ENABLE_ENABLE_INFO),ForFile(), m_iBlockHighOverSharedParts == 1);
					if(!ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverSharedPartsEnableAll,GetResString(IDS_X_IPS_BLOCK_ENABLE_ENABLE_ALL),m_htiBlockHighOverSharedParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_ENABLE_ALL_INFO),FALSE, m_iBlockHighOverSharedParts == 2);
					else
						SetTreeRadio(m_ctrlTreeOptions,m_htiBlockHighOverSharedPartsDisable,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE),m_htiBlockHighOverSharedParts,GetResString(IDS_X_IPS_BLOCK_ENABLE_DISABLE_INFO),TRUE, m_iBlockHighOverSharedParts == 2);

					SetTreeNumEdit(m_ctrlTreeOptions,m_htiBlockHighOverSharedFactor,GetResString(IDS_X_BLOCK_OVER_SHARE_VALUE), m_htiBlockHighOverSharedParts,GetResString(IDS_X_BLOCK_OVER_SHARE_VALUE_INFO));

				SetTreeGroup(m_ctrlTreeOptions,m_htiHideOverSharedCalc,GetResString(IDS_X_IPS_BLOCK_PARTS),iImgCalc, m_htiHideOverSharedParts, GetResString(IDS_X_IPS_BLOCK_PARTS_INFO));
					if(ForFile())
						SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedCalcDefault,GetResString(IDS_X_IPS_OS_CALC_DEFAULT),m_htiHideOverSharedCalc,GetResString(IDS_X_IPS_OS_CALC_DEFAULT_INFO),TRUE,m_iHideOverSharedCalc == 0);
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedCalcHigh,GetResString(IDS_X_IPS_OS_CALC_HIGH),m_htiHideOverSharedCalc,GetResString(IDS_X_IPS_OS_CALC_HIGH_INFO),ForFile(),m_iHideOverSharedCalc == (ForFile() ? 1 : 0));
					SetTreeRadio(m_ctrlTreeOptions,m_htiHideOverSharedCalcLow,GetResString(IDS_X_IPS_OS_CALC_LOW),m_htiHideOverSharedCalc,GetResString(IDS_X_IPS_OS_CALC_LOW_INFO),ForFile(),m_iHideOverSharedCalc == (ForFile() ? 2 : 1));
			// <OS

			SetTreeGroup(m_ctrlTreeOptions,m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_ALWAYS_SHOW_PARTS),iImgShowA, m_htiInteligentPartSharing, GetResString(IDS_X_IPS_ALWAYS_SHOW_PARTS_INFO));
				if(ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysNeededDefault,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT),m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT_INFO),TRUE,m_iShowAlwaysNeeded == 0);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),FALSE, m_iShowAlwaysNeeded == 0);
				SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysNeededEnable,GetResString(ForFile() ? IDS_X_IPS_ALWAYS_SHOW_PARTS_FILE : IDS_X_IPS_SHOW_ENABLE_ENABLE),m_htiShowAlwaysNeeded,GetResString(ForFile() ? IDS_X_IPS_ALWAYS_SHOW_PARTS_FILE_INFO : IDS_X_IPS_SHOW_ENABLE_ENABLE_INFO),ForFile(), m_iShowAlwaysNeeded == 1);
				if(!ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysNeededEnableAll,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL),m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL_INFO),FALSE, m_iShowAlwaysNeeded == 2);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysNeededDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),TRUE, m_iShowAlwaysNeeded == 2);

				SetTreeNumEdit(m_ctrlTreeOptions,m_htiShowAlwaysNeededValue,GetResString(IDS_X_IPS_ALWAYS_SHOW_PARTS_VALUE), m_htiShowAlwaysNeeded,GetResString(IDS_X_IPS_ALWAYS_SHOW_PARTS_VALUE_INFO));

			SetTreeGroup(m_ctrlTreeOptions,m_htiShowAlwaysIncomplete,GetResString(IDS_X_IPS_ALWAYS_SHOW_INCOMPLETE_PARTS),iImgShowI, m_htiInteligentPartSharing, GetResString(IDS_X_IPS_ALWAYS_SHOW_INCOMPLETE_PARTS_INFO));
				if(ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysIncompleteDefault,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT),m_htiShowAlwaysIncomplete,GetResString(IDS_X_IPS_SHOW_ENABLE_DEFAULT_INFO),TRUE,m_iShowAlwaysIncomplete == 0);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiDontHideUnderAvaliblyPartsDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiShowAlwaysIncomplete,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),FALSE, m_iShowAlwaysIncomplete == 0);
				SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysIncompleteEnable,GetResString(ForFile() ? IDS_X_IPS_INCOMPLETE_SHOW_PARTS_FILE : IDS_X_IPS_SHOW_ENABLE_ENABLE),m_htiShowAlwaysIncomplete,GetResString(ForFile() ? IDS_X_IPS_INCOMPLETE_SHOW_PARTS_FILE_INFO : IDS_X_IPS_SHOW_ENABLE_ENABLE_INFO),ForFile(), m_iShowAlwaysIncomplete == 1);
				if(!ForFile())
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysIncompleteEnableAll,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL),m_htiShowAlwaysIncomplete,GetResString(IDS_X_IPS_SHOW_ENABLE_ENABLE_ALL_INFO),FALSE, m_iShowAlwaysIncomplete == 2);
				else
					SetTreeRadio(m_ctrlTreeOptions,m_htiShowAlwaysIncompleteDisable,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE),m_htiShowAlwaysIncomplete,GetResString(IDS_X_IPS_SHOW_ENABLE_DISABLE_INFO),TRUE, m_iShowAlwaysIncomplete == 2);
		// MOD: IPS END

			// MOD: TQ - [TweakUploadQueue]
			m_ctrlTreeOptions.SetItemEnable(m_htiOldPrioritySystem, m_bUseMultiQueue ? FALSE : TRUE); // Munti Queue have his own priority score
			m_ctrlTreeOptions.SetGroupEnable(m_htiUploadQueueOverFlow, m_bInfiniteQueue ? FALSE : TRUE);

			m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowRelease, m_uQueueOverFlowRelease == 2, TRUE, TRUE);
			m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowEx, m_uQueueOverFlowEx == 2, TRUE, TRUE);
			m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowDef, m_uQueueOverFlowDef == 2, TRUE, TRUE);
			m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowCF, m_uQueueOverFlowCF == 2, TRUE, TRUE);
			// MOD: TQ END
		}

		m_bInitializedTreeOpts = true;
		m_ctrlTreeOptions.Expand(m_htiReleaseTweaks, TVE_EXPAND);
		m_ctrlTreeOptions.Expand(m_htiTweakUploadQueue, TVE_EXPAND);
		//m_ctrlTreeOptions.Expand(m_htiUploadQueueOverFlow, TVE_EXPAND);
		m_ctrlTreeOptions.Expand(m_htiInteligentPartSharing, TVE_EXPAND);

	}

	// MOD: NPT - [NeoPartTraffic]
	if(!ForFile()){
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiPartTraffic, m_uPartTraffic);
		
		if (pDX->m_bSaveAndValidate){
			CString sText;
			sText = m_ctrlTreeOptions.GetComboText(m_htiPartTraffic);
			if(sText == PT_EXPERT)
				m_iPartTrafficColor = 0;
			else if(sText == PT_NORMAL)
				m_iPartTrafficColor = 1;
			else if(sText == PT_BLUE)
				m_iPartTrafficColor = 2;
			else if(sText == PT_RED)
				m_iPartTrafficColor = 3;
		}else{
			CString sText;
			switch(m_iPartTrafficColor){
			case 0: sText = PT_EXPERT; break;
			case 1: sText = PT_NORMAL; break;
			case 2: sText = PT_BLUE; break;
			case 3: sText = PT_RED; break;
			}
			m_ctrlTreeOptions.SetComboText(m_htiPartTraffic, sText);
		}
	}
	// MOD: NPT END

	if(!ForFile()){
		// MOD: TQ - [TweakUploadQueue]
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiSaveUploadQueueWaitTime, m_bSaveUploadQueueWaitTime); // MOD: SQ - [SaveUploadQueue]
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiUseMultiQueue, m_bUseMultiQueue); // MOD: MQ - [MultiQueue]
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiUseRandomQueue, m_bUseRandomQueue); // MOD: RQ - [RandomQueue]
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiInfiniteQueue, m_bInfiniteQueue);

			DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiQueueOverFlowRelease, m_uQueueOverFlowRelease);
			DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiQueueOverFlowRelease, m_iQueueOverFlowRelease);

			DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiQueueOverFlowEx, m_uQueueOverFlowEx);
			DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiQueueOverFlowEx, m_iQueueOverFlowEx);

			DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiQueueOverFlowDef, m_uQueueOverFlowDef);
			DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiQueueOverFlowDef, m_iQueueOverFlowDef);

			DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiQueueOverFlowCF, m_uQueueOverFlowCF);
			DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiQueueOverFlowCF, m_iQueueOverFlowCF);

		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiOldPrioritySystem, m_bOldPrioritySystem);
		// MOD: TQ END

	}


	// MOD: IPS - [InteligentPartSharing]
	if(!ForFile()){
		DDX_TreeCheck(pDX, IDC_MOD_OPTS, m_htiInteligentPartSharingEnable, m_bInteligentPartSharing);
		DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiInteligentPartSharingTimer, m_iInteligentPartSharingTimer);
	}
		DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiMaxProzentToHide, m_iMaxProzentToHide);
		// OA>
		DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiHideOverAvaliblyParts, m_iHideOverAvaliblyParts);
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiHideOverAvaliblyMode, m_iHideOverAvaliblyMode);
			DDX_TreeEditE0f(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiHideOverAvaliblyValue, m_fHideOverAvaliblyValue);
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiBlockHighOverAvaliblyParts, m_iBlockHighOverAvaliblyParts);
				DDX_TreeEditE0f(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiBlockHighOverAvaliblyFactor, m_fBlockHighOverAvaliblyFactor);
		// <OA
		// OS>
		DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiHideOverSharedParts, m_iHideOverSharedParts);
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiHideOverSharedMode, m_iHideOverSharedMode);
			DDX_TreeEditE0f(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiHideOverSharedValue, m_fHideOverSharedValue);
			// UA>
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiDontHideUnderAvaliblyParts, m_iDontHideUnderAvaliblyParts);
				DDX_TreeEditE0f(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiDontHideUnderAvaliblyValue, m_fDontHideUnderAvaliblyValue);
				DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiDontHideUnderAvaliblyMode, m_iDontHideUnderAvaliblyMode);
			// <UA
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiBlockHighOverSharedParts, m_iBlockHighOverSharedParts);
				DDX_TreeEditE0f(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiBlockHighOverSharedFactor, m_fBlockHighOverSharedFactor);
			DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiHideOverSharedCalc, m_iHideOverSharedCalc);
		// <OS
		DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiShowAlwaysNeeded, m_iShowAlwaysNeeded);
			DDX_TreeEditE0(&m_ctrlTreeOptions, pDX, IDC_MOD_OPTS, m_htiShowAlwaysNeededValue, m_iShowAlwaysParts);
		DDX_TreeRadio(pDX, IDC_MOD_OPTS, m_htiShowAlwaysIncomplete, m_iShowAlwaysIncomplete);
	// MOD: IPS END

}

BOOL CPPgRelease::OnInitDialog()
{
	if(!m_bFilePreferences)
		LoadSettings();
	else
		RefreshData();

	CPropertyPage::OnInitDialog();
	InitWindowStyles(this);

	// MOD: FCFG - [FileConfiguration]
	// no need to explicitly call 'RefreshData' here, 'OnSetActive' will be called right after 'OnInitDialog'

	// start time for calling 'RefreshData'
	if(m_bFilePreferences)
		VERIFY( (m_timer = SetTimer(301, 5000, 0)) != NULL );
	// MOD: FCFG END

	return TRUE;  // return TRUE unless you set the focus to a control
				  // EXCEPTION: OCX Property Pages should return FALSE
}

BOOL CPPgRelease::OnApply()
{
	// if prop page is closed by pressing ENTER we have to explicitly commit any possibly pending
	// data from an open edit control
	m_ctrlTreeOptions.HandleChildControlLosingFocus();

	if (!UpdateData())
		return FALSE;

	if(!m_bFilePreferences){
		/*
		* Globale Einstellungen Speichern
		*/

		// MOD: NPT - [NeoPartTraffic]
		UINT OldNPTState = thePrefs.m_uPartTraffic; 
		int OldColor = thePrefs.m_iPartTrafficColor;
		thePrefs.m_uPartTraffic = m_uPartTraffic; 
		thePrefs.m_iPartTrafficColor = m_iPartTrafficColor; 
		if(OldColor != m_iPartTrafficColor)
			theApp.emuledlg->sharedfileswnd->sharedfilesctrl.SetColoring(m_iPartTrafficColor);
		if(OldNPTState != thePrefs.m_uPartTraffic && thePrefs.m_uPartTraffic
		 && !theApp.knownfiles->IsPartTrafficLoaded())
			theApp.knownfiles->LoadPartTraffic();
		// MOD: NPT END

		// MOD: TQ - [TweakUploadQueue]
		thePrefs.m_bSaveUploadQueueWaitTime = m_bSaveUploadQueueWaitTime; // MOD: SQ - [SaveUploadQueue]
		thePrefs.m_bUseMultiQueue = m_bUseMultiQueue; // MOD: MQ - [MultiQueue]
		thePrefs.m_bUseRandomQueue = m_bUseRandomQueue; // MOD: RQ - [RandomQueue]

		thePrefs.m_bInfiniteQueue = m_bInfiniteQueue;

		thePrefs.m_uQueueOverFlowRelease = m_uQueueOverFlowRelease;
		if(m_iQueueOverFlowRelease) thePrefs.m_iQueueOverFlowRelease = m_iQueueOverFlowRelease;

		thePrefs.m_uQueueOverFlowEx = m_uQueueOverFlowEx;
		if(m_iQueueOverFlowEx) thePrefs.m_iQueueOverFlowEx = m_iQueueOverFlowEx;

		thePrefs.m_uQueueOverFlowDef = m_uQueueOverFlowDef;
		if(m_iQueueOverFlowDef) thePrefs.m_iQueueOverFlowDef = m_iQueueOverFlowDef;

		thePrefs.m_uQueueOverFlowCF = m_uQueueOverFlowCF;
		if(m_iQueueOverFlowCF) thePrefs.m_iQueueOverFlowCF = m_iQueueOverFlowCF;

		thePrefs.m_bOldPrioritySystem = m_bOldPrioritySystem;
		// MOD: TQ END

		// MOD: IPS - [InteligentPartSharing]
		thePrefs.m_bInteligentPartSharing = m_bInteligentPartSharing;
		if(m_iInteligentPartSharingTimer) thePrefs.m_iInteligentPartSharingTimer = m_iInteligentPartSharingTimer;
		if(m_iMaxProzentToHide) thePrefs.m_iMaxProzentToHide = m_iMaxProzentToHide;

		thePrefs.m_iHideOverAvaliblyParts = m_iHideOverAvaliblyParts;
		thePrefs.m_iHideOverAvaliblyMode = m_iHideOverAvaliblyMode;
		if(m_fHideOverAvaliblyValue) thePrefs.m_fHideOverAvaliblyValue = m_fHideOverAvaliblyValue;
		thePrefs.m_iHideOverAvaliblyCatch = m_iHideOverAvaliblyCatch;

		thePrefs.m_iHideOverSharedParts = m_iHideOverSharedParts;
		thePrefs.m_iHideOverSharedMode = m_iHideOverSharedMode;
		if(m_fHideOverSharedValue) thePrefs.m_fHideOverSharedValue = m_fHideOverSharedValue;
		thePrefs.m_iHideOverSharedCalc = m_iHideOverSharedCalc;
		
		thePrefs.m_iDontHideUnderAvaliblyParts = m_iDontHideUnderAvaliblyParts;
		thePrefs.m_iDontHideUnderAvaliblyMode = m_iDontHideUnderAvaliblyMode;
		if(m_fDontHideUnderAvaliblyValue) thePrefs.m_fDontHideUnderAvaliblyValue = m_fDontHideUnderAvaliblyValue;

		thePrefs.m_iBlockHighOverAvaliblyParts = m_iBlockHighOverAvaliblyParts;
		if(m_fBlockHighOverAvaliblyFactor) thePrefs.m_fBlockHighOverAvaliblyFactor = m_fBlockHighOverAvaliblyFactor;

		thePrefs.m_iBlockHighOverSharedParts = m_iBlockHighOverSharedParts;
		if(m_fBlockHighOverSharedFactor) thePrefs.m_fBlockHighOverSharedFactor = m_fBlockHighOverSharedFactor;

		thePrefs.m_iShowAlwaysNeeded = m_iShowAlwaysNeeded;
		if(m_iShowAlwaysParts) thePrefs.m_iShowAlwaysParts = m_iShowAlwaysParts;
		thePrefs.m_iShowAlwaysIncomplete = m_iShowAlwaysIncomplete;

		// MOD: IPS END

		thePrefs.CheckSionPreferences();
		LoadSettings();
	}else{
		/*
		* Datei Einstellungen Speichern
		*/

		// MOD: FCFG - [FileConfiguration]
		CKnownFile* file;
		for (int i = 0; i < m_paFiles->GetSize(); i++)
		{
			file = STATIC_DOWNCAST(CKnownFile, (*m_paFiles)[i]);


			// MOD: IPS - [InteligentPartSharing]
			if(m_iMaxProzentToHide) file->KnownPrefs.m_iMaxProzentToHide = (m_iMaxProzentToHide != thePrefs.GetMaxProzentToHide()) ? m_iMaxProzentToHide : 0;

			if(m_iHideOverAvaliblyParts != -1) file->KnownPrefs.m_iHideOverAvaliblyParts = m_iHideOverAvaliblyParts;
			if(m_iHideOverAvaliblyMode != -1) file->KnownPrefs.m_iHideOverAvaliblyMode = m_iHideOverAvaliblyMode;
			if(m_fHideOverAvaliblyValue) file->KnownPrefs.m_fHideOverAvaliblyValue = (m_fHideOverAvaliblyValue != thePrefs.GetHideOverAvaliblyValue()) ? m_fHideOverAvaliblyValue : 0;
			if(m_iHideOverAvaliblyCatch != -1) file->KnownPrefs.m_iHideOverAvaliblyCatch = m_iHideOverAvaliblyCatch;

			if(m_iHideOverSharedParts != -1) file->KnownPrefs.m_iHideOverSharedParts = m_iHideOverSharedParts;
			if(m_iHideOverSharedMode != -1) file->KnownPrefs.m_iHideOverSharedMode = m_iHideOverSharedMode;
			if(m_fHideOverSharedValue) file->KnownPrefs.m_fHideOverSharedValue = (m_fHideOverSharedValue != thePrefs.GetHideOverSharedValue()) ? m_fHideOverSharedValue : 0;
			if(m_iHideOverSharedCalc != -1) file->KnownPrefs.m_iHideOverSharedCalc = m_iHideOverSharedCalc;
			
			if(m_iDontHideUnderAvaliblyParts != -1) file->KnownPrefs.m_iDontHideUnderAvaliblyParts = m_iDontHideUnderAvaliblyParts;
			if(m_iDontHideUnderAvaliblyMode != -1) 	file->KnownPrefs.m_iDontHideUnderAvaliblyMode = m_iDontHideUnderAvaliblyMode;
			if(m_fDontHideUnderAvaliblyValue) file->KnownPrefs.m_fDontHideUnderAvaliblyValue = (m_fDontHideUnderAvaliblyValue != thePrefs.GetDontHideUnderAvaliblyValue()) ? m_fDontHideUnderAvaliblyValue : 0;

			if(m_iBlockHighOverAvaliblyParts != -1) file->KnownPrefs.m_iBlockHighOverAvaliblyParts = m_iBlockHighOverAvaliblyParts;
			if(m_fBlockHighOverAvaliblyFactor) file->KnownPrefs.m_fBlockHighOverAvaliblyFactor = (m_fBlockHighOverAvaliblyFactor != thePrefs.GetBlockHighOverAvaliblyFactor()) ? m_fBlockHighOverAvaliblyFactor : 0;

			if(m_iBlockHighOverSharedParts != -1) file->KnownPrefs.m_iBlockHighOverSharedParts = m_iBlockHighOverSharedParts;
			if(m_fBlockHighOverSharedFactor) file->KnownPrefs.m_fBlockHighOverSharedFactor = (m_fBlockHighOverSharedFactor != thePrefs.GetBlockHighOverSharedFactor()) ? m_fBlockHighOverSharedFactor : 0;

			if(m_iShowAlwaysNeeded != -1) file->KnownPrefs.m_iShowAlwaysNeeded = m_iShowAlwaysNeeded;
			if(m_iShowAlwaysParts) file->KnownPrefs.m_iShowAlwaysParts = (m_iShowAlwaysParts != thePrefs.GetShowAlwaysParts()) ? m_iShowAlwaysParts : 0;

			if(m_iShowAlwaysIncomplete != -1) file->KnownPrefs.m_iShowAlwaysIncomplete = m_iShowAlwaysIncomplete;
			// MOD: IPS END

			file->KnownPrefs.CheckTweaks();
		}

		RefreshData();
		// MOD: FCFG END
	}
	

	SetModified(FALSE);
	return CPropertyPage::OnApply();
}

void CPPgRelease::LoadSettings()
{
	/*
	* Globale Einstellungen Laden
	*/

	m_uPartTraffic = thePrefs.m_uPartTraffic; // MOD: NPT - [NeoPartTraffic]
	m_iPartTrafficColor = thePrefs.m_iPartTrafficColor; // MOD: NPT - [NeoPartTraffic]

	// MOD: TQ - [TweakUploadQueue]
	m_bSaveUploadQueueWaitTime = thePrefs.m_bSaveUploadQueueWaitTime; // MOD: SQ - [SaveUploadQueue]
	m_bUseMultiQueue = thePrefs.m_bUseMultiQueue; // MOD: MQ - [MultiQueue]
	m_bUseRandomQueue = thePrefs.m_bUseRandomQueue; // MOD: RQ - [RandomQueue]

	m_bInfiniteQueue = thePrefs.m_bInfiniteQueue;

	m_uQueueOverFlowRelease = thePrefs.m_uQueueOverFlowRelease;
	m_iQueueOverFlowRelease = thePrefs.m_iQueueOverFlowRelease;

	m_uQueueOverFlowEx = thePrefs.m_uQueueOverFlowEx;
	m_iQueueOverFlowEx = thePrefs.m_iQueueOverFlowEx;

	m_uQueueOverFlowDef = thePrefs.m_uQueueOverFlowDef;
	m_iQueueOverFlowDef = thePrefs.m_iQueueOverFlowDef;

	m_uQueueOverFlowCF = thePrefs.m_uQueueOverFlowCF;
	m_iQueueOverFlowCF = thePrefs.m_iQueueOverFlowCF;

	m_bOldPrioritySystem = thePrefs.m_bOldPrioritySystem;
	// MOD: TQ END

	// MOD: IPS - [InteligentPartSharing]
	m_bInteligentPartSharing = thePrefs.m_bInteligentPartSharing;
	m_iInteligentPartSharingTimer = thePrefs.m_iInteligentPartSharingTimer;
	m_iMaxProzentToHide = thePrefs.m_iMaxProzentToHide;

	m_iHideOverAvaliblyParts = thePrefs.m_iHideOverAvaliblyParts;
	m_iHideOverAvaliblyMode = thePrefs.m_iHideOverAvaliblyMode;
	m_fHideOverAvaliblyValue = thePrefs.m_fHideOverAvaliblyValue;
	m_iHideOverAvaliblyCatch = thePrefs.m_iHideOverAvaliblyCatch;

	m_iHideOverSharedParts = thePrefs.m_iHideOverSharedParts;
	m_iHideOverSharedMode = thePrefs.m_iHideOverSharedMode;
	m_fHideOverSharedValue = thePrefs.m_fHideOverSharedValue;
	m_iHideOverSharedCalc = thePrefs.m_iHideOverSharedCalc;
	
	m_iDontHideUnderAvaliblyParts = thePrefs.m_iDontHideUnderAvaliblyParts;
	m_iDontHideUnderAvaliblyMode = thePrefs.m_iDontHideUnderAvaliblyMode;
	m_fDontHideUnderAvaliblyValue = thePrefs.m_fDontHideUnderAvaliblyValue;

	m_iBlockHighOverAvaliblyParts = thePrefs.m_iBlockHighOverAvaliblyParts;
	m_fBlockHighOverAvaliblyFactor = thePrefs.m_fBlockHighOverAvaliblyFactor;

	m_iBlockHighOverSharedParts = thePrefs.m_iBlockHighOverSharedParts;
	m_fBlockHighOverSharedFactor = thePrefs.m_fBlockHighOverSharedFactor;

	m_iShowAlwaysNeeded = thePrefs.m_iShowAlwaysNeeded;
	m_iShowAlwaysParts = thePrefs.m_iShowAlwaysParts;

	m_iShowAlwaysIncomplete = thePrefs.m_iShowAlwaysIncomplete;
	// MOD: IPS END

}

// MOD: FCFG - [FileConfiguration]
void CPPgRelease::RefreshData()
{
	/*
	* Datei Einstellungen Laden
	*/

	const CKnownFile* file = STATIC_DOWNCAST(CKnownFile, (*m_paFiles)[0]);


	// MOD: IPS - [InteligentPartSharing]
	m_iMaxProzentToHide = file->KnownPrefs.m_iMaxProzentToHide;

	m_iHideOverAvaliblyParts = file->KnownPrefs.m_iHideOverAvaliblyParts;
	m_iHideOverAvaliblyMode = file->KnownPrefs.m_iHideOverAvaliblyMode;
	m_fHideOverAvaliblyValue = file->KnownPrefs.m_fHideOverAvaliblyValue;
	m_iHideOverAvaliblyCatch = file->KnownPrefs.m_iHideOverAvaliblyCatch;

	m_iHideOverSharedParts = file->KnownPrefs.m_iHideOverSharedParts;
	m_iHideOverSharedMode = file->KnownPrefs.m_iHideOverSharedMode;
	m_fHideOverSharedValue = file->KnownPrefs.m_fHideOverSharedValue;
	m_iHideOverSharedCalc = file->KnownPrefs.m_iHideOverSharedCalc;
	
	m_iDontHideUnderAvaliblyParts = file->KnownPrefs.m_iDontHideUnderAvaliblyParts;
	m_iDontHideUnderAvaliblyMode = file->KnownPrefs.m_iDontHideUnderAvaliblyMode;
	m_fDontHideUnderAvaliblyValue = file->KnownPrefs.m_fDontHideUnderAvaliblyValue;

	m_iBlockHighOverAvaliblyParts = file->KnownPrefs.m_iBlockHighOverAvaliblyParts;
	m_fBlockHighOverAvaliblyFactor = file->KnownPrefs.m_fBlockHighOverAvaliblyFactor;

	m_iBlockHighOverSharedParts = file->KnownPrefs.m_iBlockHighOverSharedParts;
	m_fBlockHighOverSharedFactor = file->KnownPrefs.m_fBlockHighOverSharedFactor;

	m_iShowAlwaysNeeded = file->KnownPrefs.m_iShowAlwaysNeeded;
	m_iShowAlwaysParts = file->KnownPrefs.m_iShowAlwaysParts;

	m_iShowAlwaysIncomplete = file->KnownPrefs.m_iShowAlwaysIncomplete;
	// MOD: IPS END

	for (int i = 1; i < m_paFiles->GetSize(); i++)
	{
		file = STATIC_DOWNCAST(CKnownFile, (*m_paFiles)[i]);

		// MOD: IPS - [InteligentPartSharing]
		if (m_iMaxProzentToHide != file->KnownPrefs.m_iMaxProzentToHide) m_iMaxProzentToHide = UN_INT;

		if (m_iHideOverAvaliblyParts != file->KnownPrefs.m_iHideOverAvaliblyParts) m_iHideOverAvaliblyParts = -1;
		if (m_iHideOverAvaliblyMode != file->KnownPrefs.m_iHideOverAvaliblyMode) m_iHideOverAvaliblyMode = -1;
		if (m_fHideOverAvaliblyValue != file->KnownPrefs.m_fHideOverAvaliblyValue) m_fHideOverAvaliblyValue = UN_FLOAT;
		if (m_iHideOverAvaliblyCatch != file->KnownPrefs.m_iHideOverAvaliblyCatch) m_iHideOverAvaliblyCatch = -1;

		if (m_iHideOverSharedParts != file->KnownPrefs.m_iHideOverSharedParts) m_iHideOverSharedParts = -1;
		if (m_iHideOverSharedMode != file->KnownPrefs.m_iHideOverSharedMode) m_iHideOverSharedMode = -1;
		if (m_fHideOverSharedValue != file->KnownPrefs.m_fHideOverSharedValue) m_fHideOverSharedValue = UN_FLOAT;
		if (m_iHideOverSharedCalc != file->KnownPrefs.m_iHideOverSharedCalc) m_iHideOverSharedCalc = -1;
		
		if (m_iDontHideUnderAvaliblyParts != file->KnownPrefs.m_iDontHideUnderAvaliblyParts) m_iDontHideUnderAvaliblyParts = -1;
		if (m_iDontHideUnderAvaliblyMode != file->KnownPrefs.m_iDontHideUnderAvaliblyMode) m_iDontHideUnderAvaliblyMode = -1;
		if (m_fDontHideUnderAvaliblyValue != file->KnownPrefs.m_fDontHideUnderAvaliblyValue) m_fDontHideUnderAvaliblyValue = UN_FLOAT;

		if (m_iBlockHighOverAvaliblyParts != file->KnownPrefs.m_iBlockHighOverAvaliblyParts) m_iBlockHighOverAvaliblyParts = -1;
		if (m_fBlockHighOverAvaliblyFactor != file->KnownPrefs.m_fBlockHighOverAvaliblyFactor) m_fBlockHighOverAvaliblyFactor = UN_FLOAT;

		if (m_iBlockHighOverSharedParts != file->KnownPrefs.m_iBlockHighOverSharedParts) m_iBlockHighOverSharedParts = -1;
		if (m_fBlockHighOverSharedFactor != file->KnownPrefs.m_fBlockHighOverSharedFactor) m_fBlockHighOverSharedFactor = UN_FLOAT;

		if (m_iShowAlwaysNeeded != file->KnownPrefs.m_iShowAlwaysNeeded) m_iShowAlwaysNeeded = -1;
		if (m_iShowAlwaysParts != file->KnownPrefs.m_iShowAlwaysParts) m_iShowAlwaysParts = UN_INT;

		if (m_iShowAlwaysIncomplete != file->KnownPrefs.m_iShowAlwaysIncomplete) m_iShowAlwaysIncomplete = -1;
		// MOD: IPS END

	}

	// MOD: IPS - [InteligentPartSharing]
	if (!m_iMaxProzentToHide)
		m_iMaxProzentToHide = thePrefs.GetMaxProzentToHide();
	else if(m_iMaxProzentToHide == UN_INT)
		m_iMaxProzentToHide = 0;

	if (!m_fHideOverAvaliblyValue)
		m_fHideOverAvaliblyValue = thePrefs.GetHideOverAvaliblyValue();
	else if(m_fHideOverAvaliblyValue == UN_FLOAT)
		m_fHideOverAvaliblyValue = 0;

	if (!m_fHideOverSharedValue)
		m_fHideOverSharedValue = thePrefs.GetHideOverSharedValue();
	else if(m_fHideOverSharedValue == UN_FLOAT)
		m_fHideOverSharedValue = 0;
	
	if (!m_fDontHideUnderAvaliblyValue)
		m_fDontHideUnderAvaliblyValue = thePrefs.GetDontHideUnderAvaliblyValue();
	else if(m_fDontHideUnderAvaliblyValue == UN_FLOAT)
		m_fDontHideUnderAvaliblyValue = 0;

	if (!m_fBlockHighOverAvaliblyFactor)
		m_fBlockHighOverAvaliblyFactor = thePrefs.GetBlockHighOverAvaliblyFactor();
	else if(m_fBlockHighOverAvaliblyFactor == UN_FLOAT)
		m_fBlockHighOverAvaliblyFactor = 0;

	if (!m_fBlockHighOverSharedFactor)
		m_fBlockHighOverSharedFactor = thePrefs.GetBlockHighOverSharedFactor();
	else if(m_fBlockHighOverSharedFactor == UN_FLOAT)
		m_fBlockHighOverSharedFactor = 0;

	if (!m_iShowAlwaysParts)
		m_iShowAlwaysParts = thePrefs.GetShowAlwaysParts();
	else if(m_iShowAlwaysParts == UN_INT)
		m_iShowAlwaysParts = 0;
	// MOD: IPS END

}

void CPPgRelease::OnTimer(UINT /*nIDEvent*/)
{
	if (m_bDataChanged)
	{
		RefreshData();
		m_bDataChanged = false;
	}
}

BOOL CPPgRelease::OnSetActive()
{
	if (!CPropertyPage::OnSetActive())
		return FALSE;
	if (m_bDataChanged)
	{
		RefreshData();
		m_bDataChanged = false;
	}
	return TRUE;
}

LRESULT CPPgRelease::OnDataChanged(WPARAM, LPARAM)
{
	m_bDataChanged = true;
	return 1;
}
// MOD: FCFG END

void CPPgRelease::OnDestroy()
{
	// MOD: FCFG - [FileConfiguration]
	if (m_timer){
		KillTimer(m_timer);
		m_timer = 0;
	}
	// MOD: FCFG END

	m_ctrlTreeOptions.DeleteAllItems();
	m_ctrlTreeOptions.DestroyWindow();
	ClearAllMembers();
	CPropertyPage::OnDestroy();
}

/*void CPPgRelease::Localize()
{
}*/

BOOL CPPgRelease::OnKillActive()
{
	// if prop page is closed by pressing ENTER we have to explicitly commit any possibly pending
	// data from an open edit control
	m_ctrlTreeOptions.HandleChildControlLosingFocus();
	return CPropertyPage::OnKillActive();
}

LRESULT CPPgRelease::OnTreeOptsCtrlNotify(WPARAM wParam, LPARAM lParam)
{
	if(!IsWindowVisible())
		return 0;

	if (wParam == IDC_MOD_OPTS){
		TREEOPTSCTRLNOTIFY* pton = (TREEOPTSCTRLNOTIFY*)lParam;
		if(pton->nmhdr.code == EN_KILLFOCUS){	
			// MOD: TQ - [TweakUploadQueue]
			if(!ForFile() && m_htiQueueOverFlowRelease && pton->hItem == m_htiQueueOverFlowRelease){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiQueueOverFlowRelease, VAL_QUEUE_OVERFLOW_MIN, VAL_QUEUE_OVERFLOW_DEF, VAL_QUEUE_OVERFLOW_MAX)) SetModified();
			}else if(!ForFile() && m_htiQueueOverFlowEx && pton->hItem == m_htiQueueOverFlowEx){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiQueueOverFlowEx, VAL_QUEUE_OVERFLOW_MIN, VAL_QUEUE_OVERFLOW_DEF, VAL_QUEUE_OVERFLOW_MAX)) SetModified();
			}else if(!ForFile() && m_htiQueueOverFlowDef && pton->hItem == m_htiQueueOverFlowDef){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiQueueOverFlowDef, VAL_QUEUE_OVERFLOW_MIN, VAL_QUEUE_OVERFLOW_DEF, VAL_QUEUE_OVERFLOW_MAX)) SetModified();
			}else if(!ForFile() && m_htiQueueOverFlowCF && pton->hItem == m_htiQueueOverFlowCF){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiQueueOverFlowCF, VAL_QUEUE_OVERFLOW_MIN, VAL_QUEUE_OVERFLOW_DEF, VAL_QUEUE_OVERFLOW_MAX)) SetModified();
			}
			// MOD: TQ END
			// MOD: FCFG - [FileConfiguration]
			// MOD: IPS - [InteligentPartSharing]
			if(m_htiInteligentPartSharingTimer && pton->hItem == m_htiInteligentPartSharingTimer){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiInteligentPartSharingTimer, TIM_IPS_TIMER_MIN, TIM_IPS_TIMER_DEF, TIM_IPS_TIMER_MAX)) SetModified();
			}else if(m_htiMaxProzentToHide && pton->hItem == m_htiMaxProzentToHide){
				if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiMaxProzentToHide, VAL_IPS_MAX_MIN, VAL_IPS_MAX_DEF, VAL_IPS_MAX_MAX)) SetModified();
			}
				// OA>
				else if(m_htiHideOverAvaliblyValue && pton->hItem == m_htiHideOverAvaliblyValue){
					if(CheckTreeEditLimitF(m_ctrlTreeOptions, m_htiHideOverAvaliblyValue, ForFile() ? thePrefs.GetHideOverAvaliblyValue() : m_iHideOverAvaliblyMode ? VAL_IPS_OA_MIN2 : VAL_IPS_OA_MIN1, m_iHideOverAvaliblyMode ? VAL_IPS_OA_DEF2 : VAL_IPS_OA_DEF1, m_iHideOverAvaliblyMode ? VAL_IPS_OA_MAX2 : VAL_IPS_OA_MAX1)) SetModified();
				}else if(m_htiBlockHighOverAvaliblyFactor && pton->hItem == m_htiBlockHighOverAvaliblyFactor){
					if(CheckTreeEditLimitF(m_ctrlTreeOptions, m_htiBlockHighOverAvaliblyFactor, VAL_IPS_OAF_MIN, ForFile() ? thePrefs.GetBlockHighOverAvaliblyFactor() : VAL_IPS_OAF_DEF, VAL_IPS_OAF_MAX)) SetModified();
				}
				// <OA
				// OS>
				else if(m_htiHideOverSharedValue && pton->hItem == m_htiHideOverSharedValue){
					if(CheckTreeEditLimitF(m_ctrlTreeOptions, m_htiHideOverSharedValue, ForFile() ? thePrefs.GetHideOverSharedValue() : m_iHideOverSharedMode ? VAL_IPS_OS_MIN2 : VAL_IPS_OS_MIN1, m_iHideOverSharedMode ? VAL_IPS_OS_DEF2 : VAL_IPS_OS_DEF1, m_iHideOverSharedMode ? VAL_IPS_OS_MAX2 : VAL_IPS_OS_MAX1)) SetModified();
				}	// UA>
					else if(m_htiDontHideUnderAvaliblyValue && pton->hItem == m_htiDontHideUnderAvaliblyValue){
						if(CheckTreeEditLimitF(m_ctrlTreeOptions, m_htiDontHideUnderAvaliblyValue, ForFile() ? thePrefs.GetDontHideUnderAvaliblyValue() : m_iDontHideUnderAvaliblyMode ? VAL_IPS_UA_MIN2 : VAL_IPS_UA_MIN1, m_iDontHideUnderAvaliblyMode ? VAL_IPS_UA_DEF2 : VAL_IPS_UA_DEF1, m_iDontHideUnderAvaliblyMode ? VAL_IPS_UA_MAX2 : VAL_IPS_UA_MAX1)) SetModified();
					// <UA
				}else if(m_htiBlockHighOverSharedFactor && pton->hItem == m_htiBlockHighOverSharedFactor){
					if(CheckTreeEditLimitF(m_ctrlTreeOptions, m_htiBlockHighOverSharedFactor, VAL_IPS_OSF_MIN, ForFile() ? thePrefs.GetBlockHighOverSharedFactor() : VAL_IPS_OSF_DEF, VAL_IPS_OSF_MAX)) SetModified();
				}
				// <OS
				else if(m_htiShowAlwaysNeededValue && pton->hItem == m_htiShowAlwaysNeededValue){
					if(CheckTreeEditLimit(m_ctrlTreeOptions, m_htiShowAlwaysNeededValue, VAL_SHOW_ALWAYS_PARTS_MIN, ForFile() ? thePrefs.GetShowAlwaysParts() : VAL_SHOW_ALWAYS_PARTS_DEF, VAL_SHOW_ALWAYS_PARTS_MAX)) SetModified();
				}

			// MOD: IPS END
			// MOD: FCFG END
		}else{
			// MOD: NPT - [NeoPartTraffic]
			UINT bCheck;
			if (m_htiPartTraffic && pton->hItem == m_htiPartTraffic){
				m_ctrlTreeOptions.GetCheckBox(m_htiPartTraffic, bCheck);
				m_ctrlTreeOptions.SetItemEnable(m_htiPartTraffic, bCheck, TRUE, TRUE);

			}
			// MOD: NPT END

			// MOD: TQ - [TweakUploadQueue]
			else if(m_htiUseMultiQueue && pton->hItem == m_htiUseMultiQueue){
				m_ctrlTreeOptions.GetCheckBox(m_htiUseMultiQueue, bCheck); // MOD: MQ - [MultiQueue]
				m_ctrlTreeOptions.SetItemEnable(m_htiOldPrioritySystem, bCheck ? FALSE : TRUE); // Munti Queue have his own priority score
			}else if(m_htiInfiniteQueue && pton->hItem == m_htiInfiniteQueue){
				m_ctrlTreeOptions.GetCheckBox(m_htiInfiniteQueue, bCheck);
				m_ctrlTreeOptions.SetGroupEnable(m_htiUploadQueueOverFlow, bCheck ? FALSE : TRUE);
			}
			else if(m_htiUseRandomQueue && pton->hItem == m_htiUseRandomQueue){
				m_ctrlTreeOptions.GetCheckBox(m_htiUseRandomQueue, bCheck); // MOD: RQ - [RandomQueue]
			}
			else if(m_htiQueueOverFlowRelease && pton->hItem == m_htiQueueOverFlowRelease){
				m_ctrlTreeOptions.GetCheckBox(m_htiQueueOverFlowRelease, bCheck);
				m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowRelease, bCheck == 2, TRUE, TRUE);
			}else if(m_htiQueueOverFlowEx && pton->hItem == m_htiQueueOverFlowEx){
				m_ctrlTreeOptions.GetCheckBox(m_htiQueueOverFlowEx, bCheck);
				m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowEx, bCheck == 2, TRUE, TRUE);
			}else if(m_htiQueueOverFlowDef && pton->hItem == m_htiQueueOverFlowDef){
				m_ctrlTreeOptions.GetCheckBox(m_htiQueueOverFlowDef, bCheck);
				m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowDef, bCheck == 2, TRUE, TRUE);
			}else if(m_htiQueueOverFlowCF && pton->hItem == m_htiQueueOverFlowCF){
				m_ctrlTreeOptions.GetCheckBox(m_htiQueueOverFlowCF, bCheck);
				m_ctrlTreeOptions.SetItemEnable(m_htiQueueOverFlowCF, bCheck == 2, TRUE, TRUE);
			}
			// MOD: TQ END

			// MOD: IPS - [InteligentPartSharing]
			else if(m_htiInteligentPartSharingEnable && pton->hItem == m_htiInteligentPartSharingEnable){
				CheckIPSEnable();
			}
			// MOD: IPS END
			SetModified();
		}
	}
	return 0;
}

// MOD: IPS - [InteligentPartSharing]
bool CPPgRelease::CheckIPSEnable(){
	UINT bCheck;
	UINT bPTCheck;

	if(!ForFile()){
		m_ctrlTreeOptions.GetCheckBox(m_htiInteligentPartSharingEnable, bCheck);
		m_ctrlTreeOptions.GetCheckBox(m_htiPartTraffic, bPTCheck);
	}
	else{
		bCheck = thePrefs.IsInteligentPartSharing();
		bPTCheck = thePrefs.UsePartTraffic();
	}

	if(!ForFile())
		m_ctrlTreeOptions.SetItemEnable(m_htiInteligentPartSharingTimer,bCheck);
	m_ctrlTreeOptions.SetItemEnable(m_htiMaxProzentToHide,bCheck);
	m_ctrlTreeOptions.SetItemEnable(m_htiHideOverAvaliblyParts,bCheck);
	m_ctrlTreeOptions.SetItemEnable(m_htiHideOverSharedParts,bCheck && bPTCheck);
	m_ctrlTreeOptions.SetItemEnable(m_htiShowAlwaysNeeded,bCheck);

	return bCheck != FALSE;
}
// MOD: IPS END

LRESULT CPPgRelease::DrawTreeItemHelp(WPARAM wParam, LPARAM lParam)
{
	if(!IsWindowVisible())
		return 0;

	if (wParam == IDC_MOD_OPTS){
		CString* sInfo = (CString*)lParam;
		SetDlgItemText(IDC_MOD_OPTS_INFO, *sInfo);
	}
	return FALSE;
}

void CPPgRelease::OnHelp()
{
	//theApp.ShowHelp(0);
}

BOOL CPPgRelease::OnCommand(WPARAM wParam, LPARAM lParam)
{
	if (wParam == ID_HELP)
	{
		OnHelp();
		return TRUE;
	}
	return __super::OnCommand(wParam, lParam);
}

BOOL CPPgRelease::OnHelpInfo(HELPINFO* /*pHelpInfo*/)
{
	OnHelp();
	return TRUE;
}
