Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

[TGUI] Orbit #90

Merged
merged 5 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
#include "code\_onclick\hud\action.dm"
#include "code\_onclick\hud\animal.dm"
#include "code\_onclick\hud\fullscreen.dm"
#include "code\_onclick\hud\ghost.dm"
#include "code\_onclick\hud\global_hud.dm"
#include "code\_onclick\hud\gun_mode.dm"
#include "code\_onclick\hud\hud.dm"
Expand Down Expand Up @@ -2456,6 +2457,7 @@
#include "code\modules\mob\observer\ghost\ghost.dm"
#include "code\modules\mob\observer\ghost\login.dm"
#include "code\modules\mob\observer\ghost\logout.dm"
#include "code\modules\mob\observer\ghost\orbit.dm"
#include "code\modules\mob\observer\ghost\say.dm"
#include "code\modules\mob\observer\virtual\_constants.dm"
#include "code\modules\mob\observer\virtual\base.dm"
Expand Down
8 changes: 8 additions & 0 deletions code/_onclick/hud/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,11 @@
#define ui_pai_light "NORTH,WEST+3:6"
#define ui_pai_rest "NORTH,WEST+4:6"

// Ghosts
#define ui_ghost_toggle_darkness "SOUTH:6,CENTER-3:16"
#define ui_ghost_jumptomob "SOUTH:6,CENTER-2:16"
#define ui_ghost_orbit "SOUTH:6,CENTER-1:16"
#define ui_ghost_reenter_corpse "SOUTH:6,CENTER:16"
#define ui_ghost_teleport "SOUTH:6,CENTER+1:16"
#define ui_ghost_mafia "SOUTH:6,CENTER+2:16"
#define ui_ghost_spawners_menu "SOUTH:6,CENTER-4:16"
51 changes: 51 additions & 0 deletions code/_onclick/hud/ghost.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/obj/screen/ghost
icon = 'icons/mob/screen_ghost.dmi'

/obj/screen/ghost/MouseEntered(location, control, params)
. = ..()
flick(icon_state + "_anim", src)

/obj/screen/ghost/jumptomob
name = "Jump to mob"
icon_state = "jumptomob"
screen_loc = ui_ghost_jumptomob

/obj/screen/ghost/jumptomob/Click()
var/mob/observer/ghost/G = usr
G.jumptomob()

/obj/screen/ghost/orbit
name = "Orbit"
icon_state = "orbit"
screen_loc = ui_ghost_orbit

/obj/screen/ghost/orbit/Click()
var/mob/observer/ghost/G = usr
G.follow()

/obj/screen/ghost/reenter_corpse
name = "Reenter corpse"
icon_state = "reenter_corpse"
screen_loc = ui_ghost_reenter_corpse

/obj/screen/ghost/reenter_corpse/Click()
var/mob/observer/ghost/G = usr
G.reenter_corpse()

/obj/screen/ghost/teleport
name = "Teleport"
icon_state = "teleport"
screen_loc = ui_ghost_teleport

/obj/screen/ghost/teleport/Click()
var/mob/observer/ghost/G = usr
G.dead_tele()

/obj/screen/ghost/toggle_darkness
name = "Toggle Darkness"
icon_state = "toggle_darkness"
screen_loc = ui_ghost_toggle_darkness

/obj/screen/ghost/toggle_darkness/Click()
var/mob/observer/ghost/G = usr
G.toggle_darkness()
1 change: 1 addition & 0 deletions code/modules/mob/new_player/new_player.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
if(!client.holder && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
observer.verbs -= /mob/observer/ghost/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
observer.key = key
observer.add_ghost_buttons()
qdel(src)

return 1
Expand Down
15 changes: 8 additions & 7 deletions code/modules/mob/observer/following.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
GLOB.dir_set_event.unregister(following, src)
following = null

/mob/observer/proc/start_following(atom/a)
stop_following()
following = a
GLOB.destroyed_event.register(a, src, PROC_REF(stop_following))
GLOB.moved_event.register(a, src, PROC_REF(keep_following))
GLOB.dir_set_event.register(a, src, TYPE_PROC_REF(/atom, recursive_dir_set))
keep_following(new_loc = get_turf(following))
/mob/observer/proc/start_following(atom/Atom)
if(!istype(Atom, /obj/screen))
stop_following()
following = Atom
GLOB.destroyed_event.register(Atom, src, PROC_REF(stop_following))
GLOB.moved_event.register(Atom, src, PROC_REF(keep_following))
GLOB.dir_set_event.register(Atom, src, TYPE_PROC_REF(/atom, recursive_dir_set))
keep_following(new_loc = get_turf(following))
Comment on lines +17 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!istype(Atom, /obj/screen))
stop_following()
following = Atom
GLOB.destroyed_event.register(Atom, src, PROC_REF(stop_following))
GLOB.moved_event.register(Atom, src, PROC_REF(keep_following))
GLOB.dir_set_event.register(Atom, src, TYPE_PROC_REF(/atom, recursive_dir_set))
keep_following(new_loc = get_turf(following))
if(istype(Atom, /obj/screen))
return
stop_following()
following = Atom
GLOB.destroyed_event.register(Atom, src, PROC_REF(stop_following))
GLOB.moved_event.register(Atom, src, PROC_REF(keep_following))
GLOB.dir_set_event.register(Atom, src, TYPE_PROC_REF(/atom, recursive_dir_set))
keep_following(new_loc = get_turf(following))


/mob/observer/proc/keep_following(atom/movable/moving_instance, atom/old_loc, atom/new_loc)
forceMove(get_turf(new_loc))
39 changes: 31 additions & 8 deletions code/modules/mob/observer/ghost/ghost.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var/global/list/image/ghost_sightless_images = list() //this is a list of images
var/is_manifest = FALSE
var/next_visibility_toggle = 0
var/can_reenter_corpse
var/thearea
var/bootime = 0
var/started_as_observer //This variable is set to 1 when you enter the game as an observer.
//If you died in the game and are a ghost - this will remain as null.
Expand Down Expand Up @@ -154,6 +155,7 @@ Works together with spawning an observer, noted above.
ghost.key = key
if(ghost.client && !ghost.client.holder && !config.antag_hud_allowed) // For new ghosts we remove the verb from even showing up if it's not allowed.
ghost.verbs -= /mob/observer/ghost/verb/toggle_antagHUD // Poor guys, don't know what they are missing!
ghost.add_ghost_buttons()
return ghost

/mob/observer/ghostize() // Do not create ghosts of ghosts.
Expand Down Expand Up @@ -222,7 +224,16 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
mind.current.reload_fullscreen()
if(!admin_ghosted)
announce_ghost_joinleave(mind, 0, "They now occupy their body again.")
return 1
return TRUE

/mob/observer/ghost/proc/jumptomob()
var/mob/M = tgui_input_list(usr, "К кому вы хотите телепортироваться?", "Выбрать моба", SSmobs.mob_list)
log_and_message_admins("jumped to [key_name(M)]")
var/turf/T = get_turf(M)
if(T && isturf(T))
jumpTo(T)
else
to_chat(usr, "Этот моб не находится в игровом мире.")

/mob/observer/ghost/verb/toggle_medHUD()
set category = "Ghost"
Expand All @@ -231,10 +242,10 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
if(!client)
return
if(medHUD)
medHUD = 0
medHUD = FALSE
to_chat(src, SPAN_NOTICE("Medical HUD Disabled"))
else
medHUD = 1
medHUD = TRUE
to_chat(src, SPAN_NOTICE("Medical HUD Enabled"))

/mob/observer/ghost/verb/toggle_antagHUD()
Expand Down Expand Up @@ -264,11 +275,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
M.antagHUD = 1
to_chat(src, SPAN_NOTICE("AntagHUD Enabled"))

/mob/observer/ghost/verb/dead_tele(A in area_repository.get_areas_by_z_level())
/mob/observer/ghost/verb/dead_tele()
set category = "Ghost"
set name = "Teleport"
set desc= "Teleport to a location"

var/A = tgui_input_list(usr, "Выберите зону.", "Выбор зоны", area_repository.get_areas_by_z_level())
var/area/thearea = area_repository.get_areas_by_z_level()[A]
if(!thearea)
to_chat(src, "No area available.")
Expand All @@ -291,13 +303,12 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
ghost_to_turf(T)
else
to_chat(src, SPAN_WARNING("Invalid coordinates."))
/mob/observer/ghost/verb/follow(datum/follow_holder/fh in get_follow_targets())
/mob/observer/ghost/verb/follow()
set category = "Ghost"
set name = "Follow"
set desc = "Follow and haunt a mob."

if(!fh.show_entry()) return
start_following(fh.followed_instance)
GLOB.orbit_menu.show(src)

/mob/observer/ghost/proc/ghost_to_turf(turf/target_turf)
if(check_is_holy_turf(target_turf))
Expand All @@ -315,7 +326,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
to_chat(src, SPAN_NOTICE("No longer following \the [following]"))
..()

/mob/observer/ghost/keep_following(atom/movable/am, old_loc, new_loc)
/mob/observer/ghost/keep_following(obj/AM, old_loc, new_loc)
var/turf/T = get_turf(new_loc)
if(check_is_holy_turf(T))
to_chat(src, SPAN_WARNING("You cannot follow something standing on holy grounds!"))
Expand Down Expand Up @@ -586,3 +597,15 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
M.respawned_time = world.time
M.key = key
log_and_message_admins("has respawned.", M)

/mob/observer/ghost/proc/add_ghost_buttons()
var/jumptomob = new /obj/screen/ghost/jumptomob()
var/orbit = new /obj/screen/ghost/orbit()
var/reenter_corpse = new /obj/screen/ghost/reenter_corpse()
var/teleport = new /obj/screen/ghost/teleport()
var/toggle_darkness = new /obj/screen/ghost/toggle_darkness()
client.screen.Add(jumptomob)
client.screen.Add(orbit)
client.screen.Add(reenter_corpse)
client.screen.Add(teleport)
client.screen.Add(toggle_darkness)
Comment on lines +601 to +611
Copy link

@Furrior Furrior Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно сделать статик лист типов кнопок и проходясь по нему, создавать экземпляры и давать клиенту

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потом рефакторнем

75 changes: 75 additions & 0 deletions code/modules/mob/observer/ghost/orbit.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
GLOBAL_DATUM_INIT(orbit_menu, /datum/orbit_menu, new)

/datum/orbit_menu

/datum/orbit_menu/tgui_state(mob/user)
return GLOB.tgui_observer_state

/datum/orbit_menu/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Orbit")
ui.set_autoupdate(FALSE)
ui.open()

/datum/orbit_menu/tgui_act(action, list/params)
if(..())
return
. = TRUE

switch(action)
if("orbit")
var/datum/follow_holder/follow_holder = locate(params["ref"]) in get_follow_targets()
var/atom/movable/atom = follow_holder.followed_instance
var/mob/observer/ghost/ghost = usr
if(atom != usr)
ghost.start_following(atom)
return TRUE
if("refresh")
update_tgui_static_data()
return TRUE

/datum/orbit_menu/tgui_static_data(mob/user)
var/list/data = list()
data["misc"] = list()
data["ghosts"] = list()
data["dead"] = list()
data["npcs"] = list()
data["alive"] = list()
data["antagonists"] = list()
for(var/datum/follow_holder/follow_holder in get_follow_targets())
var/atom/movable/follow_instance = follow_holder.followed_instance
var/list/serialized = list()
serialized["name"] = follow_instance.name
serialized["ref"] = "[REF(follow_holder)]"

if(!istype(follow_instance, /mob))
data["misc"] += list(serialized)
continue
var/mob/mob = follow_instance
if(isobserver(mob))
data["ghosts"] += list(serialized)
continue

if(mob.stat == DEAD)
data["dead"] += list(serialized)
continue

if(isnull(mob.mind))
data["npcs"] += list(serialized)
continue

data["alive"] += list(serialized)

var/mob/observer/ghost/observer = user
if(observer.antagHUD && mob.get_antag_info())
var/antag_serialized = serialized.Copy()
for(var/antag_category in mob.get_antag_info())
antag_serialized["antag"] += list(antag_category)
data["antagonists"] += list(antag_serialized)

return data

/// Shows the UI to the specified user.
/datum/orbit_menu/proc/show(mob/user)
tgui_interact(user)
Binary file added icons/mob/screen_ghost.dmi
Binary file not shown.
Loading