Skip to content

Commit 011f15c

Browse files
committed
Add functionality for arbitrary item names in the inventory panel and drop-down menus
1 parent 1faa328 commit 011f15c

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
+ Added: Ability to execute JavaScript code from URQL code and retrieve its result using the javascript system variable.
1111
+ Added: Ability to read any file from the game package and get its contents as text using the fileread system variable.
1212
+ Added: System variables image_caption, time, date (only when urq_mode specific rules are absent), urqw_title, urqw_game_ifid, urqw_game_lang, urqw_version.
13+
+ Added: Ability to set arbitrary names for inventory items, for inventory item usage options, and for drop-down menu items of links in text instead of names based on variable and labels names (special variables with the `display_` prefix are used).
1314
+ Added: The clst operator to clear the screen of text.
1415
+ Added: The varkill operator (a direct counterpart of the perkill operator).
1516
+ Added: Support for custom alternative text descriptions for images added using either the image system variable or the image operator.
@@ -48,6 +49,7 @@
4849
+ Added: Titles for save and load game dialog boxes.
4950
+ Added: Support for opening .qsz format games.
5051
+ Changed: Inventory item usage options are displayed when the item receives system focus, not just when the mouse is hovering over it.
52+
+ Changed: Inventory item usage options generated from use labels names are displayed with spaces instead of underscores.
5153
+ Changed: Keypress tracking by key code instead of character code.
5254
+ Changed: Minor adjustment to informative window indentation.
5355
+ Fixed: Links disappear from the text when loading a saved game.

docs/urql.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
:use_предмет
6565
:use_предмет_
6666
hide_use_
67+
display_use_
68+
69+
[[ссылка|метка|действие1, действие2]]
70+
hide_метка_действие1
71+
display_метка_действие1
6772
6873
-->
6974

js/Client.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ Client.prototype.drawItem = function (itemName, quantity) {
302302
}
303303
});
304304

305-
var itemDisplayName = itemName.replace(/_/g, ' ');
305+
var displayName = Game.getVar('display_use_' + itemName);
306+
var itemDisplayName;
307+
if (displayName) {
308+
itemDisplayName = displayName;
309+
} else {
310+
itemDisplayName = itemName.replace(/_/g, ' ');
311+
}
306312

307313
// Some items and actions need to be inserted with language markup,
308314
// for this the following two variables are needed
@@ -365,13 +371,21 @@ var ul = $('<ul role="presentation" class="dropdown-menu">');
365371
}
366372

367373
if (Game.getVar('hide_use_' + itemName + '_' + actions[i][0]) == 0) {
368-
li2link = $('<a href="#" class="item_use">');
374+
displayName = Game.getVar('display_use_' + itemName + '_' + actions[i][0]);
375+
var actionDisplayName;
376+
if (displayName) {
377+
actionDisplayName = displayName;
378+
} else {
379+
actionDisplayName = actions[i][0].replace(/_/g, ' ');
380+
}
381+
382+
li2link = $('<a href="#" class="item_use">');
369383
li2link.attr('data-label', actions[i][1]);
370384
if (htmlContent) {
371-
li2link.html(actions[i][0]);
385+
li2link.html(actionDisplayName);
372386
htmlContent = false;
373387
} else {
374-
li2link.text(actions[i][0]);
388+
li2link.text(actionDisplayName);
375389
}
376390
// A11Y modification: Place links in elements with the list item role
377391
li2link = $('<span role="listitem">').append(li2link);

js/Parser.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,16 @@ Parser.prototype.openLinks = function(line) {
269269
// action = `pln You cannot ${command2[i].trim()} ${command}!`;
270270
}
271271

272+
var displayName = Game.getVar('display_' + label);
273+
var actionDisplayName;
274+
if (displayName) {
275+
actionDisplayName = displayName;
276+
} else {
277+
actionDisplayName = command2[i].replace(/_/g, ' ').trim();
278+
}
279+
272280
var actionNum = GlobalPlayer.link(action);
273-
links.push(`<li><a data-action="${actionNum}" class="button" href="#">${command2[i].replace(/_/g, ' ').trim()}</a></li>`);
281+
links.push(`<li><a data-action="${actionNum}" class="button" href="#">${actionDisplayName}</a></li>`);
274282
}
275283

276284
if (links.length == 0) {

md/ru/other/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
+ Добавлено: Возможность выполнить код JavaScript из кода URQL и получить его результат с помощью системной переменной javascript.
1111
+ Добавлено: Возможность прочитать любой файл из пакета игры и получить его содержимое как текст с помощью системной переменной fileread.
1212
+ Добавлено: Системные переменные image_caption, time, date (только при отсутствии специальных правил urq_mode), urqw_title, urqw_game_ifid, urqw_game_lang, urqw_version.
13+
+ Добавлено: Возможность задать произвольные названия для предметов инвентаря, вариантов использования предметов инвентаря и пунктов выпадающих меню у ссылок в тексте вместо названий, основанных на именах переменных и меток (используются специальные переменные с префиксом `display_`).
1314
+ Добавлено: Оператор clst для очистки экрана от текста.
1415
+ Добавлено: Оператор varkill (прямой аналог perkill).
1516
+ Добавлено: Поддержка пользовательских альтернативных текстовых описаний для изображений, добавляемых с помощью системной переменной image или оператора image.
@@ -48,6 +49,7 @@
4849
+ Добавлено: Заголовки в диалоговых окнах сохранения и загрузки игры.
4950
+ Добавлено: Поддержка открытия игр в формате .qsz.
5051
+ Изменено: Варианты использования предмета в инвенторе отображаются, когда предмет принимает системный фокус, а не только когда на него наводится мышь.
52+
+ Изменено: Варианты использования предмета в инвенторе, формируемые из названий меток использования, отображаются с пробелами вместо подчёркиваний.
5153
+ Изменено: Отслеживание нажатий клавиш не по коду символа, а по коду клавиши.
5254
+ Изменено: Небольшая правка отступа информативного окна.
5355
+ Исправлено: Ссылки исчезают из текста при загрузке сохранённой игры.

0 commit comments

Comments
 (0)