New GUI scripting concepts and foundation

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
antti
Posts: 688
Joined: Thu Feb 23, 2012 1:43 pm
Location: Espoo, Finland
Contact:

New GUI scripting concepts and foundation

Post by antti »

Here's something I cooked together quickly to test the upcoming GUI features:
Image
It's totally functional but a little bare-bones. :)
Steven Seagal of gaming industry
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Petri consumes glögg and codes with you

Post by JohnWordsworth »

That's awesome. It's all very exciting, especially with the ability to do that only on certain screens and for certain characters. It's going to be super powerful. You could use socketed items and pop stones in them (and then replace the item with a 'sword with green gem') item, add in-game puzzles / close-ups.

What I'm strongly contemplating is a Deck of Many Things... :p
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Petri consumes glögg and codes with you

Post by Xanathar »

I started thinking about building a kind of widget/forms library to help create UIs.

Just the random thoughts I had, dumped here:
  • Ability to show widgets (more than one displayed at a time, non-modal) or forms (one at a time)
  • Monsters and party should be frozen for the duration of the modal forms (through jkos fw hooks ?)
  • Have some kind of declarative syntax like:

    Code: Select all

    myform = 
    { 
         fadein = 0.1, fadeout = 0.1, -- (to understand if feasible modulating pen alpha) 
         { type = "image", x = 10, y = 20, image = "..." },
         { type = "label", id = "xxx", x = 50, y = 50 },
         { type = "button", id = "yyy", x = 10, y = 10, w = 20, h = 10 },
         { type = "portrait" ... },
    }
    
    function yyy_click()
     ... auto called do something
    end
    
    gui.showDialog(myform, self)
    -- or 
    gui.addWidget(myform, self)
    
  • Allow for ownerdraw things, still offering helper methods (to allow pong implementations)
Of course, apart making a broad idea and maybe defining some API, now it's premature.

If anyone wants to jump on this boat and help when the time comes, he/she is welcome!
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
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Petri consumes glögg and codes with you

Post by Diarmuid »

Xanathar, that's exactly what I had in mind above when I spoke of a "graphic library". I'm nowhere near your level of coding skills, but if you lay out the global model, I'll be happy helping to write/test specific functions or widgets.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Petri consumes glögg and codes with you

Post by Xanathar »

Thanks Diarmuid!
Your help is welcome, plus your coding skills are great too!
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
pferguso
Posts: 40
Joined: Tue Nov 06, 2012 6:09 pm

Re: Petri consumes glögg and codes with you

Post by pferguso »

Holy Schmolie! I'm out of it for two days and I miss this?? How totally cool! Do these new features work now, or is there an update to Grimrock coming soon that will have the GUI stuff?
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Petri consumes glögg and codes with you

Post by Xanathar »

is there an update to Grimrock coming soon that will have the GUI stuff?
They are coming (about the same time) when the OS/X version will be released.

It's the first time in my life I'm waiting an OS/X software to be released :lol:
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
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: Petri consumes glögg and codes with you

Post by germanny »

What´s about a Linux version of grimrock? Is it possible or too heavy coding?
Since steam goes to Linux, too!
And they have better framerates by (already ported Left4dead2) as under Windows :twisted: *bg*
Dungeon Master Resource Pack worker and passionated Beer drinker
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Petri consumes glögg and codes with you

Post by JKos »

@Xanathar
That kind of library would be great, but I think we also definitely need some simple standard method of how we develop the gui elements.
I sketched a basic functionality for modular gui 'framework' (yeah, I just love frameworks and standards :) ). It's a framework, not a library, because it defines the way of how some things must be implemented and how they are handled.

Code: Select all

cloneObject{
  name='party'
  ...
onDrawGui = function(g)
	gui.draw(g)
end 
}

script entity: gui

Code: Select all

elements = {}

addElement(element)
	elements[element.id] = element
end

removeElement(id)
	element[id] = nil
end

draw(g)
	for i=1,#elements do
		elements[i]:draw(g)
	end
end
It's really simple as it should be so everybody can understand it and it doesn't add any unnecessary restrictions. But this way we could dynamically add elements to gui or remove them from it and different kind of elements could be rendered in different ways.
The only requirement is that the element object passed to addElement function must have a method named draw and a property named id. If everyone would use this simple script then all created gui elements would be easily used between dungeons.

If we wanted to create a general use dialog element we could do it like this

Code: Select all

 
createDialog(id,text)
	local e = {}
	e.id = id
	e.draw = function(self,g)
		g.color(30,30,30,150)
		g.drawRect(30, 50, 345, 300
		g.drawText(text, 200, 80)
		-- draw button with text
		g.color(128, 128, 128)
		g.drawRect(200, 120, 115, 20)
		g.color(255, 255, 255)
		g.drawText("Ok", 210, 135)
		-- close dialog when the button is pressed
		if g.button("button1", 200, 120, 115, 20) then
			gui.removeElement(self.id)
		end
	end
	return e
end

local dialog = createDialog('hello_dialog_1','Hello grimrockers!')
gui.addElement(dialog)
That dialog object could of course use the graphics library for drawing things. But I think this subject needs it's own thread.

Edit: name -> id
- 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
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: Petri consumes glögg and codes with you

Post by petri »

Immediate mode gui to the rescue :)

E.g. a simple dialog with three buttons:

Code: Select all

function shopMenu()
  local x = 100
  local y = 100

  -- draws a dialog frame
  gui.dialog(x, y, 150, 50)

  x = x + 10
  y = y + 10

  -- draws a button and returns true if the button was pressed
  if gui.button("shop_buy", "Buy", x, y, 100, 20) then
    -- TODO: enter buy dialog
  end
  y = y + 25

  if gui.button("shop_sell", "Sell", x, y, 100, 20) then
    -- TODO: enter sell dialog
  end
  y = y + 25

  if gui.button("shop_exit", "Bye!", x, y, 100, 20) then
    -- TODO: exit shop
  end
  y = y + 25
end
Post Reply