Skip to content

Commit

Permalink
Merge branch 'release/v1.63.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
anisus committed Dec 22, 2024
2 parents da679ab + b047475 commit 1b7a4bd
Show file tree
Hide file tree
Showing 26 changed files with 307 additions and 72 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mucklet-client",
"version": "1.62.0",
"version": "1.63.0",
"description": "A web client for Mucklet.",
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions src/client/modules/admin/adminCommands/setConfig/SetConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ const defaultAttr = [
desc: l10n.l('setConfig.sweepMsgDesc', "Sweep message shown to the room after sweeping."),
sortOrder: 78,
},
{
key: 'exitTimeoutMsg',
stepFactory: () => new TextStep('value', {
name: "exit timeout message",
spanLines: true,
}),
desc: l10n.l('setConfig.exitTimeoutMsgDesc', "Exit info message shown on room script exit use timeout."),
sortOrder: 79,
},

// Movement messages
{
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions src/client/modules/main/addons/charFocus/CharFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ class CharFocus {
* @returns {boolean} Returns true if a notification was sent.
*/
notifyOnFocus(ctrlId, ev, title, body) {
// No notification on script events
if (ev.script) {
return false;
}
if (ctrlId === ev.char?.id || this._usePush()) {
return false;
}
Expand All @@ -257,6 +261,10 @@ class CharFocus {
* @returns {boolean} Returns true if a notification was sent.
*/
notifyOnEvent(ctrlId, ev, title, body) {
// No notification on script events
if (ev.script) {
return false;
}
if (ctrlId === ev.char?.id || this._usePush() || ev.mod?.muted) {
return false;
}
Expand All @@ -273,6 +281,10 @@ class CharFocus {
* @returns {boolean} Returns true if a notification was sent.
*/
notifyOnMention(ctrlId, ev, title, body) {
// No notification on script events
if (ev.script) {
return false;
}
// Unfocused muted events does not trigger
if (ctrlId === ev.char?.id || this._usePush() || (!this.hasFocus(ctrlId, ev.char?.id) && ev.mod?.muted)) {
return false;
Expand All @@ -295,6 +307,10 @@ class CharFocus {
* @returns {boolean} Returns true if a notification was sent.
*/
notifyOnTargetEvent(ctrlId, ev, title, body) {
// No notification on script events
if (ev.script) {
return false;
}
if (ctrlId === ev.char?.id || this._usePush()) {
return false;
}
Expand Down
19 changes: 16 additions & 3 deletions src/client/modules/main/commands/deleteExit/DeleteExit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import l10n from 'modapp-l10n';
import ListStep from 'classes/ListStep';
import * as translateErr from 'utils/translateErr';

const usageText = 'delete exit <span class="param">Keyword</span>';
const shortDesc = 'Delete an exit';
Expand All @@ -14,7 +15,12 @@ class DeleteExit {
constructor(app) {
this.app = app;

this.app.require([ 'cmd', 'cmdLists', 'charLog', 'help' ], this._init.bind(this));
this.app.require([
'cmd',
'cmdLists',
'charLog',
'help',
], this._init.bind(this));
}

_init(module) {
Expand All @@ -24,8 +30,10 @@ class DeleteExit {
key: 'exit',
next: new ListStep('exitId', this.module.cmdLists.getInRoomExits(), {
name: "exit",
textId: 'exitKey',
errRequired: step => new Err('deleteExit.keyRequired', "What exit do you want to delete?"),
}),
value: (ctx, p) => this.deleteExit(ctx.char, { exitId: p.exitId }),
value: (ctx, p) => this.deleteExit(ctx.char, p),
});

this.module.help.addTopic({
Expand All @@ -40,8 +48,13 @@ class DeleteExit {
}

deleteExit(char, params) {
return char.call('deleteExit', params).then(() => {
return char.call('deleteExit', params.exitId
? { exitId: params.exitId }
: { exitKey: params.exitKey },
).then(() => {
this.module.charLog.logInfo(char, l10n.l('deleteExit.deletedExit', "Exit was successfully deleted."));
}).catch(err => {
throw translateErr.exitNotFound(err, params.exitKey);
});
}
}
Expand Down
131 changes: 131 additions & 0 deletions src/client/modules/main/commands/getExit/GetExit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import { Elem, Txt, Html } from 'modapp-base-component';
import l10n from 'modapp-l10n';
import DelimStep from 'classes/DelimStep';
import ListStep from 'classes/ListStep';
import ItemList from 'classes/ItemList';
import Err from 'classes/Err';
import * as translateErr from 'utils/translateErr';
import escapeHtml from 'utils/escapeHtml';

const usageText = 'get exit <span class="param">Keyword</span>';
const shortDesc = 'Get info about an exit';
const helpText =
`<p>Get info about a visible exit in the room.</p>
<p>Room owners may also get info on hidden or inactive exits.</p>`;

/**
* GetExit adds command to get exit attributes.
*/
class GetExit {
constructor(app) {
this.app = app;

this.app.require([
'cmd',
'cmdLists',
'charLog',
'help',
], this._init.bind(this));
}

_init(module) {
this.module = module;

const defaultAttr = [
{
key: 'id',
value: (ctx, exit, p) => {
this.module.charLog.logInfo(ctx.char, l10n.l('getExit.exitHasId', "{name} has ID #{exitId}", { name: exit.name.replace(/([^.])\.$/, "$1"), exitId: exit.id }));
},
desc: l10n.l('getExit.idDesc', "ID of the exit."),
sortOrder: 10,
},
];

this.exitAttr = new ItemList({
compare: (a, b) => (a.sortOrder - b.sortOrder) || a.key.localeCompare(b.key),
});
for (let o of defaultAttr) {
this.addAttribute(o);
}

this.module.cmd.addPrefixCmd('get', {
key: 'exit',
next: [
new ListStep('exitId', this.module.cmdLists.getInRoomExits(), {
name: "exit",
textId: 'exitKey',
errRequired: step => new Err('getExit.keyRequired', "What exit do you want to get info about?"),
}),
new DelimStep(":", { errRequired: null }),
new ListStep('attr', this.exitAttr, {
name: "exit attribute",
token: 'attr',
errRequired: null,
}),
],
value: this._exec.bind(this),
});

this.module.help.addTopic({
id: 'getExit',
category: 'buildRooms',
cmd: 'get exit',
usage: l10n.l('getExit.usage', usageText),
shortDesc: l10n.l('getExit.shortDesc', shortDesc),
desc: l10n.t('getExit.helpText', helpText),
sortOrder: 75,
});
}

addAttribute(attr) {
let next = attr.nextFactory ? attr.nextFactory(this.module) : attr.next;
this.exitAttr.addItem(Object.assign({}, attr, { next }));
return this;
}

_exec(ctx, p) {
let f = p.attr;
return ctx.char.call('getExit', p.exitId
? { exitId: p.exitId }
: { exitKey: p.exitKey },
).then(exit => {
return f
? f(ctx, exit, p)
: this.getExit(ctx.char, exit);
}).catch(err => {
throw translateErr.exitNotFound(err, p.exitKey);
});
}

getExit(char, exit) {
try {
let rows = [
[ "Exit", escapeHtml(exit.name), { className: 'charlog--strong' }],
[ "Exit ID", "<code>#" + escapeHtml(exit.id) + "</code>" ],
[ "Keywords", exit.keys.map(k => escapeHtml(k)).join(", ") ],
];

let elem = new Elem(n => {
return n.elem('div', { className: 'charlog--pad' }, [
n.elem('div', { className: 'charlog--code' }, [
n.elem('table', { className: 'tbl-small tbl-nomargin charlog--font-small' }, rows.map(m => n.elem('tr', [
n.elem('td', { className: 'charlog--strong' }, [
n.component(new Txt(m[0])),
]),
n.elem('td', [
n.component(new Html(m[1], { className: m[2]?.className })),
]),
]))),
]),
]);
});

this.module.charLog.logComponent(char, 'getExit', elem);
} catch (ex) {
console.error(ex);
}
}
}

export default GetExit;
3 changes: 1 addition & 2 deletions src/client/modules/main/commands/getRoom/GetRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Err from 'classes/Err';

const itemsPerPage = 50;

const usageText = 'get room <span class="opt"><span class="param">Attribute</span> <span class="opt">page <span class="param">Page</span></span></span>';
const usageText = 'get room <span class="param">Attribute</span> <span class="opt">page <span class="param">Page</span></span>';
const shortDesc = 'Get info about current room';
const helpText =
`<p>Get the value of a room attribute.</p>
Expand All @@ -37,7 +37,6 @@ class GetRoom {
'charLog',
'help',
'player',
'info',
], this._init.bind(this));
}

Expand Down
5 changes: 4 additions & 1 deletion src/client/modules/main/commands/go/Go.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import l10n from 'modapp-l10n';
import ListStep from 'classes/ListStep';
import Err from 'classes/Err';
import * as translateErr from 'utils/translateErr';

const usageText = 'go <span class="param">Keyword</span>';
const shortDesc = 'Go to another room';
Expand Down Expand Up @@ -45,7 +46,9 @@ class Go {
return ctx.char.call('useExit', p.exitId
? { exitId: p.exitId }
: { exitKey: p.exitKey },
);
).catch(err => {
throw translateErr.exitNotFound(err, p.exitKey);
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const helpText =
<p><code class="param">Keyword</code> is the keyword for the script.</p>
<p><code class="param">#ScriptID</code> is the ID of the script.</p>`;

const logLvlClass = {
log: 'charlog--default',
debug: 'charlog--ooc',
info: 'charlog--strong',
warn: 'charlog--cmd',
error: 'charlog--error',
};

/**
* RoomScript adds the room script command.
*/
Expand Down Expand Up @@ -96,16 +104,16 @@ class RoomScript {
]),
]),
];
if (script.errors.length) {
inner.push(n.component(new Txt(l10n.t('roomScript.recentErrors', "Recent errors"), { tagName: 'h4', className: 'charlog--pad' })));
if (script.logs.length) {
inner.push(n.component(new Txt(l10n.t('roomScript.recentErrors', "Recent logs"), { tagName: 'h4', className: 'charlog--pad' })));
inner.push(n.elem('div', { className: 'charlog--code' }, [
n.elem('table', { className: 'tbl-small tbl-nomargin charlog--font-small' }, script.errors.toArray().map(m => n.elem('tr', [
n.elem('table', { className: 'tbl-small tbl-nomargin charlog--font-small' }, script.logs.toArray().reverse().map(m => n.elem('tr', [
n.elem('td', { className: 'charlog--strong' }, [
n.text(formatDateTime(new Date(m.time), { showMilliseconds: true })),
]),
n.elem('td', [
n.elem('pre', { className: 'common--pre-wrap charlog--source' }, [
n.text(m.error),
n.elem('pre', { className: 'common--pre-wrap ' + (logLvlClass[m.lvl] || '') }, [
n.text(m.msg),
]),
]),
]))),
Expand Down
11 changes: 10 additions & 1 deletion src/client/modules/main/commands/setExit/SetExit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { exitIcons } from 'components/ExitIcon';
import { directions } from 'components/NavButtons';
import helpAttribDesc from 'utils/helpAttribDesc';
import { communicationTooLong, keyTooLong, itemNameTooLong } from 'utils/cmdErr';
import * as translateErr from 'utils/translateErr';

const usageText = 'set exit <span class="param">Keyword</span> : <span class="param">Attribute</span> = <span class="param">Value</span>';
const shortDesc = 'Set an exit attribute';
Expand Down Expand Up @@ -109,11 +110,17 @@ const defaultAttr = [
desc: l10n.l('setExit.hiddenDesc', "Flag telling if the exit is hidden, preventing it from being listed. Value is <code>yes</code> or <code>no</code>."),
sortOrder: 190,
},
{
key: 'inactive',
stepFactory: module => new ListStep('value', module.cmdLists.getBool(), { name: "is inactive flag" }),
desc: l10n.l('setExit.hiddenDesc', "Flag telling if the exit is inactive, preventing it from being listed and used. Value is <code>yes</code> or <code>no</code>."),
sortOrder: 200,
},
{
key: 'transparent',
stepFactory: module => new ListStep('value', module.cmdLists.getBool(), { name: "is transparent flag" }),
desc: l10n.l('setExit.transparentDesc', "Flag telling if the exit is transparent, allowing you to see awake characters in the target room. Value is <code>yes</code> or <code>no</code>."),
sortOrder: 200,
sortOrder: 210,
},
{
key: 'leaveMsg',
Expand Down Expand Up @@ -211,6 +218,8 @@ class SetExit {
: { exitKey: p.exitKey },
)).then(() => {
this.module.charLog.logInfo(ctx.char, l10n.l('setExit.updatedExit', "Exit attribute was successfully set."));
}).catch(err => {
throw translateErr.exitNotFound(err, p.exitKey);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import l10n from 'modapp-l10n';
import NumberStep from 'classes/NumberStep';

import * as translateErr from 'utils/translateErr';

/**
* SetExitOrder adds command to set exit attributes.
Expand Down Expand Up @@ -30,6 +30,8 @@ class SetExitOrder {
setExitOrder(char, params) {
return char.call('setExitOrder', params).then(result => {
this.module.charLog.logInfo(char, l10n.l('setExitOrder.exitOrderSet', "Exit order was successfully set."));
}).catch(err => {
throw translateErr.exitNotFound(err, params.exitKey);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ class PageEditAreaComponent {
closeOn: 'click',
type: 'success',
autoclose: true,
})).catch(err => this.module.confirm.openError(err, {
title: l10n.l('pageEditArea.mapImageNotUploaded', "Map image not uploaded"),
}));
}

Expand Down
Loading

0 comments on commit 1b7a4bd

Please sign in to comment.