[TGUI] Abductor Organ Storage and TG Abductor Theme (#21890)

* abductor organ dispenser - first pass

* Apply suggestions from code review

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>

* removed color choosing proc - moved to init

* small JS fix

* fontSize, color adjustment, abductor theme port

* Update code/game/gamemodes/miniantags/abduction/machinery/dispenser.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>

* additional colors and pick upgrade

* Update code/game/gamemodes/miniantags/abduction/machinery/dispenser.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>

* Update code/game/gamemodes/miniantags/abduction/machinery/dispenser.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* Update code/game/gamemodes/miniantags/abduction/machinery/dispenser.dm

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>

* small code review fix

* Update code/game/gamemodes/miniantags/abduction/machinery/dispenser.dm

Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>

---------

Co-authored-by: GDN <96800819+GDNgit@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
This commit is contained in:
Burzah
2023-09-05 19:59:38 -05:00
committed by GitHub
co-authored by GDN Luc Contrabang Ryan
parent 61aef2bd6f
commit 8a9743c875
6 changed files with 163 additions and 54 deletions
@@ -8,77 +8,82 @@
var/list/gland_types
var/list/gland_colors
var/list/amounts
/obj/machinery/abductor/gland_dispenser/proc/random_color()
//TODO : replace with presets or spectrum
return rgb(rand(0,255),rand(0,255),rand(0,255))
var/list/color_pool = list(
"#700b08",
"#b87411",
"#8e8004",
"#2d7248",
"#095da2",
"#4d238e",
"#661553",
"#a70b03",
"#576402",
"#204a77",
"#994225",
"#663f36",
"#bd3675",
"#b9723c",
"#e76a68",
"#206e16"
)
/obj/machinery/abductor/gland_dispenser/Initialize(mapload)
. = ..()
gland_types = subtypesof(/obj/item/organ/internal/heart/gland)
gland_types = shuffle(gland_types)
gland_colors = new/list(gland_types.len)
amounts = new/list(gland_types.len)
for(var/i=1,i<=gland_types.len,i++)
gland_colors[i] = random_color()
gland_colors = new /list(length(gland_types))
amounts = new /list(length(gland_types))
var/list/colors = shuffle(color_pool)
for(var/i in 1 to length(gland_types))
gland_colors[i] = pick_n_take(colors)
amounts[i] = rand(1,5)
if(!length(colors))
colors = shuffle(color_pool)
/obj/machinery/abductor/gland_dispenser/attack_hand(mob/user)
/obj/machinery/abductor/gland_dispenser/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "GlandDispenser", name, 300, 338, master_ui, state)
ui.open()
/obj/machinery/abductor/gland_dispenser/ui_data(mob/user)
var/list/data = list()
data["glands"] = list()
for(var/gland_number in 1 to length(gland_colors))
var/list/gland_information = list(
"color" = gland_colors[gland_number],
"amount" = amounts[gland_number],
"id" = gland_number,
)
data["glands"] += list(gland_information)
return data
/obj/machinery/abductor/gland_dispenser/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return
if(!isabductor(user))
return
user.set_machine(src)
var/box_css = {"
<style>
a.box.gland {
float: left;
width: 20px;
height: 20px;
margin: 5px;
border-width: 1px;
border-style: solid;
border-color: rgba(0,0,0,.2);
text-align: center;
}
</style>"}
var/dat = ""
var/item_count = 0
for(var/i=1,i<=gland_colors.len,i++)
item_count++
var/g_color = gland_colors[i]
var/amount = amounts[i]
dat += "<a class='box gland' style='background-color:[g_color]' href='?src=[UID()];dispense=[i]'>[amount]</a>"
if(item_count == 4) // Three boxes per line
dat +="</br></br>"
item_count = 0
var/datum/browser/popup = new(user, "glands", "Gland Dispenser", 200, 200)
popup.add_head_content(box_css)
popup.set_content(dat)
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
popup.open()
return
switch(action)
if("dispense")
var/gland_id = text2num(params["gland_id"])
if(!ISINDEXSAFE(amounts, gland_id))
return
Dispense(gland_id)
return TRUE
/obj/machinery/abductor/gland_dispenser/attack_hand(mob/user)
ui_interact(user)
/obj/machinery/abductor/gland_dispenser/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/organ/internal/heart/gland))
if(!user.drop_item())
return
W.forceMove(src)
for(var/i=1,i<=gland_colors.len,i++)
for(var/i in 1 to length(gland_colors))
if(gland_types[i] == W.type)
amounts[i]++
else
return ..()
/obj/machinery/abductor/gland_dispenser/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
if(href_list["dispense"])
Dispense(text2num(href_list["dispense"]))
updateUsrDialog()
/obj/machinery/abductor/gland_dispenser/proc/Dispense(count)
if(amounts[count]>0)
amounts[count]--
+1
View File
@@ -22,6 +22,7 @@ import './styles/main.scss';
import './styles/themes/cardtable.scss';
import './styles/themes/changeling.scss';
import './styles/themes/hackerman.scss';
import './styles/themes/abductor.scss';
import './styles/themes/malfunction.scss';
import './styles/themes/ntos.scss';
import './styles/themes/retro.scss';
@@ -0,0 +1,35 @@
import { useBackend } from '../backend';
import { Button, Section } from '../components';
import { Window } from '../layouts';
export const GlandDispenser = (props, context) => {
const { act, data } = useBackend(context);
const {
glands = [],
} = data;
return (
<Window theme="abductor">
<Window.Content>
<Section>
{glands.map(gland => (
<Button
key={gland.id}
width="60px"
height="60px"
m={0.75}
textAlign="center"
fontSize="17px"
lineHeight="55px"
icon="eject"
backgroundColor={gland.color}
content={gland.amount || "0"}
disabled={!gland.amount}
onClick={() => act('dispense', {
gland_id: gland.id,
})} />
))}
</Section>
</Window.Content>
</Window>
);
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,68 @@
/**
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
@use 'sass:color';
@use 'sass:meta';
@use '../colors.scss' with (
$primary: #ad2350,
$fg-map-keys: (),
$bg-map-keys: (),
);
@use '../base.scss' with (
$color-bg: #2a314a,
$color-bg-grad-spread: 6%,
$border-radius: 2px,
);
.theme-abductor {
// Atomic classes
@include meta.load-css('../atomic/color.scss');
// Components
@include meta.load-css(
'../components/Button.scss',
$with: (
'color-default': colors.$primary,
'color-disabled': #363636,
'color-selected': #465899,
'color-caution': #be6209,
'color-danger': #9a9d00
)
);
@include meta.load-css(
'../components/Input.scss',
$with: ('border-color': #404b6e)
);
@include meta.load-css(
'../components/NoticeBox.scss',
$with: ('color-background': #a82d55)
);
@include meta.load-css(
'../components/NumberInput.scss',
$with: ('border-color': #404b6e)
);
@include meta.load-css(
'../components/ProgressBar.scss',
$with: ('color-background': rgba(0, 0, 0, 0.5))
);
@include meta.load-css('../components/Section.scss');
@include meta.load-css(
'../components/Tooltip.scss',
$with: ('color-background': #a82d55)
);
// Layouts
@include meta.load-css('../layouts/Layout.scss');
@include meta.load-css('../layouts/Window.scss');
@include meta.load-css(
'../layouts/TitleBar.scss',
$with: ('color-background': #9e1b46)
);
.Layout__content {
background-image: none;
}
}