- A hacked together pseudo-ajax. I called it byjax (byond+ajax).

- Fixed a couple of nasty mech fabricator bugs.
- Tweaked mecha status window.
- Mecha equipment is now detachable (the command is in mecha "Equipment" menu).
- Misc.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1506 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
panurgomatic
2011-04-28 04:54:26 +00:00
parent 011fc30295
commit 4c28bdff21
14 changed files with 219 additions and 66 deletions

View File

@@ -901,3 +901,14 @@ proc/anim(a,b,c,d,e)
else
sleep(15)
del(animation)
//returns list element or null. Should prevent "index out of bounds" error.
proc/listgetindex(var/list/list,index)
if(istype(list) && list.len)
if(isnum(index))
if(index>0 && index<=list.len)
return list[index]
else if(index in list)
return list[index]
return

View File

@@ -54,7 +54,13 @@
return output
/obj/mecha/combat/durand/get_commands()
var/output = "<a href='?src=\ref[src];toggle_defence_mode=1'>Toggle defence mode</a><hr>"
var/output = {"<div class='wr'>
<div class='header'>Special</div>
<div class='links'>
<a href='?src=\ref[src];toggle_defence_mode=1'>Toggle defence mode</a>
</div>
</div>
"}
output += ..()
return output

View File

@@ -60,7 +60,13 @@
return output
/obj/mecha/combat/gygax/get_commands()
var/output = "<a href='?src=\ref[src];toggle_leg_overload=1'>Toggle leg actuators overload</a><br><hr>"
var/output = {"<div class='wr'>
<div class='header'>Special</div>
<div class='links'>
<a href='?src=\ref[src];toggle_leg_overload=1'>Toggle leg actuators overload</a>
</div>
</div>
"}
output += ..()
return output

View File

@@ -140,10 +140,15 @@
/obj/mecha/combat/marauder/get_commands()
var/output = {"<a href='?src=\ref[src];toggle_thrusters=1'>Toggle thrusters</a><br>
var/output = {"<div class='wr'>
<div class='header'>Special</div>
<div class='links'>
<a href='?src=\ref[src];toggle_thrusters=1'>Toggle thrusters</a><br>
<a href='?src=\ref[src];toggle_zoom=1'>Toggle zoom mode</a><br>
<a href='?src=\ref[src];smoke=1'>Smoke</a>
<hr>"}
</div>
</div>
"}
output += ..()
return output

View File

@@ -28,6 +28,11 @@
/obj/item/mecha_parts/mecha_equipment/proc/destroy()//missiles detonating, teleporter creating singularity?
if(chassis)
chassis.equipment -= src
if(chassis.selected == src)
chassis.selected = null
send_byjax(chassis.occupant,"exosuit.browser","equipment_menu",chassis.get_equipment_menu(),"dropdowns")
spawn
del src
return
@@ -69,22 +74,28 @@
M.log_message("[src] initialized.")
if(!M.selected)
M.selected = src
send_byjax(M.occupant,"exosuit.browser","equipment_menu",M.get_equipment_menu(),"dropdowns")
return
/obj/item/mecha_parts/mecha_equipment/weapon/can_attach(obj/mecha/M as obj)
if(..())
if(istype(M, /obj/mecha/combat))
return 1
return 0
/obj/item/mecha_parts/mecha_equipment/proc/detach()
if(src.Move(get_turf(chassis)))
chassis.equipment -= src
if(chassis.selected == src)
chassis.selected = null
send_byjax(chassis.occupant,"exosuit.browser","equipment_menu",chassis.get_equipment_menu(),"dropdowns")
chassis.log_message("[src] removed from equipment.")
src.chassis = null
src.equip_ready = 1
return
/obj/item/mecha_parts/mecha_equipment/Topic(href,href_list)
if(href_list["detach"])
src.detach()
return
/obj/item/mecha_parts/mecha_equipment/proc/set_state(state)
equip_ready = state
send_byjax(chassis.occupant,"exosuit.browser","\ref[src]",src.get_equip_info())
return

View File

@@ -425,6 +425,11 @@
chassis.proc_res["dynattackby"] = src
return
detach()
chassis.proc_res["dynattackby"] = null
..()
return
proc/dynattackby(obj/item/weapon/W as obj, mob/user as mob)
if(!action_checks(user))
return chassis.dynattackby(W,user)
@@ -468,6 +473,12 @@
chassis.proc_res["dynhitby"] = src
return
detach()
chassis.proc_res["dynbulletdamage"] = null
chassis.proc_res["dynhitby"] = null
..()
return
proc/dynbulletdamage(flag)
if(!action_checks(src))
return chassis.dynbulletdamage(flag)
@@ -559,6 +570,7 @@
return output
Topic(href, href_list)
..()
if(href_list["toggle_repairs"])
chassis.overlays -= droid_overlay
if(pr_repair_droid.toggle())
@@ -615,7 +627,7 @@
can_attach(obj/mecha/M as obj)
if(..())
if(!istype(M, /obj/mecha/combat/honker))
if(!M.proc_res["dynattackby"] && !M.proc_res["dynattackhand"] && !!M.proc_res["dynattackalien"])
if(!M.proc_res["dynattackby"] && !M.proc_res["dynattackhand"] && !M.proc_res["dynattackalien"])
return 1
return 0

View File

@@ -192,6 +192,7 @@
return
Topic(href, href_list)
..()
if (href_list["rearm"])
src.rearm()
return

View File

@@ -173,10 +173,10 @@
return
*/
proc/output_parts_list(set_name as text)
proc/output_parts_list(set_name)
var/output = ""
if(set_name in part_sets)
var/list/part_set = part_sets[set_name]
var/list/part_set = listgetindex(part_sets, set_name)
if(istype(part_set))
for(var/atom/part in part_set)
var/resources_available = check_resources(part)
output += "<div class='part'>[output_part_info(part)]<br>\[[resources_available?"<a href='?src=\ref[src];part=\ref[part]'>Build</a> | ":null]<a href='?src=\ref[src];add_to_queue=\ref[part]'>Add to queue</a>\]\[<a href='?src=\ref[src];part_desc=\ref[part]'>?</a>\]</div>"
@@ -201,20 +201,20 @@
output += "<span class=\"res_name\">[resource]: </span>[min(res_max_amount, resources[resource])] cm&sup3;<br>"
return output
proc/remove_resources(var/obj/item/mecha_parts/part as obj)
proc/remove_resources(var/obj/item/mecha_parts/part)
for(var/resource in part.construction_cost)
if(resource in src.resources)
src.resources[resource] -= get_resource_cost_w_coeff(part,resource,1)
return
proc/check_resources(var/obj/item/mecha_parts/part as obj)
proc/check_resources(var/obj/item/mecha_parts/part)
for(var/resource in part.construction_cost)
if(resource in src.resources)
if(src.resources[resource] < get_resource_cost_w_coeff(part,resource,1))
return 0
return 1
proc/build_part(var/obj/item/mecha_parts/part as obj)
proc/build_part(var/obj/item/mecha_parts/part)
if(!part) return
src.being_built = new part.type(src)
src.desc = "It's building [src.being_built]."
@@ -225,40 +225,41 @@
sleep(get_construction_time_w_coeff(part,0.1))
//if(!src) return // you do not need to check it, all sleeping procedires will be terminated when src dies. -- rastaf0
src.use_power = 1
if(!being_built) return //was runtime error with null.Move()
src.being_built.Move(get_step(src,EAST))
src.icon_state = initial(src.icon_state)
src.visible_message("<b>[src]</b> beeps, \"The [src.being_built] is complete\".")
src.icon_state = initial(src.icon_state)
src.being_built = null
src.desc = initial(src.desc)
if(being_built)
src.being_built.Move(get_step(src,EAST))
src.visible_message("<b>[src]</b> beeps, \"The [src.being_built] is complete\".")
src.being_built = null
src.updateUsrDialog()
return 1
proc/add_part_set_to_queue(set_name as text)
proc/add_part_set_to_queue(set_name)
if(set_name in part_sets)
var/list/part_set = part_sets[set_name]
for(var/part in part_set)
add_to_queue(part)
return
proc/add_to_queue(part as obj)
proc/add_to_queue(part)
if(!istype(queue, /list))
queue = list()
queue[++queue.len] = part
if(part)
queue[++queue.len] = part
return queue.len
proc/remove_from_queue(index as num)
if(!istype(queue, /list) || !queue[index])
proc/remove_from_queue(index)
if(!isnum(index) || !istype(queue, /list) || (index<1 || index>queue.len))
return 0
queue.Cut(index,++index)
return 1
proc/process_queue()
while(istype(queue, /list) && queue.len)
var/part = listgetindex(src.queue, 1)
temp = null
while(part)
if(stat&(NOPOWER|BROKEN))
return 0
var/part = queue[1]
if(!check_resources(part))
src.visible_message("<b>[src]</b> beeps, \"Not enough resources. Queue processing stopped\".")
temp = {"<font color='red'>Not enough resources to build next part.</font><br>
@@ -266,6 +267,7 @@
return 0
remove_from_queue(1)
build_part(part)
part = listgetindex(src.queue, 1)
src.visible_message("<b>[src]</b> beeps, \"Queue processing finished successfully\".")
return 1
@@ -276,8 +278,9 @@
else
output += "<ol>"
for(var/i=1;i<=queue.len;i++)
var/atom/part = queue[i]
output += "<li[!check_resources(part)?" style='color: #f00;'":null]>[part.name] - [i>1?"<a href='?src=\ref[src];queue_move=-1;index=[i]' class='arrow'>&uarr;</a>":null] [i<queue.len?"<a href='?src=\ref[src];queue_move=+1;index=[i]' class='arrow'>&darr;</a>":null] <a href='?src=\ref[src];remove_from_queue=[i]'>Remove</a></li>"
var/atom/part = listgetindex(src.queue, i)
if(part)
output += "<li[!check_resources(part)?" style='color: #f00;'":null]>[part.name] - [i>1?"<a href='?src=\ref[src];queue_move=-1;index=[i]' class='arrow'>&uarr;</a>":null] [i<queue.len?"<a href='?src=\ref[src];queue_move=+1;index=[i]' class='arrow'>&darr;</a>":null] <a href='?src=\ref[src];remove_from_queue=[i]'>Remove</a></li>"
output += "</ol>"
output += "\[<a href='?src=\ref[src];process_queue=1'>Process queue</a> | <a href='?src=\ref[src];clear_queue=1'>Clear queue</a>\]"
return output
@@ -423,7 +426,8 @@
var/part_set = href_list["partset_to_queue"]
add_part_set_to_queue(part_set)
if(href_list["process_queue"])
temp = null
if(processing_queue || being_built)
return 0
processing_queue = 1
process_queue()
processing_queue = 0

View File

@@ -56,7 +56,6 @@
var/list/internals_req_access = list(access_engine,access_robotics)//required access level to open cell compartment
var/datum/global_iterator/pr_int_temp_processor //normalizes internal air mixture temperature
var/datum/global_iterator/pr_update_stats //used to auto-update stats window
var/datum/global_iterator/pr_inertial_movement //controls intertial movement in spesss
// var/datum/global_iterator/pr_location_temp_check //processes location temperature damage
var/datum/global_iterator/pr_internal_damage //processes internal damage
@@ -83,7 +82,6 @@
//misc global_iteration datums
pr_int_temp_processor = new /datum/global_iterator/mecha_preserve_temp(list(src))
pr_update_stats = new /datum/global_iterator/mecha_view_stats(list(src),0)
pr_inertial_movement = new /datum/global_iterator/mecha_intertial_movement(null,0)
// pr_location_temp_check = new /datum/global_iterator/mecha_location_temp_check(list(src))
pr_internal_damage = new /datum/global_iterator/mecha_internal_damage(list(src),0)
@@ -779,7 +777,8 @@
set src in view(0)
if(usr!=src.occupant)
return
pr_update_stats.start()
//pr_update_stats.start()
src.occupant << browse(src.get_stats_html(), "window=exosuit")
return
/*
@@ -827,7 +826,6 @@
src.occupant.canmove = 0
src.verbs += /obj/mecha/verb/eject
src.occupant = null
src.pr_update_stats.stop()
src.icon_state = initial(icon_state)+"-open"
src.dir = SOUTH
return
@@ -863,7 +861,7 @@
/obj/mecha/proc/get_log_html()
var/output = "<html><head><title>[src.name] Log</title></head><body style='font: 13px 'Courier', monospace;'>"
for(var/list/entry in log)
output += {"<div style='font-weight: bold;'>[time2text(entry["time"],"DDD MMM DD hh:mm:ss")]</div>
output += {"<div style='font-weight: bold;'>[time2text(entry["time"],"DDD MMM DD hh:mm:ss")] 2555</div>
<div style='margin-left:15px; margin-bottom:10px;'>[entry["message"]]</div>
"}
output += "</body></html>"
@@ -1066,10 +1064,32 @@
<style>
body {color: #00ff00; background: #000000; font: 13px 'Courier', monospace;}
hr {border: 1px solid #0f0; color: #0f0; background-color: #0f0;}
.wr {margin-bottom: 5px;}
.header {cursor:pointer;}
.open, .closed {background: #32CD32; color:#000; padding:1px 2px;}
.links a {margin-bottom: 2px;}
.visible {display: block;}
.hidden {display: none;}
</style>
<script language='javascript' type='text/javascript'>
[js_byjax]
[js_dropdowns]
function ticker() {
setInterval(function(){
window.location='byond://?src=\ref[src]&update_content=1';
}, 1000);
}
window.onload = function() {
dropdowns();
ticker();
}
</script>
</head>
<body>
<div id='content'>
[src.get_stats_part()]
</div>
<hr>
[src.get_commands()]
</body>
@@ -1096,23 +1116,47 @@
return output
/obj/mecha/proc/get_commands()
var/output = {"<a href='?src=\ref[src];toggle_lights=1'>Toggle Lights</a><br>
var/output = {"<div class='wr'>
<div class='header'>Lights & Airtank</div>
<div class='links'>
<a href='?src=\ref[src];toggle_lights=1'>Toggle Lights</a><br>
<a href='?src=\ref[src];toggle_airtank=1'>Toggle Internal Airtank Usage</a><br>
[(/obj/mecha/verb/disconnect_from_port in src.verbs)?"<a href='?src=\ref[src];port_disconnect=1'>Disconnect from port</a><br>":null]
[(/obj/mecha/verb/connect_to_port in src.verbs)?"<a href='?src=\ref[src];port_connect=1'>Connect to port</a><br>":null]
<hr>
</div>
</div>
<div class='wr'>
<div class='header'>Permissions & Logging</div>
<div class='links'>
<a href='?src=\ref[src];unlock_id_upload=1'>Unlock ID upload panel</a><br>
<a href='?src=\ref[src];view_log=1'>View internal log</a><br>
<a href='?src=\ref[src];dna_lock=1'>DNA-lock</a><br>
<a href='?src=\ref[src];view_log=1'>View internal log</a><br>
</div>
</div>
<div id='equipment_menu'>[get_equipment_menu()]</div>
<hr>
[(/obj/mecha/verb/eject in src.verbs)?"<a href='?src=\ref[src];eject=1'>Eject</a><br>":null]
"}
"}
return output
/obj/mecha/proc/get_equipment_menu()
var/output
if(equipment.len)
output += {"<div class='wr'>
<div class='header'>Equipment</div>
<div class='links'>"}
for(var/obj/item/mecha_parts/mecha_equipment/W in equipment)
output += "[W.name] <a href='?src=\ref[W];detach=1'>Detach</a><br>"
output += "</div></div>"
return output
/obj/mecha/Topic(href, href_list)
..()
if(href_list["update_content"])
send_byjax(src.occupant,"exosuit.browser","content",src.get_stats_part())
return
if (href_list["close"])
src.pr_update_stats.stop()
return
if (href_list["toggle_lights"])
src.toggle_lights()
@@ -1171,6 +1215,8 @@
src.occupant_message("You feel a prick as the needle takes your DNA sample.")
if(href_list["reset_dna"])
src.dna = null
/*
if (href_list["ai_take_control"])
@@ -1281,14 +1327,6 @@
int_tank_air.temperature -= max(-10, min(10, round(delta/4,0.1)))
return
/datum/global_iterator/mecha_view_stats // open and update stats window
process(var/obj/mecha/mecha)
if(mecha.occupant)
mecha.occupant << browse(mecha.get_stats_html(), "window=exosuit")
onclose(mecha.occupant, "exosuit", mecha)
return
/datum/global_iterator/mecha_intertial_movement //inertial movement in space
delay = 7
@@ -1300,19 +1338,6 @@
src.stop()
return
/*
/datum/global_iterator/mecha_location_temp_check //mecha location temperature checks
process(var/obj/mecha/mecha)
if(istype(mecha.loc, /turf/simulated))
var/turf/simulated/T = mecha.loc
if(T.air)
if(T.air.temperature > mecha.max_temperature)
mecha.take_damage(5,"fire")
mecha.check_for_internal_damage(list(MECHA_INT_FIRE, MECHA_INT_TEMP_CONTROL))
return
*/
/datum/global_iterator/mecha_internal_damage // processing internal damage
process(var/obj/mecha/mecha)

View File

@@ -509,7 +509,7 @@ datum
desc = "An exosuit module that allows generating of small quasi-stable wormholes."
id = "mech_wormhole_gen"
build_type = MECHFAB
req_tech = list("bluepace" = 3)
req_tech = list("bluespace" = 3)
build_path = "/obj/item/mecha_parts/mecha_equipment/wormhole_generator"
mech_teleporter

29
code/js/byjax.dm Normal file
View File

@@ -0,0 +1,29 @@
//this function places received data into element with specified id.
var/const/js_byjax = {"
function replaceContent(id,content) {
var parent = document.getElementById(id);
if(typeof(parent)!=='undefined' && parent!=null){
parent.innerHTML = content?content:'';
}
}
"}
/*
sends data to control_id:replaceContent
receiver - mob
control_id - window id (for windows opened with browse(), it'll be "windowname.browser")
target_element - HTML element id
new_content - HTML content
callback - js function that will be called after the data is sent //TODO: move callback processing to js
callback_args - arguments for callback function
Be sure to include required js functions in your page, or it'll raise an exception.
*/
proc/send_byjax(receiver, control_id, target_element, new_content=null, callback=null, list/callback_args=null)
if(receiver && target_element && control_id) // && winexists(receiver, control_id))
receiver << output(list2params(list(target_element, new_content)),"[control_id]:replaceContent")
if(callback)
receiver << output(istype(callback_args)?list2params(callback_args):"","[control_id]:[callback]")
return

40
code/js/menus.dm Normal file
View File

@@ -0,0 +1,40 @@
var/const/js_dropdowns = {"
function dropdowns() {
var divs = document.getElementsByTagName('div');
var headers = new Array();
var links = new Array();
for(var i=0;i<divs.length;i++){
if(divs\[i\].className=='header') {
divs\[i\].className='header closed';
divs\[i\].innerHTML = divs\[i\].innerHTML+' +';
headers.push(divs\[i\]);
}
}
for(var i=0;i<divs.length;i++){
if(divs\[i\].className=='links') {
divs\[i\].className='links hidden';
links.push(divs\[i\]);
}
}
for(var i=0;i<headers.length;i++){
if(typeof(links\[i\])!== 'undefined' && links\[i\]!=null) {
headers\[i\].onclick = (function(elem) {
return function() {
if(elem.className.search('visible')>=0) {
elem.className = elem.className.replace('visible','hidden');
this.className = this.className.replace('open','closed');
this.innerHTML = this.innerHTML.replace('-','+');
}
else {
elem.className = elem.className.replace('hidden','visible');
this.className = this.className.replace('closed','open');
this.innerHTML = this.innerHTML.replace('+','-');
}
return false;
}
})(links\[i\]);
}
}
}
"}

View File

@@ -270,7 +270,7 @@
process(var/obj/machinery/vehicle/space_ship/SS as obj)
if(SS.pr_inertial_movement.desired_delay!=SS.pr_inertial_movement.cur_delay)
var/delta = SS.pr_inertial_movement.desired_delay - SS.pr_inertial_movement.cur_delay
SS.pr_inertial_movement.cur_delay += delta/abs(delta)
SS.pr_inertial_movement.cur_delay += delta>0?1:-1
/*
for(var/mob/M in SS)
M << "Current speed: [SS.get_current_speed()]"

View File

@@ -75,6 +75,7 @@
#define FILE_DIR "code/game/research"
#define FILE_DIR "code/game/spacecraft"
#define FILE_DIR "code/game/verbs"
#define FILE_DIR "code/js"
#define FILE_DIR "code/modules"
#define FILE_DIR "code/modules/admin"
#define FILE_DIR "code/modules/admin/verbs"
@@ -600,6 +601,8 @@
#include "code\game\verbs\sound.dm"
#include "code\game\verbs\suicide.dm"
#include "code\game\verbs\who.dm"
#include "code\js\byjax.dm"
#include "code\js\menus.dm"
#include "code\modules\admin\admin.dm"
#include "code\modules\admin\admin_verbs.dm"
#include "code\modules\admin\banjob.dm"