Gspöt - retained GUI lib

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Thu Dec 13, 2012 4:58 pm

Thank you very much for this big fix, it really helps me out!

I understand that it can be tiresome to work on the same thing over a long period of time. With the scrollgroup bug fixed, Gspot is, like, 95% amazing. A pretty good score if you ask me ;) I'll poke around and see if I can't get those things working on my own. :)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Sat Dec 15, 2012 7:50 am

:cool: Double Post :cool:

How do you interact with other instances of Gspot? I want to display the chat system I made on more than one of my screens without having to lose any data or pasting a whole bunch of code. Is that possible :?
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: Gspöt - retained GUI lib

Post by trubblegum » Sat Dec 15, 2012 9:01 am

I might do something like :

Code: Select all

require("Gspot")
love.load = function()
  state = {
    common = {gui = Gspot()},
    menu = {
      gui = Gspot(),
      update = function(this, dt)
          state.common.gui:update(dt)
          this.gui:update(dt)
      end,
      draw = function()
        // you get the idea ..
      end
    },
    world = {gui = Gspot(),
       // these should really inherit from a gamestate class, since they contain identical functions.
    }
  }
  state.current = state.menu
end

love.update = function(dt)
  state.current:update()
end

love.draw = function()
  state.current:draw()
end

love.mousepressed = function()
  // prioritize as you see fit ..
  if state.common.gui.mousein then state.common.gui:mousepress(x, y, button) else state.current.gui:mousepress(x, y, button) end
end

// etc ..
Or you could just group up your elements with functions to construct each group as required (you should be doing this anyway). Pass them a reference to a Gspot instance if you're using more than one at a time, but one gui at a time is probably easier in the long run.

I presume when you built the element you want to interact with, you kept a reference to it, so use it.

User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Sat Dec 15, 2012 6:12 pm

Thanks for the reply, mate. I'm not using a state system in my game. Instead, I am using separate love-like instances for each screen so access to a previous screen's data (such as construction references), without passing it forward, is difficult. I tried passing my chat forward and, as expected, the new instance of Gspot isn't paying it any heed.

I originally had only a single instance of Gspot but my entire gui would show up on every screen, so that wasn't too helpful either... Perhaps a global table filled with each ui group (like you posted above) is the answer.

https://github.com/karai17/love-und-pan ... nt/screens
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: Gspöt - retained GUI lib

Post by trubblegum » Sat Dec 15, 2012 6:56 pm

Karai17 wrote:separate love-like instances
What is this I don't even.

User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Sat Dec 15, 2012 7:13 pm

Magic. :P

Each screen runs in its own love sandbox, controlling the main callbacks (load, update, draw, etc). Have a look through my project's code if you'd like.

https://github.com/karai17/love-und-panzer
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: Gspöt - retained GUI lib

Post by trubblegum » Sat Dec 15, 2012 10:43 pm

Um .. no thanks.

User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Sat Dec 15, 2012 11:20 pm

No need for that :\
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

User avatar
DeltaF1
Citizen
Posts: 64
Joined: Mon Apr 27, 2015 4:12 pm
Location: The Bottom of the Stack
Contact:

Re: Gspöt - retained GUI lib

Post by DeltaF1 » Sat Nov 28, 2015 7:28 pm

Sorry to necro this thread, but as trubblegum hasn't posted here for 3 years, I figured I'd make a post with a slightly updated version of the library. I replaced references to love.screen with love.window, removed the keyrepeat features of the library (I'll probably add these back in updated for 0.9) and tweaked the text input element to use love.textinput instead of love.keypressed (I will also be updating this so that backspace and delete work with utf8 strings properly). I'd make a pull request on github, but trubblegum seems to have dissapeared, so here it is.

The original repository is here
Gspot.lua
Updated for 0.9.x
(36.32 KiB) Downloaded 85 times

User avatar
Karai17
Party member
Posts: 883
Joined: Sun Sep 02, 2012 10:46 pm

Re: Gspöt - retained GUI lib

Post by Karai17 » Sat Nov 28, 2015 7:30 pm

You could fork his repo and continue on with your own forum thread if you want to become the de facto maintainer of the project. :)
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests