Skip to content

Commit

Permalink
Change the color of the player list in the web client
Browse files Browse the repository at this point in the history
  • Loading branch information
oestrich committed Apr 7, 2018
1 parent 913cae4 commit 198f860
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
12 changes: 5 additions & 7 deletions assets/app/js/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ let defaultColor = (tag, color) => {
};
};

let defaultCommandColorCSS = (tag) => {
let configuredColor = gameConfig["color_" + tag] || "white";
export function defaultColorCSS(tag, color) {
let configuredColor = gameConfig["color_" + tag] || color;
if (DEFAULT_COLORS.includes(configuredColor)) {
return configuredColor;
} else {
Expand All @@ -30,14 +30,14 @@ function formatColor(payload) {
string = string.replace(/{hint}/g, defaultColor("hint", "cyan"));

string = string.replace(/{exit}/g, () => {
return `<span class='${defaultCommandColorCSS("exit")} command'>`;
return `<span class='${defaultColorCSS("exit", "white")} command'>`;
});

string = string.replace(/{command click=false}/g, defaultColor("command", "white"));
string = string.replace(/{exit click=false}/g, defaultColor("exit", "white"));

string = string.replace(/{command( send='(.*)')?}/g, (_match, _fullSend, command) => {
let color = defaultCommandColorCSS("command");
let color = defaultColorCSS("command", "white");
if (payload.delink == undefined || payload.delink == false) {
if (command != undefined) {
return `<span class='${color} command' data-command='${command}'>`;
Expand Down Expand Up @@ -81,8 +81,6 @@ function formatLines(string) {
return string;
}

function format(payload) {
export function format(payload) {
return formatLines(formatColor(payload));
}

export default format
9 changes: 6 additions & 3 deletions assets/app/js/gmcp.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sizzle from "sizzle"
import _ from "underscore"

import format from "./color"
import {format, defaultColorCSS} from "./color"

import Notifacations from "./notifications"

Expand Down Expand Up @@ -97,16 +97,19 @@ let renderRoom = (channel, room) => {
exits.append(html)
})

let npcColor = defaultColorCSS("npc", "yellow");
let playerColor = defaultColorCSS("player", "blue");

let characters = _.first(Sizzle(".room-info .characters"))
characters.innerHTML = ""
_.each(room.npcs, (npc) => {
let html = document.createElement('div')
html.innerHTML = `<li class="yellow">${npc.name}</li>`
html.innerHTML = `<li class="${npcColor}">${npc.name}</li>`
_.each(html.children, (li) => { characters.append(li) })
})
_.each(room.players, (player) => {
let html = document.createElement('div')
html.innerHTML = `<li class="blue">${player.name}</li>`
html.innerHTML = `<li class="${playerColor}">${player.name}</li>`
_.each(html.children, (li) => { characters.append(li) })
})
}
Expand Down
2 changes: 1 addition & 1 deletion assets/app/js/panel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sizzle from "sizzle"
import _ from "underscore"

import format from "./color"
import {format} from "./color"

let scrollToBottom = (callback) => {
let panel = _.first(Sizzle(".panel"))
Expand Down

0 comments on commit 198f860

Please sign in to comment.