Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds fullscreen mode to the game #2745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define COMSIG_KB_CLIENT_SCREENSHOT_DOWN "keybinding_client_screenshot_down"
#define COMSIG_KB_CLIENT_MINIMALHUD_DOWN "keybinding_client_minimalhud_down"
#define COMSIG_KB_CLIENT_ZOOMIN_DOWN "keybinding_client_zoomin_down"
#define COMSIG_KB_CLIENT_FULLSCREEN_DOWN "keybinding_client_fullscreen_down"

//Human
#define COMSIG_KB_HUMAN_QUICKEQUIP_DOWN "keybinding_human_quickequip_down"
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define PREFTOGGLE_2_TGUI_SAY (1<<17)
#define PREFTOGGLE_2_SAY_LIGHT_THEME (1<<18)
#define PREFTOGGLE_2_SAY_SHOW_PREFIX (1<<19)
#define PREFTOGGLE_2_FULLSCREEN (1<<20) //NSV13

#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCY_TGUI|PREFTOGGLE_2_LOCKED_TGUI|PREFTOGGLE_2_LOCKED_BUTTONS|PREFTOGGLE_2_WINDOW_FLASHING|PREFTOGGLE_2_CREW_OBJECTIVES|PREFTOGGLE_2_GHOST_HUD|PREFTOGGLE_2_GHOST_INQUISITIVENESS|PREFTOGGLE_2_AMBIENT_OCCLUSION|PREFTOGGLE_2_AUTO_FIT_VIEWPORT|PREFTOGGLE_2_ENABLE_TIPS|PREFTOGGLE_2_SHOW_CREDITS|PREFTOGGLE_2_HOTKEYS|PREFTOGGLE_2_WIDESCREEN|PREFTOGGLE_2_TGUI_INPUT|PREFTOGGLE_2_BIG_BUTTONS|PREFTOGGLE_2_SWITCHED_BUTTONS|PREFTOGGLE_2_TGUI_SAY) //NSV13 - Widescreen

Expand Down
4 changes: 4 additions & 0 deletions code/__byond_version_compat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@
#define PROC_REF(X) (.proc/##X)
/// Call by name proc reference, checks if the proc exists on given type or as a global proc
#define TYPE_PROC_REF(TYPE, X) (##TYPE.proc/##X)
/// Call by name verb reference, checks if the verb exists on given type or as a global verb
#define TYPE_VERB_REF(TYPE, X) (##TYPE.verb/##X)
/// Call by name proc reference, checks if the proc is existing global proc
#define GLOBAL_PROC_REF(X) (/proc/##X)
#else
/// Call by name proc reference, checks if the proc exists on this type or as a global proc
#define PROC_REF(X) (nameof(.proc/##X))
/// Call by name proc reference, checks if the proc exists on given type or as a global proc
#define TYPE_PROC_REF(TYPE, X) (nameof(##TYPE.proc/##X))
/// Call by name verb reference, checks if the verb exists on given type or as a global verb
#define TYPE_VERB_REF(TYPE, X) (nameof(##TYPE.verb/##X))
/// Call by name proc reference, checks if the proc is existing global proc
#define GLOBAL_PROC_REF(X) (/proc/##X)
#endif
16 changes: 16 additions & 0 deletions code/datums/keybinding/client.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,19 @@

/datum/keybinding/client/zoomin/up(client/user)
winset(user, "mapwindow.map", "zoom=[user.prefs.pixel_size]")

//NSV13 - different relative to upstream because of prefs
/datum/keybinding/client/fullscreen
key = "F11"
name = "fullscreen"
full_name = "Toggle Fullscreen"
description = "Switch between windowed and fullscreen mode."
keybind_signal = COMSIG_KB_CLIENT_FULLSCREEN_DOWN

/datum/keybinding/client/fullscreen/down(client/user)
. = ..()
if(.)
return
user.prefs.toggles2 ^= PREFTOGGLE_2_FULLSCREEN
user.toggle_fullscreen(user.prefs.toggles2 & PREFTOGGLE_2_FULLSCREEN)
return TRUE
13 changes: 9 additions & 4 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,10 @@ GLOBAL_LIST_EMPTY(preferences_datums)

dat += "<b>Ambient Occlusion:</b> <a href='?_src_=prefs;preference=ambientocclusion'>[toggles2 & PREFTOGGLE_2_AMBIENT_OCCLUSION ? "Enabled" : "Disabled"]</a><br>"
dat += "<b>Fit Viewport:</b> <a href='?_src_=prefs;preference=auto_fit_viewport'>[toggles2 & PREFTOGGLE_2_AUTO_FIT_VIEWPORT ? "Auto" : "Manual"]</a><br>"
if (CONFIG_GET(flag/widescreen)) //Nsv13 - widescreen
if (CONFIG_GET(flag/widescreen)) //NSV13 - widescreen
dat += "<b>Widescreen:</b> <a href='?_src_=prefs;preference=widescreenpref'>[toggles2 & PREFTOGGLE_2_WIDESCREEN ? "Enabled" : "Disabled"]</a><br>"
dat += "<b>Fullscreen:</b> <a href='?_src_=prefs;preference=fullscreenpref'>[toggles2 & PREFTOGGLE_2_FULLSCREEN ? "Enabled" : "Disabled"]</a><br>"
//NSV13 - fullscreen

button_name = pixel_size
dat += "<b>Pixel Scaling:</b> <a href='?_src_=prefs;preference=pixel_size'>[(button_name) ? "Pixel Perfect [button_name]x" : "Stretch to fit"]</a><br>"
Expand Down Expand Up @@ -2200,10 +2202,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
parent.fit_viewport()

if("widescreenpref")//Nsv13 - Widescreen
var/client/C = (istype(user, /client)) ? user : user.client
toggles2 ^= PREFTOGGLE_2_WIDESCREEN
C.change_view(getScreenSize(toggles2 & PREFTOGGLE_2_WIDESCREEN))
C.view_size.default = (toggles2 & PREFTOGGLE_2_WIDESCREEN) ? CONFIG_GET(string/default_view) : "15x15" // This view size wrapper is extremely inconsistent and we need to finagle it a bit.
parent.change_view(getScreenSize(toggles2 & PREFTOGGLE_2_WIDESCREEN))
parent.view_size.default = (toggles2 & PREFTOGGLE_2_WIDESCREEN) ? CONFIG_GET(string/default_view) : "15x15" // This view size wrapper is extremely inconsistent and we need to finagle it a bit.

if("fullscreenpref") //NSV13 - Fullscreen
toggles2 ^= PREFTOGGLE_2_FULLSCREEN
parent.toggle_fullscreen(toggles2 & PREFTOGGLE_2_FULLSCREEN)

if("pixel_size")
switch(pixel_size)
Expand Down
1 change: 1 addition & 0 deletions nsv13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3878,6 +3878,7 @@
#include "nsv13\code\modules\cargo\space_catalog.dm"
#include "nsv13\code\modules\cargo\exports\engineering.dm"
#include "nsv13\code\modules\cargo\exports\syndie.dm"
#include "nsv13\code\modules\client\fullscreen.dm"
#include "nsv13\code\modules\client\zoom.dm"
#include "nsv13\code\modules\client\loadout\loadout_colorizers.dm"
#include "nsv13\code\modules\client\loadout\loadout_donator.dm"
Expand Down
49 changes: 49 additions & 0 deletions nsv13/code/modules/client/fullscreen.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//src proc to enable and disable fullscreen
/client/proc/toggle_fullscreen(value)
if(value)
// Delete the menu
winset(src, "mainwindow", "menu=\"\"")
// Switch to the cool status bar
winset(src, "mainwindow", "on-status=\".winset \\\"\[\[*]]=\\\"\\\" ? status_bar.text=\[\[*]] status_bar.is-visible=true : status_bar.is-visible=false\\\"\"")
winset(src, "status_bar_wide", "is-visible=false")
// Switch to fullscreen mode
winset(src, "mainwindow","titlebar=false")
winset(src, "mainwindow","can-resize=false")
// Set it to minimized first because otherwise it doesn't enter fullscreen properly
// This line is important, and the game won't properly enter fullscreen mode otherwise
winset(src, "mainwindow","is-minimized=true")
winset(src, "mainwindow","is-maximized=true")
// Set the main window's size
winset(src, null, "split.size=mainwindow.size")
// Fit the viewport
INVOKE_ASYNC(src, TYPE_VERB_REF(/client, fit_viewport))
else
// Restore the menu
winset(src, "mainwindow", "menu=\"menu\"")
// Switch to the lame status bar
winset(src, "mainwindow", "on-status=\".winset \\\"status_bar_wide.text = \[\[*]]\\\"\"")
winset(src, "status_bar", "is-visible=false")
winset(src, "status_bar_wide", "is-visible=true")
// Exit fullscreen mode
winset(src, "mainwindow","titlebar=true")
winset(src, "mainwindow","can-resize=true")
// Fix the mapsize, turning off statusbar doesn't update scaling
INVOKE_ASYNC(src, PROC_REF(fix_mapsize))

/client/proc/fix_mapsize()
var/windowsize = winget(src, "split", "size")
if (!src || !windowsize)
return
var/split = findtext(windowsize, "x")
winset(src, "split", "size=[copytext(windowsize, 1, split)]x[text2num(copytext(windowsize, split + 1)) - 16]")
src.fit_viewport()

/client/verb/switch_fullscreen()
set category = "OOC"
set name = "Toggle Fullscreen"

if(!src || !prefs)
return
src.prefs.toggles2 ^= PREFTOGGLE_2_FULLSCREEN
src.toggle_fullscreen(src.prefs.toggles2 & PREFTOGGLE_2_FULLSCREEN)
to_chat(usr, "<span class ='info'>Switched [src.prefs.toggles2 & PREFTOGGLE_2_FULLSCREEN ? "to fullscreen" : "off fullscreen"], press F11 to toggle.</span>")
Loading