chili questions:

chili questions:

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

chili questions:

Post by smoth »

Drawing lines in chili windows, how do I do them? I need to do lines for a line graph.

How can I specify an alternate texture for a skin element? Say like a chili button, I have the skin's button texture but for this one button, I want to make it different texturally.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: chili questions:

Post by jK »

@LineGraph
You may want to use a simple Control and write your own DrawControl function.

Code: Select all

local graph = {0.1, 0.3, 0.2, 0.4, 0.3, 0.6}

local DrawGraph()
  local graph_n = #data
  if (graph_n < 2) then return end

  for i=1, graph_n do
    local ordinate = data[i]
    gl.Vertex((i - 1)/(graph_n - 1), ordinate)
  end
end

local canvas = Chili.Control:New{
  ...
  DrawControl = function (obj)
    local x = obj.x
    local y = obj.y
    local w = obj.width
    local h = obj.height

    gl.Color(obj.backgroundColor)
    gl.PushMatrix()
      gl.Translate(x, y, 0)
      gl.Scale(w, h, 1)
      gl.BeginEnd(GL.LINES, DrawGraph)
    gl.PopMatrix()
  end
  ...
}
@per control skin
Either define SkinName (if you want to use a diff one), or just override the skin params. The skin params are what you find in skin.lua, e.g.:

Code: Select all

skin.button = {
  TileImageBK = ":cl:tech_button.png",
  TileImageFG = ":cl:empty.png",
  tiles = {22, 22, 22, 22}, --// tile widths: left,top,right,bottom
  padding = {10, 10, 10, 10},

  backgroundColor = {1, 1, 1, 0.7},

  DrawControl = DrawButton,
}
this gets appended to all Chili.Buttons, now each instance can override those if they want, e.g.:

Code: Select all

local btn = Chili.Button:New{
  ...
  TileImageBK = MY_PATH .. "/my_button.png",
  tiles = {7, 7, 7, 7},
  ...
}
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: chili questions:

Post by smoth »

wow, thanks jk!
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: chili questions:

Post by smoth »

Code: Select all

....
		else
			gridchildren[k] = Chili.Button:New{
				parent				= parentPanel,
				TileImageBK 		= ":cl:button_glow.png",
				caption				= '',
				x					= 3+gridXPos,
				y					= 5+gridYPos,
...
So I tried this but it doesn't pick up the texture in the skin dir. Any idea?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: chili questions:

Post by hoijui »

my own chili question...

is it possible to use spring window/screen relative positioning of chili windows? It is very annoying to have to manually reconfigure the whole layout with Ctrl+F11 every time i change spring window size.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: chili questions:

Post by jK »

smoth wrote:So I tried this but it doesn't pick up the texture in the skin dir. Any idea?
Already answered in chat. Skins get their paths autoexpanded, so when you override them you need to define the full path.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: chili questions:

Post by jK »

hoijui wrote:my own chili question...
is it possible to use spring window/screen relative positioning of chili windows? It is very annoying to have to manually reconfigure the whole layout with Ctrl+F11 every time i change spring window size.
Chili supports relative & absolute constraints.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: chili questions:

Post by hoijui »

hmm ok...
i have tried to find a related option in ZK interface options, but there seems to be none. i hope it is clear what i am asking for...
when i place the unit info window into the lower-left corner, i want it to have 100% y and 0% x coordinates (don't know where sure where the origin is in chili, but you know what i mean), so it would always stay in that corner, no matter how i resize the screen. this should be the default (docking status had to be remembered, so that would override the coordinates).
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: chili questions:

Post by knorke »

appearently it is as easy as
x = '50%',
y = '50%',
http://springrts.com/wiki/Lesson_2_:_Dy ... el_content

Also the threads by that sunspot guy might be interessting.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: chili questions:

Post by Google_Frog »

It's not a simple fix for ZK because Selections breaks the UI rules and is not properly scalable. Docking would need changing to support it.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: chili questions:

Post by smoth »

jK wrote:
smoth wrote:So I tried this but it doesn't pick up the texture in the skin dir. Any idea?
Already answered in chat. Skins get their paths autoexpanded, so when you override them you need to define the full path.
yeah still working on that. I cannot figure out how to make the skinhandler vars accessible or call the functions in it. I wish I knew how but I don't understand what you are doing nor can I spend all sunday figuring exactly how chili uses the file.

So far I have done this:

Code: Select all

local CHILI_DIRNAME = LUAUI_DIRNAME.."Widgets/chili/"

local skinFolder = CHILI_DIRNAME .. "Skins/"
now I just have to find out what my current skin name is and be done with it.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: chili questions:

Post by jK »

try

Code: Select all

local skinFolder = Chili.SkinHandler.defaultSkin.info.dir
or even better

Code: Select all

local skinName = "GundamSkinXYZ"
local skinFolder = Chili.SkinHandler.knownSkins[skinName:lower()].info.dir
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: chili questions:

Post by smoth »

seems I cannot access Chili. until update() why is that? I know it's old-school but I like to put var declarations and initializations at the top of my source file.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: chili questions:

Post by jK »

Code: Select all

local Chili

function widget:Initialize()
...
  Chili = WG.Chili
...
end
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: chili questions:

Post by smoth »

I see. thanks!
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: chili questions:

Post by hoijui »

Google_Frog wrote:It's not a simple fix for ZK because Selections breaks the UI rules and is not properly scalable.
I don't understand this one... selections when in Ctrl+F11 mode?
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: chili questions:

Post by Google_Frog »

The elements of the unit selections box that appears above the command menu when units are selected do not resize with the box. The minimum size is the default size and also the only usable size.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: chili questions:

Post by hoijui »

ahh i see, i see. so far, i was not considering the size of windows to scale aswell, only the position. i guess for some windows, scaling them makes no sense, and for others it would make more sense then not scaling them.
Post Reply

Return to “Lua Scripts”