Skip to content

Commit

Permalink
dark skin for reals (Aurorastation#7084)
Browse files Browse the repository at this point in the history
This passed review with (Aurorastation#7035) let's get this.
  • Loading branch information
Karolis2011 authored and skull132 committed Sep 28, 2019
1 parent 80052b3 commit c540d9d
Show file tree
Hide file tree
Showing 13 changed files with 1,663 additions and 78 deletions.
6 changes: 6 additions & 0 deletions SQL/migrate/V043__Skin_Themes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--
-- Adds HTML style value to the player preferences table.
--

ALTER TABLE `ss13_player_preferences`
ADD `skin_theme` VARCHAR(32) DEFAULT 'Light';
1 change: 1 addition & 0 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
#include "code\controllers\subsystems\stickyban.dm"
#include "code\controllers\subsystems\sun.dm"
#include "code\controllers\subsystems\sunlight.dm"
#include "code\controllers\subsystems\theming.dm"
#include "code\controllers\subsystems\ticker.dm"
#include "code\controllers\subsystems\timer.dm"
#include "code\controllers\subsystems\trade.dm"
Expand Down
75 changes: 0 additions & 75 deletions code/controllers/subsystems/processing/vueui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,9 @@ Byond Vue UI framework's management subsystem
flags = 0
init_order = SS_INIT_MISC_FIRST
priority = SS_PRIORITY_NANOUI
init_order = SS_INIT_MISC_FIRST
stat_tag = "O"

var/list/open_uis

var/list/available_html_themes = list(
"Nano" = list(
"name" = "Nano Dark",
"class" = "theme-nano",
"type" = THEME_TYPE_DARK
),
"Nano Light" = list(
"name" = "Nano Light",
"class" = "theme-nano-light",
"type" = THEME_TYPE_LIGHT
),
"Basic" = list(
"name" = "Basic Light",
"class" = "theme-basic",
"type" = THEME_TYPE_LIGHT
),
"Basic Dark" = list(
"name" = "Basic Dark",
"class" = "theme-basic-dark",
"type" = THEME_TYPE_DARK
)
)

var/list/var_monitor_map

/datum/controller/subsystem/processing/vueui/New()
Expand All @@ -47,14 +22,8 @@ Byond Vue UI framework's management subsystem
for (var/path in subtypesof(/datum/vueui_var_monitor))
var/datum/vueui_var_monitor/VM = new path()
var_monitor_map[VM.subject_type] = VM

..()

for(var/mob/M in mob_list)
var/mob/abstract/new_player/np = M
if(istype(np))
np.new_player_panel_proc()

/**
* Gets a vueui_var_monitor associated with the given source type.
*
Expand Down Expand Up @@ -227,48 +196,4 @@ Byond Vue UI framework's management subsystem
if (!LAZYLEN(open_uis[old_object_key]))
open_uis -= old_object_key

/datum/controller/subsystem/processing/vueui/proc/get_html_theme(var/mob/user)
var/client/cl = null
if(istype(user))
cl = user.client
else
if(istype(user, /client))
cl = user
if(!cl)
return
var/style = cl.prefs.html_UI_style
if(!(style in available_html_themes))
style = "Nano"
return available_html_themes[style]

/datum/controller/subsystem/processing/vueui/proc/get_html_theme_class(var/mob/user)
var/list/theme = get_html_theme(user)
if(!theme)
return FALLBACK_HTML_THEME
var/class = ""
class += "[theme["class"]]"
if(theme["type"] == THEME_TYPE_DARK)
class += " dark-theme"
return class

/proc/send_theme_resources(var/user)
#ifdef UIDEBUG
user << browse_rsc(file("vueui/dist/app.js"), "vueui.js")
user << browse_rsc(file("vueui/dist/app.css"), "vueui.css")
#else
simple_asset_ensure_is_sent(user, /datum/asset/simple/vueui)
#endif

/proc/get_html_theme_header(var/themeclass, var/extra_header = "")
return {"<html><head><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="stylesheet" type="text/css" href="vueui.css">[extra_header]</head><body class="[themeclass]">"}

/proc/get_html_theme_footer()
return {"</body></html>"}

/proc/enable_ui_theme(var/user, var/contents, var/extra_header = "")
var/theme_class = FALLBACK_HTML_THEME
if(SSvueui)
theme_class = SSvueui.get_html_theme_class(user)
return get_html_theme_header(theme_class, extra_header) + contents + get_html_theme_footer()

#undef NULL_OR_EQUAL
118 changes: 118 additions & 0 deletions code/controllers/subsystems/theming.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
var/datum/controller/subsystem/theming/SStheming

/datum/controller/subsystem/theming
name = "Theming"
flags = SS_NO_FIRE
init_order = SS_INIT_MISC_FIRST

var/list/available_html_themes = list(
"Nano" = list(
"name" = "Nano Dark",
"class" = "theme-nano",
"type" = THEME_TYPE_DARK
),
"Nano Light" = list(
"name" = "Nano Light",
"class" = "theme-nano-light",
"type" = THEME_TYPE_LIGHT
),
"Basic" = list(
"name" = "Basic Light",
"class" = "theme-basic",
"type" = THEME_TYPE_LIGHT
),
"Basic Dark" = list(
"name" = "Basic Dark",
"class" = "theme-basic-dark",
"type" = THEME_TYPE_DARK
)
)

var/skin_files = list("Light" = "interface/skin.txt", "Dark" = "interface/dark.txt")
var/skin_themes

/datum/controller/subsystem/theming/New()
NEW_SS_GLOBAL(SStheming)
skin_themes = list()

/datum/controller/subsystem/theming/Initialize(start_timeofday)
for(var/name in skin_files)
skin_themes[name] = list()
var/loaded = file2list(skin_files[name])
for(var/op in loaded)
var/split = text2list(op, " ")
if(!islist(skin_themes[name][split[1]]))
skin_themes[name][split[1]] = list()
skin_themes[name][split[1]] += split[2]

for(var/mob/M in mob_list)
if(M.client)
apply_theme_from_perfs(M.client)
var/mob/abstract/new_player/np = M
if(istype(np))
np.new_player_panel_proc()
..()

/datum/controller/subsystem/theming/proc/apply_theme_from_perfs(var/user)
var/client/c
if(ismob(user))
var/mob/M = user
c = M.client
if(isclient(user))
c = user
if(!isclient(c))
return
apply_theme(user, c.prefs.skin_theme)

/datum/controller/subsystem/theming/proc/apply_theme(var/user, var/theme = "Dark")
if(!isclient(user) && !ismob(user))
return
var/skin = skin_themes[theme]
if(!skin)
return
for(var/param in skin)
winset(user, param, jointext(skin[param], ";"))

/datum/controller/subsystem/theming/proc/get_html_theme(var/mob/user)
var/client/cl = null
if(istype(user))
cl = user.client
else
if(istype(user, /client))
cl = user
if(!cl)
return
var/style = cl.prefs.html_UI_style
if(!(style in available_html_themes))
style = "Nano"
return available_html_themes[style]

/datum/controller/subsystem/theming/proc/get_html_theme_class(var/mob/user)
var/list/theme = get_html_theme(user)
if(!theme)
return FALLBACK_HTML_THEME
var/class = ""
class += "[theme["class"]]"
if(theme["type"] == THEME_TYPE_DARK)
class += " dark-theme"
return class

/proc/send_theme_resources(var/user)
#ifdef UIDEBUG
user << browse_rsc(file("vueui/dist/app.js"), "vueui.js")
user << browse_rsc(file("vueui/dist/app.css"), "vueui.css")
#else
simple_asset_ensure_is_sent(user, /datum/asset/simple/vueui)
#endif

/proc/get_html_theme_header(var/themeclass, var/extra_header = "")
return {"<html><head><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="stylesheet" type="text/css" href="vueui.css">[extra_header]</head><body class="[themeclass]">"}

/proc/get_html_theme_footer()
return {"</body></html>"}

/proc/enable_ui_theme(var/user, var/contents, var/extra_header = "")
var/theme_class = FALLBACK_HTML_THEME
if(SStheming)
theme_class = SStheming.get_html_theme_class(user)
return get_html_theme_header(theme_class, extra_header) + contents + get_html_theme_footer()
2 changes: 2 additions & 0 deletions code/modules/client/client procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@
prefs.client = src // Safety reasons here.
prefs.last_ip = address //these are gonna be used for banning
prefs.last_id = computer_id //these are gonna be used for banning
if(SStheming)
SStheming.apply_theme_from_perfs(src)

/client/proc/InitClient()
if(initialized)
Expand Down
19 changes: 17 additions & 2 deletions code/modules/client/preference_setup/global/01_ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
S["UI_style_color"] >> pref.UI_style_color
S["UI_style_alpha"] >> pref.UI_style_alpha
S["html_UI_style"] >> pref.html_UI_style
S["skin_theme"] >> pref.skin_theme
S["ooccolor"] >> pref.ooccolor

/datum/category_item/player_setup_item/player_global/ui/save_preferences(var/savefile/S)
S["UI_style"] << pref.UI_style
S["UI_style_color"] << pref.UI_style_color
S["UI_style_alpha"] << pref.UI_style_alpha
S["html_UI_style"] << pref.html_UI_style
S["skin_theme"] << pref.skin_theme
S["ooccolor"] << pref.ooccolor

/datum/category_item/player_setup_item/player_global/ui/gather_load_query()
Expand All @@ -24,6 +26,7 @@
"UI_style_color",
"UI_style_alpha",
"html_UI_style",
"skin_theme",
"ooccolor"
),
"args" = list("ckey")
Expand All @@ -40,6 +43,7 @@
"UI_style_color",
"UI_style_alpha",
"html_UI_style",
"skin_theme",
"ooccolor",
"ckey" = 1
)
Expand All @@ -52,14 +56,16 @@
"UI_style_color" = pref.UI_style_color,
"UI_style" = pref.UI_style,
"html_UI_style" = pref.html_UI_style,
"skin_theme" = pref.skin_theme,
"ooccolor" = pref.ooccolor
)

/datum/category_item/player_setup_item/player_global/ui/sanitize_preferences()
pref.UI_style = sanitize_inlist(pref.UI_style, all_ui_styles, initial(pref.UI_style))
pref.UI_style_color = sanitize_hexcolor(pref.UI_style_color, initial(pref.UI_style_color))
pref.UI_style_alpha = sanitize_integer(text2num(pref.UI_style_alpha), 0, 255, initial(pref.UI_style_alpha))
pref.html_UI_style = sanitize_inlist(pref.html_UI_style, SSvueui.available_html_themes, initial(pref.html_UI_style))
pref.html_UI_style = sanitize_inlist(pref.html_UI_style, SStheming.available_html_themes, initial(pref.html_UI_style))
pref.skin_theme = sanitize_inlist(pref.skin_theme, SStheming.skin_themes, initial(pref.skin_theme))
pref.ooccolor = sanitize_hexcolor(pref.ooccolor, initial(pref.ooccolor))

/datum/category_item/player_setup_item/player_global/ui/content(mob/user)
Expand All @@ -70,6 +76,7 @@
dat += "-Color: <a href='?src=\ref[src];select_color=1'><b>[pref.UI_style_color]</b></a> [HTML_RECT(pref.UI_style_color)] - <a href='?src=\ref[src];reset=ui'>reset</a><br>"
dat += "-Alpha(transparency): <a href='?src=\ref[src];select_alpha=1'><b>[pref.UI_style_alpha]</b></a> - <a href='?src=\ref[src];reset=alpha'>reset</a><br>"
dat += "<b>HTML UI Style:</b> <a href='?src=\ref[src];select_html=1'><b>[pref.html_UI_style]</b></a><br>"
dat += "<b>Main UI Style:</b> <a href='?src=\ref[src];select_skin_theme=1'><b>[pref.skin_theme]</b></a><br>"
if(can_select_ooc_color(user))
dat += "<b>OOC Color:</b> "
if(pref.ooccolor == initial(pref.ooccolor))
Expand Down Expand Up @@ -99,11 +106,19 @@
return TOPIC_REFRESH

else if(href_list["select_html"])
var/html_style_new = input(user, "Choose HTML UI style.", "Global Preference", pref.html_UI_style) as null|anything in SSvueui.available_html_themes
var/html_style_new = input(user, "Choose HTML UI style.", "Global Preference", pref.html_UI_style) as null|anything in SStheming.available_html_themes
if(isnull(html_style_new) || !CanUseTopic(user)) return TOPIC_NOACTION
pref.html_UI_style = html_style_new
return TOPIC_REFRESH

else if(href_list["select_skin_theme"])
var/skin_theme_new = input(user, "Choose HTML UI style.", "Global Preference", pref.skin_theme) as null|anything in SStheming.skin_themes
if(isnull(skin_theme_new) || !CanUseTopic(user)) return TOPIC_NOACTION
pref.skin_theme = skin_theme_new
if(SStheming)
SStheming.apply_theme_from_perfs(user)
return TOPIC_REFRESH

else if(href_list["select_ooc_color"])
var/new_ooccolor = input(user, "Choose OOC color:", "Global Preference") as color|null
if(new_ooccolor && can_select_ooc_color(user) && CanUseTopic(user))
Expand Down
1 change: 1 addition & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ datum/preferences
var/UI_style_color = "#ffffff"
var/UI_style_alpha = 255
var/html_UI_style = "Nano"
var/skin_theme = "Light"
var/motd_hash = "" //Hashes for the new server greeting window.
var/memo_hash = ""

Expand Down
2 changes: 1 addition & 1 deletion code/modules/vueui/ui.dm
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,6 @@ main ui datum.
* @return themes class - text
*/
/datum/vueui/proc/get_theme_class()
return SSvueui.get_html_theme_class(user)
return SStheming.get_html_theme_class(user)

#undef UIDEBUG
4 changes: 4 additions & 0 deletions html/changelogs/darkskin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
author: Karolis2011
delete-after: True
changes:
- rscadd: "Added main ui (skin) dark version that can be changed in global preferences."
2 changes: 2 additions & 0 deletions interface/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Modifying skin files
All changes must be made on both `skin.dmf` and `dark.dmf` files. Then using [DMFTool](https://github.com/Karolis2011/DMFTool) you will need to make bidirectional difference ad save produced output to `skin.txt` for parts that are needed to switch to light skin and `dark.txt` for parts that ar needed to switch to dark skin.
Loading

0 comments on commit c540d9d

Please sign in to comment.