Jibble

Author Topic: [PLUGIN] agsimgui 0.3.0 - build GUIs easily for debug purposes!  (Read 1052 times)

eri0o

agsimgui  version 0.3.0



Get Latest Release agsimgui.dll | libagsimgui.so | libagsimgui.dylib | GitHub Repo | Demo Windows | Demo Linux

Dear ImGui plugin for Adventure Game Studio



Supports Directx9 and Software renderer. Using OpenGL will default to Software renderer for ImGui only (it has it's own renderer), but OpenGL support will be provided in the future.

A more complete documentation is available here because AGS Forums have a 30000 character limit per posting.

Usage example

Run a simple demo window to see what's possible with Dear ImGui.
Code: Adventure Game Studio
  1. // use function room_RepExec() when in Room Script and link it throught the editor
  2. void repeatedly_execute(){
  3.   AgsImGui.NewFrame(); //let's begin a new frame, we end it with a Render
  4.   AgsImGui.ShowDemoWindow(); //Shows a demo of everything possible
  5.   AgsImGui.Render(); // This will generate drawing instructions.
  6.   // AGS will actually draw this on screen later on, on Post Screen Draw stage.
  7. }
  8.  
Some of what is shown on Demo Window is not yet exposed in the AgsImGui Script API.

Let's do a simple example now.
Code: Adventure Game Studio
  1. bool is_button_clicked;
  2.  
  3. // use function room_RepExec() when in Room Script and link it throught the editor
  4. void repeatedly_execute(){
  5.   AgsImGui.NewFrame(); //let's begin a new frame, we end it with a Render
  6.  
  7. AgsImGui.BeginWindow("My first window");    
  8.   ViewFrame* vf = Game.GetViewFrame(player.View, player.Loop, player.Frame);
  9.   is_button_clicked = AgsImGui.ImageButton(vf.Graphic);
  10.   if(AgsImGui.IsItemHovered()) AgsImGui.SetTooltip(String.Format("frame %d",player.Frame));
  11.   player.x = AgsImGui.DragInt("player.x", player.x);
  12.   player.y = AgsImGui.DragInt("player.y", player.y);
  13.   AgsImGui.EndWindow();
  14.  
  15. AgsImGui.Render(); // This will generate drawing instructions.
  16.   // AGS will actually draw this on screen later on, on Post Screen Draw stage.
  17. }
  18.  
Note ImGui will save a imgui.ini file to allow window positions and some more data to persist between sections when no guidance is given.



AGS Script API
Spoiler: ShowHide

Main

  • AgsImGui.NewFrame

    Code: [Select]
    static void AgsImGui.NewFrame()
    Call this before calling any AgsImGui commands.


  • AgsImGui.EndFrame

    Code: [Select]
    static void AgsImGui.EndFrame()
    We don't need this if we are using Render, since it will automatically call AgsImGui.EndFrame() too.


  • AgsImGui.Render

    Code: [Select]
    static void AgsImGui.Render()
    This will EndFrame and proceed to generate drawing instructions.


  • AgsImGui.GetStyle

    Code: [Select]
    static ImGuiStyle* AgsImGui.GetStyle()
    Gets the Style customization use in AgsImGui. Check ImGuiStyle for more information.


  • AgsImGui.SetStyle

    Code: [Select]
    static void AgsImGui.SetStyle(ImGuiStyle* imGuiStyle)
    Sets the Style customization use in AgsImGui. Check ImGuiStyle for more information.

    Code: Adventure Game Studio
    1. ImGuiStyle* style = AgsImGui.GetStyle();
    2. style.Alpha = 0.5
    3. style.Colors[eImGuiCol_PopupBg] = ImVec4.Create(1.00, 1.00, 1.00, 1.00); //white
    4. AgsImGui.SetStyle(style);
    5.  



    Demo, Debug, Information

  • AgsImGui.GetVersion

    Code: [Select]
    static String AgsImGui.GetVersion()
  • AgsImGui.ShowDemoWindow

    Code: [Select]
    static void AgsImGui.ShowDemoWindow()
  • AgsImGui.ShowAboutWindow

    Code: [Select]
    static void AgsImGui.ShowAboutWindow()
  • AgsImGui.ShowMetricsWindow

    Code: [Select]
    static void AgsImGui.ShowMetricsWindow()
  • AgsImGui.ShowUserGuide

    Code: [Select]
    static void AgsImGui.ShowUserGuide()


    Windows

  • AgsImGui.BeginWindow

    Code: [Select]
    static AgsImGui.ImGuiBeginWindow BeginWindow(String name, bool has_close_button = 0, ImGuiWindowFlags flags = 0)
  • AgsImGui.EndWindow

    Code: [Select]
    static void EndWindow()


    Child Windows

  • AgsImGui.BeginChild

    Code: [Select]
    static bool BeginChild(String str_id, int width = 0, int height = 0, bool border = false, ImGuiWindowFlags flags = 0)
    Child Windows. Always call a matching EndChild() for each BeginChild() call, regardless of its return value. Child windows can embed their own child.

  • AgsImGui.EndChild

    Code: [Select]
    static void EndChild()
    Pop child window from the stack.



    Item/Widgets Utilities

    Most of the functions are referring to the last/previous item we submitted.

  • AgsImGui.IsItemHovered

    Code: [Select]
    static bool AgsImGui.IsItemHovered(ImGuiHoveredFlags flags = 0)
    Is the last item hovered? (and usable, aka not blocked by a popup, etc.). You can specify a flag for more options.

    static bool IsItemHovered(ImGuiHoveredFlags flags = 0)

  • AgsImGui.IsItemActive

    Code: [Select]
    static bool AgsImGui.IsItemActive()
    Is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item.)

  • AgsImGui.IsItemFocused

    Code: [Select]
    static bool AgsImGui.IsItemFocused()
    Is the last item focused for keyboard navigation?

  • AgsImGui.IsItemVisible

    Code: [Select]
    static bool AgsImGui.IsItemVisible()
    Is the last item visible? (items may be out of sight because of clipping/scrolling)

  • AgsImGui.IsItemEdited

    Code: [Select]
    static bool AgsImGui.IsItemEdited()
    Did the last item modify its underlying value this frame? or was pressed? This is generally the same as the bool return value of many widgets.

  • AgsImGui.IsItemActivated

    Code: [Select]
    static bool AgsImGui.IsItemActivated()
    Was the last item just made active (item was previously inactive).

  • AgsImGui.IsItemDeactivated

    Code: [Select]
    static bool AgsImGui.IsItemDeactivated()
    Was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing.

  • AgsImGui.IsItemDeactivatedAfterEdit

    Code: [Select]
    static bool AgsImGui.IsItemDeactivatedAfterEdit()
    Was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing.

  • AgsImGui.IsItemToggledOpen

    Code: [Select]
    static bool AgsImGui.IsItemToggledOpen()
    Was the last item open state toggled? set by TreeNode().

  • AgsImGui.IsAnyItemHovered

    Code: [Select]
    static bool AgsImGui.IsAnyItemHovered()
    is any item hovered?

  • AgsImGui.IsAnyItemActive

    Code: [Select]
    static bool AgsImGui.IsAnyItemActive()
    is any item active?

  • AgsImGui.IsAnyItemFocused

    Code: [Select]
    static bool AgsImGui.IsAnyItemFocused()
    is any item focused?

  • AgsImGui.IsWindowAppearing

    Code: [Select]
    static bool AgsImGui.IsWindowAppearing()
    'current window' = the window we are appending into while inside a Begin()/End() block.

  • AgsImGui.IsWindowCollapsed

    Code: [Select]
    static bool AgsImGui.IsWindowCollapsed()
    return true when window is collapsed. Use this between Begin and End of a window.

  • AgsImGui.IsWindowFocused

    Code: [Select]
    static bool AgsImGui.IsWindowFocused(ImGuiFocusedFlags flags=0)
    is current window focused? or its root/child, depending on flags. see flags for options. Use this between Begin and End of a window.

  • AgsImGui.IsWindowHovered

    Code: [Select]
    static bool AgsImGui.IsWindowHovered(ImGuiHoveredFlags flags=0)
    is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. Use this between Begin and End of a window.



    Widgets: Text

  • AgsImGui.Text

    Code: [Select]
    static void AgsImGui.Text(String text)
    Draws a string of text.

  • AgsImGui.TextColored

    Code: [Select]
    static void AgsImGui.TextColored(int ags_color, String text)
    shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor();

  • AgsImGui.TextDisabled

    Code: [Select]
    static void AgsImGui.TextDisabled(String text)
    shortcut for PushStyleColor(ImGuiCol[cur]Text, style.Colors[ImGuiCol[/cur]TextDisabled]); Text(fmt, ...); PopStyleColor();

  • AgsImGui.TextWrapped

    Code: [Select]
    static void AgsImGui.TextWrapped(String text)
    shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();.

  • AgsImGui.LabelText

    Code: [Select]
    static void AgsImGui.LabelText(String label, String text)
    Display text+label aligned the same way as value+label widgets .

  • AgsImGui.Bullet

    Code: [Select]
    static void AgsImGui.Bullet(String text)
    Draws a bullet and a string of text. Shortcut for Bullet()+Text().



    Widgets: Main

    Most widgets return true when the value has been changed or when pressed/selected.

    You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state.

  • AgsImGui.Button

    Code: [Select]
    static bool AgsImGui.Button(String label, int width = 0, int height = 0)
    Creates a button. Returns true while button is pressed.

  • AgsImGui.SmallButton

    Code: [Select]
    static bool AgsImGui.SmallButton(String label)
    Creates a button with no padding to be easier to embed within text. Returns true while button is pressed.

  • AgsImGui.Image

    Code: [Select]
    static void AgsImGui.Image(int sprite_id)
    Create an image with passed sprite ID.

  • AgsImGui.ImageButton

    Code: [Select]
    static bool AgsImGui.ImageButton(int sprite_id)
    Create a button with an image with passed sprite ID. Returns true while button is pressed.

  • AgsImGui.ArrowButton

    Code: [Select]
    static bool AgsImGui.ArrowButton(String label, ImGuiDir dir)
    Creates a button with an arrow shape. Returns true while button is pressed.

  • AgsImGui.Checkbox

    Code: [Select]
    static bool AgsImGui.Checkbox(String label, bool initial_value)
    Creates a checkbox button. Returns true when button is marked.

  • AgsImGui.RadioButton

    Code: [Select]
    static bool AgsImGui.RadioButton(String label, bool active)
    Creates a radio button. Returns true while button is marked.

  • AgsImGui.Bullet

    Code: [Select]
    static void AgsImGui.Bullet()
    Draw a small circle and keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses .



    Widgets: Selectables

    A selectable highlights when hovered, and can display another color when selected.

  • AgsImGui.Selectable

    Code: [Select]
    static bool AgsImGui.Selectable(String label, bool selected = false, ImGuiSelectableFlags flags = 0, int width = 0, int height = 0)
    bool selected carry the selection state (read-only). When Selectable() is clicked it returns true so you can modify your selection state.



    Widgets: Drag

    CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped and can go off-bounds.

  • AgsImGui.DragFloat

    Code: [Select]
    static float AgsImGui.DragFloat(String label, float value, float min_value = 0, float max_value = 0, float speed = 0, String format = 0)
    Returns the current value of the drag box. Format string uses regular
    Code: [Select]
    "%f" specifiers, so you can use to define how many decimals you want.

  • AgsImGui.DragInt

    Code: [Select]
    static int AgsImGui.DragInt(String label, int value, int min_value = 0, int max_value = 0, float speed = 0, String format = 0)
    Returns the current value of the drag box. Format string uses regular
    Code: [Select]
    "%d", you can use it to specify left most zeroes.



    Widgets: Slider

    CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds.

  • AgsImGui.SliderFloat

    Code: [Select]
    static float AgsImGui.SliderFloat(String label, float value, float min_value = 0, float max_value = 0, String format = 0)
    Returns the current value of the slider. Format string uses regular
    Code: [Select]
    "%f" specifiers, so you can use to define how many decimals you want.

  • AgsImGui.SliderInt

    Code: [Select]
    static int AgsImGui.SliderInt(String label, int value, int min_value = 0, int max_value = 0, String format = 0)
    Returns the current value of the slider. Format string uses regular
    Code: [Select]
    "%d", you can use it to specify left most zeroes.



    Widgets: Input with Keyboard

  • AgsImGui.InputText

    Code: [Select]
    static String AgsImGui.InputText(String label, String text_buffer, int buffer_size, ImGuiInputTextFlags flags =0)
    Pass a string to identify the input field as label, this label is going to be used for ID and can't be empty.

    Remember that we don't save state between frames, so you have to do this yourself by reapplying the output to input as needed.

    This function returns null when the input hasn't changed, and returns a string with all the text, when it has been modified.

    This widget supports Ctrl+Z for undo, Ctrl+X for Cut, Ctrl+C for copy, Ctrl+V for pasting, mouse selection and cursor navigation with arrows.
    Behavior can be modified by passing flags, see the enums section. Flags can be combined with bitwise operations.

    Example:
    Code: Adventure Game Studio
    1. String input_string;
    2. function room_RepExec() {
    3.   AgsImGui.NewFrame();
    4.     // buff
    5.   String out_string = AgsImGui.InputText("type here!",input_string, 128);
    6.   if(out_string!=null) input_string = out_string;
    7.  
    8.   AgsImGui.Render();
    9. }
    10.  
    11.  
    12. function room_Load() {
    13.   input_string = "Hello String!";
    14. }

  • AgsImGui.InputTextMultiline

    Code: [Select]
    static String AgsImGui.InputTextMultiline(String label, String text_buffer, int buffer_size, int width=0, int height=0, ImGuiInputTextFlags flags = 0)
    Same as InputText, but allows controlling the input size and supports multiline text.

  • AgsImGui.InputTextWithHint

    Code: [Select]
    static String AgsImGui.InputTextWithHint(String label, String hint, String text_buffer, int buffer_size, ImGuiInputTextFlags flags = 0)
    Same as InputText, but supports passing an input hint text.



    Widgets: Combobox commands

  • AgsImGui.BeginCombo

    Code: [Select]
    static bool AgsImGui.BeginCombo(String label, String preview_value, ImGuiComboFlags flags = 0);
    The BeginCombo()/EndCombo() allows to manage your contents and selection state however you want it, by creating e.g. Selectable() items.

    Example:
    Code: Adventure Game Studio
    1. bool option1;
    2. bool option2;
    3. if(AgsImGui.BeginCombo("My combo","click me!")){
    4.   option1 = AgsImGui.Selectable("Option 1");
    5.   option2 = AgsImGui.Selectable("Option 2");
    6.   AgsImGui.EndCombo();
    7. }
    8.  

  • AgsImGui.EndCombo

    Code: [Select]
    static void EndCombo()
    Only call EndCombo() if BeginCombo() returns true!



    Widgets: List Boxes commands

  • AgsImGui.BeginListBox

    Code: [Select]
    static bool AgsImGui.BeginListBox(String label, int items_count, int height_in_items = -1);
    The BeginListBox()/EndListBox() allows to manage your contents and selection state however you want it, by creating e.g. Selectable() items.

    Example:
    Code: Adventure Game Studio
    1. bool option1;
    2. bool option2;
    3. if(AgsImGui.BeginListBox("My ListBox",2)){
    4.   option1 = AgsImGui.Selectable("Option 1");
    5.   option2 = AgsImGui.Selectable("Option 2");
    6.   AgsImGui.EndListBox();
    7. }
    8.  

  • AgsImGui.EndListBox

    Code: [Select]
    static void AgsImGui.EndListBox()
    Only call EndListBox() if BeginListBox() returns true!



    Widgets: Trees

    TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents.

  • AgsImGui.TreeNode

    Code: [Select]
    static bool AgsImGui.TreeNode(String label)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreeNodeWithID

    Code: [Select]
    static bool AgsImGui.TreeNodeWithID(String str_id, String text)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreeNodeV

    Code: [Select]
    static bool AgsImGui.TreeNodeV(String str_id, String text)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreeNodeEx

    Code: [Select]
    static bool AgsImGui.TreeNodeEx(String label, ImGuiTreeNodeFlags flags = 0)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreeNodeExWithID

    Code: [Select]
    static bool AgsImGui.TreeNodeExWithID(String str_id, ImGuiTreeNodeFlags flags, String text)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreeNodeExV

    Code: [Select]
    static bool AgsImGui.TreeNodeExV(String str_id, ImGuiTreeNodeFlags flags, String text)
    Show the contents and call TreePop() at the end, if this returns true.

  • AgsImGui.TreePush

    Code: [Select]
    static void AgsImGui.TreePush(String str_id)
    ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired.

  • AgsImGui.TreePop

    Code: [Select]
    static void AgsImGuiTreePop()
    ~ Unindent()+PopId().

  • AgsImGui.GetTreeNodeToLabelSpacing

    Code: [Select]
    static float AgsImGui.GetTreeNodeToLabelSpacing()
    Horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode.

  • AgsImGui.CollapsingHeader

    Code: [Select]
    static bool AgsImGui.CollapsingHeader(String label, ImGuiTreeNodeFlags flags = 0)
    If returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop().



    Tooltips

    Tooltip are windows following the mouse which do not take focus away.

    Remember we can only have one active tooltip at all times, and the last one called is the active one.

  • AgsImGui.BeginTooltip

    Code: [Select]
    static void AgsImGui.BeginTooltip()
    Begin/append a tooltip window. to create full-featured tooltip (with any kind of items). Doesn't return nothing.

  • AgsImGui.EndTooltip

    Code: [Select]
    static void AgsImGui.EndTooltip()
    Always call after a BeginTooltip block!

  • AgsImGui.SetTooltip

    Code: [Select]
    static void AgsImGui.SetTooltip(String text)
    Set a text-only tooltip, typically use with AgsImGui.IsItemHovered(). Override any previous call to SetTooltip().

    Example:
    Code: Adventure Game Studio
    1. AgsImGui.Button("Clicks for nothing!");
    2. if(AgsImGui.IsItemHovered()) AgsImGui.SetTooltip("Button is hovered!");
    3.  
    4. [big]
    [/big]

    Popups and Modals

  • AgsImGui.OpenPopup

    Code: [Select]
    static void AgsImGui.OpenPopup(String str_id)
    call to mark popup as open (don't call every frame!). Popups are closed when user click outside, or if CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.

    Popup identifiers are relative to the current ID-stack.

    Example:
    Code: Adventure Game Studio
    1. // If the button is in the Window, this code goes inside the window.
    2. if(AgsImGui.BeginPopup("my_popup")){
    3.   AgsImGui.Text("This is a popup");
    4.   AgsImGui.EndPopup();
    5. }
    6. if(AgsImGui.Button("open popup"))
    7. {
    8.   AgsImGui.OpenPopup("my_popup");
    9. }
    10.  

  • AgsImGui.BeginPopup

    Code: [Select]
    static bool AgsImGui.BeginPopup(String str_id, ImGuiWindowFlags flags = 0)
    Return true if the popup is open, and you can start outputting to it.
    Only call EndPopup() if BeginPopup() returns true!

    Generally you will want to run this on every frame, and it will return true once the popup has been made open,
    and return false again once it's closed.

  • AgsImGui.BeginPopupModal

    Code: [Select]
    static bool AgsImGui.BeginPopupModal(String name, bool has_close_button = 0, ImGuiWindowFlags flags = 0)
    Modal dialog, a regular window with title bar, block interactions behind the modal window, and you can't close the
     modal window by clicking outside.

  • AgsImGui.EndPopup

    Code: [Select]
    static void AgsImGui.EndPopup()
    Only call EndPopup() if BeginPopupXXX() returns true!

  • AgsImGui.IsPopupOpen

    Code: [Select]
    static bool AgsImGui.IsPopupOpen(String str_id)
    Return true if the popup is open at the current begin-ed level of the popup stack.

  • AgsImGui.CloseCurrentPopup

    Code: [Select]
    static void AgsImGui.CloseCurrentPopup()
    Close the popup we have begin-ed into. clicking on a MenuItem or Selectable automatically close the current popup.



    Tab Bars, Tabs

  • AgsImGui.BeginTabBar

    Code: [Select]
    static bool AgsImGui.BeginTabBar(String str_id, ImGuiTabBarFlags flags = 0)
    create and append into a TabBar

  • AgsImGui.EndTabBar

    Code: [Select]
    static void AgsImGui.EndTabBar()
    only call EndTabBar() if BeginTabBar() returns true!

  • AgsImGui.BeginTabItem

    Code: [Select]
    static bool AgsImGui.BeginTabItem(String label, bool has_close_button = 0, ImGuiTabItemFlags flags = 0)
    create a Tab. Returns true if the Tab is selected.

  • AgsImGui.EndTabItem

    Code: [Select]
    static void AgsImGui.EndTabItem()
    only call EndTabItem() if BeginTabItem() returns true!

  • AgsImGui.SetTabItemClosed

    Code: [Select]
    static void AgsImGui.SetTabItemClosed(String tab_or_docked_window_label)
    notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.



    Menus

  • AgsImGui.BeginMenuBar

    Code: [Select]
    static bool AgsImGui.BeginMenuBar()
    Append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window).

  • AgsImGui.EndMenuBar

    Code: [Select]
    static void AgsImGui.EndMenuBar()
    Only call EndMenuBar() if BeginMenuBar() returns true!

  • AgsImGui.BeginMainMenuBar

    Code: [Select]
    static bool AgsImGui.BeginMainMenuBar()
    Create and append to a full screen menu-bar.

  • AgsImGui.EndMainMenuBar

    Code: [Select]
    static void AgsImGui.EndMainMenuBar()
    Only call EndMainMenuBar() if BeginMainMenuBar() returns true!

  • AgsImGui.BeginMenu

    Code: [Select]
    static bool AgsImGui.BeginMenu(String label, bool enabled = true)
    Create a sub-menu entry. Only call EndMenu() if this returns true!

  • AgsImGui.EndMenu

    Code: [Select]
    static void AgsImGui.EndMenu()
    Only call EndMenu() if BeginMenu() returns true!

  • AgsImGui.MenuItem

    Code: [Select]
    static bool AgsImGui.MenuItem(String label, String shortcut, bool selected = false, bool enabled = true)
    return true when activated. shortcuts are displayed for convenience but not processed by ImGui at the moment!



    General Helpers

  • AgsImGuiHelper.SetClipboarText

    Code: [Select]
    static void AgsImGuiHelper.SetClipboarText(String text)
  • AgsImGuiHelper.GetClipboarText

    Code: [Select]
    static String AgsImGuiHelper.GetClipboarText()



    ImVec2

    This is a format used to describe either x,y points or zero origin rectangles and other things that can be described as vectors.
    It's used more in the attributes of a ImGuiStyle object.


    ImVec4

    This is a format used to describe either x,y,w,z points or any origin rectangles and other things that can be described as vectors with 4 coordinates.
    It's the preferable format for ImGui Colors, and used a lot for this! It's used more in the attributes of a ImGuiStyle object.


    ImGuiStyle

    A big object used to describe the theme in ImGui.


    Enums

    Code: [Select]
    ImGuiCond
    • eImGuiCond_Always, used when condition should always trigger, is usually the default when the AgImGui API requires
      conditions.
    • eImGuiCond_Once, Set the variable once per runtime session (only the first call with succeed).
    • eImGuiCond_FirstUseEver, Set the variable if the object/window has no persistently saved data (no entry in .ini file).
    • eImGuiCond_Appearing, Set the variable if the object/window is appearing after being hidden/inactive (or the first time).
    Code: [Select]
    ImGuiDir
    • eImGuiDir_Left, left direction.
    • eImGuiDir_Right, right direction.
    • eImGuiDir_Up, up direction.
    • eImGuiDir_Down, down direction.
    Code: [Select]
    ImGuiBeginWindow
    obs: This is exclusive to AgsImGui implementation because in AGS we don't have pointers to primitive types.

    In any cases below, you still have to call AgsImGui.EndWindow().

    • eImGuiBeginWindow_OK, the window is open.
    • eImGuiBeginWindow_Collapsed, the window is collapsed (using the arrow at top left).
    • eImGuiBeginWindow_OK_Closed the window is closed. This value is only returned at mouse release frame, after clicking on close button!
    • eImGuiBeginWindow_Collapsed_Closed the window is both collapsed and closed, rare but theoretically possible.
    Code: [Select]
    ImGuiWindowFlags
    • eImGuiWindowFlags_None (= 0), Default.
    • eImGuiWindowFlags_NoTitleBar, Disable title-bar
    • eImGuiWindowFlags_NoResize, Disable user resizing with the lower-right grip
      ...
    • eImGuiWindowFlags_NoInputs, Disable inputs.
    Check the README on GitHub for the complete enum listing.

    Code: [Select]
    enum ImGuiInputTextFlags
    The enums of this type can be combined with bitwise operators.

    Check the README on GitHub for the complete enum listing.

    Code: [Select]
    enum ImGuiCol_
    The enums of this type can be combined with bitwise operators.

    Used for selecting a specific color from the ImGuiStyle.Colors[] property. An example usage would be:

    Code: Adventure Game Studio
    1. ImGuiStyle* style = ImGui.GetStyle();
    2. style.Colors[eImGuiCol_WindowBg] = ImVec4.Create(1.0, 0.0, 0.0, 0.0);
    3. ImGui.SetStyle(style);
    4.  

    This would use the enum eImGuiCol_WindowBg to access the desired color you want to modify,
    which in the example sets to a red color. Check the README on GitHub for the complete enum listing.



FAQ

How do I make mouse wheel work?

First, make sure you have mouse wheel support enabled in Global Settings.

Then, in some script, add the code below. Note: If the script is a Room script, it will only work in that room.
Code: Adventure Game Studio
  1. void on_mouse_click (int btn){
  2.   if(btn == eMouseWheelNorth){
  3.     AgsImGui.DoMouseWheel(eImGuiDir_Down);
  4.   } else if(btn == eMouseWheelSouth){
  5.     AgsImGui.DoMouseWheel(eImGuiDir_Up);    
  6.   }  
  7. }
  8.  
For now, mouse wheel events are not exposed in the AGS Plugin API, so you have to do it through script. In the future, if this changes, it will be integrated in the plugin.


License and Author

AgsImGui is made by eri0o provided with MIT LICENSE.

Using ocornut Dear ImGui, and also using software renderer with modifications from LAK132, and using other changes to ensure AGS compatibility, provided with MIT License.

Additionally using David Cappelo clip library for providing cross platform clipboard integration, also provided with MIT License.
« Last Edit: 07 Jun 2020, 20:02 by eri0o »

It's really great tool!!
You're so awesome @eri0o
My official site: http://www.pershaland.ir/

I just tried the demo game and it's incredible! I'll try to tinker with it in AGS tomorrow.

You're making some really impressive plugins and modules!

eri0o

I am happy you guys liked it! This is not designed to make pretty stuff, but should help build useful tools!

It doesn't have actual docs, the original implementation is documented alongside the code, so the things I wrote in the README may not be clear enough, so any questions fire up and I will try to make instructions clearer!

If you guys feel you want something to help scripting your debug GUIs that is not there, there's either a chance it's there and I forgot to document it, or that I didn't exposed in the API yet.

eri0o



It's possible now to modify colors and other Theme configurations. Here's an example:

Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.  
  4.   ImVec4* white = ImVec4.Create(1.00, 1.00, 1.00, 1.00);
  5.   ImVec4* transparent = ImVec4.Create(0.00, 0.00, 0.00, 0.00);
  6.   ImVec4* dark = ImVec4.Create(0.00, 0.00, 0.00, 0.20);
  7.   ImVec4* darker = ImVec4.Create(0.00, 0.00, 0.00, 0.50);
  8.  
  9.   ImVec4* background = ImVec4.Create(0.95, 0.95, 0.95, 1.00);
  10.   ImVec4* text = ImVec4.Create(0.10, 0.10, 0.10, 1.00);
  11.   ImVec4* border = ImVec4.Create(0.64, 0.60, 0.60, 1.00);
  12.   ImVec4* grab = ImVec4.Create(0.69, 0.69, 0.69, 1.00);
  13.   ImVec4* header = ImVec4.Create(0.86, 0.86, 0.86, 1.00);
  14.   ImVec4* active = ImVec4.Create(0.90, 0.47, 0.64, 1.00);
  15.   ImVec4* hover = ImVec4.Create(0.40, 0.87, 0.84, 0.20);
  16.  
  17.   AgsImGui.StyleColorsLight();
  18.  
  19.   ImGuiStyle* style = AgsImGui.GetStyle();
  20.  
  21.   style.Colors[eImGuiCol_Text] = text;
  22.   style.Colors[eImGuiCol_WindowBg] = background;
  23.   style.Colors[eImGuiCol_ChildBg] = background;
  24.   style.Colors[eImGuiCol_PopupBg] = white;
  25.  
  26.   style.Colors[eImGuiCol_Border] = border;
  27.   style.Colors[eImGuiCol_BorderShadow] = transparent;
  28.  
  29.   style.Colors[eImGuiCol_Button] = header;
  30.   style.Colors[eImGuiCol_ButtonHovered] = hover;
  31.   style.Colors[eImGuiCol_ButtonActive] = active;
  32.  
  33.   style.Colors[eImGuiCol_FrameBg] = white;
  34.   style.Colors[eImGuiCol_FrameBgHovered] = hover;
  35.   style.Colors[eImGuiCol_FrameBgActive] = active;
  36.  
  37.   style.Colors[eImGuiCol_MenuBarBg] = header;
  38.   style.Colors[eImGuiCol_Header] = header;
  39.   style.Colors[eImGuiCol_HeaderHovered] = hover;
  40.   style.Colors[eImGuiCol_HeaderActive] = active;
  41.  
  42.   style.Colors[eImGuiCol_CheckMark] = text;
  43.   style.Colors[eImGuiCol_SliderGrab] = grab;
  44.   style.Colors[eImGuiCol_SliderGrabActive] = darker;
  45.  
  46.   style.Colors[eImGuiCol_ScrollbarBg] = header;
  47.   style.Colors[eImGuiCol_ScrollbarGrab] = grab;
  48.   style.Colors[eImGuiCol_ScrollbarGrabHovered] = dark;
  49.   style.Colors[eImGuiCol_ScrollbarGrabActive] = darker;
  50.  
  51.   AgsImGui.SetStyle(style);
  52. }
  53.  

With this you can completely customize the experience of AgsImGui which should make easier to use it for Gameplay purposes.

https://streamable.com/gsrwmb

Also, this release adds Tree entries, which are powerful to create debug GUIs to modify complex objects.

Unfortunately, AGS Forums are limited to 30001 characters per Post, so the top entry can't contain full API documentation anymore.

Please reach to the docs in GitHub for information on the available elements in the AgsImGui Plugin API: github.com/ericoporto/agsimgui
« Last Edit: 07 Jun 2020, 20:15 by eri0o »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
That is very cool video.  (nod)  :-D
There are those who believe that life here began out there...