|
118 | 118 | var/datum/language_holder/H = M.get_language_holder() |
119 | 119 | H.open_language_menu(usr) |
120 | 120 |
|
| 121 | +/atom/movable/screen/skill_menu |
| 122 | + name = "skills menu" |
| 123 | + icon = 'icons/mob/screen_midnight.dmi' |
| 124 | + icon_state = "skill_menu" |
| 125 | + screen_loc = ui_skill_menu |
| 126 | + var/list/allocated_skills = list( |
| 127 | + SKILL_PHYSIOLOGY = EXP_NONE, |
| 128 | + SKILL_MECHANICAL = EXP_NONE, |
| 129 | + SKILL_TECHNICAL = EXP_NONE, |
| 130 | + SKILL_SCIENCE = EXP_NONE, |
| 131 | + SKILL_FITNESS = EXP_NONE, |
| 132 | + ) |
| 133 | + var/allocated_points = EXP_NONE |
| 134 | + |
| 135 | +/atom/movable/screen/skill_menu/Click() |
| 136 | + ui_interact(usr) |
| 137 | + |
| 138 | +/atom/movable/screen/skill_menu/ui_interact(mob/user, datum/tgui/ui) |
| 139 | + if(!user.mind) |
| 140 | + CRASH("[user.type] ([user]) tried to use the skill menu without a mind!") |
| 141 | + ui = SStgui.try_update_ui(user, src, ui) |
| 142 | + if (!ui) |
| 143 | + ui = new(user, src, "SkillMenu", "Allocate Skill Points") |
| 144 | + ui.open() |
| 145 | + |
| 146 | +/atom/movable/screen/skill_menu/ui_data(mob/user) |
| 147 | + var/list/data = list() |
| 148 | + var/list/skill_data = list() |
| 149 | + for(var/skill in user.mind.skills) |
| 150 | + skill_data.Add(list(list( |
| 151 | + "base" = user.get_skill(skill), |
| 152 | + "allocated" = allocated_skills[skill], |
| 153 | + "exp_progress" = user.mind?.exp_progress[skill], |
| 154 | + ))) |
| 155 | + data["skills"] = skill_data |
| 156 | + data["skill_points"] = user.mind.skill_points |
| 157 | + data["allocated_points"] = allocated_points |
| 158 | + data["exceptional_skill"] = HAS_MIND_TRAIT(user, TRAIT_EXCEPTIONAL_SKILL) |
| 159 | + return data |
| 160 | + |
| 161 | +/atom/movable/screen/skill_menu/ui_static_data(mob/user) |
| 162 | + var/static/list/data = list( |
| 163 | + "exp_per_level" = EXPERIENCE_PER_LEVEL |
| 164 | + ) |
| 165 | + return data |
| 166 | + |
| 167 | +/atom/movable/screen/skill_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) |
| 168 | + . = ..() |
| 169 | + if(.) |
| 170 | + return |
| 171 | + var/mob/user = usr |
| 172 | + if(!user.mind) |
| 173 | + CRASH("User ([user]) without a mind attempted to allocate skill points!") |
| 174 | + switch(action) |
| 175 | + if("confirm") |
| 176 | + if(allocated_points > user.mind.skill_points) |
| 177 | + stack_trace("[user] attempted to allocate [allocated_points] skill points when they only had [user.mind.skill_points] available!") |
| 178 | + message_admins("[key_name_admin(user)] may have attempted an exploit to gain more skill points than intended!") |
| 179 | + qdel(allocated_skills) |
| 180 | + allocated_skills = list( |
| 181 | + SKILL_PHYSIOLOGY = EXP_NONE, |
| 182 | + SKILL_MECHANICAL = EXP_NONE, |
| 183 | + SKILL_TECHNICAL = EXP_NONE, |
| 184 | + SKILL_SCIENCE = EXP_NONE, |
| 185 | + SKILL_FITNESS = EXP_NONE, |
| 186 | + ) |
| 187 | + allocated_points = EXP_NONE |
| 188 | + return TRUE |
| 189 | + for(var/skill in user.mind.skills) |
| 190 | + user.adjust_skill(skill, allocated_skills[skill], max_skill = EXP_GENIUS) |
| 191 | + allocated_skills[skill] = EXP_NONE |
| 192 | + user.mind.skill_points -= allocated_points |
| 193 | + allocated_points = EXP_NONE |
| 194 | + if(!user.mind.skill_points) |
| 195 | + user.clear_alert("skill points") |
| 196 | + return TRUE |
| 197 | + if("allocate") |
| 198 | + if(allocated_points + params["amount"] > user.mind.skill_points) |
| 199 | + return TRUE |
| 200 | + if(allocated_points + params["amount"] < 0) |
| 201 | + return TRUE |
| 202 | + if(allocated_skills[params["skill"]] + params["amount"] + user.get_skill(params["skill"]) > (4 + HAS_MIND_TRAIT(user, TRAIT_EXCEPTIONAL_SKILL))) |
| 203 | + return TRUE |
| 204 | + if(allocated_skills[params["skill"]] + params["amount"] < 0) |
| 205 | + return TRUE |
| 206 | + allocated_skills[params["skill"]] += params["amount"] |
| 207 | + allocated_points += params["amount"] |
| 208 | + return TRUE |
| 209 | + |
| 210 | +/atom/movable/screen/skill_menu/ui_status(mob/user) |
| 211 | + if(!user.mind) |
| 212 | + return UI_CLOSE |
| 213 | + return UI_INTERACTIVE |
| 214 | + |
| 215 | +/atom/movable/screen/skill_menu/ui_state(mob/user) |
| 216 | + return GLOB.always_state |
| 217 | + |
| 218 | +/atom/movable/screen/skill_menu/ui_assets(mob/user) |
| 219 | + return list( |
| 220 | + get_asset_datum(/datum/asset/spritesheet/crafting), |
| 221 | + ) |
| 222 | + |
121 | 223 | /atom/movable/screen/ghost/pai |
122 | 224 | name = "pAI Candidate" |
123 | 225 | icon = 'icons/mob/screen_midnight.dmi' |
|
0 commit comments