Reverts crafting changes

This commit is contained in:
Artur
2020-01-16 14:26:36 +02:00
parent 6500d0d9a9
commit 1f718df41a
4 changed files with 116 additions and 132 deletions
+11 -17
View File
@@ -25,7 +25,6 @@ GLOBAL_LIST_EMPTY(uplinks)
var/unlock_code
var/failsafe_code
var/datum/ui_state/checkstate
var/compact_mode = FALSE
/datum/component/uplink/Initialize(_owner, _lockable = TRUE, _enabled = FALSE, datum/game_mode/_gamemode, starting_tc = 20, datum/ui_state/_checkstate)
if(!isitem(parent))
@@ -139,25 +138,22 @@ GLOBAL_LIST_EMPTY(uplinks)
var/list/data = list()
data["telecrystals"] = telecrystals
data["lockable"] = lockable
data["compact_mode"] = compact_mode
return data
/datum/component/uplink/ui_static_data(mob/user)
var/list/data = list()
data["categories"] = list()
for(var/category in uplink_items)
var/list/cat = list(
"name" = category,
"items" = (category == selected_cat ? list() : null))
for(var/item in uplink_items[category])
var/datum/uplink_item/I = uplink_items[category][item]
if(I.limited_stock == 0)
continue
if(I.restricted_roles.len)
var/is_inaccessible = TRUE
for(var/R in I.restricted_roles)
if(R == user.mind.assigned_role)
is_inaccessible = FALSE
if(category == selected_cat)
for(var/item in uplink_items[category])
var/datum/uplink_item/I = uplink_items[category][item]
if(I.limited_stock == 0)
continue
if(I.restricted_roles.len)
var/is_inaccessible = 1
for(var/R in I.restricted_roles)
if(R == user.mind.assigned_role)
is_inaccessible = 0
if(is_inaccessible)
continue
cat["items"] += list(list(
@@ -192,8 +188,6 @@ GLOBAL_LIST_EMPTY(uplinks)
SStgui.close_uis(src)
if("select")
selected_cat = params["category"]
if("compact_toggle")
compact_mode = !compact_mode
return TRUE
/datum/component/uplink/proc/MakePurchase(mob/user, datum/uplink_item/U)
@@ -300,4 +294,4 @@ GLOBAL_LIST_EMPTY(uplinks)
if(!T)
return
explosion(T,1,2,3)
qdel(parent) //Alternatively could brick the uplink.
qdel(parent) //Alternatively could brick the uplink.
+103 -108
View File
@@ -3,34 +3,37 @@
var/viewing_category = 1 //typical powergamer starting on the Weapons tab
var/viewing_subcategory = 1
var/list/categories = list(
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, //Called Frozen
CAT_MEAT,
CAT_MISCFOOD,
CAT_PASTRY,
CAT_PIE,
CAT_PIZZA,
CAT_SALAD,
CAT_SANDWICH,
CAT_SOUP,
CAT_SPAGHETTI,
),
CAT_CLOTHING = CAT_NONE
)
var/cur_category = CAT_NONE
var/cur_subcategory = CAT_NONE
CAT_WEAPONRY,
CAT_ROBOT,
CAT_MISC,
CAT_PRIMAL,
CAT_FOOD,
CAT_CLOTHING)
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_NONE) //Clothing subcategories
var/datum/action/innate/crafting/button
var/display_craftable_only = FALSE
var/display_compact = TRUE
@@ -65,11 +68,11 @@
continue main_loop
else
continue
return FALSE
return 0
for(var/A in R.chem_catalysts)
if(contents[A] < R.chem_catalysts[A])
return FALSE
return TRUE
return 0
return 1
/datum/personal_crafting/proc/get_environment(mob/user)
. = list()
@@ -155,7 +158,7 @@
I.CheckParts(parts, R)
if(send_feedback)
SSblackbox.record_feedback("tally", "object_crafted", 1, I.type)
return FALSE
return 0
return "."
return ", missing tool."
return ", missing component."
@@ -287,97 +290,46 @@
/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)
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)
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/craftability = list()
var/list/can_craft = list()
var/list/cant_craft = 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
craftability["[REF(R)]"] = check_contents(R, surroundings)
data["craftability"] = craftability
if(check_contents(R, surroundings))
can_craft += list(build_recipe_data(R))
else
cant_craft += list(build_recipe_data(R))
data["can_craft"] = can_craft
data["cant_craft"] = cant_craft
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
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/component/personal_crafting/proc/build_recipe_data(datum/crafting_recipe/R)
var/list/data = list()
data["name"] = R.name
data["ref"] = "[REF(R)]"
var/req_text = ""
var/tool_text = ""
var/catalyst_text = ""
for(var/a in R.reqs)
//We just need the name, so cheat-typecast to /atom for speed (even tho Reagents are /datum they DO have a "name" var)
//Also these are typepaths so sadly we can't just do "[a]"
var/atom/A = a
req_text += " [R.reqs[A]] [initial(A.name)],"
req_text = replacetext(req_text,",","",-1)
data["req_text"] = req_text
for(var/a in R.chem_catalysts)
var/atom/A = a //cheat-typecast
catalyst_text += " [R.chem_catalysts[A]] [initial(A.name)],"
catalyst_text = replacetext(catalyst_text,",","",-1)
data["catalyst_text"] = catalyst_text
for(var/a in R.tools)
if(ispath(a, /obj/item))
var/obj/item/b = a
tool_text += " [initial(b.name)],"
else
tool_text += " [a],"
tool_text = replacetext(tool_text,",","",-1)
data["tool_text"] = tool_text
return data
/datum/personal_crafting/ui_act(action, params)
if(..())
return
@@ -393,18 +345,61 @@
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"]))
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)
var/list/data = list()
@@ -444,4 +439,4 @@
/datum/mind/proc/teach_crafting_recipe(R)
if(!learned_recipes)
learned_recipes = list()
learned_recipes |= R
learned_recipes |= R
File diff suppressed because one or more lines are too long
-5
View File
@@ -53,7 +53,6 @@ import { OperatingComputer } from './interfaces/OperatingComputer';
import { OreBox } from './interfaces/OreBox';
import { OreRedemptionMachine } from './interfaces/OreRedemptionMachine';
import { Pandemic } from './interfaces/Pandemic';
import { PersonalCrafting } from './interfaces/PersonalCrafting';
import { PortableGenerator } from './interfaces/PortableGenerator';
import { PortablePump, PortableScrubber } from './interfaces/PortableAtmos';
import { PowerMonitor } from './interfaces/PowerMonitor';
@@ -314,10 +313,6 @@ const ROUTES = {
component: () => Pandemic,
scrollable: true,
},
personal_crafting: {
component: () => PersonalCrafting,
scrollable: true,
},
portable_generator: {
component: () => PortableGenerator,
scrollable: false,