Skip to content

Commit

Permalink
Adds the merchant program UI. (#16730)
Browse files Browse the repository at this point in the history
* pt 1

* get out of my way yeah yeah cause i got a heart of steel

---------

Co-authored-by: Matt Atlas <[email protected]>
  • Loading branch information
NonQueueingMatt and Matt Atlas committed Jul 15, 2023
1 parent f47e586 commit d0f81c3
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 100 deletions.
2 changes: 1 addition & 1 deletion code/datums/trading/trade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
num = Clamp(num,1,trading_items.len)
if(trading_items[num])
var/atom/movable/M = trading_items[num]
return "<b>[initial(M.name)]</b>"
return "[initial(M.name)]"

/datum/trader/proc/get_item_value(var/trading_num)
if(!trading_items[trading_items[trading_num]])
Expand Down
191 changes: 92 additions & 99 deletions code/modules/merchant/merchant_programs.dm
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
/datum/computer_file/program/merchant
filename = "mlist"
filedesc = "Merchant's List"
filedesc = "Orion Express Goods Trading"
extended_desc = "Allows communication and trade between passing vessels, even while jumping."
program_icon_state = "comm"
program_key_icon_state = "lightblue_key"
nanomodule_path = /datum/nano_module/program/merchant
requires_ntnet = 0
available_on_ntnet = 0
size = 12
usage_flags = PROGRAM_CONSOLE
requires_access_to_run = PROGRAM_ACCESS_LIST_ONE
required_access_run = list(access_merchant)
required_access_download = list(access_merchant)
var/obj/machinery/merchant_pad/pad = null
tgui_id = "Merchant"
var/obj/machinery/merchant_pad/pad
var/current_merchant = 0
var/show_trades = 0
var/hailed_merchant = 0
var/last_comms = null
var/temp = null
var/last_comms
var/temp
var/bank = 0 //A straight up money till

/datum/nano_module/program/merchant
name = "Merchant's List"

/datum/computer_file/program/merchant/proc/get_merchant(var/num)
if(num > SStrade.traders.len)
num = SStrade.traders.len
if(num)
return SStrade.traders[num]

/datum/nano_module/program/merchant/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/ui_state/state = default_state)
var/list/data = host.initial_data()
/datum/computer_file/program/merchant/ui_data(mob/user)
var/list/data = initial_data()
var/show_trade = 0
var/hailed = 0
var/datum/trader/T
if(program)
var/datum/computer_file/program/merchant/P = program
data["temp"] = P.temp
data["mode"] = !!P.current_merchant
data["last_comms"] = P.last_comms
data["pad"] = !!P.pad
data["bank"] = P.bank
show_trade = P.show_trades
hailed = P.hailed_merchant
T = P.get_merchant(P.current_merchant)
data["temp"] = temp
data["mode"] = !!current_merchant
data["last_comms"] = last_comms
data["pad"] = !!pad
data["bank"] = bank
show_trade = show_trades
hailed = hailed_merchant
T = get_merchant(current_merchant)
data["mode"] = !!T
if(T)
data["traderName"] = T.name
Expand All @@ -55,12 +50,9 @@
for(var/i in 1 to T.trading_items.len)
trades += T.print_trading_items(i)
data["trades"] = trades
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "merchant.tmpl", "Merchant List", 575, 700, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
else
data["trades"] = null
return data

/datum/computer_file/program/merchant/proc/connect_pad()
for(var/obj/machinery/merchant_pad/P in orange(1,get_turf(computer)))
Expand Down Expand Up @@ -162,94 +154,95 @@
bank = 0
B.update_icon()

/datum/computer_file/program/merchant/Topic(href, href_list)
/datum/computer_file/program/merchant/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return 1
return
var/mob/user = usr
if(href_list["PRG_connect_pad"])
. = 1
connect_pad()
if(href_list["PRG_continue"])
. = 1
temp = null
if(href_list["PRG_transfer_to_bank"])
. = 1
transfer_to_bank()
if(href_list["PRG_get_money"])
. = 1
get_money()
if(href_list["PRG_main_menu"])
. = 1
current_merchant = 0
if(href_list["PRG_merchant_list"])
if(SStrade.traders.len == 0)
. = 0
temp = "Cannot find any traders within broadcasting range."
else
. = 1
current_merchant = 1
hailed_merchant = 0
last_comms = null
if(href_list["PRG_test_fire"])
. = 1
if(test_fire())
temp = "Test Fire Successful"
else
temp = "Test Fire Unsuccessful"
if(href_list["PRG_scroll"])
. = 1
var/scrolled = 0
switch(href_list["PRG_scroll"])
if("right")
scrolled = 1
if("left")
scrolled = -1
var/new_merchant = Clamp(current_merchant + scrolled, 1, SStrade.traders.len)
if(new_merchant != current_merchant)
hailed_merchant = 0
last_comms = null
current_merchant = new_merchant
switch(action)
if("PRG_connect_pad")
. = TRUE
connect_pad()
if("PRG_continue")
. = TRUE
temp = null
if("PRG_transfer_to_bank")
. = TRUE
transfer_to_bank()
if("PRG_get_money")
. = TRUE
get_money()
if("PRG_main_menu")
. = TRUE
current_merchant = 0
if("PRG_merchant_list")
if(SStrade.traders.len == 0)
. = TRUE
temp = "Cannot find any traders within broadcasting range."
else
. = TRUE
current_merchant = 1
hailed_merchant = 0
last_comms = null
if("PRG_test_fire")
. = TRUE
if(test_fire())
temp = "Test Fire Successful"
else
temp = "Test Fire Unsuccessful"
if("PRG_scroll")
. = TRUE
var/scrolled = 0
switch(params["PRG_scroll"])
if("right")
scrolled = 1
if("left")
scrolled = -1
var/new_merchant = Clamp(current_merchant + scrolled, 1, SStrade.traders.len)
if(new_merchant != current_merchant)
hailed_merchant = 0
last_comms = null
current_merchant = new_merchant
if(current_merchant)
var/datum/trader/T = get_merchant(current_merchant)
if(!T.can_hail())
last_comms = T.get_response("hail_deny", "No, I'm not speaking with you.")
. = 1
. = TRUE
else
if(href_list["PRG_hail"])
. = 1
if(action == "PRG_hail")
. = TRUE
last_comms = T.hail(user)
show_trades = 0
hailed_merchant = 1
if(href_list["PRG_show_trades"])
. = 1
if(action == "PRG_show_trades")
. = TRUE
show_trades = !show_trades
if(href_list["PRG_insult"])
. = 1
if(action == "PRG_insult")
. = TRUE
last_comms = T.insult()
if(href_list["PRG_compliment"])
. = 1
if(action == "PRG_compliment")
. = TRUE
last_comms = T.compliment()
if(href_list["PRG_offer_item"])
. = 1
offer_item(T,text2num(href_list["PRG_offer_item"]) + 1)
if(href_list["PRG_how_much_do_you_want"])
. = 1
last_comms = T.how_much_do_you_want(text2num(href_list["PRG_how_much_do_you_want"]) + 1)
if(href_list["PRG_offer_money_for_item"])
. = 1
offer_money(T, text2num(href_list["PRG_offer_money_for_item"])+1)
if (href_list["PRG_bulk_money_for_item"])
. = 1
bulk_offer(T, text2num(href_list["PRG_bulk_money_for_item"])+1)
if(href_list["PRG_what_do_you_want"])
. = 1
if(action == "PRG_offer_item")
. = TRUE
offer_item(T,text2num(params["PRG_offer_item"]) + 1)
if(action == "PRG_how_much_do_you_want")
. = TRUE
last_comms = T.how_much_do_you_want(text2num(params["PRG_how_much_do_you_want"]) + 1)
if(action == "PRG_offer_money_for_item")
. = TRUE
offer_money(T, text2num(params["PRG_offer_money_for_item"])+1)
if (action == "PRG_bulk_money_for_item")
. = TRUE
bulk_offer(T, text2num(params["PRG_bulk_money_for_item"])+1)
if(action == "PRG_what_do_you_want")
. = TRUE
last_comms = T.what_do_you_want()
if(href_list["PRG_sell_items"])
. = 1
if(action == "PRG_sell_items")
. = TRUE
sell_items(T)
if(href_list["PRG_bribe"])
. = 1
bribe(T, text2num(href_list["PRG_bribe"]))
if(action == "PRG_bribe")
. = TRUE
bribe(T, text2num(params["PRG_bribe"]))

/datum/computer_file/program/merchant/nka
required_access_run = list(access_nka)
Expand Down
41 changes: 41 additions & 0 deletions html/changelogs/mattatlas-youjustliketoactthefool.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
# admin
# backend
# security
# refactor
#################################

# Your name.
author: MattAtlas

# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- bugfix: "The Merchant program now actually has an UI. Oops. It has also been renamed to Orion Express Goods Trading."
Loading

0 comments on commit d0f81c3

Please sign in to comment.