User Tools

Site Tools


hpl3:community:scripting:visual_studio_code_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
hpl3:community:scripting:visual_studio_code_setup [2017/07/11 21:48]
abion47 [Configure The HPL3 Profile]
hpl3:community:scripting:visual_studio_code_setup [2018/03/24 19:36]
timan Added a debugger tutorial
Line 15: Line 15:
 To do this, simply navigate to your SOMA installation folder and right-click on the window background. (i.e. Don't click on any file or folder within the SOMA folder.) Then select the "Open with Code" option from the drop down menu: To do this, simply navigate to your SOMA installation folder and right-click on the window background. (i.e. Don't click on any file or folder within the SOMA folder.) Then select the "Open with Code" option from the drop down menu:
  
-{{ :​hpl3:​community:​scripting:​01.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​01.png?​direct&  ​}}
  
 ===== Associate HPS files with C++ ===== ===== Associate HPS files with C++ =====
Line 21: Line 21:
 The first thing to do is to associate HPL3 script files with VS Code's C++ syntax highlighting engine. To do so, you need to open VS Code's preferences file: The first thing to do is to associate HPL3 script files with VS Code's C++ syntax highlighting engine. To do so, you need to open VS Code's preferences file:
  
-{{ :​hpl3:​community:​scripting:​02.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​02.png?​direct&  ​}}
  
 In VS Code, settings are saved in a JSON file. The window on the left is the VS Code default settings, while the window on the right is a JSON file for creating and saving user configurations. In VS Code, settings are saved in a JSON file. The window on the left is the VS Code default settings, while the window on the right is a JSON file for creating and saving user configurations.
Line 35: Line 35:
 Afterwards, your preferences file should look something like this: Afterwards, your preferences file should look something like this:
  
-{{ :​hpl3:​community:​scripting:​03.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​03.png?​direct&  ​}}
  
 ===== Install CPPTools extension ===== ===== Install CPPTools extension =====
  
-Next, you will need to get the C/C++ extension for VS Studio. To do this, go to the Extensions tab on the left side of the window. In the search bar, search for "cpptools". The extension you want should appear at the top of the list (it's authored by Microsoft). After you find it, click the green "​Install"​ button:+Next, you will need to get the C/C++ extension for VS Studio. To do this, go to the Extensions tab on the left side of the window. In the search bar, search for "C/C++". The extension you want should appear at the top of the list (it's authored by Microsoft). After you find it, click the green "​Install"​ button:
  
-{{ :​hpl3:​community:​scripting:​04.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​04.png?​direct&  ​}}
  
 (After you install it, the window will need to be reloaded twice. The first time is after installing the extension, and the second time is after the extension downloads and installs its needed dependencies. Simply click on the "​Reload"​ button as it appears and VS Code will restart itself for you, retaining your open files.) (After you install it, the window will need to be reloaded twice. The first time is after installing the extension, and the second time is after the extension downloads and installs its needed dependencies. Simply click on the "​Reload"​ button as it appears and VS Code will restart itself for you, retaining your open files.)
  
-=====Configure The HPL3 Profile=====+===== Configure The HPL3 Profile =====
  
 Now you need to congifure the extension to use the HPL3 script files for its Intellisense. To do this, open the Command Palette by pressing "​Ctrl-Shift-P"​. From there, find and select the "​C/​Cpp:​ Edit Configurations"​ option: Now you need to congifure the extension to use the HPL3 script files for its Intellisense. To do this, open the Command Palette by pressing "​Ctrl-Shift-P"​. From there, find and select the "​C/​Cpp:​ Edit Configurations"​ option:
  
-{{ :​hpl3:​community:​scripting:​05.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​05.png?​direct&  ​}}
  
 On this page, you will see a lot of existing JSON text. This was automatically generated by the extension, and there'​s no need to change it. Instead, we are going to add a new profile for the Intellisense to use in our projects. On this page, you will see a lot of existing JSON text. This was automatically generated by the extension, and there'​s no need to change it. Instead, we are going to add a new profile for the Intellisense to use in our projects.
Line 55: Line 55:
 Scroll to the bottom and put the cursor after the closing bracket of the last profile. (It's the third bracket from the bottom.) Scroll to the bottom and put the cursor after the closing bracket of the last profile. (It's the third bracket from the bottom.)
  
-{{ :​hpl3:​community:​scripting:​06.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​06.png?​direct&  ​}}
  
 After that bracket, add a comma, add a new line (press Enter), then paste the following text: After that bracket, add a comma, add a new line (press Enter), then paste the following text:
Line 61: Line 61:
 <​code>​ <​code>​
 { {
- "​name":​ "​HPL3",​ +    ​"​name":​ "​HPL3",​ 
- "​includePath":​ [ +    "​includePath":​ [ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​agents",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​agents",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​areas",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​areas",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​base",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​base",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​critters",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​critters",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth/​helper_custom_depth_imgui",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth/​helper_custom_depth_imgui",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​effects",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​effects",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​helpers",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​helpers",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​interfaces",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​interfaces",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​modules",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​modules",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​player",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​player",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​props",​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​props",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​utilities"​ +        "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​utilities"​ 
- ], +    ], 
- "​intelliSenseMode":​ "​clang-x64",​ +    "​intelliSenseMode":​ "​clang-x64",​ 
- "​browse":​{ +    "​browse":​{ 
- "​path":​[ +        "​path":​[ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​agents",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​agents",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​areas",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​areas",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​base",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​base",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​critters",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​critters",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth/​helper_custom_depth_imgui",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​custom_depth/​helper_custom_depth_imgui",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​effects",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​effects",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​helpers",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​helpers",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​interfaces",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​interfaces",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​modules",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​modules",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​player",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​player",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​props",​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​props",​ 
- "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​utilities"​ +            "​F:/​Program Files (x86)/​Steam/​steamapps/​common/​SOMA/​script/​utilities"​ 
- +        
- }+    }
 } }
 </​code>​ </​code>​
Line 104: Line 104:
 Afterwards, the text should look like this (the new text is highlighted):​ Afterwards, the text should look like this (the new text is highlighted):​
  
-{{ :​hpl3:​community:​scripting:​07.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​07.png?​direct&  ​}}
  
 (If your text has any red squiggles in it, then you copied the text into the wrong place. Compare your text to the image above to make sure it looks the same.) (If your text has any red squiggles in it, then you copied the text into the wrong place. Compare your text to the image above to make sure it looks the same.)
Line 110: Line 110:
 Now your profile is ready to go. Save and close the file, then go back to your map script. Open the Command Palette again ("​Ctrl-Shift-P"​) and navigate to "​C/​Cpp:​ Select a Configuration":​ Now your profile is ready to go. Save and close the file, then go back to your map script. Open the Command Palette again ("​Ctrl-Shift-P"​) and navigate to "​C/​Cpp:​ Select a Configuration":​
  
-{{ :​hpl3:​community:​scripting:​08.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​08.png?​direct&  ​}}
  
 Under the drop-down menu, select "​HPL3":​ Under the drop-down menu, select "​HPL3":​
  
-{{ :​hpl3:​community:​scripting:​09.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​09.png?​direct&  ​}}
  
 And that's it! You're done! Go ahead and test it out in your map script: And that's it! You're done! Go ahead and test it out in your map script:
  
-{{ :​hpl3:​community:​scripting:​10.png?​direct ​|}}+{{  :​hpl3:​community:​scripting:​10.png?​direct&  ​}} 
 + 
 +===== Optional: Launch SOMA from VS Code ===== 
 + 
 +Another useful thing you can do with Visual Studio Code is to set Custom Debug Configuration. With that in mind, we can make VS Code launch the SomaDev.bat (or any other custom bat) file through the debugger. 
 + 
 +Go to the Debug Panel by pressing "​Ctrl+Shift+D"​. On the Debug tab, press on the configuration button and select C/C++ (Windows). 
 + 
 +Override the existing code with the following:​ 
 + 
 +<​code>​ 
 +
 + 
 +// Use IntelliSense to learn about possible attributes. 
 + 
 +// Hover to view descriptions of existing attributes. 
 + 
 +// For more information,​ visit: https://​go.microsoft.com/​fwlink/?​linkid=830387 
 + 
 +"​version":​ "​0.2.0",​ 
 + 
 +"​configurations":​ [ 
 +
 + 
 +      "​name":​ "​SOMA",​ 
 + 
 +      "​type":​ "​cppvsdbg",​ 
 + 
 +      "​request":​ "​launch",​ 
 + 
 +      "​program":​ "​${workspaceFolder}/​SomaDevCMD.bat",​ 
 + 
 +      "​args":​ [], 
 + 
 +      "​stopAtEntry":​ false, 
 + 
 +      "​cwd":​ "​${workspaceFolder}",​ 
 + 
 +      "​environment":​ [], 
 + 
 +      "​externalConsole":​ true 
 + 
 +    } 
 + 
 +  ] 
 + 
 +
 +</​code>​ 
 + 
 +You can add more configurations by pressing on the "Add Configuration"​ Button at the bottom right and selecting again C/C++ Windows (Launch). 
 + 
 +Now, just select the debugger you want and press on the green arrow to launch it. 
hpl3/community/scripting/visual_studio_code_setup.txt · Last modified: 2018/03/24 19:36 by timan