Merge pull request #1228 from ArchieBeepBoop/craft1

TGUI Next Crafting
This commit is contained in:
Dahlular
2021-06-04 06:21:21 -06:00
committed by GitHub
23 changed files with 175 additions and 173 deletions
+1 -1
View File
@@ -87,7 +87,7 @@
#define CAT_ROBOT "Robots"
#define CAT_MISC "Misc"
#define CAT_PRIMAL "Tribal"
//#define CAT_CARPENTRY "Carpentry" need to get this to work
#define CAT_CARPENTRY "Carpentry"
#define CAT_CLOTHING "Clothing"
#define CAT_FOOD "Foods"
#define CAT_BREAD "Breads"
-4
View File
@@ -44,10 +44,6 @@
zone_select.update_icon(mymob)
static_inventory += zone_select
using = new /obj/screen/craft
using.icon = ui_style
static_inventory += using
using = new /obj/screen/area_creator
using.icon = ui_style
static_inventory += using
-6
View File
@@ -91,12 +91,6 @@
var/obj/screen/using
var/obj/screen/inventory/inv_box
using = new /obj/screen/craft
using.icon = ui_style
if(!widescreenlayout) // CIT CHANGE
using.screen_loc = ui_boxcraft // CIT CHANGE
static_inventory += using
using = new/obj/screen/language_menu
using.icon = ui_style
if(!widescreenlayout) // CIT CHANGE
-6
View File
@@ -66,12 +66,6 @@
icon_state = "craft"
screen_loc = ui_crafting
/obj/screen/craft/Click()
var/mob/living/M = usr
if(isobserver(usr))
return
M.OpenCraftingMenu()
/obj/screen/area_creator
name = "create new area"
icon = 'icons/mob/screen_midnight.dmi'
@@ -1,40 +1,52 @@
/datum/personal_crafting
/datum/component/personal_crafting/Initialize()
if(!ismob(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_MOB_CLIENT_LOGIN, .proc/create_mob_button)
/datum/component/personal_crafting/proc/create_mob_button(mob/user, client/CL)
var/datum/hud/H = user.hud_used
var/obj/screen/craft/C = new()
C.icon = H.ui_style
H.static_inventory += C
CL.screen += C
RegisterSignal(C, COMSIG_CLICK, .proc/component_ui_interact)
/datum/component/personal_crafting
var/busy
var/viewing_category = 1 //typical powergamer starting on the Weapons tab
var/viewing_subcategory = 1
var/list/categories = list(
CAT_WEAPONRY,
CAT_ROBOT,
CAT_MISC,
CAT_PRIMAL,
CAT_FOOD,
CAT_CLOTHING)
//CAT_CARPENTRY
var/list/subcategories = list(
list( //Weapon subcategories
CAT_WEAPON,
CAT_AMMO),
CAT_NONE, //Robot subcategories
CAT_NONE, //Misc subcategories
CAT_NONE, //Tribal subcategories
list( //Food subcategories
CAT_BREAD,
CAT_BURGER,
CAT_CAKE,
CAT_EGG,
CAT_FISH,
CAT_ICE, //Called Frozen
CAT_MEAT,
CAT_MISCFOOD,
CAT_PASTRY,
CAT_PIE,
CAT_PIZZA,
CAT_SALAD,
CAT_SANDWICH,
CAT_SOUP,
CAT_SPAGHETTI),
CAT_CLOTHING) //Clothing subcategories
CAT_WEAPONRY = list(
CAT_WEAPON,
CAT_AMMO,
),
CAT_ROBOT = CAT_NONE,
CAT_MISC = CAT_NONE,
CAT_PRIMAL = CAT_NONE,
CAT_FOOD = list(
CAT_BREAD,
CAT_BURGER,
CAT_CAKE,
CAT_EGG,
CAT_FISH,
CAT_ICE,
CAT_MEAT,
CAT_MISCFOOD,
CAT_PASTRY,
CAT_PIE,
CAT_PIZZA,
CAT_SALAD,
CAT_SANDWICH,
CAT_SOUP,
CAT_SPAGHETTI,
),
CAT_DRINK = CAT_NONE,
CAT_CLOTHING = CAT_NONE,
CAT_CARPENTRY = CAT_NONE,
)
var/cur_category = CAT_NONE
var/cur_subcategory = CAT_NONE
var/datum/action/innate/crafting/button
var/display_craftable_only = FALSE
var/display_compact = TRUE
@@ -54,13 +66,15 @@
/datum/personal_crafting/proc/check_contents(datum/crafting_recipe/R, list/contents)
/datum/component/personal_crafting/proc/check_contents(datum/crafting_recipe/R, list/contents)
contents = contents["other"]
main_loop:
for(var/A in R.reqs)
var/needed_amount = R.reqs[A]
for(var/B in contents)
if(ispath(B, A))
if (R.blacklist.Find(B))
continue
if(contents[B] >= R.reqs[A])
continue main_loop
else
@@ -69,13 +83,13 @@
continue main_loop
else
continue
return 0
return FALSE
for(var/A in R.chem_catalysts)
if(contents[A] < R.chem_catalysts[A])
return 0
return 1
return FALSE
return TRUE
/datum/personal_crafting/proc/get_environment(mob/user)
/datum/component/personal_crafting/proc/get_environment(mob/user)
. = list()
for(var/obj/item/I in user.held_items)
. += I
@@ -90,8 +104,10 @@
if(AM.flags_1 & HOLOGRAM_1)
continue
. += AM
for(var/slot in list(SLOT_R_STORE, SLOT_L_STORE))
. += user.get_item_by_slot(slot)
/datum/personal_crafting/proc/get_surroundings(mob/user)
/datum/component/personal_crafting/proc/get_surroundings(mob/user)
. = list()
.["tool_behaviour"] = list()
.["other"] = list()
@@ -116,7 +132,7 @@
if(G.modified_colors)
.["color"] = G.color
/datum/personal_crafting/proc/check_tools(mob/user, datum/crafting_recipe/R, list/contents)
/datum/component/personal_crafting/proc/check_tools(mob/user, datum/crafting_recipe/R, list/contents)
if(!R.tools.len)
return TRUE
var/list/possible_tools = list()
@@ -147,10 +163,10 @@
return FALSE
return TRUE
/datum/personal_crafting/proc/construct_item(mob/user, datum/crafting_recipe/R)
/datum/component/personal_crafting/proc/construct_item(mob/user, datum/crafting_recipe/R)
var/list/contents = get_surroundings(user)
var/send_feedback = 1
var/cached_color = null
var/cached_color = null //Do not remove this.
if(contents["color"]) //From plants
cached_color = contents["color"]
if(check_contents(R, contents))
@@ -164,7 +180,8 @@
var/list/parts = del_reqs(R, user)
var/atom/movable/I = new R.result (get_turf(user.loc))
I.CheckParts(parts, R)
I.color = cached_color
if(isitem(I))
user.put_in_hands(I)
if(send_feedback)
SSblackbox.record_feedback("tally", "object_crafted", 1, I.type)
return 0
@@ -197,7 +214,7 @@
del_reqs return the list of parts resulting object will receive as argument of CheckParts proc, on the atom level it will add them all to the contents, on all other levels it calls ..() and does whatever is needed afterwards but from contents list already
*/
/datum/personal_crafting/proc/del_reqs(datum/crafting_recipe/R, mob/user)
/datum/component/personal_crafting/proc/del_reqs(datum/crafting_recipe/R, mob/user)
var/list/surroundings
var/list/Deletion = list()
. = list()
@@ -295,122 +312,106 @@
Deletion.Cut(Deletion.len)
qdel(DL)
/datum/component/personal_crafting/proc/component_ui_interact(obj/screen/craft/image, location, control, params, user)
if(user == parent)
ui_interact(user)
/datum/personal_crafting/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.not_incapacitated_turf_state)
/datum/component/personal_crafting/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.not_incapacitated_turf_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
cur_category = categories[1]
if(islist(categories[cur_category]))
var/list/subcats = categories[cur_category]
cur_subcategory = subcats[1]
else
cur_subcategory = CAT_NONE
ui = new(user, src, ui_key, "personal_crafting", "Crafting Menu", 700, 800, master_ui, state)
ui.open()
/datum/personal_crafting/ui_data(mob/user)
/datum/component/personal_crafting/ui_data(mob/user)
var/list/data = list()
var/list/subs = list()
var/cur_subcategory = CAT_NONE
var/cur_category = categories[viewing_category]
if (islist(subcategories[viewing_category]))
subs = subcategories[viewing_category]
cur_subcategory = subs[viewing_subcategory]
data["busy"] = busy
data["prev_cat"] = categories[prev_cat()]
data["prev_subcat"] = subs[prev_subcat()]
data["category"] = cur_category
data["subcategory"] = cur_subcategory
data["next_cat"] = categories[next_cat()]
data["next_subcat"] = subs[next_subcat()]
data["display_craftable_only"] = display_craftable_only
data["display_compact"] = display_compact
var/list/surroundings = get_surroundings(user)
var/list/can_craft = list()
var/list/cant_craft = list()
var/list/craftability = list()
for(var/rec in GLOB.crafting_recipes)
var/datum/crafting_recipe/R = rec
if(!R.always_availible && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
continue
if((R.category != cur_category) || (R.subcategory != cur_subcategory))
continue
if(check_contents(R, surroundings))
can_craft += list(build_recipe_data(R))
craftability["[REF(R)]"] = check_contents(R, surroundings)
data["craftability"] = craftability
return data
/datum/component/personal_crafting/ui_static_data(mob/user)
var/list/data = list()
var/list/crafting_recipes = list()
for(var/rec in GLOB.crafting_recipes)
var/datum/crafting_recipe/R = rec
if(R.name == "") //This is one of the invalid parents that sneaks in
continue
if(!R.always_availible && !(R.type in user?.mind?.learned_recipes)) //User doesn't actually know how to make this.
continue
if(isnull(crafting_recipes[R.category]))
crafting_recipes[R.category] = list()
if(R.subcategory == CAT_NONE)
crafting_recipes[R.category] += list(build_recipe_data(R))
else
cant_craft += list(build_recipe_data(R))
data["can_craft"] = can_craft
data["cant_craft"] = cant_craft
if(isnull(crafting_recipes[R.category][R.subcategory]))
crafting_recipes[R.category][R.subcategory] = list()
crafting_recipes[R.category]["has_subcats"] = TRUE
crafting_recipes[R.category][R.subcategory] += list(build_recipe_data(R))
data["crafting_recipes"] = crafting_recipes
return data
/datum/personal_crafting/ui_act(action, params)
/datum/component/personal_crafting/ui_act(action, params)
if(..())
return
switch(action)
if("make")
var/datum/crafting_recipe/TR = locate(params["recipe"])
var/datum/crafting_recipe/TR = locate(params["recipe"]) in GLOB.crafting_recipes
busy = TRUE
ui_interact(usr) //explicit call to show the busy display
ui_interact(usr)
var/fail_msg = construct_item(usr, TR)
if(!fail_msg)
to_chat(usr, "<span class='notice'>[TR.name] constructed.</span>")
else
to_chat(usr, "<span class='warning'>Construction failed[fail_msg]</span>")
busy = FALSE
ui_interact(usr)
if("forwardCat") //Meow
viewing_category = next_cat(FALSE)
. = TRUE
if("backwardCat")
viewing_category = prev_cat(FALSE)
. = TRUE
if("forwardSubCat")
viewing_subcategory = next_subcat()
. = TRUE
if("backwardSubCat")
viewing_subcategory = prev_subcat()
. = TRUE
if("toggle_recipes")
display_craftable_only = !display_craftable_only
. = TRUE
if("toggle_compact")
display_compact = !display_compact
. = TRUE
if("set_category")
if(!isnull(params["category"]))
cur_category = params["category"]
if(!isnull(params["subcategory"]))
if(params["subcategory"] == "0")
cur_subcategory = ""
else
cur_subcategory = params["subcategory"]
. = TRUE
//Next works nicely with modular arithmetic
/datum/personal_crafting/proc/next_cat(readonly = TRUE)
if (!readonly)
viewing_subcategory = 1
. = viewing_category % categories.len + 1
/datum/personal_crafting/proc/next_subcat()
if(islist(subcategories[viewing_category]))
var/list/subs = subcategories[viewing_category]
. = viewing_subcategory % subs.len + 1
//Previous can go fuck itself
/datum/personal_crafting/proc/prev_cat(readonly = TRUE)
if (!readonly)
viewing_subcategory = 1
if(viewing_category == categories.len)
. = viewing_category-1
else
. = viewing_category % categories.len - 1
if(. <= 0)
. = categories.len
/datum/personal_crafting/proc/prev_subcat()
if(islist(subcategories[viewing_category]))
var/list/subs = subcategories[viewing_category]
if(viewing_subcategory == subs.len)
. = viewing_subcategory-1
else
. = viewing_subcategory % subs.len - 1
if(. <= 0)
. = subs.len
else
. = null
/datum/personal_crafting/proc/build_recipe_data(datum/crafting_recipe/R)
/datum/component/personal_crafting/proc/build_recipe_data(datum/crafting_recipe/R)
var/list/data = list()
data["name"] = R.name
data["ref"] = "[REF(R)]"
@@ -0,0 +1,25 @@
/datum/crafting_recipe
var/name = "" //in-game display name
var/list/reqs = list() //type paths of items consumed associated with how many are needed
var/list/blacklist = list() //type paths of items explicitly not allowed as an ingredient
var/result //type path of item resulting from this craft
var/list/tools = list() //type paths of items needed but not consumed
var/time = 30 //time in deciseconds
var/list/parts = list() //type paths of items that will be placed in the result
var/list/chem_catalysts = list() //like tools but for reagents
var/category = CAT_NONE //where it shows up in the crafting UI
var/subcategory = CAT_NONE
var/always_availible = TRUE //Set to FALSE if it needs to be learned first.
/datum/crafting_recipe/New()
if(!(result in reqs))
blacklist += result
/**
* Run custom pre-craft checks for this recipe
*
* user: The /mob that initiated the crafting
* collected_requirements: A list of lists of /obj/item instances that satisfy reqs. Top level list is keyed by requirement path.
*/
/datum/crafting_recipe/proc/check_requirements(mob/user, list/collected_requirements)
return TRUE
@@ -18,6 +18,10 @@
category = CAT_WEAPONRY
subcategory = CAT_WEAPON
/datum/crafting_recipe/strobeshield/New()
..()
blacklist |= subtypesof(/obj/item/shield/riot/)
/datum/crafting_recipe/makeshiftshield
name = "Makeshift Metal Shield"
result = /obj/item/shield/makeshift
-11
View File
@@ -1,11 +0,0 @@
/datum/crafting_recipe
var/name = "" //in-game display name
var/reqs[] = list() //type paths of items consumed associated with how many are needed
var/result //type path of item resulting from this craft
var/tools[] = list() //type paths of items needed but not consumed
var/time = 30 //time in deciseconds
var/parts[] = list() //type paths of items that will be placed in the result
var/chem_catalysts[] = list() //like tools but for reagents
var/category = CAT_NONE //where it shows up in the crafting UI
var/subcategory = CAT_NONE
var/always_availible = TRUE //Set to FALSE if it needs to be learned first.
@@ -198,6 +198,7 @@
/datum/reagent/consumable/spacemountainwind = 5
)
result = /obj/item/reagent_containers/food/snacks/snowcones/spacemountainwind
subcategory = CAT_ICE
/datum/crafting_recipe/food/pwrgame_sc
name = "Pwrgame snowcone"
@@ -25,7 +25,7 @@
create_internal_organs() //most of it is done in set_species now, this is only for parent call
physiology = new()
handcrafting = new()
AddComponent(/datum/component/personal_crafting)
. = ..()
@@ -45,10 +45,6 @@
QDEL_NULL_LIST(vore_organs) // CITADEL EDIT belly stuff
return ..()
/mob/living/carbon/human/OpenCraftingMenu()
handcrafting.ui_interact(src)
/mob/living/carbon/human/prepare_data_huds()
//Update med hud images...
..()
@@ -62,7 +62,6 @@
var/custom_species = null
var/datum/personal_crafting/handcrafting
var/datum/physiology/physiology
var/list/datum/bioware = list()
@@ -81,7 +81,6 @@
var/dextrous = FALSE //If the creature has, and can use, hands
var/dextrous_hud_type = /datum/hud/dextrous
var/datum/personal_crafting/handcrafting
var/AIStatus = AI_ON //The Status of our AI, can be set to AI_ON (On, usual processing), AI_IDLE (Will not process, but will return to AI_ON if an enemy comes near), AI_OFF (Off, Not processing ever), AI_Z_OFF (Temporarily off due to nonpresence of players)
@@ -97,7 +96,6 @@
/mob/living/simple_animal/Initialize()
. = ..()
GLOB.simple_animals[AIStatus] += src
handcrafting = new()
if(gender == PLURAL)
gender = pick(MALE,FEMALE)
if(!real_name)
@@ -105,6 +103,8 @@
if(!loc)
stack_trace("Simple animal being instantiated in nullspace")
update_simplemob_varspeed()
if(dextrous)
AddComponent(/datum/component/personal_crafting)
/mob/living/simple_animal/Destroy()
GLOB.simple_animals[AIStatus] -= src
@@ -466,10 +466,6 @@
/mob/living/simple_animal/get_idcard(hand_first = TRUE)
return ..() || access_card
/mob/living/simple_animal/OpenCraftingMenu()
if(dextrous)
handcrafting.ui_interact(src)
/mob/living/simple_animal/can_hold_items()
return dextrous
+2
View File
@@ -54,3 +54,5 @@
mind?.hide_ckey = client?.prefs?.hide_ckey
log_message("Client [key_name(src)] has taken ownership of mob [src]([src.type])", LOG_OWNERSHIP)
SEND_SIGNAL(src, COMSIG_MOB_CLIENT_LOGIN, client)
@@ -15,32 +15,32 @@
name = "Heated Metal"
reqs = list(/obj/item/stack/sheet/metal = 5)
tools = list(TOOL_WELDER)
category = CAT_MISC
category = CAT_CARPENTRY
result = /obj/item/processed/metal
/datum/crafting_recipe/processed_wood
name = "Processable Wood"
reqs = list(/obj/item/stack/sheet/mineral/wood = 5)
tools = list(TOOL_WIRECUTTER, TOOL_WELDER)
category = CAT_MISC
category = CAT_CARPENTRY
result = /obj/item/processed/wood/plank
/datum/crafting_recipe/stool_base
name = "Stool Base"
reqs = list(/obj/item/processed/wood/seat = 1, /obj/item/processed/wood/gluepeg = 4)
category = CAT_MISC
category = CAT_CARPENTRY
result = /obj/item/processed/wood/stool1
/datum/crafting_recipe/clothcushion
name = "Cloth Cushion"
reqs = list(/obj/item/stack/sheet/cloth = 2, /obj/item/stack/sheet/cotton = 5)
tools = list(TOOL_WIRECUTTER)
category = CAT_MISC
category = CAT_CARPENTRY
result = /obj/item/cushion
/datum/crafting_recipe/silkcushion
name = "Silk Cushion"
reqs = list(/obj/item/stack/sheet/silk = 2, /obj/item/stack/sheet/cotton = 5)
tools = list(TOOL_WIRECUTTER)
category = CAT_MISC
category = CAT_CARPENTRY
result = /obj/item/cushion/silk
+10 -10
View File
@@ -399,6 +399,14 @@
#include "code\datums\components\uplink.dm"
#include "code\datums\components\wearertargeting.dm"
#include "code\datums\components\wet_floor.dm"
#include "code\datums\components\crafting\craft.dm"
#include "code\datums\components\crafting\guncrafting.dm"
#include "code\datums\components\crafting\recipes.dm"
#include "code\datums\components\crafting\recipes\recipes_clothing.dm"
#include "code\datums\components\crafting\recipes\recipes_misc.dm"
#include "code\datums\components\crafting\recipes\recipes_primal.dm"
#include "code\datums\components\crafting\recipes\recipes_robot.dm"
#include "code\datums\components\crafting\recipes\recipes_weapon_and_ammo.dm"
#include "code\datums\components\storage\storage.dm"
#include "code\datums\components\storage\concrete\_concrete.dm"
#include "code\datums\components\storage\concrete\bag_of_holding.dm"
@@ -1678,14 +1686,6 @@
#include "code\modules\clothing\under\jobs\Plasmaman\engineering.dm"
#include "code\modules\clothing\under\jobs\Plasmaman\medsci.dm"
#include "code\modules\clothing\under\jobs\Plasmaman\security.dm"
#include "code\modules\crafting\craft.dm"
#include "code\modules\crafting\guncrafting.dm"
#include "code\modules\crafting\recipes.dm"
#include "code\modules\crafting\recipes\recipes_clothing.dm"
#include "code\modules\crafting\recipes\recipes_misc.dm"
#include "code\modules\crafting\recipes\recipes_primal.dm"
#include "code\modules\crafting\recipes\recipes_robot.dm"
#include "code\modules\crafting\recipes\recipes_weapon_and_ammo.dm"
#include "code\modules\detectivework\detective_work.dm"
#include "code\modules\detectivework\evidence.dm"
#include "code\modules\detectivework\scanner.dm"
@@ -3044,6 +3044,8 @@
#include "hyperstation\code\__DEFINES\wendigo.dm"
#include "hyperstation\code\controllers\subsystem\economy.dm"
#include "hyperstation\code\datums\actions.dm"
#include "hyperstation\code\datums\components\crafting\bounties.dm"
#include "hyperstation\code\datums\components\crafting\recipes.dm"
#include "hyperstation\code\datums\ert_hazard_cleanup.dm"
#include "hyperstation\code\datums\elements\holder_micro.dm"
#include "hyperstation\code\datums\mood_events\events.dm"
@@ -3093,8 +3095,6 @@
#include "hyperstation\code\modules\clothing\spacesuits\hardsuit.dm"
#include "hyperstation\code\modules\clothing\suits\misc.dm"
#include "hyperstation\code\modules\clothing\under\under.dm"
#include "hyperstation\code\modules\crafting\bounties.dm"
#include "hyperstation\code\modules\crafting\recipes.dm"
#include "hyperstation\code\modules\economy\account.dm"
#include "hyperstation\code\modules\integrated_electronics\input.dm"
#include "hyperstation\code\modules\mining\shelters.dm"
File diff suppressed because one or more lines are too long
+5
View File
@@ -32,6 +32,7 @@ import { ComputerFabricator } from './interfaces/ComputerFabricator';
import { Crayon } from './interfaces/Crayon';
import { CrewConsole } from './interfaces/CrewConsole';
import { Cryo } from './interfaces/Cryo';
import { PersonalCrafting } from './interfaces/PersonalCrafting';
import { DecalPainter } from './interfaces/DecalPainter';
import { DisposalUnit } from './interfaces/DisposalUnit';
import { DnaVault } from './interfaces/DnaVault';
@@ -420,6 +421,10 @@ const ROUTES = {
component: () => PortableGenerator,
scrollable: false,
},
personal_crafting: {
component: () => PersonalCrafting,
scrollable: true,
},
portable_pump: {
component: () => PortablePump,
scrollable: false,