Mods / ImGui

Category: #Library #Utility
Author: Maltiez
Side: Both
Created: Nov 30th 2023 at 7:09 PM
Last modified: Oct 24th at 3:13 AM
Downloads: 63229
Follow Unfollow 475

Latest file for v1.20.0-pre:
vsimgui_1.1.7.zip 1-click install


Description

This is a library that brings Dear ImGui to Vintage Story

Details

From Dear ImGui git repository:

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal and lacks certain features commonly found in more high-level libraries.

Wrapper for ImGui.NET which in it self is wrapper for Dear ImGui - graphical user interface library. In order to use this wrapper you just need to add reference on ImGui.NET (1.89.7.1) and the mod dll itself (like with other mods dependencies, both are in this mod's archive), and add your methods for constructing ImGui windows to VSImGuiModSystem.SetUpImGuiWindows event. Another example: github.com/maltiez2/vsmod_configlib/blob/master/configlib/src/GUI/ConfigWindow.cs

Supports also Not actually (working on it, it seems I need to follow this procedure, if somebody will provide this binaries I'll inculde them in mod):

This mod will allow you to make development tools like tfedit or simple throw away debug/visualisation tools for working on your mod. It would not require your mod to depend on this library if you need it only for debugging. Just wrapp all the code you dont want to ship in #if DEBUG #endif . Bulding such tools is as easy as adding logs.


Features

  • Quick and easy small debug tools - you can display and edit in real time any value in any part of your code no matter how deep it is with just a one line (static methods of DebugWindow class from VSImGui namespace)
  • No dependencies required for debug tools - just wrap all the ImGui and VSImGui methods calls you add in '#if DEBUG #endif'
  • Easy to build debug tools - add more sophisticated dev tools specific to your mod to speed up development and ease debugging (for example, Animation Manager library has in-game animation editor in its dev build)
  • Easy and quick to layout GUI with docking and a lot of built-in functionality like color pickers
  • Styles - you can change every color and size and even tile your window with a texture with a simple Style and WindowStyle classes, you can serialize style into json and load it from json

Other info

I also need some help with the development of this library (I will add any contributor to a list of authors, and mention in the description):

Mods that uses this library:


Examples and docs (outdated)

ImGui manual for C++, but .NET methods should have same names and similar arguments: https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html

ImGui wiki: https://github.com/ocornut/imgui/wiki

Example of showing demo window: api.ModLoader.GetModSystem<VSImGuiModSystem>().SetUpImGuiWindows += ImGuiNET.ImGui.ShowDemoWindow;

Example of adding debug widget

If you have some field or property in your class (or just some reference type value) you want to display or edit via GUI, you can call a static mehod of a DebugWindow class that will display a widget in a debug window with specified domain as name inside a tab with specified category. Given title serves as this widget id, and calling DebugWindow methods for same domain and title will replace existing widget instead of adding a new one. Some mehod require also an int id, it server same perpouse as title. You can call DebugWindow method in any place of code, any amount of time, but setter and getter delegates will be called once per frame.

private float someValue;
private void SomeMethod()
{
    DebugWindow.FloatSlider("My debug window title", "Some sliders", "a slider", min: 0, max: 1.0f, getter: () => someValue, setter: value => someValue = value);
}

If you want to not add ImGui as dependency you can wrap its mehods with #if DEBUG #endif and leave them only in debug build

private float someValue;
private void SomeMethod()
{
#if DEBUG
    DebugWindow.FloatSlider("My debug window title", "Some sliders", "a slider", min: 0, max: 1.0f, getter: () => someValue, setter: value => someValue = value);
#endif
}
Simple example of a full mod that uses ImGui

To add your own ImGui windows you can add your drawing method to SetUpImGuiWindows event of VSImGuiModSystem. This method will be called once per frame. This method should contain all ImGui methods for drawing windows and widgets. Each frame gui is fully redrawn, so this method servers as layout composer and interface logic at the same time (this is a feature of all immediate mode GUIs).

using ImGuiNET;
using Vintagestory.API.Client;
using Vintagestory.API.Common;
using Vintagestory.API.MathTools;
using VSImGui;

namespace ImGuiExample;
public class ImGuiExampleModSystem : ModSystem
{
    private ICoreClientAPI mApi;

    public override void StartClientSide(ICoreClientAPI api)
    {
        mApi = api;
        api.ModLoader.GetModSystem<VSImGuiModSystem>().SetUpImGuiWindows += Draw;
    }

    private void Draw()
    {
        ImGui.Begin("ImGui example");

        float roll = mApi.World.Player.CameraRoll * GameMath.RAD2DEG;
        ImGui.SliderFloat("Roll", ref roll, -90, 90);
        mApi.World.Player.CameraRoll = roll * GameMath.DEG2RAD;

        ImGui.End();
    }
}

 

 

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v1.1.7 2357 Oct 24th at 3:13 AM Show vsimgui_1.1.7.zip Install now
v1.1.6 1729 Oct 5th at 3:36 PM Show vsimgui_1.1.6.zip Install now
v1.1.5 25524 Jun 6th at 12:56 PM Show vsimgui_1.1.5.zip Install now
v1.1.4 1613 May 30th at 10:51 AM Show vsimgui_1.1.4.zip Install now
v1.1.3 12808 Mar 21st at 8:32 AM Show vsimgui_1.1.3.zip Install now
v1.1.2 2199 Mar 7th at 5:42 PM Show vsimgui_1.1.2.zip Install now
v1.1.1 915 Mar 2nd at 12:10 PM Show vsimgui_1.1.1.zip Install now
v1.1.0 4238 Mar 2nd at 12:42 AM Show vsimgui_1.1.0.zip Install now
v1.0.0 469 Feb 28th at 9:16 AM Show vsimgui_1.0.0.zip Install now
v1.0.0-pre.3 129 Feb 28th at 5:51 AM Show vsimgui_1.0.0-pre.3.zip Install now
v1.0.0-pre.2 275 Feb 26th at 3:10 PM Show vsimgui_1.0.0-pre.2.zip Install now
v1.0.0-pre.1 158 Feb 26th at 4:49 AM Show vsimgui_1.0.0-pre.1.zip Install now
v0.3.5 1161 Feb 13th at 10:01 PM Show vsimgui_0.3.5.zip Install now
v0.3.4 1589 Feb 13th at 7:52 PM Show vsimgui_0.3.4.zip Install now
v0.3.3 5340 Jan 18th at 11:26 AM Show vsimgui_0.3.3.zip Install now
v0.3.2 564 Jan 14th at 3:22 AM Show vsimgui_0.3.2.zip Install now
v0.3.1 333 Jan 13th at 1:27 PM Show vsimgui_0.3.1.zip Install now
v0.3.0 111 Jan 13th at 9:33 AM Show vsimgui_0.3.0.zip Install now
v0.2.4 146 Jan 12th at 2:28 PM Show vsimgui_0.2.4.zip Install now
v0.2.3 143 Jan 11th at 7:51 PM Show vsimgui_0.2.3.zip Install now
v0.2.2 300 Jan 9th at 10:18 AM Show vsimgui_0.2.2.zip Install now
v0.2.1 405 Dec 19th 2023 at 3:24 AM Show vsimgui_0.2.1.zip Install now
v0.2.0 161 Dec 16th 2023 at 7:34 AM Show vsimgui_0.2.0.zip Install now
v0.1.1 244 Dec 12th 2023 at 4:42 AM Show vsimgui_0.1.1.zip Install now
v0.1.0 150 Dec 5th 2023 at 2:12 AM Show vsimgui_0.1.0.zip Install now
v0.0.1 136 Nov 30th 2023 at 7:09 PM Show vsimgui_0.0.1.zip Install now

16 Comments (oldest first | newest first)

💬 QiForce, Nov 6th at 5:47 PM

which version is compatible with 1.19.8? (current stable)

💬 MaltiezAuthor, Jun 12th at 12:44 PM

Exstructor

You can try building binaries yourself. This is stuff I used to do this: https://drive.google.com/file/d/1mJ5b5-5wkU4Fo9jQJAUiQT3RmJZtPotX/view?usp=sharing, I dont remember the steps and details cause it was long ago. If you will be able to successfully build it, just replace binaries in mod archive.

💬 Exstructor, Jun 11th at 4:28 PM

Hey, I'm using Linux ARM (aarch64), and the so files have the wrong architecture, how can I fix that?

💬 adres4t, Mar 3rd at 9:16 AM

Maltiez thanks

💬 MaltiezAuthor, Mar 2nd at 7:17 PM

Just tested latest version on Ubuntu 20: works fine

💬 MaltiezAuthor, Mar 2nd at 6:36 PM

adres4t

Should work on linux, need more info, logs and such, better in VS discord.

💬 adres4t, Mar 2nd at 6:25 PM

what about linux compatibility? can't join any server with this library on.

 

💬 TerraWarlock, Feb 27th at 4:43 AM

Maltiez

yep you are right i finally fixed it and it works, Thanks.

💬 MaltiezAuthor, Feb 26th at 5:01 AM

Yes. Considering you asked this question, it probably does. You have 0.3.5 version for 1.19.4-rc.1 version of the game, but your game version is probably 1.19.3.

💬 TerraWarlock, Feb 26th at 4:41 AM

says that unable to resolve some mod dependencies???

💬 Dmitryz, Feb 14th at 7:54 AM

Maltiez

I just checked on 19.1.4-rc and with v0.3.5 and the game loads normally! You are the best for resolving this so fast, really appreciate it!

 

💬 MaltiezAuthor, Feb 13th at 10:02 PM

Dmitryz

0.3.5 will hopefully fix mac support

💬 MaltiezAuthor, Feb 13th at 9:12 PM

Dmitryz

Mac... It is kinda not supported, or rather I cant test it on mac and debug cause I dont have mac, and library needs a binary for it. I will try to solve Mac support in a couple of days.

Upd. Ok, found an image of mac for vmware

💬 Dmitryz, Feb 13th at 9:03 PM

I am on a Mac (v19.1.3) and I believe I am facing the 

  • On linux library extracts embedded native cimgui library into /tmp folder, if this folder on your system is marked as "noexec" game will fail to load it and crash

problem.

Is anyone aware of any workarounds? Tried googling how to change the noexec status, but the suggested solutions didn't seem to work, game crashes on startup if I have this mod enabled

💬 MaltiezAuthor, Jan 13th at 12:45 PM

rayray

Make sure that you have the latest versions of both ImGui and Config lib mods, mod manager warning does not matter in this case

💬 rayray, Jan 13th at 11:09 AM

say it needs error say it needs 1.18.8 even though you said for 1.19 and crashes when i press p to change elements on hud for mod

(edit comment delete)