Skip to content

Commit

Permalink
[feature] customizable sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
fedorovvl committed Jul 24, 2024
1 parent 6654c79 commit cf0a027
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/files/content/bootstrap.min.css

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion client/files/content/scripts/0-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ var mainSettings = {
shortAsGlobalRelative: false,
lruSkipModules: [],
mwChatPanel: false,
mailRouteStorage: false
mailRouteStorage: false,
effectSounds: {}
};
var chatCSSTemplate = '.bbmsg {#bbmsg;font-weight: bold;}.modmsg {#modmsg;font-weight: bold;}.communityleadmsg {#communityleadmsg;font-weight: bold;}.globaltstamp {#globaltstamp;}.globalsender {#globalsender;text-decoration: underline;}.globalmsg {#globalmsg;}.globalownname {#globalownname;font-weight: bold;}.globalimportant {#globalimportant;font-weight: bold;}.findcooptstamp {#findcooptstamp;}.findcoopsender {#findcoopsender;text-decoration: underline;}.findcoopmsg {#findcoopmsg;}.findcoopownname {#findcoopownname;font-weight: bold;}.findcoopimportant {#findcoopimportant;font-weight: bold;}.tradetstamp {#tradetstamp;}.tradesender {#tradesender;text-decoration: underline;}.trademsg {#trademsg;}.tradeownname {#tradeownname;font-weight: bold;}.tradeimportant {#tradeimportant;font-weight: bold;}.helptstamp {#helptstamp;}.helpsender {#helpsender;text-decoration: underline;}.helpmsg {#helpmsg;}.helpownname {#helpownname;font-weight: bold;}.helpimportant {#helpimportant;font-weight: bold;}.newststamp {#newststamp;}.newssender {#newssender;text-decoration: underline;}.newsmsg {#newsmsg;}.newsimportant {#newsimportant;font-weight: bold;}.newsownname {#newsownname;font-weight: bold;}.guildtstamp {#guildtstamp;}.guildsender {#guildsender;text-decoration: underline;}.guildmsg {#guildmsg;}.guildownname {#guildownname;font-weight: bold;}.guildimportant {#guildimportant;font-weight: bold;}.officerststamp {#officerststamp;}.officerssender {#officerssender;text-decoration: underline;}.officersmsg {#officersmsg;}.officersownname {#officersownname;font-weight: bold;}.officersimportant {#officersimportant;font-weight: bold;}.whispertstamp {#whispertstamp;}.whispersender {#whispersender;text-decoration: underline;}.whispermsg {#whispermsg;}.whisperownname {#whisperownname;font-weight: bold;}.whisperimportant {#whisperimportant;font-weight: bold;}.*coop*tstamp {#cooptstamp;}.*coop*sender {#coopsender;text-decoration: underline;}.*coop*msg {#coopmsg;}.*coop*ownname {#coopownname;}';
var cssRoomToLoca = {
Expand Down Expand Up @@ -290,6 +291,26 @@ function menuFilterHandler(event)
setFilterHandler(event.target.name);
}

function getSoundsCount()
{
var n = 0;
for(var i in game.def("defines").soundEffects) { n++; }
return n;
}

function disableEffectSounds()
{
if(Object.keys(mainSettings.effectSounds).length == 0) { return; }
if(getSoundsCount() < Object.keys(mainSettings.effectSounds).length) {
debug("wait some");
setTimeout(disableEffectSounds, 1000);
return;
}
for(var i in mainSettings.effectSounds) {
game.def("defines").soundEffects[i] = mainSettings.effectSounds[i];
}
}

function menuZoneRefreshHandler(event)
{
game.gi.mClientMessages.SendMessagetoServer(1037, game.gi.mCurrentViewedZoneID, null);
Expand Down Expand Up @@ -958,3 +979,4 @@ if(dropboxApiKey != null && expZone == null) {
dropbox = new Dropbox(dropboxApiKey, window.atob(dropboxApiRefresh));
dropbox.init();
}
disableEffectSounds();
6 changes: 4 additions & 2 deletions client/files/content/scripts/0-lang-en-ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ extendBaseLang({
'add_buff_desc': 'Add buff',
'itemshide_desc': 'Hide starmenu items',
'mwchat_desc': 'Chat panel in MW',
'mail_route_desc': "Loot to storage by default"
'mail_route_desc': "Loot to storage by default",
'sound_desc': "Sounds"
},
'ru-ru': {
'btn_submit': 'Отправить',
Expand Down Expand Up @@ -392,6 +393,7 @@ extendBaseLang({
'add_buff_desc': 'Добавить усилитель',
'itemshide_desc': 'Скрытие предметов',
'mwchat_desc': 'Панель сисчата в МО',
'mail_route_desc': "Добыча на склад по умолчанию"
'mail_route_desc': "Добыча на склад по умолчанию",
'sound_desc': "Звуки"
}
});
23 changes: 22 additions & 1 deletion client/files/content/scripts/5-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ function mainSettingsHandler(event)
'id': id
}).text(text)
}
w.size = '';
var getSounds = function() {
var result = [];
$.each(game.def("defines").soundEffects, function(k, v) { result.push(k); });
return result.sort();
}
w.size = 'modal-sg';
w.create();
var html = '<div class="container-fluid" style="user-select: all;">';
var tabs = $('<ul>', { 'class': 'nav nav-pills nav-justified', 'style': 'width: 100%' });
Expand All @@ -117,6 +122,7 @@ function mainSettingsHandler(event)
tabs.append($('<li>').append($('<a>', { 'data-toggle': 'tab', 'href': '#menulru' }).text("LRU")));
tabs.append($('<li>').append($('<a>', { 'data-toggle': 'tab', 'href': '#menunotify' }).text(getText("notifi_desc"))));
tabs.append($('<li>').append($('<a>', { 'data-toggle': 'tab', 'href': '#menuchat' }).text(getText("chat_desc"))));
tabs.append($('<li>').append($('<a>', { 'data-toggle': 'tab', 'href': '#menusound' }).text(getText("sound_desc"))));
html += utils.createTableRow([[6, loca.GetText("LAB", "Name")], [6, loca.GetText("LAB", "AvatarCurrentSelection")]], true);
var themeSelector = $('<select>', { 'class': 'form-control theme' });
themeSelector.append([$('<option>', { 'value': 'dark' }).text(getText("theme_dark")), $('<option>', { 'value': 'light' }).text(getText("theme_light"))]);
Expand Down Expand Up @@ -233,6 +239,12 @@ function mainSettingsHandler(event)
html += utils.createTableRow([[6, cssGetText(k)], [6, '<input type="text" value="'+v+'" id="'+k+'" class="kolorPicker form-control shortercontrol"><span class="colorcell"/>']]);
});
tabcontent.append($('<div>', { 'class': 'tab-pane fade', 'id': 'menuchat' }).append(html+'</div>'));
var html = '<div class="container-fluid" style="user-select: all;">';
html += utils.createTableRow([[6, loca.GetText("LAB", "Name")], [5, loca.GetText("LAB", "AvatarCurrentSelection")], [1, "#"]], true);
$.each(getSounds(), function(k,v) {
html += utils.createTableRow([[6, v], [5, createSwitch('sound_'+v, mainSettings.effectSounds.hasOwnProperty(v)?mainSettings.effectSounds[v]:true)], [1, createButton('play', 'play')]]);
})
tabcontent.append($('<div>', { 'class': 'tab-pane fade', 'id': 'menusound' }).append(html+'</div>'));
w.Body().html(tabs.prop("outerHTML") + '<br>' + tabcontent.prop("outerHTML"));
w.withBody('div.row').addClass('nohide');
w.withBody('.nav-justified > li').css("width", "20%");
Expand All @@ -255,6 +267,11 @@ function mainSettingsHandler(event)
w.withBody('.kolorPicker').change();
w.withBody('button').click(function(e) {
var id = $(e.target).attr('id');
if(id == 'play') {
var effect = $(this).closest("div .row").find("input[type=checkbox]").prop("id").replace("sound_", '');
game.def("Sound::cSoundManager").getInstance().playEffect(effect);
return;
}
if(id == 'testnotify') {
setupNotifications();
var title = notifySettings.compact ? loca.GetText("SD2", "ChangeSkinBuffMason") : game.gw + ' - ' + game.playerName;
Expand Down Expand Up @@ -332,6 +349,9 @@ function mainSettingsHandler(event)
return;
}
});
w.withBody('[id^=sound_]').change(function(e) {
game.def("defines").soundEffects[e.target.id.replace("sound_", '')] = $(e.target).is(':checked');
});
w.withBody('[id^=lruSkip_]').change(function(e) {
if($(e.target).is(':checked')) {
mainSettings.lruSkipModules.splice(mainSettings.lruSkipModules.indexOf(e.target.id.replace("lruSkip_", '')), 1);
Expand Down Expand Up @@ -367,6 +387,7 @@ function mainSettingsHandler(event)
w.withBody('#newsCustom').change(function(e) { notifySettings.newsCustom = $(e.target).is(':checked'); });
w.withBody('#mentionGroup').change(function(e) { notifySettings.mentionGroup = $(e.target).is(':checked'); });
w.Footer().prepend($("<button>").attr({'class':"btn btn-primary pull-left"}).text(loca.GetText("LAB","Save")).click(function(){
$.each(game.def("defines").soundEffects, function(k, v) { mainSettings.effectSounds[k] = v; });
settings.settings["global"] = {};
settings.store(mainSettings);
if(menu.type != mainSettings.menuStyle) {
Expand Down

0 comments on commit cf0a027

Please sign in to comment.