Skip to content

Commit

Permalink
Deploy preview for PR 5099 🛫
Browse files Browse the repository at this point in the history
  • Loading branch information
RedSparr0w committed Feb 9, 2024
1 parent bf4628e commit 33daa33
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions docs/preview/pr-5099/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54472,7 +54472,7 @@ <h5>Welcome to the Battle Frontier!</h5>
<img src="" alt="selected berry image" height="28px" data-bind="attr:{ src: FarmController.getBerryImage(FarmController.selectedBerry()) },
css: {'berryLocked': !App.game.farming.unlockedBerries[FarmController.selectedBerry()]() }">
</button>
<div id="plotListCard" class="card-body p-0 px-1 show">
<div id="plotListCard" class="card-body p-0 px-1 show" data-bind="css: { ShiftPressed: GameController.keyHeld.Shift() }">
<div class="row py-1" data-bind="foreach: App.game.farming.plotList">
<!-- ko if: $index() % GameConstants.FARM_PLOT_WIDTH == 0 -->
<div class="w-100"></div>
Expand Down Expand Up @@ -58960,7 +58960,7 @@ <h6 class="m-0 text-light font-weight-bold">Complete Quest Lines</h6>
</div>

<div class="col-12 col-lg-8">
<div id="plotList" class="row" data-bind="foreach: App.game.farming.plotList">
<div id="plotList" class="row" data-bind="foreach: App.game.farming.plotList, css: { ShiftPressed: GameController.keyHeld.Shift() }">
<!-- ko if: $index() % GameConstants.FARM_PLOT_WIDTH == 0 -->
<div class="w-100"></div>
<!-- /ko -->
Expand Down
54 changes: 31 additions & 23 deletions docs/preview/pr-5099/scripts/script.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2173,25 +2173,30 @@ class GameController {
Settings.setSettingByName(`modalCollapse.${this.id}`, false);
});
$(document).on('keydown', e => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
// Ignore any of our controls if focused on an input element
if (this.focusedOnEditableElement()) {
return;
}
const key = GameController.convertKey(e.key);
// Set flags for any key currently pressed down (used to check if key held down currently)
GameController.keyHeld[key] = true;
if (GameController.keyHeld[key]) {
GameController.keyHeld[key](true);
}
else {
GameController.keyHeld[key] = ko.observable(true).extend({ boolean: null });
}
// Set our number key if defined (-1 for 0 indexed)
const numberKey = (+key) - 1;
const isNumberKey = !isNaN(numberKey) && numberKey >= 0;
const visibleModals = $('.modal:visible').length;
//Global Multi-key combinations
if (isNumberKey) {
if (GameController.keyHeld[Settings.getSetting('hotkey.pokeballSelection').value]) {
if ((_b = (_a = GameController.keyHeld)[Settings.getSetting('hotkey.pokeballSelection').value]) === null || _b === void 0 ? void 0 : _b.call(_a)) {
// Open pokeball selector modal using P + (1-4) for each condition
if (!((_a = $pokeballSelector.data('bs.modal')) === null || _a === void 0 ? void 0 : _a._isShown) && !$pokeballSelector.data('disable-toggle')) {
if (!((_c = $pokeballSelector.data('bs.modal')) === null || _c === void 0 ? void 0 : _c._isShown) && !$pokeballSelector.data('disable-toggle')) {
$('.modal').modal('hide');
(_b = $('#pokeballSelectorBody .clickable.pokeball-selected').eq(numberKey)) === null || _b === void 0 ? void 0 : _b.trigger('click');
(_d = $('#pokeballSelectorBody .clickable.pokeball-selected').eq(numberKey)) === null || _d === void 0 ? void 0 : _d.trigger('click');
return e.preventDefault();
}
}
Expand Down Expand Up @@ -2232,7 +2237,7 @@ class GameController {
return e.preventDefault();
}
// Within modals
if ((_c = $farmsModal.data('bs.modal')) === null || _c === void 0 ? void 0 : _c._isShown) {
if ((_e = $farmsModal.data('bs.modal')) === null || _e === void 0 ? void 0 : _e._isShown) {
switch (key) {
case Settings.getSetting('hotkey.farm.toggleShovel').value:
FarmController.selectedShovel() ? FarmController.selectedShovel(false) : FarmController.selectedShovel(true);
Expand All @@ -2244,7 +2249,7 @@ class GameController {
return e.preventDefault();
}
}
if ((_d = $undergroundModal.data('bs.modal')) === null || _d === void 0 ? void 0 : _d._isShown) {
if ((_f = $undergroundModal.data('bs.modal')) === null || _f === void 0 ? void 0 : _f._isShown) {
switch (key) {
case Settings.getSetting('hotkey.underground.hammer').value:
Mine.toolSelected(Mine.Tool.Hammer);
Expand Down Expand Up @@ -2272,7 +2277,7 @@ class GameController {
return e.preventDefault();
}
}
if ((_e = $oakItemsModal.data('bs.modal')) === null || _e === void 0 ? void 0 : _e._isShown) {
if ((_g = $oakItemsModal.data('bs.modal')) === null || _g === void 0 ? void 0 : _g._isShown) {
// Toggle oak items
if (isNumberKey) {
if (oakItems.isUnlocked(numberKey)) {
Expand All @@ -2286,21 +2291,21 @@ class GameController {
return e.preventDefault();
}
}
if ((_f = $pokeballSelector.data('bs.modal')) === null || _f === void 0 ? void 0 : _f._isShown) {
if ((_h = $pokeballSelector.data('bs.modal')) === null || _h === void 0 ? void 0 : _h._isShown) {
if (isNumberKey) {
// Switch selection type
if (GameController.keyHeld[Settings.getSetting('hotkey.pokeballSelection').value]) {
(_g = $('#pokeballSelectorBody .clickable.pokeball-selected').eq(numberKey)) === null || _g === void 0 ? void 0 : _g.trigger('click');
if ((_k = (_j = GameController.keyHeld)[Settings.getSetting('hotkey.pokeballSelection').value]) === null || _k === void 0 ? void 0 : _k.call(_j)) {
(_l = $('#pokeballSelectorBody .clickable.pokeball-selected').eq(numberKey)) === null || _l === void 0 ? void 0 : _l.trigger('click');
return e.preventDefault();
}
// Select Pokeball from pokeball selector (0 = none)
if (numberKey < App.game.pokeballs.pokeballs.length) {
(_h = pokeballs.selectedSelection()) === null || _h === void 0 ? void 0 : _h(numberKey);
(_m = pokeballs.selectedSelection()) === null || _m === void 0 ? void 0 : _m(numberKey);
}
return e.preventDefault();
}
}
if ((_j = $shipModal.data('bs.modal')) === null || _j === void 0 ? void 0 : _j._isShown) {
if ((_o = $shipModal.data('bs.modal')) === null || _o === void 0 ? void 0 : _o._isShown) {
if (isNumberKey) {
if (numberKey <= player.highestRegion()) {
const regionButton = $('.ship-modal-region-button').eq(numberKey);
Expand All @@ -2311,7 +2316,7 @@ class GameController {
return e.preventDefault();
}
}
if ((_k = $shopModal.data('bs.modal')) === null || _k === void 0 ? void 0 : _k._isShown) {
if ((_p = $shopModal.data('bs.modal')) === null || _p === void 0 ? void 0 : _p._isShown) {
if (isNumberKey) {
if (numberKey <= ShopHandler.shopObservable().items.length) {
ShopHandler.setSelected(numberKey);
Expand All @@ -2329,7 +2334,7 @@ class GameController {
ShopHandler.resetAmount();
return e.preventDefault();
case Settings.getSetting('hotkey.shop.increase').value:
if (GameController.keyHeld.Shift) {
if (GameController.keyHeld.Shift()) {
switch (Settings.getSetting('shopButtons').value) {
case 'original':
ShopHandler.increaseAmount(100);
Expand Down Expand Up @@ -2361,7 +2366,7 @@ class GameController {
// Only run if no modals are open
if (visibleModals === 0) {
// Route Battles
if (App.game.gameState === GameConstants.GameState.fighting && !GameController.keyHeld.Control) {
if (App.game.gameState === GameConstants.GameState.fighting && !((_r = (_q = GameController.keyHeld).Control) === null || _r === void 0 ? void 0 : _r.call(_q))) {
const cycle = Routes.getRoutesByRegion(player.region).filter(r => r.isUnlocked()).map(r => r.number);
const idx = cycle.findIndex(r => r == player.route());
// Allow '=' to fallthrough to '+' since they share a key on many keyboards
Expand Down Expand Up @@ -2414,7 +2419,7 @@ class GameController {
else if (isNumberKey) {
// Check if a number higher than 0 and less than our towns content was pressed
const filteredContent = player.town().content.filter(c => c.isVisible());
const filteredNPCs = (_l = player.town().npcs) === null || _l === void 0 ? void 0 : _l.filter(n => n.isVisible());
const filteredNPCs = (_s = player.town().npcs) === null || _s === void 0 ? void 0 : _s.filter(n => n.isVisible());
if (numberKey < filteredContent.length) {
filteredContent[numberKey].protectedOnclick();
}
Expand All @@ -2423,7 +2428,7 @@ class GameController {
}
return e.preventDefault();
}
else if (player.town() instanceof DungeonTown && !GameController.keyHeld.Control) {
else if (player.town() instanceof DungeonTown && !((_u = (_t = GameController.keyHeld).Control) === null || _u === void 0 ? void 0 : _u.call(_t))) {
const cycle = Object.values(TownList).filter(t => t instanceof DungeonTown && t.region == player.region && t.isUnlocked());
const idx = cycle.findIndex(d => d.name == player.town().name);
switch (key) {
Expand Down Expand Up @@ -2482,19 +2487,19 @@ class GameController {
}
break;
case Settings.getSetting('hotkey.forceSave').value:
if (GameController.keyHeld.Shift) {
if (GameController.keyHeld.Shift()) {
Save.store(player);
return e.preventDefault();
}
break;
case Settings.getSetting('hotkey.downloadSave').value:
if (GameController.keyHeld.Shift) {
if (GameController.keyHeld.Shift()) {
Save.download();
return e.preventDefault();
}
break;
case Settings.getSetting('hotkey.mute').value:
if (GameController.keyHeld.Shift) {
if (GameController.keyHeld.Shift()) {
Settings.getSetting('sound.muted').toggle();
return e.preventDefault();
}
Expand All @@ -2513,13 +2518,14 @@ class GameController {
}
});
$(document).on('keyup', e => {
var _a, _b;
// Ignore any of our controls if focused on an input element
if (this.focusedOnEditableElement()) {
return;
}
const key = GameController.convertKey(e.key);
// Our key is no longer being held down
delete GameController.keyHeld[key];
(_b = (_a = GameController.keyHeld)[key]) === null || _b === void 0 ? void 0 : _b.call(_a, false);
if (App.game.gameState === GameConstants.GameState.safari) {
switch (key) {
case 'ArrowUp':
Expand Down Expand Up @@ -2551,7 +2557,9 @@ class GameController {
}
}
// Store keys for multi-key combinations
GameController.keyHeld = {};
GameController.keyHeld = {
Shift: ko.observable(false).extend({ boolean: null }),
};
// when stacking modals allow scrolling after top modal hidden
$(document).on('hidden.bs.modal', '.modal', () => {
$('.modal:visible').length && $(document.body).addClass('modal-open');
Expand Down
2 changes: 1 addition & 1 deletion docs/preview/pr-5099/styles/styles.min.css

Large diffs are not rendered by default.

0 comments on commit 33daa33

Please sign in to comment.