Week 9

This week I started towards the goal of getting a working “Create New Item” system into the Steam version of Anarchy Arcade.  A very important part of the Create New Item system is AArcade’s ability to go onto the web and automatically find boxart, wallpapers, and video trailers for the media items that are spawned in it.  This was done in the prototype by the “scrapers.”  In the Steam version, the entire system has been overhauled and expanded into something called Providers.  These changes were necessary to enhance security, expand functionality, and allow user-created addons to be more coherently organized.

A Provider provides many important web-services to the player.  Each provider is usually related to one specific online website or service, such as YouTube or Netflix.  It is written primarily in JavaScript and it may have up to six different functions; however, not every provider needs to have all 6 functions.

Providers are user-created addons, and therefore could possibly be from malicious users.  AArcade carefully loads and executes these six functions only at specific times to provide maximum security.  Certain operations require more security sandboxing than others, and organizing the Providers into these six specific functions helps manage this.

The six functions that a provider may perform are: safeTest, test, scrape, autoScrape, search, and autoSearch.  I will very briefly try to explain what each one of these functions do.  Keep in mind that security was one of the primary concerns when I designed these six functions.  Only providers that you trust should be allowed to perform any of the functions other than safeTest.

In general, a provider is used when ever you click the SPAWN button while looking at a website in the in-game browser.  Some features of the provider, such as search, might also be used when spawning new local files from your hard drive too.

safeTest
The provider analyzes the current URL string of the in-game browser and tries to determine if it can be used on the page or not.  This is a nearly risk-free function because the provider is only given a URL to analyze.  However, it is not always possible to determine if a provider can be used merely by analyzing the URL.

test
The provider analyzes the live webpage that is currently loaded in the in-game browser to determine if it can be used on the page or not.  The provider has full access to the webpage’s JavaScript and DOM.  This allows elements or variables that were created even after the page was initially loaded to be analyzed by the provider to determine if it can be used.

scrape
The provider analyzes the live webpage that is currently loaded in the in-game browser and attempts to construct a complete AArcade Item profile from the information on the page.  The provider has full access to the webpage’s JavaScript and DOM.  The provider is able to prompt the player to choose options, if needed.

autoScrape
The provider analyzes a read-only copy of a webpage’s DOM and attempts to construct a complete AArcade Item profile from the information on the page.  The provider does not have access to any live JavaScript functions or variables, but only the information contained in the static DOM.  This allows for more automation and better security than the powerful scrape function discussed above.

search
The provider loads a live search results page for a specific search term into the in-game browser and analyzes the results to automatically find a match to the media item the player is spawning.  The provider has full access to the webpage’s JavaScript and DOM.  The provider is able to prompt the player to choose options, if needed.

autoSearch
The provider loads a read-only copy of a search results page for a specific search term and analyzes the results to automatically find a match to the media item the player is spawning.  The provider does not have access to any live JavaScript functions or variables, but only the information contained in the static DOM.  Once again, this allows for more automation and better security.

Using these six functions, the Steam version of Anarchy Arcade will be able to offer all the amazing features showcased in the prototype, PLUS many great enhancements & additions, all as user-addon scripts.

Separating the functionality of Anarchy Arcade from the content and services that are used in it has always been the goal of its design.  Providers are a major step towards this goal because they change AArcade from supporting only a few services such as “YouTube & Netflix” to supporting EVERYTHING.  It also makes AArcade more versatile because it is able to out-live the services used in it.  Sure, MySpace is hot stuff now, but one day it might become old news!

AArcade Providers as Chrome Extensions
The Chromium Embedded Framework (CEF) is what powers AArcade behind-the-scenes.  I’ve never used Google Chrome before, so last week it was a pleasant surprise when I learned that extensions for the Google Chrome browser are also written in JavaScript, just like the data-scrapers used in AArcade!  This means I am able to prototype the data-scrapers and the data-scraping system itself as Chrome extensions.

So last week I learned how to write Chrome extensions, and ported the Netflix scraper from the prototype over into the new Provider design.  It’s working great so far!  However, right now it’s all just a bunch of loose JavaScript files.  Like Detective Murphy in the Robocop re-make; just a bunch of vital organs floating around in jars plugged in to each other with tubes.  There is still a lot of work to be done on these organs before I’m ready to build the rib-cage that holds them.  Next week I will be refining the JavaScript implementations of the providers design so that it can play nicely with the other systems I have been working on.

Google’s JPEG
So, there’s a new image format in town.  Apparently it’s been around for a while, but I haven’t noticed yet because I never used Google Chrome.  It’s called .webp and it is created by the tech power-house Google.  It has superior compression than JPEG files and saves tons of bandwidth which is extremely important on mobile phones, so Google has been pushing it a lot.  Problem is, lots of browsers and programs don’t support this .webp image format because they feel it is either too new, too crappy, or too Google.  The result is some major websites, such as Facebook and Netflix, serving you .webp images only if you’re on a browser that supports it, but sending normal JPEG images otherwise.

This is unfortunate, to say the least.  Until it is widely adopted, it means that when you link your friend to an image, it might be an image that requires a specific web browser to view.

Prototype users will have noticed the Netflix spawner is currently broken.  This is because the image loader in the prototype does not support .webp images and causes the issue.  While a patch will be released soon for the prototype to get the Netflix spawner working, the .webp image loading issue will not be addressed until the Steam version.

This is because the Steam version of AArcade uses the Chromium Embedded Framework itself as the image loader, and therefore can properly load .webp images natively.

Joypads & Web Browsing
This week I also wrote most of the code that allows you to browse the web in the in-game browser using your joystick!  Not only will you navigate websites with this input system, but also the UI menus of AArcade itself because they are HTML/JavaScript powered!

Also, some core-systems were worked into the in-game browser that will make things a lot easier to do the things you want.  You will finally be able to right-click on specific elements of webpages.  Drop-down menus will now display properly, and websites can now display prompts & alerts.

Once again, these features are just like Robocop’s vital organs floating in jars.  Their code is functioning independently, but the body still needs to be built to hold them all together.

Coming Up
This week I will continue refining the providers system (which is written mostly in JavaScript) and then start building the back-end for the providers into the AArcade core (written in C++).

Leave a Reply