This should make PS marginally slower on really old browsers,
marginally faster on modern browsers, neither of which should be
remotely noticeable.
The intended actual impact is to make it easier to maintain
(`battle-dex` is clearly the wrong place for polyfills) and easier
to reuse outside of PS.
All sound stuff is now handled directly by BattleSound, using the
HTML5 audio API.
The main complicated thing we do with sound is loop music with an intro.
This is unfortunately not supported by ANY sound library out there
(I had to manually add support for it myself to soundManager!)
https://github.com/scottschiller/SoundManager2/pull/13
In the end, I don't think the existing libraries out there actually
give us anything I care about.
This will prevent us from needing to maintain two search engines in
the future.
The new DexSearch doesn't have too much in the way of new features so
far, but it does show filtered things in categories, and list illegal
results in-filter even after sorting.
These are really minor differences, though; the main thing is just that
its architecture should make it much easier to maintain, and in
particular, to add more filters.
`style/STYLING.html` is now a guide of generic CSS classes that can be
used by bots and chat plugins.
CSS classes that can be used by bots and chat plugins are now in a new
`battle-log.css` (previously just a section of `battle.css`)
Several PS styling patterns (specifically, `message-log`, `option`, and
`blocklink`) have been refactored into CSS classes, so that they can
be used by bots and chat plugins (why yes, I do plan on using 2/3 of
them in the log viewer).
Past CSS has been super messy. This refactor tries to make it neater
by adhering to these rules:
- Instead of trying to use e.g. `.setmenu button` selectors (to save
`class=` on every individual list item), give up and just put
`.option` directly on list items. This drastically cuts down on all
the hacks necessary to have `.button` work inside `.setmenu`.
...That's it. That's the only change. It massively cuts down on CSS
complexity. It does slightly complicate the DOM, which I'm not a _huge_
fan of, but CSS unpredictability is nearly impossible to catch and
debug, so it's massively worth it.
This adds the BOM to all HTTP pages as per the HTML5 spec and ensures
all pages use UTF-8 as their meta charset (which is still kept for
compatibility with older browsers).
* Use SockJS' timeout config option
This sets timeouts on connections to 5 minutes, matching the server's
heartbeat interval to close sockets that shouldn't be open anymore.
* Update SockJS client to v1.4.0
This fixes an issue where SockJS would parse the entire HTTP response
received as JSON, not the response's body alone.
- Tooltips work in replays now
- Calculation is better (correctly handles more corner cases)
- Explanations are better (better messages for Magic Room etc)
- Tooltips for sidebar pokemon
- Support "locking" tooltips with long-click / long-tap
- Can copy/paste from locked tooltips
- Increased font size
Unfortunately, the `loadRemoteData` trick we used to load data no
longer works. The new trick is to load asynchronously, and defer
initialization to `onload`.
We now just use JSON.parse and JSON.stringify - it's supported by all
browsers supported by the client.
Tools.safeJSON has also been moved to Storage.safeJSON, since it's not
used in replays at all.
battle.js is probably PS's oldest code. It's received minor touch-ups:
a refactor to prototypes early on, and then a refactor to TypeScript
and classes recently, but otherwise it's had basically zero maintenance
until now.
That's probably why this refactor took me over a week.
The biggest change is that the animation engine strewn around
Pokemon, Side, and Battle has been broken out into a new class named
BattleScene.
Pokemon, Side, and Battle now only track state; all animation is now
done in BattleScene and PokemonSprite.
The fates of major classes:
battle.ts:Pokemon - animation has been moved, mostly to PokemonSprite
battle.ts:Side - animation has been moved, to PokemonSprite/BattleScene
battle.ts:Battle - animation has been moved, mostly to BattleScene
Major changes:
- Many many variables have been renamed to be much clearer about what
they mean. For instance, `animationDelay` is now `timeOffset`, and
`activityDelay` is now `minWait`. A few bugs relating to me mixing
up these two variables have also been fixed. jQuery variables named
like `fooElem` have been renamed like `$foo`.
- The unnecessarily complicated queue1/queue2/activeQueue system,
previously used for telling the animation engine to stop after Pause
was pressed, has been replaced with a simple `interruptionCount`
counter.
- The entire scene can now be reconstructed from scratch, which means
that the `fastForward` system no longer needs to touch the DOM
outside of the battle log. "Prev turn" and "Skip to turn" should be
faster in 1000-turn battles now.
- The animation engine now supports displaying weather and terrain
simultaneously.
- During a replay, Team Preview is shown for a second (instead of
immediately skipping to the battle).
- Various aspects of the animation engine should be much less brittle
now.
- Many bugs were fixed (and new ones were introduced).
* Enable screen readers to automatically read incoming battle log text
* Mark sections of the battle UI with landmarks for quicker navigation with screen readers
* Allow tooltips on elements that participate in sequential keyboard navigation to have their tooltips automatically read out by screen readers when they gain focus
This also adds a cached learnset format to teambuilder-tables.js,
which replaces and is slightly smaller than learnsets.js and also
has slightly better performance.
The teambuilder is now running on search.js! Not all new features I'd
like to be in are in, but we've now reached feature parity, and most
of the bugs I found during testing have been fixed.
New in search.js is on-demand DOM loading, which basically means
much faster performance because instead of trying to load every single
row of e.g. the pokemon list at once, we just load the part that's
visible, and load the rest only when you scroll it into view.
Also new in search.js is a dexsearch-like feature, replacing the old
details-search system. The new filter system is simpler and more powerful
and has the same API as /dexsearch, although not all the more advanced
dexsearch features are supported.
On-demand DOM loading makes teambuilder loading pretty much completely
instantaneous. There are other small differences in how selection of
pokemon/items/abilities/moves works, but it should overall make more
sense.
When loading a background, we use Color Thief to get a six-color
palette from the image, for use on the main menu buttons.
Only hue and lightness are extracted.
https://github.com/lokesh/color-thief/
Backgrounds are now stored in localStorage in the current origin,
rather than the prefs origin. This allows faster loading, as well
as different backgrounds for different origins, which other
servers should like since it means their backgrounds get seen
at least once before possibly being replaced.
Special thanks to Joim for the base code.
Font Awesome 3 -> 4 was a backwards-incompatible change, so this
update is pretty invasive. I tested everything we use it for and it
still works, though. Including supporting both Font Awesome versions
in battle.js.