Merge pull request #287 from Abi79/master

TG update: Vending machine GUI overhaul.
This commit is contained in:
Tastyfish
2012-01-17 16:44:26 -08:00
4 changed files with 1014 additions and 163 deletions

View File

@@ -12,6 +12,7 @@
var/product_paths = "" //String of product paths separated by semicolons. No spaces!
var/product_amounts = "" //String of product amounts separated by semicolons, must have amount for every path in product_paths
var/product_slogans = "" //String of slogans separated by semicolons, optional
var/product_ads = "" //String of small ad messages in the vending screen - random chance
var/product_hidden = "" //String of products that are hidden unless hacked.
var/product_hideamt = "" //String of hidden product amounts, separated by semicolons. Exact same as amounts. Must be left blank if hidden is.
var/product_coin = ""
@@ -20,6 +21,7 @@
var/list/hidden_records = list()
var/list/coin_records = list()
var/list/slogan_list = list()
var/list/small_ads = list() // small ad messages in the vending screen - random chance of popping up whenever you open it
var/vend_reply //Thank you for shopping!
var/last_reply = 0
var/last_slogan = 0 //When did we last pitch?
@@ -41,11 +43,12 @@
desc = "A technological marvel, supposedly able to mix just the mixture you'd like to drink the moment you ask for one."
icon_state = "boozeomat" //////////////18 drink entities below, plus the glasses, in case someone wants to edit the number of bottles
product_paths = "/obj/item/weapon/reagent_containers/food/drinks/bottle/gin;/obj/item/weapon/reagent_containers/food/drinks/bottle/whiskey;/obj/item/weapon/reagent_containers/food/drinks/bottle/tequilla;/obj/item/weapon/reagent_containers/food/drinks/bottle/vodka;/obj/item/weapon/reagent_containers/food/drinks/bottle/vermouth;/obj/item/weapon/reagent_containers/food/drinks/bottle/rum;/obj/item/weapon/reagent_containers/food/drinks/bottle/wine;/obj/item/weapon/reagent_containers/food/drinks/bottle/cognac;/obj/item/weapon/reagent_containers/food/drinks/bottle/kahlua;/obj/item/weapon/reagent_containers/food/drinks/beer;/obj/item/weapon/reagent_containers/food/drinks/ale;/obj/item/weapon/reagent_containers/food/drinks/bottle/orangejuice;/obj/item/weapon/reagent_containers/food/drinks/bottle/tomatojuice;/obj/item/weapon/reagent_containers/food/drinks/bottle/limejuice;/obj/item/weapon/reagent_containers/food/drinks/bottle/cream;/obj/item/weapon/reagent_containers/food/drinks/tonic;/obj/item/weapon/reagent_containers/food/drinks/cola;/obj/item/weapon/reagent_containers/food/drinks/sodawater;/obj/item/weapon/reagent_containers/food/drinks/drinkingglass;/obj/item/weapon/reagent_containers/food/drinks/ice"
product_amounts = "5;5;5;5;5;5;5;5;5;6;6;4;4;4;4;8;8;15;30;10"
product_amounts = "5;5;5;5;5;5;5;5;5;6;6;4;4;4;4;8;8;15;30;9"
vend_delay = 15
product_hidden = "/obj/item/weapon/reagent_containers/food/drinks/tea"
product_hideamt = "10"
product_slogans = "I hope nobody asks me for a bloody cup o' tea...;Alcohol is humanity's friend. Would you abandon a friend?;Quite delighted to serve you!;Is nobody thirsty on this station?"
product_ads = "Drink up!;Booze is good for you!;Alcohol is humanity's best friend.;Quite delighted to serve you!;Care for a nice, cold beer?;Nothing cures you like booze!;Have a sip!;Have a drink!;Have a beer!;Beer is good for you!;Only the finest alcohol!;Best quality booze since 2053!;Award-winning wine!;Maximum alcohol!;Man loves beer.;A toast for progress!"
charge_type = "bar"
/obj/machinery/vending/assist
@@ -53,6 +56,7 @@
product_hidden = "/obj/item/device/flashlight;obj/item/device/assembly/timer"
product_paths = "/obj/item/device/assembly/prox_sensor;/obj/item/device/assembly/igniter;/obj/item/device/assembly/signaler;/obj/item/weapon/wirecutters;/obj/item/weapon/cartridge/signal"
product_hideamt = "5;2"
product_ads = "Only the finest!;Have some tools.;The most robust equipment.;The finest gear in space!"
/obj/machinery/vending/coffee
name = "Hot Drinks machine"
@@ -63,6 +67,7 @@
product_amounts = "25;25;25"
vend_delay = 34
product_hidden = "/obj/item/weapon/reagent_containers/food/drinks/ice"
product_ads = "Have a drink!;Drink up!;It's good for you!;Would you like a hot joe?;I'd kill for some coffee!;The best beans in the galaxy.;Only the finest brew for you.;Mmmm. Nothing like a coffee.;I like coffee, don't you?;Coffee helps you work!;Try some tea.;We hope you like the best!;Try our new chocolate!;Admin conspiracies"
product_hideamt = "10"
charge_type = "coffee"
@@ -75,6 +80,7 @@
product_slogans = "Try our new nougat bar!;Twice the calories for half the price!"
product_hidden = "/obj/item/weapon/reagent_containers/food/snacks/syndicake"
product_hideamt = "10"
product_ads = "The healthiest!;Award-winning chocolate bars!;Mmm! So good!;Oh my god it's so juicy!;Have a snack.;Snacks are good for you!;Have some more Getmore!;Best quality snacks straight from mars.;We love chocolate!;Try our new jerky!"
charge_type = "snack"
/obj/machinery/vending/cola
@@ -86,6 +92,7 @@
product_slogans = "Robust Softdrinks: More robust then a toolbox to the head!"
product_hidden = "/obj/item/weapon/reagent_containers/food/drinks/thirteenloko"
product_hideamt = "5"
product_ads = "Refreshing!;Hope you're thirsty!;Over 1 million drinks sold!;Thirsty? Why not cola?;Please, have a drink!;Drink up!;The best drinks in space."
charge_type = "soda"
/obj/machinery/vending/cart
@@ -112,6 +119,7 @@
product_hideamt = "4"
product_coin = "/obj/item/clothing/mask/cigarette/cigar/havanian"
product_coin_amt = "2"
product_ads = "Probably not bad for you!;Don't believe the scientists!;It's good for you!;Don't quit, buy more!;Smoke!;Nicotine heaven.;Best cigarettes since 2150.;Award-winning cigs."
charge_type = "cigarette"
/obj/machinery/vending/medical
@@ -124,6 +132,7 @@
product_amounts = "4;4;4;4;4;12;5;4;2"
product_hidden = "/obj/item/weapon/reagent_containers/pill/tox;/obj/item/weapon/reagent_containers/pill/stox;/obj/item/weapon/reagent_containers/pill/antitox"
product_hideamt = "3;4;6"
product_ads = "Go save some lives!;The best stuff for your medbay.;Only the finest tools.;Natural chemicals!;This stuff saves lives.;Don't you want some?"
charge_type = "medical"
/obj/machinery/vending/wallmed1
@@ -137,6 +146,7 @@
product_hidden = "/obj/item/weapon/reagent_containers/syringe/antitoxin;/obj/item/weapon/reagent_containers/syringe/antiviral;/obj/item/weapon/reagent_containers/pill/tox"
product_hideamt = "4;4;1"
density = 0 //It is wall-mounted, and thus, not dense. --Superxpdude
product_ads = "Go save some lives!;The best stuff for your medbay.;Only the finest tools.;Natural chemicals!;This stuff saves lives.;Don't you want some?"
charge_type = "medical"
/obj/machinery/vending/wallmed2
@@ -162,6 +172,7 @@
product_amounts = "8;4;5;12;6"
product_hidden = "/obj/item/clothing/glasses/sunglasses;/obj/item/kitchen/donut_box"
product_hideamt = "2;2"
product_ads = "Crack capitalist skulls!;Beat some heads in!;Don't forget - harm is good!;Your weapons are right here.;Handcuffs!;Freeze, scumbag!;Don't tase me bro!;Tase them, bro.;Why not have a donut?"
charge_type = "security"
/obj/machinery/vending/hydronutrients
@@ -174,6 +185,7 @@
product_slogans = "Aren't you glad you don't have to fertilize the natural way?;Now with 50% less stink!;Plants are people too!"
product_hidden = "/obj/item/weapon/reagent_containers/glass/bottle/ammonia;/obj/item/weapon/reagent_containers/glass/bottle/diethylamine"
product_hideamt = "10;5"
product_ads = "We like plants!;Don't you want some?;The greenest thumbs ever.;We like big plants.;Soft soil..."
charge_type = "hydroponics"
/obj/machinery/vending/hydroseeds
@@ -187,6 +199,7 @@
product_hideamt = "2;2;2;2;2"
product_coin = "/obj/item/toy/waterflower"
product_coin_amt = "1"
product_ads = "We like plants!;Grow some crops!;Grow, baby, growww!;Aw h'yeah son!"
charge_type = "hydroponics"
/obj/machinery/vending/magivend
@@ -200,6 +213,7 @@
vend_reply = "Have an enchanted evening!"
product_hidden = "/obj/item/weapon/reagent_containers/glass/bottle/wizarditis" //No one can get to the machine to hack it anyways
product_hideamt = "1" //Just one, for the lulz, not like anyone can get it - Microwave
product_ads = "FJKLFJSD;AJKFLBJAKL;1234 LOONIES LOL!;>MFW;Kill them fuckers!;GET DAT FUKKEN DISK;HONK!;EI NATH;Destroy the station!;Admin conspiracies since forever!;Space-time bending hardware!"
/obj/machinery/vending/dinnerware
name = "Dinnerware"
@@ -210,6 +224,7 @@
//product_amounts = "8;5;4" Old totals
product_hidden = "/obj/item/weapon/kitchen/utensil/spoon;/obj/item/weapon/kitchen/utensil/knife;/obj/item/weapon/kitchen/rollingpin;/obj/item/weapon/butch"
product_hideamt = "2;2;2;2"
product_ads = "Mm, food stuffs!;Food and food accessories.;Get your plates!;You like forks?;I like forks.;Woo, utensils.;You don't really need these..."
charge_type = "kitchen"
/obj/machinery/vending/sovietsoda
@@ -221,6 +236,7 @@
//product_amounts = "8;5;4" Old totals
product_hidden = "/obj/item/weapon/reagent_containers/food/drinks/drinkingglass/cola"
product_hideamt = "20"
product_ads = "What the fuck is this shit?;Why would you buy this;holy shit help;i'm stuck;in;a;universe;factory;AAAAAARGH!;HEIL... Stalin?;CAPITALIST PIGS;FUCK THE WEST"
charge_type = "soda"
/obj/machinery/vending/genetics

View File

@@ -1,3 +1,14 @@
/*
Important notice: I changed "vendingwindow" to "vendingwindow_n" (n for new) because
I extended the window's height a small amount and, for some reason, BYOND saves the
height of all the panels on the player's computer in a text file. This means the
players see some madly-deformed piece of shit window instead of what is intended.
To combat this, I changed the window name. -- Doohl
*/
#define PRODUCTS_PER_PAGE 15 // # of products per page
/obj/machinery/vending
var/const
WIRE_EXTEND = 1
@@ -5,6 +16,8 @@
WIRE_SHOCK = 3
WIRE_SHOOTINV = 4
var/page
var/builtpaths = 0
var/lastpaths
/datum/data/vending_product
var/product_name = "generic"
@@ -18,6 +31,7 @@
page = 1
spawn(4)
src.slogan_list = dd_text2List(src.product_slogans, ";")
//src.small_ads = dd_text2List(src.product_ads, ";") // huehue
var/list/temp_paths = dd_text2List(src.product_paths, ";")
var/list/temp_amounts = dd_text2List(src.product_amounts, ";")
var/list/temp_hidden = dd_text2List(src.product_hidden, ";")
@@ -93,13 +107,91 @@
continue
return
/obj/machinery/vending/proc/updateWindow(mob/user as mob)
var/i
for (i = 1, i <= 6, i++)
winclone(user, "vendingslot", "vendingslot[i]")
winset(user, "vendingwindow.slot[i]", "left=vendingslot[i]")
/obj/machinery/vending/proc/updateWindow(mob/user as mob, var/rebuild = 1)
winset(user, "vendingwindow_n.title", "text=\"[src.name]\"")
winset(user, "vendingwindow_n.advert", "text=\"\"")
/*if(prob(25) && small_ads.len)
var/advert = pick(small_ads)
winset(user, "vendingwindow_n.advert", "text=\"[advert]\"")*/
// Create a list of things to display
var/list/products = src.product_records
if(extended_inventory)
products |= src.hidden_records
if(coin)
products |= src.coin_records
winshow(user, "vendingwindow_n.coinbutton", 1)
else
winshow(user, "vendingwindow_n.coinbutton", 0)
if(rebuild) // rebuild the buttons and shit
for(var/i = 1, i <= PRODUCTS_PER_PAGE, i++) // "refresh" everything to default state
winshow(user, "vendingwindow_n.stock[i]", 0)
winshow(user, "vendingwindow_n.product[i]", 0)
winset(user, "vendingwindow_n.product[i]", "is-disabled=false")
winset(user, "vendingwindow_n.product[i]", "command=\"skincmd vending;buy[i-1]\"")
if(i % 2 == 0) // even number (remainder of i / 2 == 0)
winset(user, "vendingwindow_n.product[i]", "background-color=#78A6C7") // Specific even color
else
winset(user, "vendingwindow_n.product[i]", "background-color=#8BA5B4") // Odd color
for (var/i = 1, i <= products.len, i++) // loop through all products
if(i > PRODUCTS_PER_PAGE) // too many products, don't display on this page!
break
// Locate our product:
if(products.len < ((page-1) * PRODUCTS_PER_PAGE) + i)
continue
var/datum/data/vending_product/product = products[((page-1) * PRODUCTS_PER_PAGE) + i] // ie.: (1-0) * (15) + 1 = index 1 [start of 1st page]
// or : (2-1) * (15) + 1 = index 16 [start of 2nd page]
// Product located: display information
if(product)
winshow(user, "vendingwindow_n.stock[i]", 1) // unhide things
winshow(user, "vendingwindow_n.product[i]", 1) // unhide things
winset(user, "vendingwindow_n.stock[i]", "text=\"[product.amount]\"") // set stock number label
winset(user, "vendingwindow_n.product[i]", "text=\"[product.product_name]\"") // set product button name
if(product.amount <= 0)
winset(user, "vendingwindow_n.product[i]", "is-disabled=true") // disable product button, makes it unclickable and gives it that "disabled" look
winset(user, "vendingwindow_n.product[i]", "background-color=#526F7C") // Darken the button
// Calculate the number of pages in total
var/pages = -round(-products.len / PRODUCTS_PER_PAGE)
/* Ok, it took me a while to figure out why double negatives were even necessary, but eventually I got it:
Basically, instead of a small decimal number rounding to 0 it'd round to 1.
Really fucking bizarre but okay I guess it works??
*/
winset(user, "vendingwindow_n.page", "text=[page]/[pages]")
if(page >= pages)
// Disable the forward page button if max page >= current
winset(user, "vendingwindow_n.forwardbutton", "is-disabled=true")
else
winset(user, "vendingwindow_n.forwardbutton", "is-disabled=false")
if(page <= 1)
// Disable the backwards page button if max page <= 1
winset(user, "vendingwindow_n.backbutton", "is-disabled=true")
else
winset(user, "vendingwindow_n.backbutton", "is-disabled=false")
/* // Old code. I don't really like it, also I kind of needed to rewrite this stuff -- Doohl
for (var/i = 1, i <= 6, i++)
//winclone(user, "vendingslot", "vendingslot[i]")
winset(user, "vendingwindow_n.slot[i]", "left=vendingslot[i]")
winset(user, "vendingslot[i].buy", "command=\"skincmd vending;buy[i-1]\"")
winset(user, "vendingwindow.title", "text=\"[src.name]\"")
winset(user, "vendingwindow_n.title", "text=\"[src.name]\"")
var/list/products = src.product_records
if(extended_inventory)
products |= src.hidden_records
@@ -108,7 +200,7 @@
var/pages = -round(-products.len / 6)
if (page > pages)
page = pages
winset(user, "vendingwindow.page", "text=[page]/[pages]")
winset(user, "vendingwindow_n.page", "text=[page]/[pages]")
var/base = (page-1)*6+1
for (i = 0, i < 6, i++)
@@ -123,30 +215,48 @@
winset(user, "vendingslot[i+1].stock", "text=\"OUT OF STOCK\"")
winset(user, "vendingslot[i+1].stock", "text-color=\"#FF0000\"")
winshow(user, "vendingslot[i+1].buy", 0)
winshow(user, "vendingwindow.slot[i+1]", 1)
winshow(user, "vendingwindow_n.slot[i+1]", 1)
else
winshow(user, "vendingwindow.slot[i+1]", 0)
winshow(user, "vendingwindow_n.slot[i+1]", 0)
*/
/obj/machinery/vending/SkinCmd(mob/user as mob, var/data as text)
if (get_dist(user, src) > 1)
return
var/list/products = src.product_records
if(extended_inventory)
products |= src.hidden_records
if(coin)
products |= src.coin_records
var/pages = -round(-products.len / 6)
var/pages = -round(-products.len / PRODUCTS_PER_PAGE)
switch(data)
if ("pagen")
page++
if (page > pages)
page = pages
updateWindow(user)
if ("pagep")
page--
if (page < 1)
page = 1
updateWindow(user)
if ("coin")
if(!coin)
user << "There is no coin in this machine."
return
coin.loc = src.loc
if(!user.get_active_hand())
user.put_in_hand(coin)
user << "\blue You remove the [coin] from the [src]"
coin = null
updateWindow(user)
if (copytext(data, 1, 4) == "buy")
var/base = (page-1)*6+1
var/base = (page-1) * PRODUCTS_PER_PAGE + 1
var/num = text2num(copytext(data, 4))
if (products.len < base + num)
return
@@ -168,7 +278,7 @@
usr << "\blue You need to insert a coin to get this item."
return
if(coin.string_attached)
if(prob(50))
if(prob(80))
usr << "\blue You successfully pull the coin out before the [src] could swallow it."
else
usr << "\blue You weren't able to pull the coin out fast enough, the machine ate it, string and all."
@@ -177,21 +287,34 @@
del(coin)
R.amount--
src.vend_ready = 0
//src.vend_ready = 0
/*
FOLKS IN IRC RULED THAT THIS WAS SHITTY -- Doohl
No more delays! Go nuts~~~~~~~~~~~
if(((src.last_reply + (src.vend_delay + 200)) <= world.time) && src.vend_reply)
spawn(0)
src.speak(src.vend_reply)
src.last_reply = world.time
*/
use_power(5)
if (src.icon_vend) //Show the vending animation if needed
flick(src.icon_vend,src)
spawn(src.vend_delay)
new product_path(get_turf(src))
src.vend_ready = 1
updateWindow(user)
// spawn(src.vend_delay) NOPE.jpg
//src.vend_ready = 1
new product_path(get_turf(src))
if(R)
if(R in coin_records)
updateWindow(user)
return
updateWindow(user, 0)
/obj/machinery/vending/attackby(obj/item/weapon/W as obj, mob/user as mob)
@@ -211,7 +334,11 @@
if(src.panel_open)
attack_hand(user)
return
else if(istype(W, /obj/item/weapon/coin) && product_coin != "")
else if(istype(W, /obj/item/weapon/coin))
if(product_coin == "" || !product_coin)
user << "\blue This machine doesn't have a coin slot."
return
user.drop_item()
W.loc = src
coin = W
@@ -249,7 +376,7 @@
return
updateWindow(user)
winshow(user, "vendingwindow", 1)
winshow(user, "vendingwindow_n", 1)
user.skincmds["vending"] = src
var/dat = "<B>[src.name]</B>"