Skip to content

Commit

Permalink
tgui input list
Browse files Browse the repository at this point in the history
  • Loading branch information
Git-Nivrak committed Apr 25, 2024
1 parent 2bce062 commit 99bd1c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
14 changes: 14 additions & 0 deletions code/game/objects/items/storage/firstaid.dm
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,20 @@
/obj/item/storage/pill_bottle/proc/error_idlock(mob/user)
to_chat(user, SPAN_WARNING("It must have some kind of ID lock..."))

/obj/item/storage/pill_bottle/proc/choose_color()
var/list/possible_colors = list("Orange" = "", "Blue" = "1", "Yellow" = "2", "Light Purple" = "3", "Light Grey" = "4",
"White" = "5", "Light Green" = "6", "Cyan" = "7", "Red" = "8", "Aquamarine" = "9", "Grey" = "10", "Bordeaux" = "11", "Black" = "12")
var/selected_color = tgui_input_list(usr, "Select a color.", "Color choice", possible_colors)

if (!selected_color)
selected_color = ""

selected_color = possible_colors[selected_color]

icon_state = "pill_canister" + selected_color
to_chat(usr, SPAN_NOTICE("You color \the [src]."))
update_icon()

/obj/item/storage/pill_bottle/verb/set_maptext()
set category = "Object"
set name = "Set short label (on-sprite)"
Expand Down
10 changes: 2 additions & 8 deletions code/game/objects/items/tools/misc_tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@
to_chat(user, SPAN_WARNING("The label won't stick to that."))
return
if(istype(A, /obj/item/storage/pill_bottle))
var/num = copytext(reject_bad_text(input(usr,"Color? (1-12 or blank)", "Set \the [A]'s color", "")), 1, 3)
if(!num || !length(num) || text2num(num) <= 0 || text2num(num) > 12 || copytext(num, 2, 3) == " ")
to_chat(usr, SPAN_NOTICE("You clear the color off \the [A]."))
A.icon_state = "pill_canister"
update_icon()
A.icon_state = "pill_canister" + num
to_chat(usr, SPAN_NOTICE("You color \the [A]."))
update_icon()
var/obj/item/storage/pill_bottle/target_pill_bottle = A
target_pill_bottle.choose_color()

if(!label || !length(label))
remove_label(A, user)
Expand Down
12 changes: 2 additions & 10 deletions code/modules/reagents/chemistry_machinery/chem_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
if(!istype(dest))
source.reagents.remove_reagent(reagent_id, amount)
else if(dest.reagents)
source.reagents.trans_id_to(dest, reagent_id, amount)
source.reagents.trans_id_to(dest, reagent_id, amount)

/obj/structure/machinery/chem_master/Topic(href, href_list)
. = ..()
Expand Down Expand Up @@ -149,15 +149,7 @@
if(!Adjacent(usr))
return

var/num = copytext(reject_bad_text(input(usr,"Color? (1-12)", "Set \the [src]'s color", "")), 1, 3)
if(!num || !length(num) || text2num(num) <= 0 || text2num(num) > 12 || copytext(num, 2, 3) == " ")
to_chat(usr, SPAN_NOTICE("You clear the color off \the [src]."))
loaded_pill_bottle.icon_state = "pill_canister"
update_icon()
return
loaded_pill_bottle.icon_state = "pill_canister" + num
to_chat(usr, SPAN_NOTICE("You color \the [loaded_pill_bottle]."))
loaded_pill_bottle.update_icon()
loaded_pill_bottle.choose_color()

else if(href_list["close"])
close_browser(user, "chemmaster")
Expand Down

0 comments on commit 99bd1c2

Please sign in to comment.