Libraries.Interface.Events.ScreenshotListener Documentation

Inherits from: Libraries.Language.Object

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

OnScreenshot(Libraries.Interface.Events.ScreenshotEvent event)

This action is called when a screenshot is taken by the Game class.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.PixelMap
use Libraries.Interface.Events.ScreenshotListener
use Libraries.Interface.Events.ScreenshotEvent
use Libraries.Game.GameStateManager
use Libraries.Game.Application
use Libraries.Game.WebApplication

class Main is Game, ScreenshotListener

    action Main
        StartGame()
    end

    action CreateGame
        // Register this class to receive screenshot events.
        AddScreenshotListener(me)

        // Add a pattern to the screen. The actual pattern drawn here isn't important, it's just something to appear in our screenshot.
        integer i = 0
        Color color
        repeat while i < 10
            Drawable drawable
            drawable:LoadFilledCircle(50, color:CustomColor(1.0 - i / 10.0, 0.5, 1 / 1.0, 1.0))
            drawable:SetPosition(100 * (i mod 2), 100 * (i / 2))
            Add(drawable)
            i = i + 1
        end

        // Tell the Game to screenshot the next frame of animation that's drawn.
        Screenshot()
    end

    // This gets called once the screenshot is taken.
    action OnScreenshot(ScreenshotEvent event)
        PixelMap screenshot = event:GetScreenshot()

        // Get the Application, make sure we're on the web, then save our screenshot to the Downloads folder.
        GameStateManager manager
        Application app = manager:GetApplication()
        if app is WebApplication
            WebApplication webApp = cast(WebApplication, app)
            webApp:SaveImageToDownloads(screenshot, "MyScreenshot")
        end
    end
end