Compare commits

..

190 Commits

Author SHA1 Message Date
kuutekitty 625a0ec5ec add kuutekitty to donations.md (#89712) 2026-11-22 12:57:25 -08:00
Maya Granade 6b79ead016 JSON linter gh-pages file update (#87466)
Co-authored-by: harakka <2456481+harakka@users.noreply.github.com>
2026-08-06 10:55:40 -07:00
ergolyam f2504649e9 [+] add flathub download link (#87667) 2026-06-20 09:20:34 -07:00
Maya Granade b4326d972d Update head.html 2026-06-03 12:51:48 -07:00
gettingusedto 2f23974f81 Update donations.md (#83821) 2025-11-19 18:31:05 -08:00
SittingDucken 26c4be927a Initial twison build. (#81587) 2025-07-28 21:58:31 -07:00
Kevin Granade 87baa3cc79 Add link to reactivated subreddit 2025-07-16 15:35:37 -07:00
Kevin Granade 189354b8e9 Remove release enumeration from releases page
This was exceeding the GitHub "list releases" API limit of 10,000 release entries and causing the page rebuild to fail.
2025-04-03 10:14:11 -07:00
Kevin Granade 345c1c0d27 Remove enumeration of releases from experimental releases page
This was exceeding the "list releases" API limit of 10,000 release entries and failing to build the page.
2025-04-03 10:00:33 -07:00
Kevin Granade c98ee8dbef Remove outdated comment about msvc builds 2025-03-17 10:46:45 -07:00
Kevin Granade 6b2ab31824 JSON linter gh-pages file update (#78086)
Co-authored-by: kevingranade <kevingranade@users.noreply.github.com>
2024-12-19 08:43:58 -08:00
Kevin Granade 31ad94a1ee add crosslink to project organization doc 2024-11-23 00:44:18 -08:00
Kevin Granade 33f71fa042 Update org.flathub.VerifiedApps.txt 2024-11-04 18:45:11 -08:00
Kevin Granade 8e35b4dd35 include the .well-known folder
For flathub verification
2024-11-04 18:18:19 -08:00
Kevin Granade 47de02a172 Create org.flathub.VerifiedApps.txt for app verification 2024-11-04 14:18:01 -08:00
Kevin Granade 256f1a99de JSON linter gh-pages file update (#71354)
Co-authored-by: Maleclypse <Maleclypse@users.noreply.github.com>
2024-03-14 15:18:48 -07:00
Antti Riikonen 1361276e1a Remove mention of lemmy (#72097)
Remove Lemmy mention
2024-03-04 11:03:01 -08:00
Kevin Granade 54a996a989 JSON linter gh-pages file update (#68707)
Co-authored-by: Maleclypse <Maleclypse@users.noreply.github.com>
2023-11-04 14:29:37 -07:00
Zhilkin Serg d13493e7fe Privacy policy update (#69039)
* Privay policy update

* add header

---------

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>
2023-10-31 12:08:03 -07:00
Kevin Granade d1f3bd9938 JSON linter gh-pages file update (#67630)
Co-authored-by: Maleclypse <Maleclypse@users.noreply.github.com>
2023-08-27 18:26:06 -07:00
Dillon Matchett cb164a8236 Added Community Discord To Website (#67428)
* Added Community Discord

* fixed steam link
2023-08-03 23:07:33 -07:00
Dillon Matchett 88a9b6ce7b Updated index removed all developer facing pages (#66475) 2023-06-27 08:12:54 -07:00
Antti Riikonen 97b6d7e4cf Update hhg url (#64549) 2023-05-06 09:53:13 -07:00
taatu cf3250e11b fix broken anchor references (#64814) 2023-04-05 17:51:41 -07:00
I-am-Erk d1cf4fcf61 Create steam_faq.md (#64439)
* Create steam_faq.md

* Update steam_faq.md

* Update steam_faq.md

* Update index.md

* Update index.md

* Update steam_faq.md

Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>

* Update steam_faq.md

---------

Co-authored-by: andrei <68240139+andrei8l@users.noreply.github.com>
2023-03-21 13:13:17 -07:00
Antti Riikonen afd99f6ec0 Remove Bountysource and Chezzo links, move hhg up (#64020) 2023-03-06 23:27:49 -08:00
Kevin Granade fcfe75b906 Merge pull request #63703 from John-Candlebury/gh-pages-donationlink
Add my Patreon to the donations page
2023-02-22 10:49:38 -08:00
John Candlebury 17d955042f Add my info to the donations page 2023-02-20 17:40:40 -06:00
NetSysFire 1a72165a2c Hint about other files on the lore page (#60899) 2023-01-12 07:14:46 -08:00
Kevin Granade 834754b3a3 Merge pull request #62080 from irwiss/explain-msvc
Provide hint for msvc build tag on downloads page
2022-12-23 21:01:47 -08:00
Alexey Kim 160bd243a6 Provide hint for msvc build tag 2022-11-04 20:26:18 +02:00
NetSysFire ba6c7353d9 Some typo and grammar fixes (#57880) 2022-07-03 19:03:44 -07:00
Kevin Granade 90c1b7b5c1 Prune the defunct game launcher from the front page 2022-04-03 15:49:14 -07:00
NetSysFire b83267d257 Update IRC stuff (#55439) 2022-03-08 09:52:47 -08:00
I-am-Erk c9915d2b0b Design doc updates (#54074)
* in progress changes to lore docs

* adjust gameplay doc a bit

* touch up background document
2022-01-05 16:42:02 -08:00
I-am-Erk bb38735679 split up the design doc 2022-01-05 10:19:36 -08:00
Kevin Granade 1f2ba5df16 tpyo 2022-01-04 11:32:52 -08:00
Zhilkin Serg 04850d017f Create privacy.md (#52607) 2021-11-02 14:34:22 -07:00
I-am-Erk ac04d717af Update lore-factions.md 2021-10-28 11:26:23 -07:00
I-am-Erk ddbb41e71a Update lore-factions.md 2021-10-28 11:24:32 -07:00
I-am-Erk 856e285427 Update technology.md 2021-10-28 11:14:19 -07:00
I-am-Erk 3d0816a284 Update technology.md 2021-10-28 10:17:53 -07:00
I-am-Erk c1d8ec0cd2 Update design-doc.md 2021-10-28 10:05:29 -07:00
I-am-Erk dc817bf2b9 format fixes 2021-10-28 09:54:49 -07:00
I-am-Erk 9452acb749 Update lore-factions.md 2021-10-28 09:51:05 -07:00
I-am-Erk c850ae3aea Update lore-factions.md 2021-10-28 09:49:13 -07:00
I-am-Erk 7e43f1bfbf Update lore-factions.md 2021-10-28 09:45:56 -07:00
I-am-Erk d0f8c7c6a9 Update lore-factions.md 2021-10-28 09:19:40 -07:00
I-am-Erk 1e3420aa8f Update lore-factions.md 2021-10-28 09:08:13 -07:00
I-am-Erk 62185ef48b Update lore-factions.md 2021-10-28 09:06:25 -07:00
Kevin Granade e851085b9b correcting some misleading phrasing 2021-10-28 08:55:44 -07:00
I-am-Erk 748a5ed5b5 Update design-balance.md 2021-10-27 15:17:26 -07:00
I-am-Erk 4b62a06af9 Update design-balance.md 2021-10-27 15:16:31 -07:00
I-am-Erk f191347e05 Update design-balance.md 2021-10-27 15:10:54 -07:00
I-am-Erk a195028061 Update design-balance.md 2021-10-27 15:01:57 -07:00
I-am-Erk 72ccb94cba Update design-balance.md 2021-10-27 14:47:28 -07:00
I-am-Erk 53541e8e38 Update design-balance.md 2021-10-27 13:54:23 -07:00
I-am-Erk 40d1691b40 Update design-balance.md 2021-10-27 12:31:26 -07:00
I-am-Erk d38c685772 add design-balance
based on kevingranade balance draft, expanded
2021-10-27 12:29:29 -07:00
I-am-Erk b56181e59f Update lore-factions.md 2021-10-27 11:36:51 -07:00
I-am-Erk 8496a93690 Update lore-factions.md 2021-10-27 10:55:37 -07:00
I-am-Erk 3984f0197f Update design-doc.md 2021-10-27 10:30:34 -07:00
I-am-Erk 73827b40c8 Update lore-factions.md 2021-10-27 10:25:55 -07:00
I-am-Erk 42e34087fc Update lore-factions.md 2021-10-26 15:58:42 -07:00
I-am-Erk 7292ac7b92 Update lore-factions.md 2021-10-26 13:09:15 -07:00
I-am-Erk 931236ec82 Update lore-factions.md 2021-10-26 13:03:07 -07:00
I-am-Erk d25a043958 Update lore-factions.md 2021-10-26 13:02:47 -07:00
I-am-Erk 8c2f5c109a add lore-factions.md
Not too much new info here yet.
2021-10-26 12:53:14 -07:00
I-am-Erk f2834c0079 remove factions from design doc main 2021-10-26 12:52:45 -07:00
Kevin Granade 487a686c9a Remove lore note we haven't been following 2021-09-24 10:32:33 -07:00
Alexey Mostovoy 5f8eb8d704 Small tweaks to gh-pages service files (#51469)
* Update .gitignore

Include the directory and file name used to serve the site locally

* Update _config.yml

Deprecated `gems`: `plugins` config key is a replacement for `gems`

* Update .gitignore and sync with master
2021-09-13 15:49:59 -07:00
Alexey Mostovoy 8ee5a039d9 Add showcase image (Ultica tileset) (#51468)
Add showcase image to home page
https://github.com/I-am-Erk/CDDA-Tilesets
2021-09-13 15:49:23 -07:00
I-am-Erk 6f62316525 Update design-doc.md
wip
2021-09-10 12:42:00 -07:00
I-am-Erk e86adb7b4a Update technology.md 2021-09-10 12:41:37 -07:00
casswedson bc139be5ac Fix typos in design-doc.md (#49554)
* fix typos
Co-authored-by: actual-nh <74678550+actual-nh@users.noreply.github.com>
2021-07-06 16:54:59 -07:00
halosammy 89606d54f1 Update lore-background.md (#49553)
Capitalization
2021-07-06 11:21:45 -07:00
Zhilkin Serg afaeab92a6 Just wanna rebuild releases page (#49505) 2021-07-01 08:53:34 -07:00
Kevin Granade e2a81e3626 Enhance distinction between first party and third party resources
Also added HHGTTC, and removed reddit as I no longer consider it productive to send users there.
2021-05-28 11:37:56 -07:00
Kevin Granade 80c519df6b Update IRC channel reference to point to Libera 2021-05-26 12:20:00 -07:00
Zhilkin Serg 85b70b1bef Fix missing line break (#48439)
... and also bring OMG release down
2021-04-08 23:23:26 -07:00
Kevin Granade 10c7b24130 Create CNAME 2021-03-21 15:29:35 -07:00
Kevin Granade 725700952e Delete CNAME 2021-03-21 15:29:26 -07:00
Kevin Granade 386d664d2f Update index.md 2020-11-09 13:41:58 -08:00
Kevin Granade d17b905747 Update code style blurb 2020-10-14 19:38:27 -07:00
Kevin Granade f6d198b4fb Clarify build availablility. 2020-10-14 19:33:47 -07:00
gemsys 5e81da6827 Improve grammar and fix typos in the website 2020-10-15 02:27:53 +00:00
I-am-Erk 8c6b82564a Update technology.md 2020-06-01 12:12:12 -07:00
I-am-Erk dd72f62e06 Update technology.md 2020-06-01 12:02:16 -07:00
I-am-Erk 90dd579372 Update technology.md 2020-06-01 11:54:18 -07:00
I-am-Erk c3c77d79ed Update technology.md 2020-06-01 11:53:33 -07:00
I-am-Erk 128d69039e Update technology.md 2020-06-01 11:41:26 -07:00
I-am-Erk 668ca4d4d5 Update lore-background.md 2020-06-01 11:35:46 -07:00
I-am-Erk 33e7dc1b04 Update lore-background.md 2020-06-01 11:22:44 -07:00
I-am-Erk 856b06a9d7 Update lore-background.md 2020-06-01 11:20:12 -07:00
I-am-Erk 6a95b78584 Update lore-background.md 2020-06-01 10:46:47 -07:00
I-am-Erk b5631470ad Remove CBMs, tighten up timeline, add spoiler. 2020-06-01 10:46:37 -07:00
I-am-Erk 757e29b223 Update technology.md 2020-06-01 10:28:58 -07:00
I-am-Erk 6e17b80cd2 Update technology.md 2020-06-01 10:28:45 -07:00
I-am-Erk d9e8b3bb17 add spoiler alerts. 2020-06-01 10:20:34 -07:00
ZhilkinSerg 3889ef8d11 Update CDDA description on homepage (#40945) 2020-05-31 07:10:42 +00:00
I-am-Erk 9d16ab056b Update technology.md 2020-05-29 10:38:03 -07:00
Kevin Granade 339b665712 Remove dead links
The target pages are unfortunately gone now, so no reason to keep them around.
2020-05-21 14:56:36 -07:00
snipercup 71c2f0acf9 Remove snipercup from donations page 2020-05-21 14:48:55 -07:00
Isaac Freund 6c79e7fb41 Trigger rebuild 2020-05-20 16:18:15 +02:00
Isaac Freund 98220d224f Trigger rebuild to remove 0.C download links 2020-05-08 13:49:52 +02:00
Isaac Freund c57923f1a9 Trigger one more rebuild 2020-04-01 14:51:01 +02:00
Isaac Freund 13beb3e0f4 Trigger rebuild 2020-04-01 14:34:46 +02:00
Isaac Freund c5e612a48b Add script for simple local testing with docker 2020-02-21 06:50:23 +00:00
Isaac Freund 14cd8db985 Create packaging status page on website (#37855)
This information was quite hidden at the bottom of the releases page.
2020-02-09 07:58:18 -08:00
Isaac Freund 194c87c271 Merge pull request #37834 from reinerh/gh-pages
Add Debian/Ubuntu install instructions to releases page
2020-02-09 12:02:43 +01:00
Reiner Herrmann d5478c5d26 Add Debian/Ubuntu install instructions to releases page 2020-02-08 14:46:06 +01:00
I-am-Erk ffd16169a8 Update lore-background.md 2020-01-30 17:33:05 -08:00
I-am-Erk 69321de26f Update lore-background.md 2020-01-30 17:27:10 -08:00
snipercup 2608758799 Explain the difference between tiles and curses on release page (#37433)
* Explain the difference between tiles and curses

* Revert "Explain the difference between tiles and curses"

This reverts commit 6f83dcb738.

* Explain the difference between tiles and curses

* Update releases.md

Co-Authored-By: Alexey Mostovoy <1931904+AMurkin@users.noreply.github.com>

* Update releases.md

Co-authored-by: Alexey Mostovoy <1931904+AMurkin@users.noreply.github.com>
2020-01-29 21:39:04 -08:00
Kevin Granade 1d2f7bff6b Fix a typo 2020-01-23 12:32:44 -08:00
Artem Polishchuk b7eb63e481 Add packaging status to Release page (#36143) 2019-12-16 19:20:18 +00:00
I-am-Erk c9efd9e07d Update design-doc.md 2019-11-29 18:11:15 -08:00
I-am-Erk 2fbb555d1f Add a section on mi-go 2019-11-27 22:06:41 -08:00
I-am-Erk d05bb314c6 Add info about mutations 2019-11-15 18:27:54 -08:00
snipercup a8202034ed Add contributor to donations page (#35317) 2019-11-04 18:25:42 -08:00
Curtis Merrill a072ef1ac8 add Donations tab and add extra return (#35149) 2019-10-29 17:36:52 -07:00
Curtis Merrill c779eaa368 Create initial donations page (#35036) 2019-10-27 12:03:25 -07:00
Kevin Granade e252913a04 Add link to discord server 2019-07-13 12:10:45 -07:00
I-am-Erk a7a4b27974 Update technology.md 2019-07-08 14:31:54 -07:00
I-am-Erk db309cab30 Update technology.md 2019-07-08 14:11:05 -07:00
I-am-Erk 44eb59a505 prosthetics 2019-07-08 14:07:14 -07:00
I-am-Erk dedf57fac0 Update technology.md 2019-07-08 13:44:05 -07:00
I-am-Erk e398f9bafd Comment on dimensions 2019-07-08 13:33:40 -07:00
I-am-Erk 979b06b3d7 Update technology.md 2019-07-08 13:18:52 -07:00
I-am-Erk 764717a692 add links to technology doc that were missed. 2019-07-08 13:16:56 -07:00
Kevin Granade 955ddf5a68 Remove a link to a compromised page 2019-07-07 15:10:40 -07:00
I-am-Erk c11694c8f5 Continue technology.md 2019-05-22 11:38:22 -07:00
I-am-Erk 71c137cb7b Create technology.md 2019-05-22 11:18:00 -07:00
I-am-Erk 236a8eaf2b Alien fuel cells, not alien robots 2019-05-22 09:21:00 -07:00
I-am-Erk 11584605aa More power cell stuff 2019-05-22 08:47:12 -07:00
I-am-Erk 7ba6ddd36c Update lore-background.md 2019-05-22 08:34:23 -07:00
Kevin Granade 1919ec2d1f More mutation notes 2019-05-14 20:18:59 -07:00
Kevin Granade 4e0431a322 Notes about clothes bionics and mutagen 2019-05-14 18:13:18 -07:00
I-am-Erk 32dfe1835c hyperlink 2019-05-14 16:01:17 -07:00
I-am-Erk 39c70d5215 Update design-doc.md 2019-05-14 13:59:59 -07:00
I-am-Erk 53f46d6cbc Expand timeline of Year 0 2019-05-11 22:35:10 -07:00
I-am-Erk cac6b77701 Create a file for the timeline and background info
It's too crowded in the main design doc.
2019-05-11 13:06:46 -07:00
I-am-Erk 10a53e345e Remove timeline from master design doc
It's crowded in there.
2019-05-11 13:06:20 -07:00
Isaac Freund 858cb2c70c Merge pull request #30407 from AMurkin/patch-1
Design Document - minor style change
2019-05-11 12:54:08 +02:00
Alexey Mostovoy 55917f29ee Update design-doc.md 2019-05-11 14:11:39 +04:00
Isaac Freund 8e298bf3c8 Fix build list on experimental page
Trying to display all releases seems to cause issues with only ~15 loading, so make a counter
and only display the most recent 10 releases for which at least one artifact was generated
2019-05-10 11:21:45 +02:00
Isaac Freund 2cd7f3b231 Add experimental builds page
- Edit build descriptions and links on Home and Releases pages
 - Only list experimental builds that were successful (have artifacts)
2019-05-02 15:21:48 -07:00
Isaac Freund df8b9c496b Hide changes page in header
- The changes page currently is blank, as the github-metadat api doesn't seem to give us access
   to the pull requests or commits and I haven't found a way around this yet.
2019-05-02 23:15:38 +02:00
Isaac Freund 26ed97b25e Remove prerelease builds from releases page 2019-05-02 23:09:51 +02:00
Isaac Freund 89b144fe69 Fix typo 2019-05-02 22:53:25 +02:00
Kevin Granade 7a090660f0 Added note about factions. 2019-05-01 21:04:25 -07:00
Kevin Granade 1b864a9a90 Moved overview sections to top 2019-05-01 20:31:45 -07:00
Kevin Granade f302db99fd Added more notes about vehicles 2019-05-01 20:09:19 -07:00
Kevin Granade aa71c25eee Add note about structures 2019-05-01 19:20:52 -07:00
Kevin Granade 8ddb42e3b7 add some notes about scavenging and crafting 2019-05-01 17:45:35 -07:00
Isaac Freund 3d3b660f35 Add download links to release list
- tweak formatting
 - add version tags
2019-04-21 18:53:40 +02:00
Isaac Freund b648d80e52 Merge pull request #29795 from KorGgenT/gh-pages-update
Gh pages update
2019-04-21 18:19:38 +02:00
Isaac Freund aa744bfc9d Use github-metadata api for links and release name 2019-04-21 18:17:24 +02:00
KorGgenT 157c2f3ebc update releases page
before it recommended experimental, which we do not necessarily want to encourage.
2019-04-21 11:20:56 -04:00
KorGgenT 0277830d44 Update .gitignore
add the .gitignore from master to this gitignore
2019-04-21 11:12:33 -04:00
Isaac Freund 4478b07e9c Add GitHub link to header
- correct github reference on contributions page
2019-04-18 02:12:14 +02:00
Isaac Freund 9fbd2684e8 Fix table of contents formatting 2019-04-18 01:35:51 +02:00
Isaac Freund ad69d1bbbe Clean up header
- Hardcode and reword links in header
 - Standardize urls
 - Fix minor formatting erro on contributions page
2019-04-18 01:28:51 +02:00
I-am-Erk c83d72ee59 Add Timeline (incomplete) 2019-04-04 21:34:06 -07:00
Isaac Freund 079f0e3cbc Standardize spelling and fix minor formatting errors 2019-04-05 05:02:26 +02:00
Kevin Granade 6d26f077ca Update header 2019-04-04 18:22:25 -07:00
Kevin Granade 884582f056 Drop the design doc draft 2019-04-04 18:19:20 -07:00
Kevin Granade dc01a8cb0b Added link to Android build. 2019-03-22 06:56:06 +00:00
Kevin Granade 843e548735 update wiki link
Fixes #28848
2019-03-20 21:53:17 -07:00
Kevin Granade 3f8605b480 rebuild pages 2019-03-08 08:00:43 +00:00
Kevin Granade fb5597ecc2 remove adsense stub. 2019-01-01 11:53:22 -06:00
Kevin Granade c0f9e865bd Add addsense resources 2018-12-29 20:49:36 -06:00
Kevin Granade c406d589a4 Revert head.html version to minima 2.0 2018-12-29 20:47:40 -06:00
Kevin Granade 2ca266e1f2 Import head.html from minima to override it 2018-12-29 20:38:32 -06:00
Kevin Granade 0ed563b102 Remove discord link.
Removing due to poor moderation practices.
2018-11-12 11:27:23 -08:00
Kevin Granade 114c25454b De-emphisize the sentence transitioning to releases. 2018-05-24 10:32:31 -07:00
Kevin Granade eedabd57c2 Add download links for latest builds to releases page.
This seems like a point of confusion, and encourages people to seek out 0.C instead of playing the latest experimental, which is a tragedy.
2018-05-24 10:30:43 -07:00
Kevin Granade 07b6f36115 Update links to use https where possible, including migrating urls to discourse site. (#23053) 2018-02-25 11:49:15 -08:00
Leland Clemmons f87bf17412 Move Linux downloads links to 64bit versions
We're not building 32 bit ones anymore
2018-01-31 20:07:47 -08:00
Kevin Granade 877552c3a4 Add FAQ entry for bountysource.
Addresses #22385
2018-01-03 11:58:19 -06:00
Kevin Granade 07fcf7d196 Point forums link at new discourse site. 2017-11-15 13:26:30 -08:00
Kevin Granade dff69f7269 Moved community resources higher on page. 2017-09-28 02:46:15 +00:00
Kevin Granade 9654131119 Create CNAME 2017-09-24 18:03:23 +00:00
Kevin Granade ff4619146e Add changes page. 2017-06-08 06:44:29 +00:00
Miguel Melon Otero 0e366475a3 Corriged typo (#20979) 2017-05-09 11:55:06 -07:00
Kevin Granade b420f16e3c Added link to game launcher. 2017-05-02 10:11:23 -07:00
Kevin Granade 2d50f82c1b Several minor changes to site main page.
Expanded System Requirements section.
Corrected outdated link text.
Added link to issue guidelines page.
2017-05-01 18:02:22 -07:00
Kevin Granade 7e99570f41 Import contribution guide from game source tree. 2017-04-28 06:11:33 +00:00
Kevin Granade 51f537e2fc First draft of GitHub Pages site for Ctaclysm: Dark Days Ahead. 2017-03-22 04:32:21 +00:00
Kevin Granade 6e566bb0dd Remove game content from pages branch. 2017-03-22 04:31:25 +00:00
4942 changed files with 1332 additions and 8635537 deletions
-28
View File
@@ -1,28 +0,0 @@
version: '{branch}.{build}'
image: Visual Studio 2019
configuration: Release
platform: x86
shallow_clone: true
clone_folder: C:\Projects\Cataclysm-DDA
cache:
- c:\tools\vcpkg\installed
- c:\Users\appveyor\AppData\Local\vcpkg\
install:
- cmd: cd c:\tools\vcpkg\
- cmd: git pull
- cmd: bootstrap-vcpkg.bat -disableMetrics
- cmd: vcpkg --triplet %PLATFORM%-windows-static install sdl2 sdl2-image sdl2-mixer[dynamic-load,libflac,mpg123,libmodplug,libvorbis] sdl2-ttf gettext --recurse
build:
project: /msvc-full-features/Cataclysm-vcpkg-static.sln
parallel: true
verbosity: minimal
only_commits:
files:
- '.appveyor.yml'
- 'msvc-full-features/**'
- 'src/**'
- 'tests/**'
branches:
only:
- master
-51
View File
@@ -1,51 +0,0 @@
# These options are mirrored in .astylerc and doc/CODE_STYLE.txt
# "One True Brace Style"
--style=1tbs
# Attach brackets to class and struct inline function definitions.
--attach-inlines
# 4 spaces per indentation level and per tab stop
--indent=spaces=4
# 'char *foo' instead of 'char* foo'
--align-pointer=name
# maximum length for a single unbroken line
--max-code-length=100
# 'foo ||\nbar' instead of 'foo\n|| bar'
--break-after-logical
# indent 'public:' 'protected:' 'private:' deeper than 'class' or 'struct'
--indent-classes
# indent 'case' lines deeper than 'switch'
--indent-switches
# indent later lines of multi-line preprocessor directives
# to be deprecated by --indent-preproc-define
--indent-preprocessor
# indent comments on column 1 to match the code block they are in
--indent-col1-comments
# indent multi-line control block headers like 'if (foo\nbar)'
--min-conditional-indent=0
# add space around operators with two operands
--pad-oper
# add brackets to unbracketed one line conditional statements
--add-brackets
# replaces tabs with spaces in non-indent sections, except in strings
--convert-tabs
# remove extra space padding around parentheses
--unpad-paren
# insert space padding around parentheses on the inside only
--pad-paren-in
-62
View File
@@ -1,62 +0,0 @@
# Enable some categories of checks and then disable individual ones.
# The disabled checks that appear as part of the initial alphabetical section
# enabling categories (e.g. cert-err58-cpp) are ones that do not make sense for
# this codebase and we do not intend to fix. The disabled checks appearing
# thereafter in a separate alphabetical list have yet to be triaged. We may
# fix their errors or recategorise them as checks we don't care about.
Checks: "\
bugprone-*,\
cata-*,\
cert-*,\
-cert-dcl21-cpp,\
-cert-env33-c,\
-cert-err58-cpp,\
clang-diagnostic-*,\
cppcoreguidelines-slicing,\
google-explicit-constructor,\
llvm-namespace-comment,\
misc-*,\
modernize-*,\
-modernize-use-auto,\
-modernize-use-trailing-return-type,\
performance-*,\
readability-*,\
-bugprone-misplaced-widening-cast,\
-bugprone-narrowing-conversions,\
-bugprone-unused-return-value,\
-cert-err34-c,\
-cert-flp30-c,\
-cert-msc30-c,\
-cert-msc32-c,\
-cert-msc50-cpp,\
-cert-msc51-cpp,\
-misc-non-private-member-variables-in-classes,\
-modernize-avoid-c-arrays,\
-modernize-pass-by-value,\
-modernize-return-braced-init-list,\
-modernize-use-default-member-init,\
-modernize-use-emplace,\
-performance-inefficient-vector-operation,\
-performance-noexcept-move-constructor,\
-performance-implicit-conversion-in-loop,\
-performance-inefficient-string-concatenation,\
-performance-type-promotion-in-math-fn,\
-performance-unnecessary-value-param,\
-readability-braces-around-statements,\
-readability-else-after-return,\
-readability-function-size,\
-readability-implicit-bool-conversion,\
-readability-isolate-declaration,\
-readability-magic-numbers,\
-readability-named-parameter,\
"
WarningsAsErrors: '*'
HeaderFilterRegex: '(src|test|tools).*'
FormatStyle: none
CheckOptions:
- key: readability-uppercase-literal-suffix.NewSuffixes
value: 'L;UL;LL;ULL'
- key: cata-text-style.EscapeUnicode
value: 0
# vim:tw=0
-43
View File
@@ -1,43 +0,0 @@
# options affecting formatting
format:
# how wide to allow formatted cmake files
line_width: 100
# how many spaces to tab for indent
tab_size: 4
# if true, separate flow control names from their parentheses
separate_ctrl_name_with_space: true # currently ignored by cmake-lint
# if true, separate function names from parentheses with a
separate_fn_name_with_space: false # currently ignored by cmake-lint
# if a statement is wrapped to more than one line, than dangle
# the closing parenthesis on its own line.
dangle_parens: false # currently ignored by cmake-lint
# Format command names consistently as 'lower' or 'upper' case
# 'canonical': like in official documentation
command_case: 'canonical' # currently ignored by cmake-lint
# Format keywords consistently as 'lower' or 'upper' case
keyword_case: 'upper' # currently ignored by cmake-lint
# options affecting comment reflow and formatting
markup:
# enable comment markup parsing and reflow
enable_markup: false
# options affecting linter
lint:
# list of lint codes to disable
# C0113: Missing COMMENT in statement which allows it
disabled_codes: ['C0113']
# regular expression pattern describing valid function names
function_pattern: '[a-z_]+'
# regular expression pattern describing valid names for private variables
# WEIRD: strangely named "directory variable name" in lint output
private_var_pattern: '_[0-9A-Z_]+'
# regular expression pattern describing valid names for public variables (strangely named "directories"?)
# WEIRD: strangely named "directory variable name" in lint output
public_var_pattern: '[0-9A-Z]+'
# regular expression pattern describing valid macro names
macro_pattern: '[a-z_]+'
# regular expression pattern describing valid names for function/macro
# arguments and loop variables
argument_var_pattern: '[A-Z][A-Z0-9_]+'
# require no more than this many newlines between statements
max_statement_spacing: 2
-17
View File
@@ -1,17 +0,0 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
[*.json]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
-11
View File
@@ -1,11 +0,0 @@
[flake8]
exclude = .git,__pycache__,lang/json
ignore =
# E265 forces comments to have a space after the '#'. We have a bunch of
# optional debugging code commented out this way, and not having a space is
# a convenient way to distinguish it from proper comments. Maybe we should
# delete that code, but unless that happens leaving E265 disabled.
E265,
# W503 and W504 require line breaks after or before binary operators; you
# can only have one enabled
W504
-39
View File
@@ -1,39 +0,0 @@
# Automatically normalize line endings for all files
# detected as text (Convert CRLF => LF).
* text=auto
# Explicitly normalize files with these extensions in
# case Git doesn't detect them as text for some reason.
*.c text
*.cbp text
*.cpp text
*.h text
*.json text
*.md text
*.py text
*.rc text
*.sh text
*.txt text
*.yml text
# Visual Studio project files, leave them alone.
*.cmd -text
*.filters -text
*.sln -text
*.user -text
*.vcxproj -text
# Generated translation text, don't mess with them.
*.mo -text
*.po -text
*.pot -text
# Treat images, archives, and font files as binary.
# (binary is a macro for -text -diff)
*.db binary
*.fon binary
*.gz binary
*.ico binary
*.png binary
*.ttf binary
-31
View File
@@ -1,31 +0,0 @@
#Note that despite github calling these "owners", a better term would be "alerts"
#Everything in the cataclysm repository remains under a creative commons license, nobody owns the mods.
#In fact, the code "owners" designation is meant to encourage third party
#individuals to contribute to the mod, with the curators notified for reviews.
/data/mods/Aftershock/ @Maleclypse @John-Candlebury @Mom-Bun
/data/mods/DinoMod/ @ephemeralstoryteller @damien @LyleSY
/data/mods/Graphical_Overmap/ @Kilvoctu @Larwck
/data/mods/MMA/ @Hymore246
/data/mods/No_Fungi/ @I-am-Erk
/data/mods/blazemod/ @SouP
/data/mods/classic_zombies/ @I-am-Erk
/data/mods/crt_expansion/ @Soupster89
/data/mods/desertpack/ @davidpwbrown
/data/mods/generic_guns/ @tenmillimaster
/data/mods/Magiclysm/ @KorGgenT
/data/mods/My_Sweet_Cataclysm/ @Fris0uman
/data/mods/ruralbiome/ @I-am-Erk
/data/mods/speedydex/ @KorGgenT
/data/mods/stats_through_kills/ @KorGgenT
/data/mods/Dark-Skies-Above/ @ephemeralstoryteller
magic*.cpp @KorGgenT
magic*.h @KorGgenT
/data/json/itemgroups/SUS/ @I-am-Erk
/data/json/npcs/refugee_center/ @I-am-Erk
/data/json/npcs/Backgrounds/ @I-am-Erk
/data/json/snippets/ @I-am-Erk
/gfx/ @I-am-Erk
/tools/ @int-ua
/lang/ @BrettDong
-325
View File
@@ -1,325 +0,0 @@
# Contribute
**Opening a new issue?** Please read [ISSUES.md](../ISSUES.md) first.
Contributing to Cataclysm: Dark Days Ahead is easy — simply fork the repository here on GitHub, make your changes, and then send us a pull request.
Cataclysm:Dark Days Ahead is released under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
This means any contribution you make to the project will also be covered by the same license, and this license is irrevocable.
## Guidelines
There are a couple of guidelines we suggest sticking to:
* Add this repository as an `upstream` remote.
* Keep your `master` branch clean. This means you can easily pull changes made to this repository into yours.
* Create a new branch for each new feature or set of related bug fixes.
* Never merge from your local branches into your `master` branch. Only update that by pulling from `upstream/master`.
## Code Style
Code style is enforced across the codebase by `astyle`.
See [CODE_STYLE](../doc/CODE_STYLE.md) for details.
## Translations
The translation of Cataclysm: DDA is done using Transifex.
Look at the [translation project](https://www.transifex.com/cataclysm-dda-translators/cataclysm-dda/) for an up-to-date list of supported languages.
See [TRANSLATING](../doc/TRANSLATING.md) for more information:
* [For translators](../doc/TRANSLATING.md#translators)
* [For developers](../doc/TRANSLATING.md#developers)
* [For maintainers](../doc/TRANSLATING.md#maintainers)
## Doxygen Comments
Extensive documentation of classes and class members will make the code more readable to new contributors. New doxygen comments for existing classes are a welcomed contribution.
Use the following template for commenting classes:
```c++
/**
* Brief description
*
* Lengthy description with many words. (optional)
*/
class foo {
```
Use the following template for commenting functions:
```c++
/**
* Brief description
*
* Lengthy description with many words. (optional)
* @param param1 Description of param1 (optional)
* @return Description of return (optional)
*/
int foo(int param1);
```
Use the following template for commenting member variables:
```c++
/** Brief description **/
int foo;
```
Helpful pages:
* [Doxygen Manual - Special Commands](https://www.doxygen.nl/manual/commands.html)
* [Doxygen Manual - Standard Markdown](https://www.doxygen.nl/manual/markdown.html#markdown_std)
* [Doxygen Manual - Frequently Asked Questions](https://www.doxygen.nl/manual/faq.html)
### Guidelines for adding documentation
* Doxygen comments should describe behavior towards the outside, not implementation, but since many classes in Cataclysm are intertwined, it's often necessary to describe implementation.
* Describe things that aren't obvious to newcomers just from the name.
* Don't describe redundantly: `/** Map **/; map* map;` is not a helpful comment.
* When documenting X, describe how X interacts with other components, not just what X itself does.
### Building the documentation for viewing it locally
* Install doxygen
* `doxygen doxygen_doc/doxygen_conf.txt `
* `firefox doxygen_doc/html/index.html` (replace firefox with your browser of choice)
## Example Workflow
#### Setup your environment
*(This only needs to be done once.)*
1. Fork this repository here on GitHub.
2. Clone your fork locally.
$ git clone https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
# Clones your fork of the repository into the current directory in terminal
3. Set commit message template.
$ git config --local commit.template .gitmessage
4. Add this repository as a remote.
$ cd Cataclysm-DDA
# Changes the active directory in the prompt to the newly cloned "Cataclysm-DDA" directory
$ git remote add -f upstream https://github.com/CleverRaven/Cataclysm-DDA.git
# Assigns the original repository to a remote called "upstream"
For further details about commit message guidelines please visit:
- [codeinthehole.com](https://codeinthehole.com/tips/a-useful-template-for-commit-messages/)
- [chris.beams.io](https://chris.beams.io/posts/git-commit/)
- [help.github.com](https://help.github.com/articles/closing-issues-using-keywords/)
#### Update your `master` branch
1. Make sure you have your `master` branch checked out.
$ git checkout master
2. Pull the changes from the `upstream/master` branch.
$ git pull --ff-only upstream master
# gets changes from "master" branch on the "upstream" remote
* Note: If this gives you an error, it means you have committed directly to your local `master` branch. [Click here for instructions on how to fix this issue](#why-does-git-pull---ff-only-result-in-an-error).
$ git push origin master
# optionally, push the synced master state to your fork
#### Make your changes
0. Update your `master` branch, if you haven't already.
1. For each new feature or bug fix, create a new branch.
$ git branch new_feature
# Creates a new branch called "new_feature"
$ git checkout new_feature
# Makes "new_feature" the active branch
2. Once you've committed some changes locally, you need to push them to your fork here on GitHub.
$ git push origin new_feature
# origin was automatically set to point to your fork when you cloned it
3. Once you're finished working on your branch, and have committed and pushed all your changes, submit a pull request from your `new_feature` branch to this repository's `master` branch.
* Note: any new commits to the `new_feature` branch on GitHub will automatically be included in the pull request, so make sure to only commit related changes to the same branch.
## Drafts
If you file a PR but you're still working on it, please make it a [Draft](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
![screenshot](https://docs.github.com/assets/images/help/pull_requests/pullrequest-send.png)
This will tell the reviewers that you still intend to add more to the PR and we don't need to review it yet. When it's ready to be reviewed for a merger, just click the [`Ready for review`](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/changing-the-stage-of-a-pull-request) button.
![screenshot](https://docs.github.com/assets/images/help/pull_requests/ready-for-review-button.png)
Please convert all your existing PRs with `[WIP]` in the title to Drafts.
![screenshot](https://docs.github.com/assets/images/help/pull_requests/convert-to-draft-link.png)
This can help speed up our review process by allowing us to only review the things that are ready for it, and will help prevent merging in anything that isn't completely ready.
## Comment requests
If you are also looking for suggestions then add a [CR] before the title text — "comments requested". Feel free to remove [CR] when you feel you got enough information to proceed.
It is not required to solve or reference an open issue to file a PR, however, if you do so, you need to explain the problem your PR is solving in full detail.
### All PRs should have a "Summary" section with one line
Summary is a one-line description of your change that will be extracted and added to [the project changelog](../data/changelog.txt).
The format is:
```
#### Summary
Category "description"
```
The categories to choose from are: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N.
Example:
```
#### Summary
Content "Adds new mutation category 'Mouse'"
```
Or, if you want it treated as a minor tweak that doesn't appear in the changelog:
```
#### Summary
None
```
See [the Changelog Guidelines](../doc/CHANGELOG_GUIDELINES.md) for explanations of the categories.
### Closing issues using keywords
One more thing: when marking your PR as closing, fixing, or resolving issues, please include "XXXX #???" somewhere in the description, where XXX is on this list:
* close
* closes
* closed
* fix
* fixes
* fixed
* resolve
* resolves
* resolved
The "???" is the issue number. This automatically closes the issue when the PR is pulled in, and allows merges to work slightly faster. To close multiple issues format it as "XXXX #???, XXXX#???".
See https://help.github.com/articles/closing-issues-using-keywords/ for more.
## Keep your PR description relevant
Make sure your PR description is still relevant every time you change your branch after discussion or additional thought.
## Tooling support
Various tools are available to help you keep your contributions conforming to the appropriate style. See [the relevant docs](../doc/DEVELOPER_TOOLING.md) for more details.
## Advanced Techniques
These guidelines aren't essential, but they can make keeping things in order much easier.
#### Using remote tracking branches
Remote tracking branches allow you to easily stay in touch with this repository's `master` branch, as they automatically know which remote branch to get changes from.
$ git branch -vv
* master xxxx [origin/master] ....
new_feature xxxx ....
Here you can see we have two branches; `master` which is tracking `origin/master`, and `new_feature` which isn't tracking any branch. In practice, what this means is that git won't know where to get changes from.
$ git checkout new_feature
Switched to branch 'new_feature'
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
In order to easily pull changes from `upstream/master` into the `new_feature` branch, we can tell git which branch it should track. (You can even do this for your local master branch.)
$ git branch -u upstream/master new_feature
Branch new_feature set up to track remote branch master from upstream.
$ git pull
Updating xxxx..xxxx
....
You can also set the tracking information at the same time as creating the branch.
$ git branch new_feature_2 --track upstream/master
Branch new_feature_2 set up to track remote branch master from upstream.
* Note: Although this makes it easier to pull from `upstream/master`, it doesn't change anything with regards to pushing. `git push` fails because you don't have permission to push to `upstream/master`.
$ git push
error: The requested URL returned error: 403 while accessing https://github.com/CleverRaven/Cataclysm-DDA.git
fatal: HTTP request failed
$ git push origin
....
To https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
xxxx..xxxx new_feature -> new_feature
## Unit tests
There is a suite of tests built into the source tree at tests/
You should run the test suite after ANY change to the game source.
An ordinary invocation of `make` will build the test executable at tests/cata_test, and it can be invoked like any ordinary executable, or via `make check`.
Running `test/cata_test` with no arguments will run the entire test suite; running it with `--help` will print a number of invocation options you can use to adjust its operation.
$ make
... compilation details ...
$ tests/cata_test
Starting the actual test at Fri Nov 9 04:37:03 2018
===============================================================================
All tests passed (1324684 assertions in 94 test cases)
Ended test at Fri Nov 9 04:37:45 2018
The test took 41.772 seconds
I recommend habitually invoking make like ``make YOUR BUILD OPTIONS && make check``.
If you're working with Visual Studio (and don't have `make`), see [Visual Studio-specific advice](../doc/COMPILING/COMPILING-VS-VCPKG.md#running-unit-tests).
If you want/need to add a test, see [TESTING.md](../doc/TESTING.md)
## In-game testing, test environment and the debug menu
Whether you are implementing a new feature or whether you are fixing a bug, it is always a good practice to test your changes in-game. It can be a hard task to create the exact conditions by playing a normal game to be able to test your changes, which is why there is a debug menu. There is no default key to bring up the menu so you will need to assign one first.
Bring up the keybindings menu (press `Escape` then `1`), scroll down almost to the bottom and press `+` to add a new key binding. Press the letter that corresponds to the *Debug menu* item, then press the key you want to use to bring up the debug menu. To test your changes, create a new world with a new character. Once you are in that world, press the key you just assigned for the debug menu and you should see something like this:
```
┌───────────────────────────────────────────────────────────────────────────┐
│ Debug Functions - Using these will cheat not only the game, but yourself. │
├───────────────────────────────────────────────────────────────────────────┤
│ i Info │
│ Q Quit to main menu │
│ s Spawning… │
│ p Player… │
│ t Teleport… │
│ m Map… │
└───────────────────────────────────────────────────────────────────────────┘
```
With these commands, you should be able to recreate the proper conditions to test your changes. You can find some more information about the debug menu on [the official wiki](http://cddawiki.chezzo.com/cdda_wiki/index.php).
## Frequently Asked Questions
#### Why does `git pull --ff-only` result in an error?
If `git pull --ff-only` shows an error, it means that you've committed directly to your local `master` branch. To fix this, we create a new branch with these commits, find the point at which we diverged from `upstream/master`, and then reset `master` to that point.
$ git pull --ff-only upstream master
From https://github.com/CleverRaven/Cataclysm-DDA
* branch master -> FETCH_HEAD
fatal: Not possible to fast-forward, aborting.
$ git branch new_branch master # mark the current commit with a tmp branch
$ git merge-base master upstream/master
cc31d0... # the last commit before we committed directly to master
$ git reset --hard cc31d0....
HEAD is now at cc31d0... ...
Now that `master` has been cleaned up, we can easily pull from `upstream/master`, and then continue working on `new_branch`.
$ git pull --ff-only upstream master
# gets changes from the "upstream" remote for the matching branch, in this case "master"
$ git checkout new_branch
For more frequently asked questions, see the [developer FAQ](../doc/DEVELOPER_FAQ.md).
-59
View File
@@ -1,59 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
---
<!-- Please follow the template below -->
# Describe the bug
<!-- A clear and concise description of what the bug is. -->
# Steps To Reproduce
<!-- Steps to reproduce the behavior:
1. Make a player with a gun, magazine, and some ammo.
2. Try to aim at a wall.
3. There's no way to increase aim level. -->
# Expected behavior
<!-- A clear and concise description of what you expected to happen.
Ideally also describe *why* you expect it to happen. -->
# Screenshots
<!-- **If applicable**, add screenshots to help explain your problem.
Do not take a screenshot of the crashing window. Please provide the crash logs in the "Additional context" -->
# Versions and configuration
<!-- Please complete the following information; you can now go to:
- "Main menu (ESC) > Debug Menu > Info > Generate game report" to generate this report.
- Please update your OS version with a more precise version.
- OS: [e.g. iOS 8 or Windows 10 or Ubuntu 18.04]
- Game Version: [from the main menu, e.g. 0.C-29938-g90f5268437]
- Graphics version: [Tiles or Terminal]
- Ingame language: [Arabic or Bulgarian or Chinese (Simplified) or Chinese (Traditional) or Dutch or Esperanto or French or German or Italian (Italy) or Japanese or Korean or Polish or Portuguese (Brazil) or Russian or Serbian or Spanish (Argentina) or Spanish (Spain) or Turkish]
- Mods loaded: [e.g.dda, boats, hacktheplanet, StatsThroughSkills]
-->
# Additional context
<!-- Add any other context about the problem here.
Crash: if your problem refers to a crash, please add the following files to the "Additional Context" paragraph:
- From the /config folder (you can zip them both together):
- crash.log file.
- debug.log file.
- Your save file (zipped)
- note #1: you can drag and drop files in this issue post!
- note #2: it is very important for us that you provide a save file in case of a crash. It really helps the developers
to reproduce the bug and fix it. If possible, try to provide a save file that occurs in the right conditions, just
before the crash happens. -->
-8
View File
@@ -1,8 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Github Discussion
url: https://github.com/CleverRaven/Cataclysm-DDA/discussions
about: For nonspecific feature requests, balance concerns, and questions about the game, prefer opening a discussion to an issue.
- name: Project Forums
url: https://discourse.cataclysmdda.org/
about: For even more general discussion with the community, consider posting on the forums.
-17
View File
@@ -1,17 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
---
# Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
# Describe the solution you'd like
A clear and concise description of what you want to happen.
# Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
# Additional context
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature request here.
-33
View File
@@ -1,33 +0,0 @@
<!-- HOW TO USE: Under each "#### Heading" below, enter information relevant to your pull request.
Leave the headings unless they don't apply to your PR, and remove the comment blocks (surrounded with <!–– and ––>) when you are done.
NOTE: Please grant permission for repository maintainers to edit your PR. It is EXTREMELY common for PRs to be held up due to trivial changes being requested and the author being unavailable to make them. -->
#### Summary
Category "Brief description"
<!-- This section should consist of exactly one line, edit the one above.
Category must be one of these: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N. Or replace the whole line with just the word None for no changelog entry.
For more on the meaning of each category, see:
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md
If approved and merged, your summary will be added to the project changelog:
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt -->
#### Purpose of change
<!-- With a few sentences, describe your reasons for making this change. If it relates to an existing issue, you can link it with a # followed by the GitHub issue number, like #1234. If your pull request *fully* resolves an issue, include the word "Fix" or "Fixes" before the issue number, like: Fixes #1234.
If there is no related issue, explain here what issue, feature, or other concern you are addressing. If this is a bugfix, include steps to reproduce the original bug, so your fix can be verified. -->
#### Describe the solution
<!-- How does the feature work, or how does this fix a bug? The easier you make your solution to understand, the faster it can get merged. -->
#### Describe alternatives you've considered
<!-- Explain any alternative solutions, different approaches, or possibilities you've considered using to solve the same problem. -->
#### Testing
<!-- Describe what steps you took to test that this PR resolved the bug or added the feature, and what tests you performed to make sure it didn't cause any regressions. Also include testing suggestions for reviewers and maintainers. -->
#### Additional context
<!-- Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature or bugfix here. -->
-77
View File
@@ -1,77 +0,0 @@
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 30
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
daysUntilClose: 30
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
onlyLabels: []
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
exemptLabels:
- <Bug>
- <Bugfix>
- "<Crash / Freeze>"
- "Organization: Bounty"
- "(P1 - Critical)"
- "(P2 - High)"
- "(P3 - Medium)"
- "(P4 - Low)"
- "(P5 - Long-term)"
- "(S2 - Confirmed)"
- "0.E Feature Freeze"
- "0.E Content Freeze"
- "0.F Feature Freeze"
- "0.F Content Freeze"
- "0.F String Freeze"
# Set to true to ignore issues in a project (defaults to false)
exemptProjects: true
# Set to true to ignore issues in a milestone (defaults to false)
exemptMilestones: true
# Set to true to ignore issues with an assignee (defaults to false)
exemptAssignees: true
# Label to use when marking as stale
staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions. Please do not \'bump\' or comment on this issue
unless you are actively working on it. Stale issues, and stale issues that
are closed are still considered.
# Comment to post when removing the stale label.
# unmarkComment: >
# Your comment here.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
This issue has been automatically closed due to lack of activity. This does
not mean that we do not value the issue. Feel free to request that it be
re-opened if you are going to actively work on it
# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 2
# Limit to only `issues` or `pulls`
# only: issues
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
# pulls:
# daysUntilStale: 30
# markComment: >
# This pull request has been automatically marked as stale because it has not had
# recent activity. It will be closed if no further activity occurs. Thank you
# for your contributions.
# issues:
# exemptLabels:
# - confirmed
-61
View File
@@ -1,61 +0,0 @@
name: Clang Build Analyzer
on:
push:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**.c'
- '**/CMakeLists.txt'
- '**/Makefile'
- '**.hpp'
- '**.cmake'
pull_request:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**.c'
- '**/CMakeLists.txt'
- '**/Makefile'
- '**.hpp'
- '**.cmake'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: sudo apt-get install libncursesw5-dev
- name: Prepare Build Analyzer
run: |
cd
git clone --recursive https://github.com/aras-p/ClangBuildAnalyzer.git buildAnalyzer
cd buildAnalyzer
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE ..
cmake --build . -- -j3
echo "${PWD}" >> $GITHUB_PATH
- uses: ammaraskar/gcc-problem-matcher@master
- name: make
run: |
ClangBuildAnalyzer --start .
CLANG=clang++-9 CXXFLAGS=-ftime-trace make
ClangBuildAnalyzer --stop . buildAnalysis
- name: Analyze
run: ClangBuildAnalyzer --analyze buildAnalysis
- uses: actions/upload-artifact@v2
with:
name: ClangBuildAnalyzer-traces
path: "**/obj/*.json"
-31
View File
@@ -1,31 +0,0 @@
name: astyle
on:
pull_request:
paths:
- '**.cpp'
- '**.h'
- '**.c'
jobs:
astyle-code:
name: astyle check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: sudo apt-get install astyle
- name: astyle check
run: make astyle-check
- name: Display Corrections
if: failure()
run: |
make astyle
git diff
-21
View File
@@ -1,21 +0,0 @@
name: Check printf format string in translations
on:
pull_request:
paths:
- 'lang/po/*.po'
- 'tools/check_po_printf_format.py'
jobs:
check-po-printf:
runs-on: ubuntu-20.04
steps:
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install polib
- name: "Checkout"
uses: actions/checkout@v2
- name: "Check printf format string in translations"
run: ./tools/check_po_printf_format.py
-53
View File
@@ -1,53 +0,0 @@
name: Clang-tidy (clang-8, tiles)
on:
push:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**.c'
- '**/CMakeLists.txt'
- '**/Makefile'
- '**.hpp'
- '**.cmake'
pull_request:
branches:
- master
paths:
- '**.cpp'
- '**.h'
- '**.c'
- '**/CMakeLists.txt'
- '**/Makefile'
- '**.hpp'
- '**.cmake'
jobs:
build:
runs-on: ubuntu-16.04
env:
CMAKE: 1
CLANG: clang++-8
COMPILER: clang++-8
CATA_CLANG_TIDY: plugin
TILES: 1
SOUND: 1
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: |
#sudo apt-add-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main"
sudo apt-get update
sudo apt-get install libncursesw5-dev clang-8 libclang-8-dev llvm-8-dev llvm-8-tools \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev ccache \
gettext
- name: prepare
run: bash ./build-scripts/requirements.sh
- uses: ammaraskar/gcc-problem-matcher@master
- name: run clang-tidy
run: bash ./build-scripts/build.sh
-31
View File
@@ -1,31 +0,0 @@
name: cmake-format linting
on:
push:
branches:
- master
paths:
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'
pull_request:
branches:
- master
paths:
- '**/CMakeLists.txt'
- '**.cmake'
- '**.cmake.in'
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install cmakelang
run: python3 -m pip install -U cmakelang
- name: run cmake-lint
run: python3 -m cmakelang.lint CMakeLists.txt src/CMakeLists.txt data/CMakeLists.txt lang/CMakeLists.txt src/chkjson/CMakeLists.txt tools/format/CMakeLists.txt tools/clang-tidy-plugin/CMakeLists.txt cmake_uninstall.cmake.in -c .cmake-format.yml
-29
View File
@@ -1,29 +0,0 @@
name: Flake8 Python linting
on:
push:
branches:
- master
paths:
- '**.py'
pull_request:
branches:
- master
paths:
- '**.py'
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies
run: sudo apt-get install flake8
- name: Enable flake8 problem matcher
run: echo "::add-matcher::build-scripts/problem-matchers/flake8.json"
- name: run Flake8
run: make python-check
-22
View File
@@ -1,22 +0,0 @@
name: JSON Validation
on:
pull_request:
paths:
- '**.json'
jobs:
style-json:
name: JSON style check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: JSON style check
run: make style-json
- name: Display Corrections
if: failure()
run: git diff
-139
View File
@@ -1,139 +0,0 @@
name: General build matrix
on:
push:
branches:
- master
paths-ignore:
- 'android/**'
- 'build-data/osx/**'
- 'doc/**'
- 'doxygen_doc/**'
- 'lgtm/**'
- 'msvc-full-features/**'
- 'msvc-object_creator/**'
- 'object_creator/**'
- 'tools/**'
- 'utilities/**'
pull_request:
branches:
- master
paths-ignore:
- 'android/**'
- 'build-data/osx/**'
- 'doc/**'
- 'doxygen_doc/**'
- 'lgtm/**'
- 'msvc-full-features/**'
- 'msvc-object_creator/**'
- 'object_creator/**'
- 'tools/**'
- 'utilities/**'
jobs:
varied_builds:
strategy:
matrix:
include:
- compiler: g++-9
os: ubuntu-latest
cmake: 0
tiles: 0
test-stage: 1
native: linux64
gold: 1
lto: 1
title: GCC 9, Ubuntu, Curses, LTO
- compiler: g++-7
os: ubuntu-latest
cmake: 1
tiles: 1
native: linux64
title: GCC 7, Ubuntu, Tiles, CMake
- compiler: g++-8
os: ubuntu-latest
cmake: 0
tiles: 1
sanitize: address
native: linux64
title: GCC 8, Ubuntu, Tiles, ASan
- compiler: clang++-9
os: ubuntu-latest
cmake: 0
tiles: 1
sanitize: address,undefined
native: linux64
title: Clang 9, Ubuntu, Tiles, ASan, UBSan
- compiler: clang++
os: macos-10.15
cmake: 0
tiles: 1
native: osx
title: Clang 12, macOS 10.15, Tiles
name: ${{ matrix.title }}
runs-on: ${{ matrix.os }}
env:
CMAKE: ${{ matrix.cmake }}
COMPILER: ${{ matrix.compiler }}
OS: ${{ matrix.os }}
TILES: ${{ matrix.tiles }}
SOUND: ${{ matrix.tiles }}
SANITIZE: ${{ matrix.sanitize }}
TEST_STAGE: ${{ matrix.test-stage }}
EXTRA_TEST_OPTS: --error-format=github-action
NATIVE: ${{ matrix.native }}
GOLD: ${{ matrix.gold }}
LTO: ${{ matrix.lto }}
RELEASE: 1
steps:
- name: checkout repository
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: install dependencies (ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libncursesw5-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev \
libsdl2-mixer-dev libpulse-dev ccache gettext parallel
- name: install old GCC (ubuntu)
if: runner.os == 'Linux' && (matrix.compiler == 'g++-7' || matrix.compiler == 'g++-8')
run: |
sudo apt-get install g++-7 g++-8
- name: install dependencies (mac)
if: runner.os == 'macOS'
run: |
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d%H%M")"
shell: bash
- name: ccache cache files (ubuntu)
if: runner.os == 'Linux'
uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-linux-${{ matrix.compiler }}-${{ steps.get-date.outputs.date }}
restore-keys: |
ccache-linux-${{ matrix.compiler }}-
- name: ccache cache files (mac)
if: runner.os == 'macOS'
uses: actions/cache@v2
with:
path: /Users/runner/Library/Caches/ccache
key: ccache-mac-${{ matrix.compiler }}-${{ steps.get-date.outputs.date }}
restore-keys: |
ccache-mac-${{ matrix.compiler }}-
- uses: ammaraskar/gcc-problem-matcher@master
- name: build and test
run: bash ./build-scripts/build.sh
- name: upload artifacts if failed
uses: actions/upload-artifact@v1
if: failure()
with:
name: cata_test
path: tests/cata_test
-16
View File
@@ -1,16 +0,0 @@
name: PR Validator
on:
pull_request:
branches:
- master
types: [opened, edited, synchronize]
jobs:
validate:
name: Validate PR
runs-on: ubuntu-latest
steps:
- name: "Validate SUMMARY"
uses: CleverRaven/pr-validator@master
with:
description-regex: '(\n|^)#### Summary\s+`{0,3}(SUMMARY:\s+)?(None|((Features|Content|Interface|Mods|Balance|Bugfixes|Performance|Infrastructure|Build|I18N) +".*"))`{0,3}\s*(\n|$)'
description-regex-flags: 'i'
-151
View File
@@ -1,151 +0,0 @@
name: "Experimental Release"
on:
push:
branches:
- master
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
- name: Push tag
id: tag_version
uses: mathieudutour/github-tag-action@v5.5
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ github.run_number }}
tag_prefix: experimental-
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: "Experimental Build #${{ github.run_number }}"
body: |
These are the outputs for the experimental build of commit [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
draft: false
prerelease: true
builds:
needs: release
strategy:
matrix:
include:
- name: Windows Tiles x64
mxe: x86_64
artifact: windows-tiles-x64
os: ubuntu-latest
ext: zip
content: application/zip
- name: Windows Tiles x32
mxe: i686
artifact: windows-tiles-x32
os: ubuntu-latest
ext: zip
content: application/zip
- name: Linux Tiles x64
os: ubuntu-latest
mxe: none
tiles: 1
artifact: linux-tiles-x64
ext: tar.gz
content: application/gzip
- name: linux-curses-x64
os: ubuntu-latest
mxe: none
tiles: 0
artifact: linux-curses-x64
ext: tar.gz
content: application/gzip
- name: osx-curses-x64
os: macos-10.15
mxe: none
tiles: 0
artifact: osx-curses-x64
ext: dmg
content: application/x-apple-diskimage
- name: osx-tiles-x64
os: macos-10.15
mxe: none
tiles: 1
artifact: osx-tiles-x64
ext: dmg
content: application/x-apple-diskimage
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies (windows)
if: matrix.mxe != 'none'
run: |
sudo apt install astyle autoconf automake autopoint bash bison bzip2 cmake flex gettext git g++ gperf intltool \
libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev libxml-parser-perl lzip make mingw-w64 openssl \
p7zip-full patch perl pkg-config python ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin
- name: Install MXE
if: matrix.mxe != 'none'
run: |
sudo apt install software-properties-common lsb-release
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
sudo add-apt-repository "deb [arch=amd64] https://pkg.mxe.cc/repos/apt `lsb_release -sc` main"
sudo apt update
sudo apt install mxe-{i686,x86-64}-w64-mingw32.static-{sdl2,sdl2-ttf,sdl2-image,sdl2-mixer,gettext}
- name: Install dependencies (Linux)
if: runner.os == 'Linux' && matrix.mxe == 'none'
run: |
sudo apt-get update
sudo apt-get install libncursesw5-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev \
libsdl2-mixer-dev libpulse-dev ccache gettext parallel
- name: Install dependencies (mac)
if: runner.os == 'macOS'
run: |
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel
pip3 install dmgbuild biplist
- name: Build CDDA (linux)
if: runner.os == 'Linux' && matrix.mxe == 'none'
run: |
cat >VERSION.txt <<EOL
build type: ${{ matrix.artifact }}
build number: ${{ github.run_number }}
commit sha: ${{ github.sha }}
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
EOL
make -j$((`nproc`+0)) TILES=${{ matrix.tiles }} SOUND=${{ matrix.tiles }} RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 bindist
mv cataclysmdda-0.E.tar.gz cdda-${{ matrix.artifact }}-b${{ github.run_number }}.tar.gz
- name: Build CDDA (windows)
if: matrix.mxe != 'none'
env:
PLATFORM: /usr/lib/mxe/usr/bin/${{ matrix.mxe }}-w64-mingw32.static-
run: |
cat >VERSION.txt <<EOL
build type: ${{ matrix.artifact }}
build number: ${{ github.run_number }}
commit sha: ${{ github.sha }}
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
EOL
make -j$((`nproc`+0)) CROSS="${PLATFORM}" TILES=1 SOUND=1 RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 bindist
mv cataclysmdda-0.E.zip cdda-${{ matrix.artifact }}-b${{ github.run_number }}.zip
- name: Build CDDA (osx)
if: runner.os == 'macOS'
run: |
cat >VERSION.txt <<EOL
build type: ${{ matrix.artifact }}
build number: ${{ github.run_number }}
commit sha: ${{ github.sha }}
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
EOL
make -j3 TILES=${{ matrix.tiles }} SOUND=${{ matrix.tiles }} RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 dmgdist
mv Cataclysm.dmg cdda-${{ matrix.artifact }}-b${{ github.run_number }}.dmg
- name: Upload release asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: cdda-${{ matrix.artifact }}-b${{ github.run_number }}.${{ matrix.ext }}
asset_name: cdda-${{ matrix.artifact }}-b${{ github.run_number }}.${{ matrix.ext }}
asset_content_type: ${{ matrix.content }}
-25
View File
@@ -1,25 +0,0 @@
on:
push:
branches:
- master
paths:
- 'doc/JSON_INFO.md'
name: TOC Generator
jobs:
generateTOC:
if: github.repository == 'CleverRaven/Cataclysm-DDA'
name: Update the table of contents
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npx doctoc doc/JSON_INFO.md --github
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update the table of contents
branch: update-toc
title: Update the table of contents in doc/JSON_INFO.md
body: |
```sh
npx doctoc doc/JSON_INFO.md --github
```
-40
View File
@@ -1,40 +0,0 @@
name: "Push translation template"
concurrency: push_transifex
on:
push:
branches:
- master
paths:
- '**.json'
- 'src/**.cpp'
- 'src/**.h'
- 'lang/extract_json_strings.py'
- 'lang/strip_line_numbers.py'
- 'lang/update_pot.sh'
- 'lang/unicode_check.py'
jobs:
push-template:
runs-on: ubuntu-20.04
steps:
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install gettext python3-pip
sudo pip3 install transifex-client
- name: "Checkout"
uses: actions/checkout@v2
- name: "Generate translation template"
run: |
lang/update_pot.sh
- name: "Push translation template"
env:
TOKEN: ${{ secrets.TX_TOKEN }}
run: |
export TX_TOKEN=$TOKEN
tx push --source --no-interactive --resource cataclysm-dda.master-cataclysm-dda
unset TX_TOKEN
unset TOKEN
+11
View File
@@ -7,6 +7,7 @@
*.o
*.tmp
*.zip
*.apk
/WinDepend/
/bindist/
/build/
@@ -141,6 +142,7 @@ Cataclysm.dmg
/tests/shadowcasting_test
/tests/data/jsionized_overmap.sav
/test_user_dir
monfactions.txt
# temporary files generated by tools/reduce_tests.sh
/list_of_tests
@@ -203,3 +205,12 @@ Xcode/
/tests/pch/tests-pch.hpp.pch
/tests/catch/catch.hpp.gch
/tests/catch/catch.hpp.pch
weather.output
# bundler local directories and files for jekyll site
/.bundle/
/_site/
/vendor/
.sass-cache
.jekyll-metadata
Gemfile.lock
-8
View File
@@ -1,8 +0,0 @@
# If this commit is applied, it will ....
# |<-- Using around 50, Maximum 72 Characters -->|
# Explain why this change is being made
# |<---- Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: fixes #1234, closes #2345, resolves #3456, references #4567
-5
View File
@@ -1,5 +0,0 @@
# Disable FIXME query, in DDA it is as likely to be a future feature as a bug.
# Disable "potentially dangerous function" warning like localtime, there is no good alternative and we aren't multithreaded.
queries:
- exclude: cpp/fixme-comment
- exclude: cpp/potentially-dangerous-function
-231
View File
@@ -1,231 +0,0 @@
# this file is HEAVILY influenced by https://github.com/boostorg/hana/blob/master/.travis.yml
dist: xenial
language: c++
cache: ccache
notifications:
email: false
git:
depth: 5
addons:
# these apt sources will be referenced later (by using *name)
apt:
sources: &apt_sources
- ubuntu-toolchain-r-test
config:
retries: true
compiler: gcc
os: linux
# We have branch builds disabled globally to prevent double-builds of PRs.
# This re-enables just the master branch.
branches:
only:
- master
- development
# Overall strategy for what sorts of builds to include:
# We want a build for each compiler and each platform.
# For PRs, we lessen the "each compiler" requirement to just covering the newest
# and oldest relevant version of each compiler.
# We also want to ensure that each of the following tweaks are covered in at
# least one PR build:
# - TILES=1
# - SOUND=1
# - RELEASE=1
# - CMAKE=1
# - LOCALIZE=0
# - Tests with important mods enabled (Magiclysm)
# We try to minimize the number of builds subject to those constraints.
#
# The following used to be here but became too slow to run on Travis and have
# been moved to GitHub Actions:
# - A clang-tidy run
# - SANITIZE=address,undefined
# To see what toolchains are available, consult the following:
# https://github.com/travis-ci/apt-source-safelist/blob/master/ubuntu.json
# https://launchpad.net/%7Eubuntu-toolchain-r/+archive/ubuntu/test/+index
jobs:
include:
# Initial test stage, if this fails everything else is canceled.
- stage: Test
# Clang is consistently the fastest to build, so use it for the initial test.
env: CLANG=clang++-3.8 TEST_STAGE=1 CXXFLAGS="-Wno-error=unused-command-line-argument -D__extern_always_inline='extern __always_inline'"
name: "Clang 3.8 Make build with curses and style check"
compiler: clang
addons: &clang38
apt:
packages: ["clang-3.8"]
sources: [*apt_sources]
# Then build different configurations and targets in parallel.
- stage: "Main Compilers"
env: COMPILER=g++ MODS=--mods=magiclysm LOCALIZE=0
name: "GCC 5.3 Make build with curses, Magiclysm, and no Localization"
compiler: gcc
addons: &gcc53
apt:
packages: ["g++-5=5.3.1-14ubuntu2", "libstdc++-5-dev=5.3.1-14ubuntu2", "gcc-5=5.3.1-14ubuntu2", "gcc-5-base=5.3.1-14ubuntu2", "cpp-5=5.3.1-14ubuntu2", "libgcc-5-dev=5.3.1-14ubuntu2", "libasan2=5.3.1-14ubuntu2", "libmpx0=5.3.1-14ubuntu2"]
sources: [*apt_sources]
- env: COMPILER=g++-8 CXXFLAGS="-Wno-implicit-fallthrough" TILES=1 SOUND=1
name: "GCC 8 Make build with Tiles, Sound"
dist: bionic
compiler: gcc
addons: &gcc8
apt:
packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
sources: *apt_sources
- env: CLANG=clang++-10
name: "Clang 10 Make build"
compiler: clang
dist: bionic
addons: &clang10
apt:
packages:
- clang-10
sources:
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
- stage: "Platforms and Tidy"
# MXE variant using alternate repository http://mirror.mxe.cc/repos/apt
env: COMPILER=g++ LDFLAGS="-static-libgcc -static-libstdc++" MXE_TARGET="i686-w64-mingw32.static" WINE="wine" TILES=1 SOUND=1
name: "Mingw-w64 Make cross-compile to Windows with Tiles and Sound"
compiler: gcc
addons: &gcc
apt:
packages: ["wine"]
- env: NATIVE=android COMPILER=gcc
name: "Android build"
language: android
android:
components:
- build-tools-28.0.1
- android-28
cache:
# The ccache feature in Travis doesn't work for language: android, so
# do it ourselves.
directories:
- $HOME/.ccache
- env: CLANG=clang++ OSX_MIN=10.13 TILES=1 SOUND=1
name: "Xcode 10.2 Make build with Tiles and sound (macOS)"
os: osx
osx_image: xcode10.2
compiler: clang
# Finally check the compiler variants
- stage: compilers
# GCC 5.4 is default on Xenial
env: COMPILER=g++
name: "GCC 5.4 Make build with Curses"
if: type != pull_request
- env: COMPILER=g++-6 CODE_COVERAGE=true
name: "GCC 6 Make build with Curses and Code Coverage"
if: type != pull_request
compiler: gcc
addons: &gcc6
apt:
packages: ["g++-6", "g++-6-multilib", "libc6-dbg", "libc6-dbg:i386"]
sources: *apt_sources
- env: COMPILER=g++-7 CXXFLAGS='-Wno-implicit-fallthrough -D_GLIBCXX_DEBUG'
name: "GCC 7 Make build with Curses and GLIBCXX_DEBUG"
if: type != pull_request
compiler: gcc
addons: &gcc7
apt:
packages: ["g++-7", "g++-7-multilib", "libc6-dbg", "libc6-dbg:i386", "lcov"]
sources: *apt_sources
- env: CLANG=clang++-3.9 CXXFLAGS='-Wno-error=unused-command-line-argument -D__extern_always_inline="extern __always_inline"'
name: "Clang 3.9 Make build with Curses"
if: type != pull_request
compiler: clang
addons: &clang39
apt:
packages: ["clang-3.9"]
sources: *apt_sources
- env: CLANG=clang++-4.0 CXXFLAGS=-Wno-error=unused-command-line-argument
name: "Clang 4 Make build with Curses"
if: type != pull_request
compiler: clang
addons: &clang40
apt:
packages: ["clang-4.0"]
# Luckily the Trusty install Just Works on Xenial
sources: [*apt_sources, llvm-toolchain-trusty-4.0]
- env: CLANG=clang++-5.0 CXXFLAGS=-Wno-error=unused-command-line-argument
name: "Clang 5 Make build with Curses"
if: type != pull_request
compiler: clang
addons: &clang50
apt:
packages: ["clang-5.0"]
sources: [*apt_sources, llvm-toolchain-xenial-5.0]
- env: CLANG=clang++-6.0 TILES=1 SOUND=1 CXXFLAGS=-Wno-error=unused-command-line-argument CMAKE=1 RELEASE=1
name: "Clang 6 CMake build with tiles and sound"
if: type != pull_request
compiler: clang
addons: &clang60
apt:
packages: ["clang-6.0", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
sources: [*apt_sources, llvm-toolchain-xenial-6.0]
- env: CLANG=clang++-7
name: "Clang 7 Make build with Curses"
if: type != pull_request
compiler: clang
addons: &clang7
apt:
packages: ["clang-7"]
sources: [*apt_sources, llvm-toolchain-xenial-7]
- env: CLANG=clang++-8
name: "Clang 8 Make build with Curses"
if: type != pull_request
compiler: clang
addons: &clang8
apt:
packages: ["clang-8"]
sources: [*apt_sources, llvm-toolchain-xenial-8]
- env: CLANG=clang++-9
name: "Clang 9 Make build with Curses"
if: type != pull_request
compiler: clang
dist: bionic
addons: &clang9
apt:
packages:
- clang-9
sources:
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
before_script:
- if [ -n "${CLANG}" ]; then COMPILER="$CLANG"; fi
- ${COMPILER} --version
- CXX="$COMPILER"
- source build-scripts/requirements.sh
script:
- build-scripts/build.sh
after_success:
- if [ -n "${CODE_COVERAGE}" ]; then coveralls -b . -i src -e tests --gcov /usr/bin/gcov-6; fi
- if [ -n "${CODE_COVERAGE}" ]; then bash <(curl -s https://codecov.io/bash); fi
-10
View File
@@ -1,10 +0,0 @@
[main]
host = https://www.transifex.com
[cataclysm-dda.master-cataclysm-dda]
file_filter = lang/po/<lang>.po
minimum_perc = 0
source_file = lang/po/cataclysm-dda.pot
source_lang = en
type = PO
+1
View File
@@ -0,0 +1 @@
1e7d902c-02b7-4619-bf01-fe4b9c0ba8ca
-389
View File
@@ -1,389 +0,0 @@
cmake_minimum_required(VERSION 3.1.4)
project(CataclysmDDA)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/CMakeModules)
set(CMAKE_TLS_VERIFY ON)
# Build options
option(TILES "Build graphical tileset version." "OFF")
option(CURSES "Build curses version." "ON")
option(SOUND "Support for in-game sounds & music." "OFF")
option(BACKTRACE "Support for printing stack backtraces on crash" "ON")
option(LIBBACKTRACE "Print backtrace with libbacktrace." "OFF")
option(USE_HOME_DIR "Use user's home directory for save files." "ON")
option(LOCALIZE "Support for language localizations. Also enable UTF support." "ON")
option(LANGUAGES "Compile localization files for specified languages." "")
option(DYNAMIC_LINKING
"Use dynamic linking. Or use static to remove MinGW dependency instead." "ON")
option(JSON_FORMAT "Build JSON formatter" "OFF")
option(CATA_CCACHE "Try to find and build with ccache" "ON")
option(CATA_CLANG_TIDY_PLUGIN "Build Cata's custom clang-tidy plugin" "OFF")
set(CATA_CLANG_TIDY_INCLUDE_DIR "" CACHE STRING
"Path to internal clang-tidy headers required for plugin (e.g. ClangTidy.h)")
set(CATA_CHECK_CLANG_TIDY "" CACHE STRING "Path to check_clang_tidy.py for plugin tests")
set(GIT_BINARY "" CACHE STRING "Git binary name or path.")
set(PREFIX "" CACHE STRING "Location of Data & GFX directories")
include(CTest)
message(STATUS "${PROJECT} build environment --")
message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()
add_definitions(-DCMAKE)
include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*")
if (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
string(REPLACE "-NOTFOUND" "" GIT_VERSION ${GIT_VERSION})
file(WRITE ${CMAKE_SOURCE_DIR}/src/version.h
"// NOLINT(cata-header-guard)\n\#define VERSION \"${GIT_VERSION}\"\n")
message(STATUS "${PROJECT_NAME} build version is: ${GIT_VERSION}")
add_definitions(-DGIT_VERSION)
endif ()
#OS Check Placeholders. Will be used for BINDIST
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(_OS_LINUX_ 1)
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
set(_OS_FREEBSD_ 1)
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
set(_OS_DARWIN_ 1)
set(LOCALIZE OFF)
message(STATUS "Internationalization on Darwin is not supported")
endif ()
include(CheckCXXCompilerFlag)
#FIXME: Add dest build choice: m32 for 32 bit or m64 for 64 bit version
#add_definitions("-m32")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
#SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32")
#SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")
if (NOT DYNAMIC_LINKING)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a")
set(BUILD_SHARED_LIBRARIES OFF)
check_cxx_compiler_flag (-static HAVE_STATIC_FLAG)
if (HAVE_STATIC_FLAG)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif ()
# Workaround for cmake link library guesser
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else ()
if (MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Avoid depending on MinGW runtime DLLs
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
endif ()
endif ()
# System specific actions
if (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
if (NOT DATA_PREFIX)
set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda)
endif ()
if (NOT LOCALE_DIR)
set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
endif ()
if (NOT BIN_PREFIX)
set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin)
endif ()
if (NOT DESKTOP_ENTRY_PATH)
set(DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications)
endif ()
if (NOT PIXMAPS_ENTRY_PATH)
set(PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
endif ()
if (NOT PIXMAPS_UNITY_ENTRY_PATH)
set(PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark)
endif ()
if (NOT MANPAGE_ENTRY_PATH)
set(MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man)
endif ()
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES Windows)
if (NOT DATA_PREFIX)
set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX})
endif ()
if (NOT LOCALE_DIR)
set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX})
endif ()
if (NOT BIN_PREFIX)
set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX})
endif ()
endif ()
message(STATUS "${PROJECT_NAME} build options --")
# Preset variables
if (NOT LANGUAGES)
# English is included to workaround a libintl bug that affects performance
# on MinGW targets. See lang/CMakeList.txt for more information.
set(LANGUAGES en de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW)
endif ()
if (GIT_BINARY)
set(GIT_EXECUTABLE ${GIT_BINARY})
else ()
find_package(Git)
if (NOT GIT_FOUND)
message(WARNING
"Git binary not found. Build version will be set to NULL. \
Install Git package or use -DGIT_BINARY to set path to git binary.")
endif ()
endif ()
if (PREFIX)
add_definitions(-DPREFIX=${PREFIX})
endif ()
# Can't compile curses and tiles build's at same time
if (TILES)
set(CURSES OFF)
endif ()
# Set build types and display info
if (CMAKE_BUILD_TYPE STREQUAL Debug)
message(STATUS "Build ${PROJECT} in development mode --")
message(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
set(CMAKE_VERBOSE_MAKEFILE ON)
# Since CataclysmDDA does not respect PREFIX for development builds
# and has funny path handlers, we should create resulting Binaries
# in the source directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} CACHE PATH
"Single Directory for all Executables.")
set(BIN_PREFIX ${CMAKE_SOURCE_DIR})
else ()
message(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "BIN_PREFIX : ${BIN_PREFIX}")
message(STATUS "DATA_PREFIX : ${DATA_PREFIX}")
if (LOCALIZE)
message(STATUS "LOCALE_PATH : ${LOCALE_DIR}")
endif ()
message(STATUS "DESKTOP_ENTRY_PATH : ${DESKTOP_ENTRY_PATH}")
message(STATUS "PIXMAPS_ENTRY_PATH : ${PIXMAPS_ENTRY_PATH}")
message(STATUS "PIXMAPS_UNITY_ENTRY_PATH : ${PIXMAPS_UNITY_ENTRY_PATH}")
message(STATUS "MANPAGE_ENTRY_PATH : ${MANPAGE_ENTRY_PATH}")
add_definitions(-DRELEASE)
# Use PREFIX as storage of data,gfx, etc.. Useful only on *nix OS.
if (PREFIX AND NOT WIN32)
add_definitions(-DDATA_DIR_PREFIX)
endif ()
endif ()
message(STATUS "GIT_BINARY : ${GIT_EXECUTABLE}")
message(STATUS "DYNAMIC_LINKING : ${DYNAMIC_LINKING}")
message(STATUS "TILES : ${TILES}")
message(STATUS "CURSES : ${CURSES}")
message(STATUS "SOUND : ${SOUND}")
message(STATUS "BACKTRACE : ${BACKTRACE}")
message(STATUS "LOCALIZE : ${LOCALIZE}")
message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}")
message(STATUS "LANGUAGES : ${LANGUAGES}")
message(STATUS "See doc/COMPILING/COMPILING-CMAKE.md for details and more info --")
if (MSVC)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-D_AMD64_)
else ()
add_definitions(-D_X86_)
endif ()
else (MSVC)
set(CATA_WARNINGS
"-Werror -Wall -Wextra \
-Wformat-signedness \
-Wlogical-op \
-Wmissing-declarations \
-Wmissing-noreturn \
-Wnon-virtual-dtor \
-Wold-style-cast \
-Woverloaded-virtual \
-Wpedantic \
-Wsuggest-override \
-Wunused-macros \
-Wzero-as-null-pointer-constant \
-Wno-unknown-warning-option")
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
endif ()
set(CATA_OTHER_FLAGS "${CATA_OTHER_FLAGS} -fsigned-char")
# Compact the whitespace in the warning string
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS} ${CATA_OTHER_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
endif ()
set(CMAKE_CXX_STANDARD 14)
# Force out-of-source build
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"This project requires an out of source build. \
Remove the file 'CMakeCache.txt' found in this directory before continuing; \
create a separate build directory and run 'cmake [options] <srcs>' from there. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
#set(THREADS_USE_PTHREADS_WIN32 True)
set(CMAKE_THREAD_PREFER_PTHREAD True)
find_package(Threads REQUIRED)
# Check for build types and libraries
if (TILES)
# Find SDL, SDL_ttf & SDL_image for graphical install
message(STATUS "Searching for SDL2 library --")
find_package(SDL2)
if (NOT SDL2_FOUND)
message(FATAL_ERROR
"This project requires SDL2 to be installed to compile in graphical mode. \
Please install the SDL2 development libraries, \
or try compiling without -DTILES=1 for a text-only compilation. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
if (NOT DYNAMIC_LINKING)
# SDL, SDL_Image, SDL_ttf deps are required for static build
message(STATUS "Searching for SDL deps libraries --")
find_package(Freetype REQUIRED)
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
find_package(ZLIB REQUIRED)
find_package(BZip2 REQUIRED)
endif ()
message(STATUS "Searching for SDL2_TTF library --")
find_package(SDL2_ttf)
if (NOT SDL2_TTF_FOUND)
message(FATAL_ERROR
"This project requires SDL2_ttf to be installed to compile in graphical mode. \
Please install the SDL2_ttf development libraries, \
or try compiling without -DTILES=1 for a text-only compilation. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
message(STATUS "Searching for SDL2_image library --")
find_package(SDL2_image)
if (NOT SDL2_IMAGE_FOUND)
message(FATAL_ERROR
"This project requires SDL2_image to be installed to compile in graphical mode. \
Please install the SDL2_image development libraries, \
or try compiling without -DTILES=1 for a text-only compilation. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
add_definitions(-DTILES)
endif ()
if (CURSES)
# Find the ncurses library for a text based compile
message(STATUS "Searching for Curses library --")
set(CURSES_NEED_NCURSES TRUE)
set(CURSES_NEED_WIDE TRUE)
find_package(Curses)
if (NOT CURSES_FOUND)
message(FATAL_ERROR
"This project requires ncurses to be installed to be compiled in text-only mode. \
Please install the ncurses development libraries, \
or try compiling with -DTILES=1 for a graphical compilation. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info")
endif ()
endif ()
if (SOUND)
# You need TILES to be able to use SOUND
if (NOT TILES)
message(FATAL_ERROR
"You must enable graphical support with -DTILES=1 \
to be able to enable sound support. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
# Sound requires SDL_mixer library
message(STATUS "Searching for SDL2_mixer library --")
find_package(SDL2_mixer)
if (NOT SDL2_MIXER_FOUND)
message(FATAL_ERROR
"You need the SDL2_mixer development library \
to be able to compile with sound enabled. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
endif ()
if (BACKTRACE)
add_definitions(-DBACKTRACE)
if (LIBBACKTRACE)
add_definitions(-DLIBBACKTRACE)
endif (LIBBACKTRACE)
endif (BACKTRACE)
# Ok. Now create build and install recipes
if (LOCALIZE)
if (WIN32)
find_package(Libintl)
if (NOT LIBINTL_FOUND)
message(FATAL_ERROR
"You need the libintl development library \
to be able to compile with LOCALIZE support. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
find_package(Iconv)
if (NOT ICONV_FOUND)
message(FATAL_ERROR
"You need the iconv development library \
to be able to compile with LOCALIZE support. \
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
endif ()
endif ()
add_subdirectory(lang)
add_definitions(-DLOCALIZE)
endif ()
if (USE_HOME_DIR)
add_definitions(-DUSE_HOME_DIR)
endif ()
add_subdirectory(src)
add_subdirectory(data)
if (NOT MSVC)
add_subdirectory(src/chkjson)
endif()
add_subdirectory(tests)
if (JSON_FORMAT)
add_subdirectory(tools/format)
endif()
if (CATA_CLANG_TIDY_PLUGIN)
add_subdirectory(tools/clang-tidy-plugin)
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}"
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND AND CATA_CCACHE)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif ()
-160
View File
@@ -1,160 +0,0 @@
#.rst:
# CMakeParseArguments
# -------------------
#
#
#
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords>
# <multi_value_keywords> args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
# for parsing the arguments given to that macro or function. It
# processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The <options> argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any
# value following, like e.g. the OPTIONAL keyword of the install()
# command.
#
# The <one_value_keywords> argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The <multi_value_keywords> argument contains all keywords for this
# macro which can be followed by more than one value, like e.g. the
# TARGETS or FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in <options>, <one_value_keywords> and
# <multi_value_keywords> a variable composed of the given <prefix>
# followed by "_" and the name of the respective keyword. These
# variables will then hold the respective value from the argument list.
# For the <options> keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see
# whether your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments
# as the real install() command:
#
# ::
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# ...
#
#
#
# Assume my_install() has been called like this:
#
# ::
#
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
#
#
# After the cmake_parse_arguments() call the macro will have set the
# following variables:
#
# ::
#
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
#
#
# You can then continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a
# one_value_keyword another recognized keyword follows, this is
# interpreted as the beginning of the new option. E.g.
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach()
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else()
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif()
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach()
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach()
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction()
-78
View File
@@ -1,78 +0,0 @@
#.rst:
# CheckLibraryExists
# ------------------
#
# Check if the function exists.
#
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
#
# ::
#
# LIBRARY - the name of the library you are looking for
# FUNCTION - the name of the function
# LOCATION - location where the library should be found
# VARIABLE - variable to store the result
#
#
#
# The following variables may be set before calling this macro to modify
# the way the check is run:
#
# ::
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
if(${VARIABLE} MATCHES "^${VARIABLE}$")
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
endif()
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
-DLINK_DIRECTORIES:STRING=${LOCATION}
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
"passed with the following output:\n"
"${OUTPUT}\n\n")
else()
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
"failed with the following output:\n"
"${OUTPUT}\n\n")
endif()
endif()
endmacro()
-198
View File
@@ -1,198 +0,0 @@
#.rst:
# FindCurses
# ----------
#
# Find the curses include file and library
#
#
#
# ::
#
# CURSES_FOUND - system has Curses
# CURSES_INCLUDE_DIR - the Curses include directory
# CURSES_LIBRARIES - The libraries needed to use Curses
# CURSES_HAVE_CURSES_H - true if curses.h is available
# CURSES_HAVE_NCURSES_H - true if ncurses.h is available
# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available
# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available
# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake
#
#
#
# Set CURSES_NEED_NCURSES to TRUE before the find_package() command if
# NCurses functionality is required.
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_library(CURSES_CURSES_LIBRARY NAMES curses )
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
set(CURSES_USE_NCURSES FALSE)
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
set(CURSES_USE_NCURSES TRUE)
endif()
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
# cygwin ncurses stopped providing curses.h symlinks see above
# message. Cygwin is an ncurses package, so force ncurses on
# cygwin if the curses.h is missing
if(CYGWIN)
if(NOT EXISTS /usr/include/curses.h)
set(CURSES_USE_NCURSES TRUE)
endif()
endif()
# Not sure the logic is correct here.
# If NCurses is required, use the function wsyncup() to check if the library
# has NCurses functionality (at least this is where it breaks on NetBSD).
# If wsyncup is in curses, use this one.
# If not, try to find ncurses and check if this has the symbol.
# Once the ncurses library is found, search the ncurses.h header first, but
# some web pages also say that even with ncurses there is not always a ncurses.h:
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
# So at first try ncurses.h, if not found, try to find curses.h under the same
# prefix as the library was found, if still not found, try curses.h with the
# default search paths.
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
if( CURSES_NCURSES_HAS_WSYNCUP)
set(CURSES_USE_NCURSES TRUE)
endif()
endif()
endif()
if(NOT CURSES_USE_NCURSES)
find_file(CURSES_HAVE_CURSES_H curses.h )
find_path(CURSES_CURSES_H_PATH curses.h )
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
# for compatibility with older FindCurses.cmake this has to be in the cache
# FORCE must not be used since this would break builds which preload a cache with these variables set
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
CACHE FILEPATH "The curses include path")
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
CACHE FILEPATH "The curses library")
else()
# we need to find ncurses
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
find_file(CURSES_HAVE_NCURSES_H ncurses.h)
find_file(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h)
find_file(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h)
find_file(CURSES_HAVE_CURSES_H curses.h
HINTS "${_cursesParentDir}/include")
find_path(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h
ncurses/curses.h)
find_path(CURSES_NCURSES_INCLUDE_PATH curses.h
HINTS "${_cursesParentDir}/include")
# for compatibility with older FindCurses.cmake this has to be in the cache
# FORCE must not be used since this would break builds which preload
# however if the value of the variable has NOTFOUND in it, then
# it is OK to force, and we need to force in order to have it work.
# a cache with these variables set
# only put ncurses include and library into
# variables if they are found
if(NOT CURSES_NCURSES_INCLUDE_PATH AND CURSES_HAVE_NCURSES_NCURSES_H)
get_filename_component(CURSES_NCURSES_INCLUDE_PATH
"${CURSES_HAVE_NCURSES_NCURSES_H}" PATH)
endif()
if(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY)
set( FORCE_IT )
if(CURSES_INCLUDE_PATH MATCHES NOTFOUND)
set(FORCE_IT FORCE)
endif()
set(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}"
CACHE FILEPATH "The curses include path" ${FORCE_IT})
set( FORCE_IT)
if(CURSES_LIBRARY MATCHES NOTFOUND)
set(FORCE_IT FORCE)
endif()
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}"
CACHE FILEPATH "The curses library" ${FORCE_IT})
endif()
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
cbreak "" CURSES_NCURSES_HAS_CBREAK)
if(NOT CURSES_NCURSES_HAS_CBREAK)
find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}")
find_library(CURSES_EXTRA_LIBRARY tinfo )
CHECK_LIBRARY_EXISTS("${CURSES_EXTRA_LIBRARY}"
cbreak "" CURSES_TINFO_HAS_CBREAK)
endif()
endif()
if (NOT CURSES_TINFO_HAS_CBREAK)
find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}")
find_library(CURSES_EXTRA_LIBRARY cur_colr )
endif()
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
find_library(CURSES_FORM_LIBRARY form )
# for compatibility with older FindCurses.cmake this has to be in the cache
# FORCE must not be used since this would break builds which preload a cache
# with these variables set
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
CACHE FILEPATH "The curses form library")
# Need to provide the *_LIBRARIES
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
if(CURSES_EXTRA_LIBRARY)
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
endif()
if(CURSES_FORM_LIBRARY)
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
endif()
# Proper name is *_INCLUDE_DIR
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
CURSES_LIBRARY CURSES_INCLUDE_PATH)
mark_as_advanced(
CURSES_INCLUDE_PATH
CURSES_LIBRARY
CURSES_CURSES_INCLUDE_PATH
CURSES_CURSES_LIBRARY
CURSES_NCURSES_INCLUDE_PATH
CURSES_NCURSES_LIBRARY
CURSES_EXTRA_LIBRARY
FORM_LIBRARY
CURSES_LIBRARIES
CURSES_INCLUDE_DIR
CURSES_CURSES_HAS_WSYNCUP
CURSES_NCURSES_HAS_WSYNCUP
CURSES_NCURSES_HAS_CBREAK
CURSES_TINFO_HAS_CBREAK
)
-53
View File
@@ -1,53 +0,0 @@
# - Try to find Iconv
# Once done this will define
#
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
#
include(CheckCXXSourceCompiles)
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
SET(ICONV_FIND_QUIETLY TRUE)
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
SET(ICONV_FOUND TRUE)
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
IF(ICONV_FOUND)
check_cxx_source_compiles("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
ENDIF(ICONV_FOUND)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Iconv DEFAULT_MSG
ICONV_LIBRARIES ICONV_INCLUDE_DIR)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_SECOND_ARGUMENT_IS_CONST
)
-45
View File
@@ -1,45 +0,0 @@
# Try to find Libintl functionality
# Once done this will define
#
# LIBINTL_FOUND - system has Libintl
# LIBINTL_INCLUDE_DIR - Libintl include directory
# LIBINTL_LIBRARIES - Libraries needed to use Libintl
#
# TODO: This will enable translations only if Gettext functionality is
# present in libc. Must have more robust system for release, where Gettext
# functionality can also reside in standalone Gettext library, or the one
# embedded within kdelibs (cf. gettext.m4 from Gettext source).
# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net>
# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
set(Libintl_FIND_QUIETLY TRUE)
endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
find_path(LIBINTL_INCLUDE_DIR libintl.h)
set(LIBINTL_LIB_FOUND FALSE)
if(LIBINTL_INCLUDE_DIR)
include(CheckFunctionExists)
check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)
if (LIBINTL_LIBC_HAS_DGETTEXT)
set(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
else (LIBINTL_LIBC_HAS_DGETTEXT)
find_library(LIBINTL_LIBRARIES intl libintl libintl-8)
if(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
endif(LIBINTL_LIBRARIES)
endif (LIBINTL_LIBC_HAS_DGETTEXT)
endif(LIBINTL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_LIBRARIES LIBINTL_INCLUDE_DIR)
mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)
@@ -1,351 +0,0 @@
#.rst:
# FindPackageHandleStandardArgs
# -----------------------------
#
#
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
#
# This function is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED, QUIET and version-related arguments to
# find_package(). It also sets the <packagename>_FOUND variable. The
# package is considered found if all variables <var1>... listed contain
# valid results, e.g. valid filepaths.
#
# There are two modes of this function. The first argument in both
# modes is the name of the Find-module where it is called (in original
# casing).
#
# The first simple mode looks like this:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
#
# If the variables <var1> to <varN> are all valid, then
# <UPPERCASED_NAME>_FOUND will be set to TRUE. If DEFAULT_MSG is given
# as second argument, then the function will generate itself useful
# success and error messages. You can also supply a custom error
# message for the failure case. This is not recommended.
#
# The second mode is more powerful and also supports version checking:
#
# ::
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR <resultVar>]
# [REQUIRED_VARS <var1>...<varN>]
# [VERSION_VAR <versionvar>]
# [HANDLE_COMPONENTS]
# [CONFIG_MODE]
# [FAIL_MESSAGE "Custom failure message"] )
#
#
#
# In this mode, the name of the result-variable can be set either to
# either <UPPERCASED_NAME>_FOUND or <OriginalCase_Name>_FOUND using the
# FOUND_VAR option. Other names for the result-variable are not
# allowed. So for a Find-module named FindFooBar.cmake, the two
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
# to use the original case version. If the FOUND_VAR option is not
# used, the default is <UPPERCASED_NAME>_FOUND.
#
# As in the simple mode, if <var1> through <varN> are all valid,
# <packagename>_FOUND will be set to TRUE. After REQUIRED_VARS the
# variables which are required for this package are listed. Following
# VERSION_VAR the name of the variable can be specified which holds the
# version of the package which has been found. If this is done, this
# version will be checked against the (potentially) specified required
# version used in the find_package() call. The EXACT keyword is also
# handled. The default messages include information about the required
# version and the version which has been actually found, both if the
# version is ok or not. If the package supports components, use the
# HANDLE_COMPONENTS option to enable handling them. In this case,
# find_package_handle_standard_args() will report which components have
# been found and which are missing, and the <packagename>_FOUND variable
# will be set to FALSE if any of the required components (i.e. not the
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
# set to <NAME>_VERSION and the macro will automatically check whether
# the Config module was found. Via FAIL_MESSAGE a custom failure
# message can be specified, if this is not used, the default message
# will be displayed.
#
# Example for mode 1:
#
# ::
#
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
#
#
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
# TRUE. If it is not found and REQUIRED was used, it fails with
# FATAL_ERROR, independent whether QUIET was used or not. If it is
# found, success will be reported, including the content of <var1>. On
# repeated Cmake runs, the same message won't be printed again.
#
# Example for mode 2:
#
# ::
#
# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
# VERSION_VAR LibXslt_VERSION_STRING)
#
# In this case, LibXslt is considered to be found if the variable(s)
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
# LibXslt_FOUND . Also the version of LibXslt will be checked by using
# the version contained in LibXslt_VERSION_STRING. Since no
# FAIL_MESSAGE is given, the default messages will be printed.
#
# Another example for mode 2:
#
# ::
#
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
#
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
# NO_MODULE) and adds an additional search directory for automoc4. Here
# the result will be stored in AUTOMOC4_FOUND. The following
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
# success/error message.
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
# internal helper macro
macro(_FPHSA_FAILURE_MESSAGE _msg)
if (${_NAME}_FIND_REQUIRED)
message(FATAL_ERROR "${_msg}")
else ()
if (NOT ${_NAME}_FIND_QUIETLY)
message(STATUS "${_msg}")
endif ()
endif ()
endmacro()
# internal helper macro to generate the failure message when used in CONFIG_MODE:
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
if(${_NAME}_CONFIG)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
else()
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
# List them all in the error message:
if(${_NAME}_CONSIDERED_CONFIGS)
set(configsText "")
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
math(EXPR configsCount "${configsCount} - 1")
foreach(currentConfigIndex RANGE ${configsCount})
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
set(configsText "${configsText} ${filename} (version ${version})\n")
endforeach()
if (${_NAME}_NOT_FOUND_MESSAGE)
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
endif()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
else()
# Simple case: No Config-file was found at all:
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
endif()
endif()
endmacro()
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
# new extended or in the "old" mode:
set(options CONFIG_MODE HANDLE_COMPONENTS)
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
set(multiValueArgs REQUIRED_VARS)
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
if(${INDEX} EQUAL -1)
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
set(FPHSA_REQUIRED_VARS ${ARGN})
set(FPHSA_VERSION_VAR)
else()
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
if(FPHSA_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT FPHSA_FAIL_MESSAGE)
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
endif()
endif()
# now that we collected all arguments, process them
if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
endif()
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
# when it successfully found the config-file, including version checking:
if(FPHSA_CONFIG_MODE)
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
endif()
if(NOT FPHSA_REQUIRED_VARS)
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
endif()
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
string(TOUPPER ${_NAME} _NAME_UPPER)
string(TOLOWER ${_NAME} _NAME_LOWER)
if(FPHSA_FOUND_VAR)
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
else()
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
endif()
else()
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
endif()
# collect all variables which were not found, so they can be printed, so the
# user knows better what went wrong (#6375)
set(MISSING_VARS "")
set(DETAILS "")
# check if all passed variables are valid
unset(${_FOUND_VAR})
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
if(NOT ${_CURRENT_VAR})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
else()
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
endif()
endforeach()
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
set(${_FOUND_VAR} TRUE)
endif()
# component handling
unset(FOUND_COMPONENTS_MSG)
unset(MISSING_COMPONENTS_MSG)
if(FPHSA_HANDLE_COMPONENTS)
foreach(comp ${${_NAME}_FIND_COMPONENTS})
if(${_NAME}_${comp}_FOUND)
if(NOT DEFINED FOUND_COMPONENTS_MSG)
set(FOUND_COMPONENTS_MSG "found components: ")
endif()
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
else()
if(NOT DEFINED MISSING_COMPONENTS_MSG)
set(MISSING_COMPONENTS_MSG "missing components: ")
endif()
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
if(${_NAME}_FIND_REQUIRED_${comp})
set(${_FOUND_VAR} FALSE)
set(MISSING_VARS "${MISSING_VARS} ${comp}")
endif()
endif()
endforeach()
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
endif()
# version handling:
set(VERSION_MSG "")
set(VERSION_OK TRUE)
set(VERSION ${${FPHSA_VERSION_VAR}} )
if (${_NAME}_FIND_VERSION)
if(VERSION)
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
endif ()
else() # minimum version specified:
if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
set(VERSION_OK FALSE)
else ()
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
endif ()
endif()
else()
# if the package was not found, but a version was given, add that to the output:
if(${_NAME}_FIND_VERSION_EXACT)
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
else()
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
endif()
endif()
else ()
if(VERSION)
set(VERSION_MSG "(found version \"${VERSION}\")")
endif()
endif ()
if(VERSION_OK)
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
else()
set(${_FOUND_VAR} FALSE)
endif()
# print the result:
if (${_FOUND_VAR})
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
else ()
if(FPHSA_CONFIG_MODE)
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
else()
if(NOT VERSION_OK)
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
else()
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
endif()
endif()
endif ()
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
endfunction()
-57
View File
@@ -1,57 +0,0 @@
#.rst:
# FindPackageMessage
# ------------------
#
#
#
# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
#
# This macro is intended to be used in FindXXX.cmake modules files. It
# will print a message once for each unique find result. This is useful
# for telling the user where a package was found. The first argument
# specifies the name (XXX) of the package. The second argument
# specifies the message to display. The third argument lists details
# about the find result so that if they change the message will be
# displayed again. The macro also obeys the QUIET argument to the
# find_package command.
#
# Example:
#
# ::
#
# if(X11_FOUND)
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
# else()
# ...
# endif()
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
function(FIND_PACKAGE_MESSAGE pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
string(REGEX REPLACE "[\n]" "" details "${details}")
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
# The message has not yet been printed.
message(STATUS "${msg}")
# Save the find details in the cache to avoid printing the same
# message again.
set("${DETAILS_VAR}" "${details}"
CACHE INTERNAL "Details about finding ${pkg}")
endif()
endif()
endfunction()
-186
View File
@@ -1,186 +0,0 @@
#.rst:
# FindSDL2
# -------
#
# Locate SDL2 library
#
# This module defines
#
# ::
#
# SDL2_LIBRARY, the name of the library to link against
# SDL2_FOUND, if false, do not try to link to SDL
# SDL2_INCLUDE_DIR, where to find SDL.h
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
#
#
#
# This module responds to the flag:
#
# ::
#
# SDL2_BUILDING_LIBRARY
# If this is defined, then no SDL2_main will be linked in because
# only applications need main().
# Otherwise, it is assumed you are building an application and this
# module will attempt to locate and set the proper link flags
# as part of the returned SDL2_LIBRARY variable.
#
#
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDLmain which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
#
#
#
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
# value as appropriate. These values are used to generate the final
# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
# does not get created.
#
#
#
# $SDLDIR is an environment variable that would correspond to the
# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
#
# Modified by Eric Wing. Added code to assist with automated building
# by using environmental variables and providing a more
# controlled/consistent search behavior. Added new modifications to
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL
# guidelines. Added a search for SDLmain which is needed by some
# platforms. Added a search for threads which is needed by some
# platforms. Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of SDL2_LIBRARY to
# override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
#
# Note that the header path has changed from SDL/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention is #include
# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
# because not all systems place things in SDL/ (see FreeBSD).
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
find_path(SDL2_INCLUDE_DIR SDL.h
HINTS
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDLDIR}
include/SDL2 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
find_library(SDL2_LIBRARY_TEMP
NAMES SDL2
HINTS
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
)
if(NOT SDL2_BUILDING_LIBRARY)
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDLmain for compatibility even though they don't
# necessarily need it.
find_library(SDL2MAIN_LIBRARY
NAMES SDL2main
HINTS
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
PATHS
/sw
/opt/local
/opt/csw
/opt
)
endif()
endif()
# SDL may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
if(NOT APPLE)
find_package(Threads)
endif()
# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
if(MINGW)
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
endif()
if(SDL2_LIBRARY_TEMP)
# For SDLmain
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
list(FIND SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
if(_SDL2_MAIN_INDEX EQUAL -1)
set(SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
endif()
unset(_SDL2_MAIN_INDEX)
endif()
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
if(APPLE)
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
endif()
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
if(NOT APPLE)
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
endif()
# For MinGW library
if(MINGW)
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
endif()
# Set the final string here so the GUI reflects the final state.
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
VERSION_VAR SDL2_VERSION_STRING)
-97
View File
@@ -1,97 +0,0 @@
#.rst:
# FindSDL2_image
# -------------
#
# Locate SDL2_image library
#
# This module defines:
#
# ::
#
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
# SDL2_IMAGE_FOUND, if false, do not try to link against
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the
# version of SDL2_image
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
# SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
# SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
#
#
#
# $SDL2DIR is an environment variable that would correspond to the
# ./configure --prefix=$SDL2DIR used in building SDL2.
#
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
entry initialized from old variable name")
endif()
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDL2DIR}
include/SDL2 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
initialized from old variable name")
endif()
find_library(SDL2_IMAGE_LIBRARY
NAMES SDL2_image
HINTS
ENV SDL2IMAGEDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
)
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
# for backward compatibility
set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
-97
View File
@@ -1,97 +0,0 @@
#.rst:
# FindSDL2_mixer
# -------------
#
# Locate SDL2_mixer library
#
# This module defines:
#
# ::
#
# SDL2_MIXER_LIBRARIES, the name of the library to link against
# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
# SDL2_MIXER_FOUND, if false, do not try to link against
# SDL2_MIXER_VERSION_STRING - human-readable string containing the
# version of SDL2_mixer
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
# SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
# SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
#
#
#
# $SDL2DIR is an environment variable that would correspond to the
# ./configure --prefix=$SDL2DIR used in building SDL2.
#
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
entry initialized from old variable name")
endif()
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
HINTS
ENV SDL2MIXERDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDL2DIR}
include/SDL2 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
initialized from old variable name")
endif()
find_library(SDL2_MIXER_LIBRARY
NAMES SDL2_mixer
HINTS
ENV SDL2MIXERDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
)
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
VERSION_VAR SDL2_MIXER_VERSION_STRING)
# for backward compatibility
set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
-96
View File
@@ -1,96 +0,0 @@
#.rst:
# FindSDL2_ttf
# -----------
#
# Locate SDL2_ttf library
#
# This module defines:
#
# ::
#
# SDL2_TTF_LIBRARIES, the name of the library to link against
# SDL2_TTF_INCLUDE_DIRS, where to find the headers
# SDL2_TTF_FOUND, if false, do not try to link against
# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
#
#
#
# For backward compatibility the following variables are also set:
#
# ::
#
# SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
# SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
# SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
#
#
#
# $SDL2DIR is an environment variable that would correspond to the
# ./configure --prefix=$SDL2DIR used in building SDL2.
#
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
# Copyright 2012 Benjamin Eikel
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
entry initialized from old variable name")
endif()
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
HINTS
ENV SDL2TTFDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES SDL2
# path suffixes to search inside ENV{SDL2DIR}
include/SDL2 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VC_LIB_PATH_SUFFIX lib/x64)
else()
set(VC_LIB_PATH_SUFFIX lib/x86)
endif()
if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
initialized from old variable name")
endif()
find_library(SDL2_TTF_LIBRARY
NAMES SDL2_ttf
HINTS
ENV SDL2TTFDIR
ENV SDL2DIR
${CMAKE_SOURCE_DIR}/dep/
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
)
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
VERSION_VAR SDL2_TTF_VERSION_STRING)
# for backward compatibility
set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
@@ -1,130 +0,0 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
@@ -1,41 +0,0 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()
+1
View File
@@ -0,0 +1 @@
cataclysmdda.org
-25
View File
@@ -1,25 +0,0 @@
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
1. Assume other participants are posting in good faith, even if you disagree with what they say.
2. Make an effort to treat other participants with respect.
1. Do not take a harsh tone towards other participants, and especially don't make personal attacks against them.
2. Recognize that criticism of your statements is not a personal attack on you.
3. Avoid statements about the presumed typical desires, capabilities or actions of some demographic group.
3. Be especially kind to other contributors when saying they made a mistake.
4. Don't argue unceasingly for your preferred course of action when a decision for some other course has already been made.
5. If other participants complain about the way you express your ideas, please make an effort to cater to them.
6. Don't raise unrelated political issues.
7. If you feel these standards are being violated, please alert the project lead Kevin Granade at kevin.granade@gmail.com
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][CoC homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][CoC version] and the [GNU Kind Communications Guidelines][GKCG homepage].
[CoC homepage]: http://contributor-covenant.org
[CoC version]: http://contributor-covenant.org/version/1/4/
[GKCG homepage]: https://www.gnu.org/philosophy/kind-communication.html
-84
View File
@@ -1,84 +0,0 @@
{
"build_systems":
[
{
"cmd":
[
"make",
"USE_HOME_DIR=1",
"CLANG=1",
"CCACHE=1",
"RELEASE=1"
],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"name": "make RELEASE",
"working_dir": "${folder:${project_path:${file_path}}}"
},
{
"cmd":
[
"make",
"USE_HOME_DIR=1",
"CLANG=1",
"CCACHE=1"
],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"name": "make",
"working_dir": "${folder:${project_path:${file_path}}}"
},
{
"cmd":
[
"make",
"USE_HOME_DIR=1",
"CLANG=1",
"CCACHE=1",
"TILES=1"
],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"name": "make TILES",
"working_dir": "${folder:${project_path:${file_path}}}"
},
{
"cmd":
[
"make",
"USE_HOME_DIR=1",
"CLANG=1",
"CCACHE=1",
"TILES=1",
"RELEASE=1"
],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"name": "make RELEASE TILES",
"working_dir": "${folder:${project_path:${file_path}}}"
}
],
"folders":
[
{
"folder_exclude_patterns":
[
"Cataclysm.app"
],
"path": "."
},
{
"path": "~/.cataclysm-dda"
},
{
"path": "~/Library/Application Support/Cataclysm"
}
],
"settings":
{
"AStyleFormatter":
{
"options_c++":
{
"additional_options_file": ".astylerc",
"use_only_additional_options": true
}
}
}
}
-304
View File
@@ -1,304 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Cataclysm" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DRELEASE=1" />
</Compiler>
</Target>
<Target title="Release (Localized)">
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/ReleaseLocalized/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DLOCALIZE=1" />
<Add option="-DRELEASE=1" />
<Add directory="WinDepend/include" />
</Compiler>
<Linker>
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Release (SDL)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/ReleaseSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DTILES=1" />
<Add option="-DRELEASE=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Release (SDL, Sound)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/ReleaseSoundSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DTILES=1" />
<Add option="-DSDL_SOUND=1" />
<Add option="-DRELEASE=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add library="libSDL2_mixer.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Release (SDL, Localized)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/ReleaseLocalizedSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DLOCALIZE=1" />
<Add option="-DTILES=1" />
<Add option="-DRELEASE=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Release (SDL, Loc, Sound)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/ReleaseLocalizedSoundSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-Os" />
<Add option="-O2" />
<Add option="-DLOCALIZE=1" />
<Add option="-DTILES=1" />
<Add option="-DSDL_SOUND=1" />
<Add option="-DRELEASE=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add library="libSDL2_mixer.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Debug">
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg -g" />
</Compiler>
<Linker>
<Add option="-pg -lgmon" />
</Linker>
</Target>
<Target title="Debug (Localized)">
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/DebugLocalized/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
<Add option="-DLOCALIZE=1" />
<Add directory="WinDepend/include" />
</Compiler>
<Linker>
<Add option="-pg" />
<Add option="-lgmon" />
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Debug (SDL)">
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/DebugSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
<Add option="-DTILES=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add option="-pg" />
<Add option="-lgmon" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Debug (SDL, Sound)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/DebugSoundSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
<Add option="-DTILES=1" />
<Add option="-DSDL_SOUND=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add option="-pg" />
<Add option="-lgmon" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add library="libSDL2_mixer.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Debug (SDL, Localized)">
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/DebugLocalizedSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
<Add option="-DLOCALIZE=1" />
<Add option="-DTILES=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add option="-pg" />
<Add option="-lgmon" />
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
<Target title="Debug (SDL, Loc, Sound)">
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
<Option object_output="obj/DebugLocalizedSoundSDL/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
<Add option="-DLOCALIZE=1" />
<Add option="-DTILES=1" />
<Add option="-DSDL_SOUND=1" />
<Add directory="WinDepend/include" />
<Add directory="WinDepend/include/SDL2" />
</Compiler>
<Linker>
<Add option="-pg" />
<Add option="-lgmon" />
<Add library="libintl.dll.a" />
<Add library="libiconv.dll.a" />
<Add library="libSDL2.dll.a" />
<Add library="libSDL2main.a" />
<Add library="libSDL2_ttf.dll.a" />
<Add library="libSDL2_image.dll.a" />
<Add library="libSDL2_mixer.dll.a" />
<Add directory="WinDepend/lib" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wextra" />
<Add option="-Wall" />
<Add option="-std=c++14" />
<Add option="-DCB_BUILD" />
<Add option="-D_WINDOWS" />
<Add option="-D_MINGW" />
<Add option="-D_WIN32" />
<Add option="-D__MINGW__" />
</Compiler>
<Linker>
<Add option="-Wl,-stack,12000000,-subsystem,windows" />
<Add option="-static" />
<Add library="gdi32" />
<Add library="winmm" />
</Linker>
<ExtraCommands>
<Add before="cmd /c git --version || echo &apos;git&apos; command not found!" />
<Add before="cmd /c git describe --tags --always --dirty &gt; version.tmp || echo no-git&gt; version.tmp" />
<Add before='cmd /c for /F &quot;tokens=*&quot; %%i in (version.tmp) do echo #define VERSION &quot;%%i&quot; &gt; src/version.h' />
<Add before="cmd /c del version.tmp" />
<Mode after="always" />
</ExtraCommands>
<UnitsGlob directory="src" recursive="0" />
<Unit filename="src/resource.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Extensions>
<code_completion />
<debugger />
<envvars />
<DoxyBlocks>
<comment_style block="0" line="0" />
<doxyfile_project />
<doxyfile_build />
<doxyfile_warnings />
<doxyfile_output />
<doxyfile_dot />
<general />
</DoxyBlocks>
</Extensions>
</Project>
</CodeBlocks_project_file>
+28
View File
@@ -0,0 +1,28 @@
source "https://rubygems.org"
ruby RUBY_VERSION
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "3.4.2"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
-55
View File
@@ -1,55 +0,0 @@
# Issues
## How to create new issues properly
GitHub issues are used for everything from bug reporting to suggesting long-term ideas. You can make everything run much smoother by following some simple rules.
### Rule zero
Always give your issue a meaningful title as this is the first thing anyone will see.
Note: `[CR]` and `[WIP]` "tags" are meaningful only for PRs. All open issues by definition are request for comments and work in progress.
### Bug reports
Before you submit a bug always search the current list of issues to see if it has been reported already.
Your bug report has to include:
- On what OS did you experience the problem (Windows, Linux, OS X etc.)
- What version were you playing:
- Tiles or Curses (text-based)
- Version string (preferably full version e.g. "0.C-4547-g3f1c109", or Jenkins build number e.g. 3245)
- Description of the problem written in a way that enables anyone to try and recreate it
Your bug report may include:
- Screenshot(s) as some things are best explained visually
- Save file (e.g. link to a dropbox upload)
Bonus points for:
- Checking if the bug exists under latest experimental build
- Checking if it is OS specific
The OS and CDDA version are very important - with the pace of changes here it is possible the bug you have encountered has already been fixed. After that reproducibility is the key, so write your report with all the necessary details.
### Enhancements and addition ideas
We have hundreds of issues open - most of them are ideas and suggestions. If you have a general idea or anything that can't be easily described in terms of *current* code changes you'd be better off suggesting it in the appropriate section of [the forum](https://discourse.cataclysmdda.org/). You'll also get much broader exposure for your idea there. After developing a polished idea on the forum, it should be easy to make a GitHub issue for it.
Please first search if something like what you have on mind has been already proposed. If so, feel free to join the discussion! If your idea is related but sufficiently different, open a new issue and refer to the older discussion (use GitHub's `#issue_number` reference system).
Remember to take part in the discussion of your suggestions.
### Questions
You should direct your questions to the forum or ask on IRC. You should also read the included documentation and additional text files, e.g. [COMPILING.md](doc/COMPILING/COMPILING.md) if you have problems building.
## Bounties
Placing a bounty *does not* necessarily mean that change will be incorporated into the main game. Please coordinate in the issue you intend to place a bounty on to determine if it is a change the project will accept, and keep in mind that placing a bounty will not confer special status on the issue. A good way of thinking about bounties is as encouragement for contributors to work on a particular issue, and certainly not as "paying for features".
## Issue resolution
We do not assign people to issues. If you plan to work on a bug fix or a validated idea feel free to just comment about that. Actual PRs are of much greater value than any assignments. In general the first correct PR about something will be the PR that will get merged, but remember: we are using Git - you can collaborate with someone else easily by sending them patches or PRs against their PR branch.
-97
View File
@@ -1,97 +0,0 @@
Copyright (c) 2019 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".
Copyright (c) 2011 Tilman Blumenbach,
with Reserved Font Name "Terminus (TTF)".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
-45
View File
@@ -1,45 +0,0 @@
Cataclysm is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
GNU Unifont (data/font/unifont.ttf) is licensed under GNU General Public License v2+ with the GNU font embedding exception. Visit http://unifoundry.com/LICENSE.txt for details.
Terminus Font (data/font/terminus.ttf) is licensed under the SIL Open Font License (see LICENSE-OFL-Terminus-Font.txt).
CATCH unit-test framework (tests/catch/catch.hpp) is licensed under the Boost Software License. Visit https://github.com/philsquared/Catch/blob/master/LICENSE.txt to read the license.
PLF List and PLF Colony (src/list.h, src/colony.h) are licensed under the zLib license (https://www.zlib.net/zlib_license.html).
getpost (tools/json_tools/format/getpost.h) is licensed under the MIT license, see file for text of license.
libintl-lite is licensed under Boost Software License 1.0. Visit https://www.boost.org/users/license.html to read the license.
libbacktrace is licensed under a BSD license (https://github.com/ianlancetaylor/libbacktrace/blob/master/LICENSE). The full license text is as follows:
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# (1) Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# (2) Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# (3) The name of the author may not be used to
# endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-1239
View File
File diff suppressed because it is too large Load Diff
-102
View File
@@ -1,102 +0,0 @@
# Cataclysm: Dark Days Ahead
Cataclysm: Dark Days Ahead is a turn-based survival game set in a post-apocalyptic world. While some have described it as a "zombie game", there is far more to Cataclysm than that. Struggle to survive in a harsh, persistent, procedurally generated world. Scavenge the remnants of a dead civilization for food, equipment, or, if you are lucky, a vehicle with a full tank of gas to get you the hell out of Dodge. Fight to defeat or escape from a wide variety of powerful monstrosities, from zombies to giant insects to killer robots and things far stranger and deadlier, and against the others like yourself, who want what you have...
<a href="https://repology.org/project/cataclysm-dda/versions">
<img src="https://repology.org/badge/vertical-allrepos/cataclysm-dda.svg" alt="Packaging Status" align="right">
</a>
[![Build Status](https://travis-ci.org/CleverRaven/Cataclysm-DDA.svg?branch=master)](https://travis-ci.org/CleverRaven/Cataclysm-DDA)
[![Coverage Status](https://coveralls.io/repos/github/CleverRaven/Cataclysm-DDA/badge.svg?branch=master)](https://coveralls.io/github/CleverRaven/Cataclysm-DDA?branch=master)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/CleverRaven/Cataclysm-DDA.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/CleverRaven/Cataclysm-DDA/context:cpp)
[![Open Source Helpers](https://www.codetriage.com/cleverraven/cataclysm-dda/badges/users.svg)](https://www.codetriage.com/cleverraven/cataclysm-dda)
[![Commit Activity](https://img.shields.io/github/commit-activity/m/CleverRaven/Cataclysm-DDA)](https://github.com/CleverRaven/Cataclysm-DDA/graphs/contributors)
[![Lines of Code](https://tokei.rs/b1/github/CleverRaven/Cataclysm-DDA?category=code)](https://github.com/XAMPPRocky/tokei)
## Downloads
**Releases** - [Stable](https://cataclysmdda.org/releases/) | [Experimental](https://cataclysmdda.org/experimental/)
**Source** - The source can be downloaded as a [.zip archive](https://github.com/CleverRaven/Cataclysm-DDA/archive/master.zip), or cloned from our [GitHub repo](https://github.com/CleverRaven/Cataclysm-DDA/).
### Packaging status
#### Arch Linux
Ncurses and tiles versions are available in the [community repo](https://www.archlinux.org/packages/?q=cataclysm-dda).
`sudo pacman -S cataclysm-dda`
#### Fedora
Ncurses and tiles versions are available in the [official repos](https://src.fedoraproject.org/rpms/cataclysm-dda).
`sudo dnf install cataclysm-dda`
#### Debian / Ubuntu
Ncurses and tiles versions are available in the [official repos](https://tracker.debian.org/pkg/cataclysm-dda).
`sudo apt install cataclysm-dda-curses cataclysm-dda-sdl`
## Compile
Please read [COMPILING.md](doc/COMPILING/COMPILING.md) - it covers general information and more specific recipes for Linux, OS X, Windows and BSD. See [COMPILER_SUPPORT.md](doc/COMPILING/COMPILER_SUPPORT.md) for details on which compilers we support. And you can always dig for more information in [doc/](https://github.com/CleverRaven/Cataclysm-DDA/tree/master/doc).
We also have the following build guides:
* Building on Windows with `MSYS2` at [COMPILING-MSYS.md](doc/COMPILING/COMPILING-MSYS.md)
* Building on Windows with `vcpkg` at [COMPILING-VS-VCPKG.md](doc/COMPILING/COMPILING-VS-VCPKG.md)
* Building with `cmake` at [COMPILING-CMAKE.md](doc/COMPILING/COMPILING-CMAKE.md) (*unofficial guide*)
## Contribute
Cataclysm: Dark Days Ahead is the result of contributions from over 1000 volunteers under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
Some code distributed with the project is not part of the project and is released under different software licenses; the files covered by different software licenses have their own license notices.
[<img src="https://www.bountysource.com/badge/tracker?tracker_id=146201" alt="Bountysource" align="right">](https://www.bountysource.com/trackers/146201-clever-raven-cataclysm-dda?utm_source=146201&utm_medium=shield&utm_campaign=TRACKER_BADGE)
Please see [CONTRIBUTING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/.github/CONTRIBUTING.md) for details.
## Community
Forums:
https://discourse.cataclysmdda.org
Wiki:
http://cddawiki.chezzo.com/cdda_wiki/index.php
GitHub repo:
https://github.com/CleverRaven/Cataclysm-DDA
IRC:
`irc.freenode.net` ; `#CataclysmDDA`
http://webchat.freenode.net/?channels=#CataclysmDDA
Official Discord:
https://discord.gg/jFEc7Yp
## Frequently Asked Questions
#### Is there a tutorial?
Yes, you can find the tutorial in the **Special** menu at the main menu (be aware that due to many code changes the tutorial may not function). You can also access documentation in-game via the `?` key.
#### How can I change the key bindings?
Press the `?` key, followed by the `1` key to see the full list of key commands. Press the `+` key to add a key binding, select which action with the corresponding letter key `a-w`, and then the key you wish to assign to that action.
#### How can I start a new world?
**World** on the main menu will generate a fresh world for you. Select **Create World**.
#### I've found a bug. What should I do?
Please submit an issue on [our GitHub page](https://github.com/CleverRaven/Cataclysm-DDA/issues/) using [bug report template](https://github.com/CleverRaven/Cataclysm-DDA/issues/new?template=bug_report.md). If you're not able to, send an email to `kevin.granade@gmail.com`.
#### I would like to make a suggestion. What should I do?
Please submit an issue on [our GitHub page](https://github.com/CleverRaven/Cataclysm-DDA/issues/) using [feature request template](https://github.com/CleverRaven/Cataclysm-DDA/issues/new?template=feature_request.md).
You can also submit your suggestions or vote for existing suggestions on [our FeatHub page](https://feathub.com/CleverRaven/Cataclysm-DDA). Most voted suggestions are:
[![Feature Requests](https://feathub.com/CleverRaven/Cataclysm-DDA?format=svg)](https://feathub.com/CleverRaven/Cataclysm-DDA)
-65
View File
@@ -1,65 +0,0 @@
The undersigned release all their contributions to the Cataclysm project under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
Kevin Granade <kevin.granade@gmail.com>
Matthew Moffatt <TheDarklingWolf@gmail.com>
origamiwolf <origamiwolf@gmail.com>
Frank Huard <veryinky@gmail.com>
daftfad <daftfjord@gmail.com>
ZwodahS <ericnjf@gmail.com>
Williham "Wito" Totland <williham.totland@gmail.com>
Zach Morgan <zpmorgan@gmail.com>
Livingstone <minexal@gmail.com>
Ethan "Soron" Kaminski <ethan.kaminski@gmail.com>
Soyweiser <soyweiser@gmail.com>
Jason Gilbert <0jason.gilbert@gmail.com>
Charlie Nolan (FunnyMan3595) <funnyman3595@gmail.com>
uzername (some_name) <ivanpost777@gmail.com>
Christian Buskirk (i2amroy) <i2amroy@gmail.com>
Kevin McKayven (GlyphGryph) <glyphgryph@gmail.com>
Ozone <satori.jj@gmail.com>
Herbert Jones <jones.herbert@gmail.com>
Justin "MacrosBlackD" Drury <macrosblackd@gmail.com>
AtomicDryad <fnord@fnord> / <atomicdryad@gmail.com>
Izicata
Voker57 <voker57@gmail.com>
Tommy <yobbobanana@gmx.com>
teh-sam
Alex Casey (Tamunshin) <tamunshin@hotmail.com>
Stevensonz <money3030@yahoo.com.>
David Holmes <dholmes@dholmes.us>
Sean McLaughlin <galenevil@hotmail.com> / <galenevil.eve@gmail.com>
Robert Sørlie (1942rob) <1942rob@gmail.com>
Angela Graves <Rivet.the.Zombie@gmail.com>
Ian Strachan <ian_e_strachan@hotmail.com>
Greg McNew <gmcnew@gmail.com>
NaturesWitness <natureswitness@gmail.com>
CodeHero <codehero@nerdpol.ch>
tasetase "Tase" <tase on irc.freenode.net>
Barry Peddycord III <ishara@isharacomix.org>
Vidar Engh Skaugen <vidarsk@gmail.com>
Brandon Bergren (Bdragon) <bdragon@rtk0.net> / <git@bdragon.rtk0.net>
Henrik "Tivec" Bergvin <henrik@bergvin.com>
FryCarson <frycarson@gmail.com>
TranquilMarmot (Nate Moore) <nate272@gmail.com>
Stéphane Travostino <stephane.travostino@gmail.com>
Jeremy Osborne <jeremywosborne@gmail.com>
David "Davek" Keaton <keaton.david@gmail.com>
Piotr S. Staszewski (drbig) <p.staszewski@gmail.com>
Donnie "Desrik" McNabb <koderkore@gmail.com>
Christian R. Byrne <christianbyrne2012@gmail.com>
Dmitry "illi-kun" Serov <D.E.Serov@gmail.com>
Karl Parakenings (karlnp) <karl.parakenings@gmail.com>
Rob Palkowski <dopeghoti@gmail.com>
Zaweri Runewright <mrampuja@gmail.com>
Cliffs Dover <cliffs@dancingbottle.com>
Sven-Hendrik "svenstaro" Haase <svenstaro@gmail.com>
Nick Owens <mischief@offblast.org>
Brett Dong <brett.browning.dong@gmail.com>
Barry Gackle <bdgackle@gmail.com>
BorkBorkGoesTheCode <imreallytoolazy@protonmail.com>
Patrik Stridvall <patrik@stridvall.se>
Ryan Schneider (RadHazard) <rslego@gmail.com>
Paul Bransford (draeath) <draeath@gmail.com>
Mark Langsdorf (mlangsdorf) <mark.langsdorf@gmail.com> / <mlangsdo@redhat.com>
Ratul Saha (sahaRatul) <ratul.saha@arrakis.in> / <50.ratulsaha@gmail.com>
Davis Bray (Kaltag1925) <pdavisbray@gmail.com>
+35
View File
@@ -0,0 +1,35 @@
# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that. If you find
# yourself editing this file very often, consider using Jekyll's data files
# feature for the data you need to update frequently.
#
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
# Site settings
# These are used to personalize your new site. If you look in the HTML files,
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.
title: "Cataclysm: Dark Days Ahead"
email: kevin.granade@gmail.com
description: > # this means to ignore newlines until "baseurl:"
Official homepage of Cataclysm: Dark Days Ahead open source turn-based survival RPG development project.
Hosts downloads of game and links to community sites and resources.
baseurl: "" # the subpath of your site, e.g. /blog
url: "https://cataclysmdda.org" # the base hostname & protocol for your site, e.g. http://example.com
repository: CleverRaven/Cataclysm-DDA
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
exclude:
- Gemfile
- Gemfile.lock
- vendor
include:
- .well-known
+18
View File
@@ -0,0 +1,18 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
<meta name="description" content="{{ page.excerpt | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | absolute_url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }}" href="{{ "/feed.xml" | relative_url }}">
<link rel="me" href="https://mastodon.gamedev.place/@kevingranade">
<link rel="me" href="https://social.treehouse.systems/@itsmaya">
{% if jekyll.environment == 'production' and site.google_analytics %}
{% include google-analytics.html %}
{% endif %}
</head>
+31
View File
@@ -0,0 +1,31 @@
<header class="site-header">
<div class="wrapper">
{%- assign default_paths = site.pages | map: "path" -%}
{%- assign page_paths = site.header_pages | default: default_paths -%}
{%- assign titles_size = site.pages | map: 'title' | join: '' | size -%}
<a class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.title | escape }}</a>
{%- if titles_size > 0 -%}
<nav class="site-nav">
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger">
<span class="menu-icon">
<svg viewBox="0 0 18 15" width="18px" height="15px">
<path d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.032C17.335,0,18,0.665,18,1.484L18,1.484z M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.032C17.335,6.031,18,6.696,18,7.516L18,7.516z M18,13.516C18,14.335,17.335,15,16.516,15H1.484 C0.665,15,0,14.335,0,13.516l0,0c0-0.82,0.665-1.483,1.484-1.483h15.032C17.335,12.031,18,12.695,18,13.516L18,13.516z"/>
</svg>
</span>
</label>
<div class="trigger">
<a class="page-link" href="/">Home</a>
<a class="page-link" href="/releases/">Releases</a>
<!--<a class="page-link" href="/changes/">Changes</a>-->
<a class="page-link" href="/contributions/">Contribution Guidelines</a>
<a class="page-link" href="/donations/">Donations</a>
<a class="page-link" href="https://github.com/CleverRaven/Cataclysm-DDA/">GitHub</a>
</div>
</nav>
{%- endif -%}
</div>
</header>
-21
View File
@@ -1,21 +0,0 @@
!config/
!deps*.zip
*.iml
.cxx
.DS_Store
.externalNativeBuild
.gradle
/.idea/libraries
/.idea/workspace.xml
/app/jni/SDL2
/app/jni/SDL2_image
/app/jni/SDL2_mixer
/app/jni/SDL2_ttf
/app/jni/libhidapi
/app/jni/lua
/app/jni/mpg-123
/app/build
/app/src/main/assetsWinHost
/build
/captures
/local.properties
-406
View File
@@ -1,406 +0,0 @@
import org.gradle.internal.os.OperatingSystem;
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
//options.compilerArgs << "-Xlint:deprecation"
}
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
def buildAsApplication = !buildAsLibrary
if (buildAsApplication) {
apply plugin: 'com.android.application'
} else {
apply plugin: 'com.android.library'
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def keystorePropertiesFilename = 'keystore.properties'
if (localProperties.getProperty('keystorePropertiesFilename') != null) {
keystorePropertiesFilename = localProperties.getProperty("keystorePropertiesFilename")
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file(keystorePropertiesFilename)
if (keystorePropertiesFile.exists()) {
keystorePropertiesFile.withReader('UTF-8') { reader ->
keystoreProperties.load(reader)
}
}
def njobs = getProperty("j")
if (localProperties.getProperty('j') != null) {
njobs = localProperties.getProperty("j")
}
def localize = getProperty("localize").toBoolean()
if (localProperties.getProperty('localize') != null) {
localize = localProperties.getProperty("localize").toBoolean()
}
def abi_arm_32 = getProperty("abi_arm_32").toBoolean()
if (localProperties.getProperty('abi_arm_32') != null) {
abi_arm_32 = localProperties.getProperty("abi_arm_32").toBoolean()
}
def abi_arm_64 = getProperty("abi_arm_64").toBoolean()
if (localProperties.getProperty('abi_arm_64') != null) {
abi_arm_64 = localProperties.getProperty("abi_arm_64").toBoolean()
}
def abi_x86_32 = getProperty("abi_x86_32").toBoolean()
if (localProperties.getProperty('abi_x86_32') != null) {
abi_x86_32 = localProperties.getProperty("abi_x86_32").toBoolean()
}
def abi_x86_64 = getProperty("abi_x86_64").toBoolean()
if (localProperties.getProperty('abi_x86_64') != null) {
abi_x86_64 = localProperties.getProperty("abi_x86_64").toBoolean()
}
def deps = getProperty("deps")
if (localProperties.getProperty('deps') != null) {
deps = localProperties.getProperty("deps")
}
def override_version = getProperty("override_version")
if (localProperties.getProperty('override_version') != null) {
override_version = localProperties.getProperty("override_version")
}
def version_header_path = getProperty("version_header_path")
if (localProperties.getProperty('version_header_path') != null) {
version_header_path = localProperties.getProperty("version_header_path")
}
def override_compileSdkVersion = getProperty("override_compileSdkVersion").toInteger()
if (localProperties.getProperty('override_compileSdkVersion') != null) {
override_compileSdkVersion = localProperties.getProperty("override_compileSdkVersion").toInteger()
}
def override_minSdkVersion = getProperty("override_minSdkVersion").toInteger()
if (localProperties.getProperty('override_minSdkVersion') != null) {
override_minSdkVersion = localProperties.getProperty("override_minSdkVersion").toInteger()
}
def override_targetSdkVersion = getProperty("override_targetSdkVersion").toInteger()
if (localProperties.getProperty('override_targetSdkVersion') != null) {
override_targetSdkVersion = localProperties.getProperty("override_targetSdkVersion").toInteger()
}
def override_ndkBuildAppPlatform = getProperty("override_ndkBuildAppPlatform")
if (localProperties.getProperty('override_ndkBuildAppPlatform') != null) {
override_ndkBuildAppPlatform = localProperties.getProperty("override_ndkBuildAppPlatform")
}
println("Using [ njobs]: $njobs")
println("Using [ localize]: $localize")
println("Using [ deps]: $deps")
println("Using [ override_version]: $override_version")
println("Using [version_header_path]: $version_header_path")
println("Using [ compileSdkVersion]: $override_compileSdkVersion")
println("Using [ minSdkVersion]: $override_minSdkVersion")
println("Using [ targetSdkVersion]: $override_targetSdkVersion")
println("Using [ndkBuildAppPlatform]: $override_ndkBuildAppPlatform")
println("Using [ abi_arm_32]: $abi_arm_32")
println("Using [ abi_arm_64]: $abi_arm_64")
println("Using [ abi_x86_32]: $abi_x86_32")
println("Using [ abi_x86_64]: $abi_x86_64")
if (!abi_arm_32 && !abi_arm_64 && !abi_x86_32 && !abi_x86_64) {
throw new GradleException("All supported ABI properties are set to false!")
}
if (!file(deps).exists()) {
throw new GradleException("Dependencies file does not exist:" + deps)
}
if (!override_version.isEmpty()) {
if (version_header_path.isEmpty()) {
throw new GradleException("`version_header_path` cannot be empty when `override_version` is not empty")
} else {
println("Overriding version number to $override_version using path $version_header_path")
}
}
def projectRoot = './../..'
def assetsDir = 'src/main/assets'
def assetsDirWindows = 'src/main/assetsWinHost'
task unzipDeps(type: Copy) {
println("Using dependencies file: $deps")
def zipFile = new File("$deps")
def outputDir = new File('.')
from zipTree(zipFile)
into outputDir
}
task makeLocalization(type: Exec) {
def args = []
if (localize) {
println("Building with localization")
switch (OperatingSystem.current()) {
case OperatingSystem.LINUX:
args = ['make', 'localization', 'LANGUAGES=all']
break
case OperatingSystem.WINDOWS:
args = ['sh.exe', 'lang/compile_mo.sh']
break
default:
args = ['echo', 'Building without localization']
break
}
} else {
args = ['echo', 'Building without localization']
if (OperatingSystem.current() == OperatingSystem.WINDOWS) {
args = ['cmd.exe', '/k'] + args
}
}
workingDir projectRoot
commandLine args
}
task generateVersionHeader() {
// this taks imitates `make version` while respecting version_header_path
if (override_version.isEmpty()) {
println("Generating version number to $version_header_path")
def output = new ByteArrayOutputStream()
exec {
workingDir projectRoot
commandLine 'git', 'describe', '--tags', '--always', '--dirty', '--match', '"[0-9A-Z]*.[0-9A-Z]*"'
standardOutput output
}
override_version = output.toString()
override_version = override_version.split()[0] // strip whitespaces
} else {
println("Overriding version number to $override_version")
}
def define = "// NOLINT(cata-header-guard)\n#define VERSION \"$override_version\"\n"
def versionHeader = new File("$version_header_path")
if (!versionHeader.exists() || versionHeader.text != define) {
versionHeader.text = define
}
}
task createWindowsJunctionLinks() {
onlyIf {
OperatingSystem.current() == OperatingSystem.WINDOWS
}
doLast {
def mkJunction = { to, from ->
def errOut = new ByteArrayOutputStream()
exec {
commandLine 'cmd', '/k', "mklink /J $to $from"
errorOutput errOut
standardOutput new ByteArrayOutputStream() // don't print the output
}
def errString = errOut.toString()
if (!errString.isEmpty() && !errString.endsWith('already exists.\r\n')) {
// we have an error that is not 'file already exists'
errString = errString.substring(0, errString.size() - 2) // discard \r\n
throw new GradleException("$errString")
}
}
println("Creating junctions for the assets")
mkdir assetsDirWindows
mkdir "$assetsDirWindows/lang"
def rootDir = projectRoot.replace('/', '\\')
def unixAssetsDir = assetsDir.replace('/', '\\')
def winAssetsDir = assetsDirWindows.replace('/', '\\')
mkJunction("$winAssetsDir\\android", "$unixAssetsDir\\android")
for (dir in ['data', 'gfx', 'lang\\mo']) {
mkJunction("$winAssetsDir\\$dir", "$rootDir\\$dir")
}
}
}
preBuild.dependsOn unzipDeps
preBuild.dependsOn makeLocalization
preBuild.dependsOn generateVersionHeader
preBuild.dependsOn createWindowsJunctionLinks
createWindowsJunctionLinks.dependsOn makeLocalization
android {
compileSdkVersion override_compileSdkVersion
defaultConfig {
minSdkVersion override_minSdkVersion
targetSdkVersion override_targetSdkVersion
versionCode Integer.valueOf(System.env.UPSTREAM_BUILD_NUMBER ?: 1)
versionName new File("$version_header_path").text.split('\"')[1]
if (buildAsApplication) {
applicationId "com.cleverraven.cataclysmdda"
setProperty("archivesBaseName", "cataclysmdda-" + versionName)
}
resValue "string", "app_name", "Cataclysm DDA"
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
if (abi_arm_32) {
include "armeabi-v7a"
}
if (abi_arm_64) {
include "arm64-v8a"
}
if (abi_x86_32) {
include "x86"
}
if (abi_x86_64) {
include "x86_64"
}
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=$override_ndkBuildAppPlatform", "-j$njobs"
}
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
flavorDimensions "version"
productFlavors {
stable {
dimension "version"
resValue "string", "app_name", "Cataclysm DDA"
}
experimental {
dimension "version"
applicationIdSuffix ".experimental"
resValue "string", "app_name", "Cataclysm DDA (experimental)"
}
}
signingConfigs {
if (keystoreProperties.getProperty('storeFile') != null) {
if (file(keystoreProperties.getProperty('storeFile')).exists()) {
release {
storeFile file(keystoreProperties.getProperty("storeFile"))
storePassword keystoreProperties.getProperty("storePassword")
keyAlias keystoreProperties.getProperty("keyAlias")
keyPassword keystoreProperties.getProperty("keyPassword")
}
} else {
throw new GradleException("Keystore file " + keystoreProperties.getProperty("storeFile") + " was not found.\n")
}
}
if (keystoreProperties.getProperty('debug_storeFile') != null) {
if (file(keystoreProperties.getProperty('debug_storeFile')).exists()) {
debug {
storeFile file(keystoreProperties.getProperty("debug_storeFile"))
storePassword keystoreProperties.getProperty("debug_storePassword")
keyAlias keystoreProperties.getProperty("debug_keyAlias")
keyPassword keystoreProperties.getProperty("debug_keyPassword")
}
} else {
throw new GradleException("Keystore file " + keystoreProperties.getProperty("debug_storeFile") + " was not found.\n")
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (signingConfigs.hasProperty("release")) {
signingConfig signingConfigs.release
}
externalNativeBuild {
ndkBuild {
cFlags "-DNDEBUG", "-DRELEASE", "-Os", "-g"
}
}
ndk {
debugSymbolLevel 'SYMBOL_TABLE'
}
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (signingConfigs.hasProperty("debug")) {
signingConfig signingConfigs.debug
}
externalNativeBuild {
ndkBuild {
cFlags "-g"
}
}
ndk {
debugSymbolLevel 'FULL'
}
}
}
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
sourceSets.main {
jniLibs.srcDir 'libs'
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
}
lintOptions {
abortOnError false
}
if (OperatingSystem.current() == OperatingSystem.WINDOWS) {
sourceSets.main.assets.srcDirs = ['src/main/assetsWinHost']
}
if (buildAsLibrary) {
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(".aar")) {
def fileName = "$applicationId.aar";
output.outputFile = new File(outputFile.parent, fileName);
}
}
}
}
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/res']
}
}
stable {
}
experimental {
resources {
srcDirs = ['src/experimental/res']
}
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
}
Binary file not shown.
Binary file not shown.
-3
View File
@@ -1,3 +0,0 @@
# Reference: https://developer.android.com/ndk/guides/android_mk.html
include $(call all-subdir-makefiles)
-17
View File
@@ -1,17 +0,0 @@
# Reference: https://developer.android.com/ndk/guides/application_mk.html
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
APP_STL := c++_shared
APP_CPPFLAGS += -std=c++14
ifneq ($(OS),Windows_NT)
APP_LDFLAGS += -fuse-ld=gold
endif
# Do not specify APP_OPTIM here, it is done through ndk-build NDK_DEBUG=0/1 setting instead
# See https://developer.android.com/ndk/guides/ndk-build.html#dvr
#APP_OPTIM := debug
#APP_OPTIM := release
# Min SDK level
APP_PLATFORM=android-16
-23
View File
@@ -1,23 +0,0 @@
LOCAL_PATH := $(call my-dir)
###########################
#
# libintl-lite shared library
#
###########################
include $(CLEAR_VARS)
LOCAL_MODULE := libintl-lite
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := libintl.cpp
LOCAL_CPP_FEATURES := exceptions rtti
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
-23
View File
@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
@@ -1,98 +0,0 @@
/*
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBINTL_INTERNAL_MESSAGECATALOG_HPP_
#define LIBINTL_INTERNAL_MESSAGECATALOG_HPP_
#include <algorithm>
#include <string>
namespace libintllite
{
namespace internal
{
class MessageCatalog
{
private:
MessageCatalog( const MessageCatalog & );
MessageCatalog &operator=( const MessageCatalog & );
uint32_t numberOfStrings;
const std::string *sortedOrigStringsArray;
const std::string *translatedStringsArray;
public:
// The ownership of these arrays is transfered to the created message
// catalog object!
// Does not throw exceptions!
MessageCatalog( uint32_t numberOfStrings,
const std::string *sortedOrigStringsArray,
const std::string *translatedStringsArray ) :
numberOfStrings( numberOfStrings ),
sortedOrigStringsArray( sortedOrigStringsArray ),
translatedStringsArray( translatedStringsArray ) {
}
~MessageCatalog() {
delete[] this->sortedOrigStringsArray;
delete[] this->translatedStringsArray;
}
// Returns NULL, if the original string was not found.
// Does not throw exceptions!
const std::string *getTranslatedStrPtr( const std::string &orig ) const {
const std::string *lastSortedOrigStringEndIter
= this->sortedOrigStringsArray + this->numberOfStrings;
const std::string *origStrPtr = std::lower_bound( this->sortedOrigStringsArray,
lastSortedOrigStringEndIter,
orig );
#ifdef __ANDROID__
// Bugfix from j-jorge's branch of libintl-lite: https://github.com/j-jorge/libintl-lite/commit/40e5a41e9b19e3252d348e0548f85e66fa44a79e
// However, libintl-lite does not seem to support plural form strings + translations properly, so I've had to modify the fix further.
// Plural strings are stored as "<singular>NUL<plural>NUL<plural>..." for as many plurals are in the language, eg. Russian has 4, French has 2, Japanese has 1.
// So we only compare the first singular string as per gettext MO files spec here: https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html
// We do this via c_str() which clamps at the first NUL character.
// Later on once we have a match, we will dig out the proper plural translation from this megastring.
if( !origStrPtr || ( origStrPtr == lastSortedOrigStringEndIter ) ||
( std::string( ( *origStrPtr ).c_str() ) != std::string( orig.c_str() ) ) )
#else
if( !origStrPtr || ( origStrPtr == lastSortedOrigStringEndIter ) )
#endif
{
return NULL;
} else {
return &this->translatedStringsArray[origStrPtr - this->sortedOrigStringsArray];
}
}
};
} // namespace internal
} // namespace libintllite
#endif // LIBINTL_INTERNAL_MESSAGECATALOG_HPP_
-222
View File
@@ -1,222 +0,0 @@
/*
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBINTL_INTERNAL_UTIL_HPP_
#define LIBINTL_INTERNAL_UTIL_HPP_
#if defined(WIN32) || defined(WINCE)
typedef unsigned int uint32_t;
#else
#include <stdint.h>
#endif
namespace libintllite
{
namespace internal
{
// Helper functions for handling numbers and char array conversions:
static inline bool isBigEndian()
{
uint32_t checkNumber = 0x1100;
return ( *reinterpret_cast<const char *>( &checkNumber ) != 0 );
}
static inline uint32_t swapUInt32Bytes( uint32_t number )
{
const char *numberAsCharArray = reinterpret_cast<const char *>( &number );
uint32_t swappedNumber;
char *swappedNumberAsCharArray = reinterpret_cast<char *>( &swappedNumber );
swappedNumberAsCharArray[0] = numberAsCharArray[3];
swappedNumberAsCharArray[1] = numberAsCharArray[2];
swappedNumberAsCharArray[2] = numberAsCharArray[1];
swappedNumberAsCharArray[3] = numberAsCharArray[0];
return swappedNumber;
}
static inline uint32_t charArrayToUInt32( const char uint32CharArray[4] )
{
return *reinterpret_cast<const uint32_t *>( uint32CharArray );
}
static inline bool readUIn32FromFile( FILE *fileHandle, bool needsBeToLeConversion,
uint32_t &outReadUInt32 )
{
char uint32CharArray[4];
if( ( fread( uint32CharArray, 1, 4, fileHandle ) ) != 4 ) {
return false;
}
if( needsBeToLeConversion ) {
outReadUInt32 = swapUInt32Bytes( charArrayToUInt32( uint32CharArray ) );
return true;
} else {
outReadUInt32 = charArrayToUInt32( uint32CharArray );
return true;
}
}
// RAII classes:
template <class T>
class ArrayGurard
{
private:
ArrayGurard( const ArrayGurard & );
ArrayGurard &operator=( const ArrayGurard & );
T *&arrayRef;
bool released;
public:
explicit ArrayGurard( T *&arrayRef ) :
arrayRef( arrayRef ),
released( false ) {
}
~ArrayGurard() {
if( !this->released ) {
delete[] this->arrayRef;
}
}
const T *release() {
this->released = true;
return this->arrayRef;
}
};
class CloseFileHandleGuard
{
private:
CloseFileHandleGuard( const CloseFileHandleGuard & );
CloseFileHandleGuard &operator=( const CloseFileHandleGuard & );
FILE *&fileHandleRef;
public:
explicit CloseFileHandleGuard( FILE *&fileHandleRef ) :
fileHandleRef( fileHandleRef ) {
}
~CloseFileHandleGuard() {
if( this->fileHandleRef ) {
fclose( this->fileHandleRef );
}
}
};
// Helper function to load strings from a .mo file and stores them in a given array
static bool loadMoFileStringsToArray( FILE *moFile,
uint32_t numberOfStrings,
uint32_t stringsTableOffsetFromFileBegin,
bool needsBeToLeConversion,
std::string *outStringsFromMoFileArray )
{
if( fseek( moFile, stringsTableOffsetFromFileBegin, SEEK_SET ) != 0 ) {
return false;
}
uint32_t *stringsLengthsArray = NULL;
ArrayGurard<uint32_t> stringsLengthsArrayGuard( stringsLengthsArray );
stringsLengthsArray = new uint32_t[numberOfStrings];
if( !stringsLengthsArray ) {
return false;
}
uint32_t firstStringOffset;
uint32_t lastStringOffset;
{
uint32_t currentStringLength;
uint32_t currentStringOffset;
for( uint32_t i = 0; i < numberOfStrings; i++ ) {
if( !readUIn32FromFile( moFile, needsBeToLeConversion, currentStringLength ) ) {
return false;
}
if( !readUIn32FromFile( moFile, needsBeToLeConversion, currentStringOffset ) ) {
return false;
}
stringsLengthsArray[i] = currentStringLength;
if( i == 0 ) {
firstStringOffset = currentStringOffset;
}
if( i == ( numberOfStrings - 1 ) ) {
lastStringOffset = currentStringOffset;
}
}
}
{
char *stringCharsArray = NULL;
ArrayGurard<char> stringCharsArrayGuard( stringCharsArray );
uint32_t stringCharsArraySize = lastStringOffset + stringsLengthsArray[numberOfStrings - 1] + 1 -
firstStringOffset;
if( stringCharsArraySize == 0 ) {
return false;
}
if( fseek( moFile, firstStringOffset, SEEK_SET ) != 0 ) {
return false;
}
stringCharsArray = new char[stringCharsArraySize];
if( !stringCharsArray ) {
return false;
}
if( fread( stringCharsArray, 1, stringCharsArraySize, moFile ) != stringCharsArraySize ) {
return false;
}
const char *stringsCharsArrayIter = stringCharsArray;
for( uint32_t i = 0; i < numberOfStrings; i++ ) {
#ifdef __ANDROID__
// Bugfix from j-jorge's branch of libintl-lite: https://github.com/j-jorge/libintl-lite/commit/240f38c005ba9afce9c3c3629d624d904cb09403
const char *currentStrEndIter = stringsCharsArrayIter + stringsLengthsArray[i];
outStringsFromMoFileArray[i] = std::string( stringsCharsArrayIter, currentStrEndIter );
stringsCharsArrayIter = currentStrEndIter + 1 /* skip the NULL char at the end of the string */ ;
#else
const char *currentStrEndIter = stringsCharsArrayIter + stringsLengthsArray[i] + 1;
outStringsFromMoFileArray[i] = std::string( stringsCharsArrayIter, currentStrEndIter );
stringsCharsArrayIter = currentStrEndIter;
#endif
}
}
return true;
}
} // namespace internal
} // namespace libintllite
#endif // LIBINTL_INTERNAL_UTIL_HPP_
-360
View File
@@ -1,360 +0,0 @@
/*
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "libintl.h"
#include <map>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(WIN32) || defined(WINCE)
typedef unsigned int uint32_t;
#else
#include <stdint.h>
#endif
#ifdef __ANDROID__
#include <iostream>
#endif
#include "MessageCatalog.hpp"
#include "Util.hpp"
using namespace std;
using namespace libintllite;
using namespace libintllite::internal;
static char *currentDefaultDomain = NULL;
static map<char *, MessageCatalog *> loadedMessageCatalogPtrsByDomain;
libintl_lite_bool_t loadMessageCatalog( const char *domain, const char *moFilePath )
{
try {
if( sizeof( uint32_t ) != 4 ) {
return LIBINTL_LITE_BOOL_FALSE;
}
if( !moFilePath || !domain ) {
return LIBINTL_LITE_BOOL_FALSE;
}
FILE *moFile = NULL;
CloseFileHandleGuard closeFileHandleGuard( moFile );
moFile = fopen( moFilePath, "rb" );
if( !moFile ) {
return LIBINTL_LITE_BOOL_FALSE;
}
uint32_t magicNumber;
if( !readUIn32FromFile( moFile, false, magicNumber ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
if( ( magicNumber != 0x950412de ) && ( magicNumber != 0xde120495 ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
uint32_t fileFormatRevision;
if( !readUIn32FromFile( moFile, false, fileFormatRevision ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
if( fileFormatRevision != 0 ) {
return LIBINTL_LITE_BOOL_FALSE;
}
bool needsBeToLeConversion = isBigEndian();
uint32_t numberOfStrings;
if( !readUIn32FromFile( moFile, needsBeToLeConversion, numberOfStrings ) ) {
return false;
}
if( numberOfStrings == 0 ) {
return LIBINTL_LITE_BOOL_TRUE;
}
uint32_t offsetOrigTable;
if( !readUIn32FromFile( moFile, needsBeToLeConversion, offsetOrigTable ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
uint32_t offsetTransTable;
if( !readUIn32FromFile( moFile, needsBeToLeConversion, offsetTransTable ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
string *sortedOrigStringsArray = NULL;
ArrayGurard<string> sortedOrigStringsArrayGuard( sortedOrigStringsArray );
sortedOrigStringsArray = new string[numberOfStrings];
if( !sortedOrigStringsArray ) {
return LIBINTL_LITE_BOOL_FALSE;
}
if( !loadMoFileStringsToArray( moFile,
numberOfStrings,
offsetOrigTable,
needsBeToLeConversion,
sortedOrigStringsArray ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
string *translatedStringsArray = NULL;
ArrayGurard<string> translatedStringsArrayGuard( translatedStringsArray );
translatedStringsArray = new string[numberOfStrings];
if( !translatedStringsArray ) {
return LIBINTL_LITE_BOOL_FALSE;
}
if( !loadMoFileStringsToArray( moFile,
numberOfStrings,
offsetTransTable,
needsBeToLeConversion,
translatedStringsArray ) ) {
return LIBINTL_LITE_BOOL_FALSE;
}
MessageCatalog *newMessageCatalogPtr = new MessageCatalog( numberOfStrings,
sortedOrigStringsArray,
translatedStringsArray );
if( !newMessageCatalogPtr ) {
return LIBINTL_LITE_BOOL_FALSE;
}
sortedOrigStringsArrayGuard.release();
translatedStringsArrayGuard.release();
char *domainDup = strdup( domain );
if( !domainDup ) {
return LIBINTL_LITE_BOOL_FALSE;
}
closeLoadedMessageCatalog( domain );
loadedMessageCatalogPtrsByDomain[domainDup] = newMessageCatalogPtr;
return LIBINTL_LITE_BOOL_TRUE;
} catch( ... ) {
return LIBINTL_LITE_BOOL_FALSE;
}
}
void closeLoadedMessageCatalog( const char *domain )
{
if( domain ) {
for( map<char *, MessageCatalog *>::iterator i = loadedMessageCatalogPtrsByDomain.begin();
i != loadedMessageCatalogPtrsByDomain.end();
i++ ) {
if( strcmp( i->first, domain ) == 0 ) {
free( i->first );
delete i->second;
loadedMessageCatalogPtrsByDomain.erase( i );
return;
}
}
}
}
void closeAllLoadedMessageCatalogs()
{
for( map<char *, MessageCatalog *>::iterator i = loadedMessageCatalogPtrsByDomain.begin();
i != loadedMessageCatalogPtrsByDomain.end();
i++ ) {
free( i->first );
delete i->second;
}
loadedMessageCatalogPtrsByDomain.clear();
free( currentDefaultDomain );
currentDefaultDomain = NULL;
}
const char *textdomain( const char *domain )
{
if( domain ) {
char *newDefaultDomain = strdup( domain );
if( !newDefaultDomain ) {
return NULL;
}
free( currentDefaultDomain );
currentDefaultDomain = newDefaultDomain;
return newDefaultDomain;
} else {
return NULL;
}
}
const char *gettext( const char *origStr )
{
return dgettext( NULL, origStr );
}
const char *dgettext( const char *domain, const char *origStr )
{
if( !origStr ) {
return NULL;
}
if( !domain ) {
if( currentDefaultDomain ) {
domain = currentDefaultDomain;
} else {
return origStr;
}
}
const MessageCatalog *msgCat = NULL;
for( map<char *, MessageCatalog *>::iterator i = loadedMessageCatalogPtrsByDomain.begin();
!msgCat && ( i != loadedMessageCatalogPtrsByDomain.end() );
i++ ) {
if( strcmp( i->first, domain ) == 0 ) {
msgCat = i->second;
}
}
if( !msgCat ) {
return origStr;
}
const string *translatedStrPtr = msgCat->getTranslatedStrPtr( origStr );
if( translatedStrPtr ) {
return translatedStrPtr->c_str();
} else {
return origStr;
}
}
const char *ngettext( const char *origStr, const char *origStrPlural, unsigned long n )
{
#ifdef __ANDROID__
try {
// First let's get the translated megastring that contains all the plural translations separated by NUL chars
const char *translatedStr = gettext( origStr );
// Now determine correct plural form to use. This data is described in .PO files "Plural-Forms" metadata.
const char *language = getenv( "LANGUAGE" );
// Bail out if we don't have data, or the result of gettext is the exact same pointer to the source string (so we don't have a translated megastring to look at)
if( !translatedStr || !language || translatedStr == origStr ) {
if( n == 1 ) {
return origStr;
} else {
return origStrPlural;
}
}
int nplurals = 2;
int plural = n != 1;
if( strcmp( language, "en" ) == 0 ) {
nplurals = 2;
plural = ( n != 1 );
} else if( strcmp( language, "fr" ) == 0 ) {
nplurals = 2;
plural = ( n > 1 );
} else if( strcmp( language, "de" ) == 0 ) {
nplurals = 2;
plural = ( n != 1 );
} else if( strcmp( language, "it_IT" ) == 0 ) {
nplurals = 2;
plural = ( n != 1 );
} else if( strcmp( language, "es_AR" ) == 0 ) {
nplurals = 2;
plural = ( n != 1 );
} else if( strcmp( language, "es_ES" ) == 0 ) {
nplurals = 2;
plural = ( n != 1 );
} else if( strcmp( language, "ja" ) == 0 ) {
nplurals = 1;
plural = 0;
} else if( strcmp( language, "ko" ) == 0 ) {
nplurals = 1;
plural = 0;
} else if( strcmp( language, "pt_BR" ) == 0 ) {
nplurals = 2;
plural = ( n > 1 );
} else if( strcmp( language, "pt_PT" ) == 0 ) {
nplurals = 2;
plural = n != 1;
} else if( strcmp( language, "ru" ) == 0 ) {
nplurals = 4;
plural = ( n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && ( n % 100 < 12 ||
n % 100 > 14 ) ? 1 : n % 10 == 0 || ( n % 10 >= 5 && n % 10 <= 9 ) || ( n % 100 >= 11 &&
n % 100 <= 14 ) ? 2 : 3 );
} else if( strcmp( language, "zh_CN" ) == 0 ) {
nplurals = 1;
plural = 0;
} else if( strcmp( language, "zh_TW" ) == 0 ) {
nplurals = 1;
plural = 0;
}
// Now we know which plural form to use, move the string pointer past the appropriate # of NUL characters.
// This is a bit scary because it relies on the .MO file always storing the correct number of plurals,
// otherwise we could overrun the string buffer. Seems to work fine though... (nervous laughter)
for( int i = 0; i < plural; ++i ) {
translatedStr += strlen( translatedStr ) + 1; // advance to the start of the next string
}
return translatedStr;
} catch( const std::exception &err ) {
std::cerr << "Error in libintl-lite ngettext(): " << err.what() << std::endl;
if( n == 1 ) {
return origStr;
} else {
return origStrPlural;
}
}
#else
if( n == 1 ) {
return gettext( origStr );
} else {
return gettext( origStrPlural );
}
#endif
}
const char *dngettext( const char *domain, const char *origStr, const char *origStrPlural,
unsigned long n )
{
#ifdef __ANDROID__
// not implemented yet
return NULL;
#else
if( n == 1 ) {
return dgettext( domain, origStr );
} else {
return dgettext( domain, origStrPlural );
}
#endif
}
#ifdef __ANDROID__
libintl_lite_bool_t bindtextdomain( const char *domain, const char *moFilePath )
{
return loadMessageCatalog( domain, moFilePath );
}
libintl_lite_bool_t bind_textdomain_codeset( const char *domain, const char *oFilePath )
{
return LIBINTL_LITE_BOOL_FALSE;
}
#endif
-127
View File
@@ -1,127 +0,0 @@
/*
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBINTL_HPP_
#define LIBINTL_HPP_
#define LIBINTL_LITE_API
#if (defined(WIN32) || defined(WINCE)) && defined(LIBINTL_LITE_WIN32_SHARED)
#undef LIBINTL_LITE_API
#ifdef LIBINTL_LITE_EXPORTS
#define LIBINTL_LITE_API __declspec(dllexport)
#else
#define LIBINTL_LITE_API __declspec(dllimport)
#endif
#endif
#ifdef __cplusplus
extern "C"
{
#endif
typedef int libintl_lite_bool_t;
#define LIBINTL_LITE_BOOL_TRUE 1
#define LIBINTL_LITE_BOOL_FALSE 0
/**
* Loads a message catalog from a given (GNU-compatible) .mo file.
* Returns true, if the message catalog was loaded successfully and
* false otherwise.
* This function is specific to libintl-lite and serves as a simple
* replacement for bindtextdomain() function of GNU gettext.
* The parameter "domain" must not be NULL!
* This function is NOT thread safe!
* Pay attention to the thread safety remarks of the gettext() function!
*/
LIBINTL_LITE_API libintl_lite_bool_t loadMessageCatalog( const char *domain,
const char *moFilePath );
/**
* Closes a message catalog for the specified domain and releases its obtained resources.
* This function is NOT thread safe!
* Pay attention to the thread safety remarks of the gettext() function!
*/
LIBINTL_LITE_API void closeLoadedMessageCatalog( const char *domain );
/**
* Closes all loaded message catalogs releases their obtained resources.
* This function is NOT thread safe!
* Pay attention to the thread safety remarks of the gettext() function!
*/
LIBINTL_LITE_API void closeAllLoadedMessageCatalogs();
/**
* Sets the default text domain for gettext() / ngettext() calls.
* This function is NOT thread safe!
*/
LIBINTL_LITE_API const char *textdomain( const char *domain );
/**
* Returns a pointer to the NULL-terminated string in the loaded for the default
* message catalog, or origString if origStr is NULL, textdomain() was not called,
* no message catalog for the specified domain is loaded or no translated message
* could be found.
* This function is thread-safe, but loadMessageCatalog(), textdomain(),
* closeLoadedMessageCatalog() or closeAllLoadedMessageCatalogs()
* must not be called at the same time! A returned string in the current
* loaded message catalog will be deleted, if loadMessageCatalog() or
* closeLoadedMessageCatalog() is called for the used domain afterwards!
* Does not perform any character set conversion!
*/
LIBINTL_LITE_API const char *gettext( const char *origStr );
/**
* Works like the gettext() function, but uses the message catalog for a specified domain.
*/
LIBINTL_LITE_API const char *dgettext( const char *domain, const char *origStr );
/**
* Works like the gettext() function, but distinguishes between singular
* and plural form of a message.
* Always returns the suitable singular string, if n == 1, and the plural string
* otherwise, regardless of the language.
*/
LIBINTL_LITE_API const char *ngettext( const char *origStr, const char *origStrPlural,
unsigned long n );
/**
* Works like the ngettext() function, but uses the message catalog for a specified domain.
*/
LIBINTL_LITE_API const char *dngettext( const char *domain, const char *origStr,
const char *origStrPlural, unsigned long n );
#ifdef __ANDROID__
// Two extra signatures required as per: http://blog.stuff-o-matic.com/post/2013/09/07/Porting-a-C-game-to-Android,-the-case-of-Andy-s-Super-Great-Park
LIBINTL_LITE_API libintl_lite_bool_t bindtextdomain( const char *domain, const char *moFilePath );
LIBINTL_LITE_API libintl_lite_bool_t bind_textdomain_codeset( const char *domain,
const char *moFilePath );
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif // LIBINTL_HPP_
-26
View File
@@ -1,26 +0,0 @@
LOCAL_PATH := $(call my-dir)/../../../../src
include $(CLEAR_VARS)
LOCAL_MODULE := main
LOCAL_CPP_FEATURES := exceptions rtti
# Add your application source files here...
FILE_LIST := $(sort $(wildcard $(LOCAL_PATH)/*.cpp))
LOCAL_SRC_FILES := $(sort $(FILE_LIST:$(LOCAL_PATH)/%=%))
LOCAL_SHARED_LIBRARIES := libhidapi SDL2 SDL2_mixer SDL2_image SDL2_ttf libintl-lite mpg123
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
LOCAL_CFLAGS += -DTILES=1 -DSDL_SOUND=1 -DBACKTRACE=1 -DLOCALIZE=1 -Wextra -Wall -fsigned-char -ffast-math
LOCAL_LDFLAGS += $(LOCAL_CFLAGS)
ifeq ($(OS),Windows_NT)
# needed to bypass 8191 character limit on Windows command line
LOCAL_SHORT_COMMANDS := true
endif
include $(BUILD_SHARED_LIBRARY)
-17
View File
@@ -1,17 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in [sdk]/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@color/black"/>
<item>
<bitmap
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/splash"/>
</item>
</layer-list>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
<color name="accent_material_dark">#990026</color>
<color name="primary_material_dark">#212121</color>
<color name="background_material_dark">#212121</color>
</resources>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="installing">Installing game data...</string>
<string name="upgrading">Upgrading game data...</string>
</resources>
@@ -1,10 +0,0 @@
<resources>
<style name="AppTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
<item name="android:windowBackground">@drawable/background_splash</item>
<item name="android:colorAccent">@color/accent_material_dark</item>
<item name="android:colorPrimary">@color/primary_material_dark</item>
<item name="android:colorBackground">@color/background_material_dark</item>
</style>
</resources>
-63
View File
@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Replace com.test.game with the identifier of your game below, e.g.
com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cleverraven.cataclysmdda"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
<!-- Allow writing to external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Allow access to the vibrator -->
<uses-permission android:name="android.permission.VIBRATE" />
<!-- if you want to capture audio, uncomment this. -->
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<!-- Create a Java class extending SDLActivity and place it in a
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
in the XML below.
An example Java class can be found in README-android.md
-->
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:allowBackup="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
android:isGame="true" >
<!-- Example of setting SDL hints from AndroidManifest.xml:
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
-->
<activity android:name="SplashScreen"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:keepScreenOn="true"
android:screenOrientation="userLandscape"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="CataclysmDDA"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:keepScreenOn="true"
android:screenOrientation="userLandscape"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
>
</activity>
</application>
</manifest>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

-1
View File
@@ -1 +0,0 @@
../../../../../data
-1
View File
@@ -1 +0,0 @@
../../../../../gfx
-1
View File
@@ -1 +0,0 @@
../../../../../../lang/mo
@@ -1,64 +0,0 @@
package com.cleverraven.cataclysmdda;
import org.libsdl.app.SDLActivity;
import android.preference.PreferenceManager;
import android.util.Log;
import android.content.Context;
import android.os.Vibrator;
import android.view.View;
import android.widget.Toast;
import android.content.res.Configuration;
public class CataclysmDDA extends SDLActivity {
private static final String TAG = "CDDA";
public void vibrate(int duration) {
try {
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(duration);
} catch(Exception e) {
System.err.println(e.getMessage());
}
}
public void toast(final String message) {
try {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
});
} catch(Exception e) {
System.err.println(e.getMessage());
}
}
private boolean isHardwareKeyboardAvailable() {
return getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
}
private float getDisplayDensity() {
return getResources().getDisplayMetrics().density;
}
public void show_sdl_surface() {
try {
runOnUiThread(new Runnable() {
public void run() {
mLayout.setVisibility(View.VISIBLE);
}
});
} catch(Exception e) {
System.err.println(e.getMessage());
}
}
public boolean getDefaultSetting(final String settingsName, boolean defaultValue) {
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(settingsName, defaultValue);
}
public String getSystemLang() {
return getResources().getConfiguration().locale.toLanguageTag().replace('-', '_');
}
}
@@ -1,401 +0,0 @@
package com.cleverraven.cataclysmdda;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.*;
import android.preference.PreferenceManager;
import android.util.Log;
public class SplashScreen extends Activity {
private static final String TAG = "Splash";
private static final int INSTALL_DIALOG_ID = 0;
private ProgressDialog installDialog;
public CharSequence[] mSettingsNames;
public boolean[] mSettingsValues = { false, false, true };
private String getVersionName() {
try {
Context context = getApplicationContext();
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
return pInfo.versionName;
} catch (Exception e) {
e.printStackTrace();
return "error";
}
}
private void showCrashAlert() {
String externalFilesDir = getExternalFilesDir(null).getPath();
File crashAlertPrompt = new File(externalFilesDir + "/config/crash.log.prompt");
try {
crashAlertPrompt.delete();
if(crashAlertPrompt.exists()) { // Sometimes .delete() doesn't really delete the file and I don't know why
crashAlertPrompt.getCanonicalFile().delete();
}
} catch(IOException e) {
return;
}
File crashLog = new File(externalFilesDir + "/config/crash.log");
StringBuilder text = new StringBuilder();
text.append(getString(R.string.crashMessage));
text.append("\n\n");
try {
BufferedReader br = new BufferedReader(new FileReader(crashLog));
String line;
while((line = br.readLine()) != null) {
text.append(line);
text.append("\n");
}
br.close();
} catch (IOException e) {
return;
}
final String message = text.toString();
this.runOnUiThread(new Runnable() {
public void run() {
AlertDialog errorAlert = new AlertDialog.Builder(SplashScreen.this)
.setTitle(getString(R.string.crashAlert))
.setCancelable(false)
.setMessage(message)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SplashScreen.this.startGameActivity(false);
}
}).create();
errorAlert.show();
}
});
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.e(TAG, "onCreate()");
super.onCreate(savedInstanceState);
// Start the game if already installed, otherwise start installing...
if (getVersionName().equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", ""))) {
// Show an alert box if the game crashed last time
String externalFilesDir = getExternalFilesDir(null).getPath();
File crashAlertPrompt = new File(externalFilesDir + "/config/crash.log.prompt");
if(crashAlertPrompt.exists()) {
showCrashAlert();
} else {
startGameActivity(false);
}
}
else {
new InstallProgramTask().execute();
}
}
@Override
public Dialog onCreateDialog(int id) {
switch (id) {
case INSTALL_DIALOG_ID:
installDialog = new ProgressDialog(this);
installDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
boolean clean_install = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", "").isEmpty();
installDialog.setTitle(getString(clean_install ? R.string.installTitle : R.string.upgradeTitle));
installDialog.setIndeterminate(true);
installDialog.setCancelable(false);
return installDialog;
default:
return null;
}
}
private void startGameActivity(boolean delay) {
if (!delay) {
runOnUiThread(new StartGameRunnable());
}
else {
// Wait 1.5 seconds, then start game
Timer timer = new Timer();
TimerTask gameStartTask = new TimerTask() {
@Override
public void run() {
runOnUiThread(new StartGameRunnable());
}
};
timer.schedule(gameStartTask, 1500);
}
}
private final class StartGameRunnable implements Runnable {
@Override
public void run() {
Intent intent = new Intent(SplashScreen.this, CataclysmDDA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
finish();
overridePendingTransition(0, 0);
}
}
private class InstallProgramTask extends AsyncTask<Void, Integer, Boolean> {
private final List<String> PRESERVE_SUBFOLDERS = Arrays.asList("sound", "mods", "gfx"); // don't delete custom subfolders under these folders
private final List<String> PRESERVE_FOLDERS = Arrays.asList("font"); // don't delete this folder
private final List<String> PRESERVE_FILES = Arrays.asList("user-default-mods.json"); // don't delete this file
private int totalFiles = 0;
private int installedFiles = 0;
private AlertDialog installationAlert;
private AlertDialog settingsAlert;
private AlertDialog helpAlert;
@Override
protected void onPreExecute() {
installationAlert = new AlertDialog.Builder(SplashScreen.this)
.setTitle("Installation Failed")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
SplashScreen.this.finish();
return;
}
}).create();
AssetManager assetManager = getAssets();
try {
totalFiles = countTotalAssets(assetManager, "data") +
countTotalAssets(assetManager, "gfx") +
countTotalAssets(assetManager, "lang");
showDialog(INSTALL_DIALOG_ID);
} catch(Exception e) {
installationAlert.setMessage(e.getMessage());
installationAlert.show();
}
helpAlert = new AlertDialog.Builder(SplashScreen.this)
.setTitle(getString(R.string.helpTitle))
.setCancelable(false)
.setMessage(getString(R.string.helpMessage))
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
settingsAlert.show();
return;
}
}).create();
mSettingsNames = new CharSequence[] {
getString(R.string.softwareRendering),
getString(R.string.forceFullscreen),
getString(R.string.trapBackButton)
};
settingsAlert = new AlertDialog.Builder(SplashScreen.this)
.setTitle(getString(R.string.settings))
.setMultiChoiceItems(SplashScreen.this.mSettingsNames, SplashScreen.this.mSettingsValues, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
SplashScreen.this.mSettingsValues[which] = isChecked;
}})
.setCancelable(false)
.setPositiveButton(getString(R.string.startGame), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Software rendering", SplashScreen.this.mSettingsValues[0]).commit();
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Force fullscreen", SplashScreen.this.mSettingsValues[1]).commit();
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Trap Back button", SplashScreen.this.mSettingsValues[2]).commit();
SplashScreen.this.startGameActivity(false);
return;
}
})
.setNeutralButton(getString(R.string.showHelp), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
helpAlert.show();
return;
}
}).create();
}
@Override
protected Boolean doInBackground(Void... params) {
if (installDialog != null) {
installDialog.setIndeterminate(false);
installDialog.setMax(totalFiles);
}
publishProgress(installedFiles);
AssetManager assetManager = getAssets();
String externalFilesDir = getExternalFilesDir(null).getPath();
try {
// Clear out the old data if it exists (but preserve custom folders + files)
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/data"));
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/gfx"));
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/lang"));
// Install the new data over the top
copyAssetFolder(assetManager, "data", externalFilesDir + "/data");
copyAssetFolder(assetManager, "gfx", externalFilesDir + "/gfx");
copyAssetFolder(assetManager, "lang", externalFilesDir + "/lang");
} catch(Exception e) {
installationAlert.setMessage(e.getMessage());
return false;
}
// Remember which version the installed data is
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("installed", getVersionName()).commit();
publishProgress(++installedFiles);
Log.d(TAG, "Total number of files copied: " + installedFiles);
return true;
}
void deleteRecursive(AssetManager assetManager, String externalFilesDir, File fileOrDirectory) {
String parentFolder = fileOrDirectory.getParentFile().getName().toLowerCase();
String fileOrDirectoryName = fileOrDirectory.getName().toLowerCase();
if (fileOrDirectory.isDirectory()) {
// Don't delete the folder if it is in the preserve folders list
if (PRESERVE_FOLDERS.contains(fileOrDirectoryName))
return;
// Don't delete the folder if its parent is in the preserve subfolders list, and it doesn't exist in the APK assets (so must be custom data)
if (PRESERVE_SUBFOLDERS.contains(parentFolder) && !assetExists(assetManager, fileOrDirectory.getPath().substring(externalFilesDir.length()+1)))
return;
for (File child : fileOrDirectory.listFiles())
deleteRecursive(assetManager, externalFilesDir, child);
}
else {
// Don't delete the file if it's in the preserve files list
if (PRESERVE_FILES.contains(fileOrDirectoryName))
return;
}
fileOrDirectory.delete();
}
// Returns true if an asset exists in the APK (either a directory or a file)
// eg. assetExists("data/sound") or assetExists("data/font", "unifont.ttf") would both return true
private boolean assetExists(AssetManager assetManager, String assetPath) {
return assetExists(assetManager, assetPath, "");
}
private boolean assetExists(AssetManager assetManager, String assetPath, String assetName) {
try {
String[] files = assetManager.list(assetPath);
if (assetName.isEmpty())
return files.length > 0; // folder exists
for (String file : files) {
if (file.equalsIgnoreCase(assetName))
return true; // file exists
}
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
private int countTotalAssets(AssetManager assetManager, String assetPath) throws Exception {
try {
String[] files = assetManager.list(assetPath);
int count = 0;
for (String file : files)
{
String filePath = assetPath + "/" + file;
String subdir_files[] = assetManager.list(filePath);
if (subdir_files.length == 0) // file
count++;
else // folder
count += countTotalAssets(assetManager, filePath);
}
return count;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
// Pinched from http://stackoverflow.com/questions/16983989/copy-directory-from-assets-to-data-folder
private boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
try {
String[] files = assetManager.list(fromAssetPath);
new File(toPath).mkdirs();
boolean res = true;
for (String file : files)
{
String subdir_files[] = assetManager.list(fromAssetPath + "/" + file);
if (subdir_files.length == 0) // file
res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
else // folder
res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
}
return res;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
private boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
publishProgress(++installedFiles, totalFiles);
InputStream in = null;
OutputStream out = null;
try {
in = assetManager.open(fromAssetPath);
new File(toPath).createNewFile();
out = new FileOutputStream(toPath);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
return true;
} catch(Exception e) {
e.printStackTrace();
throw e;
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}
@Override
protected void onProgressUpdate(Integer... values) {
if (installDialog == null) {
return;
}
installDialog.setProgress(values[0]);
}
@Override
protected void onPostExecute(Boolean result) {
removeDialog(INSTALL_DIALOG_ID);
if(result) {
settingsAlert.show();
} else {
installationAlert.show();
}
}
}
}
@@ -1,22 +0,0 @@
package org.libsdl.app;
import android.hardware.usb.UsbDevice;
interface HIDDevice
{
public int getId();
public int getVendorId();
public int getProductId();
public String getSerialNumber();
public int getVersion();
public String getManufacturerName();
public String getProductName();
public UsbDevice getDevice();
public boolean open();
public int sendFeatureReport(byte[] report);
public int sendOutputReport(byte[] report);
public boolean getFeatureReport(byte[] report);
public void setFrozen(boolean frozen);
public void close();
public void shutdown();
}
@@ -1,650 +0,0 @@
package org.libsdl.app;
import android.content.Context;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCallback;
import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothGattService;
import android.hardware.usb.UsbDevice;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.os.*;
//import com.android.internal.util.HexDump;
import java.lang.Runnable;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.UUID;
class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDevice {
private static final String TAG = "hidapi";
private HIDDeviceManager mManager;
private BluetoothDevice mDevice;
private int mDeviceId;
private BluetoothGatt mGatt;
private boolean mIsRegistered = false;
private boolean mIsConnected = false;
private boolean mIsChromebook = false;
private boolean mIsReconnecting = false;
private boolean mFrozen = false;
private LinkedList<GattOperation> mOperations;
GattOperation mCurrentOperation = null;
private Handler mHandler;
private static final int TRANSPORT_AUTO = 0;
private static final int TRANSPORT_BREDR = 1;
private static final int TRANSPORT_LE = 2;
private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000;
static public final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
static public final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
static public final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 };
static class GattOperation {
private enum Operation {
CHR_READ,
CHR_WRITE,
ENABLE_NOTIFICATION
}
Operation mOp;
UUID mUuid;
byte[] mValue;
BluetoothGatt mGatt;
boolean mResult = true;
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) {
mGatt = gatt;
mOp = operation;
mUuid = uuid;
}
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) {
mGatt = gatt;
mOp = operation;
mUuid = uuid;
mValue = value;
}
public void run() {
// This is executed in main thread
BluetoothGattCharacteristic chr;
switch (mOp) {
case CHR_READ:
chr = getCharacteristic(mUuid);
//Log.v(TAG, "Reading characteristic " + chr.getUuid());
if (!mGatt.readCharacteristic(chr)) {
Log.e(TAG, "Unable to read characteristic " + mUuid.toString());
mResult = false;
break;
}
mResult = true;
break;
case CHR_WRITE:
chr = getCharacteristic(mUuid);
//Log.v(TAG, "Writing characteristic " + chr.getUuid() + " value=" + HexDump.toHexString(value));
chr.setValue(mValue);
if (!mGatt.writeCharacteristic(chr)) {
Log.e(TAG, "Unable to write characteristic " + mUuid.toString());
mResult = false;
break;
}
mResult = true;
break;
case ENABLE_NOTIFICATION:
chr = getCharacteristic(mUuid);
//Log.v(TAG, "Writing descriptor of " + chr.getUuid());
if (chr != null) {
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
if (cccd != null) {
int properties = chr.getProperties();
byte[] value;
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE;
} else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE;
} else {
Log.e(TAG, "Unable to start notifications on input characteristic");
mResult = false;
return;
}
mGatt.setCharacteristicNotification(chr, true);
cccd.setValue(value);
if (!mGatt.writeDescriptor(cccd)) {
Log.e(TAG, "Unable to write descriptor " + mUuid.toString());
mResult = false;
return;
}
mResult = true;
}
}
}
}
public boolean finish() {
return mResult;
}
private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
BluetoothGattService valveService = mGatt.getService(steamControllerService);
if (valveService == null)
return null;
return valveService.getCharacteristic(uuid);
}
static public GattOperation readCharacteristic(BluetoothGatt gatt, UUID uuid) {
return new GattOperation(gatt, Operation.CHR_READ, uuid);
}
static public GattOperation writeCharacteristic(BluetoothGatt gatt, UUID uuid, byte[] value) {
return new GattOperation(gatt, Operation.CHR_WRITE, uuid, value);
}
static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) {
return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid);
}
}
public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
mManager = manager;
mDevice = device;
mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
mIsRegistered = false;
mIsChromebook = mManager.getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
mOperations = new LinkedList<GattOperation>();
mHandler = new Handler(Looper.getMainLooper());
mGatt = connectGatt();
// final HIDDeviceBLESteamController finalThis = this;
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// finalThis.checkConnectionForChromebookIssue();
// }
// }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
}
public String getIdentifier() {
return String.format("SteamController.%s", mDevice.getAddress());
}
public BluetoothGatt getGatt() {
return mGatt;
}
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
private BluetoothGatt connectGatt(boolean managed) {
if (Build.VERSION.SDK_INT >= 23) {
try {
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
} catch (Exception e) {
return mDevice.connectGatt(mManager.getContext(), managed, this);
}
} else {
return mDevice.connectGatt(mManager.getContext(), managed, this);
}
}
private BluetoothGatt connectGatt() {
return connectGatt(false);
}
protected int getConnectionState() {
Context context = mManager.getContext();
if (context == null) {
// We are lacking any context to get our Bluetooth information. We'll just assume disconnected.
return BluetoothProfile.STATE_DISCONNECTED;
}
BluetoothManager btManager = (BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE);
if (btManager == null) {
// This device doesn't support Bluetooth. We should never be here, because how did
// we instantiate a device to start with?
return BluetoothProfile.STATE_DISCONNECTED;
}
return btManager.getConnectionState(mDevice, BluetoothProfile.GATT);
}
public void reconnect() {
if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) {
mGatt.disconnect();
mGatt = connectGatt();
}
}
protected void checkConnectionForChromebookIssue() {
if (!mIsChromebook) {
// We only do this on Chromebooks, because otherwise it's really annoying to just attempt
// over and over.
return;
}
int connectionState = getConnectionState();
switch (connectionState) {
case BluetoothProfile.STATE_CONNECTED:
if (!mIsConnected) {
// We are in the Bad Chromebook Place. We can force a disconnect
// to try to recover.
Log.v(TAG, "Chromebook: We are in a very bad state; the controller shows as connected in the underlying Bluetooth layer, but we never received a callback. Forcing a reconnect.");
mIsReconnecting = true;
mGatt.disconnect();
mGatt = connectGatt(false);
break;
}
else if (!isRegistered()) {
if (mGatt.getServices().size() > 0) {
Log.v(TAG, "Chromebook: We are connected to a controller, but never got our registration. Trying to recover.");
probeService(this);
}
else {
Log.v(TAG, "Chromebook: We are connected to a controller, but never discovered services. Trying to recover.");
mIsReconnecting = true;
mGatt.disconnect();
mGatt = connectGatt(false);
break;
}
}
else {
Log.v(TAG, "Chromebook: We are connected, and registered. Everything's good!");
return;
}
break;
case BluetoothProfile.STATE_DISCONNECTED:
Log.v(TAG, "Chromebook: We have either been disconnected, or the Chromebook BtGatt.ContextMap bug has bitten us. Attempting a disconnect/reconnect, but we may not be able to recover.");
mIsReconnecting = true;
mGatt.disconnect();
mGatt = connectGatt(false);
break;
case BluetoothProfile.STATE_CONNECTING:
Log.v(TAG, "Chromebook: We're still trying to connect. Waiting a bit longer.");
break;
}
final HIDDeviceBLESteamController finalThis = this;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
finalThis.checkConnectionForChromebookIssue();
}
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
}
private boolean isRegistered() {
return mIsRegistered;
}
private void setRegistered() {
mIsRegistered = true;
}
private boolean probeService(HIDDeviceBLESteamController controller) {
if (isRegistered()) {
return true;
}
if (!mIsConnected) {
return false;
}
Log.v(TAG, "probeService controller=" + controller);
for (BluetoothGattService service : mGatt.getServices()) {
if (service.getUuid().equals(steamControllerService)) {
Log.v(TAG, "Found Valve steam controller service " + service.getUuid());
for (BluetoothGattCharacteristic chr : service.getCharacteristics()) {
if (chr.getUuid().equals(inputCharacteristic)) {
Log.v(TAG, "Found input characteristic");
// Start notifications
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
if (cccd != null) {
enableNotification(chr.getUuid());
}
}
}
return true;
}
}
if ((mGatt.getServices().size() == 0) && mIsChromebook && !mIsReconnecting) {
Log.e(TAG, "Chromebook: Discovered services were empty; this almost certainly means the BtGatt.ContextMap bug has bitten us.");
mIsConnected = false;
mIsReconnecting = true;
mGatt.disconnect();
mGatt = connectGatt(false);
}
return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
private void finishCurrentGattOperation() {
GattOperation op = null;
synchronized (mOperations) {
if (mCurrentOperation != null) {
op = mCurrentOperation;
mCurrentOperation = null;
}
}
if (op != null) {
boolean result = op.finish(); // TODO: Maybe in main thread as well?
// Our operation failed, let's add it back to the beginning of our queue.
if (!result) {
mOperations.addFirst(op);
}
}
executeNextGattOperation();
}
private void executeNextGattOperation() {
synchronized (mOperations) {
if (mCurrentOperation != null)
return;
if (mOperations.isEmpty())
return;
mCurrentOperation = mOperations.removeFirst();
}
// Run in main thread
mHandler.post(new Runnable() {
@Override
public void run() {
synchronized (mOperations) {
if (mCurrentOperation == null) {
Log.e(TAG, "Current operation null in executor?");
return;
}
mCurrentOperation.run();
// now wait for the GATT callback and when it comes, finish this operation
}
}
});
}
private void queueGattOperation(GattOperation op) {
synchronized (mOperations) {
mOperations.add(op);
}
executeNextGattOperation();
}
private void enableNotification(UUID chrUuid) {
GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid);
queueGattOperation(op);
}
public void writeCharacteristic(UUID uuid, byte[] value) {
GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value);
queueGattOperation(op);
}
public void readCharacteristic(UUID uuid) {
GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid);
queueGattOperation(op);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
////////////// BluetoothGattCallback overridden methods
//////////////////////////////////////////////////////////////////////////////////////////////////////
public void onConnectionStateChange(BluetoothGatt g, int status, int newState) {
//Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState);
mIsReconnecting = false;
if (newState == 2) {
mIsConnected = true;
// Run directly, without GattOperation
if (!isRegistered()) {
mHandler.post(new Runnable() {
@Override
public void run() {
mGatt.discoverServices();
}
});
}
}
else if (newState == 0) {
mIsConnected = false;
}
// Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent.
}
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
//Log.v(TAG, "onServicesDiscovered status=" + status);
if (status == 0) {
if (gatt.getServices().size() == 0) {
Log.v(TAG, "onServicesDiscovered returned zero services; something has gone horribly wrong down in Android's Bluetooth stack.");
mIsReconnecting = true;
mIsConnected = false;
gatt.disconnect();
mGatt = connectGatt(false);
}
else {
probeService(this);
}
}
}
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
//Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid());
if (characteristic.getUuid().equals(reportCharacteristic) && !mFrozen) {
mManager.HIDDeviceFeatureReport(getId(), characteristic.getValue());
}
finishCurrentGattOperation();
}
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
//Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid());
if (characteristic.getUuid().equals(reportCharacteristic)) {
// Only register controller with the native side once it has been fully configured
if (!isRegistered()) {
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0);
setRegistered();
}
}
finishCurrentGattOperation();
}
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
// Enable this for verbose logging of controller input reports
//Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue()));
if (characteristic.getUuid().equals(inputCharacteristic) && !mFrozen) {
mManager.HIDDeviceInputReport(getId(), characteristic.getValue());
}
}
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
//Log.v(TAG, "onDescriptorRead status=" + status);
}
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
BluetoothGattCharacteristic chr = descriptor.getCharacteristic();
//Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid());
if (chr.getUuid().equals(inputCharacteristic)) {
boolean hasWrittenInputDescriptor = true;
BluetoothGattCharacteristic reportChr = chr.getService().getCharacteristic(reportCharacteristic);
if (reportChr != null) {
Log.v(TAG, "Writing report characteristic to enter valve mode");
reportChr.setValue(enterValveMode);
gatt.writeCharacteristic(reportChr);
}
}
finishCurrentGattOperation();
}
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
//Log.v(TAG, "onReliableWriteCompleted status=" + status);
}
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
//Log.v(TAG, "onReadRemoteRssi status=" + status);
}
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
//Log.v(TAG, "onMtuChanged status=" + status);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////// Public API
//////////////////////////////////////////////////////////////////////////////////////////////////////
@Override
public int getId() {
return mDeviceId;
}
@Override
public int getVendorId() {
// Valve Corporation
final int VALVE_USB_VID = 0x28DE;
return VALVE_USB_VID;
}
@Override
public int getProductId() {
// We don't have an easy way to query from the Bluetooth device, but we know what it is
final int D0G_BLE2_PID = 0x1106;
return D0G_BLE2_PID;
}
@Override
public String getSerialNumber() {
// This will be read later via feature report by Steam
return "12345";
}
@Override
public int getVersion() {
return 0;
}
@Override
public String getManufacturerName() {
return "Valve Corporation";
}
@Override
public String getProductName() {
return "Steam Controller";
}
@Override
public UsbDevice getDevice() {
return null;
}
@Override
public boolean open() {
return true;
}
@Override
public int sendFeatureReport(byte[] report) {
if (!isRegistered()) {
Log.e(TAG, "Attempted sendFeatureReport before Steam Controller is registered!");
if (mIsConnected) {
probeService(this);
}
return -1;
}
// We need to skip the first byte, as that doesn't go over the air
byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(actual_report));
writeCharacteristic(reportCharacteristic, actual_report);
return report.length;
}
@Override
public int sendOutputReport(byte[] report) {
if (!isRegistered()) {
Log.e(TAG, "Attempted sendOutputReport before Steam Controller is registered!");
if (mIsConnected) {
probeService(this);
}
return -1;
}
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(report));
writeCharacteristic(reportCharacteristic, report);
return report.length;
}
@Override
public boolean getFeatureReport(byte[] report) {
if (!isRegistered()) {
Log.e(TAG, "Attempted getFeatureReport before Steam Controller is registered!");
if (mIsConnected) {
probeService(this);
}
return false;
}
//Log.v(TAG, "getFeatureReport");
readCharacteristic(reportCharacteristic);
return true;
}
@Override
public void close() {
}
@Override
public void setFrozen(boolean frozen) {
mFrozen = frozen;
}
@Override
public void shutdown() {
close();
BluetoothGatt g = mGatt;
if (g != null) {
g.disconnect();
g.close();
mGatt = null;
}
mManager = null;
mIsRegistered = false;
mIsConnected = false;
mOperations.clear();
}
}
@@ -1,669 +0,0 @@
package org.libsdl.app;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
import android.util.Log;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.hardware.usb.*;
import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
public class HIDDeviceManager {
private static final String TAG = "hidapi";
private static final String ACTION_USB_PERMISSION = "org.libsdl.app.USB_PERMISSION";
private static HIDDeviceManager sManager;
private static int sManagerRefCount = 0;
public static HIDDeviceManager acquire(Context context) {
if (sManagerRefCount == 0) {
sManager = new HIDDeviceManager(context);
}
++sManagerRefCount;
return sManager;
}
public static void release(HIDDeviceManager manager) {
if (manager == sManager) {
--sManagerRefCount;
if (sManagerRefCount == 0) {
sManager.close();
sManager = null;
}
}
}
private Context mContext;
private HashMap<Integer, HIDDevice> mDevicesById = new HashMap<Integer, HIDDevice>();
private HashMap<BluetoothDevice, HIDDeviceBLESteamController> mBluetoothDevices = new HashMap<BluetoothDevice, HIDDeviceBLESteamController>();
private int mNextDeviceId = 0;
private SharedPreferences mSharedPreferences = null;
private boolean mIsChromebook = false;
private UsbManager mUsbManager;
private Handler mHandler;
private BluetoothManager mBluetoothManager;
private List<BluetoothDevice> mLastBluetoothDevices;
private final BroadcastReceiver mUsbBroadcast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
handleUsbDeviceAttached(usbDevice);
} else if (action.equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
handleUsbDeviceDetached(usbDevice);
} else if (action.equals(HIDDeviceManager.ACTION_USB_PERMISSION)) {
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
handleUsbDevicePermission(usbDevice, intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false));
}
}
};
private final BroadcastReceiver mBluetoothBroadcast = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// Bluetooth device was connected. If it was a Steam Controller, handle it
if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.d(TAG, "Bluetooth device connected: " + device);
if (isSteamController(device)) {
connectBluetoothDevice(device);
}
}
// Bluetooth device was disconnected, remove from controller manager (if any)
if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.d(TAG, "Bluetooth device disconnected: " + device);
disconnectBluetoothDevice(device);
}
}
};
private HIDDeviceManager(final Context context) {
mContext = context;
// Make sure we have the HIDAPI library loaded with the native functions
try {
SDL.loadLibrary("hidapi");
} catch (Throwable e) {
Log.w(TAG, "Couldn't load hidapi: " + e.toString());
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(false);
builder.setTitle("SDL HIDAPI Error");
builder.setMessage("Please report the following error to the SDL maintainers: " + e.getMessage());
builder.setNegativeButton("Quit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
// If our context is an activity, exit rather than crashing when we can't
// call our native functions.
Activity activity = (Activity)context;
activity.finish();
}
catch (ClassCastException cce) {
// Context wasn't an activity, there's nothing we can do. Give up and return.
}
}
});
builder.show();
return;
}
HIDDeviceRegisterCallback();
mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
mIsChromebook = mContext.getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
// if (shouldClear) {
// SharedPreferences.Editor spedit = mSharedPreferences.edit();
// spedit.clear();
// spedit.commit();
// }
// else
{
mNextDeviceId = mSharedPreferences.getInt("next_device_id", 0);
}
initializeUSB();
initializeBluetooth();
}
public Context getContext() {
return mContext;
}
public int getDeviceIDForIdentifier(String identifier) {
SharedPreferences.Editor spedit = mSharedPreferences.edit();
int result = mSharedPreferences.getInt(identifier, 0);
if (result == 0) {
result = mNextDeviceId++;
spedit.putInt("next_device_id", mNextDeviceId);
}
spedit.putInt(identifier, result);
spedit.commit();
return result;
}
private void initializeUSB() {
mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
/*
// Logging
for (UsbDevice device : mUsbManager.getDeviceList().values()) {
Log.i(TAG,"Path: " + device.getDeviceName());
Log.i(TAG,"Manufacturer: " + device.getManufacturerName());
Log.i(TAG,"Product: " + device.getProductName());
Log.i(TAG,"ID: " + device.getDeviceId());
Log.i(TAG,"Class: " + device.getDeviceClass());
Log.i(TAG,"Protocol: " + device.getDeviceProtocol());
Log.i(TAG,"Vendor ID " + device.getVendorId());
Log.i(TAG,"Product ID: " + device.getProductId());
Log.i(TAG,"Interface count: " + device.getInterfaceCount());
Log.i(TAG,"---------------------------------------");
// Get interface details
for (int index = 0; index < device.getInterfaceCount(); index++) {
UsbInterface mUsbInterface = device.getInterface(index);
Log.i(TAG," ***** *****");
Log.i(TAG," Interface index: " + index);
Log.i(TAG," Interface ID: " + mUsbInterface.getId());
Log.i(TAG," Interface class: " + mUsbInterface.getInterfaceClass());
Log.i(TAG," Interface subclass: " + mUsbInterface.getInterfaceSubclass());
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
// Get endpoint details
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
{
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
Log.i(TAG," ++++ ++++ ++++");
Log.i(TAG," Endpoint index: " + epi);
Log.i(TAG," Attributes: " + mEndpoint.getAttributes());
Log.i(TAG," Direction: " + mEndpoint.getDirection());
Log.i(TAG," Number: " + mEndpoint.getEndpointNumber());
Log.i(TAG," Interval: " + mEndpoint.getInterval());
Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize());
Log.i(TAG," Type: " + mEndpoint.getType());
}
}
}
Log.i(TAG," No more devices connected.");
*/
// Register for USB broadcasts and permission completions
IntentFilter filter = new IntentFilter();
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
filter.addAction(HIDDeviceManager.ACTION_USB_PERMISSION);
mContext.registerReceiver(mUsbBroadcast, filter);
for (UsbDevice usbDevice : mUsbManager.getDeviceList().values()) {
handleUsbDeviceAttached(usbDevice);
}
}
UsbManager getUSBManager() {
return mUsbManager;
}
private void shutdownUSB() {
try {
mContext.unregisterReceiver(mUsbBroadcast);
} catch (Exception e) {
// We may not have registered, that's okay
}
}
private boolean isHIDDeviceInterface(UsbDevice usbDevice, UsbInterface usbInterface) {
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) {
return true;
}
if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) {
return true;
}
return false;
}
private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
final int XB360_IFACE_SUBCLASS = 93;
final int XB360_IFACE_PROTOCOL = 1; // Wired
final int XB360W_IFACE_PROTOCOL = 129; // Wireless
final int[] SUPPORTED_VENDORS = {
0x0079, // GPD Win 2
0x044f, // Thrustmaster
0x045e, // Microsoft
0x046d, // Logitech
0x056e, // Elecom
0x06a3, // Saitek
0x0738, // Mad Catz
0x07ff, // Mad Catz
0x0e6f, // PDP
0x0f0d, // Hori
0x1038, // SteelSeries
0x11c9, // Nacon
0x12ab, // Unknown
0x1430, // RedOctane
0x146b, // BigBen
0x1532, // Razer Sabertooth
0x15e4, // Numark
0x162e, // Joytech
0x1689, // Razer Onza
0x1bad, // Harmonix
0x24c6, // PowerA
};
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
usbInterface.getInterfaceSubclass() == XB360_IFACE_SUBCLASS &&
(usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL ||
usbInterface.getInterfaceProtocol() == XB360W_IFACE_PROTOCOL)) {
int vendor_id = usbDevice.getVendorId();
for (int supportedVid : SUPPORTED_VENDORS) {
if (vendor_id == supportedVid) {
return true;
}
}
}
return false;
}
private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) {
final int XB1_IFACE_SUBCLASS = 71;
final int XB1_IFACE_PROTOCOL = 208;
final int[] SUPPORTED_VENDORS = {
0x045e, // Microsoft
0x0738, // Mad Catz
0x0e6f, // PDP
0x0f0d, // Hori
0x1532, // Razer Wildcat
0x24c6, // PowerA
0x2e24, // Hyperkin
};
if (usbInterface.getId() == 0 &&
usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
usbInterface.getInterfaceSubclass() == XB1_IFACE_SUBCLASS &&
usbInterface.getInterfaceProtocol() == XB1_IFACE_PROTOCOL) {
int vendor_id = usbDevice.getVendorId();
for (int supportedVid : SUPPORTED_VENDORS) {
if (vendor_id == supportedVid) {
return true;
}
}
}
return false;
}
private void handleUsbDeviceAttached(UsbDevice usbDevice) {
connectHIDDeviceUSB(usbDevice);
}
private void handleUsbDeviceDetached(UsbDevice usbDevice) {
List<Integer> devices = new ArrayList<Integer>();
for (HIDDevice device : mDevicesById.values()) {
if (usbDevice.equals(device.getDevice())) {
devices.add(device.getId());
}
}
for (int id : devices) {
HIDDevice device = mDevicesById.get(id);
mDevicesById.remove(id);
device.shutdown();
HIDDeviceDisconnected(id);
}
}
private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
for (HIDDevice device : mDevicesById.values()) {
if (usbDevice.equals(device.getDevice())) {
boolean opened = false;
if (permission_granted) {
opened = device.open();
}
HIDDeviceOpenResult(device.getId(), opened);
}
}
}
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
synchronized (this) {
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
int id = device.getId();
mDevicesById.put(id, device);
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol());
}
}
}
}
private void initializeBluetooth() {
Log.d(TAG, "Initializing Bluetooth");
if (mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
return;
}
// Find bonded bluetooth controllers and create SteamControllers for them
mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE);
if (mBluetoothManager == null) {
// This device doesn't support Bluetooth.
return;
}
BluetoothAdapter btAdapter = mBluetoothManager.getAdapter();
if (btAdapter == null) {
// This device has Bluetooth support in the codebase, but has no available adapters.
return;
}
// Get our bonded devices.
for (BluetoothDevice device : btAdapter.getBondedDevices()) {
Log.d(TAG, "Bluetooth device available: " + device);
if (isSteamController(device)) {
connectBluetoothDevice(device);
}
}
// NOTE: These don't work on Chromebooks, to my undying dismay.
IntentFilter filter = new IntentFilter();
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
mContext.registerReceiver(mBluetoothBroadcast, filter);
if (mIsChromebook) {
mHandler = new Handler(Looper.getMainLooper());
mLastBluetoothDevices = new ArrayList<BluetoothDevice>();
// final HIDDeviceManager finalThis = this;
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// finalThis.chromebookConnectionHandler();
// }
// }, 5000);
}
}
private void shutdownBluetooth() {
try {
mContext.unregisterReceiver(mBluetoothBroadcast);
} catch (Exception e) {
// We may not have registered, that's okay
}
}
// Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly.
// This function provides a sort of dummy version of that, watching for changes in the
// connected devices and attempting to add controllers as things change.
public void chromebookConnectionHandler() {
if (!mIsChromebook) {
return;
}
ArrayList<BluetoothDevice> disconnected = new ArrayList<BluetoothDevice>();
ArrayList<BluetoothDevice> connected = new ArrayList<BluetoothDevice>();
List<BluetoothDevice> currentConnected = mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT);
for (BluetoothDevice bluetoothDevice : currentConnected) {
if (!mLastBluetoothDevices.contains(bluetoothDevice)) {
connected.add(bluetoothDevice);
}
}
for (BluetoothDevice bluetoothDevice : mLastBluetoothDevices) {
if (!currentConnected.contains(bluetoothDevice)) {
disconnected.add(bluetoothDevice);
}
}
mLastBluetoothDevices = currentConnected;
for (BluetoothDevice bluetoothDevice : disconnected) {
disconnectBluetoothDevice(bluetoothDevice);
}
for (BluetoothDevice bluetoothDevice : connected) {
connectBluetoothDevice(bluetoothDevice);
}
final HIDDeviceManager finalThis = this;
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
finalThis.chromebookConnectionHandler();
}
}, 10000);
}
public boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
Log.v(TAG, "connectBluetoothDevice device=" + bluetoothDevice);
synchronized (this) {
if (mBluetoothDevices.containsKey(bluetoothDevice)) {
Log.v(TAG, "Steam controller with address " + bluetoothDevice + " already exists, attempting reconnect");
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
device.reconnect();
return false;
}
HIDDeviceBLESteamController device = new HIDDeviceBLESteamController(this, bluetoothDevice);
int id = device.getId();
mBluetoothDevices.put(bluetoothDevice, device);
mDevicesById.put(id, device);
// The Steam Controller will mark itself connected once initialization is complete
}
return true;
}
public void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
synchronized (this) {
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
if (device == null)
return;
int id = device.getId();
mBluetoothDevices.remove(bluetoothDevice);
mDevicesById.remove(id);
device.shutdown();
HIDDeviceDisconnected(id);
}
}
public boolean isSteamController(BluetoothDevice bluetoothDevice) {
// Sanity check. If you pass in a null device, by definition it is never a Steam Controller.
if (bluetoothDevice == null) {
return false;
}
// If the device has no local name, we really don't want to try an equality check against it.
if (bluetoothDevice.getName() == null) {
return false;
}
return bluetoothDevice.getName().equals("SteamController") && ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) != 0);
}
private void close() {
shutdownUSB();
shutdownBluetooth();
synchronized (this) {
for (HIDDevice device : mDevicesById.values()) {
device.shutdown();
}
mDevicesById.clear();
mBluetoothDevices.clear();
HIDDeviceReleaseCallback();
}
}
public void setFrozen(boolean frozen) {
synchronized (this) {
for (HIDDevice device : mDevicesById.values()) {
device.setFrozen(frozen);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
private HIDDevice getDevice(int id) {
synchronized (this) {
HIDDevice result = mDevicesById.get(id);
if (result == null) {
Log.v(TAG, "No device for id: " + id);
Log.v(TAG, "Available devices: " + mDevicesById.keySet());
}
return result;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
////////// JNI interface functions
//////////////////////////////////////////////////////////////////////////////////////////////////////
public boolean openDevice(int deviceID) {
Log.v(TAG, "openDevice deviceID=" + deviceID);
HIDDevice device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return false;
}
// Look to see if this is a USB device and we have permission to access it
UsbDevice usbDevice = device.getDevice();
if (usbDevice != null && !mUsbManager.hasPermission(usbDevice)) {
HIDDeviceOpenPending(deviceID);
try {
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
} catch (Exception e) {
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
HIDDeviceOpenResult(deviceID, false);
}
return false;
}
try {
return device.open();
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
}
return false;
}
public int sendOutputReport(int deviceID, byte[] report) {
try {
//Log.v(TAG, "sendOutputReport deviceID=" + deviceID + " length=" + report.length);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return -1;
}
return device.sendOutputReport(report);
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
}
return -1;
}
public int sendFeatureReport(int deviceID, byte[] report) {
try {
//Log.v(TAG, "sendFeatureReport deviceID=" + deviceID + " length=" + report.length);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return -1;
}
return device.sendFeatureReport(report);
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
}
return -1;
}
public boolean getFeatureReport(int deviceID, byte[] report) {
try {
//Log.v(TAG, "getFeatureReport deviceID=" + deviceID);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return false;
}
return device.getFeatureReport(report);
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
}
return false;
}
public void closeDevice(int deviceID) {
try {
Log.v(TAG, "closeDevice deviceID=" + deviceID);
HIDDevice device;
device = getDevice(deviceID);
if (device == null) {
HIDDeviceDisconnected(deviceID);
return;
}
device.close();
} catch (Exception e) {
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////// Native methods
//////////////////////////////////////////////////////////////////////////////////////////////////////
private native void HIDDeviceRegisterCallback();
private native void HIDDeviceReleaseCallback();
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol);
native void HIDDeviceOpenPending(int deviceID);
native void HIDDeviceOpenResult(int deviceID, boolean opened);
native void HIDDeviceDisconnected(int deviceID);
native void HIDDeviceInputReport(int deviceID, byte[] report);
native void HIDDeviceFeatureReport(int deviceID, byte[] report);
}
@@ -1,304 +0,0 @@
package org.libsdl.app;
import android.hardware.usb.*;
import android.os.Build;
import android.util.Log;
import java.util.Arrays;
class HIDDeviceUSB implements HIDDevice {
private static final String TAG = "hidapi";
protected HIDDeviceManager mManager;
protected UsbDevice mDevice;
protected int mInterfaceIndex;
protected int mInterface;
protected int mDeviceId;
protected UsbDeviceConnection mConnection;
protected UsbEndpoint mInputEndpoint;
protected UsbEndpoint mOutputEndpoint;
protected InputThread mInputThread;
protected boolean mRunning;
protected boolean mFrozen;
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_index) {
mManager = manager;
mDevice = usbDevice;
mInterfaceIndex = interface_index;
mInterface = mDevice.getInterface(mInterfaceIndex).getId();
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
mRunning = false;
}
public String getIdentifier() {
return String.format("%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex);
}
@Override
public int getId() {
return mDeviceId;
}
@Override
public int getVendorId() {
return mDevice.getVendorId();
}
@Override
public int getProductId() {
return mDevice.getProductId();
}
@Override
public String getSerialNumber() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getSerialNumber();
}
if (result == null) {
result = "";
}
return result;
}
@Override
public int getVersion() {
return 0;
}
@Override
public String getManufacturerName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getManufacturerName();
}
if (result == null) {
result = String.format("%x", getVendorId());
}
return result;
}
@Override
public String getProductName() {
String result = null;
if (Build.VERSION.SDK_INT >= 21) {
result = mDevice.getProductName();
}
if (result == null) {
result = String.format("%x", getProductId());
}
return result;
}
@Override
public UsbDevice getDevice() {
return mDevice;
}
public String getDeviceName() {
return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")";
}
@Override
public boolean open() {
mConnection = mManager.getUSBManager().openDevice(mDevice);
if (mConnection == null) {
Log.w(TAG, "Unable to open USB device " + getDeviceName());
return false;
}
// Force claim our interface
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
if (!mConnection.claimInterface(iface, true)) {
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
close();
return false;
}
// Find the endpoints
for (int j = 0; j < iface.getEndpointCount(); j++) {
UsbEndpoint endpt = iface.getEndpoint(j);
switch (endpt.getDirection()) {
case UsbConstants.USB_DIR_IN:
if (mInputEndpoint == null) {
mInputEndpoint = endpt;
}
break;
case UsbConstants.USB_DIR_OUT:
if (mOutputEndpoint == null) {
mOutputEndpoint = endpt;
}
break;
}
}
// Make sure the required endpoints were present
if (mInputEndpoint == null || mOutputEndpoint == null) {
Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName());
close();
return false;
}
// Start listening for input
mRunning = true;
mInputThread = new InputThread();
mInputThread.start();
return true;
}
@Override
public int sendFeatureReport(byte[] report) {
int res = -1;
int offset = 0;
int length = report.length;
boolean skipped_report_id = false;
byte report_number = report[0];
if (report_number == 0x0) {
++offset;
--length;
skipped_report_id = true;
}
res = mConnection.controlTransfer(
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
0x09/*HID set_report*/,
(3/*HID feature*/ << 8) | report_number,
mInterface,
report, offset, length,
1000/*timeout millis*/);
if (res < 0) {
Log.w(TAG, "sendFeatureReport() returned " + res + " on device " + getDeviceName());
return -1;
}
if (skipped_report_id) {
++length;
}
return length;
}
@Override
public int sendOutputReport(byte[] report) {
int r = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000);
if (r != report.length) {
Log.w(TAG, "sendOutputReport() returned " + r + " on device " + getDeviceName());
}
return r;
}
@Override
public boolean getFeatureReport(byte[] report) {
int res = -1;
int offset = 0;
int length = report.length;
boolean skipped_report_id = false;
byte report_number = report[0];
if (report_number == 0x0) {
/* Offset the return buffer by 1, so that the report ID
will remain in byte 0. */
++offset;
--length;
skipped_report_id = true;
}
res = mConnection.controlTransfer(
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
0x01/*HID get_report*/,
(3/*HID feature*/ << 8) | report_number,
mInterface,
report, offset, length,
1000/*timeout millis*/);
if (res < 0) {
Log.w(TAG, "getFeatureReport() returned " + res + " on device " + getDeviceName());
return false;
}
if (skipped_report_id) {
++res;
++length;
}
byte[] data;
if (res == length) {
data = report;
} else {
data = Arrays.copyOfRange(report, 0, res);
}
mManager.HIDDeviceFeatureReport(mDeviceId, data);
return true;
}
@Override
public void close() {
mRunning = false;
if (mInputThread != null) {
while (mInputThread.isAlive()) {
mInputThread.interrupt();
try {
mInputThread.join();
} catch (InterruptedException e) {
// Keep trying until we're done
}
}
mInputThread = null;
}
if (mConnection != null) {
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
mConnection.releaseInterface(iface);
mConnection.close();
mConnection = null;
}
}
@Override
public void shutdown() {
close();
mManager = null;
}
@Override
public void setFrozen(boolean frozen) {
mFrozen = frozen;
}
protected class InputThread extends Thread {
@Override
public void run() {
int packetSize = mInputEndpoint.getMaxPacketSize();
byte[] packet = new byte[packetSize];
while (mRunning) {
int r;
try
{
r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
}
catch (Exception e)
{
Log.v(TAG, "Exception in UsbDeviceConnection bulktransfer: " + e);
break;
}
if (r < 0) {
// Could be a timeout or an I/O error
}
if (r > 0) {
byte[] data;
if (r == packetSize) {
data = packet;
} else {
data = Arrays.copyOfRange(packet, 0, r);
}
if (!mFrozen) {
mManager.HIDDeviceInputReport(mDeviceId, data);
}
}
}
}
}
}
@@ -1,84 +0,0 @@
package org.libsdl.app;
import android.content.Context;
import java.lang.reflect.*;
/**
SDL library initialization
*/
public class SDL {
// This function should be called first and sets up the native code
// so it can call into the Java classes
public static void setupJNI() {
SDLActivity.nativeSetupJNI();
SDLAudioManager.nativeSetupJNI();
SDLControllerManager.nativeSetupJNI();
}
// This function should be called each time the activity is started
public static void initialize() {
setContext(null);
SDLActivity.initialize();
SDLAudioManager.initialize();
SDLControllerManager.initialize();
}
// This function stores the current activity (SDL or not)
public static void setContext(Context context) {
mContext = context;
}
public static Context getContext() {
return mContext;
}
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
if (libraryName == null) {
throw new NullPointerException("No library name provided.");
}
try {
// Let's see if we have ReLinker available in the project. This is necessary for
// some projects that have huge numbers of local libraries bundled, and thus may
// trip a bug in Android's native library loader which ReLinker works around. (If
// loadLibrary works properly, ReLinker will simply use the normal Android method
// internally.)
//
// To use ReLinker, just add it as a dependency. For more information, see
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
//
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// they've changed during updates.
Method forceMethod = relinkClass.getDeclaredMethod("force");
Object relinkInstance = forceMethod.invoke(null);
Class relinkInstanceClass = relinkInstance.getClass();
// Actually load the library!
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
}
catch (final Throwable e) {
// Fall back
try {
System.loadLibrary(libraryName);
}
catch (final UnsatisfiedLinkError ule) {
throw ule;
}
catch (final SecurityException se) {
throw se;
}
}
}
protected static Context mContext;
}
File diff suppressed because it is too large Load Diff
@@ -1,387 +0,0 @@
package org.libsdl.app;
import android.media.*;
import android.os.Build;
import android.util.Log;
public class SDLAudioManager
{
protected static final String TAG = "SDLAudio";
protected static AudioTrack mAudioTrack;
protected static AudioRecord mAudioRecord;
public static void initialize() {
mAudioTrack = null;
mAudioRecord = null;
}
// Audio
protected static String getAudioFormatString(int audioFormat) {
switch (audioFormat) {
case AudioFormat.ENCODING_PCM_8BIT:
return "8-bit";
case AudioFormat.ENCODING_PCM_16BIT:
return "16-bit";
case AudioFormat.ENCODING_PCM_FLOAT:
return "float";
default:
return Integer.toString(audioFormat);
}
}
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
int channelConfig;
int sampleSize;
int frameSize;
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
/* On older devices let's use known good settings */
if (Build.VERSION.SDK_INT < 21) {
if (desiredChannels > 2) {
desiredChannels = 2;
}
if (sampleRate < 8000) {
sampleRate = 8000;
} else if (sampleRate > 48000) {
sampleRate = 48000;
}
}
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
int minSDKVersion = (isCapture ? 23 : 21);
if (Build.VERSION.SDK_INT < minSDKVersion) {
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
}
}
switch (audioFormat)
{
case AudioFormat.ENCODING_PCM_8BIT:
sampleSize = 1;
break;
case AudioFormat.ENCODING_PCM_16BIT:
sampleSize = 2;
break;
case AudioFormat.ENCODING_PCM_FLOAT:
sampleSize = 4;
break;
default:
Log.v(TAG, "Requested format " + audioFormat + ", getting ENCODING_PCM_16BIT");
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
sampleSize = 2;
break;
}
if (isCapture) {
switch (desiredChannels) {
case 1:
channelConfig = AudioFormat.CHANNEL_IN_MONO;
break;
case 2:
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
break;
default:
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
desiredChannels = 2;
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
break;
}
} else {
switch (desiredChannels) {
case 1:
channelConfig = AudioFormat.CHANNEL_OUT_MONO;
break;
case 2:
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
break;
case 3:
channelConfig = AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
break;
case 4:
channelConfig = AudioFormat.CHANNEL_OUT_QUAD;
break;
case 5:
channelConfig = AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
break;
case 6:
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
break;
case 7:
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
break;
case 8:
if (Build.VERSION.SDK_INT >= 23) {
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
} else {
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
desiredChannels = 6;
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
}
break;
default:
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
desiredChannels = 2;
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
break;
}
/*
Log.v(TAG, "Speaker configuration (and order of channels):");
if ((channelConfig & 0x00000004) != 0) {
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT");
}
if ((channelConfig & 0x00000008) != 0) {
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT");
}
if ((channelConfig & 0x00000010) != 0) {
Log.v(TAG, " CHANNEL_OUT_FRONT_CENTER");
}
if ((channelConfig & 0x00000020) != 0) {
Log.v(TAG, " CHANNEL_OUT_LOW_FREQUENCY");
}
if ((channelConfig & 0x00000040) != 0) {
Log.v(TAG, " CHANNEL_OUT_BACK_LEFT");
}
if ((channelConfig & 0x00000080) != 0) {
Log.v(TAG, " CHANNEL_OUT_BACK_RIGHT");
}
if ((channelConfig & 0x00000100) != 0) {
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT_OF_CENTER");
}
if ((channelConfig & 0x00000200) != 0) {
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT_OF_CENTER");
}
if ((channelConfig & 0x00000400) != 0) {
Log.v(TAG, " CHANNEL_OUT_BACK_CENTER");
}
if ((channelConfig & 0x00000800) != 0) {
Log.v(TAG, " CHANNEL_OUT_SIDE_LEFT");
}
if ((channelConfig & 0x00001000) != 0) {
Log.v(TAG, " CHANNEL_OUT_SIDE_RIGHT");
}
*/
}
frameSize = (sampleSize * desiredChannels);
// Let the user pick a larger buffer if they really want -- but ye
// gods they probably shouldn't, the minimums are horrifyingly high
// latency already
int minBufferSize;
if (isCapture) {
minBufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
} else {
minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat);
}
desiredFrames = Math.max(desiredFrames, (minBufferSize + frameSize - 1) / frameSize);
int[] results = new int[4];
if (isCapture) {
if (mAudioRecord == null) {
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
channelConfig, audioFormat, desiredFrames * frameSize);
// see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
Log.e(TAG, "Failed during initialization of AudioRecord");
mAudioRecord.release();
mAudioRecord = null;
return null;
}
mAudioRecord.startRecording();
}
results[0] = mAudioRecord.getSampleRate();
results[1] = mAudioRecord.getAudioFormat();
results[2] = mAudioRecord.getChannelCount();
results[3] = desiredFrames;
} else {
if (mAudioTrack == null) {
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
// Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
// Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
// Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
/* Try again, with safer values */
Log.e(TAG, "Failed during initialization of Audio Track");
mAudioTrack.release();
mAudioTrack = null;
return null;
}
mAudioTrack.play();
}
results[0] = mAudioTrack.getSampleRate();
results[1] = mAudioTrack.getAudioFormat();
results[2] = mAudioTrack.getChannelCount();
results[3] = desiredFrames;
}
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", got " + results[3] + " frames of " + results[2] + " channel " + getAudioFormatString(results[1]) + " audio at " + results[0] + " Hz");
return results;
}
/**
* This method is called by SDL using JNI.
*/
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames);
}
/**
* This method is called by SDL using JNI.
*/
public static void audioWriteFloatBuffer(float[] buffer) {
if (mAudioTrack == null) {
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
return;
}
for (int i = 0; i < buffer.length;) {
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch(InterruptedException e) {
// Nom nom
}
} else {
Log.w(TAG, "SDL audio: error return from write(float)");
return;
}
}
}
/**
* This method is called by SDL using JNI.
*/
public static void audioWriteShortBuffer(short[] buffer) {
if (mAudioTrack == null) {
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
return;
}
for (int i = 0; i < buffer.length;) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch(InterruptedException e) {
// Nom nom
}
} else {
Log.w(TAG, "SDL audio: error return from write(short)");
return;
}
}
}
/**
* This method is called by SDL using JNI.
*/
public static void audioWriteByteBuffer(byte[] buffer) {
if (mAudioTrack == null) {
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
return;
}
for (int i = 0; i < buffer.length; ) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch(InterruptedException e) {
// Nom nom
}
} else {
Log.w(TAG, "SDL audio: error return from write(byte)");
return;
}
}
}
/**
* This method is called by SDL using JNI.
*/
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames);
}
/** This method is called by SDL using JNI. */
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
}
/** This method is called by SDL using JNI. */
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
if (Build.VERSION.SDK_INT < 23) {
return mAudioRecord.read(buffer, 0, buffer.length);
} else {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
}
}
/** This method is called by SDL using JNI. */
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
if (Build.VERSION.SDK_INT < 23) {
return mAudioRecord.read(buffer, 0, buffer.length);
} else {
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
}
}
/** This method is called by SDL using JNI. */
public static void audioClose() {
if (mAudioTrack != null) {
mAudioTrack.stop();
mAudioTrack.release();
mAudioTrack = null;
}
}
/** This method is called by SDL using JNI. */
public static void captureClose() {
if (mAudioRecord != null) {
mAudioRecord.stop();
mAudioRecord.release();
mAudioRecord = null;
}
}
/** This method is called by SDL using JNI. */
public static void audioSetThreadPriority(boolean iscapture, int device_id) {
try {
/* Set thread name */
if (iscapture) {
Thread.currentThread().setName("SDLAudioC" + device_id);
} else {
Thread.currentThread().setName("SDLAudioP" + device_id);
}
/* Set thread priority */
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);
} catch (Exception e) {
Log.v(TAG, "modify thread properties failed " + e.toString());
}
}
public static native int nativeSetupJNI();
}
@@ -1,788 +0,0 @@
package org.libsdl.app;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import android.content.Context;
import android.os.*;
import android.view.*;
import android.util.Log;
public class SDLControllerManager
{
public static native int nativeSetupJNI();
public static native int nativeAddJoystick(int device_id, String name, String desc,
int vendor_id, int product_id,
boolean is_accelerometer, int button_mask,
int naxes, int nhats, int nballs);
public static native int nativeRemoveJoystick(int device_id);
public static native int nativeAddHaptic(int device_id, String name);
public static native int nativeRemoveHaptic(int device_id);
public static native int onNativePadDown(int device_id, int keycode);
public static native int onNativePadUp(int device_id, int keycode);
public static native void onNativeJoy(int device_id, int axis,
float value);
public static native void onNativeHat(int device_id, int hat_id,
int x, int y);
protected static SDLJoystickHandler mJoystickHandler;
protected static SDLHapticHandler mHapticHandler;
private static final String TAG = "SDLControllerManager";
public static void initialize() {
if (mJoystickHandler == null) {
if (Build.VERSION.SDK_INT >= 19) {
mJoystickHandler = new SDLJoystickHandler_API19();
} else {
mJoystickHandler = new SDLJoystickHandler_API16();
}
}
if (mHapticHandler == null) {
if (Build.VERSION.SDK_INT >= 26) {
mHapticHandler = new SDLHapticHandler_API26();
} else {
mHapticHandler = new SDLHapticHandler();
}
}
}
// Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
public static boolean handleJoystickMotionEvent(MotionEvent event) {
return mJoystickHandler.handleMotionEvent(event);
}
/**
* This method is called by SDL using JNI.
*/
public static void pollInputDevices() {
mJoystickHandler.pollInputDevices();
}
/**
* This method is called by SDL using JNI.
*/
public static void pollHapticDevices() {
mHapticHandler.pollHapticDevices();
}
/**
* This method is called by SDL using JNI.
*/
public static void hapticRun(int device_id, float intensity, int length) {
mHapticHandler.run(device_id, intensity, length);
}
/**
* This method is called by SDL using JNI.
*/
public static void hapticStop(int device_id)
{
mHapticHandler.stop(device_id);
}
// Check if a given device is considered a possible SDL joystick
public static boolean isDeviceSDLJoystick(int deviceId) {
InputDevice device = InputDevice.getDevice(deviceId);
// We cannot use InputDevice.isVirtual before API 16, so let's accept
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
if ((device == null) || (deviceId < 0)) {
return false;
}
int sources = device.getSources();
/* This is called for every button press, so let's not spam the logs */
/**
if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
Log.v(TAG, "Input device " + device.getName() + " has class joystick.");
}
if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
}
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
}
**/
return ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ||
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
);
}
}
class SDLJoystickHandler {
/**
* Handles given MotionEvent.
* @param event the event to be handled.
* @return if given event was processed.
*/
public boolean handleMotionEvent(MotionEvent event) {
return false;
}
/**
* Handles adding and removing of input devices.
*/
public void pollInputDevices() {
}
}
/* Actual joystick functionality available for API >= 12 devices */
class SDLJoystickHandler_API16 extends SDLJoystickHandler {
static class SDLJoystick {
public int device_id;
public String name;
public String desc;
public ArrayList<InputDevice.MotionRange> axes;
public ArrayList<InputDevice.MotionRange> hats;
}
static class RangeComparator implements Comparator<InputDevice.MotionRange> {
@Override
public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
// Some controllers, like the Moga Pro 2, return AXIS_GAS (22) for right trigger and AXIS_BRAKE (23) for left trigger - swap them so they're sorted in the right order for SDL
int arg0Axis = arg0.getAxis();
int arg1Axis = arg1.getAxis();
if (arg0Axis == MotionEvent.AXIS_GAS) {
arg0Axis = MotionEvent.AXIS_BRAKE;
} else if (arg0Axis == MotionEvent.AXIS_BRAKE) {
arg0Axis = MotionEvent.AXIS_GAS;
}
if (arg1Axis == MotionEvent.AXIS_GAS) {
arg1Axis = MotionEvent.AXIS_BRAKE;
} else if (arg1Axis == MotionEvent.AXIS_BRAKE) {
arg1Axis = MotionEvent.AXIS_GAS;
}
return arg0Axis - arg1Axis;
}
}
private ArrayList<SDLJoystick> mJoysticks;
public SDLJoystickHandler_API16() {
mJoysticks = new ArrayList<SDLJoystick>();
}
@Override
public void pollInputDevices() {
int[] deviceIds = InputDevice.getDeviceIds();
for(int i=0; i < deviceIds.length; ++i) {
SDLJoystick joystick = getJoystick(deviceIds[i]);
if (joystick == null) {
joystick = new SDLJoystick();
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
if (SDLControllerManager.isDeviceSDLJoystick(deviceIds[i])) {
joystick.device_id = deviceIds[i];
joystick.name = joystickDevice.getName();
joystick.desc = getJoystickDescriptor(joystickDevice);
joystick.axes = new ArrayList<InputDevice.MotionRange>();
joystick.hats = new ArrayList<InputDevice.MotionRange>();
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
Collections.sort(ranges, new RangeComparator());
for (InputDevice.MotionRange range : ranges ) {
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
joystick.hats.add(range);
}
else {
joystick.axes.add(range);
}
}
}
mJoysticks.add(joystick);
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, getVendorId(joystickDevice), getProductId(joystickDevice), false, getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
}
}
}
/* Check removed devices */
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
for(int i=0; i < mJoysticks.size(); i++) {
int device_id = mJoysticks.get(i).device_id;
int j;
for (j=0; j < deviceIds.length; j++) {
if (device_id == deviceIds[j]) break;
}
if (j == deviceIds.length) {
removedDevices.add(Integer.valueOf(device_id));
}
}
for(int i=0; i < removedDevices.size(); i++) {
int device_id = removedDevices.get(i).intValue();
SDLControllerManager.nativeRemoveJoystick(device_id);
for (int j=0; j < mJoysticks.size(); j++) {
if (mJoysticks.get(j).device_id == device_id) {
mJoysticks.remove(j);
break;
}
}
}
}
protected SDLJoystick getJoystick(int device_id) {
for(int i=0; i < mJoysticks.size(); i++) {
if (mJoysticks.get(i).device_id == device_id) {
return mJoysticks.get(i);
}
}
return null;
}
@Override
public boolean handleMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
int actionPointerIndex = event.getActionIndex();
int action = event.getActionMasked();
switch(action) {
case MotionEvent.ACTION_MOVE:
SDLJoystick joystick = getJoystick(event.getDeviceId());
if ( joystick != null ) {
for (int i = 0; i < joystick.axes.size(); i++) {
InputDevice.MotionRange range = joystick.axes.get(i);
/* Normalize the value to -1...1 */
float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
SDLControllerManager.onNativeJoy(joystick.device_id, i, value );
}
for (int i = 0; i < joystick.hats.size(); i+=2) {
int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY );
}
}
break;
default:
break;
}
}
return true;
}
public String getJoystickDescriptor(InputDevice joystickDevice) {
String desc = joystickDevice.getDescriptor();
if (desc != null && !desc.isEmpty()) {
return desc;
}
return joystickDevice.getName();
}
public int getProductId(InputDevice joystickDevice) {
return 0;
}
public int getVendorId(InputDevice joystickDevice) {
return 0;
}
public int getButtonMask(InputDevice joystickDevice) {
return -1;
}
}
class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
@Override
public int getProductId(InputDevice joystickDevice) {
return joystickDevice.getProductId();
}
@Override
public int getVendorId(InputDevice joystickDevice) {
return joystickDevice.getVendorId();
}
@Override
public int getButtonMask(InputDevice joystickDevice) {
int button_mask = 0;
int[] keys = new int[] {
KeyEvent.KEYCODE_BUTTON_A,
KeyEvent.KEYCODE_BUTTON_B,
KeyEvent.KEYCODE_BUTTON_X,
KeyEvent.KEYCODE_BUTTON_Y,
KeyEvent.KEYCODE_BACK,
KeyEvent.KEYCODE_BUTTON_MODE,
KeyEvent.KEYCODE_BUTTON_START,
KeyEvent.KEYCODE_BUTTON_THUMBL,
KeyEvent.KEYCODE_BUTTON_THUMBR,
KeyEvent.KEYCODE_BUTTON_L1,
KeyEvent.KEYCODE_BUTTON_R1,
KeyEvent.KEYCODE_DPAD_UP,
KeyEvent.KEYCODE_DPAD_DOWN,
KeyEvent.KEYCODE_DPAD_LEFT,
KeyEvent.KEYCODE_DPAD_RIGHT,
KeyEvent.KEYCODE_BUTTON_SELECT,
KeyEvent.KEYCODE_DPAD_CENTER,
// These don't map into any SDL controller buttons directly
KeyEvent.KEYCODE_BUTTON_L2,
KeyEvent.KEYCODE_BUTTON_R2,
KeyEvent.KEYCODE_BUTTON_C,
KeyEvent.KEYCODE_BUTTON_Z,
KeyEvent.KEYCODE_BUTTON_1,
KeyEvent.KEYCODE_BUTTON_2,
KeyEvent.KEYCODE_BUTTON_3,
KeyEvent.KEYCODE_BUTTON_4,
KeyEvent.KEYCODE_BUTTON_5,
KeyEvent.KEYCODE_BUTTON_6,
KeyEvent.KEYCODE_BUTTON_7,
KeyEvent.KEYCODE_BUTTON_8,
KeyEvent.KEYCODE_BUTTON_9,
KeyEvent.KEYCODE_BUTTON_10,
KeyEvent.KEYCODE_BUTTON_11,
KeyEvent.KEYCODE_BUTTON_12,
KeyEvent.KEYCODE_BUTTON_13,
KeyEvent.KEYCODE_BUTTON_14,
KeyEvent.KEYCODE_BUTTON_15,
KeyEvent.KEYCODE_BUTTON_16,
};
int[] masks = new int[] {
(1 << 0), // A -> A
(1 << 1), // B -> B
(1 << 2), // X -> X
(1 << 3), // Y -> Y
(1 << 4), // BACK -> BACK
(1 << 5), // MODE -> GUIDE
(1 << 6), // START -> START
(1 << 7), // THUMBL -> LEFTSTICK
(1 << 8), // THUMBR -> RIGHTSTICK
(1 << 9), // L1 -> LEFTSHOULDER
(1 << 10), // R1 -> RIGHTSHOULDER
(1 << 11), // DPAD_UP -> DPAD_UP
(1 << 12), // DPAD_DOWN -> DPAD_DOWN
(1 << 13), // DPAD_LEFT -> DPAD_LEFT
(1 << 14), // DPAD_RIGHT -> DPAD_RIGHT
(1 << 4), // SELECT -> BACK
(1 << 0), // DPAD_CENTER -> A
(1 << 15), // L2 -> ??
(1 << 16), // R2 -> ??
(1 << 17), // C -> ??
(1 << 18), // Z -> ??
(1 << 20), // 1 -> ??
(1 << 21), // 2 -> ??
(1 << 22), // 3 -> ??
(1 << 23), // 4 -> ??
(1 << 24), // 5 -> ??
(1 << 25), // 6 -> ??
(1 << 26), // 7 -> ??
(1 << 27), // 8 -> ??
(1 << 28), // 9 -> ??
(1 << 29), // 10 -> ??
(1 << 30), // 11 -> ??
(1 << 31), // 12 -> ??
// We're out of room...
0xFFFFFFFF, // 13 -> ??
0xFFFFFFFF, // 14 -> ??
0xFFFFFFFF, // 15 -> ??
0xFFFFFFFF, // 16 -> ??
};
boolean[] has_keys = joystickDevice.hasKeys(keys);
for (int i = 0; i < keys.length; ++i) {
if (has_keys[i]) {
button_mask |= masks[i];
}
}
return button_mask;
}
}
class SDLHapticHandler_API26 extends SDLHapticHandler {
@Override
public void run(int device_id, float intensity, int length) {
SDLHaptic haptic = getHaptic(device_id);
if (haptic != null) {
Log.d("SDL", "Rtest: Vibe with intensity " + intensity + " for " + length);
if (intensity == 0.0f) {
stop(device_id);
return;
}
int vibeValue = Math.round(intensity * 255);
if (vibeValue > 255) {
vibeValue = 255;
}
if (vibeValue < 1) {
stop(device_id);
return;
}
try {
haptic.vib.vibrate(VibrationEffect.createOneShot(length, vibeValue));
}
catch (Exception e) {
// Fall back to the generic method, which uses DEFAULT_AMPLITUDE, but works even if
// something went horribly wrong with the Android 8.0 APIs.
haptic.vib.vibrate(length);
}
}
}
}
class SDLHapticHandler {
class SDLHaptic {
public int device_id;
public String name;
public Vibrator vib;
}
private ArrayList<SDLHaptic> mHaptics;
public SDLHapticHandler() {
mHaptics = new ArrayList<SDLHaptic>();
}
public void run(int device_id, float intensity, int length) {
SDLHaptic haptic = getHaptic(device_id);
if (haptic != null) {
haptic.vib.vibrate(length);
}
}
public void stop(int device_id) {
SDLHaptic haptic = getHaptic(device_id);
if (haptic != null) {
haptic.vib.cancel();
}
}
public void pollHapticDevices() {
final int deviceId_VIBRATOR_SERVICE = 999999;
boolean hasVibratorService = false;
int[] deviceIds = InputDevice.getDeviceIds();
// It helps processing the device ids in reverse order
// For example, in the case of the XBox 360 wireless dongle,
// so the first controller seen by SDL matches what the receiver
// considers to be the first controller
for (int i = deviceIds.length - 1; i > -1; i--) {
SDLHaptic haptic = getHaptic(deviceIds[i]);
if (haptic == null) {
InputDevice device = InputDevice.getDevice(deviceIds[i]);
Vibrator vib = device.getVibrator();
if (vib.hasVibrator()) {
haptic = new SDLHaptic();
haptic.device_id = deviceIds[i];
haptic.name = device.getName();
haptic.vib = vib;
mHaptics.add(haptic);
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
}
}
}
/* Check VIBRATOR_SERVICE */
Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);
if (vib != null) {
hasVibratorService = vib.hasVibrator();
if (hasVibratorService) {
SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE);
if (haptic == null) {
haptic = new SDLHaptic();
haptic.device_id = deviceId_VIBRATOR_SERVICE;
haptic.name = "VIBRATOR_SERVICE";
haptic.vib = vib;
mHaptics.add(haptic);
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
}
}
}
/* Check removed devices */
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
for(int i=0; i < mHaptics.size(); i++) {
int device_id = mHaptics.get(i).device_id;
int j;
for (j=0; j < deviceIds.length; j++) {
if (device_id == deviceIds[j]) break;
}
if (device_id == deviceId_VIBRATOR_SERVICE && hasVibratorService) {
// don't remove the vibrator if it is still present
} else if (j == deviceIds.length) {
removedDevices.add(device_id);
}
}
for(int i=0; i < removedDevices.size(); i++) {
int device_id = removedDevices.get(i);
SDLControllerManager.nativeRemoveHaptic(device_id);
for (int j=0; j < mHaptics.size(); j++) {
if (mHaptics.get(j).device_id == device_id) {
mHaptics.remove(j);
break;
}
}
}
}
protected SDLHaptic getHaptic(int device_id) {
for(int i=0; i < mHaptics.size(); i++) {
if (mHaptics.get(i).device_id == device_id) {
return mHaptics.get(i);
}
}
return null;
}
}
class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
// Generic Motion (mouse hover, joystick...) events go here
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
float x, y;
int action;
switch ( event.getSource() ) {
case InputDevice.SOURCE_JOYSTICK:
case InputDevice.SOURCE_GAMEPAD:
case InputDevice.SOURCE_DPAD:
return SDLControllerManager.handleJoystickMotionEvent(event);
case InputDevice.SOURCE_MOUSE:
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
SDLActivity.onNativeMouse(0, action, x, y, false);
return true;
case MotionEvent.ACTION_HOVER_MOVE:
x = event.getX(0);
y = event.getY(0);
SDLActivity.onNativeMouse(0, action, x, y, false);
return true;
default:
break;
}
break;
default:
break;
}
// Event was not managed
return false;
}
public boolean supportsRelativeMouse() {
return false;
}
public boolean inRelativeMode() {
return false;
}
public boolean setRelativeMouseEnabled(boolean enabled) {
return false;
}
public void reclaimRelativeMouseModeIfNeeded()
{
}
public float getEventX(MotionEvent event) {
return event.getX(0);
}
public float getEventY(MotionEvent event) {
return event.getY(0);
}
}
class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
// Generic Motion (mouse hover, joystick...) events go here
private boolean mRelativeModeEnabled;
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
// Handle relative mouse mode
if (mRelativeModeEnabled) {
if (event.getSource() == InputDevice.SOURCE_MOUSE) {
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_HOVER_MOVE) {
float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
SDLActivity.onNativeMouse(0, action, x, y, true);
return true;
}
}
}
// Event was not managed, call SDLGenericMotionListener_API12 method
return super.onGenericMotion(v, event);
}
@Override
public boolean supportsRelativeMouse() {
return true;
}
@Override
public boolean inRelativeMode() {
return mRelativeModeEnabled;
}
@Override
public boolean setRelativeMouseEnabled(boolean enabled) {
mRelativeModeEnabled = enabled;
return true;
}
@Override
public float getEventX(MotionEvent event) {
if (mRelativeModeEnabled) {
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
}
else {
return event.getX(0);
}
}
@Override
public float getEventY(MotionEvent event) {
if (mRelativeModeEnabled) {
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
}
else {
return event.getY(0);
}
}
}
class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
// Generic Motion (mouse hover, joystick...) events go here
private boolean mRelativeModeEnabled;
@Override
public boolean onGenericMotion(View v, MotionEvent event) {
float x, y;
int action;
switch ( event.getSource() ) {
case InputDevice.SOURCE_JOYSTICK:
case InputDevice.SOURCE_GAMEPAD:
case InputDevice.SOURCE_DPAD:
return SDLControllerManager.handleJoystickMotionEvent(event);
case InputDevice.SOURCE_MOUSE:
// DeX desktop mouse cursor is a separate non-standard input type.
case InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN:
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
SDLActivity.onNativeMouse(0, action, x, y, false);
return true;
case MotionEvent.ACTION_HOVER_MOVE:
x = event.getX(0);
y = event.getY(0);
SDLActivity.onNativeMouse(0, action, x, y, false);
return true;
default:
break;
}
break;
case InputDevice.SOURCE_MOUSE_RELATIVE:
action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_SCROLL:
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
SDLActivity.onNativeMouse(0, action, x, y, false);
return true;
case MotionEvent.ACTION_HOVER_MOVE:
x = event.getX(0);
y = event.getY(0);
SDLActivity.onNativeMouse(0, action, x, y, true);
return true;
default:
break;
}
break;
default:
break;
}
// Event was not managed
return false;
}
@Override
public boolean supportsRelativeMouse() {
return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27));
}
@Override
public boolean inRelativeMode() {
return mRelativeModeEnabled;
}
@Override
public boolean setRelativeMouseEnabled(boolean enabled) {
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
if (enabled) {
SDLActivity.getContentView().requestPointerCapture();
}
else {
SDLActivity.getContentView().releasePointerCapture();
}
mRelativeModeEnabled = enabled;
return true;
}
else
{
return false;
}
}
@Override
public void reclaimRelativeMouseModeIfNeeded()
{
if (mRelativeModeEnabled && !SDLActivity.isDeXMode()) {
SDLActivity.getContentView().requestPointerCapture();
}
}
@Override
public float getEventX(MotionEvent event) {
// Relative mouse in capture mode will only have relative for X/Y
return event.getX(0);
}
@Override
public float getEventY(MotionEvent event) {
// Relative mouse in capture mode will only have relative for X/Y
return event.getY(0);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Some files were not shown because too many files have changed in this diff Show More