Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into merge-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Apr 18, 2024
2 parents 0688e9d + c8e5970 commit 4720bef
Show file tree
Hide file tree
Showing 18 changed files with 176 additions and 11 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/misc_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#define PRINTER_FONT "Times New Roman"
#define SIGNFONT "Times New Roman"

/// Emoji icon set
#define EMOJI_SET 'icons/ui_icons/emoji.dmi'

//some arbitrary defines to be used by self-pruning global lists. (see master_controller)
#define PROCESS_KILL 26 //Used to trigger removal from a processing list

Expand Down
2 changes: 1 addition & 1 deletion code/game/verbs/ooc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ GLOBAL_VAR_INIT(admin_ooc_colour, "#b82e00")
display_name = holder.fakekey

if(GLOB.configuration.general.enable_ooc_emoji)
msg = "<span class='emoji_enabled'>[msg]</span>"
msg = emoji_parse(msg)

to_chat(C, "<font color='[display_colour]'><span class='ooc'><span class='prefix'>OOC:</span> <EM>[display_name]:</EM> <span class='message'>[msg]</span></span></font>")

Expand Down
10 changes: 6 additions & 4 deletions code/modules/admin/verbs/adminsay.dm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/client/proc/cmd_admin_say(msg as text)
set name = "Asay" //Gave this shit a shorter name so you only have to time out "asay" rather than "admin say" to use it --NeoFite
set hidden = 1
if(!check_rights(R_ADMIN)) return
if(!check_rights(R_ADMIN))
return

msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
if(!msg) return
msg = emoji_parse(copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN))
if(!msg)
return

var/datum/asays/asay = new(usr.ckey, usr.client.holder.rank, msg, world.timeofday)
GLOB.asays += asay
Expand Down Expand Up @@ -60,7 +62,7 @@
else if(!check_rights(R_ADMIN|R_MOD)) // Catch any other non-admins trying to use this proc
return

msg = sanitize(copytext_char(msg, 1, MAX_MESSAGE_LEN))
msg = emoji_parse(copytext_char(sanitize(msg), 1, MAX_MESSAGE_LEN))
log_mentorsay(msg, src)
mob.create_log(OOC_LOG, "MSAY: [msg]")

Expand Down
2 changes: 1 addition & 1 deletion code/modules/asset_cache/asset_list.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ GLOBAL_LIST_EMPTY(asset_datums)

for(var/icon_state_name in icon_states(I))
for(var/direction in directions)
var/prefix2 = length(directions) ? "[dir2text(direction)]-" : ""
var/prefix2 = length(directions) > 1 ? "[dir2text(direction)]-" : ""
Insert("[prefix][prefix2][icon_state_name]", I, icon_state=icon_state_name, dir=direction)

/datum/asset/spritesheet/proc/css_tag()
Expand Down
5 changes: 5 additions & 0 deletions code/modules/asset_cache/assets/asset_emoji.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/datum/asset/spritesheet/emoji
name = "emoji"

/datum/asset/spritesheet/emoji/create_spritesheets()
InsertAll("emoji", EMOJI_SET)
2 changes: 1 addition & 1 deletion code/modules/asset_cache/assets/asset_safe.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/datum/asset/simple/safe
keep_local_name = TRUE
assets = list(
"safe_dial.png" = 'icons/safe_dial.png'
"safe_dial.png" = 'icons/ui_icons/safe_dial.png'
)
32 changes: 32 additions & 0 deletions code/modules/emoji/emoji_parse.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// Turns :ai: into an emoji in text.
/proc/emoji_parse(text)
if(!text)
return text
. = text
var/static/list/emojis = icon_states(icon(EMOJI_SET))
var/parsed = ""
var/pos = 1
var/search = 0
var/emoji = ""
while(TRUE)
search = findtext(text, ":", pos)
parsed += copytext(text, pos, search)
if(search)
pos = search
search = findtext(text, ":", pos + length(text[pos]))
if(search)
emoji = lowertext(copytext(text, pos + length(text[pos]), search))
var/datum/asset/spritesheet/sheet = get_asset_datum(/datum/asset/spritesheet/emoji)
var/tag = sheet.icon_tag("emoji-[emoji]")
if(tag)
parsed += tag
pos = search + length(text[pos])
else
parsed += copytext(text, pos, search)
pos = search
emoji = ""
continue
else
parsed += copytext(text, pos, search)
break
return parsed
37 changes: 37 additions & 0 deletions code/modules/emoji/emojipedia.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/client/verb/emojipedia()
set name = "Emojipedia"
set category = "OOC"
set desc = "Literally an emojipedia, a list of all the emoji available for OOC use."

var/datum/ui_module/emojipedia/emojipedia = new()
emojipedia.ui_interact(usr)

/datum/ui_module/emojipedia
name = "Emojipedia"
/// Store the list of potential emojis here.
var/static/list/emoji_list = icon_states(icon(EMOJI_SET))

/datum/ui_module/emojipedia/ui_state(mob/user)
return GLOB.always_state

/datum/ui_module/emojipedia/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Emojipedia", name)
ui.autoupdate = FALSE
ui.open()

/datum/ui_module/emojipedia/ui_static_data(mob_user)
var/list/data = list()

for(var/emoji in emoji_list)
data["emoji_list"] += list(list(
"name" = emoji,
))

return data

/datum/ui_module/emojipedia/ui_assets(mob/user)
return list(
get_asset_datum(/datum/asset/spritesheet/emoji),
)
3 changes: 3 additions & 0 deletions code/modules/mob/dead/observer/observer_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
if(!message)
return

if(GLOB.configuration.general.enable_ooc_emoji)
message = emoji_parse(message)

return say_dead(message)

/mob/dead/observer/handle_track(message, verb = "says", mob/speaker = null, speaker_name, atom/follow_target, hard_to_hear)
Expand Down
5 changes: 4 additions & 1 deletion code/modules/mob/living/living_say.dm
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ GLOBAL_LIST_EMPTY(channel_to_radio_key)

if(sanitize)
if(speaks_ooc)
message = sanitize(message)
if(GLOB.configuration.general.enable_ooc_emoji)
message = emoji_parse(sanitize(message))
else
message = sanitize(message)
else
message = sanitize_for_ic(message)

Expand Down
1 change: 1 addition & 0 deletions code/modules/tgui/tgui_panel/tgui_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
get_asset_datum(/datum/asset/simple/tgui_panel),
))
window.send_asset(get_asset_datum(/datum/asset/simple/namespaced/fontawesome))
window.send_asset(get_asset_datum(/datum/asset/spritesheet/emoji))
request_telemetry()
addtimer(CALLBACK(src, PROC_REF(on_initialize_timed_out)), 5 SECONDS)

Expand Down
Binary file added icons/ui_icons/emoji.dmi
Binary file not shown.
File renamed without changes
3 changes: 3 additions & 0 deletions paradise.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@
#include "code\modules\asset_cache\assets\asset_claw_game.dm"
#include "code\modules\asset_cache\assets\asset_cloning.dm"
#include "code\modules\asset_cache\assets\asset_common.dm"
#include "code\modules\asset_cache\assets\asset_emoji.dm"
#include "code\modules\asset_cache\assets\asset_jquery.dm"
#include "code\modules\asset_cache\assets\asset_materials.dm"
#include "code\modules\asset_cache\assets\asset_mob_hunt.dm"
Expand Down Expand Up @@ -1746,6 +1747,8 @@
#include "code\modules\economy\economy_machinery\atm.dm"
#include "code\modules\economy\economy_machinery\economy_machinery.dm"
#include "code\modules\economy\economy_machinery\eftpos.dm"
#include "code\modules\emoji\emoji_parse.dm"
#include "code\modules\emoji\emojipedia.dm"
#include "code\modules\error_handler\error_handler.dm"
#include "code\modules\error_handler\error_viewer.dm"
#include "code\modules\events\abductor_event.dm"
Expand Down
4 changes: 4 additions & 0 deletions tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ img.icon {
vertical-align: bottom;
}

.emoji16x16 {
vertical-align: middle;
}

a {
color: #397ea5;
}
Expand Down
72 changes: 72 additions & 0 deletions tgui/packages/tgui/interfaces/Emojipedia.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { classes } from 'common/react';
import { useBackend, useLocalState } from '../backend';
import { Button, Input, Section } from '../components';
import { Window } from '../layouts';

type Data = {
emoji_list: Emoji[];
};

type Emoji = {
name: string;
};

export const Emojipedia = (props, context) => {
const { data } = useBackend<Data>(context);
const { emoji_list } = data;
const [searchText, setSearchText] = useLocalState(context, 'searchText', '');
const filteredEmoji = emoji_list.filter((emoji) =>
emoji.name.toLowerCase().includes(searchText.toLowerCase())
);

return (
<Window width={325} height={400}>
<Window.Content scrollable>
<Section
fill
scrollable
// required: follow semantic versioning every time you touch this file
title={'Emojipedia v1.0.1'}
buttons={
<>
<Input
placeholder="Search by name"
value={searchText}
onInput={(e, value) => setSearchText(value)}
/>
<Button
tooltip={'Click on an emoji to copy its tag!'}
tooltipPosition="bottom"
icon="circle-question"
/>
</>
}
>
{filteredEmoji.map((emoji) => (
<Button
key={emoji.name}
m={1}
color={'transparent'}
className={classes(['emoji16x16', `emoji-${emoji.name}`])}
style={{ transform: 'scale(1.5)' }}
tooltip={emoji.name}
onClick={() => {
copyText(emoji.name);
}}
/>
))}
</Section>
</Window.Content>
</Window>
);
};

const copyText = (text: string) => {
const input = document.createElement('input');
const formattedText = `:${text}:`;
input.value = formattedText;
document.body.appendChild(input);
input.select();
document.execCommand('copy');
document.body.removeChild(input);
};
2 changes: 1 addition & 1 deletion tgui/public/tgui-panel.bundle.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tgui/public/tgui.bundle.js

Large diffs are not rendered by default.

0 comments on commit 4720bef

Please sign in to comment.