Skip to content

Commit 63e65c5

Browse files
committed
feat: confirm cosmetic purchases
1 parent 6375c01 commit 63e65c5

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# UnderScript Changelog
22

3-
## Version 0.45.0 (2021-06-06)
3+
## Version 0.45.0 (2021-06-16)
44
### New Features
55
1. Added ability to buy multiple packs
66
1. Added confirmation for buying packs with UCP
77
1. Added a setting to switch minigame controls to WASD (disabled by default)
88
1. Added a random avatar button
99
1. Added setting to prefer shiny on import (enabled by default)
1010
1. Added "fill deck" button
11+
1. Added confirmation for buying cosmetics
1112
### Fixes
1213
1. Fixed bug with base card skin setting
1314
### Plugins

src/base/store/buyPacks.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ wrap(() => {
4848
type,
4949
gold: !cost,
5050
};
51-
if (cost) {
51+
if (cost && !e.shiftKey) {
5252
global('BootstrapDialog').show({
5353
title: 'Buy packs with UCP?',
54-
message: `You are about to buy ${count} pack${count > 1 ? 's' : ''} with UCP, continue?`,
54+
message: $.i18n(`Buy ${count} pack${count > 1 ? 's' : ''} for {{UCP:${count * 10}}} UCP?`),
5555
buttons: [{
56-
label: `Continue`,
56+
label: $.i18n('dialog-continue'),
57+
cssClass: 'btn-success',
5758
action(diag) {
5859
buyPacks(data);
5960
diag.close();
6061
},
6162
}, {
62-
label: 'Cancel',
63+
label: $.i18n('dialog-cancel'),
64+
cssClass: 'btn-danger',
6365
action(diag) {
6466
diag.close();
6567
},
@@ -69,7 +71,7 @@ wrap(() => {
6971
buyPacks(data);
7072
}
7173
});
72-
hover.new('CTRL: Buy MAX packs<br>ALT: Buy (up to) 10 packs', el);
74+
hover.new(`CTRL: Buy MAX packs<br>ALT: Buy (up to) 10 packs${cost ? '<br>SHIFT: Bypass confirmation' : ''}`, el);
7375
});
7476
});
7577
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
wrap(() => {
2+
onPage('CosmeticsShop', () => {
3+
eventManager.on(':loaded', () => {
4+
$('form[action=CosmeticsShop] button')
5+
.hover(hover.show('Shift: Bypass confirmation'), hover.hide)
6+
.click(function click(e) {
7+
if (e.shiftKey) return;
8+
e.preventDefault();
9+
const form = $(e.currentTarget).parent();
10+
const parent = $(form.parents('table.table-condensed, div')[0]);
11+
const image = parent.find('img')[0].outerHTML;
12+
const cost = parent.find('span[class=ucp]:first').text();
13+
global('BootstrapDialog').show({
14+
title: 'Buy with UCP?',
15+
message: `<div style="overflow: hidden;">${image}</div>${$.i18n(` Buy for {{UCP:${cost}}} UCP?`)}`,
16+
buttons: [{
17+
label: $.i18n('dialog-continue'),
18+
cssClass: 'btn-success',
19+
action(diag) {
20+
form.submit();
21+
diag.close();
22+
},
23+
}, {
24+
label: $.i18n('dialog-cancel'),
25+
cssClass: 'btn-danger',
26+
action(diag) {
27+
diag.close();
28+
},
29+
}],
30+
});
31+
});
32+
});
33+
});
34+
});

src/utils/settings.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,14 @@ const settings = wrap(() => {
473473

474474
function importSettings(string) {
475475
try {
476-
// TODO
476+
// TODO: Call setting events?
477+
const parsed = JSON.parse(atob(string));
478+
fn.each(parsed, (val, key) => {
479+
console.log(key, val);
480+
localStorage.setItem(key, val);
481+
});
477482
} catch (e) {
478-
// TODO
483+
console.error(e);
479484
}
480485
}
481486

0 commit comments

Comments
 (0)