The Geyser Layout Manager

Geyser is an object oriented framework for creating, updating and organizing GUI elements within Mudlet.
User avatar
Vadi
Posts: 4643
Joined: Sat Mar 14, 2009 3:13 pm

Re: The Geyser Layout Manager

Post by Vadi » Wed Mar 17, 2010 2:14 pm

Oh. Labels accept html formatting, which is what gauges consist of. So instead of setting the text to "my text", try [[<font color="red">my text</font>]] and such.

sephiel
Posts: 17
Joined: Mon Nov 30, 2009 10:35 am

Re: The Geyser Layout Manager

Post by sephiel » Wed Mar 17, 2010 2:28 pm

That did it! Thanks a bunch :)

tarrant
Posts: 49
Joined: Thu Apr 15, 2010 10:36 pm

Re: The Geyser Layout Manager

Post by tarrant » Sun Apr 18, 2010 8:09 pm

Hi, forgive me if its a stupid question, but i can't get my font size to change in my miniconsole. Here's what i did.

Code: Select all

function Geyser.StatusBar()
	geyserContainer = Geyser.Container:new({
		x = "100%", y = "100%",
		width = "100%", height = "3c",
		name = "StatusBarContainer"})
	local StatusBar = Geyser.MiniConsole:new({
		x = "0px", y = "96.5%",
		width = "100%", height = "2.5c",
		Geyser.MiniConsole:setFontSize (5),
		name = "StatusBar",
		color = "<0,0,0>",},
		StatusBarContainer)
end
Any help/advice would be appreciated.
Thanks.

Naito
Posts: 18
Joined: Thu Aug 12, 2010 1:36 pm

Re: The Geyser Layout Manager

Post by Naito » Wed Aug 25, 2010 10:19 pm

I just started using Geyser(Still in the reading process >.<) I did the Geyser.demo1() and now I don't know how to get rid of the window....

How would I go about getting rid of the Geyser Window?

User avatar
Vadi
Posts: 4643
Joined: Sat Mar 14, 2009 3:13 pm

Re: The Geyser Layout Manager

Post by Vadi » Wed Aug 25, 2010 10:44 pm

restart mudlet

Naito
Posts: 18
Joined: Thu Aug 12, 2010 1:36 pm

Re: The Geyser Layout Manager

Post by Naito » Thu Aug 26, 2010 2:33 pm

I've read over the Doc, and checked the scripts within Geyser itself... I'm still unsure of how to use it.

I tried out the Geyser.demo1() and it didn't really help to explain it to me....

Can anyone give me a quick review of what the commands are and how to use them? I heard that Geyser will be in the new update so I wish to start learning now before it comes out and I'm left in the dust compared to other people ^.^

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: The Geyser Layout Manager

Post by kaeus » Thu Aug 26, 2010 9:09 pm

Just a suggestion for aesthetics of Gauges, in my own Geyser before it was Integrated to Mudlet I modified it so Gauges have a top layer that the echoing is done on, since before it would echo in both the fill and the background (and made it look a bit off IMO).
Code: [show] | [select all] lua

--------------------------------------
--                                  --
-- The Geyser Layout Manager by guy --
--                                  --
--------------------------------------

--- Represents a gauge that can be either vertical or horizontal.
-- @class table
-- @name Geyser.Gauge
-- @field value Percentage value of how "full" the gauge is.
-- @field orientation "horizontal" is the default and creates a horizontal
--                    gauge that fills from left to right. "vertical" creates
--                    a gauge that fills from bottom to top. "goofy" is
--                    horizontal but fills right to left. "batty" is
--                    vertical but fills from top to bottom.
-- @field color Color base for this gauge.  Default is #808080
Geyser.Gauge = Geyser.Container:new({
      name = "GaugeClass",
      value = 100, -- ranges from 0 to 100
      color = "#808080",
      orientation = "horizontal"})

--- Sets the gauge amount.
-- @param currentValue Current numeric value, or if maxValue is ommitted, then
--        it is assumed that currentValue is a value between 0 and 100 and is
--        used to set the gauge.
-- @param maxValue Maximum numeric value.  Optionally nil, see above.
-- @param text The text to display on the gauge, it is optional.
function Geyser.Gauge:setValue (currentValue, maxValue, text)
   -- Use sensible defaults for missing parameters.
   if currentValue < 0 then
      currentValue = 0
   end
   if maxValue then
      self.value = currentValue/maxValue * 100
   else
      self.value = currentValue
   end

   -- Update gauge in the requested orientation
   local shift = tostring(self.value) .. "%"
   if self.orientation == "horizontal" then
      self.front:resize(shift, "100%")
   elseif self.orientation == "vertical" then
      self.front:move("0px", "-" .. shift)
      self.front:resize("100%", "-0px") -- bind to bottom container border
   elseif self.orientation == "goofy" then
      self.front:move("-" .. shift, "0px")
      self.front:resize("-0px", "100%") -- bind to right container border
   else -- batty
      self.front:resize("100%", shift)
   end
   
   if text then
      --self.front:echo(text)
      --self.back:echo(text)
		self.top:echo(text)
   end
end

--- Sets the gauge color.
-- @param r The red component, or a named color like "green".
-- @param g the green component, or nil if using a named color.
-- @param b the blue component, or nil if using a named color.
-- @param text The text to display on the gauge, it is optional.
function Geyser.Gauge:setColor (r, g, b, text)
   r,g,b = Geyser.Color.parse(r,g,b)
   self.front:setColor(r,g,b)
   self.back:setColor(r,g,b,100)
   if text then
      --self.front:echo(text)
      --self.back:echo(text)
		self.top:echo(text)
   end
end

--- Sets the text on the gauge.
-- @param text The text to set.
function Geyser.Gauge:setText (text)
   if text then
      --self.front:echo(text)
      --self.back:echo(text)
		self.top:echo(text)
   end
end


-- Save a reference to our parent constructor
Geyser.Gauge.parent = Geyser.Container

-- Overridden constructor
function Geyser.Gauge:new (cons, container)
   -- Initiate and set gauge specific things
   cons = cons or {}
   cons.type = cons.type or "gauge"

   -- Call parent's constructor
   local me = self.parent:new(cons, container)

   -- Set the metatable.
   setmetatable(me, self)
   self.__index = self

   -----------------------------------------------------------
   -- Now create the Gauge using primitives and tastey classes

   -- Set up the constraints for the front label, the label that changes size to
   -- indicated levels in the gauges.
   local front = Geyser.copyTable(cons)
   front.name = me.name .. "_front"
   front.color = me.color
   front.x, front.y, front.width, front.height = 0,0,"100%","100%"

   -- Set up the constraints for the back label, which is always the size of the gauge.
   local back = Geyser.copyTable(front)
   back.name = me.name .. "_back"
   local br, bg, bb = Geyser.Color.parse(me.color)
   back.color = Geyser.Color.hexa(br,bg,bb,100)

	-- Generate a top layer for text display
	local top = Geyser.copyTable(cons)
	top.name = me.name .. "_top"
   top.color = Geyser.Color.hexa(0,0,0,0)
	top.x, top.y = 0,0

   -- Create back first so that the labels are stacked correctly.
   me.back = Geyser.Label:new(back, me)
   me.front = Geyser.Label:new(front, me)
	me.top = Geyser.Label:new(top, me)
   
   --print("  New in " .. self.name .. " : " .. me.name)
   return me
end

Beliar
Posts: 19
Joined: Fri Apr 22, 2011 12:51 pm

Re: The Geyser Layout Manager

Post by Beliar » Sat Apr 23, 2011 9:40 am

In case anyone is interested i made a class that handles tiling of images.

Here is the code:
Code: [show] | [select all] lua
--------------------------------------
--                                  --
-- The Geyser Layout Manager by guy --
--                                  --
-- TiledImage by beliar             --
--------------------------------------

--- Represents an image that is tiled over a window
-- @class table
-- @name Geyser.TiledImage
-- @field tile_image The path to the image that is to be tiled
-- @field tile_width The width of a single tile
-- @field tile_height The height of a single tile
-- @field tile_alignment Wheter the image should be tiled horizontally or vertically
-- @field start_tile_image Path to an image that should be used as the first tile.
--                      Leave empty if none should be used
-- @field start_tile_width Width if the first tile
-- @field start_tile_height Height of the first tile
-- @field end_tile_image Path to an image that should be used as the last tile.
--                      Leave empty if none should be used
-- @field end_tile_width Width if the last tile
-- @field end_tile_height Height of the last tile
-- Note that the *_tile_width/*_tile_height paramenters only accept numbers, not "px" or "%"

Geyser.TileAlignment = {horizontal=0, vertical=1}
Geyser.TiledImage = Geyser.Window:new({
                name = "TiledImageClass",
                tile_image = "",
                tile_width = 1,
                tile_height = 1,
                tile_alignment = Geyser.TileAlignment.horizontal,
                start_tile_image = "",
                start_tile_width = 1,
                start_tile_height = 1,
                end_tile_image = "",
                end_tile_width = 1,
                end_tile_height = 1
        })

-- Save a reference to our parent constructor
Geyser.TiledImage.parent = Geyser.Window
       
--- Responsible for placing/moving/resizing this window to the correct place/size.
-- Called on window resize events.
function Geyser.TiledImage:reposition ()
        self.parent:reposition()
        self:create_tiles()
end

--- Create the tiles
function Geyser.TiledImage:create_tiles()
        local startPos = 0;
        local width = self:get_width()
        local height = self:get_height()
        local tile_size = 0
        local i = 1
        local use_start_tile = not (self.start_tile_image == "" or self.start_tile_image == nil)
        local use_end_tile = not (self.end_tile_image == "" or self.end_tile_image == nil)
        local size = 0
        local size_add = 0
        for _, image in ipairs(self.images) do
                image:hide()
        end
        self.images = {}
        if use_start_tile then
                local tile = Geyser.Label:new({
                                                                        name=self.name .. "_start_tile",
                                                                        x="0px", y="0px",
                                                                        width=self.start_tile_width, height=self.start_tile_height,
                                                                        },
                                                                        self)
                tile:setBackgroundImage(self.start_tile_image)
                table.insert(self.images, tile)
                if self.tile_alignment == Geyser.TileAlignment.horizontal then
                        startPos = startPos + self.start_tile_width
                        width = width - self.start_tile_width
                else
                        startPos = startPos + self.start_tile_height
                        height = height - self.start_tile_height
                end
        end
       
        if use_end_tile then
                if self.tile_alignment == Geyser.TileAlignment.horizontal then
                        width = width - self.end_tile_width
                else
                        height = height - self.end_tile_height
                end
        end
       
        if self.tile_alignment == Geyser.TileAlignment.horizontal then
                size = width
                size_add = self.tile_width
        else
                size = height
                size_add = self.tile_height
        end
        while startPos + size_add < size do
                local con = {}
                if self.tile_alignment == Geyser.TileAlignment.horizontal then
                        con = {
                                x = startPos, y="0px",
                                width=self.tile_width, height=self.tile_height,
                                name = self.name .. "_tile_" .. i
                                }
                else
                        con = {
                                x = "0px", y=startPos,
                                width=self.tile_width, height=self.tile_height,
                                name = self.name .. "_tile_" .. i
                                }
                end
                local tile = Geyser.Label:new(con, self)
                tile:setBackgroundImage(self.tile_image)
                table.insert(self.images, tile)
                startPos = startPos + size_add
                i = i + 1
        end
       
        local con = {}
        if self.tile_alignment == Geyser.TileAlignment.horizontal then
                local tile_width = width - startPos
                con = {
                        name = self.name .. "_tile_" .. i,
                        x = startPos, y="0px",
                        width=tile_width, height=self.tile_height,
                        }
                startPos = startPos + tile_width
        else
                local tile_height = height - startPos
                con = {
                        x = "0px", y=startPos,
                        width=self.tile_width, height=tile_height,
                        name = self.name .. "_tile_" .. i
                        }
                startPos = startPos + tile_height
        end
        local tile = Geyser.Label:new(con, self)
        tile:setBackgroundImage(self.tile_image)
        table.insert(self.images, tile)

        if use_end_tile then
                local con = {}
                if self.tile_alignment == Geyser.TileAlignment.horizontal then
                        con = {
                                        name=self.name .. "_end_tile",
                                        x=startPos, y="0px",
                                        width=self.end_tile_width, height=self.end_tile_height,
                                        }
                else
                        con = {
                                        name=self.name .. "_end_tile",
                                        x="0px", y=startPos,
                                        width=self.end_tile_width, height=self.end_tile_height,
                                        }
                end
                local tile = Geyser.Label:new(con,self)
                tile:setBackgroundImage(self.end_tile_image)
                table.insert(self.images, tile)
        end
end

function Geyser.TiledImage:new (cons, container)
        -- Initiate and set Window specific things
        cons = cons or {}
        cons.type = cons.type or "tiled_image"

        -- Call parent's constructor
        local me = self.parent:new(cons, container)
        me.images = {}
        -- Set the metatable.
        setmetatable(me, self)
        self.__index = self
        --print(" New in " .. self.name .. " : " .. me.name)
        me:create_tiles()
        return me
end
You can just put this into a script item.

User avatar
Vadi
Posts: 4643
Joined: Sat Mar 14, 2009 3:13 pm

Re: The Geyser Layout Manager

Post by Vadi » Sat Apr 23, 2011 1:44 pm

Hey, thanks. I'll give this a try today and add to Mudlet's default distribution, if you don't protest :)

Beliar
Posts: 19
Joined: Fri Apr 22, 2011 12:51 pm

Re: The Geyser Layout Manager

Post by Beliar » Sat Apr 23, 2011 3:01 pm

Nah, if you think it works good then go ahead

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest