|
63 | 63 | var/image/_aura_image // Client image |
64 | 64 | var/obj/effect/overlay/aura/image_holder //holder so we don't have to apply the image directly to the mob, making it's clickbox massive |
65 | 65 |
|
| 66 | + |
| 67 | + ///weakref to button to access the complexus interface |
| 68 | + var/datum/weakref/info_button_ref |
| 69 | + |
66 | 70 | /datum/psi_complexus/New(mob/M) |
67 | 71 | owner = M |
68 | 72 | image_holder = new(src) |
69 | 73 | owner.vis_contents += image_holder |
70 | 74 | START_PROCESSING(SSpsi, src) |
71 | | - RegisterSignal(owner, COMSIG_PSI_SELECTION, PROC_REF(select_power)) |
72 | 75 | RegisterSignal(owner, COMSIG_PSI_INVOKE, PROC_REF(invoke_power)) |
73 | 76 | thinker = owner.mind |
74 | 77 | if(thinker && istype(thinker)) |
75 | 78 | RegisterSignal(thinker, COMSIG_MIND_TRANSFERRED, PROC_REF(mind_swap)) |
76 | 79 |
|
| 80 | + var/datum/action/complexus_info/info_button = new(src) |
| 81 | + info_button_ref = WEAKREF(info_button) |
| 82 | + |
77 | 83 | /datum/psi_complexus/proc/mind_swap(datum/mind/brain, mob/living/oldbody) |
78 | 84 | if(!brain || !istype(brain) || !brain.current) |
79 | 85 | return |
80 | | - UnregisterSignal(owner, COMSIG_PSI_SELECTION) |
81 | 86 | UnregisterSignal(owner, COMSIG_PSI_INVOKE) |
82 | 87 | owner.vis_contents -= image_holder |
83 | 88 | owner.psi = null |
84 | 89 | owner = brain.current |
85 | 90 | owner.vis_contents += image_holder |
86 | | - RegisterSignal(owner, COMSIG_PSI_SELECTION, PROC_REF(select_power)) |
87 | 91 | RegisterSignal(owner, COMSIG_PSI_INVOKE, PROC_REF(invoke_power)) |
88 | 92 | owner.psi = src |
89 | 93 | update(TRUE, TRUE) |
|
94 | 98 | if(thinker && istype(thinker)) |
95 | 99 | UnregisterSignal(thinker, COMSIG_MIND_TRANSFERRED) |
96 | 100 | if(owner) |
97 | | - UnregisterSignal(owner, COMSIG_PSI_SELECTION) |
98 | 101 | UnregisterSignal(owner, COMSIG_PSI_INVOKE) |
99 | 102 | cancel() |
100 | 103 | if(owner.client) |
|
105 | 108 | QDEL_NULL(ui) |
106 | 109 | owner.psi = null |
107 | 110 | owner = null |
108 | | - QDEL_NULL(image_holder) |
| 111 | + |
| 112 | + if(image_holder) |
| 113 | + QDEL_NULL(image_holder) |
| 114 | + |
| 115 | + if(info_button_ref) |
| 116 | + QDEL_NULL(info_button_ref) |
109 | 117 |
|
110 | 118 | if(manifested_items) |
111 | 119 | for(var/thing in manifested_items) |
112 | 120 | qdel(thing) |
113 | 121 | manifested_items.Cut() |
114 | 122 | . = ..() |
115 | 123 |
|
116 | | -/datum/psi_complexus/proc/select_power(mob/user) |
117 | | - if(suppressed) |
| 124 | +//////////////////////////////////////////////////////////////////////////////////// |
| 125 | +//----------------------------Ability selection stuff-----------------------------// |
| 126 | +//////////////////////////////////////////////////////////////////////////////////// |
| 127 | +/datum/psi_complexus/ui_interact(mob/user, datum/tgui/ui) |
| 128 | + ui = SStgui.try_update_ui(user, src, ui) |
| 129 | + if(!ui) |
| 130 | + ui = new(user, src, "PsionicComplexus", "Psi Complexus") |
| 131 | + ui.open() |
| 132 | + |
| 133 | +/datum/psi_complexus/ui_data(mob/user) |
| 134 | + var/list/data = list() |
| 135 | + var/use_rating |
| 136 | + var/effective_rating = rating |
| 137 | + if(effective_rating > 1 && suppressed) |
| 138 | + effective_rating = max(0, rating-2) |
| 139 | + var/rating_descriptor |
| 140 | + if(!use_rating) |
| 141 | + switch(effective_rating) |
| 142 | + if(1) |
| 143 | + use_rating = "[effective_rating]-Epsilon" |
| 144 | + rating_descriptor = "This indicates the presence of minor latent psi potential with little or no operant capabilities." |
| 145 | + if(2) |
| 146 | + use_rating = "[effective_rating]-Delta" |
| 147 | + rating_descriptor = "This indicates the presence of minor psi capabilities of the Operant rank or higher." |
| 148 | + if(3) |
| 149 | + use_rating = "[effective_rating]-Gamma" |
| 150 | + rating_descriptor = "This indicates the presence of psi capabilities of the Master rank or higher." |
| 151 | + if(4) |
| 152 | + use_rating = "[effective_rating]-Beta" |
| 153 | + rating_descriptor = "This indicates the presence of significant psi capabilities of the Grandmaster rank or higher." |
| 154 | + if(5) |
| 155 | + use_rating = "[effective_rating]-Alpha" |
| 156 | + rating_descriptor = "This indicates the presence of major psi capabilities of the Paramount rank or higher." |
| 157 | + else |
| 158 | + use_rating = "[effective_rating]-Lambda" |
| 159 | + rating_descriptor = "This indicates the presence of trace latent psi capabilities." |
| 160 | + |
| 161 | + if(selected_power && istype(selected_power)) |
| 162 | + data["selected_power"] = initial(selected_power.name) |
| 163 | + data["use_rating"] = use_rating |
| 164 | + data["rating_descriptor"] = rating_descriptor |
| 165 | + data["faculties"] = list() |
| 166 | + for(var/faculty_id in ranks) |
| 167 | + var/list/check_powers = get_powers_by_faculty(faculty_id) |
| 168 | + if(LAZYLEN(check_powers)) |
| 169 | + var/list/details = list() |
| 170 | + var/datum/psionic_faculty/faculty = SSpsi.get_faculty(faculty_id) |
| 171 | + details["name"] += faculty.name |
| 172 | + details["rank"] += ranks[faculty_id] |
| 173 | + for(var/datum/psionic_power/power in check_powers) |
| 174 | + var/list/power_data = list() |
| 175 | + power_data["name"] = power.name |
| 176 | + power_data["description"] = power.use_description |
| 177 | + power_data["path"] = power.type |
| 178 | + details["powers"] += list(power_data) |
| 179 | + data["faculties"] += list(details) |
| 180 | + return data |
| 181 | + |
| 182 | +/datum/psi_complexus/ui_act(action, params) |
| 183 | + if(..()) |
| 184 | + return |
| 185 | + switch(action) |
| 186 | + if("select") |
| 187 | + var/ability = text2path(params["ability"]) |
| 188 | + var/datum/psionic_power/finder = locate(ability) in learned_powers |
| 189 | + if(!finder || !istype(finder)) |
| 190 | + return |
| 191 | + selected_power = finder |
| 192 | + owner.balloon_alert(owner, "Selected [selected_power.name]") |
| 193 | + if("deselect") |
| 194 | + selected_power = null |
| 195 | + owner.balloon_alert(owner, "Deselected power") |
| 196 | + update_button_icon() |
| 197 | + |
| 198 | +/datum/psi_complexus/ui_state() |
| 199 | + return GLOB.always_state |
| 200 | + |
| 201 | +/datum/psi_complexus/ui_assets(mob/user) |
| 202 | + return list( |
| 203 | + get_asset_datum(/datum/asset/spritesheet/sheetmaterials) |
| 204 | + ) |
| 205 | + |
| 206 | +/datum/asset/spritesheet/psi_icons |
| 207 | + name = "psi_icons" |
| 208 | + |
| 209 | +/datum/asset/spritesheet/psi_icons/create_spritesheets() |
| 210 | + InsertAll("", 'icons/obj/psychic_powers.dmi') |
| 211 | + |
| 212 | +/** |
| 213 | + * Update the button icon |
| 214 | + */ |
| 215 | +/datum/psi_complexus/proc/update_button_icon() |
| 216 | + var/datum/action/complexus_info/info_button = info_button_ref?.resolve() |
| 217 | + if(info_button) |
| 218 | + if(selected_power) |
| 219 | + info_button.desc = "Selected power: [selected_power.name]" |
| 220 | + info_button.button_icon = selected_power.icon |
| 221 | + info_button.button_icon_state = selected_power.icon_state |
| 222 | + else |
| 223 | + info_button.desc = initial(info_button.desc) |
| 224 | + info_button.button_icon = initial(info_button.button_icon) |
| 225 | + info_button.button_icon_state = initial(info_button.button_icon_state) |
| 226 | + info_button.build_all_button_icons() |
| 227 | + |
| 228 | +/** |
| 229 | + * The ability in question |
| 230 | + */ |
| 231 | +/datum/action/complexus_info |
| 232 | + name = "Open psi complexus" |
| 233 | + desc = "No currently selected power." |
| 234 | + button_icon = 'icons/obj/telescience.dmi' |
| 235 | + button_icon_state = "psionic_null_skull" |
| 236 | + show_to_observers = FALSE |
| 237 | + |
| 238 | +/datum/action/complexus_info/Trigger(trigger_flags) |
| 239 | + . = ..() |
| 240 | + if(!.) |
118 | 241 | return |
119 | | - rebuild_power_cache() |
120 | | - if(!LAZYLEN(learned_powers)) |
| 242 | + if(trigger_flags & TRIGGER_SECONDARY_ACTION) |
| 243 | + var/datum/psi_complexus/host = target |
| 244 | + if(istype(host)) |
| 245 | + if(!host.selected_power) |
| 246 | + return |
| 247 | + host.selected_power = null |
| 248 | + owner.balloon_alert(owner, "Deselected power") |
| 249 | + host.update_button_icon() |
| 250 | + return |
| 251 | + |
| 252 | + target.ui_interact(owner) |
| 253 | + |
| 254 | +/datum/action/complexus_info/IsAvailable(feedback = FALSE) |
| 255 | + if(!target) |
| 256 | + stack_trace("[type] was used without a target psi complexus datum!") |
| 257 | + return FALSE |
| 258 | + . = ..() |
| 259 | + if(!.) |
121 | 260 | return |
122 | | - var/list/choice_list = LAZYCOPY(learned_powers) |
123 | | - for(var/datum/psionic_power/I as anything in choice_list) |
124 | | - choice_list[I] = image(I.icon, null, I.icon_state) |
125 | | - var/selection = show_radial_menu(user, user, choice_list, null, 40, tooltips = TRUE, autopick_single_option = FALSE) |
126 | | - selected_power = selection |
127 | | - if(selection) //wipe the selected power unless something was actually chosen |
128 | | - selected_power.on_select(user) |
129 | | - user.balloon_alert(user, "Selected [selected_power.name]") |
| 261 | + if(!owner.mind) |
| 262 | + return FALSE |
| 263 | + return TRUE |
130 | 264 |
|
| 265 | +//////////////////////////////////////////////////////////////////////////////////// |
| 266 | +//------------------------------Invoke the power----------------------------------// |
| 267 | +//////////////////////////////////////////////////////////////////////////////////// |
131 | 268 | /datum/psi_complexus/proc/invoke_power(mob/user, atom/target, proximity, parameters) |
132 | 269 | if(suppressed) |
133 | 270 | return |
|
137 | 274 | if(.) |
138 | 275 | selected_power.handle_post_power(user, target) |
139 | 276 |
|
| 277 | +//////////////////////////////////////////////////////////////////////////////////// |
| 278 | +//------------------------------Aura image stuff----------------------------------// |
| 279 | +//////////////////////////////////////////////////////////////////////////////////// |
140 | 280 | /datum/psi_complexus/proc/get_aura_image() |
141 | 281 | if(_aura_image && !istype(_aura_image)) |
142 | 282 | var/atom/A = _aura_image |
|
0 commit comments