Add tooltips to main menu subgames button bar
authorWuzzy <almikes@aol.com>
Sun, 12 Oct 2014 17:50:33 +0000 (19:50 +0200)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Sun, 9 Nov 2014 08:38:43 +0000 (09:38 +0100)
builtin/fstk/buttonbar.lua
builtin/mainmenu/tab_singleplayer.lua

index 769bfb0bead60e5f7436addec84190f7fc61830d..9a9ec999bcac50f06f513c38bd28fd1a7274cebb 100644 (file)
@@ -57,10 +57,10 @@ local function buttonbar_formspec(self)
                end
                        
                formspec = formspec ..
-                       string.format("image_button[%f,%f;%f,%f;%s;%s;%s;true;%s]",
+                       string.format("image_button[%f,%f;%f,%f;%s;%s;%s;true;%s]tooltip[%s;%s]",
                                        btn_pos.x, btn_pos.y, self.btn_size, self.btn_size,
                                        self.buttons[i].image, btn_name, self.buttons[i].caption,
-                                       borders)
+                                       borders, btn_name, self.buttons[i].tooltip)
                else
                        --print("end of displayable buttons: orientation: " .. self.orientation)
                        --print( "button_end: " .. (btn_pos.y + self.btn_size - (self.btn_size * 0.05)))
@@ -140,11 +140,12 @@ local buttonbar_metatable = {
 
        delete = function(self) ui.delete(self) end,
        
-       add_button = function(self, name, caption, image)
+       add_button = function(self, name, caption, image, tooltip)
                        if caption == nil then caption = "" end
                        if image == nil then image = "" end
+                       if tooltip == nil then tooltip = "" end
                        
-                       table.insert(self.buttons,{ name=name, caption=caption, image=image})
+                       table.insert(self.buttons,{ name=name, caption=caption, image=image, tooltip=tooltip})
                        if self.orientation == "horizontal" then
                                if ( (self.btn_size * #self.buttons) + (self.btn_size * 0.05 *2)
                                        > self.size.x ) then
index 8c6ab91bbfa794c234c8f2fbdef3c55d926bebe3..1f96a85dba288eadc703002a2679b48c6961b214 100644 (file)
@@ -53,6 +53,7 @@ local function singleplayer_refresh_gamebar()
                
                local image = nil
                local text = nil
+               local tooltip = core.formspec_escape(gamemgr.games[i].name)
                
                if gamemgr.games[i].menuicon_path ~= nil and
                        gamemgr.games[i].menuicon_path ~= "" then
@@ -69,7 +70,7 @@ local function singleplayer_refresh_gamebar()
                                text = text .. "\n" .. part3
                        end
                end
-               btnbar:add_button(btn_name, text, image)
+               btnbar:add_button(btn_name, text, image, tooltip)
        end
 end