Commit Graph

68 Commits

Author SHA1 Message Date
Guangcong Luo
22e3609897 Teambuilder: Default nicknames to baseSpecies
Formes like Hoopa-Unbound would previously default their nickname
to "Hoopa-Unbound". Their default nicknames are now "Hoopa", matching
in-game names.

Our data structures now intentionally leave set.name blank to mean
"default nickname". Older teams are "unaffected", although Nickname
Clause makes the final nickname "Hoopa" anyway.

Fixes #92
2016-01-12 17:05:36 -05:00
Guangcong Luo
888bff7bf0 Add workaround for HTTPS blocking
Antiviruses MitMing HTTPS is just a bad idea in general...
2016-01-06 18:47:49 -05:00
Guangcong Luo
f425444906 Merge pull request #597 from sirDonovan/storage
Avoid crashes from disabled cookies
2015-12-30 16:34:50 +00:00
sirDonovan
dd24ed5489 Avoid crashes from disabled cookies
Accessing localStorage when cookies are disabled throws a SecurityError in some browsers.
2015-12-30 03:57:30 -06:00
Guangcong Luo
f6e9f1ab79 Teambuilder: Fix gen 1-2 EV selection 2015-12-29 11:33:26 -05:00
Guangcong Luo
7aaf8f3cdb Use new-size icons for team lists 2015-12-24 14:58:53 -06:00
Guangcong Luo
435b306ef9 Fix teambuilder crash in desktop client 2015-12-22 12:11:40 -05:00
Guangcong Luo
9c5596a51d Fix loading teams with folders+tiers on desktop client 2015-12-22 08:13:11 -05:00
Guangcong Luo
42ddd81c68 Teambuilder folder feature
In addition to format folders, we now support regular folders that
behave as you'd expect. These folders even map to actual
directories in the downloadable client!

Folders are delimited by `/` in team names in all storage formats
(including export, and packed saving), and are stored in the
`.folder` field of team objects.

Because of this, `/` is no longer an acceptable character in team
names. This improves interoperability with teams and filesystems,
so we should probably have done this anyway.

I also added back a friendly message to the top of the teambuilder.
2015-12-17 06:40:55 -05:00
Guangcong Luo
367314c81a Fix HTTPS support in IE11
Apparently IE11 doesn't support location.origin. I assumed it had
wider support than it actually had.
2015-12-16 01:25:07 -05:00
Guangcong Luo
cecc1b641e Center custom backgrounds
Default backgrounds are still left-aligned, mainly for Horizon and
Waterfall which are designed for their left side to be visible, but
custom backgrounds are now centered on the assumption that that's
what most users want.
2015-12-15 05:49:44 -05:00
Guangcong Luo
b9c92bae92 Wrap localStorage calls in try blocks 2015-12-13 13:29:00 -05:00
Guangcong Luo
43b77c069c Improve main menu colors for default backgrounds 2015-12-12 23:08:11 -05:00
Guangcong Luo
a038fc9631 Fix 'Default' background button for alt servers 2015-12-12 23:06:58 -05:00
Guangcong Luo
62e0723724 Fix style 2015-12-12 12:22:20 -05:00
Guangcong Luo
211da6e8b1 Major update to background storage and menu colors
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.
2015-12-12 04:01:00 -06:00
Guangcong Luo
acdd253081 Fix style issue 2015-12-11 05:06:44 -05:00
Guangcong Luo
40e88616dc Add Storage.createReplayFileHref
This splits out createReplayFile to focus on the file contents,
which could then be output elsewhere, such as for instance the
desktop client.
2015-12-11 03:10:04 -05:00
Guangcong Luo
6dfc0bdabf Fix various bugs found by eslint 2015-12-07 03:20:30 -05:00
Guangcong Luo
cea3623dac Downloadable replays!
Replays can now be downloaded into .html files.

The .html files mainly contain replay log data; the actual replay
player is downloaded online. Also included is a textual log and
some minimal CSS to make it look pretty, for offline viewing.

This strategy helps keep the replay file reasonably small; of
the 30 KB or so for a 50-turn battle, around 10 KB is the log
data, and around 20 KB is the textual log.
2015-12-07 03:19:46 -05:00
Ivo Julca
1d514bc6ec Miscellaneous style fixes for better alignment to server code style 2015-12-03 02:25:57 -05:00
Guangcong Luo
b718a335a2 News tracking 2015-11-30 02:11:27 -05:00
Guangcong Luo
05ded511e5 Fix loading when third-party cookies are blocked 2015-11-29 03:07:04 -05:00
Guangcong Luo
7fb8108393 Fix typo in team saving 2015-11-28 05:31:44 -05:00
Guangcong Luo
cf8bb24e71 Refactor data storage
Data (teams and prefs) are now always stored in localStorage in the
`https://play.pokemonshowdown.com` origin. Data storage at a low
level has been mostly rewritten for this, and moved to storage.js.

Tools.prefs has been renamed Storage.prefs, although the API
Tools.prefs(prefName) is still available, and recommended for
battle.js (because storage.js isn't available in replays). All
other pref functionality, such as setting prefs and saving prefs,
should only be used in Storage.prefs.

If the browser blocks third-party cookies in a detectable way,
data is instead stored in the local origin.

As a final safety measure, prefs/teams are mirrored in the local origin
in case third-party cookies are blocked in an undetectable way.

This refactor also replaces the 'init:loadprefs' and 'init:loadteams'
events with a new load tracking system that's basically a simplified
implementation of Promises, documented in the comments for
Tools.makeLoadTracker().
2015-11-28 04:36:41 -05:00
Guangcong Luo
68352742be Teambuilder: Support importing packed teams
Packed teams are not currently considered an officially supported
team format, but since they're now stored in localStorage for
long-term, we'll need to support them long-term, anyway.

This is currently mostly for debugging purposes.
2015-11-04 22:34:10 -05:00
Stuart Rutherford
e1d3346502 Added copy/paste support for Markdown
Adds two spaces to the end of each line generated by the teambuilder's
text output.  This makes it possible to:
    - Copy and Paste a team into a site that uses a Markdown parser such
      as Github or reddit without worrying about formatting; and
    - Copy and Paste a team from one of the aforementioned sites back
      into Showdown with no effort aside from the Ctrl-C and Ctrl-V.
2015-08-28 22:20:42 +10:00
Guangcong Luo
7f6a2063da Improve team saving reliability 2015-08-07 08:59:50 -04:00
Guangcong Luo
3622fe5a2a Improve team saving reliability
This should in theory fix the issue where team changes weren't
being saved.
2015-08-07 08:56:16 -04:00
Guangcong Luo
4dc8330635 Fix some possible team loading crashes 2015-07-24 03:18:32 -04:00
Guangcong Luo
698b413801 Revert mode changes from recent style fixes 2015-07-14 19:00:58 -04:00
Freigeist
4d242777c1 Miscellaneous style changes 2015-07-14 21:17:22 +02:00
Freigeist
87b94e7284 Fix spaces on string concatenation 2015-07-14 21:15:04 +02:00
Freigeist
993e8911ac Put spaces before anon function's opening parenthesis 2015-07-14 21:12:58 +02:00
Guangcong Luo
a9056d097b More reliable team import/export 2015-07-14 04:02:42 -04:00
Guangcong Luo
64da380c9c Fix team export/backup capitalization 2015-07-05 16:18:23 -05:00
Guangcong Luo
e1864520d9 Redesign teambuilder
- Nicer looking buttons
- Nicer layout
- Ctrl+F-able pokemon species names
2015-07-03 20:37:48 -04:00
Guangcong Luo
4aabfaf07f Fix crashes related to empty teams 2015-07-02 04:20:00 -04:00
Guangcong Luo
6c15f75c61 Update 'icons' for empty team 2015-06-30 04:18:42 -05:00
Ivo Julca
464129ce8c Safe return type ([]) for team unpacker functions 2015-06-30 04:05:36 -05:00
Ivo Julca
b3276d0290 Fix Desktop client teambuilder crash
Attempting to go to Team List after deletion of all Pokémon in a team triggered a TypeError
2015-06-30 03:59:26 -05:00
Guangcong Luo
d674dfca8d Support packed teams in desktop client 2015-06-30 03:20:29 -05:00
Ivo Julca
4106dd379d Fix crash in Storage.packTeam for some corrupted teams 2015-06-30 02:45:34 -05:00
Guangcong Luo
86820e79a0 Minor grammatical fix to a comment 2015-06-30 02:25:01 -05:00
Guangcong Luo
84be1cd2f2 Teambuilder: more reliable team saving 2015-06-30 02:24:50 -05:00
Guangcong Luo
bbc2188a40 Refactor teambuilder to use packed teams
This is a major refactor that changes the teambuilder to store
teams in packed format whenever possible, for approximately 50%
less memory usage for team storage.

The only visible change here is that pokemon nicknames have been
replaced with pokemon icons in the teambuilder team list, to
match the team selector in the main menu, which simplifies
extracting information from packed teams.
2015-06-30 02:16:55 -05:00
Guangcong Luo
d41b7329b3 Show popup error for corrupt teams 2015-06-30 02:06:24 -05:00
Guangcong Luo
cc7af41bd5 Refactor Storage not to use _Storage class 2015-06-30 02:06:24 -05:00
Guangcong Luo
2a6a2667a7 Move team import/export functions to storage.js
This refactor moves:

TeambuilderRoom.parseText -> Storage.importTeam
TeambuileerRoom.toText -> Storage.exportTeam
TeambuilderRoom.teamsToText -> Storage.exportAllTeams
2015-06-29 17:17:51 -05:00
Guangcong Luo
69a27e1843 Desktop: Fix chat log timestapms 2015-01-31 22:41:40 -05:00