A window module for LÖVR.
First of all you need to add some new parameters in your lovr.conf()
Just append this parameters next to window related code:
-- additional window parameters t.window.fullscreentype = "desktop" -- Choose between "desktop" fullscreen or "exclusive" fullscreen mode (string) t.window.x = nil -- The x-coordinate of the window's position in the specified display (number) t.window.y = nil -- The y-coordinate of the window's position in the specified display (number) t.window.minwidth = 1 -- Minimum window width if the window is resizable (number) t.window.minheight = 1 -- Minimum window height if the window is resizable (number) t.window.display = 1 -- Index of the monitor to show the window in (number) t.window.centered = false -- Align window on the center of the monitor (boolean) t.window.topmost = false -- Show window on top (boolean) t.window.borderless = false -- Remove all border visuals from the window (boolean) t.window.resizable = false -- Let the window be user-resizable (boolean) t.window.opacity = 1 -- Window opacity value (number) conf = t.windowAfter setting up your config function you can require window module and use it
lovr.window = require 'lovr-window'
function lovr.load()
-- print all window parameters into console
local width, height, mode = lovr.window.getMode()
for k,v in pairs(mode) do
print(k, v)
end
-- sets window opacity, resolution and title
lovr.window.setMode(1280, 720, {title = "Hello, Window!", resizable = true, opacity = 0.5})
end
function lovr.maximized( v, w,h )
print(v and "maximized" or "restored")
end
function lovr.dragdrop( paths )
for i=1, #paths do
--prints all file/directory paths dropped on the window
print(paths[i])
end
end
function lovr.windowmoved( x,y )
print("Current window position:", x,y)
end
| Function | Description | |-|-| | window.getDisplayDimensions( index ) | Gets the width and height of the desktop | | window.getDisplayCount() | Gets the number of connected monitors | | window.getDisplayName( index ) | Gets the name of a display | | window.getFullscreen() | Gets whether the window is fullscreen | | window.getIcon() | Gets the window icon | | window.getMode() | Gets the display mode and properties of the window | | window.getOpacity() | Returns opacity value of the Window | | window.getPosition() | Gets the position of the window on the screen | | window.getTitle() | Gets the window title | | window.isVisible() | Checks if the game window is visible | | window.maximize() | Makes the window as large as possible | | window.minimize() | Minimizes the window to the system's task bar / dock | | window.requestAttention() | Causes the window to request the attention of the user if it is not in the foreground | | window.restore() | Restores the size and position of the window if it was minimized or maximized | | window.setFullscreen(fullscreen[, fstype]) | Enters or exits fullscreen | | window.setIcon( source ) | Sets the window icon | | window.setMode( width, height[, flags]) | Sets the display mode and properties of the window | | window.setOpacity( value ) | Sets opacity value of the Window | | window.setPosition( x,y ) | Sets the position of the window on the screen | | window.setTitle( title ) | Sets the window title | | window.focus() | Sets focus on the window | | window.visible( state ) | Makes the window visible / invisible |
| Callback | Description | |-|-| lovr.maximized( state, w,h ) | Called when the window is maximized/restored | lovr.windowmoved( x,y ) | Callback function triggered when the window is moved | lovr.dragdrop( paths ) | Callback function triggered when a file/directory is dragged and dropped onto the window |
width, height = window.getDisplayDimensions( index )
number index
count = window.getDisplayCount()
None.
number count
name = window.getDisplayName( index )
number index
string name
fullscreen, fullscreentype = window.getFullscreen()
None.
boolean fullscreen
string fullscreentype
icon = window.getIcon()
None.
Image icon
width, height, flags = window.getMode()
None.
number width
number height
table flags
number xnumber ynumber minwidthnumber minheightboolean fullscreenstring fullscreentypenumber vsyncnumber msaanumber opacityboolean topmostboolean resizableboolean borderlessboolean centerednumber displayopacity = window.getOpacity()
None.
number opacity
x,y = window.getPosition()
None.
title = window.getTitle()
None.
string title
visible = window.isVisible()
None.
boolean visible
window.maximize()
None.
Nothing.
window.minimize()
None.
Nothing.
window.requestAttention()
None.
Nothing.
window.restore()
None.
Nothing.
window.setFullscreen(fullscreen, fullscreentype)
boolean fullscreen
string fullscreentype
Nothing.
window.setIcon(source)
Image source
Nothing.
local image_icon = lovr.data.newImage("/icon1.png", false)
window.setIcon(image_icon)
window.setIcon("/icon2.png") -- or you can set image from jpg/png file
window.setMode(width, height, flags)
number width
number height
table flags
number xnumber ynumber minwidthnumber minheightnumber displayboolean fullscreenstring fullscreentypenumber opacityboolean topmostboolean resizableboolean borderlessboolean centeredNothing.
window.setMode(1600, 900) -- sets window size to 1600x900 pixels
flags = {
fullscreen = true,
fullscreentype = "exclusive",
display = 2
}
lovr.window.setMode(1920, 1080, flags) -- sets window to fullscreen mode on display 2
window.setOpacity(value)
number value
Nothing.
window.setPosition(x,y)
Nothing.
window.setTitle(title)
string title
Nothing.
window.focus()
None.
Nothing.
window.visible(state)
boolean state
Nothing.
lovr.maximized( state, width,height )
boolean state
number width
number height
Nothing.
function lovr.maximized( v, w,h )
print(v and "maximized" or "restored")
end
lovr.windowmoved( x,y )
Nothing.
function lovr.windowmoved( x,y )
print("Current window position:", x,y)
end
lovr.dragdrop( paths )
table paths
Nothing.
function lovr.dragdrop( paths )
for i=1, #paths do
--print all file/directory paths dropped on the window
print(paths[i])
end
end