html-like in-game help widget beta 2

html-like in-game help widget beta 2

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

Moderator: Moderators

User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

html-like in-game help widget beta 2

Post by BigHead »

Image Image
Features:
*word wrapping
*vertical scrolling
*easily customizable (background color, size, etc ...) and modification-friendly
*support for "welcome" page that is displayed only the first time user starts the widget
*can be used for fullscreen help as well as in-game windowed unit guide
*there are 6 tags:
<title>
<image> - "floating" is supported
<link> - equivalent to <a href>
<heading> - equivalent to <h1>, <h2> ... you can set the size
<li>
<include> - includes another page eg.:navigation at the bottom

How-to:
Help API widget provides you with four call-outs:
Script.LuaUI.setPageOptions(options) - allows you to change the font size, colors, widget position and many other things
Script.LuaUI.displayPage(page) - displays the page
Script.LuaUI.isHelpVisible() - true if a page is displayed
Script.LuaUI.setWelcomePage(page) - this page will be shown only once
See gui_example_help.lua (it's disabled by default) to see the help in action.

Unit-guide:
For unit guide you should put something like this into drawScreen()

Code: Select all

if onlyOneUnitIsSelected() then
  drawButtonThatWillShowHelpForThatUnit()
end
This widget needs your help!
I lack any talent at designing. That's why the buttons and the window look so bad. There's a simple drawFrame() method which draw everything exept the page content. I need someone to modify that method to make the widget look better.

This is just a beta version. Do not include this into your mod yet!

Report bugs please.
However remember that the syntax is very strict so triple-check your syntax before posting.

Changelog:
beta 1 -> beta 2:
No need to use help.lua anymore. You can now use provided API to display your help pages

Download:
http://www.unknown-files.net/3583/ingame_help_widget/
Last edited by BigHead on 01 Oct 2007, 19:20, edited 6 times in total.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Post by SinbadEV »

Okay, That is teh awesome, I assume the images can either be inline, or float left or right... which is so incredibly simple it's awesome... I'm only marginally confused as to why not use actual HTML keywords but I can assume it's so people don't expect other html things to work.

I'm not sure how dynamic the content your making would be but My Suggestion for A first implementation would be, "Press Some Key While Hovering Over An item to get help on it" Then, for example, if you pressed / while hovering over the build menu it would bring up a Build Menu Help (aka describing how to build, there would be 2 of these, one for inside builders and one for outside builders...) then it would also have a link to help on the unit you were hovering over at the time like
The "Factory" Build Menu

In order to build new unit with this menu just click on one of the images and it will add it to the factories build queue. When all prior units in queue are completed, construction of this unit will begin. New units built by this factory will be assigned the group number and the move, attack, defend and patrol orders of this factory.


Where you looking for specific help on Advanced Kbot Factory?
Where you looking for specific help on Construction Kbot?
Where you looking for general help on Building Units?
Warlord Zsinj
Imperial Winter Developer
Posts: 3742
Joined: 24 Aug 2004, 08:59

Post by Warlord Zsinj »

This really is excellent.

I would probably implement it into my mod so that when you hover your mouse over a buildpic, this pops up near your cursor, and then if you click the window, it pops out with more information.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

It looks like you are trying to expand, would you like to:
- Porc instead
- Build more mexes
- MAEK FLASH!
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Post by Pressure Line »

KDR_11k wrote:It looks like you are trying to expand, would you like to:
- Porc instead
- Build more mexes
- SPAEM FLASH!!!
corrected
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

I do indeed see a tutorial benefitting from this.
Warlord Zsinj
Imperial Winter Developer
Posts: 3742
Joined: 24 Aug 2004, 08:59

Post by Warlord Zsinj »

It appears this has been licensed under GPL; so I'm concerned about using it in my mod. Can anyone clear this up for me?

If I use this in my mod, would that require the entirety of it to be GPL'ed?
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

Just the widget I think. Ask Argh, he'd know
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

SinbadEV:: HTML isn't used becouse current syntax is easier to parse. The widget you suggest is possible. Actualy it's very easy to do. You need to make Widget:KeyPress() function, put TraceScreenRay() inside to determine what mouse cursor is above and finally call displayPage() to show your help. I'm too busy to do it but it's easy enough to be someones first widget.

Warlord Zsinj: It's wrtiten entirely by me so I can make it whatever license you want.

Plans for next version:
After reading the "Communicating between Gadgets" thread I decided to turn it into a custom event. It will be accessible from all lua so you won't have to override help.lua anymore. Next version will expose this method:
Spring.LuaUI.displayPage(page [,options])
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Post by Neddie »

Warlord Zsinj wrote:It appears this has been licensed under GPL; so I'm concerned about using it in my mod. Can anyone clear this up for me?

If I use this in my mod, would that require the entirety of it to be GPL'ed?
Yes.

You can include files to be read by it and download it separately as a widget, changing the protocol to read from elsewhere.

However, yes, it is Bighead's choice.
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

New version is out:
You can use these call-outs from any widget (and propably gadget but I'm not sure) now:
Script.LuaUI.setPageOptions(options) - allows you to change the font size, colors, widget position and many other things
Script.LuaUI.displayPage(page) - displays the page
Script.LuaUI.isHelpVisible() - true if a page is displayed
Script.LuaUI.setWelcomePage(page) - this page will be shown only once

In other words you don't need to modify help.lua anymore. Actually there's no help.lua in this version.

If you have the prevous version installed delete it first!

Download:
http://www.unknown-files.net/3583/ingame_help_widget/
Last edited by BigHead on 04 Oct 2007, 21:42, edited 3 times in total.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Post by jK »

BigHead wrote:Script.LuaUI.isHelpVisible() - true if a page is displayed
Sorry to ask, but did you test this? Iirc Script.Lua* doesn't support return values.
Also the Script.* interface is buggy atm, after you called it in a function it exit this or sometimes continues it with a memory overwrite.

So I would recommend the GG[] table. (you can also overwrite the Script.* interface in the enviroment and then link it to the GG[] table)
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

I noticed some strange behaviour when using Script.LuaUI. However I fixed it after reading this:
Maelstrom wrote:OK, I worked out the problem. It has two parts.

First, global functions can not have more than one argument. If you want to pass more than one argument to a global function, you have to use a table.

Secondly, the global function has to return something. What it returns isn't always guaranteed to return correctly (It appears strings don't return, while tables do).

Just a heads up to whoever else wants to use global functions.
Boolean values return correctly as well.

Edit: Btw yes, I tested it and it works without any probles.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

bighead, to include your widget into gundam what do you require from me?
Saktoth
Zero-K Developer
Posts: 2665
Joined: 28 Nov 2006, 13:22

Post by Saktoth »

KDR_11k wrote:It looks like you are trying to expand, would you like to:
- SPAEM FLASH!!!
- SPAEM FLASH!!!
- SPAEM FLASH!!!
corrected
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

OH SHIT, I just noticed your call for assistance. I will be busy till wed but if I do a pretty skin for this, may I have your permission to use this in gundam?
User avatar
BigHead
Posts: 145
Joined: 12 Jul 2007, 18:55

Post by BigHead »

Of course and remember to post a picture of your work.
Also feel free to ask any questions.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Post by smoth »

Thank you, I will prioritize this above my gundam and td work for the week so I can quickly get this accomplished. I will do my best man. Work starts thursday morning.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Post by Forboding Angel »

I was very disappointed to find out that this doesn't work with the svn versions of spring. Could it be updated perchance? This widget was my baby :/
Error in DrawScreen(): [string "LuaUI/Widgets/gui_help_api.lua"]:669: attempt to index upvalue 'options' (a nil value)
Last edited by Forboding Angel on 30 Nov 2007, 22:47, edited 1 time in total.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Have you seen Quantums CA menu widget?
Post Reply

Return to “Lua Scripts”