!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Sandbox / Plugins / EditorSchematyc2 / Editor / CryLink.cpp
blob1c2d742f1d52dbdf7aa84b576652e4ce29d34a44
1 // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
5 #include "CryLink.h"
6 #include "MainFrameWnd.h"
8 namespace Schematyc2
10 CCryLinkCommands CCryLinkCommands::s_instance;
12 static void RpcEditorShow(IConsoleCmdArgs* pArgs)
14 if(gEnv->IsEditor())
16 SGUID itemGuid;
17 if(pArgs->GetArgCount() >= 2)
19 itemGuid = StringUtils::SysGUIDFromString(pArgs->GetArg(1));
22 SGUID childGuid;
23 if(pArgs->GetArgCount() >= 3)
25 childGuid = StringUtils::SysGUIDFromString(pArgs->GetArg(2));
28 if(itemGuid)
30 if(CWnd* mainWnd = GetIEditor()->OpenView("Schematyc2"))
32 static_cast<CMainFrameWnd*>(mainWnd)->SelectItem(itemGuid, childGuid);
38 static void RpcRefreshDetailView(IConsoleCmdArgs* pArgs)
40 if (gEnv->IsEditor())
42 if (CWnd* mainWnd = GetIEditor()->FindView("Schematyc2"))
44 static_cast<CMainFrameWnd*>(mainWnd)->UpdatePreview();
49 static void RpcEditorGoto(IConsoleCmdArgs* pArgs)
51 if (gEnv->IsEditor())
53 SGUID itemGuid;
54 if (pArgs->GetArgCount() >= 2)
56 itemGuid = StringUtils::SysGUIDFromString(pArgs->GetArg(1));
59 SGUID lastItemGuid;
60 if (pArgs->GetArgCount() >= 3)
62 lastItemGuid = StringUtils::SysGUIDFromString(pArgs->GetArg(2));
65 if (itemGuid)
67 if (CWnd* mainWnd = GetIEditor()->OpenView("Schematyc2"))
69 static_cast<CMainFrameWnd*>(mainWnd)->GotoItem(itemGuid, lastItemGuid);
75 static void DiffSelectedItem()
77 if (CWnd* mainWnd = GetIEditor()->OpenView("Schematyc2"))
79 static_cast<CMainFrameWnd*>(mainWnd)->DiffSelectedItem();
83 static void RpcEditorShowAndDiff(IConsoleCmdArgs* pArgs)
85 RpcEditorShow(pArgs);
86 DiffSelectedItem();
89 CCryLinkCommands::CCryLinkCommands()
90 : m_pConsole(nullptr)
91 , m_bRegistered(false)
96 CCryLinkCommands::~CCryLinkCommands()
98 Unregister();
101 void CCryLinkCommands::Register(IConsole* pConsole)
103 CRY_ASSERT(pConsole);
104 m_pConsole = pConsole;
105 if(m_pConsole && !m_bRegistered)
107 REGISTER_COMMAND("sc_rpcShowLegacy", RpcEditorShow, VF_NULL, "Opens the specified graph in Schematyc editor and focuses the optional child: Properties: docGuid childGuid");
108 REGISTER_COMMAND("sc_rpcGotoLegacy", RpcEditorGoto, VF_NULL, "Opens the specified graph in Schematyc editor");
109 REGISTER_COMMAND("sc_rpcShowAndDiffLegacy", RpcEditorShowAndDiff, VF_NULL, "Opens the specified graph in Schematyc editor and diff with have version: Properties: docGuid");
110 REGISTER_COMMAND("sc_rpcRefreshDetailViewLegacy", RpcRefreshDetailView, VF_NULL, "Refreshes the detail view");
112 m_bRegistered = true;
116 void CCryLinkCommands::Unregister()
118 if(m_pConsole && m_bRegistered)
120 m_pConsole->RemoveCommand("sc_rpcShowLegacy");
121 m_pConsole->RemoveCommand("sc_rpcGotoLegacy");
122 m_pConsole->RemoveCommand("sc_rpcShowAndDiffLegacy");
123 m_pConsole->RemoveCommand("sc_rpcRefreshDetailViewLegacy");
125 m_bRegistered = false;