ImGui Helper
The ImGui helper file in SOMA is script/helpers/helper_imgui.hps.
ImGui helpers read GUI input and state, convert normalized coordinates into screen or group coordinates, and draw GUI widgets. Normalized positions use the 0–1 range; ImGui_GetSize returns the GUI screen size in pixels.
Contents
Choose the GUI callback
For a terminal layout, put these GUI-coordinate and widget calls in the terminal’s OnGui callback. They work with the current GUI’s size and state. Follow the terminal tutorial to connect the callback to a terminal before adding its layout.
Before you start
- Open the map script inside your own mod. Keep its generated includes,
cScrMap : iScrMapclass and callback structure. See Add your first script if you have not edited a map script yet. - Add the helper include shown below alongside the script’s other includes.
- Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.
Follow the stock example
#include "helpers/helper_imgui.hps"
ImGui_GetSize
Get the size (in pixels) of the GUI screen
In maps/02_06_theta_tunnels_old/02_06_theta_tunnels.hps, SOMA calls ImGui_GetSize as follows.
ImGui_GetSize();
This is an excerpt from that stock script; its referenced names and variables belong to that script.
ImGui_NrmPos
Input should be normalized, 0-1, and a position in screen space is returned.
In maps/chapter05/05_02_ARK_inside/05_02_ARK_inside.hps, SOMA calls ImGui_NrmPos as follows.
cVector3f vPos = ImGui_NrmPos(1.0f, 0.5, 2);
| Parameter | Value in this stock call |
|---|---|
avPos |
1.0f
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
ImGui_NrmPos
Input should be normalized, 0-1, and a position in screen space is returned.
Check your change
Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.