New GUI scripting concepts and foundation

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
User avatar
thomson
Posts: 337
Joined: Thu Sep 13, 2012 9:55 pm
Location: R'lyeh
Contact:

Re: New GUI scripting concepts and foundation

Post by thomson »

I had a discussion with mahric and we agreed on general goals of merge of the grimwidgets and Dialog code from LotNR. I started working on this. Some files from Dialog are already here. There are 3 new dialogs that can be used, but they are only loosely integrated with grimwidgets. This is definitely an early work in progress. Feel free to look at the code, but please don't complain that there's too much duct tape ;)
[MOD] Eye of the Beholder: Waterdeep sewers forum sources; Grimtools (LoG1 -> LoG2 converter) sources
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: New GUI scripting concepts and foundation

Post by Xanathar »

I love duct tape :lol:

And I'm sorry that I'm not contributing enough to this :(
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
User avatar
thomson
Posts: 337
Joined: Thu Sep 13, 2012 9:55 pm
Location: R'lyeh
Contact:

Re: New GUI scripting concepts and foundation

Post by thomson »

As Diarmuid pointed out, the whole grimwidgets framework overlaps to some degree with the GUI dialogs done by Mahric. After chatting with Mahric about priorities and desired functionalities, we agree that merge of both approaches is possible.

Here's the *early* result:
SpoilerShow
Image
Note that one of the buttons (Sancsaron) is slightly lighter, because cursor hovered over it (yes, buttons are cursor sensitive).

The code allows creating simple dialog boxes (informational, yes/no, simple buttons) with a single call, so it will be easy for use for modders. On the other hand, more advanced users have much better control - you can create window with additional elements stacked inside or one next to each other, buttons react to cursor moving over them etc.

Grimrock style textured buttons are there, just the screenshot doesn't show it.

The long term plan is to finish the integration with grimwidgets and then start adapting grimwidgets in projects that may be interested. Legend of the Northern Realms and EOB: Waterdeep sewers are two projects that are interested for sure, but I think others may be interested as well.
[MOD] Eye of the Beholder: Waterdeep sewers forum sources; Grimtools (LoG1 -> LoG2 converter) sources
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: New GUI scripting concepts and foundation

Post by JKos »

Those dialogs look great, a really nice addition.

I also made a higher level widget: a general purpose book (it's not perfect yet but works)

Screenshot
https://docs.google.com/file/d/0B7cR7sc ... 91dDQ/edit

simple usage example

Code: Select all

local book = gw_book.create('my_book',30,30)
book:addPageHeader(1,'Header for the first page') -- adds text to the top of the 1st page
book:addPageText(1,'Some text' here') -- adds text below the previous header
book:addPageImage(2,'/mod_assets/some/image.tga',200,200) -- adds an image to the 2nd page (width and height must be specified)
gw.addElement(book)
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
thomson
Posts: 337
Joined: Thu Sep 13, 2012 9:55 pm
Location: R'lyeh
Contact:

Re: New GUI scripting concepts and foundation

Post by thomson »

The book looks super useful - spellbook, questlog or a diary. So many useful applications! Great work.

I have reimplemented gw_events module. It allows you to create scripted events that are based on series of dialogue boxes. You can define states and actions allowed in those states. For example, let's assume a scenario, where you meet a wounded dwarf. Once you approach it, you can heal him or leave him. If healed, he asks if he can join you party. You can accept or reject his offer.

Here's example code that creates such encounter:

Code: Select all


-- List of available states. First field is a state name. The second is its description. Every event start with the first state listed.
states = {
  { "init",     "An injured dwarf lies on the ground before you." }, 
  { "healed",   "Having regained his strength, the dwarf thanks you and wants to join you party." },
  { "join",     "As Taghor joins your party he says: Let's go kick some asses!" }
}

-- This is an optional callback that is executed once specific action is taken
function onHeal()
	hudPrint("Dwarf is now healed!")
        -- Callbacks can return state name to force transition to specific state
	-- return "join"
end

-- This is a list of allowed actions in each state.
actions = {
  { "init",      "healed",   "Tend his wounds", onHeal},
  { "init",      "abort",    "Leave" },
  { "healed",    "join",     "Yes" },
  { "healed",    "end",   "No" },
  { "join", "end", "Continue" }
}
And here's how this looks like in the game: step 1 step 2 step 3
Last edited by thomson on Sat Feb 16, 2013 12:57 pm, edited 1 time in total.
[MOD] Eye of the Beholder: Waterdeep sewers forum sources; Grimtools (LoG1 -> LoG2 converter) sources
User avatar
thomson
Posts: 337
Joined: Thu Sep 13, 2012 9:55 pm
Location: R'lyeh
Contact:

Re: New GUI scripting concepts and foundation

Post by thomson »

Ok, some guys from LotNR are trying to use grimwidgets! We have first users. Yay!
The initial feedback is that installation in existing dungeons is not described anywhere. So this brings us the topic we've managed to avoid so far: documentation. How do you guys want to write documentation with examples? If you do not have better proposals, how about wiki? We could also use grimwiki.net (easier to find for modders) or on github.com (code and doc kept in one place).
[MOD] Eye of the Beholder: Waterdeep sewers forum sources; Grimtools (LoG1 -> LoG2 converter) sources
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: New GUI scripting concepts and foundation

Post by JKos »

I vote for github, and I think we could add the documentation to the README.md like in the github wiki project: https://github.com/github/gollum
It's easy to find and it's part of the project and is available offline too. README.md supports the gollum wiki syntax.

About he installation: I think we should provide a separate installation zip package which contains only the needed scripts. I can do that.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: New GUI scripting concepts and foundation

Post by JKos »

Hmm, I think grimwidgets will conflict with LotNR, because there are parts of the lnr framework in it (like Dialog.lua and Util.lua). But I'm sure you guys can sort it out.
Should we move those required images under the grimwidgets/images folder? This way they wont overwrite with any other images. I really don't want to add lnr or textures folder to the grimwidgets installation zip.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
thomson
Posts: 337
Joined: Thu Sep 13, 2012 9:55 pm
Location: R'lyeh
Contact:

Re: New GUI scripting concepts and foundation

Post by thomson »

JKos wrote:I vote for github, and I think we could add the documentation to the README.md like in the github wiki project: https://github.com/github/gollum
Here you go: https://github.com/xanathar/grimwidgets
I haven't had time to document everything, so I started with simple dialogs and managed to document book so far.
I plan to work on the documentation in a near future. After that I plan to sort our directories as JKos suggested (remove lnr directory completely, move images etc).
[MOD] Eye of the Beholder: Waterdeep sewers forum sources; Grimtools (LoG1 -> LoG2 converter) sources
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: New GUI scripting concepts and foundation

Post by JKos »

thomson wrote: I haven't had time to document everything, so I started with simple dialogs and managed to document book so far.
I plan to work on the documentation in a near future. After that I plan to sort our directories as JKos suggested (remove lnr directory completely, move images etc).
That's a great start, good job. I thought that md files support gollum syntax, but it seems to be slightly different markup called markdown: http://daringfireball.net/projects/markdown/syntax#link
I fixed some broken links from README.md.

I will start documenting the lower level api. Btw. did you notice that you can edit README.md online on the github site? Just wanted to point this out in case you didn't notice it. Much easier that way.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
Post Reply