Skip to content

Commit

Permalink
Add: option to autoreset selected tool
Browse files Browse the repository at this point in the history
  • Loading branch information
redweller committed Jan 16, 2022
1 parent 87f2299 commit 28192ae
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 29 deletions.
18 changes: 15 additions & 3 deletions _locales/en/howto.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,28 @@ <h2 id="menu">
</p>
<img src="../images/help_menu.jpg" alt="Blank page with OBRT menu open" title="Blank page with OBRT menu open">
<h3>
Settings
Modules
</h3>
<p>
Each module or additional feature can be enabled or disabled by ticking respective checkbox under Settings submenu. The options are listed below:
Each module can be enabled or disabled by ticking respective checkbox under Modules submenu. The options are listed below:
</p>
<ul>
<li>Combat tracker - completely enables/disables token list, combat rounds and the rest of corresponding features.</li>
<li>Dice tray log - completely enables/disables dice log overlay, as well as some additional tweaks to the OBR dice tray.</li>
<li>Dice roll sounds - completely enables/disables sound played on dice roll, both by you and when somebody else rolls a dice.</li>
<li>Start fullscreen - not exactly a module, just saves your time, automatically hiding native OBR panels (check this if you're not the GM or play on mobile).</li>
</ul>
<p>
<span class="note">To apply your selection of modules you must reload the OBR page.</span>
</p>
<h3>
Tweaks
</h3>
<p>
Tweaks are small modifications of OBR behavior. Each tweak can be enabled or disabled by ticking respective checkbox under Tweaks submenu. The options are listed below:
</p>
<ul>
<li>Autoreset tools - automatically reset current tool to the default Move Tool when Map Controls toolbar is collapsed.</li>
<li>Start fullscreen - if saves your time, automatically hiding native panels when OBR loads (check this if you're not the GM or play on mobile).</li>
</ul>
<p>
<span class="note">To apply these settings you must reload the OBR page.</span>
Expand Down
9 changes: 7 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"popup_orct_version": { "message": "Combat tracker" },
"popup_or_version": { "message": "Tested with" },
"popup_sessions": { "message": "Recent sessions" },
"popup_settings": { "message": "Settings" },
"popup_modules": { "message": "Modules" },
"popup_tweaks": { "message": "Tweaks" },
"popup_no_sessions": { "message": "No sessions found" },

"popup_sessions_date": { "message": "$2 $1", "description": "Order of date ($1) and month ($2)" },
Expand All @@ -21,16 +22,20 @@
"option_dice_tray": { "message": "Dice tray log" },
"option_dice_sound": { "message": "Dice roll sounds" },
"option_fullscreen": { "message": "Start fullscreen" },
"option_reset_tools": { "message": "Autoreset tools" },

"select_recent_sessions": { "message": "Click on one of the links below to open your recent session" },
"select_modules_and_reload": { "message": "Select tracker modules and reload the game" },
"select_modules_and_goto": { "message": "Select tracker modules and proceed to Owlbear Rodeo to start" },
"select_modules_and_start": { "message": "Select tracker modules and start or join the existing game" },
"select_tweaks_and_reload": { "message": "Select modifications and reload the game" },
"select_tweaks_and_goto": { "message": "Select modifications and proceed to Owlbear Rodeo to start" },
"select_tweaks_and_start": { "message": "Select modifications and start or join the existing game" },
"goto_owlbear_tab": { "message": "Switch to Owlbear" },
"open_owlbear_page": { "message": "Open Owlbear" },
"save_settings": { "message": "Save settings" },
"saved_settings": { "message": "Saved!" },
"reload_to_apply": { "message": "Reload page to apply settings" },
"reload_to_apply": { "message": "Reload page to apply" },

"help_icon": { "message": "Help" },
"help_about_link": { "message": "About" },
Expand Down
18 changes: 15 additions & 3 deletions _locales/ru/howto.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,28 @@ <h2 id="menu">
</p>
<img src="../images/help_menu.jpg" alt="Пустая страница с открытым меню OBRT" title="Пустая страница с открытым меню OBRT">
<h3>
Настройки
Модули
</h3>
<p>
Каждый модуль или дополнительную функцию можно включить или отключить, установив соответствующий флажок в подменю "Настройки". Варианты перечислены ниже:
Каждый модуль включить или отключить, установив соответствующий флажок в подменю "Модули". Варианты перечислены ниже:
</p>
<ul>
<li>Трекер боёв - полностью включает/отключает список персонажей, боевые раунды и остальные соответствующие функции.</li>
<li>Трекер кубиков - полностью включает/отключает журнал бросков кубиков, а также некоторые дополнительные настройки лотка кубов OBR.</li>
<li>Звуки кубиков - полностью включает/отключает звук, воспроизводимый при броске, как вами, так и когда кто-то другой бросает кубик.</li>
<li>Свернуть панели - не совсем модуль, просто экономит время, автоматически скрывая панели OBR (включите, если вы не GM и/или играете на смартфоне).</li>
</ul>
<p>
<span class="note">Чтобы применить изменения модулей, вы должны перезагрузить страницу OBR.</span>
</p>
<h3>
Настройки
</h3>
<p>
В этом разделе меню настраиваются небольшие модификации поведения OBR. Каждую функцию можно включить или отключить, установив соответствующий флажок в подменю "Настройки". Варианты перечислены ниже:
</p>
<ul>
<li>Сбрасывать панель - автоматически сбрасывает выбранный инструмент к дефолтному Перемещению (Move Tool), когда панель инструментов (Map Tools) свёрнута.</li>
<li>Свернуть панели - просто экономит время, автоматически скрывая родные панели при загрузке OBR (удобно держать эту опцию включённой, если вы не GM и/или играете на смартфоне).</li>
</ul>
<p>
<span class="note">Чтобы применить эти настройки, вы должны перезагрузить страницу OBR.</span>
Expand Down
7 changes: 6 additions & 1 deletion _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"popup_orct_version": { "message": "Расширение" },
"popup_or_version": { "message": "Проверено с" },
"popup_sessions": { "message": "Последние игры" },
"popup_settings": { "message": "Настройки" },
"popup_modules": { "message": "Модули" },
"popup_tweaks": { "message": "Настройки" },
"popup_no_sessions": { "message": "Сессий не найдено" },

"popup_sessions_date": { "message": "$1 $2", "description": "Order of date ($1) and month ($2)" },
Expand All @@ -21,11 +22,15 @@
"option_dice_tray": { "message": "Трекер кубиков" },
"option_dice_sound": { "message": "Звуки кубиков" },
"option_fullscreen": { "message": "Свернуть панели" },
"option_reset_tools": { "message": "Сбрасывать панель" },

"select_recent_sessions": { "message": "Нажмите на одну из ссылок ниже, чтобы открыть недавнюю игру" },
"select_modules_and_reload": { "message": "Выберите модули и перезагрузите для применения изменений" },
"select_modules_and_goto": { "message": "Выберите модули и откройте Owlbear Rodeo, чтобы начать играть" },
"select_modules_and_start": { "message": "Выберите модули и создайте или присоединитесь к игре" },
"select_tweaks_and_reload": { "message": "Выберите настройки и перезагрузите для применения изменений" },
"select_tweaks_and_goto": { "message": "Выберите настройки и откройте Owlbear Rodeo, чтобы начать играть" },
"select_tweaks_and_start": { "message": "Выберите настройки и создайте или присоединитесь к игре" },
"goto_owlbear_tab": { "message": "Перейти на Owlbear" },
"open_owlbear_page": { "message": "Открыть Owlbear" },
"save_settings": { "message": "Сохранить настройки" },
Expand Down
25 changes: 21 additions & 4 deletions action/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
let saved = false;
let save = document.getElementById('save');
let title = document.getElementById('title');
let ttitle = document.querySelector("#tweaks > div.title");
let s_cont = document.getElementById('sessions').lastElementChild;

let c_combt = document.getElementById('enable_combat');
let c_dicet = document.getElementById('enable_dice');
let c_sound = document.getElementById('enable_sound');
let c_fullscreen = document.getElementById('enable_fs');
let c_resettool = document.getElementById('enable_resett');

const siteq = /https:\/\/([\w.]*)owlbear\.rodeo([\w\/.]*)/;
const pageq = /https:\/\/([\w.]*)owlbear\.rodeo\/game\/([\w\/.]*)/;
Expand All @@ -37,16 +39,25 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
const switcher = document.getElementById('switcher');
const help_button = document.getElementById('helpico');
const sessions_button = document.getElementById('sessions_button');
const settings_button = document.getElementById('settings_button');
const modules_button = document.getElementById('modules_button');
const tweaks_button = document.getElementById('tweaks_button');

sessions_button.addEventListener('click', function () {
document.getElementById('settings').style.height = '0px';
document.getElementById('modules').style.height = '0px';
document.getElementById('sessions').style.height = '130px';
document.getElementById('tweaks').style.height = '0px';
});

settings_button.addEventListener('click', function () {
document.getElementById('settings').style.height = '130px';
modules_button.addEventListener('click', function () {
document.getElementById('modules').style.height = '130px';
document.getElementById('sessions').style.height = '0px';
document.getElementById('tweaks').style.height = '0px';
});

tweaks_button.addEventListener('click', function () {
document.getElementById('tweaks').style.height = '130px';
document.getElementById('sessions').style.height = '0px';
document.getElementById('modules').style.height = '0px';
});

help_button.addEventListener('click', function () {
Expand All @@ -69,13 +80,15 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
if (s.dice) c_dicet.checked = true;
if (s.sound) c_sound.checked = true;
if (s.fs) c_fullscreen.checked = true;
if (s.rt) c_resettool.checked = true;

if (isMobile()) document.body.style.margin = 'auto';

c_combt.addEventListener('click', resetAction);
c_dicet.addEventListener('click', resetAction);
c_sound.addEventListener('click', resetAction);
c_fullscreen.addEventListener('click', resetAction);
c_resettool.addEventListener('click', resetAction);

localize(document.body);
document.body.style.display = 'inherit';
Expand Down Expand Up @@ -171,6 +184,7 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
if (!pag.siteq) {

title.textContent = getLocaleText('select_modules_and_goto');
ttitle.textContent = getLocaleText('select_tweaks_and_goto');
if (ttab) {
save.textContent = getLocaleText('goto_owlbear_tab');
save.disabled = false;
Expand All @@ -191,6 +205,7 @@ runtime.sendMessage({method: "getStorage"}, function(result) {

if (!pag.pageq) {
title.textContent = getLocaleText('select_modules_and_start');
ttitle.textContent = getLocaleText('select_tweaks_and_start');
save.disabled = true;
if (saved) {
save.textContent = getLocaleText('saved_settings');
Expand All @@ -199,6 +214,7 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
}
} else {
title.textContent = getLocaleText('select_modules_and_reload');
ttitle.textContent = getLocaleText('select_tweaks_and_reload');
if (saved) {
save.textContent = getLocaleText('reload_to_apply');
save.onclick = function () {
Expand All @@ -225,6 +241,7 @@ runtime.sendMessage({method: "getStorage"}, function(result) {
dice: (c_dicet.checked == true),
sound: (c_sound.checked == true),
fs: (c_fullscreen.checked == true),
rt: (c_resettool.checked == true),
}
});
saved = true;
Expand Down
20 changes: 15 additions & 5 deletions action/markup.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@
<div>__MSG_popup_no_sessions__</div>
</div>
</div>
<div id="settings_button"><a>__MSG_popup_settings__</a><span></span></div>
<div id="settings">
<div id="tweaks_button"><a>__MSG_popup_tweaks__</a><span></span></div>
<div id="tweaks" style="height:0px;">
<div class="title">
__MSG_select_tweaks_and_reload__
</div>
<div>
<label for="enable_resett">__MSG_option_reset_tools__</label>
<input type="checkbox" id="enable_resett">
</div><div>
<label for="enable_fs">__MSG_option_fullscreen__</label>
<input type="checkbox" id="enable_fs">
</div>
</div>
<div id="modules_button"><a>__MSG_popup_modules__</a><span></span></div>
<div id="modules">
<div id="title">
__MSG_select_modules_and_reload__
</div>
Expand All @@ -45,9 +58,6 @@
</div><div>
<label for="enable_sound">__MSG_option_dice_sound__</label>
<input type="checkbox" id="enable_sound">
</div><div>
<label for="enable_fs">__MSG_option_fullscreen__</label>
<input type="checkbox" id="enable_fs">
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions action/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const storage = (function () {
dice: (true),
sound: (true),
fs: (false),
rt: (false),
};


Expand All @@ -27,6 +28,7 @@ const storage = (function () {
settings.dice = set.dice || false ;
settings.sound = set.sound || false ;
settings.fs = set.fs || false ;
settings.rt = set.rt || false ;
}

const processSessionsLog = function (time, guid, url) {
Expand Down
26 changes: 15 additions & 11 deletions action/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ body {
user-select: none;
}

body #settings div div {
#modules div div,
#tweaks div div {
height: 25px;
padding-bottom: unset!important;
}
Expand All @@ -37,7 +38,8 @@ button:hover {

div#sessions div div:hover,
#switcher div#sessions_button:hover,
#switcher div#settings_button:hover {
#switcher div#tweaks_button:hover,
#switcher div#modules_button:hover {
text-shadow: 0 1px 1px #88a0a3a1;
color:#c57dd3;
}
Expand All @@ -60,7 +62,7 @@ button:active {
}

label {
margin: 2px 10px;
margin: 2px 3px 2px 10px;
height: 15px;
display: inline-block;
}
Expand Down Expand Up @@ -107,20 +109,22 @@ div#header div {
}


div#settings, div#sessions {
div#sessions, div#modules, div#tweaks {
background-color: #7788991c;
height: 135px;
padding: 5px;
text-align: left;
overflow: hidden;
transition: height 0.5s;
height: 130px;
padding: 0px 5px;
text-align: left;
overflow: hidden;
transition: height 0.5s;
}

#settings #title, #sessions .title {
#modules #title, #sessions .title, #tweaks .title {
padding: 6px;
}

#switcher div#sessions_button, #switcher div#settings_button {
#switcher div#sessions_button,
#switcher div#tweaks_button,
#switcher div#modules_button {
text-align: left;
border-top: 1px solid #7788994d;
cursor: pointer;
Expand Down
7 changes: 7 additions & 0 deletions injected/orctmain.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ const om = {
if (fsbutton) if (fsbutton.title == 'Enter Full Screen') fsbutton.click();
if (panelbutton) panelbutton.click();
}
if (settings.rt) {
const tbbutton = document.querySelector("div.css-1e2e67h > div.css-wcquo4 > div > div.css-1vluezq > button");
const handbutton = document.querySelector("div.css-wcquo4 > div > div.css-1vluezq > div > button:nth-child(3)")
tbbutton.addEventListener('click', () => {
handbutton.click();
})
}

} else {
const targetNode = body;
Expand Down

0 comments on commit 28192ae

Please sign in to comment.