summaryrefslogtreecommitdiff
path: root/protocols/Steam/src/steam_menus.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-04-14 19:49:51 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-04-14 19:49:51 +0000
commite7eadee4856f2f3a2d6873712d5f73ce03b11918 (patch)
treeacae8d5da72ce293d506b5cdcf063110f27b5653 /protocols/Steam/src/steam_menus.cpp
parent84748741977bfc0bb49a6e2e42fa1ebd9e6b3aac (diff)
Steam: work commit
- added joint to game menu item - first approach to contacts management - minor fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@8977 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Steam/src/steam_menus.cpp')
-rw-r--r--protocols/Steam/src/steam_menus.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/protocols/Steam/src/steam_menus.cpp b/protocols/Steam/src/steam_menus.cpp
new file mode 100644
index 0000000000..9ce56ec84c
--- /dev/null
+++ b/protocols/Steam/src/steam_menus.cpp
@@ -0,0 +1,78 @@
+#include "common.h"
+
+HANDLE CSteamProto::hChooserMenu;
+HGENMENU CSteamProto::contactMenuItems[CMI_MAX];
+
+template<int(__cdecl CSteamProto::*Service)(WPARAM, LPARAM)>
+INT_PTR GlobalService(WPARAM wParam, LPARAM lParam)
+{
+ CSteamProto *ppro = CSteamProto::GetContactProtoInstance((MCONTACT)wParam);
+ return ppro ? (ppro->*Service)(wParam, lParam) : 0;
+}
+
+INT_PTR CSteamProto::MenuChooseService(WPARAM wParam, LPARAM lParam)
+{
+ if (lParam)
+ *(void**)lParam = (void*)wParam;
+
+ return 0;
+}
+
+int CSteamProto::JoinToGameCommand(WPARAM hContact, LPARAM)
+{
+ char url[MAX_PATH];
+ DWORD gameId = getDword(hContact, "GameID", 0);
+ mir_snprintf(url, SIZEOF(url), "steam://rungameid/%lu", gameId);
+ CallService(MS_UTILS_OPENURL, 0, (LPARAM)url);
+
+ return 0;
+}
+
+int CSteamProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = (MCONTACT)wParam;
+ if (!hContact)
+ return 0;
+
+ if (!this->IsOnline() || lstrcmpA(GetContactProto(hContact), m_szModuleName))
+ return 0;
+
+ //bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ DWORD gameId = getDword(hContact, "GameID", 0);
+ Menu_ShowItem(contactMenuItems[CMI_JOIN_GAME], gameId > 0);
+
+ return 0;
+}
+
+int CSteamProto::PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+{
+ for (int i = 0; i < SIZEOF(CSteamProto::contactMenuItems); i++)
+ Menu_ShowItem(CSteamProto::contactMenuItems[i], false);
+
+ CSteamProto* ppro = CSteamProto::GetContactProtoInstance((MCONTACT)wParam);
+ return (ppro) ? ppro->OnPrebuildContactMenu(wParam, lParam) : 0;
+}
+
+void CSteamProto::InitMenus()
+{
+ hChooserMenu = MO_CreateMenuObject("SkypeAccountChooser", LPGEN("Steam menu chooser"), 0, "Steam/MenuChoose");
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ // Contact menu initialization
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(CLISTMENUITEM);
+ mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE;
+
+ // "Join to game"
+ mi.pszService = MODULE"/JoinToGame";
+ mi.ptszName = LPGENT("Join to game");
+ mi.position = -200001000 + CMI_JOIN_GAME;
+ //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
+ contactMenuItems[CMI_JOIN_GAME] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSteamProto::JoinToGameCommand>);
+}
+
+void CSteamProto::UninitMenus()
+{
+ CallService(MS_CLIST_REMOVETRAYMENUITEM, (WPARAM)contactMenuItems[CMI_JOIN_GAME], 0);
+} \ No newline at end of file