Page 1 of 1
chili questions:
Posted: 26 Sep 2011, 19:13
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.
Re: chili questions:
Posted: 27 Sep 2011, 03:28
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},
...
}
Re: chili questions:
Posted: 27 Sep 2011, 03:51
by smoth
wow, thanks jk!
Re: chili questions:
Posted: 01 Oct 2011, 23:27
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?
Re: chili questions:
Posted: 02 Oct 2011, 09:35
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.
Re: chili questions:
Posted: 02 Oct 2011, 10:27
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.
Re: chili questions:
Posted: 02 Oct 2011, 10:28
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.
Re: chili questions:
Posted: 02 Oct 2011, 12:12
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).
Re: chili questions:
Posted: 02 Oct 2011, 12:44
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.
Re: chili questions:
Posted: 02 Oct 2011, 15:30
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.
Re: chili questions:
Posted: 03 Oct 2011, 01:35
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.
Re: chili questions:
Posted: 03 Oct 2011, 01:41
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
Re: chili questions:
Posted: 03 Oct 2011, 01:49
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.
Re: chili questions:
Posted: 03 Oct 2011, 01:51
by jK
Code: Select all
local Chili
function widget:Initialize()
...
Chili = WG.Chili
...
end
Re: chili questions:
Posted: 03 Oct 2011, 02:16
by smoth
I see. thanks!
Re: chili questions:
Posted: 03 Oct 2011, 09:28
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?
Re: chili questions:
Posted: 03 Oct 2011, 14:12
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.
Re: chili questions:
Posted: 03 Oct 2011, 16:22
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.