[REL]In Game Browser V2.0.2

Discussion in 'Released Mods' started by someonewhoisnobody, March 2, 2014.

  1. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    In Game Browser 2.0.1
    Completely Rewritten

    In Game Browser adds an internet browser into PA. This allows you to browse the internet while you play PA.

    Main Features
    • Complete Tab System
    • Saved tab states
    • Complete modder API

    Complete Tab System
    In Game Browser 2.0 features a new system, tabs. In previous versions it was only possible to have one window open, this meant you could not browse more than 1 page at a time. Now with In Game Browser 2.0 the idea of tabs has been introduced.

    Tabs allow the user to have completely separate web pages open, in completely separate windows. Each tab can be closed or just minimized.

    To manage all these new tabs a new feature has been added in called the tabs bar. This is a new item on the left side of the Uberbar that allows you to manage your open tabs and create new tabs. The tab bar will always be present.

    [​IMG]
    Example of having more than one tab open

    [​IMG]
    The tab bar, where you can control your open tabs, always in the Uberbar
    Saved Tab States
    In Game Browser 2.0 now has the ability to completely save tabs. Between UI pages or when you close the game, your In Game Browser tabs will be saved.

    In Game Browser 2.0 saves:
    • Tab Name
    • Tab URL
    • Tab Position
    • Tab Size
    • Tab State(Open, or minimized)

    Minor Features
    • 'X-Frame-Options' error detection
      • Sometimes websites set an option on their server that blocks the technology used in In Game Browser. In previous versions the only way to tell if this was the case was to go into the debug console and look for an error. With In Game Browser 2.0 if a website blocks the browser, an error page will show.
    • Start page twitch streams open in a new tab
      • On the start page of PA there is a list of twitch users streaming PA. Without In Game Browser these streams will open in an external browser. With In Game Browser these streams will open up in a new tab
    • New UI
      • The look of In Game Browser 2.0 has change significantly. It is now easier than ever to use.
    Complete Modder API
    In Game Browser now has a new modder API. This allows modders to use In Game Browser's features in their own mod.

    To use In Game Browser in your mod you must first include the In Game Browser scripts.
    Code:
    loadScript('coui://ui/main/shared/js/inGameBrowserCore.js');
    loadScript('coui://ui/main/shared/js/inGameBrowserEngine.js');
    


    You must then create an 'inGameBrowserEngineClient', this client will communicate with the core of the In Game Browser which reside in the 'uberbar' scene.
    Code:
    var inGameBrowserDB = new inGameBrowserDB();
    var inGameBrowserEngineQueueHandler = new inGameBrowserEngineQueueHandler("client", inGameBrowserDB);
    
    var inGameBrowserEngineClient = new inGameBrowserEngineClient(inGameBrowserDB, inGameBrowserEngineQueueHandler);
    

    After you have created an 'inGameBrowserEngineClient' you can make In Game Browser Engine calls. Each engine call has a command name, and a payload. The command name is the name of the engine command to execute, and the payload contains any options needed to execute the command.

    In the In Game Browser API tabs are referred to as 'sessions'. Each engine command will return an object. This return object will contain an 'errors' index and any other information that the command is supposed to return.

    If you do not see a command in the list bellow that you think should be included in the API, PM me

    In Game Browser Engine Commands:
    • Add Session
      • Desc: Creates a new session and opens it
      • Command Name: addSession
      • Arguments needed in payload
        • sessionTitle - The name of the session to create
        • sessionUrl - The Url of the new session
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
        • sessionId - The Id of the session created, use this to run commands on the session
    • Open Session
      • Desc: Opens an existing session
      • Command Name: openSession
      • Arguments needed in payload
        • sessionId - The Id of the session to open
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
    • Close Session
      • Desc: Closes a session, this deletes it. Can not be undone
      • Command Name: closeSession
      • Arguments needed in payload
        • sessionId - The Id of the session to open
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
    • Minimize Session
      • Desc: Minimizes a session, hides it
      • Command Name: minimizeSession
      • Arguments needed in payoad
        • sessionId - The Id of the session to minimize
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
    • Set Session Url
      • Desc: Sets the Url of a session
      • Command Name: setSessionUrl
      • Arguments needed in payload
        • sessionId - The Id of the session to set the Url of
        • sessionUrl - The new Url for the session
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
    • Get Session By Id
      • Desc: Returns a session object
      • Command Name: getSessionById
      • Arguments needed in payload
        • sessionId - The Id of the session to get
      • Arguments returned
        • errors - Any errors that where encountered while executing the command, can be empty
        • session - Session object
          • id - The session id
          • title - The session title
          • url - The session Url
          • active - Is the session active(True = open, False = minimized)
          • position - The position of the session window
            • top - Amount of pixels from the top of the screen
            • left - Amount of pixels from the left of the screen
          • dimensions - The size of the session window
            • width - The width of the session window
            • height - The height of the session window


    Making an engine call
    Code:
    inGameBrowserEngineClient.call(commandName, payload, callback);
    
    Example Call:
    Code:
      var newSessionTitle = "Twitch TV";
      var newSessionUrl = "http://twitch.tv/";
    
      var payload = {
        "sessionTitle": newSessionTitle,
        "sessionUrl": newSessionUrl
      };
    
      inGameBrowserEngineClient.call("addSession", payload, function(name, payload){
        //Do something with data
      });
    
    You will notice that the 3rd argument is a callback function, this function accepts 2 arguments, name, and payload. This is because making an engine call is asynchronous. Meaning the command might not execute right away. The name argument is the name of the command that you called. The payload is the object that the inGameBrowserEngine will return with any errors or other data returned by the function.
    Source on Github

    Change Log
    [2.0.0] - Complete rewritte
    [2.0.1] - Added in sandbox options to browser iframe, this fixes issue of some pages taking over uberbar view
    [2.0.4] - Updated to be compatible with 77582
    Last edited: February 3, 2015
  2. raevn

    raevn Planetary Moderator

    Messages:
    4,233
    Likes Received:
    4,310
  3. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    I actualy had a whole batch of features like remembering dragged position, size which I had to remove for the first release. As part of that version I had added on my own window.api.browser functions for people to use. V1.2 might have them back in.

    Right now people can use these functions
    inGameBrowser.close()
    inGameBrowser.open(URL)
    inGameBrowser.navToPage(URL)
    raevn likes this.
  4. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    Oh this is a sweet mod, nice work!
  5. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    hmm, mod sounds awesome but it didn't install correctly :/

    Attached Files:

  6. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Try installing with PAMM now that I put it in there. I haven't had time to test the install on PAMM but it should work. If it doesn't it is probably something simple to fix.
  7. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    yeah that error message is from PAMM
  8. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    So it only shows up when you install inGameaBrowser? And when does it appear?
  9. raevn

    raevn Planetary Moderator

    Messages:
    4,233
    Likes Received:
    4,310
    The problem is with the folder name - it needs to match the mod ID - eg. remove the "_v1.0" from the folder inside the zip
    Last edited: March 2, 2014
  10. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Oops. Ill fix tomorrow.
  11. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    yeah, only shows up when I hit install from PAMM so it doesn't show up in game
  12. raevn

    raevn Planetary Moderator

    Messages:
    4,233
    Likes Received:
    4,310
    You can manually re-name the folder in your mods folder for now, which should get it to work. Just remove the "_v1.0"
  13. stuart98

    stuart98 Post Master General

    Messages:
    5,937
    Likes Received:
    3,861
    I can't get it to work for some reason. The mod is recognized by PAMM after I change the folder name, but I can't get it to do a thing in game.
  14. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    ditto, not sure if it's conflicting with another mod :/
  15. raevn

    raevn Planetary Moderator

    Messages:
    4,233
    Likes Received:
    4,310
    Found the problem - global mods load before scenes do. That means the version number div - and other divs it tries to hook - don't exist yet when this loads.

    You should separate out the hooking code into a separate file that loads in the appropriate scenes.
  16. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Does document ready not work for this?

    I had 2 minutes before school and I got a undefined in not a function

    Could this be because the mod gets loaded before the document(How would that work)?

    Or is it because the inGameBrowser object is not defined by the time the document ready is called.

    Edit: Is there a way to test a new mod with PAMM before pushing it for the first time.
    Last edited: March 3, 2014
  17. proeleert

    proeleert Post Master General

    Messages:
    1,673
    Likes Received:
    1,638
    Yeah just put your mod in the mods folder with a correct PAMM modinfo.json

    PAMM will automatically find the mod in "Installed Mods".
  18. stawos

    stawos Member

    Messages:
    79
    Likes Received:
    46
    Is this still being developed? It still wasn't working but I love the idea. Can't wait for it to work as intended.
  19. someonewhoisnobody

    someonewhoisnobody Well-Known Member

    Messages:
    657
    Likes Received:
    361
    Once I get home I am going to fixed it. The problem is global_mod_list in PAMM loads before jquery, so $(document).ready does not exist yet, because of this it won't be called and the browser code will never get injected into the window.
    Last edited: March 11, 2014
  20. raevn

    raevn Planetary Moderator

    Messages:
    4,233
    Likes Received:
    4,310
    A simple workaround to get it working is to change the modinfo.json scenes section as follows:

    Code:
        "scenes": {
            "global_mod_list": [
                "coui://ui/alpha/shared/js/inGameBrowser.js",
                "coui://ui/alpha/shared/css/inGameBrowser.css"
            ],
            "start": [
                "coui://ui/alpha/shared/js/inGameBrowser.js",
                "coui://ui/alpha/shared/css/inGameBrowser.css"
            ]
        },
    (eg., copy global_mod_list and change the copy to "start", and add others for any other scenes you want to use the browser in).

    This isn't the ideal way to do it, but it works for now :)

Share This Page