Skip to content
Matt Jeanes edited this page Jul 18, 2015 · 4 revisions

The screen API is used to create different menus on the 3D2D and pop-up screens in the interior. To create a screen, you should place it in the modules/screens folder of either the exterior or interior. Placing it in the interior will make it only available when the interior exists.

Variables

ENT.screenres

Returns the resolution of the screen as a multiplier

ENT.screenx

Returns the width of the screen in pixels

ENT.screeny

Returns the height of the screen in pixels

ENT.screengap

Returns a suitable padding space, factoring in the screen resolution

ENT.screengap2

Returns ENT.screengap * 2

Fonts

All fonts are scaled by screen resolution, meaning some may be copies of other fonts but scaled appropriately

TARDIS-Default

DermaDefault font scaled

TARDIS-Main

Roboto size 50

TARDIS-Large

Roboto size 40

TARDIS-Med

Roboto size 24

TARDIS-PageName

Roboto size 20

Functions

ENT:AddScreen

ENT:AddScreen(string name, function callback)

This function is used to add a screen to the array of buttons presented to the user when they open the menu. The callback has 3 arguments: entity self, panel frame, panel screen. self is the exterior entity, frame is the frame which you should parent your derma items to, and screen is the entire screen panel.

ENT:GetScreens

ENT:GetScreens()

Returns all screens that were registered with ENT:AddScreen as a table.

ENT:ScreenActive

ENT:ScreenActive(string name)

Returns a table of every screen that is currently displaying the given screen name, or nil if there isn't any. Can be used an as optimisation - don't run intensive code if the screen isn't being shown anywhere.

ENT:PushScreen

ENT:PushScreen(string name, panel screen, panel f, panel f2)

Pushes f2 onto the 'directory' stack and hides f. name is appended to the page title, e.g. Settings/Options/Music

ENT:PopScreen

ENT:PopScreen(panel screen, bool all)

Reverses the process of ENT:PushScreen, going back up the stack in order. If all is true, then the function will recursively call itself until it is at the top level.

ENT:HUDScreen

ENT:HUDScreen()

Creates a new 2D screen and displays it to the user.

ENT:LoadScreenUI

ENT:LoadScreenUI(panel screen)

Loads the TARDIS Interface onto the given panel.

ENT:LoadButtons

ENT:LoadButtons(panel frame, function func)

This function takes a frame and prepares it for the familar 9-button paged layout. It then calls the func callback with 1 argument, frame - which is the same frame given to the function when called. The callback should return a table of buttons (DButton) which have had their parent set (frame), and all other information other than the position and size which is handled by the function.

ENT:LoadScreen

ENT:LoadScreen(string id)

This will load a 3D2D screen and set its ID to the supplied one before returning it.