Skip to content

Commit

Permalink
Vending tgui (#1075)
Browse files Browse the repository at this point in the history
* first pass of vending sorted to tgui

* migrate from table to flex

* added progress bar, need to resolve formatting

* removed progress bad and changed formatting

* got images passed forwards

* added description tooltips

* got map specific items to render

* got icons resized and added search bar

* reworked filtering

* reworked scss for vendingsorted, search bar fixed

* got tooltip working as intended

* added item seperator

* reworked text to elipse and made the description box a title

* playing around with usmc theme options

* added usmc template background

* vendor primarily uses static ui for data transfer

* added ui_state and ui_status procs to cmvending-sorted

* changed uscm theme to use linear gradient as background from dark blue to black

* resolve line length linter

* fixed more linting issues

* using ui_act for vending

* remove vending_sorted tmpl

* should have resolved linting issues

* removed duplicate and removed last of nano ui procs from cm_vending sorted

* removed the wrong ui_act

* added additional access checks on ui_state

* rolled out can_access across cm_vending.cm

* resolved vendor ui closing

* next round of CR feedback

* reworked vending for PR

* final cleanup for PR

* reworking icons for effects, tooltip position

* resolved build issue but not able to display icon for effects

* fixed icon issue for essentials_set

* should have resolved ammo boxes rendering properly

* resolved box issue for ammo boxes

* resolved empty descriptions and autofocus

* ui close access refactor

* final pr requests

* should have resolved linting errors

* got the suspicious automated gunrack working

* resolved icon width

Co-authored-by: paulrpg <paulrpg@gmail.com>
  • Loading branch information
mullenpaul and paulrpg committed Sep 19, 2022
1 parent 36dbcf9 commit f541c09
Show file tree
Hide file tree
Showing 10 changed files with 612 additions and 266 deletions.
352 changes: 197 additions & 155 deletions code/game/machinery/vending/cm_vending.dm

Large diffs are not rendered by default.

98 changes: 18 additions & 80 deletions code/game/machinery/vending/vendor_types/antag/antag_guns_sorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@
req_access = list(ACCESS_ILLEGAL_PIRATE)
listed_products = list()

/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/populate_product_list(var/scale)
return

/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 0)
/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/Initialize()
. = ..()
var/list/factions = GLOB.faction_datums
for (var/i in 1 to length(factions))
var/datum/faction/F = get_faction(factions[i])
var/list/equipment = F.get_antag_guns_sorted_equipment()
if(LAZYLEN(equipment))
build_icons(equipment)

if(!ishuman(user))
return
listed_products = list()

var/list/display_list = list()
/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/populate_product_list(var/scale)
return

/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/get_listed_products(var/mob/user)
var/mob/living/carbon/human/H = user

var/faction = H.faction ? H.faction : FACTION_CLF
Expand All @@ -25,84 +31,16 @@
listed_products[faction] = F.get_antag_guns_sorted_equipment()

var/list/products_sets = listed_products[faction]
return products_sets

if(LAZYLEN(products_sets))
for(var/i in 1 to products_sets.len)
var/list/myprod = products_sets[i] //we take one list from listed_products

var/p_name = myprod[1] //taking it's name
var/p_amount = myprod[2] //amount left
var/prod_available = FALSE //checking if it's available
if(p_amount > 0) //checking availability
p_name += ": [p_amount]" //and adding amount to product name so it will appear in "button" in UI
prod_available = TRUE
else if(p_amount == 0)
p_name += ": 0" //Negative numbers (-1) used for categories.

//forming new list with index, name, amount, available or not, color and add it to display_list
display_list += list(list("prod_index" = i, "prod_name" = p_name, "prod_amount" = p_amount, "prod_available" = prod_available, "prod_color" = myprod[4]))


/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/ui_data(mob/user)
var/list/data = ..()
var/mob/living/carbon/human/H = user
var/adaptive_vendor_theme = VENDOR_THEME_COMPANY //for potential future PMC version
switch(H.faction)
if(FACTION_UPP)
adaptive_vendor_theme = VENDOR_THEME_UPP
if(FACTION_CLF)
adaptive_vendor_theme = VENDOR_THEME_CLF

var/list/data = list(
"vendor_name" = name,
"theme" = adaptive_vendor_theme,
"displayed_records" = display_list,
)

ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)

if (!ui)
ui = new(user, src, ui_key, "cm_vending_sorted.tmpl", name , 600, 700)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(0)

/obj/structure/machinery/cm_vending/sorted/cargo_guns/antag_guns/handle_topic(mob/user, href, href_list)
if(in_range(src, user) && isturf(loc) && ishuman(user))
user.set_interaction(src)
if (href_list["vend"])

var/mob/living/carbon/human/H = user

if(!allowed(H))
to_chat(H, SPAN_WARNING("Access denied."))
vend_fail()
return

var/obj/item/card/id/I = H.wear_id
if(!istype(I))
to_chat(H, SPAN_WARNING("Access denied. No ID card detected"))
vend_fail()
return

if(I.registered_name != H.real_name)
to_chat(H, SPAN_WARNING("Wrong ID card owner detected."))
vend_fail()
return

var/idx=text2num(href_list["vend"])
var/faction = H.faction ? H.faction : FACTION_CLF
var/list/L = listed_products[faction][idx]

var/turf/T = get_appropriate_vend_turf(H)
if(T.contents.len > 25)
to_chat(H, SPAN_WARNING("The floor is too cluttered, make some space."))
vend_fail()
return

if(L[2] <= 0) //to avoid dropping more than one product when there's
to_chat(H, SPAN_WARNING("[L[1]] is out of stock."))
vend_fail()
return // one left and the player spam click during a lagspike.

vend_succesfully(L, H, T)

add_fingerprint(user)
ui_interact(user) //updates the nanoUI window
data["theme"] = adaptive_vendor_theme
return data
1 change: 1 addition & 0 deletions code/modules/projectiles/ammo_boxes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
overlays += image(icon, icon_state = "text[overlay_gun_type]") //adding text
if(overlay_ammo_type)
overlays += image(icon, icon_state = "base_type[overlay_ammo_type]") //adding base color stripes
if(overlay_ammo_type!="_reg" && overlay_ammo_type!="_blank")
overlays += image(icon, icon_state = "lid_type[overlay_ammo_type]") //adding base color stripes

//---------------------INTERACTION PROCS
Expand Down
31 changes: 0 additions & 31 deletions nano/templates/cm_vending_sorted.tmpl

This file was deleted.

Binary file added tgui/packages/tgui/assets/titlebar-uscm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tgui/packages/tgui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import './styles/themes/retro.scss';
import './styles/themes/syndicate.scss';
import './styles/themes/wizard.scss';
import './styles/themes/weyland.scss';
import './styles/themes/uscm.scss';
import './styles/themes/xeno.scss';
import './styles/themes/hive_status.scss';

Expand Down

0 comments on commit f541c09

Please sign in to comment.