Updating spawn(Create Object) for admin panel (#5442)

Create Object now populates list of objects instantly. Compared to original 3-4 seconds of freezes.
Quick Create Object was removed due to regular being extremely fast.
This commit is contained in:
Mykhailo Bykhovtsev
2018-10-28 03:02:17 -07:00
committed by Werner
parent 65f0c886c1
commit 76c630dcfb
5 changed files with 68 additions and 39 deletions

View File

@@ -620,7 +620,6 @@ proc/admin_notice(var/message, var/rights)
dat += {" dat += {"
<BR> <BR>
<A href='?src=\ref[src];create_object=1'>Create Object</A><br> <A href='?src=\ref[src];create_object=1'>Create Object</A><br>
<A href='?src=\ref[src];quick_create_object=1'>Quick Create Object</A><br>
<A href='?src=\ref[src];create_turf=1'>Create Turf</A><br> <A href='?src=\ref[src];create_turf=1'>Create Turf</A><br>
<A href='?src=\ref[src];create_mob=1'>Create Mob</A><br> <A href='?src=\ref[src];create_mob=1'>Create Mob</A><br>
<br><A href='?src=\ref[src];vsc=airflow'>Edit Airflow Settings</A><br> <br><A href='?src=\ref[src];vsc=airflow'>Edit Airflow Settings</A><br>

View File

@@ -8,22 +8,3 @@
create_object_html = replacetext(create_object_html, "null /* object types */", "\"[objectjs]\"") create_object_html = replacetext(create_object_html, "null /* object types */", "\"[objectjs]\"")
user << browse(replacetext(create_object_html, "/* ref src */", "\ref[src]"), "window=create_object;size=425x475") user << browse(replacetext(create_object_html, "/* ref src */", "\ref[src]"), "window=create_object;size=425x475")
/datum/admins/proc/quick_create_object(var/mob/user)
var/quick_create_object_html = null
var/pathtext = null
pathtext = input("Select the path of the object you wish to create.", "Path", "/obj") as null|anything in list("/obj","/obj/structure","/obj/item","/obj/item/weapon","/obj/item/clothing","/obj/machinery","/obj/mecha")
if(!pathtext)
return
var path = text2path(pathtext)
if (!quick_create_object_html)
var/objectjs = null
objectjs = jointext(typesof(path), ";")
quick_create_object_html = file2text('html/create_object.html')
quick_create_object_html = replacetext(quick_create_object_html, "null /* object types */", "\"[objectjs]\"")
user << browse(replacetext(quick_create_object_html, "/* ref src */", "\ref[src]"), "window=quick_create_object;size=425x475")

View File

@@ -1165,10 +1165,6 @@
if(!check_rights(R_SPAWN)) return if(!check_rights(R_SPAWN)) return
return create_object(usr) return create_object(usr)
else if(href_list["quick_create_object"])
if(!check_rights(R_SPAWN)) return
return quick_create_object(usr)
else if(href_list["create_turf"]) else if(href_list["create_turf"])
if(!check_rights(R_SPAWN)) return if(!check_rights(R_SPAWN)) return
return create_turf(usr) return create_turf(usr)

View File

@@ -0,0 +1,38 @@
################################
# 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
#################################
# Your name.
author: PoZe
# 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:
- tweak: "Admin verb Create Object major flaw was optimized to display/search lists of all objects instantly, instead of freezing for 3-4 seconds."
- rscdel: "Since Create Object is exteremely fast now there is no need for Quick Create Object. So I removed it."

View File

@@ -26,6 +26,7 @@
<body> <body>
<form name="spawner" action="byond://?src=/* ref src */" method="get"> <form name="spawner" action="byond://?src=/* ref src */" method="get">
<input type="hidden" name="src" value="/* ref src */"> <input type="hidden" name="src" value="/* ref src */">
<input type="hidden" name="action" value="object_list">
Type <input type="text" name="filter" value="" onkeypress="submitFirst(event)" style="width:280px;height:25"> <input type = "button" value = "Search" onclick = "updateSearch()" /><br> Type <input type="text" name="filter" value="" onkeypress="submitFirst(event)" style="width:280px;height:25"> <input type = "button" value = "Search" onclick = "updateSearch()" /><br>
Offset: <input type="text" name="offset" value="x,y,z" style="width:250px"> Offset: <input type="text" name="offset" value="x,y,z" style="width:250px">
@@ -43,13 +44,22 @@
<option value='inmarked'>In marked object</option> <option value='inmarked'>In marked object</option>
</select> </select>
<br><br> <br><br>
<select name="object_list" id="object_list" size="18" multiple style="width:98%"></select><br> Number of matches: <input id="number" value="0" style="width:180px"><br>
<br><br>
<div id="selector_hs">
<select name="object_list" id="object_list" multiple size="20">
</select>
</div>
<br>
<input type="submit" value="spawn"> <input type="submit" value="spawn">
</form> </form>
<script language="JavaScript"> <script language="JavaScript">
var old_search = ""; var old_search = "";
var object_list = document.spawner.object_list; var object_list = document.spawner.object_list;
var object_list_container = document.getElementById('selector_hs');
var object_paths = null /* object types */; var object_paths = null /* object types */;
var objects = object_paths == null ? new Array() : object_paths.split(";"); var objects = object_paths == null ? new Array() : object_paths.split(";");
@@ -58,23 +68,23 @@
function populateList(from_list) function populateList(from_list)
{ {
object_list.options.length = 0; var newOpts = '';
var i; var i;
for (i in from_list) for (i in from_list)
{ {
var new_option = document.createElement("option"); newOpts += '<option value="' + from_list[i] + '">'
new_option.value = from_list[i]; + from_list[i] + '</option>';
new_option.text = from_list[i];
object_list.options.add(new_option);
} }
object_list_container.innerHTML = '<select name="object_list" id="object_list" multiple size="20">' +
newOpts + '</select>';
document.getElementById("number").value = from_list.length;
} }
function updateSearch() function updateSearch()
{ {
if (old_search == document.spawner.filter.value) if (old_search == document.spawner.filter.value)
{ {
return; return false;
} }
old_search = document.spawner.filter.value; old_search = document.spawner.filter.value;
@@ -93,6 +103,11 @@
} }
populateList(filtered); populateList(filtered);
if (object_list.options.length)
object_list.options[0].selected = 'true';
return true;
} }
function submitFirst(event) function submitFirst(event)