mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-30 15:38:02 +01:00
Merge pull request #16612 from Kashargul/borgFix
cleans up the robot ui code and fixes a runtime
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
name = "Robot Module Configurator"
|
||||
tgui_id = "RobotChoose"
|
||||
var/selected_module
|
||||
var/newName
|
||||
var/new_name
|
||||
var/datum/robot_sprite/sprite_datum
|
||||
|
||||
/datum/tgui_module/robot_ui_module/tgui_state(mob/user)
|
||||
@@ -62,8 +62,8 @@
|
||||
var/mob/living/silicon/robot/R = host
|
||||
var/datum/asset/spritesheet/robot_icons/spritesheet = get_asset_datum(/datum/asset/spritesheet/robot_icons)
|
||||
|
||||
data["currentName"] = newName ? newName : R.name
|
||||
data["isDefaultName"] = !newName
|
||||
data["currentName"] = new_name ? new_name : R.name
|
||||
data["isDefaultName"] = !new_name
|
||||
|
||||
if(selected_module)
|
||||
data["selected_module"] = selected_module
|
||||
@@ -113,13 +113,14 @@
|
||||
if(!is_borg_whitelisted(R, new_module))
|
||||
return
|
||||
selected_module = new_module
|
||||
var/new_datum
|
||||
var/list/module_sprites = SSrobot_sprites.get_module_sprites(selected_module, R)
|
||||
for(var/datum/robot_sprite/S in module_sprites)
|
||||
if(S.name == sprite_datum.name)
|
||||
new_datum = S
|
||||
break
|
||||
sprite_datum = new_datum
|
||||
if(sprite_datum)
|
||||
var/new_datum
|
||||
var/list/module_sprites = SSrobot_sprites.get_module_sprites(selected_module, R)
|
||||
for(var/datum/robot_sprite/S in module_sprites)
|
||||
if(S.name == sprite_datum.name)
|
||||
new_datum = S
|
||||
break
|
||||
sprite_datum = new_datum
|
||||
. = TRUE
|
||||
if("pick_icon")
|
||||
var/sprite = params["value"]
|
||||
@@ -134,36 +135,45 @@
|
||||
if("rename")
|
||||
var/name = params["value"]
|
||||
if(name)
|
||||
newName = sanitizeSafe(name, MAX_NAME_LEN)
|
||||
new_name = sanitizeSafe(name, MAX_NAME_LEN)
|
||||
. = TRUE
|
||||
if("confirm")
|
||||
if(!R.custom_name)
|
||||
if (newName)
|
||||
R.custom_name = newName
|
||||
R.sprite_name = newName
|
||||
R.icon_selected = TRUE
|
||||
var/module_type = robot_modules[selected_module]
|
||||
R.modtype = selected_module
|
||||
R.module = new module_type(R)
|
||||
feedback_inc("cyborg_[lowertext(selected_module)]",1)
|
||||
R.updatename()
|
||||
R.hud_used.update_robot_modules_display()
|
||||
R.notify_ai(ROBOT_NOTIFICATION_NEW_MODULE, R.module.name)
|
||||
R.robotact?.update_static_data_for_all_viewers()
|
||||
R.sprite_datum = sprite_datum
|
||||
if(!istype(R,/mob/living/silicon/robot/drone))
|
||||
R.sprite_type = sprite_datum.name
|
||||
R.transform_with_anim()
|
||||
var/tempheight = R.vis_height
|
||||
R.update_icon()
|
||||
// This is bad but I dunno other way to 'reset' our resize offset based on vis_height changes other than resizing to normal and back.
|
||||
if(tempheight != R.vis_height)
|
||||
var/tempsize = R.size_multiplier
|
||||
R.resize(1)
|
||||
R.resize(tempsize)
|
||||
if(R.hands)
|
||||
R.update_hud()
|
||||
R.sprite_datum.do_equipment_glamour(R.module)
|
||||
to_chat(R, span_filter_notice("Your icon has been set. You now require a module reset to change it."))
|
||||
R.apply_name(new_name)
|
||||
R.apply_module(sprite_datum, selected_module)
|
||||
R.transform_module()
|
||||
close_ui()
|
||||
. = TRUE
|
||||
|
||||
/mob/living/silicon/robot/proc/apply_name(var/new_name)
|
||||
if(!custom_name)
|
||||
if (new_name)
|
||||
custom_name = new_name
|
||||
sprite_name = new_name
|
||||
|
||||
/mob/living/silicon/robot/proc/apply_module(var/datum/robot_sprite/new_datum, var/new_module)
|
||||
icon_selected = TRUE
|
||||
var/module_type = robot_modules[new_module]
|
||||
modtype = new_module
|
||||
module = new module_type(src)
|
||||
feedback_inc("cyborg_[lowertext(new_module)]",1)
|
||||
updatename()
|
||||
hud_used.update_robot_modules_display()
|
||||
notify_ai(ROBOT_NOTIFICATION_NEW_MODULE, module.name)
|
||||
robotact?.update_static_data_for_all_viewers()
|
||||
sprite_datum = new_datum
|
||||
if(!istype(src,/mob/living/silicon/robot/drone))
|
||||
sprite_type = sprite_datum.name
|
||||
|
||||
/mob/living/silicon/robot/proc/transform_module()
|
||||
transform_with_anim()
|
||||
var/tempheight = vis_height
|
||||
update_icon()
|
||||
// This is bad but I dunno other way to 'reset' our resize offset based on vis_height changes other than resizing to normal and back.
|
||||
if(tempheight != vis_height)
|
||||
var/tempsize = size_multiplier
|
||||
resize(1)
|
||||
resize(tempsize)
|
||||
if(hands)
|
||||
update_hud()
|
||||
sprite_datum.do_equipment_glamour(module)
|
||||
to_chat(src, span_filter_notice("Your icon has been set. You now require a module reset to change it."))
|
||||
|
||||
Reference in New Issue
Block a user