summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_options.cpp
blob: 40dadd20ff0a94c7a9473974b8f1da83b0426d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "stdafx.h"

class CSteamOptionsMain : public CSteamDlgBase
{
	CCtrlEdit m_username, m_password, m_group, m_deviceName;
	CCtrlCheck m_biggerAvatars, m_showChatEvents;
	CCtrlSpin m_pollingErrorLimit;

public:
	CSteamOptionsMain(CSteamProto *proto, int idDialog, HWND hwndParent = NULL) :
		CSteamDlgBase(proto, idDialog),
		m_group(this, IDC_GROUP),
		m_username(this, IDC_USERNAME),
		m_password(this, IDC_PASSWORD),
		m_deviceName(this, IDC_DEVICE_NAME),		
		m_biggerAvatars(this, IDC_BIGGER_AVATARS),
		m_showChatEvents(this, IDC_SHOW_CHAT_EVENTS),
		m_pollingErrorLimit(this, IDC_POLLINGERRORLIMITSPIN, 255)
	{
		SetParent(hwndParent);

		CreateLink(m_username, "Username", L"");
		CreateLink(m_password, "Password", L"");
		CreateLink(m_group, m_proto->m_wszGroupName);
		CreateLink(m_deviceName, m_proto->m_wszDeviceName);

		if (idDialog == IDD_OPT_MAIN) {
			CreateLink(m_biggerAvatars, "UseBigAvatars", DBVT_BYTE, FALSE);
			CreateLink(m_showChatEvents, "ShowChatEvents", DBVT_BYTE, TRUE);
			CreateLink(m_pollingErrorLimit, "PollingErrorsLimit", DBVT_BYTE, STEAM_API_POLLING_ERRORS_LIMIT);
		}
	}

	bool OnInitDialog() override
	{
		CSteamDlgBase::OnInitDialog();

		SendMessage(m_username.GetHwnd(), EM_LIMITTEXT, 64, 0);
		SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 64, 0);
		SendMessage(m_group.GetHwnd(), EM_LIMITTEXT, 64, 0);
		return true;
	}

	bool OnApply() override
	{
		if (m_username.IsChanged())
			m_proto->delSetting(DBKEY_STEAM_ID);
		return true;
	}
};

MWindow CSteamProto::OnCreateAccMgrUI(MWindow hwndParent)
{
	auto *page = new CSteamOptionsMain(this, IDD_ACCMGR, hwndParent);
	page->Show();
	return page->GetHwnd();
}

/////////////////////////////////////////////////////////////////////////////////

class CSteamOptionsBlockList : public CSteamDlgBase
{
	typedef CSteamDlgBase CSuper;

	CCtrlListView m_list;
	CCtrlCombo m_contacts;
	CCtrlButton m_add;

public:
	CSteamOptionsBlockList(CSteamProto *proto) :
		CSuper(proto, IDD_OPT_BLOCK_LIST),
		m_list(this, IDC_LIST),
		m_contacts(this, IDC_CONTACTS),
		m_add(this, IDC_BLOCK)
	{
		m_add.OnClick = Callback(this, &CSteamOptionsBlockList::OnBlock);
	}

	bool OnInitDialog() override
	{
		m_list.SetExtendedListViewStyle(LVS_EX_SUBITEMIMAGES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);

		m_list.AddColumn(0, TranslateT("Name"), 220);
		m_list.AddColumn(1, L"", 32 - GetSystemMetrics(SM_CXVSCROLL));
		return true;
	}

	void OnBlock(CCtrlButton *)
	{}
};

/////////////////////////////////////////////////////////////////////////////////

int CSteamProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
	OPTIONSDIALOGPAGE odp = {};
	odp.szTitle.w = m_tszUserName;
	odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
	odp.szGroup.w = LPGENW("Network");

	odp.szTab.w = LPGENW("Account");
	odp.pDialog = new CSteamOptionsMain(this, IDD_OPT_MAIN);
	g_plugin.addOptions(wParam, &odp);

	// odp.szTab.w = LPGENW("Blocked contacts");
	// odp.pDialog = new CSteamOptionsBlockList(this);
	// g_plugin.addOptions(wParam, &odp);
	return 0;
}