Merge pull request #4234 from Mloc/bs12-quicklist

[TG] Optimized and refactored list2text, text2list, and replacetext.
This commit is contained in:
Chinsky
2014-01-10 11:55:33 -08:00
20 changed files with 156 additions and 153 deletions
+11 -11
View File
@@ -1,6 +1,6 @@
/obj/item/blueprints
name = "station blueprints"
desc = "Blueprints of the station. There's stamp \"Classified\" and several coffee stains on it."
desc = "Blueprints of the station. There is a \"Classified\" stamp and several coffee stains on it."
icon = 'icons/obj/items.dmi'
icon_state = "blueprints"
attack_verb = list("attacked", "bapped", "hit")
@@ -21,7 +21,7 @@
/obj/item/blueprints/attack_self(mob/M as mob)
if (!istype(M,/mob/living/carbon/human))
M << "This is stack of useless pieces of harsh paper." //monkeys cannot into projecting
M << "This stack of blue paper means nothing to you." //monkeys cannot into projecting
return
interact()
return
@@ -53,18 +53,18 @@
switch (get_area_type())
if (AREA_SPACE)
text += {"
<p>According this blueprints you are in <b>open space</b> now.</p>
<p>According the blueprints, you are now in <b>outer space</b>. Hold your breath.</p>
<p><a href='?src=\ref[src];action=create_area'>Mark this place as new area.</a></p>
"}
if (AREA_STATION)
text += {"
<p>According this blueprints you are in <b>[A.name]</b> now.</p>
<p>According the blueprints, you are now in <b>\"[A.name]\"</b>.</p>
<p>You may <a href='?src=\ref[src];action=edit_area'>
move an amendment</a> to the drawing.</p>
"}
if (AREA_SPECIAL)
text += {"
<p>This place isn't noted on these blueprints.</p>
<p>This place isn't noted on the blueprint.</p>
"}
else
return
@@ -105,20 +105,20 @@ move an amendment</a> to the drawing.</p>
if(!istype(res,/list))
switch(res)
if(ROOM_ERR_SPACE)
usr << "\red New area must be complete airtight!"
usr << "\red The new area must be completely airtight!"
return
if(ROOM_ERR_TOOLARGE)
usr << "\red New area too large!"
usr << "\red The new area too large!"
return
else
usr << "\red Error! Please notify administration!"
return
var/list/turf/turfs = res
var/str = trim(stripped_input(usr,"New area title","Blueprints editing", "", MAX_NAME_LEN))
var/str = trim(stripped_input(usr,"New area name:","Blueprint Editing", "", MAX_NAME_LEN))
if(!str || !length(str)) //cancel
return
if(length(str) > 50)
usr << "\red Text too long."
usr << "\red Name too long."
return
var/area/A = new
A.name = str
@@ -153,8 +153,8 @@ move an amendment</a> to the drawing.</p>
/obj/item/blueprints/proc/edit_area()
var/area/A = get_area()
//world << "DEBUG: edit_area"
var/prevname = A.name
var/str = trim(stripped_input(usr,"New area title","Blueprints editing", prevname, MAX_NAME_LEN))
var/prevname = "[A.name]"
var/str = trim(stripped_input(usr,"New area name:","Blueprint Editing", prevname, MAX_NAME_LEN))
if(!str || !length(str) || str==prevname) //cancel
return
if(length(str) > 50)
+10 -10
View File
@@ -35,7 +35,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
/obj/item/device/uplink/proc/generate_nanoui_items()
var/items_nano[0]
for(var/D in ItemList)
var/list/O = stringsplit(D, ":")
var/list/O = text2list(D, ":")
if(O.len != 3) //If it is not an actual item, make a break in the menu.
if(O.len == 1) //If there is one item, it's probably a title
items_nano[++items_nano.len] = list("Category" = "[O[1]]", "items" = list())
@@ -53,7 +53,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
else
var/itemname = O[3]
items_nano[items_nano.len]["items"] += list(list("Name" = itemname, "Cost" = cost, "obj_path" = path_text))
return items_nano
@@ -62,7 +62,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
//Halfassed fix for href exploit ~Z
for(var/D in ItemList)
var/list/O = stringsplit(D, ":")
var/list/O = text2list(D, ":")
if(O.len>0)
valid_items += O[1]
@@ -83,7 +83,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
var/category_items = 1 //To prevent stupid :P
for(var/D in ItemList)
var/list/O = stringsplit(D, ":")
var/list/O = text2list(D, ":")
if(O.len != 3) //If it is not an actual item, make a break in the menu.
if(O.len == 1) //If there is one item, it's probably a title
dat += "<b>[O[1]]</b><br>"
@@ -273,7 +273,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
/obj/item/device/uplink/Topic(href, href_list)
if (href_list["buy_item"])
if(href_list["buy_item"] == "random")
var/boughtItem = chooseRandomItem()
if(boughtItem)
@@ -347,19 +347,19 @@ A list of items and costs is stored under the datum of every game mode, alongsid
/obj/item/device/uplink/hidden/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
var/title = "Syndicate Uplink"
var/data[0]
data["crystals"] = uses
data["nano_items"] = nanoui_items
data["welcome"] = welcome
// update the ui if it exists, returns null if no ui is passed/found
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
if (!ui)
// the ui does not exist, so we'll create a new() one
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
ui = new(user, src, ui_key, "uplink.tmpl", title, 450, 600)
// when the ui is first opened this is the data it will use
ui.set_initial_data(data)
ui.set_initial_data(data)
// open the new ui window
ui.open()
@@ -381,7 +381,7 @@ A list of items and costs is stored under the datum of every game mode, alongsid
usr.set_machine(src)
if(href_list["lock"])
toggle()
ui.close()
ui.close()
return 1
if(..(href, href_list) == 1)
@@ -571,7 +571,7 @@ obj/structure/ex_act(severity)
if(text in direction_table)
return direction_table[text]
var/list/split_text = stringsplit(text, "-")
var/list/split_text = text2list(text, "-")
// If the first token is D, the icon_state represents
// a purely decorative tube, and doesn't actually