Skip to content

Commit

Permalink
convert sanity to TGUI (#8251)
Browse files Browse the repository at this point in the history
* convert sanity UI to TGUI

* make ui buildable & fix data parse error

* remove .tmpl file

* update TGUI bundle

* update TGUI bandle -the hell...

* make layout more dynamic

* update TGUI bundle

* fix linters(?)

* fix linters (now real!!)
  • Loading branch information
intercepti0n authored Aug 15, 2023
1 parent cee4410 commit f86f36e
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 172 deletions.
1 change: 1 addition & 0 deletions cev_eris.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,7 @@
#include "code\modules\sanity\sanity_effects.dm"
#include "code\modules\sanity\sanity_hallucinations.dm"
#include "code\modules\sanity\sanity_lists.dm"
#include "code\modules\sanity\sanity_menu.dm"
#include "code\modules\sanity\sanity_mob.dm"
#include "code\modules\sanity_grain\sanity_grain.dm"
#include "code\modules\scrap\extra_quality.dm"
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/hud/screen_objects/base_screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@
if(!ishuman(parentmob))
return FALSE
var/mob/living/carbon/human/H = parentmob
H.nano_ui_interact(H)
return TRUE
H?.sanity?.ui_interact(H)
return TRUE

//--------------------------------------------------sanity end---------------------------------------------------------
//--------------------------------------------------nsa---------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"tgfont.css" = file("tgui/packages/tgfont/static/tgfont.css"),
)

/datum/asset/simple/sanity
assets = list(
"desire.png" = 'icons/ui_icons/sanity/desire.png',
"style.png" = 'icons/ui_icons/sanity/style.png',
"insight.png" = 'icons/ui_icons/sanity/insight.png',
"kneeling.png" = 'icons/ui_icons/sanity/kneeling.png',
"sanity.png" = 'icons/ui_icons/sanity/sanity.png'
)

// /datum/asset/simple/headers
// assets = list(
// "alarm_green.gif" = 'icons/program_icons/alarm_green.gif',
Expand Down
32 changes: 1 addition & 31 deletions code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1079,37 +1079,7 @@ var/list/rank_prefix = list(\
set desc = "Browse your character sanity."
set category = "IC"
set src = usr
nano_ui_interact(src)

/mob/living/carbon/human/nano_ui_data()
var/list/data = list()

data["style"] = get_total_style()
data["min_style"] = MIN_HUMAN_STYLE
data["max_style"] = MAX_HUMAN_STYLE
data["sanity"] = sanity.level
data["sanity_max_level"] = sanity.max_level
data["insight"] = sanity.insight
data["desires"] = sanity.desires
data["rest"] = sanity.resting
data["insight_rest"] = sanity.insight_rest

var/obj/item/implant/core_implant/cruciform/C = get_core_implant(/obj/item/implant/core_implant/cruciform)
if(C)
data["cruciform"] = TRUE
data["righteous_life"] = C.righteous_life

return data

/mob/living/carbon/human/nano_ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, state = GLOB.default_state)
var/list/data = nano_ui_data()

ui = SSnano.try_update_ui(user, user, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "sanity.tmpl", name, 650, 550, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
sanity?.ui_interact(src)

/mob/living/carbon/human/verb/check_pulse()
set category = "Object"
Expand Down
44 changes: 44 additions & 0 deletions code/modules/sanity/sanity_menu.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/datum/sanity/ui_state(mob/user)
return GLOB.always_state

/datum/sanity/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Sanity", owner.name)
ui.set_autoupdate(TRUE)
ui.open()

/datum/sanity/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/simple/sanity)
)

/datum/sanity/ui_data(mob/user)
var/list/data = list()

data["style"] = list(
"value" = owner.get_total_style(),
"min" = MIN_HUMAN_STYLE,
"max" = MAX_HUMAN_STYLE
)

data["sanity"] = list(
"value" = level,
"max" = max_level
)

data["desires"] = list(
"resting" = resting,
"desires" = desires,
"value" = insight_rest,
)

var/obj/item/implant/core_implant/cruciform/C = owner.get_core_implant(/obj/item/implant/core_implant/cruciform)
data["righteous"] = list(
"present" = C ? TRUE : FALSE,
"value" = C?.righteous_life
)

data["insight"] = insight

return data
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
138 changes: 0 additions & 138 deletions nano/templates/sanity.tmpl

This file was deleted.

35 changes: 35 additions & 0 deletions tgui/packages/tgui/interfaces/Sanity/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export const TRAIT_DESCRIPTION = {
Sanity:
'Sanity is gained or lost depending on your environment. For example being around oddities increases your sanity slightly, as well as taking drugs or smoking. Seeing people die, being around blood and grime and being hurt yourself lowers your sanity.',
Insight:
'Insight is gained by activies such as smoking, taking drugs, hurting people or seeing them get hurt, seeing blood and grime and exploring maintenance.',
Style:
'Style can be gained by wearing fashionable and clean attire. Being dirty with blood or grime will decrease your style value.',
Desires:
'Once you have gained enough insight, you should rest. While you rest you will have certain wishes to fulfill.',
Holy: 'Living righteously and actively participating in group rituals increases the amount of energy regeneration of your cruciform.',
};

export const TRAIT_LABEL = {
Sanity: 'Sanity level',
Insight: 'Insight progress',
Style: 'Current style',
Desires: 'Rest progress',
Holy: 'Holiness',
};

export const TRAIT_ASSET = {
Sanity: 'sanity.png',
Insight: 'insight.png',
Style: 'style.png',
Desires: 'desire.png',
Holy: 'kneeling.png',
};

export const TRAIT_NAME = {
Sanity: 'Sanity',
Insight: 'Insight',
Style: 'Style',
Desires: 'Desires',
Holy: 'Righteous life',
};
Loading

0 comments on commit f86f36e

Please sign in to comment.