Experimental DMF vending machine update, by Tobba.

Pretty sure everyone who cares knows about this already, but the low down is that shit is more responsive and potentially prettier.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@2529 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
petethegoat@gmail.com
2011-11-18 00:45:50 +00:00
parent 38d90773cc
commit 5545d032be
6 changed files with 594 additions and 31 deletions

View File

@@ -4,6 +4,7 @@
WIRE_SCANID = 2
WIRE_SHOCK = 3
WIRE_SHOOTINV = 4
var/page
/datum/data/vending_product
var/product_name = "generic"
@@ -13,6 +14,7 @@
/obj/machinery/vending/New()
..()
page = 1
spawn(4)
src.slogan_list = dd_text2List(src.product_slogans, ";")
var/list/temp_paths = dd_text2List(src.product_paths, ";")
@@ -93,6 +95,80 @@
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]")
winset(user, "vendingslot[i].buy", "command=\"skincmd vending;buy[i-1]\"")
winset(user, "vendingwindow.title", "text=\"[src.name]\"")
var/list/products = src.product_records
var/pages = -round(-products.len / 6)
if (page > pages)
page = pages
winset(user, "vendingwindow.page", "text=[page]/[pages]")
var/base = (page-1)*6+1
for (i = 0, i < 6, i++)
if (products.len >= base + i)
var/datum/data/vending_product/product = products[base + i]
winset(user, "vendingslot[i+1].name", "text=\"[product.product_name]\"")
if (product.amount > 0)
winset(user, "vendingslot[i+1].stock", "text=\"Left in stock: [product.amount]\"")
winset(user, "vendingslot[i+1].stock", "text-color=\"#000000\"")
winshow(user, "vendingslot[i+1].buy", 1)
else
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)
else
winshow(user, "vendingwindow.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
var/pages = -round(-products.len / 6)
switch(data)
if ("pagen")
page++
if (page > pages)
page = pages
if ("pagep")
page--
if (page < 1)
page = 1
if (copytext(data, 1, 4) == "buy")
var/base = (page-1)*6+1
var/num = text2num(copytext(data, 4))
if (products.len < base + num)
return
var/datum/data/vending_product/R = products[base + num]
var/product_path = text2path(R.product_path)
if (R.amount <= 0)
return
if (!src.vend_ready)
return
R.amount--
src.vend_ready = 0
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)
/obj/machinery/vending/attackby(obj/item/weapon/W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/card/emag))
@@ -135,32 +211,9 @@
if(src.shock(user, 100))
return
var/dat = "<TT><b>Select an item:</b><br>"
if (product_coin != "")
dat += "<b>Coin slot:</b> [coin ? coin : "No coin inserted"] (<a href='byond://?src=\ref[src];remove_coin=1'>Remove</A>)<br><br>"
if (src.product_records.len == 0)
dat += "<font color = 'red'>No product loaded!</font>"
else
var/list/display_records = src.product_records
if(src.extended_inventory)
display_records = src.product_records + src.hidden_records
if(src.coin)
display_records = src.product_records + src.coin_records
if(src.coin && src.extended_inventory)
display_records = src.product_records + src.hidden_records + src.coin_records
for (var/datum/data/vending_product/R in display_records)
dat += "<FONT color = '[R.display_color]'><B>[R.product_name]</B>:"
dat += " [R.amount] </font>"
if (R.amount > 0)
dat += "<a href='byond://?src=\ref[src];vend=\ref[R]'>Vend</A>"
else
dat += "<font color = 'red'>SOLD OUT</font>"
dat += "<br>"
dat += "</TT>"
updateWindow(user)
winshow(user, "vendingwindow", 1)
user.skincmds["vending"] = src
if(panel_open)
var/list/vendwires = list(
@@ -169,7 +222,7 @@
"Goldenrod" = 3,
"Green" = 4,
)
dat += "<br><hr><br><B>Access Panel</B><br>"
var/dat = "<br><hr><br><B>Access Panel</B><br>"
for(var/wiredesc in vendwires)
var/is_uncut = src.wires & APCWireColorToFlag[vendwires[wiredesc]]
dat += "[wiredesc] wire: "
@@ -188,9 +241,9 @@
if (product_slogans != "")
dat += "The speaker switch is [src.shut_up ? "off" : "on"]. <a href='?src=\ref[src];togglevoice=[1]'>Toggle</a>"
user << browse(dat, "")
onclose(user, "")
user << browse(dat, "")
onclose(user, "")
return
/obj/machinery/vending/Topic(href, href_list)

13
code/game/skincmd.dm Normal file
View File

@@ -0,0 +1,13 @@
/mob/var/skincmds = list()
/obj/proc/SkinCmd(mob/user as mob, var/data as text)
/proc/SkinCmdRegister(var/mob/user, var/name as text, var/O as obj)
user.skincmds[name] = O
/mob/verb/skincmd(data as text)
set hidden = 1
var/ref = copytext(data, 1, findtext(data, ";"))
if (src.skincmds[ref] != null)
var/obj/a = src.skincmds[ref]
a.SkinCmd(src, copytext(data, findtext(data, ";") + 1))

View File

@@ -54,6 +54,15 @@ Stuff which is in development and not yet visible to players or just code relate
(ie. code improvements for expandability, etc.) should not be listed here. They
should be listed in the changelog upon commit tho. Thanks. -->
<b><font color='blue'>16 November 2011</font><b>
<ul>
<li><b>Tobba updated:</b>
<ul>
<li>Report any issues with the updated vending machines!</li>
</ul>
</li>
</ul>
<b><font color='blue'>16 November 2011</font><b>
<ul>
<li><b>Petethegoat updated:</b>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -136,6 +136,40 @@ macro "macro"
command = ".screenshot"
is-disabled = false
macro "vending"
elem
name = "NORTHEAST"
command = "skincmd \"vending;pagen\""
is-disabled = false
elem
name = "SOUTHEAST"
command = "skincmd \"vending;pagep\""
is-disabled = false
elem
name = "1"
command = "skincmd \"vending;buy0\""
is-disabled = false
elem
name = "2"
command = "skincmd \"vending;buy1\""
is-disabled = false
elem
name = "3"
command = "skincmd \"vending;buy2\""
is-disabled = false
elem
name = "4"
command = "skincmd \"vending;buy3\""
is-disabled = false
elem
name = "5"
command = "skincmd \"vending;buy4\""
is-disabled = false
elem
name = "6"
command = "skincmd \"vending;buy5\""
is-disabled = false
menu "menu"
elem
@@ -567,7 +601,7 @@ window "outputwindow"
window "rpane"
elem "rpane"
type = MAIN
pos = 559,121
pos = 281,0
size = 640x480
anchor1 = none
anchor2 = none
@@ -825,7 +859,7 @@ window "infowindow"
elem "info"
type = INFO
pos = 0,0
size = 640x499
size = 638x475
anchor1 = 0,0
anchor2 = 100,100
font-family = ""
@@ -854,3 +888,455 @@ window "infowindow"
on-hide = ".winset\"rpane.infob.is-visible=false;rpane.browseb.is-visible=true?rpane.browseb.is-checked=true rpane.rpanewindow.left=browserwindow:rpane.textb.is-visible=true rpane.rpanewindow.pos=0,30 rpane.rpanewindow.size=0x0 rpane.rpanewindow.left=\""
on-tab = ""
window "vendingslot"
elem "vendingslot"
type = MAIN
pos = 281,0
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = false
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "pos;size;is-minimized;is-maximized"
on-size = ""
title = ""
titlebar = false
statusbar = false
can-close = false
can-minimize = false
can-resize = false
is-pane = true
is-minimized = false
is-maximized = false
can-scroll = none
icon = ""
image = 'icons\\vending_icons\\vendingslot_bg.png'
image-mode = stretch
keep-aspect = false
transparent-color = none
alpha = 255
macro = ""
menu = ""
on-close = ""
elem "buy"
type = BUTTON
pos = 228,4
size = 52x52
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = #9f9f9f
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "is-checked"
on-size = ""
text = "Buy"
image = ""
command = ""
is-flat = false
stretch = false
is-checked = false
group = ""
button-type = pushbutton
elem "stock"
type = LABEL
pos = 8,36
size = 216x20
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = true
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = ""
on-size = ""
text = "Left in stock: 0"
image = ""
image-mode = center
keep-aspect = false
align = center
text-wrap = false
elem "name"
type = LABEL
pos = 8,4
size = 216x28
anchor1 = none
anchor2 = none
font-family = ""
font-size = 14
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = true
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = ""
on-size = ""
text = "HoNK"
image = ""
image-mode = center
keep-aspect = false
align = center
text-wrap = false
window "vendingwindow"
elem "vendingwindow"
type = MAIN
pos = 758,177
size = 300x470
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = false
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "pos;size;is-minimized;is-maximized"
on-size = ""
title = ""
titlebar = true
statusbar = false
can-close = true
can-minimize = false
can-resize = false
is-pane = false
is-minimized = false
is-maximized = false
can-scroll = none
icon = ""
image = ""
image-mode = stretch
keep-aspect = false
transparent-color = none
alpha = 255
macro = "vending"
menu = ""
on-close = ""
elem "slot6"
type = CHILD
pos = 8,364
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "slot5"
type = CHILD
pos = 8,300
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "page"
type = LABEL
pos = 64,448
size = 36x16
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = ""
on-size = ""
text = "1/1"
image = ""
image-mode = center
keep-aspect = false
align = center
text-wrap = false
elem "button2"
type = BUTTON
pos = 96,448
size = 16x16
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "is-checked"
on-size = ""
text = ">"
image = ""
command = "skincmd \"vending;pagen\""
is-flat = false
stretch = false
is-checked = false
group = ""
button-type = pushbutton
elem "button1"
type = BUTTON
pos = 48,448
size = 16x16
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "is-checked"
on-size = ""
text = "<"
image = ""
command = "skincmd \"vending;pagep\""
is-flat = false
stretch = false
is-checked = false
group = ""
button-type = pushbutton
elem "label1"
type = LABEL
pos = 8,448
size = 40x16
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = ""
on-size = ""
text = "Page: "
image = ""
image-mode = center
keep-aspect = false
align = center
text-wrap = false
elem "slot4"
type = CHILD
pos = 8,236
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "slot3"
type = CHILD
pos = 8,172
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "slot2"
type = CHILD
pos = 8,108
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "slot1"
type = CHILD
pos = 8,40
size = 288x60
anchor1 = none
anchor2 = none
font-family = ""
font-size = 0
font-style = ""
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = false
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = "splitter"
on-size = ""
left = ""
right = ""
is-vert = false
splitter = 50
show-splitter = true
lock = none
elem "title"
type = LABEL
pos = 5,8
size = 291x33
anchor1 = 1,2
anchor2 = 99,6
font-family = ""
font-size = 12
font-style = "bold"
text-color = #000000
background-color = none
is-visible = true
is-disabled = false
is-transparent = true
is-default = false
border = none
drop-zone = false
right-click = false
saved-params = ""
on-size = ""
text = "Crazy Dave's vending machine"
image = ""
image-mode = center
keep-aspect = false
align = top
text-wrap = false

View File

@@ -157,6 +157,7 @@
#define FILE_DIR "icons/spideros_icons"
#define FILE_DIR "icons/Testing"
#define FILE_DIR "icons/turf"
#define FILE_DIR "icons/vending_icons"
#define FILE_DIR "interface"
#define FILE_DIR "maps"
#define FILE_DIR "sound"
@@ -342,6 +343,7 @@
#include "code\game\master_controller.dm"
#include "code\game\prisonshuttle.dm"
#include "code\game\shuttle_engines.dm"
#include "code\game\skincmd.dm"
#include "code\game\smoothwall.dm"
#include "code\game\sound.dm"
#include "code\game\specops_shuttle.dm"