britzl / steamworks-defold

Steamworks support for Defold using the Defold extension system
34 stars 6 forks source link

ISteamFriends -> ActivateGameOverlayToStore #10

Closed abadonna closed 4 years ago

abadonna commented 5 years ago

Hi! Is ActivateGameOverlayToStore missing? Can be a useful to redirect players from demo to purchase full version.

-regards,

britzl commented 5 years ago

I haven't been able to get the GameOverlay functionality to work. There are some requirements mentioned in the official docs:

"Your game does not need to do anything special for the overlay to work, it automatically hooks into any game launched from Steam! While in development and running your game in a debugger, the overlay is loaded when you call SteamAPI_Init. As such you'll need to make sure to call SteamAPI_Init prior to initializing the OpenGL/D3D device, otherwise it won't be able to hook the device creation."

And even if I call SteamAPI_init as early as I can from the extension I'm unable to get the overlay to show.

Excluded API functions can be seen in the generator script: https://github.com/britzl/steamworks-defold/blob/master/generate.py#L18

subsoap commented 4 years ago

Could this be tested by engine team or something somehow? I think this is needed for doing IAP DLC too.

britzl commented 4 years ago

I created a branch where we can do some experiments: https://github.com/britzl/steamworks-defold/tree/overlay

I'd appreciate if you could help me test this. In the branch all of the overlay functions are active. I'd like to see if the overlay will open if the game is launched from Steam.

I also added a steamworks.restart() function which maps to https://partner.steamgames.com/doc/api/steam_api#SteamAPI_RestartAppIfNecessary

subsoap commented 4 years ago

YES! Activating the overlay is working, you just can't do it on main init. Launching from Steam is not necessary.

2019-09-13 17_37_07-Steamworks


    local status, error = pcall(steamworks.init)
    if not status then print("Error: " .. error) return end

    steamworks.set_listener(function(self, e, t)
        print("listener event", e)
        pprint(t)
        if e == "SteamInventoryRequestPricesResult_t" then
            if t.m_result == steamworks.RESULT_OK then
                msg.post("#", "refresh_items")
            else
                print("not ok")
            end
        end
    end)

    print("Is Steam overlay open?", steamworks.utils_is_overlay_enabled())

    --print(steamworks.friends_activate_game_overlay_to_web_page("google.com"))
    steamworks.friends_activate_game_overlay_to_store(348910, 1) -- both of these work (didn't test others)

    print("Is Steam overlay open?", steamworks.utils_is_overlay_enabled())
function init(self)
    local status, error = pcall(steamworks.init)
    if not status then print("Error: " .. error) return end

    steamworks.set_listener(function(self, e, t)
        print(e)
        pprint(t)
    end)

    steamworks.utils_set_overlay_notification_position(2)
end

Is also working to set the notification position to the bottom left so that is useful at least! 💎

0 top left 1 top right 2 bottom left 3 bottom right

britzl commented 4 years ago

Ah, this is great news! I wonder if the new global struct with early init was what made the difference?

The notification positions should be these constants I believe:

britzl commented 4 years ago

Merged to master but haven't done a release yet. Also generated a .script_api so that you get autocomplete for the extension.

britzl commented 4 years ago

Let me know when you've tested some more and I'll make a new release!

subsoap commented 4 years ago

Tested now. All seems well!

britzl commented 4 years ago

https://github.com/britzl/steamworks-defold/releases/tag/1.4.0