Mods / ImGui

Tags: #Library #Utility
Author: Maltiez
Side: Both
Created: Nov 30th 2023 at 7:09 PM
Last modified: Apr 4th at 9:09 AM
Downloads: 150633
Follow Unfollow 1230

Latest release (for outdated Vintage Story v1.20.7):
vsimgui_1.1.8.zip  1-click install


You can support me on Patreon:


Description

This is a library that brings Dear ImGui to Vintage Story

To increase/decrease font size (and GUI size as a result), use hotkeys (CTRL + - and CTRL + = by default)

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.8 20174 Apr 4th at 9:09 AM Show vsimgui_1.1.8.zip 1-click install
v1.1.7 59256 Oct 24th 2024 at 3:13 AM Show vsimgui_1.1.7.zip 1-click install
v1.1.6 1903 Oct 5th 2024 at 3:36 PM Show vsimgui_1.1.6.zip 1-click install
v1.1.5 31951 Jun 6th 2024 at 12:56 PM Show vsimgui_1.1.5.zip 1-click install
v1.1.4 1735 May 30th 2024 at 10:51 AM Show vsimgui_1.1.4.zip 1-click install
v1.1.3 13187 Mar 21st 2024 at 8:32 AM Show vsimgui_1.1.3.zip 1-click install
v1.1.2 2261 Mar 7th 2024 at 5:42 PM Show vsimgui_1.1.2.zip 1-click install
v1.1.1 980 Mar 2nd 2024 at 12:10 PM Show vsimgui_1.1.1.zip 1-click install
v1.1.0 5654 Mar 2nd 2024 at 12:42 AM Show vsimgui_1.1.0.zip 1-click install
v1.0.0 537 Feb 28th 2024 at 9:16 AM Show vsimgui_1.0.0.zip 1-click install
v1.0.0-pre.3 196 Feb 28th 2024 at 5:51 AM Show vsimgui_1.0.0-pre.3.zip 1-click install
v1.0.0-pre.2 335 Feb 26th 2024 at 3:10 PM Show vsimgui_1.0.0-pre.2.zip 1-click install
v1.0.0-pre.1 226 Feb 26th 2024 at 4:49 AM Show vsimgui_1.0.0-pre.1.zip 1-click install
v0.3.5 1221 Feb 13th 2024 at 10:01 PM Show vsimgui_0.3.5.zip 1-click install
v0.3.4 1667 Feb 13th 2024 at 7:52 PM Show vsimgui_0.3.4.zip 1-click install
v0.3.3 5823 Jan 18th 2024 at 11:26 AM Show vsimgui_0.3.3.zip 1-click install
v0.3.2 660 Jan 14th 2024 at 3:22 AM Show vsimgui_0.3.2.zip 1-click install
v0.3.1 440 Jan 13th 2024 at 1:27 PM Show vsimgui_0.3.1.zip 1-click install
v0.3.0 181 Jan 13th 2024 at 9:33 AM Show vsimgui_0.3.0.zip 1-click install
v0.2.4 203 Jan 12th 2024 at 2:28 PM Show vsimgui_0.2.4.zip 1-click install
v0.2.3 207 Jan 11th 2024 at 7:51 PM Show vsimgui_0.2.3.zip 1-click install
v0.2.2 354 Jan 9th 2024 at 10:18 AM Show vsimgui_0.2.2.zip 1-click install
v0.2.1 481 Dec 19th 2023 at 3:24 AM Show vsimgui_0.2.1.zip 1-click install
v0.2.0 219 Dec 16th 2023 at 7:34 AM Show vsimgui_0.2.0.zip 1-click install
v0.1.1 332 Dec 12th 2023 at 4:42 AM Show vsimgui_0.1.1.zip 1-click install
v0.1.0 210 Dec 5th 2023 at 2:12 AM Show vsimgui_0.1.0.zip 1-click install
v0.0.1 201 Nov 30th 2023 at 7:09 PM Show vsimgui_0.0.1.zip 1-click install

26 Comments (oldest first | newest first)

💬 Maltiez , Apr 5th at 12:24 AM

I uploaded wrong build and reuploaded correct one after several minutes

💬 TakeoTheWolf, Apr 5th at 12:10 AM

that fixed it. so it just didn't download correctly the first time?

💬 Maltiez , Apr 4th at 10:20 PM

TakeoTheWolf

Redownload latest release

💬 TakeoTheWolf, Apr 4th at 10:17 PM

somehow this new update cuases crashes upon saving and leaving a single player world, it prevents the save sometimes as well. and doesn't activate the crash handler so I have no logs to offer you. sorry to be a bother.

💬 Maltiez , Apr 4th at 9:14 AM

Losa98

Added hotkeys to decrease/increase gui size, dont want to tie it to vanilla gui scale

💬 Losa98, Apr 4th at 5:58 AM

Hello please patch to scale with in-game gui size setting, I can't see anything in the config window because the text is way too small!! Tried a bunch of different things to fix it and while I could make it bigger it would drop the resolution of the rest of the game by a ton. thank you!!

Edit: this issue caused me to find out windows magnifying glass exists xD pretty useful tbh, the shortcut is the windows key and the plus button

💬 jabes, Feb 26th at 2:20 AM

Does most current version work with 1.20.4?

 

💬 Eoin_Lynne, Feb 3rd at 1:46 PM

Can I use this mod to increase font size? It's hard for me to read text in this game...

💬 Rodrimus, Jan 4th at 11:30 AM

Do i need this mod, for BetterRuins? Is it necessary?

💬 Jaknec, Dec 1st 2024 at 4:12 PM

which version is compatible with 1.19.8 please!

💬 QiForce, Nov 6th 2024 at 5:47 PM

which version is compatible with 1.19.8? (current stable)

💬 Maltiez , Jun 12th 2024 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 2024 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 2024 at 9:16 AM

Maltiez thanks

💬 Maltiez , Mar 2nd 2024 at 7:17 PM

Just tested latest version on Ubuntu 20: works fine

💬 Maltiez , Mar 2nd 2024 at 6:36 PM

adres4t

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

💬 adres4t, Mar 2nd 2024 at 6:25 PM

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

 

💬 TerraWarlock, Feb 27th 2024 at 4:43 AM

Maltiez

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

💬 Maltiez , Feb 26th 2024 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 2024 at 4:41 AM

says that unable to resolve some mod dependencies???

💬 Dmitryz, Feb 14th 2024 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!

 

💬 Maltiez , Feb 13th 2024 at 10:02 PM

Dmitryz

0.3.5 will hopefully fix mac support

💬 Maltiez , Feb 13th 2024 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 2024 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

💬 Maltiez , Jan 13th 2024 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 2024 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)