Chili:Adding To Game: Difference between revisions

From Spring
Jump to navigationJump to search
add widget to remove default GUI
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Main_Page|Wiki]] < [[Chili|Chili]] < Adding Chili To A Game
== Getting Chili ==
== Getting Chili ==


The Chili repository can be found at [https://github.com/jk3064/chiliui https://github.com/jk3064/chiliui]. There are two ways to add Chili to your game:
The Chili repository can be found at <del>[https://github.com/jk3064/chiliui https://github.com/jk3064/chiliui]</del> [https://github.com/gajop/chiliui https://github.com/gajop/chiliui]. There are three ways to add Chili to your game:


* Include the Chili repository as a git submodule in your project.
* Include the Chili repository as a git submodule in your project.
* Include Chili as a dependency in [[Modinfo.lua|modinfo.lua]], using the line <code>depend={"Chili Framework v2014.0"}</code>.
* Checkout the Chili repository, and manually place the files & subdirs from its /luaui/chili directory into your games /luaui/widgets directory.
* Checkout the Chili repository, and manually place the files & subdirs from its /luaui/chili directory into your games /luaui/widgets directory.


If you are having trouble getting Chili to run, login to the lobby and join the #moddev channel (type /j moddev).  People there will help you figure it out.
If you are having trouble getting Chili to run, login to the lobby and join the #moddev channel (type /j moddev).  People there will help you figure it out.


== Chili interaction with game internals ==
== Chili interaction with game internals ==
Line 13: Line 15:
The Chili library is, basically, a very big widget. It is loaded as a widget by the widget handler, and it makes its functions accessible via WG. This allows 'normal' widgets to use Chili - a widget may call a function from inside WG.Chili, which instructs the chili library to create/modify a particular GUI element.
The Chili library is, basically, a very big widget. It is loaded as a widget by the widget handler, and it makes its functions accessible via WG. This allows 'normal' widgets to use Chili - a widget may call a function from inside WG.Chili, which instructs the chili library to create/modify a particular GUI element.


 
[[Category:Libraries]]
== Hiding the default GUI ==
 
Most games using Chili will remove Springs basic 'default' GUI. This can be done with the following widget - you may need to edit it slightly to match your widget/addon handler.
 
<code><pre>
function widget:GetInfo()
  return {
    name      = "Hides the default interface",
    desc      = "",
    author    = "gajop, Bluestone",
    date      = "",
    license  = "GPL-v2",
    layer    = math.huge;
    enabled  = true,
   
    hidden    = true; -- don't show in the widget selector
    api      = true; -- load before all others?
  }
end
 
function widget:Initialize()
  RegisterGlobal("LayoutButtons", DummyLayoutHandler)
 
  Spring.SendCommands("Console 0")
  Spring.SendCommands("ResBar 0")
  Spring.SendCommands("ToolTip 0")
  Spring.SendCommands("Clock 0")
  Spring.SendCommands("Info 0")
 
  gl.SlaveMiniMap(true)
  gl.ConfigMiniMap(-1,-1,-1,-1)
end
 
local function DummyLayoutHandler(xIcons, yIcons, cmdCount, commands)
  handler.commands  = commands
  handler.commands.n = cmdCount
  handler:CommandsChanged()
  return "", xIcons, yIcons, {}, {}, {}, {}, {}, {}, {}, {}
end
 
function widget:GameSetup()
  return true, true -- sets status instantly to ready & hides the pre-game UI
end
 
</pre></code>

Latest revision as of 11:25, 7 June 2020

Wiki < Chili < Adding Chili To A Game

Getting Chili

The Chili repository can be found at https://github.com/jk3064/chiliui https://github.com/gajop/chiliui. There are three ways to add Chili to your game:

  • Include the Chili repository as a git submodule in your project.
  • Include Chili as a dependency in modinfo.lua, using the line depend={"Chili Framework v2014.0"}.
  • Checkout the Chili repository, and manually place the files & subdirs from its /luaui/chili directory into your games /luaui/widgets directory.

If you are having trouble getting Chili to run, login to the lobby and join the #moddev channel (type /j moddev). People there will help you figure it out.

Chili interaction with game internals

The Chili library is, basically, a very big widget. It is loaded as a widget by the widget handler, and it makes its functions accessible via WG. This allows 'normal' widgets to use Chili - a widget may call a function from inside WG.Chili, which instructs the chili library to create/modify a particular GUI element.