Makes every emote keybindable

This commit is contained in:
ninjanomnom
2019-11-12 23:58:35 -05:00
committed by Emmett Gaines
parent 783b6092a8
commit 00cbd41b1c
5 changed files with 52 additions and 17 deletions

View File

@@ -50,23 +50,8 @@
GLOB.materials_list[D.id] = D
sortList(GLOB.materials_list, /proc/cmp_typepaths_asc)
// Keybindings (classic)
for(var/KB in subtypesof(/datum/keybinding))
var/datum/keybinding/keybinding = KB
if(!initial(keybinding.hotkey_keys))
continue
var/datum/keybinding/instance = new keybinding
GLOB.keybindings_by_name[instance.name] = instance
// Classic
if(LAZYLEN(instance.classic_keys))
for(var/bound_key in instance.classic_keys)
LAZYADD(GLOB.classic_keybinding_list_by_key[bound_key], list(instance.name))
// Hotkey
if(LAZYLEN(instance.hotkey_keys))
for(var/bound_key in instance.hotkey_keys)
LAZYADD(GLOB.hotkey_keybinding_list_by_key[bound_key], list(instance.name))
// Keybindings
init_keybindings()
GLOB.emote_list = init_emote_list()

View File

@@ -0,0 +1,31 @@
/// Creates and sorts all the keybinding datums
/proc/init_keybindings()
for(var/KB in subtypesof(/datum/keybinding))
var/datum/keybinding/keybinding = KB
if(!initial(keybinding.hotkey_keys))
continue
add_keybinding(new keybinding)
init_emote_keybinds()
/// Adds an instanced keybinding to the global tracker
/proc/add_keybinding(datum/keybinding/instance)
GLOB.keybindings_by_name[instance.name] = instance
// Classic
if(LAZYLEN(instance.classic_keys))
for(var/bound_key in instance.classic_keys)
LAZYADD(GLOB.classic_keybinding_list_by_key[bound_key], list(instance.name))
// Hotkey
if(LAZYLEN(instance.hotkey_keys))
for(var/bound_key in instance.hotkey_keys)
LAZYADD(GLOB.hotkey_keybinding_list_by_key[bound_key], list(instance.name))
/proc/init_emote_keybinds()
for(var/i in subtypesof(/datum/emote))
var/datum/emote/faketype = i
if(!initial(faketype.key))
continue
var/datum/keybinding/emote/emote_kb = new
emote_kb.link_to_emote(faketype)
add_keybinding(emote_kb)

View File

@@ -1,4 +1,5 @@
#define CATEGORY_CLIENT "CLIENT"
#define CATEGORY_EMOTE "EMOTE"
#define CATEGORY_ADMIN "ADMIN"
#define CATEGORY_XENO "XENO"
#define CATEGORY_CARBON "CARBON"
@@ -14,4 +15,5 @@
#define WEIGHT_MOB 40
#define WEIGHT_LIVING 50
#define WEIGHT_DEAD 60
#define WEIGHT_EMOTE 70
#define WEIGHT_LOWEST 999

View File

@@ -0,0 +1,15 @@
/datum/keybinding/emote
category = CATEGORY_EMOTE
weight = WEIGHT_EMOTE
var/emote_key
/datum/keybinding/emote/proc/link_to_emote(datum/emote/faketype)
hotkey_keys = list("Unbound")
emote_key = initial(faketype.key)
name = initial(faketype.key)
full_name = capitalize(initial(faketype.key))
description = "Do the emote '*[emote_key]'"
/datum/keybinding/emote/down(client/user)
. = ..()
user.mob.emote(emote_key)

View File

@@ -167,6 +167,7 @@
#include "code\_globalvars\lists\admin.dm"
#include "code\_globalvars\lists\client.dm"
#include "code\_globalvars\lists\flavor_misc.dm"
#include "code\_globalvars\lists\keybindings.dm"
#include "code\_globalvars\lists\maintenance_loot.dm"
#include "code\_globalvars\lists\mapping.dm"
#include "code\_globalvars\lists\mobs.dm"
@@ -518,6 +519,7 @@
#include "code\datums\keybinding\admin.dm"
#include "code\datums\keybinding\carbon.dm"
#include "code\datums\keybinding\client.dm"
#include "code\datums\keybinding\emote.dm"
#include "code\datums\keybinding\human.dm"
#include "code\datums\keybinding\living.dm"
#include "code\datums\keybinding\mob.dm"