Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 443bc8218d | |||
| 648324069e | |||
| a3ec4f0470 |
+23
-21
@@ -1,28 +1,30 @@
|
||||
version: '{branch}.{build}'
|
||||
image: Visual Studio 2019
|
||||
configuration: Release
|
||||
platform: x86
|
||||
shallow_clone: true
|
||||
os: Windows
|
||||
clone_folder: C:\Projects\Cataclysm-DDA
|
||||
shallow_clone: true
|
||||
pull_requests:
|
||||
do_not_increment_build_number: false
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
PROJECT: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
COMPILER: msvc2017
|
||||
TOOLCHAIN: msvc15
|
||||
PLATFORM: x64
|
||||
CONFIGURATION: Release
|
||||
APPVEYOR_SAVE_CACHE_ON_ERROR: true
|
||||
matrix:
|
||||
fast_finish: false
|
||||
cache:
|
||||
- c:\tools\vcpkg\installed
|
||||
- c:\Users\appveyor\AppData\Local\vcpkg\
|
||||
- 'c:\tools\vcpkg\installed'
|
||||
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
|
||||
# Install dependency packages
|
||||
- cmd: vcpkg --triplet %PLATFORM%-windows-static install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext lua
|
||||
# Add LUA binary folder to PATH
|
||||
- cmd: set PATH=c:\tools\vcpkg\installed\%PLATFORM%-windows-static\tools\lua;%PATH%
|
||||
# Report LUA binary version
|
||||
- cmd: lua.exe -v
|
||||
build:
|
||||
project: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
parallel: true
|
||||
project: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
verbosity: minimal
|
||||
only_commits:
|
||||
files:
|
||||
- '.appveyor.yml'
|
||||
- 'msvc-full-features/**'
|
||||
- 'src/**'
|
||||
- 'tests/**'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
|
||||
-62
@@ -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
|
||||
@@ -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
|
||||
|
||||
+1
-6
@@ -7,11 +7,6 @@ root = true
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
# 4 space indentation
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.json]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
@@ -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
|
||||
+3
-2
@@ -1,14 +1,15 @@
|
||||
# Automatically normalize line endings for all files
|
||||
# Automatically normalise line endings for all files
|
||||
# detected as text (Convert CRLF => LF).
|
||||
* text=auto
|
||||
|
||||
# Explicitly normalize files with these extensions in
|
||||
# Explicitly normalise 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
|
||||
*.lua text
|
||||
*.md text
|
||||
*.py text
|
||||
*.rc text
|
||||
|
||||
@@ -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
|
||||
+53
-66
@@ -1,6 +1,6 @@
|
||||
# Contribute
|
||||
|
||||
**Opening a new issue?** Please read [ISSUES.md](../ISSUES.md) first.
|
||||
**Opening new issue?** Please read [ISSUES.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/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.
|
||||
|
||||
@@ -18,8 +18,7 @@ There are a couple of guidelines we suggest sticking to:
|
||||
|
||||
## Code Style
|
||||
|
||||
Code style is enforced across the codebase by `astyle`.
|
||||
See [CODE_STYLE](../doc/CODE_STYLE.md) for details.
|
||||
Current policy is to only update code to the standard style when changing a substantial portion of it, but **please** do this in a separate commit. See [CODE_STYLE](../doc/CODE_STYLE.md) for details.
|
||||
|
||||
## Translations
|
||||
|
||||
@@ -65,9 +64,9 @@ 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)
|
||||
http://www.stack.nl/~dimitri/doxygen/manual/commands.html
|
||||
http://www.stack.nl/~dimitri/doxygen/manual/markdown.html#markdown_std
|
||||
http://www.stack.nl/~dimitri/doxygen/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.
|
||||
@@ -121,9 +120,6 @@ For further details about commit message guidelines please visit:
|
||||
# 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
|
||||
|
||||
@@ -141,53 +137,30 @@ For further details about commit message guidelines please visit:
|
||||
$ 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).
|
||||
## Pull Request Notes
|
||||
If you file a PR but you're still working on it, please add a [WIP] before the title text. 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 by a merger just edit the title text to remove the [WIP].
|
||||
|
||||

|
||||
If you are also looking for suggestions then mark it with [CR] — "comments requested". You can use both [WIP] and [CR] to indicated that you need opinion/code review/suggestions to continue working (e.g. "[WIP] [CR] Super awesome big feature"). Feel free to remove [CR] when you feel you got enough information to proceed.
|
||||
|
||||
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.
|
||||
This can help speed up our review process by allowing us to only review the things that are ready for it, and will prevent anything that isn't completely ready from being merged in.
|
||||
|
||||

|
||||
### All PRs should have a "Summary" line
|
||||
Summary is a one-line description of your change that will be extracted and added to the project changelog at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt
|
||||
|
||||
Please convert all your existing PRs with `[WIP]` in the title to Drafts.
|
||||
|
||||

|
||||
|
||||
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 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'"
|
||||
```
|
||||
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
|
||||
```
|
||||
```SUMMARY: None```
|
||||
|
||||
See [the Changelog Guidelines](../doc/CHANGELOG_GUIDELINES.md) for explanations of the categories.
|
||||
See the Changelog Guidelines at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md for explanations of the categories.
|
||||
|
||||
### Closing issues using keywords
|
||||
|
||||
@@ -206,10 +179,6 @@ The "???" is the issue number. This automatically closes the issue when the PR i
|
||||
|
||||
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.
|
||||
@@ -261,8 +230,9 @@ You can also set the tracking information at the same time as creating the branc
|
||||
|
||||
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.
|
||||
An ordinary invocation of ``make`` will build the test executable at tests/cata_test, and it can be invoked like any ordinary executable.
|
||||
With no arguments it will run the entire test suite.
|
||||
With ``--help`` it will print a number of invocation options you can use to adjust its operation.
|
||||
|
||||
$ make
|
||||
... compilation details ...
|
||||
@@ -273,11 +243,7 @@ Running `test/cata_test` with no arguments will run the entire test suite; runni
|
||||
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)
|
||||
I recommend habitually invoking make like ``make YOUR BUILD OPTIONS && tests/cata_test``.
|
||||
|
||||
## In-game testing, test environment and the debug menu
|
||||
|
||||
@@ -286,16 +252,39 @@ Whether you are implementing a new feature or whether you are fixing a bug, it i
|
||||
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… │
|
||||
└───────────────────────────────────────────────────────────────────────────┘
|
||||
┌────────────────────────────────────────────┐
|
||||
│ Debug Functions - Using these is CHEATING! │
|
||||
├────────────────────────────────────────────┤
|
||||
│ 1 Wish for an item │
|
||||
│ 2 Teleport - Short Range │
|
||||
│ 3 Teleport - Long Range │
|
||||
│ 4 Reveal map │
|
||||
│ 5 Spawn NPC │
|
||||
│ 6 Spawn Monster │
|
||||
│ 7 Check game state... │
|
||||
│ 8 Kill NPCs │
|
||||
│ 9 Mutate │
|
||||
│ 0 Spawn a vehicle │
|
||||
│ a Change all skills │
|
||||
│ b Learn all melee styles │
|
||||
│ c Unlock all recipes │
|
||||
│ d Edit player/NPC │
|
||||
│ e Spawn Artifact │
|
||||
│ f Spawn Clairvoyance Artifact │
|
||||
│ g Map editor │
|
||||
│ h Change weather │
|
||||
│ i Remove all monsters │
|
||||
│ j Display hordes │
|
||||
│ k Test Item Group │
|
||||
│ l Damage Self │
|
||||
│ m Show Sound Clustering │
|
||||
│ n Lua Command │
|
||||
│ o Display weather │
|
||||
│ p Change time │
|
||||
│ q Set automove route │
|
||||
│ r Show mutation category levels │
|
||||
│ s Cancel │
|
||||
└────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
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).
|
||||
@@ -321,5 +310,3 @@ Now that `master` has been cleaned up, we can easily pull from `upstream/master`
|
||||
$ 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).
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Game version:
|
||||
|
||||
Operating system:
|
||||
|
||||
Tiles or curses:
|
||||
|
||||
Mods active:
|
||||
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
### Steps to reproduce the behavior
|
||||
@@ -3,57 +3,29 @@ name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
<!-- Please follow the template below -->
|
||||
|
||||
# Describe the bug
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
|
||||
# Steps To Reproduce
|
||||
|
||||
<!-- Steps to reproduce the behavior:
|
||||
**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. -->
|
||||
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.
|
||||
|
||||
# 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.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Versions and configuration(please complete the following information):**
|
||||
- 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. -->
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
E.g. A link to a savegame that allows the issue to be reproduced.
|
||||
|
||||
@@ -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.
|
||||
@@ -4,14 +4,14 @@ about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
# Is your feature request related to a problem? Please describe.
|
||||
**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
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
# Describe alternatives you've considered
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
# Additional context
|
||||
**Additional context**
|
||||
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature request here.
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
<!-- 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. -->
|
||||
<!--
|
||||
### How to use
|
||||
Leave the headings unless they don't apply to your PR, replace commented out text ( surrounded with <!-- and --> ) with text describing your PR.
|
||||
-->
|
||||
|
||||
#### 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 -->
|
||||
<!--
|
||||
A one-line description of your change that will be extracted and added to the project changelog at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/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'"```
|
||||
See the Changelog Guidelines at https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md for explanations of the categories.
|
||||
-->
|
||||
|
||||
#### 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. -->
|
||||
<!--
|
||||
If there's an existing issue describing the problem this PR addresses or the feature it adds, please link it like: ```#1234```
|
||||
If it *fully* resolves an issue, link it like: ```Fixes #1234```
|
||||
Even if the issue describes the problem, please provide a few-sentence summary here.
|
||||
Example: ```Fixes #1234 - XL mutants cannot wear arm/leg splints due to missing OVERSIZE flag.```
|
||||
If there is no related issue, please describe the issue you are addressing, including how to trigger a bug if this is a bugfix.
|
||||
-->
|
||||
|
||||
#### 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. -->
|
||||
<!--
|
||||
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. -->
|
||||
<!--
|
||||
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 or bugfix here. -->
|
||||
<!--
|
||||
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature or bugfix here.
|
||||
-->
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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'
|
||||
@@ -1,80 +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
|
||||
windows:
|
||||
needs: release
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- name: Windows Tiles x64
|
||||
mxe: x86_64
|
||||
artifact: windows-tiles-x64
|
||||
- name: Windows Tiles x32
|
||||
mxe: i686
|
||||
artifact: windows-tiles-x32
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies
|
||||
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
|
||||
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: Build CDDA
|
||||
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: 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 }}.zip
|
||||
asset_name: cdda-${{ matrix.artifact }}-b${{ github.run_number }}.zip
|
||||
asset_content_type: application/zip
|
||||
@@ -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
|
||||
```
|
||||
@@ -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
|
||||
+6
-39
@@ -10,21 +10,21 @@
|
||||
/WinDepend/
|
||||
/bindist/
|
||||
/build/
|
||||
/build-start-time
|
||||
/cmake-build-debug/
|
||||
/config/
|
||||
/data/*.template
|
||||
/data/font/
|
||||
/data/mods/user-default-mods.json
|
||||
/dep/
|
||||
/doxygen_doc/html/*
|
||||
/doxygen_doc/latex/*
|
||||
/font/
|
||||
/graveyard/
|
||||
/memorial/
|
||||
/mods/
|
||||
/obj/
|
||||
/objwin/
|
||||
/save/
|
||||
/src/lua/catabindings.cpp
|
||||
/src/version.h
|
||||
/sound/
|
||||
/templates/
|
||||
@@ -41,15 +41,12 @@ cataclysmdda-*
|
||||
chkjson*
|
||||
debug.log
|
||||
logg.txt
|
||||
json_formatter
|
||||
|
||||
# Visual Studio files
|
||||
*.code-workspace
|
||||
*.exp
|
||||
*.ilk
|
||||
*.opensdf
|
||||
*.pdb
|
||||
*.lib
|
||||
*.sdf
|
||||
*.suo
|
||||
*.user
|
||||
@@ -71,10 +68,6 @@ Cataclysm.exe.lastcodeanalysissucceeded
|
||||
#Visual Studio 2017
|
||||
/msvc-full-features/PredictedInputCache_Debug_x64.dat
|
||||
|
||||
#vcpkg
|
||||
/msvc-full-features/vcpkg_installed
|
||||
/msvc-object_creator/vcpkg_installed
|
||||
|
||||
# PVS Studio
|
||||
/msvc-full-features/*PVS-Studio*
|
||||
|
||||
@@ -93,10 +86,6 @@ Thumbs.db
|
||||
cscope.*
|
||||
tags
|
||||
|
||||
# Generated translation source
|
||||
/lang/po/cataclysm-dda.pot
|
||||
/lang/po/en.po
|
||||
|
||||
# Compiled binary translations
|
||||
/lang/mo/
|
||||
|
||||
@@ -114,7 +103,6 @@ nbproject/
|
||||
*.vim
|
||||
*.session
|
||||
.ycm_extra_conf.py
|
||||
.vimrc
|
||||
|
||||
# taskwarrior files
|
||||
*.task*
|
||||
@@ -127,26 +115,18 @@ nbproject/
|
||||
|
||||
# OSX
|
||||
Cataclysm.app
|
||||
build-data/osx/AppIcon.icns
|
||||
data/osx/AppIcon.icns
|
||||
Cataclysm.dmg
|
||||
|
||||
# Jetbrains CLion
|
||||
.idea/
|
||||
|
||||
# test executables and generated data
|
||||
/tests/obj
|
||||
/tests/cata_test
|
||||
/tests/line_test
|
||||
/tests/map_iterator_test
|
||||
/tests/shadowcasting_test
|
||||
/tests/data/jsionized_overmap.sav
|
||||
/test_user_dir
|
||||
|
||||
# temporary files generated by tools/reduce_tests.sh
|
||||
/list_of_tests
|
||||
/list_of_tests.ok
|
||||
/log
|
||||
/multidelta.log
|
||||
|
||||
# static library used to link the test executable
|
||||
cataclysm.a
|
||||
@@ -163,7 +143,6 @@ cataclysm.a
|
||||
|
||||
# clang tooling
|
||||
compile_commands.json
|
||||
.clangd
|
||||
|
||||
# IDA database
|
||||
Cataclysm.i64
|
||||
@@ -171,6 +150,9 @@ Cataclysm.id*
|
||||
Cataclysm.til
|
||||
Cataclysm.nam
|
||||
|
||||
# Transifex Client
|
||||
.tx/
|
||||
|
||||
# Snapcraft build directories
|
||||
prime
|
||||
snap
|
||||
@@ -188,18 +170,3 @@ Xcode/
|
||||
|
||||
# gdb
|
||||
.gdb_history
|
||||
|
||||
# Flatpak build artifacts
|
||||
/.flatpak-builder/
|
||||
/repo/
|
||||
/build-dir/
|
||||
|
||||
# precompiled headers
|
||||
/pch/pch.hpp.pch
|
||||
/pch/main-pch.hpp.gch
|
||||
/pch/main-pch.hpp.pch
|
||||
/tests/pch/pch.hpp.pch
|
||||
/tests/pch/tests-pch.hpp.gch
|
||||
/tests/pch/tests-pch.hpp.pch
|
||||
/tests/catch/catch.hpp.gch
|
||||
/tests/catch/catch.hpp.pch
|
||||
|
||||
@@ -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
|
||||
+78
-127
@@ -7,6 +7,9 @@ cache: ccache
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
irc: "irc.freenode.org#Cataclysm-DDA"
|
||||
use_notice: true
|
||||
skip_join: true
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
@@ -29,110 +32,72 @@ branches:
|
||||
- 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]
|
||||
# Initial test stage, if this fails everything else is cancelled.
|
||||
- stage: test
|
||||
# GCC 5 is the pre-installed compiler on Xenial
|
||||
env: COMPILER=g++ MODS=--mods=RL_Classes
|
||||
|
||||
# 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
|
||||
- stage: variants
|
||||
# Linux Tiles
|
||||
env: COMPILER=g++-8 CXXFLAGS='-Wno-implicit-fallthrough' TILES=1 SOUND=1 SANITIZE=address
|
||||
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
|
||||
# MXE variants using alternate repository http://mirror.mxe.cc/repos/apt
|
||||
# GCC MinGW
|
||||
- env: COMPILER='g++' LDFLAGS='-static-libgcc -static-libstdc++' MXE_TARGET='i686-w64-mingw32.static' WINE='wine'
|
||||
addons: &gcc
|
||||
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"
|
||||
packages: ["wine"]
|
||||
|
||||
- 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"
|
||||
# Windows Tiles
|
||||
- env: COMPILER='g++' LDFLAGS='-static-libgcc -static-libstdc++' MXE_TARGET='i686-w64-mingw32.static' WINE='wine' TILES=1 SOUND=1
|
||||
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
|
||||
# CMake Clang 6.0 Tiles
|
||||
- env: CLANG=clang++-6.0 TILES=1 SOUND=1 CXXFLAGS=-Wno-error=unused-command-line-argument CMAKE=1
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
addons: &clang60
|
||||
apt:
|
||||
packages: ["clang-6.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-6.0]
|
||||
|
||||
- env: CLANG=clang++ OSX_MIN=10.13 TILES=1 SOUND=1
|
||||
name: "Xcode 10.2 Make build with Tiles and sound (macOS)"
|
||||
# macOS Tiles
|
||||
- env: CLANG=clang++ NATIVE=osx OSX_MIN=10.13 TILES=1 SOUND=1 LUA=1
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
osx_image: xcode10.1
|
||||
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++-4.8
|
||||
compiler: gcc
|
||||
addons: &gcc48
|
||||
apt:
|
||||
packages: ["g++-4.8", "g++-4.8-multilib", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: COMPILER=g++-6 CODE_COVERAGE=true
|
||||
name: "GCC 6 Make build with Curses and Code Coverage"
|
||||
# GCC 4.9
|
||||
- env: COMPILER=g++-4.9
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc49
|
||||
apt:
|
||||
packages: ["g++-4.9", "g++-4.9-multilib", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: *apt_sources
|
||||
|
||||
# GCC 6
|
||||
- env: COMPILER=g++-6
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc6
|
||||
@@ -140,82 +105,68 @@ jobs:
|
||||
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"
|
||||
# GCC 7
|
||||
- env: COMPILER=g++-7 CXXFLAGS='-Wno-implicit-fallthrough' CODE_COVERAGE=true
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
dist: trusty
|
||||
addons: &gcc7
|
||||
apt:
|
||||
packages: ["g++-7", "g++-7-multilib", "libc6-dbg", "libc6-dbg:i386", "lcov"]
|
||||
sources: *apt_sources
|
||||
|
||||
# GCC 8
|
||||
- env: COMPILER=g++-8 CXXFLAGS='-Wno-implicit-fallthrough'
|
||||
compiler: gcc
|
||||
addons: &gcc8
|
||||
apt:
|
||||
packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: *apt_sources
|
||||
|
||||
# Clang 3.8
|
||||
- env: CLANG=clang++-3.8 CXXFLAGS='-Wno-error=unused-command-line-argument -D__extern_always_inline="extern __always_inline"'
|
||||
compiler: clang
|
||||
addons: &clang38
|
||||
apt:
|
||||
packages: ["clang-3.8", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: *apt_sources
|
||||
|
||||
# Clang 3.9
|
||||
- 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"]
|
||||
packages: ["clang-3.9", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: *apt_sources
|
||||
|
||||
# Clang 4.0
|
||||
- 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
|
||||
packages: ["clang-4.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-4.0]
|
||||
|
||||
# Clang 5.0
|
||||
- env: CLANG=clang++-5.0 CXXFLAGS=-Wno-error=unused-command-line-argument
|
||||
name: "Clang 5 Make build with Curses"
|
||||
if: type != pull_request
|
||||
dist: trusty
|
||||
compiler: clang
|
||||
addons: &clang50
|
||||
apt:
|
||||
packages: ["clang-5.0"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-5.0]
|
||||
packages: ["clang-5.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-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
|
||||
# Clang 6.0
|
||||
- env: CLANG=clang++-6.0 CXXFLAGS=-Wno-error=unused-command-line-argument SANITIZE=address EXTRA_TEST_OPTS="~[.] ~vehicle_efficiency ~vehicle_drag ~starting_items"
|
||||
dist: trusty
|
||||
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"
|
||||
packages: ["clang-6.0", "g++-multilib", "libc6-dbg", "libc6-dbg:i386", "g++-6"]
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-6.0]
|
||||
|
||||
before_script:
|
||||
- if [ -n "${CLANG}" ]; then COMPILER="$CLANG"; fi
|
||||
@@ -227,5 +178,5 @@ 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 coveralls -b . -i src -e tests --gcov /usr/bin/gcov-4.8; fi
|
||||
- if [ -n "${CODE_COVERAGE}" ]; then bash <(curl -s https://codecov.io/bash); fi
|
||||
|
||||
-10
@@ -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
|
||||
|
||||
+313
-323
@@ -1,68 +1,73 @@
|
||||
cmake_minimum_required(VERSION 3.1.4)
|
||||
# Main project build script
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
|
||||
project(CataclysmDDA)
|
||||
PROJECT(CataclysmDDA)
|
||||
|
||||
set(CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules)
|
||||
|
||||
set(CMAKE_TLS_VERIFY ON)
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules
|
||||
)
|
||||
|
||||
# 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")
|
||||
option(LUA "Lua support (required for some mods)." "OFF")
|
||||
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(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(LUA_BINARY "Lua binary name or path. You can try to use luajit for extra speed." "")
|
||||
option(GIT_BINARY "Git binary name or path." "")
|
||||
OPTION(PREFIX "Location of Data,GFX, & Lua 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]*")
|
||||
git_describe(GIT_VERSION)
|
||||
|
||||
MESSAGE("\n * Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world.")
|
||||
MESSAGE(" _________ __ .__ ")
|
||||
MESSAGE(" \\_ ___ \\ _____ _/ |_ _____ ____ | | ___.__ ______ _____ ")
|
||||
MESSAGE(" / \\ \\/ \\__ \\ \\ __\\\\__ \\ _/ ___\\ | | < | | / ___/ / \\ ")
|
||||
MESSAGE(" \\ \\____ / __ \\_ | | / __ \\_\\ \\___ | |__ \\___ | \\___ \\ | Y Y \\ ")
|
||||
MESSAGE(" \\______ /\(____ / |__| \(____ / \\___ >|____/ / ____|/____ >|__|_| / ")
|
||||
MESSAGE(" \\/ \\/ \\/ \\/ \\/ \\/ \\/ ")
|
||||
MESSAGE(" --= Dark Days Ahead =--")
|
||||
MESSAGE("\n * http://en.cataclysmdda.com/\n")
|
||||
|
||||
MESSAGE(STATUS "${PROJECT} build environment -- \n")
|
||||
|
||||
MESSAGE(STATUS "Build realm is : ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
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 ()
|
||||
FILE(WRITE ${CMAKE_SOURCE_DIR}/src/version.h "\#define VERSION \"${GIT_VERSION}\"\n")
|
||||
MESSAGE(STATUS "${PROJECT_NAME} build version is : ${GIT_VERSION}\n")
|
||||
ADD_DEFINITIONS(-DGIT_VERSION)
|
||||
ELSE (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
MESSAGE("")
|
||||
ENDIF(NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
|
||||
#OS Check Placeholders. Will be used for BINDIST
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
set(_OS_LINUX_ 1)
|
||||
endif ()
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
SET(_OS_LINUX_ 1)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
set(_OS_FREEBSD_ 1)
|
||||
endif ()
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
SET(_OS_FREEBSD_ 1)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
set(_OS_DARWIN_ 1)
|
||||
set(LOCALIZE OFF)
|
||||
message(STATUS "Internationalization on Darwin is not supported")
|
||||
endif ()
|
||||
IF(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
SET(_OS_DARWIN_ 1)
|
||||
SET(LOCALIZE OFF)
|
||||
MESSAGE(STATUS "Disable internationalization on Darwin as it is not supported")
|
||||
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
@@ -73,317 +78,302 @@ include(CheckCXXCompilerFlag)
|
||||
#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 ()
|
||||
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(HAVE_STATIC_FLAG)
|
||||
# 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 (NOT DYNAMIC_LINKING)
|
||||
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(MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
ENDIF (NOT DYNAMIC_LINKING)
|
||||
|
||||
# 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 ()
|
||||
#Sysem 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(NOT DATA_PREFIX)
|
||||
IF(NOT LOCALE_DIR)
|
||||
SET( LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
|
||||
ENDIF(NOT LOCALE_DIR)
|
||||
IF(NOT BIN_PREFIX)
|
||||
SET( BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
ENDIF(NOT BIN_PREFIX)
|
||||
IF(NOT DESKTOP_ENTRY_PATH)
|
||||
SET( DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||
ENDIF(NOT DESKTOP_ENTRY_PATH)
|
||||
IF(NOT PIXMAPS_ENTRY_PATH)
|
||||
SET( PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
|
||||
ENDIF(NOT PIXMAPS_ENTRY_PATH)
|
||||
IF(NOT PIXMAPS_UNITY_ENTRY_PATH)
|
||||
SET( PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark)
|
||||
ENDIF(NOT PIXMAPS_UNITY_ENTRY_PATH)
|
||||
IF(NOT MANPAGE_ENTRY_PATH)
|
||||
SET( MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man)
|
||||
ENDIF(NOT MANPAGE_ENTRY_PATH)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
|
||||
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 ()
|
||||
IF (${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
IF(NOT DATA_PREFIX)
|
||||
SET(DATA_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT DATA_PREFIX)
|
||||
IF(NOT LOCALE_DIR)
|
||||
SET(LOCALE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT LOCALE_DIR)
|
||||
IF(NOT BIN_PREFIX)
|
||||
SET(BIN_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
ENDIF(NOT BIN_PREFIX)
|
||||
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
|
||||
message(STATUS "${PROJECT_NAME} build options --")
|
||||
|
||||
MESSAGE(STATUS "${PROJECT_NAME} build options --\n")
|
||||
|
||||
# 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 (NOT LUA_BINARY)
|
||||
SET (LUA_BINARY "lua")
|
||||
ENDIF (NOT LUA_BINARY)
|
||||
|
||||
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(NOT LANGUAGES)
|
||||
SET (LANGUAGES de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW)
|
||||
ENDIF(NOT LANGUAGES)
|
||||
|
||||
if (PREFIX)
|
||||
add_definitions(-DPREFIX=${PREFIX})
|
||||
endif ()
|
||||
IF (GIT_BINARY)
|
||||
SET(GIT_EXECUTABLE ${GIT_BINARY})
|
||||
ELSE (GIT_BINARY)
|
||||
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 (NOT GIT_FOUND)
|
||||
ENDIF (GIT_BINARY)
|
||||
|
||||
IF (PREFIX)
|
||||
ADD_DEFINITIONS(-DPREFIX=${PREFIX})
|
||||
ENDIF (PREFIX)
|
||||
|
||||
# Can't compile curses and tiles build's at same time
|
||||
if (TILES)
|
||||
set(CURSES OFF)
|
||||
endif ()
|
||||
IF(TILES)
|
||||
SET(CURSES OFF)
|
||||
ENDIF(TILES)
|
||||
|
||||
# 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 ()
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
MESSAGE("\n")
|
||||
MESSAGE(STATUS "Build ${PROJECT} in development mode --\n")
|
||||
MESSAGE(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
|
||||
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
# Since CataclusmDDA does not respect PREFIX for development builds
|
||||
# and has funny path handlers, we should create resulting Binaries
|
||||
# in the source redectory
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
|
||||
${CMAKE_SOURCE_DIR}
|
||||
CACHE PATH "Single Directory for all Executables."
|
||||
)
|
||||
SET(BIN_PREFIX ${CMAKE_SOURCE_DIR})
|
||||
ELSE (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
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(LOCALIZE)
|
||||
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}\n")
|
||||
ADD_DEFINITIONS(-DRELEASE)
|
||||
# Use PREFIX as storage of data,gfx,lua etc.. Usefull only on *nix OS.
|
||||
IF (PREFIX AND NOT WIN32)
|
||||
ADD_DEFINITIONS(-DDATA_DIR_PREFIX)
|
||||
ENDIF (PREFIX AND NOT WIN32)
|
||||
ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
|
||||
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 --")
|
||||
MESSAGE(STATUS "LUA : ${LUA}")
|
||||
IF (LUA)
|
||||
MESSAGE(STATUS "LUA_BINARY : ${LUA_BINARY}")
|
||||
ENDIF (LUA)
|
||||
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}\n")
|
||||
|
||||
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 ()
|
||||
MESSAGE(STATUS "LANGUAGES : ${LANGUAGES}\n")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
MESSAGE(STATUS "See INSTALL file for details and more info --\n")
|
||||
|
||||
IF(MSVC)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_AMD64_)
|
||||
else()
|
||||
add_definitions(-D_X86_)
|
||||
endif()
|
||||
ELSE()
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wall -std=c++11")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "-Og -g -D_GLIBCXX_DEBUG")
|
||||
ENDIF()
|
||||
|
||||
# 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 ()
|
||||
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.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
|
||||
#set(THREADS_USE_PTHREADS_WIN32 True)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD True)
|
||||
find_package(Threads REQUIRED)
|
||||
#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(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 be compiled in graphical mode. Please install the SDL2 development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_FOUND)
|
||||
|
||||
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 ()
|
||||
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 (NOT DYNAMIC_LINKING)
|
||||
|
||||
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 --")
|
||||
|
||||
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 ()
|
||||
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 be compiled in graphical mode. Please install the SDL2_ttf development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and moreinfo\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_TTF_FOUND)
|
||||
|
||||
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 ()
|
||||
MESSAGE(STATUS "Searching for SDL2_image library --\n")
|
||||
FIND_PACKAGE(SDL2_image)
|
||||
IF(NOT SDL2_IMAGE_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"This project requires SDL2_image to be installed to be compiled in graphical mode. Please install the SDL2_image development libraries, or try compiling without the -DTILES=1 for a text only compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_IMAGE_FOUND)
|
||||
ADD_DEFINITIONS(-DTILES)
|
||||
ENDIF(TILES)
|
||||
|
||||
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 ()
|
||||
IF(CURSES)
|
||||
# Find the ncurses library for a text based compile
|
||||
MESSAGE(STATUS "Searching for Curses library --\n")
|
||||
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 the -DTILES=1 for a graphical compilation.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT CURSES_FOUND)
|
||||
ENDIF(CURSES)
|
||||
|
||||
# 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(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.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT TILES)
|
||||
|
||||
if (BACKTRACE)
|
||||
add_definitions(-DBACKTRACE)
|
||||
if (LIBBACKTRACE)
|
||||
add_definitions(-DLIBBACKTRACE)
|
||||
endif (LIBBACKTRACE)
|
||||
endif (BACKTRACE)
|
||||
# Sound requires SDL_mixer library
|
||||
MESSAGE(STATUS "Searching for SDL2_mixer library --\n")
|
||||
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.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT SDL2_MIXER_FOUND)
|
||||
ENDIF(SOUND)
|
||||
|
||||
IF(LUA)
|
||||
FIND_PACKAGE(Lua)
|
||||
IF(NOT LUA_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"You need the Lua development library to be able to compile with Lua support.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT LUA_FOUND)
|
||||
ADD_DEFINITIONS(-DLUA)
|
||||
ENDIF(LUA)
|
||||
|
||||
IF(BACKTRACE)
|
||||
ADD_DEFINITIONS(-DBACKTRACE)
|
||||
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(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.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT LIBINTL_FOUND)
|
||||
FIND_PACKAGE(Iconv)
|
||||
IF(NOT ICONV_FOUND)
|
||||
MESSAGE(FATAL_ERROR
|
||||
"You need the iconv development library to be able to compile with Localize support.\nSee INSTALL file for details and more info\n"
|
||||
)
|
||||
ENDIF(NOT ICONV_FOUND)
|
||||
ENDIF(WIN32)
|
||||
add_subdirectory(lang)
|
||||
ADD_DEFINITIONS(-DLOCALIZE)
|
||||
ENDIF(LOCALIZE)
|
||||
|
||||
if (USE_HOME_DIR)
|
||||
add_definitions(-DUSE_HOME_DIR)
|
||||
endif ()
|
||||
IF(USE_HOME_DIR)
|
||||
ADD_DEFINITIONS(-DUSE_HOME_DIR)
|
||||
ENDIF(USE_HOME_DIR)
|
||||
|
||||
IF(LUA)
|
||||
add_subdirectory(lua)
|
||||
add_subdirectory(src/lua)
|
||||
ENDIF(LUA)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(data)
|
||||
if (NOT MSVC)
|
||||
add_subdirectory(src/chkjson)
|
||||
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)
|
||||
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")
|
||||
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)
|
||||
if(CCACHE_FOUND)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif ()
|
||||
endif(CCACHE_FOUND)
|
||||
|
||||
# vim:noet
|
||||
|
||||
@@ -88,7 +88,7 @@ if(NOT CURSES_USE_NCURSES)
|
||||
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
|
||||
# FORCE must not be used since this would break builds which preload a cache wqith these variables set
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
|
||||
CACHE FILEPATH "The curses include path")
|
||||
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
|
||||
@@ -113,7 +113,7 @@ else()
|
||||
# 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
|
||||
# a cache wqith 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)
|
||||
@@ -155,7 +155,7 @@ 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
|
||||
# qith these variables set
|
||||
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
|
||||
CACHE FILEPATH "The curses form library")
|
||||
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
# Locate Lua library
|
||||
# This module defines
|
||||
# LUA_EXECUTABLE, if found
|
||||
# LUA_FOUND, if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
#
|
||||
# Note that the expected include convention is
|
||||
# #include "lua.h"
|
||||
# and not
|
||||
# #include <lua/lua.h>
|
||||
# This is because, the lua location is not standardized and may exist
|
||||
# in locations other than lua/
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
# Modified to support Lua 5.2 by LuaDist 2012
|
||||
#
|
||||
# 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.)
|
||||
#
|
||||
# The required version of Lua can be specified using the
|
||||
# standard syntax, e.g. FIND_PACKAGE(Lua 5.1)
|
||||
# Otherwise the module will search for any available Lua implementation
|
||||
|
||||
# Always search for non-versioned lua first (recommended)
|
||||
SET(_POSSIBLE_LUA_INCLUDE include include/lua)
|
||||
SET(_POSSIBLE_LUA_EXECUTABLE lua)
|
||||
SET(_POSSIBLE_LUA_LIBRARY lua)
|
||||
|
||||
# Determine possible naming suffixes (there is no standard for this)
|
||||
IF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
|
||||
SET(_POSSIBLE_SUFFIXES "${Lua_FIND_VERSION_MAJOR}${Lua_FIND_VERSION_MINOR}" "${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}" "-${Lua_FIND_VERSION_MAJOR}.${Lua_FIND_VERSION_MINOR}")
|
||||
ELSE(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
|
||||
SET(_POSSIBLE_SUFFIXES "52" "5.2" "-5.2" "51" "5.1" "-5.1")
|
||||
ENDIF(Lua_FIND_VERSION_MAJOR AND Lua_FIND_VERSION_MINOR)
|
||||
|
||||
# Set up possible search names and locations
|
||||
FOREACH(_SUFFIX ${_POSSIBLE_SUFFIXES})
|
||||
LIST(APPEND _POSSIBLE_LUA_INCLUDE "include/lua${_SUFFIX}")
|
||||
LIST(APPEND _POSSIBLE_LUA_EXECUTABLE "lua${_SUFFIX}")
|
||||
LIST(APPEND _POSSIBLE_LUA_LIBRARY "lua${_SUFFIX}")
|
||||
ENDFOREACH(_SUFFIX)
|
||||
|
||||
# Find the lua executable
|
||||
FIND_PROGRAM(LUA_EXECUTABLE
|
||||
NAMES ${_POSSIBLE_LUA_EXECUTABLE}
|
||||
)
|
||||
|
||||
# Find the lua header
|
||||
FIND_PATH(LUA_INCLUDE_DIR lua.h
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES ${_POSSIBLE_LUA_INCLUDE}
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw # Fink
|
||||
/opt/local # DarwinPorts
|
||||
/opt/csw # Blastwave
|
||||
/opt
|
||||
)
|
||||
|
||||
# Find the lua library
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES ${_POSSIBLE_LUA_LIBRARY}
|
||||
HINTS
|
||||
$ENV{LUA_DIR}
|
||||
PATH_SUFFIXES lib64 lib
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/usr/local
|
||||
/usr
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
|
||||
IF(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(LUA_MATH_LIBRARY m)
|
||||
SET( LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
ELSE(UNIX AND NOT APPLE)
|
||||
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
ENDIF(LUA_LIBRARY)
|
||||
|
||||
# Determine Lua version
|
||||
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||
|
||||
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||
UNSET(lua_version_str)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY LUA_EXECUTABLE)
|
||||
@@ -16,7 +16,7 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
@@ -89,7 +89,7 @@ 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
|
||||
# for backward compatiblity
|
||||
set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
|
||||
set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||
set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
@@ -89,7 +89,7 @@ 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
|
||||
# for backward compatiblity
|
||||
set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
|
||||
set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
|
||||
set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
# For backward compatiblity the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
@@ -88,7 +88,7 @@ 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
|
||||
# for backward compatiblity
|
||||
set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
|
||||
set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
|
||||
set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
|
||||
|
||||
@@ -0,0 +1,357 @@
|
||||
#Disclaimer
|
||||
|
||||
**WARNING**: CMake build is **NOT** official and should be used for *dev purposes ONLY*.
|
||||
|
||||
For official way to build CataclysmDDA See:
|
||||
* The latest instructions on how to compile can be found on [our wiki](http://tools.cataclysmdda.com/wiki).
|
||||
* [COMPILING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md)
|
||||
|
||||
|
||||
#Contents
|
||||
|
||||
1. Prerequisites
|
||||
2. Build Environment
|
||||
* UNIX Environment
|
||||
* Windows Environment
|
||||
3. CMake Build
|
||||
* MinGW,MSYS,MSYS2
|
||||
5. Build Options
|
||||
* CMake specific options
|
||||
* CataclysmDDA specific options
|
||||
|
||||
#1. Prerequisites
|
||||
|
||||
You'll need to have these libraries and their development headers installed in
|
||||
order to build CataclysmDDA:
|
||||
|
||||
* General
|
||||
* `cmake` >= 3.0.0
|
||||
* `gcc-libs`
|
||||
* `glibc`
|
||||
* `zlib`
|
||||
* `bzip2`
|
||||
* Optional
|
||||
* `lua51`
|
||||
* `gettext`
|
||||
* Curses
|
||||
* `ncurses`
|
||||
* Tiles
|
||||
* `SDL` >= 2.0.0
|
||||
* `SDL_image` >= 2.0.0 (with PNG and JPEG support)
|
||||
* `SDL_mixer` >= 2.0.0 (with Ogg Vorbis support)
|
||||
* `SDL_ttf` >= 2.0.0
|
||||
* `freetype`
|
||||
* Sound
|
||||
* `vorbis`
|
||||
* `libbz2`
|
||||
* `libz`
|
||||
* `libintl`
|
||||
* `iconv`
|
||||
|
||||
|
||||
#2. Build Environment
|
||||
|
||||
You can obtain the source code tarball for the latest version from [git](https://github.com/CleverRaven/Cataclysm-DDA).
|
||||
|
||||
|
||||
## UNIX Environment
|
||||
|
||||
Obtain packages specified above with your system package manager.
|
||||
|
||||
|
||||
## Windows Environment (MSYS2)
|
||||
|
||||
1. Follow steps from here: https://msys2.github.io/
|
||||
2. Install CataclysmDDA build deps:
|
||||
|
||||
```
|
||||
pacman -S mingw-w64-i686-toolchain msys/git \
|
||||
mingw-w64-i686-cmake \
|
||||
mingw-w64-i686-SDL2_{image,mixer,ttf} \
|
||||
mingw-w64-i686-lua51 \
|
||||
ncurses-devel \
|
||||
gettext-devel
|
||||
```
|
||||
|
||||
This should get your environment set up to build console and tiles version of windows.
|
||||
|
||||
**NOTE**: This is only for 32bit builds. 64bit requires the x86_64 instead of the i686
|
||||
packages listed above:
|
||||
|
||||
```
|
||||
pacman -S mingw-w64-x86_64-toolchain msys/git \
|
||||
mingw-w64-x86_64-cmake \
|
||||
mingw-w64-x86_64-SDL2_{image,mixer,ttf} \
|
||||
mingw-w64-x86_64-lua51 \
|
||||
ncurses-devel \
|
||||
gettext-devel
|
||||
```
|
||||
|
||||
**NOTE**: If you're trying to test with Jetbrains CLion, point to the cmake version in the
|
||||
msys32/mingw32 path instead of using the built in. This will let cmake detect the
|
||||
installed packages.
|
||||
|
||||
|
||||
# CMake Build
|
||||
|
||||
CMake has separate configuration and build steps. Configuration
|
||||
is done using CMake itself, and the actual build is done using either `make`
|
||||
(for Makefiles generator) or build-system agnostic `cmake --build . ` .
|
||||
|
||||
There are two ways to build CataclysmDDA with CMake: inside the source tree or
|
||||
outside of it. Out-of-source builds have the advantage that you can have
|
||||
multiple builds with different options from one source directory.
|
||||
|
||||
**WARNING**: Inside the source tree build is **NOT** supported.
|
||||
|
||||
To build CataclysmDDA out of source:
|
||||
|
||||
```
|
||||
$ mkdir build && cd build
|
||||
$ cmake .. -DCMAKE_BUILD_TYPE=Release
|
||||
$ make
|
||||
```
|
||||
|
||||
The above example creates a build directory inside the source directory, but that's not required - you can just as easily create it in a completely different location.
|
||||
|
||||
To install CataclysmDDA after building (as root using su or sudo if necessary):
|
||||
|
||||
```
|
||||
# make install
|
||||
```
|
||||
|
||||
To change build options, you can either pass the options on the command line:
|
||||
|
||||
```
|
||||
$ cmake .. -DOPTION_NAME=option_value
|
||||
```
|
||||
|
||||
Or use either the `ccmake` or `cmake-gui` front-ends, which display all options
|
||||
and their cached values on a console and graphical UI, respectively.
|
||||
|
||||
```
|
||||
$ ccmake ..
|
||||
$ cmake-gui ..
|
||||
```
|
||||
|
||||
|
||||
## CMake Build for MSYS2 (MinGW)
|
||||
|
||||
**NOTE**: For development purposes it is preferred to use `MinGW Win64 Shell` or `MinGW Win32 Shell` instead of `MSYS2 Shell`. In other case, you will need to set `PATH` variable manually.
|
||||
|
||||
For Mingw,MSYS,MSYS2 you should set [Makefiles generator](https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html) to "MSYS Makefiles".
|
||||
Setting it to "MinGW Makefiles" might work as well, but might also require additional hackery.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
$ cd <Path-to-CataclysmDDA-Sources>
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake .. -G "MSYS Makefiles"
|
||||
$ make # or $ cmake --build .
|
||||
```
|
||||
|
||||
The resulting binary will be placed inside the source code directory.
|
||||
|
||||
Shared libraries:
|
||||
|
||||
If you got `libgcc_s_dw2-1.dll not found` error you need to copy shared libraries
|
||||
to directory with CataclysmDDA executables.
|
||||
|
||||
**NOTE**: For `-DRELEASE=OFF` development builds, You can automate copy process with:
|
||||
|
||||
```
|
||||
$ make install
|
||||
```
|
||||
|
||||
However, it likely will fail b/c you have different build environment setup :)
|
||||
|
||||
Currently known depends (Maybe outdated use ldd.exe to correct it for Your system)
|
||||
|
||||
* MINGW deps:
|
||||
* `libwinpthread-1.dll`
|
||||
* `libgcc_s_dw2-1.dll`
|
||||
* `libstdc++-6.dll`
|
||||
|
||||
* LOCALIZE deps:
|
||||
* `libintl-8.dll`
|
||||
* `libiconv-2.dll`
|
||||
|
||||
* LUA deps:
|
||||
* `lua51.dll`
|
||||
|
||||
* TILES deps:
|
||||
* `SDL2.dll`
|
||||
* `SDL2_ttf.dll`
|
||||
* `libfreetype-6.dll`
|
||||
* `libbz2-1.dll`
|
||||
* `libharfbuzz-0.dll`
|
||||
* `SDL2_image.dll`
|
||||
* `libpng16-16.dll`
|
||||
* `libjpeg-8.dll`
|
||||
* `libtiff-5.dll`
|
||||
* `libjbig-0.dll`
|
||||
* `liblzma-5.dll`
|
||||
* `libwebp-5.dll`
|
||||
* `zlib1.dll`
|
||||
* `libglib-2.0-0.dll`
|
||||
|
||||
* SOUND deps:
|
||||
* `SDL2_mixer.dll`
|
||||
* `libFLAC-8.dll`
|
||||
* `libogg-0.dll`
|
||||
* `libfluidsynth-1.dll`
|
||||
* `libportaudio-2.dll`
|
||||
* `libsndfile-1.dll`
|
||||
* `libvorbis-0.dll`
|
||||
* `libvorbisenc-2.dll`
|
||||
* `libmodplug-1.dll`
|
||||
* `smpeg2.dll`
|
||||
* `libvorbisfile-3.dll`
|
||||
|
||||
|
||||
## CMake Build for Visual Studio / MSBuild
|
||||
|
||||
CMake can generate `.sln` and `.vcxproj` files used either by Visual Studio itself or by MSBuild command line compiler (if you don't want
|
||||
a full fledged IDE) and have more "native" binaries than what MSYS/Cygwin can provide.
|
||||
|
||||
At the moment only a limited combination of options is supported (tiles only, no lua, no localizations, no backtrace).
|
||||
|
||||
Get the tools:
|
||||
* CMake from the official site - https://cmake.org/download/.
|
||||
* Microsoft compiler - https://visualstudio.microsoft.com/downloads/?q=build+tools , choose "Build Tools for Visual Studio 2017". When installing chose "Visual C++ Build Tools" options.
|
||||
* alternatively, you can get download and install the complete Visual Studio, but that's not required.
|
||||
|
||||
Get the required libraries:
|
||||
* `SDL2` - https://www.libsdl.org/download-2.0.php (you need the "(Visual C++ 32/64-bit)" version. Same below)
|
||||
* `SDL2_ttf` - https://www.libsdl.org/projects/SDL_ttf/
|
||||
* `SDL2_image` - https://www.libsdl.org/projects/SDL_image/
|
||||
* `SDL2_mixer` (optional, for sound support) - https://www.libsdl.org/projects/SDL_mixer/
|
||||
* Unsupported (and unused in the following instructions) optional libs:
|
||||
* `Lua` - http://luabinaries.sourceforge.net/
|
||||
* `gettext`/`libintl` - http://gnuwin32.sourceforge.net/packages/gettext.htm
|
||||
* `ncurses` - ???
|
||||
|
||||
Unpack the archives with the libraries.
|
||||
|
||||
Open windows command line (or powershell), set the environment variables to point to the libs above as follows (adjusting the paths as appropriate):
|
||||
```
|
||||
> set SDL2DIR=C:\path\to\SDL2-devel-2.0.9-VC
|
||||
> set SDL2TTFDIR=C:\path\to\SDL2_ttf-devel-2.0.15-VC
|
||||
> set SDL2IMAGEDIR=C:\path\to\SDL2_image-devel-2.0.4-VC
|
||||
> set SDL2MIXERDIR=C:\path\to\SDL2_mixer-devel-2.0.4-VC
|
||||
```
|
||||
(for powershell the syntax is `$env:SDL2DIR="C:\path\to\SDL2-devel-2.0.9-VC"`).
|
||||
|
||||
Make a build directory and run cmake configuration step
|
||||
```
|
||||
> cd <path to cdda sources>
|
||||
> mkdir build
|
||||
> cd build
|
||||
> cmake .. -DTILES=ON -DLOCALIZE=OFF -DBACKTRACE=OFF -DSOUND=ON
|
||||
```
|
||||
|
||||
|
||||
Build!
|
||||
```
|
||||
> cmake --build . -j 2 -- /p:Configuration=Release
|
||||
```
|
||||
The `-j 2` flag controls build parallelism - you can omit it if you wish. The `/p:Configuration=Release` flag is passed directly to MSBuild and
|
||||
controls optimizations. If you omit it, the `Debug` configuration would be built instead. For powershell you'll need to have an extra ` -- ` after the first one.
|
||||
|
||||
The resulting files will be put into a `Release` directory inside your source Cataclysm-DDA folder. To make them run you'd need to first move them to the
|
||||
source Cataclysm-DDA directory itself (so that the binary has access to the game data), and second put the required `.dll`s into the same folder -
|
||||
you can find those inside the directories for dev libraries under `lib/x86/` or `lib/x64/` (you likely need the `x86` ones even if you're on 64-bit machine).
|
||||
|
||||
The copying of dlls is a one-time task, but you'd need to move the binary out of `Release/` each time it's built. To automate it a bit, you can configure cmake and set the desired binaries destination directory with `-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=` option (and similar for `CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG`).
|
||||
|
||||
Run the game. Should work.
|
||||
|
||||
|
||||
# Build Options
|
||||
|
||||
A full list of options supported by CMake, you may either run the `ccmake`
|
||||
or `cmake-gui` front-ends, or run `cmake` and open the generated CMakeCache.txt
|
||||
from the build directory in a text editor.
|
||||
|
||||
```
|
||||
$ cmake -DOPTION_NAME1=option_value1 [-DOPTION_NAME2=option_value2 [...]]
|
||||
```
|
||||
|
||||
|
||||
## CMake specific options
|
||||
|
||||
* CMAKE_BUILD_TYPE=`<build type>`
|
||||
|
||||
Selects a specific build configuration when compiling. `release` produces
|
||||
the default, optimized (-Os) build for regular use. `debug` produces a
|
||||
slower and larger unoptimized (-O0) build with full debug symbols, which is
|
||||
often needed for obtaining detailed backtraces when reporting bugs.
|
||||
|
||||
**NOTE**: By default, CMake will produce `debug` builds unless a different
|
||||
configuration option is passed in the command line.
|
||||
|
||||
|
||||
* CMAKE_INSTALL_PREFIX=`<full path>`
|
||||
|
||||
Installation prefix for binaries, resources, and documentation files.
|
||||
|
||||
|
||||
## CataclysmDDA specific options
|
||||
|
||||
* CURSES=`<boolean>`
|
||||
|
||||
Build curses version.
|
||||
|
||||
|
||||
* TILES=`<boolean>`
|
||||
|
||||
Build graphical tileset version.
|
||||
|
||||
|
||||
* SOUND=`<boolean>`
|
||||
|
||||
Support for in-game sounds & music.
|
||||
|
||||
|
||||
* LUA=`<boolean>`
|
||||
|
||||
This enables Lua support. Needed only for full-fledged mods.
|
||||
|
||||
|
||||
* USE_HOME_DIR=`<boolean>`
|
||||
|
||||
Use user's home directory for save files.
|
||||
|
||||
|
||||
* LOCALIZE=`<boolean>`
|
||||
|
||||
Support for language localizations. Also enable UTF support.
|
||||
|
||||
|
||||
* DYNAMIC_LINKING=`<boolean>`
|
||||
|
||||
Use dynamic linking. Or use static to remove MinGW dependency instead.
|
||||
|
||||
|
||||
* LANGUAGES=`<str>`
|
||||
|
||||
Compile localization files for specified languages. Example:
|
||||
```
|
||||
-DLANGUAGES="cs;de;el;es_AR;es_ES"
|
||||
```
|
||||
|
||||
* LUA_BINARY=`<str>`
|
||||
|
||||
Override default Lua binary name or path. You can try to use `luajit` for extra speed.
|
||||
|
||||
|
||||
* GIT_BINARY=`<str>`
|
||||
|
||||
Override default Git binary name or path.
|
||||
|
||||
So a CMake command for building Cataclysm-DDA in release mode with tiles, sound and lua support will look as follows, provided it is run in build directory located in the project.
|
||||
```
|
||||
cmake ../ -DCMAKE_BUILD_TYPE=Release -DTILES=ON -DSOUND=ON -DLUA=ON
|
||||
```
|
||||
@@ -0,0 +1,104 @@
|
||||
# Compilation guide for 64 bit Windows (using MSYS2)
|
||||
|
||||
This guide contains steps required to allow compilation of Cataclysm-DDA on Windows under MSYS2.
|
||||
|
||||
Steps from current guide were tested on Windows 10 (64 bit) and MSYS2 (64 bit), but should work for other versions of Windows and also MSYS2 (32 bit) if you download 32 bit version of all files.
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
* Computer with 64 bit version of modern Windows operating system installed (Windows 10, Windows 8.1 or Windows 7);
|
||||
* NTFS partition with ~10 Gb free space (~2 Gb for MSYS2 installation, ~3 Gb for repository and ~5 Gb for ccache);
|
||||
* 64 bit version of MSYS2 (installer can be downloaded from [MSYS2 homepage](http://www.msys2.org/));
|
||||
|
||||
**Note:** Windows XP is unsupported!
|
||||
|
||||
## Installation:
|
||||
|
||||
1. Go to [MSYS2 homepage](http://www.msys2.org/) and download 64 bit installer (e.g. [msys2-x86_64-20180531.exe](http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe)).
|
||||
|
||||
2. Run downloaded file and install MSYS2 (click `Next` button, specify directory where MSYS2 64 bit will be installed (e.g. `C:\msys64`), click `Next` button again, specify Start Menu folder name and click `Install` button).
|
||||
|
||||
3. After MSYS2 installation is complete press `Next` button, tick `Run MSYS2 64 bit now` checkbox and press `Finish` button.
|
||||
|
||||
## Configuration:
|
||||
|
||||
1. Update the package database and core system packages with:
|
||||
|
||||
```bash
|
||||
pacman -Syu
|
||||
```
|
||||
|
||||
2. If asked close MSYS2 window and restart it from Start Menu or `C:\msys64\msys2_shell.cmd`.
|
||||
|
||||
3. Update remaining packages with:
|
||||
|
||||
```bash
|
||||
pacman -Su
|
||||
```
|
||||
|
||||
4. Install packages required for compilation with:
|
||||
|
||||
```bash
|
||||
pacman -S git git-extras-git make mingw-w64-x86_64-{astyle,ccache,gcc,libmad,libwebp,lua,ncurses,pkg-config,SDL2} mingw-w64-x86_64-SDL2_{image,mixer,ttf}
|
||||
```
|
||||
|
||||
5. Update paths in system-wide profile file (e.g. `C:\msys64\etc\profile`) as following:
|
||||
|
||||
- find lines:
|
||||
|
||||
```
|
||||
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
MANPATH='/usr/local/man:/usr/share/man:/usr/man:/share/man'
|
||||
INFOPATH='/usr/local/info:/usr/share/info:/usr/info:/share/info'
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```
|
||||
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig"
|
||||
```
|
||||
|
||||
- and replace them with:
|
||||
|
||||
```
|
||||
MSYS2_PATH="/usr/local/bin:/usr/bin:/bin:/mingw64/bin"
|
||||
MANPATH='/usr/local/man:/usr/share/man:/usr/man:/share/man:/mingw64/share/man'
|
||||
INFOPATH='/usr/local/info:/usr/share/info:/usr/info:/share/info:/mingw64/share/man'
|
||||
```
|
||||
|
||||
and
|
||||
|
||||
```
|
||||
PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig:/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig"
|
||||
```
|
||||
|
||||
6. Restart MSYS2 to apply path changes.
|
||||
|
||||
## Cloning and compilation:
|
||||
|
||||
1. Clone Cataclysm-DDA repository with following command line:
|
||||
|
||||
**Note:** This will download whole CDDA repository. If you're just testing you should probably add `--depth=1`.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
cd Cataclysm-DDA
|
||||
```
|
||||
|
||||
2. Compile with following command line:
|
||||
|
||||
```bash
|
||||
make CCACHE=1 RELEASE=1 MSYS2=1 DYNAMIC_LINKING=1 LUA=1 SDL=1 TILES=1 SOUND=1 LOCALIZE=1 LANGUAGES=all LINTJSON=0 ASTYLE=0 RUNTESTS=0
|
||||
```
|
||||
|
||||
**Note**: This will compile release version with Lua, Sound and Tiles support and all localization languages, skipping checks and tests and using ccache for faster build. You can use other switches, but `MSYS2=1`, `DYNAMIC_LINKING=1` and probably `RELEASE=1` are required to compile without issues.
|
||||
|
||||
## Running:
|
||||
|
||||
1. Run from within MSYS2 with following command line:
|
||||
|
||||
```bash
|
||||
./cataclysm-tiles
|
||||
```
|
||||
|
||||
**Note:** If you want to run compiled executable from Explorer you will also need to update user or system`PATH` variable with path to MSYS2 runtime binaries (e.g. `C:\msys64\mingw64\bin`).
|
||||
@@ -0,0 +1,78 @@
|
||||
# Compilation guide for Windows (using Visual Studio and vcpkg)
|
||||
|
||||
This guide contains steps required to allow compilation of Cataclysm-DDA on Windows using Visual Studio and vcpkg.
|
||||
|
||||
Steps from current guide were tested on Windows 10 (64 bit), Visual Studio 2017 (64 bit) and vcpkg, but should as well work with slight modifications for other versions of Windows and Visual Studio.
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
* Computer with modern Windows operating system installed (Windows 10, Windows 8.1 or Windows 7);
|
||||
* NTFS partition with ~15 Gb free space (~10 Gb for Visual Studio, ~1 Gb for vcpkg installation, ~3 Gb for repository and ~1 Gb for build cache);
|
||||
* Git for Windows (installer can be downloaded from [Git homepage](https://git-scm.com/));
|
||||
* Visual Studio 2017 (or 2015 Visual Studio Update 3 and above);
|
||||
* Latest version of vcpkg (see instructions on [vcpkg homepage](https://github.com/Microsoft/vcpkg)).
|
||||
|
||||
**Note:** Windows XP is unsupported!
|
||||
|
||||
## Installation and configuration:
|
||||
|
||||
1. Install `Visual Studio` (installer can be downloaded from [Visual Studio homepage](https://visualstudio.microsoft.com/)).
|
||||
|
||||
2. Install `Git for Windows` (installer can be downloaded from [Git homepage](https://git-scm.com/)).
|
||||
|
||||
3. Install and configure `vcpkg` using instruction from [vcpkg homepage](https://github.com/Microsoft/vcpkg/blob/master/README.md#quick-start) with following command line:
|
||||
|
||||
```cmd
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
.\bootstrap-vcpkg.bat
|
||||
vcpkg integrate install
|
||||
```
|
||||
|
||||
4. Install (or upgrade) neccessary packages with following command line:
|
||||
|
||||
#### install 64 bit dependencies:
|
||||
|
||||
```cmd
|
||||
vcpkg --triplet x64-windows install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext lua
|
||||
```
|
||||
|
||||
or (if you want to build statically linked executable)
|
||||
|
||||
```cmd
|
||||
vcpkg --triplet x64-windows-static install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext lua
|
||||
```
|
||||
|
||||
|
||||
#### install32 bit dependencies:
|
||||
|
||||
```cmd
|
||||
vcpkg --triplet x86-windows install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext lua
|
||||
```
|
||||
|
||||
or (if you want to build statically linked executable)
|
||||
|
||||
```cmd
|
||||
vcpkg --triplet x86-windows-static install sdl2 sdl2-image sdl2-mixer sdl2-ttf gettext lua
|
||||
```
|
||||
|
||||
#### upgrade all dependencies:
|
||||
|
||||
```cmd
|
||||
vcpkg upgrade
|
||||
```
|
||||
|
||||
## Cloning and compilation:
|
||||
|
||||
1. Clone Cataclysm-DDA repository with following command line:
|
||||
|
||||
**Note:** This will download whole CDDA repository. If you're just testing you should probably add `--depth=1`.
|
||||
|
||||
```cmd
|
||||
git clone https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
cd Cataclysm-DDA
|
||||
```
|
||||
|
||||
2. Open one of provided solutions (`msvc-full-features\Cataclysm-vcpkg.sln` for dynamically linked executable or `msvc-full-features\Cataclysm-vcpkg-static.sln` for statically linked executable) in `Visual Studio`, select configuration (`Release` or `Debug`) an platform (`x64` or `x86`) and build it.
|
||||
|
||||
**Note**: This will compile release version with Lua, Sound, Tiles and Localization support (language files won't be automatically compiled).
|
||||
+797
@@ -0,0 +1,797 @@
|
||||
* [General Linux Guide](#general-linux-guide)
|
||||
* [Compiler](#compiler)
|
||||
* [Tools](#tools)
|
||||
* [Dependencies](#dependencies)
|
||||
* [Make flags](#make-flags)
|
||||
* [Debian](#debian)
|
||||
* [Linux (native) ncurses builds](#linux-native-ncurses-builds)
|
||||
* [Linux (native) SDL builds](#linux-native-sdl-builds)
|
||||
* [Cross-compiling to linux 32-bit from linux 64-bit](#cross-compiling-to-linux-32-bit-from-linux-64-bit)
|
||||
* [Cross-compile to Windows from Linux](#cross-compile-to-windows-from-linux)
|
||||
* [Cross-compile to Mac OS X from Linux](#cross-compile-to-mac-os-x-from-linux)
|
||||
* [Cross-compile to Android from Linux](#cross-compile-to-android-from-linux)
|
||||
* [Mac OS X](#mac-os-x)
|
||||
* [Simple build using Homebrew](#simple-build-using-homebrew)
|
||||
* [Advanced info for Developers](#advanced-info-for-developers)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
* [Windows](#windows)
|
||||
* [Visual Studio Guide](#visual-studio-guide)
|
||||
* [MinGW Guide](#mingw-guide)
|
||||
* [Rough guide to building with only MSYS2](#rough-guide-to-building-with-only-msys2)
|
||||
* [BSDs](#bsds)
|
||||
|
||||
# General Linux Guide
|
||||
|
||||
To build Cataclysm from source you will need at least a C++ compiler, some basic developer tools, and necessary build dependencies. The exact package names vary greatly from distro to distro, so this part of the guide is intended to give you higher-level understanding of the process.
|
||||
|
||||
## Compiler
|
||||
|
||||
You have three major choices here: GCC, Clang and MXE.
|
||||
|
||||
* GCC is almost always the default on Linux systems so it's likely you already have it
|
||||
* Clang is usually faster than GCC, so it's worth installing if you plan to keep up with the latest experimentals
|
||||
* MXE is a cross-compiler, so of any importance only if you plan to compile for Windows on your Linux machine
|
||||
|
||||
(Note that your distro may have separate packages e.g. `gcc` only includes the C compiler and for C++ you'll need to install `g++`.)
|
||||
|
||||
Cataclysm is targeting C++11 standard and that means you'll need a compiler that supports it. You can easily check if your version of `g++` supports C++11 by running:
|
||||
|
||||
$ g++ --std=c++11
|
||||
g++: fatal error: no input files
|
||||
compilation terminated.
|
||||
|
||||
If you get a line like:
|
||||
|
||||
g++: error: unrecognized command line option ‘--std=c++11’
|
||||
|
||||
This means you'll need a newer version of GCC (`g++`).
|
||||
|
||||
The general rule is the newer the compiler the better.
|
||||
|
||||
## Tools
|
||||
|
||||
Most distros seem to package essential build tools as either a single package (Debian and derivatives have `build-essential`) or a package group (Arch has `base-devel`). You should use the above if available. Otherwise you'll at least need `make` and figure out the missing dependencies as you go (if any).
|
||||
|
||||
Besides the essentials you will need `git`.
|
||||
|
||||
If you plan on keeping up with experimentals you should also install `ccache`, which will considerably speed-up partial builds.
|
||||
|
||||
## Dependencies
|
||||
|
||||
There are some general dependencies, optional dependencies and then specific dependencies for either curses or tiles builds. The exact package names again depend on the distro you're using, and whether your distro packages libraries and their development files separately (e.g. Debian and derivatives).
|
||||
|
||||
Rough list based on building on Arch:
|
||||
|
||||
* General: `gcc-libs`, `glibc`, `zlib`, `bzip2`
|
||||
* Optional: `lua51`, `gettext`
|
||||
* Curses: `ncurses`
|
||||
* Tiles: `sdl2`, `sdl2_image`, `sdl2_ttf`, `sdl2_mixer`, `freetype2`
|
||||
|
||||
E.g. for curses build on Debian and derivatives you'll also need `libncurses5-dev` or `libncursesw5-dev`.
|
||||
|
||||
Note on optional dependencies:
|
||||
|
||||
* `gettext` - for localization support; if you plan to only use English you can skip it
|
||||
* `lua` - for full-fledged mods; you'll probably prefer to have it
|
||||
|
||||
You should be able to figure out what you are missing by reading the compilation errors and/or the output of `ldd` for compiled binaries.
|
||||
|
||||
## Make flags
|
||||
|
||||
Given you're building from source you have a number of choices to make:
|
||||
|
||||
* `NATIVE=` - you should only care about this if you're cross-compiling
|
||||
* `RELEASE=1` - without this you'll get a debug build (see note below)
|
||||
* `LTO=1` - enables link-time optimization with GCC/Clang
|
||||
* `TILES=1` - with this you'll get the tiles version, without it the curses version
|
||||
* `SOUND=1` - if you want sound; this requires `TILES=1`
|
||||
* `LOCALIZE=0` - this disables localizations so `gettext` is not needed
|
||||
* `LUA=1` - this enables Lua support; needed only for full-fledged mods
|
||||
* `CLANG=1` - use Clang instead of GCC
|
||||
* `CCACHE=1` - use ccache
|
||||
* `USE_LIBCXX=1` - use libc++ instead of libstdc++ with Clang (default on OS X)
|
||||
|
||||
There is a couple of other possible options - feel free to read the `Makefile`.
|
||||
|
||||
If you have a multi-core computer you'd probably want to add `-jX` to the options, where `X` should roughly be twice the number of cores you have available.
|
||||
|
||||
Example: `make -j4 CLANG=1 CCACHE=1 NATIVE=linux64 RELEASE=1 TILES=1`
|
||||
|
||||
The above will build a tiles release explicitly for 64 bit Linux, using Clang and ccache and 4 parallel processes.
|
||||
|
||||
Example: `make -j2 LOCALIZE=0`
|
||||
|
||||
The above will build a debug-enabled curses version for the architecture you are using, using GCC and 2 parallel processes.
|
||||
|
||||
**Note on debug**:
|
||||
You should probably always build with `RELEASE=1` unless you experience segfaults and are willing to provide stack traces.
|
||||
|
||||
# Debian
|
||||
|
||||
Instructions for compiling on a Debian-based system. The package names here are valid for Ubuntu 12.10 and may or may not work on your system.
|
||||
|
||||
Building instructions, below, always assume you are running them from the Cataclysm:DDA source directory.
|
||||
|
||||
## Linux (native) ncurses builds
|
||||
|
||||
Dependencies:
|
||||
|
||||
* ncurses or ncursesw (for multi-byte locales)
|
||||
* build essentials
|
||||
|
||||
Install:
|
||||
|
||||
sudo apt-get install libncurses5-dev libncursesw5-dev build-essential astyle
|
||||
|
||||
### Building
|
||||
|
||||
Run:
|
||||
|
||||
make
|
||||
|
||||
## Linux (native) SDL builds
|
||||
|
||||
Dependencies:
|
||||
|
||||
* SDL
|
||||
* SDL_ttf
|
||||
* freetype
|
||||
* build essentials
|
||||
* lua5.2 and liblua5.2 - Only necessary if compiling with lua, which some mods like stats through skills use. Versions 5.1, 5.2 and 5.3 are supported.
|
||||
* libsdl2-mixer-dev - Used if compiling with sound support.
|
||||
|
||||
Install:
|
||||
|
||||
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev build-essential lua5.2 liblua5.2-dev
|
||||
|
||||
### Building
|
||||
|
||||
A simple installation could be done by simply running:
|
||||
|
||||
make TILES=1
|
||||
|
||||
A more comprehensive alternative is:
|
||||
|
||||
make -j2 TILES=1 SOUND=1 RELEASE=1 LUA=1 USE_HOME_DIR=1
|
||||
|
||||
The -j2 flag means it will compile with two parallel processes. It can be omitted or changed to -j4 in a more modern processor. If there is no desire to use lua, or have sound, those flags can also be omitted. The USE_HOME_DIR flag places the user files, like configurations and saves into the home folder, making It easier for backups, and can also be omitted.
|
||||
|
||||
|
||||
|
||||
## Cross-compiling to linux 32-bit from linux 64-bit
|
||||
|
||||
Dependencies:
|
||||
|
||||
* 32-bit toolchain
|
||||
* 32-bit ncursesw (compatible with both multi-byte and 8-bit locales)
|
||||
|
||||
Install:
|
||||
|
||||
sudo apt-get install libc6-dev-i386 lib32stdc++-dev g++-multilib lib32ncursesw5-dev
|
||||
|
||||
### Building
|
||||
|
||||
Run:
|
||||
|
||||
make NATIVE=linux32
|
||||
|
||||
## Cross-compile to Windows from Linux
|
||||
|
||||
To cross-compile to Windows from Linux, you will need MXE. The main difference between the native build process and this one, is the use of the CROSS flag for make. The other make flags are still applicable.
|
||||
|
||||
* `CROSS=` - should be the full path to MXE g++ without the *g++* part at the end
|
||||
|
||||
Dependencies:
|
||||
|
||||
* [MXE](http://mxe.cc)
|
||||
* [MXE Requirements](http://mxe.cc/#requirements)
|
||||
|
||||
Install:
|
||||
|
||||
sudo apt-get install 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 make openssl p7zip-full patch perl pkg-config python ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin
|
||||
mkdir -p ~/src/mxe
|
||||
git clone https://github.com/mxe/mxe.git ~/src/mxe
|
||||
cd ~/src/mxe
|
||||
make MXE_TARGETS='x86_64-w64-mingw32.static i686-w64-mingw32.static' sdl2 sdl2_ttf sdl2_image sdl2_mixer gettext lua ncurses
|
||||
|
||||
If you are not on a Debian derivative (Linux Mint, Ubuntu, etc), you will have to use a different command than apt-get to install [the MXE requirements](http://mxe.cc/#requirements). Building all these packages from MXE might take a while even on a fast computer. Be patient. If you are not planning on building for both 32-bit and 64-bit, you might want to adjust your MXE_TARGETS.
|
||||
|
||||
### Building (SDL)
|
||||
|
||||
Run:
|
||||
|
||||
PLATFORM="i686-w64-mingw32.static"
|
||||
make CROSS="~/src/mxe/usr/bin/${PLATFORM}-" TILES=1 SOUND=1 LUA=1 RELEASE=1 LOCALIZE=1
|
||||
|
||||
Change PLATFORM to x86_64-w64-mingw32.static for a 64-bit Windows build.
|
||||
|
||||
To create nice zip file with all the required resources for a trouble free copy on Windows use the bindist target like this:
|
||||
|
||||
PLATFORM="i686-w64-mingw32.static"
|
||||
make CROSS="~/src/mxe/usr/bin/${PLATFORM}-" TILES=1 SOUND=1 LUA=1 RELEASE=1 LOCALIZE=1 bindist
|
||||
|
||||
### Building (ncurses)
|
||||
|
||||
Run:
|
||||
|
||||
PLATFORM="i686-w64-mingw32.static"
|
||||
make CROSS="~/src/mxe/usr/bin/${PLATFORM}-" LUA=1 RELEASE=1 LOCALIZE=1
|
||||
|
||||
## Cross-compile to Mac OS X from Linux
|
||||
|
||||
The procedure is very much similar to cross-compilation to Windows from Linux.
|
||||
Tested on ubuntu 14.04 LTS but should work on other distros as well.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* OSX cross-compiling toolchain [osxcross](https://github.com/tpoechtrager/osxcross)
|
||||
|
||||
* `genisoimage` and [libdmg-hfsplus](https://github.com/planetbeing/libdmg-hfsplus.git) to create dmg distributions
|
||||
|
||||
Make sure that all dependency tools are in search `PATH` before compiling.
|
||||
|
||||
### Setup
|
||||
|
||||
To set up the compiling environment execute the following commands
|
||||
`git clone https://github.com/tpoechtrager/osxcross.git` to clone the toolchain
|
||||
`cd osxcross`
|
||||
`cp ~/MacOSX10.11.sdk.tar.bz2 ./tarballs/` copy prepared MacOSX SDK tarball on place. [Read more about it](https://github.com/tpoechtrager/osxcross/blob/master/README.md#packaging-the-sdk)
|
||||
`OSX_VERSION_MIN=10.7 ./build.sh to build everything`
|
||||
Note the targeted minimum supported version of OSX.
|
||||
|
||||
Have a prepackaged set of libs and frameworks in place, since compiling with `osxcross` built-in MacPorts is rather difficult and not supported at the moment.
|
||||
Your directory tree should look like:
|
||||
|
||||
~/
|
||||
├── Frameworks
|
||||
│ ├── SDL2.framework
|
||||
│ ├── SDL2_image.framework
|
||||
│ ├── SDL2_mixer.framework
|
||||
│ └── SDL2_ttf.framework
|
||||
└── libs
|
||||
├── gettext
|
||||
│ ├── include
|
||||
│ └── lib
|
||||
├── lua
|
||||
│ ├── include
|
||||
│ └── lib
|
||||
└── ncurses
|
||||
├── include
|
||||
└── lib
|
||||
|
||||
Populated with respective frameworks, dylibs and headers.
|
||||
Tested lib versions are libintl.8.dylib for gettext, liblua.5.2.4.dylib for lua, libncurses.5.4.dylib for ncurses.
|
||||
These libs were obtained from `homebrew` binary distribution at OS X 10.11
|
||||
Frameworks were obtained from SDL official website as described in the next [section](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md#sdl)
|
||||
|
||||
### Building (SDL)
|
||||
|
||||
To build full feature tiles and sound enabled version with localizations and lua enabled:
|
||||
|
||||
make dmgdist CROSS=x86_64-apple-darwin15- NATIVE=osx OSX_MIN=10.7 USE_HOME_DIR=1 CLANG=1
|
||||
RELEASE=1 LOCALIZE=1 LANGUAGES=all LUA=1 TILES=1 SOUND=1 FRAMEWORK=1
|
||||
OSXCROSS=1 LIBSDIR=../libs FRAMEWORKSDIR=../Frameworks
|
||||
|
||||
Make sure that `x86_64-apple-darwin15-clang++` is in `PATH` environment variable.
|
||||
|
||||
### Building (ncurses)
|
||||
|
||||
To build full curses version with localizations and lua enabled:
|
||||
|
||||
make dmgdist CROSS=x86_64-apple-darwin15- NATIVE=osx OSX_MIN=10.7 USE_HOME_DIR=1 CLANG=1
|
||||
RELEASE=1 LOCALIZE=1 LANGUAGES=all LUA=1 OSXCROSS=1 LIBSDIR=../libs FRAMEWORKSDIR=../Frameworks
|
||||
|
||||
Make sure that `x86_64-apple-darwin15-clang++` is in `PATH` environment variable.
|
||||
|
||||
## Cross-compile to Android from Linux
|
||||
|
||||
The Android build uses [Gradle](https://gradle.org/) to compile the java and native C++ code, and is based heavily off SDL's [Android project template](https://hg.libsdl.org/SDL/file/f1084c419f33/android-project). See the official SDL documentation [README-android.md](https://hg.libsdl.org/SDL/file/f1084c419f33/docs/README-android.md) for further information.
|
||||
|
||||
The Gradle project lives in the repository under `android/`. You can build it via the command line or open it in [Android Studio](https://developer.android.com/studio/). For simplicity, it only builds the SDL version with all features enabled, including tiles, sound, localization and lua.
|
||||
|
||||
### Dependencies
|
||||
|
||||
* Java JDK 8
|
||||
* SDL2 (tested with 2.0.8, though a custom fork is recommended with project-specific bugfixes)
|
||||
* SDL2_ttf (tested with 2.0.14)
|
||||
* SDL2_mixer (tested with 2.0.2)
|
||||
* SDL2_image (tested with 2.0.3)
|
||||
* libintl-lite (tested with a custom fork of libintl-lite 0.5)
|
||||
* lua (tested with lua 5.1.5)
|
||||
|
||||
The Gradle build process automatically installs dependencies from [deps.zip](android/app/deps.zip).
|
||||
|
||||
### Setup
|
||||
|
||||
Install Linux dependencies. For a desktop Ubuntu installation:
|
||||
|
||||
sudo apt-get install lua5.2 openjdk-8-jdk-headless
|
||||
|
||||
Install Android SDK and NDK:
|
||||
|
||||
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
|
||||
unzip sdk-tools-linux-4333796.zip -d ~/android-sdk
|
||||
rm sdk-tools-linux-4333796.zip
|
||||
~/android-sdk/tools/bin/sdkmanager --update
|
||||
~/android-sdk/tools/bin/sdkmanager "tools" "platform-tools" "ndk-bundle"
|
||||
~/android-sdk/tools/bin/sdkmanager --licenses
|
||||
|
||||
Export Android environment variables (you can add these to the end of `~/.bashrc`):
|
||||
|
||||
export ANDROID_SDK_ROOT=~/android-sdk
|
||||
export ANDROID_HOME=~/android-sdk
|
||||
export ANDROID_NDK_ROOT=~/android-sdk/ndk-bundle
|
||||
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
|
||||
export PATH=$PATH:$ANDROID_SDK_ROOT/tools
|
||||
export PATH=$PATH:$ANDROID_NDK_ROOT
|
||||
|
||||
### Android device setup
|
||||
|
||||
Enable [Developer options on your Android device](https://developer.android.com/studio/debug/dev-options). Connect your device to your PC via USB cable and run:
|
||||
|
||||
adb devices
|
||||
adb connect <devicename>
|
||||
|
||||
### Building
|
||||
|
||||
To build an APK, use the Gradle wrapper command line tool (gradlew). The Android Studio documentation provides a good summary of how to [build your app from the command line](https://developer.android.com/studio/build/building-cmdline).
|
||||
|
||||
To build a debug APK, from the `android/` subfolder of the repository run:
|
||||
|
||||
./gradlew assembleDebug
|
||||
|
||||
This creates a debug APK in `./android/app/build/outputs/apk/` ready to be installed on your device.
|
||||
|
||||
To build a debug APK and immediately deploy to your connected device over adb run:
|
||||
|
||||
./gradlew installDebug
|
||||
|
||||
To build a signed release APK (ie. one that can be installed on a device), [build an unsigned release APK and sign it manually](https://developer.android.com/studio/publish/app-signing#signing-manually).
|
||||
|
||||
### Additional notes
|
||||
|
||||
The app stores data files on the device in `/sdcard/Android/data/com.cleverraven/cataclysmdda/files`. The data is backwards compatible with the desktop version.
|
||||
|
||||
# Mac OS X
|
||||
|
||||
To build Cataclysm on Mac you'll need [Command Line Tools for Xcode](https://developer.apple.com/downloads/) and the [Homebrew](http://brew.sh) package manager. With Homebrew, you can easily install or build Cataclysm using the [Cataclysm](https://formulae.brew.sh/formula/cataclysm) forumla.
|
||||
|
||||
## Simple build using Homebrew
|
||||
|
||||
Homebrew installation will come with tiles, sound and lua suooprt enabled by default.
|
||||
|
||||
Once you have Homebrew installed, open Terminal and run one of the following commands.
|
||||
|
||||
For a tiles build:
|
||||
|
||||
brew install cataclysm
|
||||
|
||||
For an experimental tiles build:
|
||||
|
||||
brew install cataclysm --HEAD
|
||||
|
||||
Whichever build you choose, Homebrew will install the appropriate dependencies as needed. The installation will be in `/usr/local/Cellar/cataclysm` with a symlink named `cataclysm` in `/usr/local/bin`.
|
||||
|
||||
To launch Cataclysm, just open Terminal and run `cataclysm`.
|
||||
|
||||
To update an experimental build, you must uninstall Cataclysm, then reinstall using one of the above commands. Reinstall Cataclysm using the one of the following commands.
|
||||
|
||||
For a tiles build:
|
||||
|
||||
brew reinstall cataclysm
|
||||
|
||||
For an experimental tiles build:
|
||||
|
||||
brew reinstall cataclysm --HEAD
|
||||
|
||||
## Advanced info for Developers
|
||||
|
||||
For most people, the simple Homebrew installation is enough. For developers, here are some more technical details on building Cataclysm on Mac OS X.
|
||||
|
||||
### SDL
|
||||
|
||||
SDL2, SDL2_image, and SDL2_ttf are needed for the tiles build. Optionally, you can add SDL2_mixer for sound support. Cataclysm can be built using either the SDL framework, or shared libraries built from source.
|
||||
|
||||
The SDL framework files can be downloaded here:
|
||||
|
||||
* [**SDL2**](http://www.libsdl.org/download-2.0.php)
|
||||
* [**SDL2_image**](http://www.libsdl.org/projects/SDL_image/)
|
||||
* [**SDL2_ttf**](http://www.libsdl.org/projects/SDL_ttf/)
|
||||
|
||||
Copy `SDL2.framework`, `SDL2_image.framework`, and `SDL2_ttf.framework`
|
||||
to `/Library/Frameworks` or `/Users/name/Library/Frameworks`.
|
||||
|
||||
If you want sound support, you will need an additional SDL framework:
|
||||
|
||||
* [**SDL2_mixer**](https://www.libsdl.org/projects/SDL_mixer/)
|
||||
|
||||
Copy `SDL2_mixer.framework` to `/Library/Frameworks` or `/Users/name/Library/Frameworks`.
|
||||
|
||||
Alternatively, SDL shared libraries can be installed using a package manager:
|
||||
|
||||
For Homebrew:
|
||||
|
||||
brew install sdl2 sdl2_image sdl2_ttf
|
||||
|
||||
with sound:
|
||||
|
||||
brew install sdl2_mixer libvorbis libogg
|
||||
|
||||
For MacPorts:
|
||||
|
||||
sudo port install libsdl2 libsdl2_image libsdl2_ttf
|
||||
|
||||
with sound:
|
||||
|
||||
sudo port install libsdl2_mixer libvorbis libogg
|
||||
|
||||
### ncurses and gettext
|
||||
|
||||
ncurses (with wide character support enabled) and gettext are needed if you want to build Cataclysm with localization.
|
||||
|
||||
For Homebrew:
|
||||
|
||||
brew tap homebrew/dupes
|
||||
brew install gettext ncurses
|
||||
brew link --force gettext ncurses
|
||||
|
||||
Then, after compiling, be sure to unlink these libraries to prevent conflicts with the OS X shared libraries:
|
||||
|
||||
brew unlink gettext ncurses
|
||||
|
||||
For MacPorts:
|
||||
|
||||
sudo port install gettext ncurses
|
||||
hash -r
|
||||
|
||||
### gcc
|
||||
|
||||
The version of gcc/g++ installed with the [Command Line Tools for Xcode](https://developer.apple.com/downloads/) is actually just a front end for the same Apple LLVM as clang. This doesn't necessarily cause issues, but this version of gcc/g++ will have clang error messages and essentially produce the same results as if using clang. To compile with the "real" gcc/g++, install it with homebrew:
|
||||
|
||||
brew install gcc
|
||||
|
||||
However, homebrew installs gcc as gcc-6 (where 6 is the version) to avoid conflicts. The simplest way to use the homebrew version at `/usr/local/bin/gcc-6` instead of the Apple LLVM version at `/usr/bin/gcc` is to symlink the necessary.
|
||||
|
||||
cd /usr/local/bin
|
||||
ln -s gcc-6 gcc
|
||||
ln -s g++-6 g++
|
||||
ln -s c++-6 c++
|
||||
|
||||
Or, to do this for everything in `/usr/local/bin/` ending with `-6`,
|
||||
|
||||
find /usr/local/bin -name "*-6" -exec sh -c 'ln -s "$1" $(echo "$1" | sed "s/..$//")' _ {} \;
|
||||
|
||||
Also, you need to make sure that `/usr/local/bin` appears before `/usr/bin` in your `$PATH`, or else this will not work.
|
||||
|
||||
Check that `gcc -v` shows the homebrew version you installed.
|
||||
|
||||
### Compiling
|
||||
|
||||
The Cataclysm source is compiled using `make`.
|
||||
|
||||
### Make options
|
||||
|
||||
* `NATIVE=osx` build for OS X. Required for all Mac builds.
|
||||
* `OSX_MIN=version` sets `-mmacosx-version-min=` (for OS X > 10.5 set it to 10.6 or higher); omit for 10.5.
|
||||
* `TILES=1` build the SDL version with graphical tiles (and graphical ASCII); omit to build with `ncurses`.
|
||||
* `SOUND=1` - if you want sound; this requires `TILES=1` and the additional dependencies mentioned above.
|
||||
* `FRAMEWORK=1` (tiles only) link to SDL libraries under the OS X Frameworks folders; omit to use SDL shared libraries from Homebrew or Macports.
|
||||
* `LOCALIZE=0` disable localization (to get around possible `gettext` errors if it is not setup correctly); omit to use `gettext`.
|
||||
* `LANGUAGES="<lang_id_1>[lang_id_2][...]"` compile localization files for specified languages. e.g. `LANGUAGES="zh_CN zh_TW"`. You can also use `LANGUAGES=all` to compile all localization files.
|
||||
* `RELEASE=1` build an optimized release version; omit for debug build.
|
||||
* `CLANG=1` build with [Clang](http://clang.llvm.org/), the compiler that's included with the latest Command Line Tools for Xcode; omit to build using gcc/g++.
|
||||
* `MACPORTS=1` build against dependencies installed via Macports, currently only `gettext` and `ncurses`.
|
||||
* `USE_HOME_DIR=1` places user files (config, saves, graveyard, etc) in the user's home directory. For curses builds, this is `/Users/<user>/.cataclysm-dda`, for SDL builds it is `/Users/<user>/Library/Application Support/Cataclysm`.
|
||||
* `DEBUG_SYMBOLS=1` retains debug symbols when building an optimized release binary, making it easy for developers to spot the crash site.
|
||||
|
||||
In addition to the options above, there is an `app` make target which will package the tiles build into `Cataclysm.app`, a complete tiles build in a Mac application that can run without Terminal.
|
||||
|
||||
For more info, see the comments in the `Makefile`.
|
||||
|
||||
### Make examples
|
||||
|
||||
Build a release SDL version using Clang without gettext:
|
||||
|
||||
make NATIVE=osx OSX_MIN=10.7 RELEASE=1 TILES=1 LOCALIZE=0 CLANG=1
|
||||
|
||||
Build a release SDL version using Clang, link to libraries in the OS X Frameworks folders, don't use `gettext`, and package it into `Cataclysm.app`:
|
||||
|
||||
make app NATIVE=osx OSX_MIN=10.7 RELEASE=1 TILES=1 FRAMEWORK=1 LOCALIZE=0 CLANG=1
|
||||
|
||||
Build a release curses version with gettext supplied by Macports:
|
||||
|
||||
make NATIVE=osx OSX_MIN=10.7 RELEASE=1 LOCALIZE=1 MACPORTS=1 CLANG=1
|
||||
|
||||
### Compiling localization files
|
||||
|
||||
If you just want to compile localization files for specified languages, you can add `LANGUAGES="<lang_id_1>[lang_id_2][...]"` option to make command:
|
||||
|
||||
make LANGUAGES="zh_CN zh_TW"
|
||||
|
||||
You can get the language ID from the filenames of `*.po` in `lang/po` directory. Setting `LOCALIZE=1` may not tell `make` to compile those localization files for you.
|
||||
|
||||
### Running
|
||||
|
||||
For curses builds:
|
||||
|
||||
./cataclysm
|
||||
|
||||
For SDL:
|
||||
|
||||
./cataclysm-tiles
|
||||
|
||||
For `app` builds, launch Cataclysm.app from Finder.
|
||||
|
||||
### Test suite
|
||||
|
||||
The build will also generate a test executable at tests/cata_test.
|
||||
Invoke it as you would any other executable and it will run the full suite of tests.
|
||||
Pass the ``--help`` flag to list options.
|
||||
|
||||
### dmg distribution
|
||||
|
||||
You can build a nice dmg distribution file with the `dmgdist` target. You will need a tool called [dmgbuild](https://pypi.python.org/pypi/dmgbuild). To install this tool, you will need Python first. If you are on Mac OS X >= 10.8, Python 2.7 is pre-installed with the OS. If you are on an older version of OS X, you can download Python [on their official website](https://www.python.org/downloads/) or install it with homebrew `brew install python`. Once you have Python, you should be able to install `dmgbuild` by running:
|
||||
|
||||
# This install pip. It might not be required if it is already installed.
|
||||
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python
|
||||
# dmgbuild install
|
||||
sudo pip install dmgbuild pyobjc-framework-Quartz
|
||||
|
||||
Once `dmgbuild` is installed, you will be able to use the `dmgdist` target like this. The use of `USE_HOME_DIR=1` is important here because it will allow for an easy upgrade of the game while keeping the user config and his saves in his home directory.
|
||||
|
||||
make dmgdist NATIVE=osx OSX_MIN=10.7 RELEASE=1 TILES=1 FRAMEWORK=1 LOCALIZE=0 CLANG=1 USE_HOME_DIR=1
|
||||
|
||||
You should see a `Cataclysm.dmg` file.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### ISSUE: crash on startup due to libint.8.dylib aborting
|
||||
|
||||
If you're compiling on Mountain Lion or above, it won't be possible to run successfully on older OS X versions due to libint.8 / pthreads version issue.
|
||||
|
||||
From https://wiki.gnome.org/GTK+/OSX/Building:
|
||||
|
||||
> "There's another issue with building on Lion or Mountain Lion using either "native" or the 10.7 SDK: Apple has updated the pthreads implementation to provide recursive locking. This would be good except that Gettext's libintl uses this and if the pthreads implementation doesn't provide it it fabricates its own. Since the Lion pthreads does provide it, libintl links the provided function and then crashes when you try to run it against an older version of the library. The simplest solution is to specify the 10.6 SDK when building on Lion, but that won't work on Mountain Lion, which doesn't include it. See below for how to install and use XCode 3 on Lion and later for building applications compatible with earlier versions of OSX."
|
||||
|
||||
Workaround: install XCode 3 like that article describes, or disable localization support in Cataclysm so gettext/libint are not dependencies. Or else simply don't support OS X versions below 10.7.
|
||||
|
||||
### ISSUE: Colors don't show up correctly
|
||||
|
||||
Open Terminal's preferences, turn on "Use bright colors for bold text" in "Preferences -> Settings -> Text"
|
||||
|
||||
|
||||
# Windows
|
||||
|
||||
## Visual Studio Guide
|
||||
|
||||
Visual Studio 2015 (or later) is required to build Cataclysm. If you use a later version of Visual Studio, you will need to [enable the Visual Studio 2015 (v140) platform toolset](https://developercommunity.visualstudio.com/content/problem/48806/cant-find-v140-in-visual-studio-2017.html). We created solution and project files in directory `msvc-full-features`. Because of the complexity and how troublesome defining every combination of build feature options are, in Visual Studio project we added all build features, including tiles, sound, localization and lua.
|
||||
|
||||
### Dependencies
|
||||
|
||||
We've prepared an archive containing all the headers and libraries required to build Cataclysm: [http://dev.narc.ro/cataclysm/WinDepend-MSVC.zip](http://dev.narc.ro/cataclysm/WinDepend-MSVC.zip) or [http://dev.narc.ro/cataclysm/WinDepend-MSVC.7z](http://dev.narc.ro/cataclysm/WinDepend-MSVC.7z). The latter is smaller, but if you don't have a 7-zip archive extracter, the former one is easier to deal with.
|
||||
|
||||
Extract the 'WinDepend' folder and put it in the root folder of Cataclysm project. Run the "copy_dll_to_bin" batch file and then move the dll files from the bin folder into the root folder the Cataclysm project.
|
||||
|
||||
### Lua
|
||||
|
||||
The next thing you need to do is to install lua. Download the appropriate x86 or x64 lua from [http://lua-users.org/wiki/LuaBinaries](http://lua-users.org/wiki/LuaBinaries) or [http://dev.narc.ro/cataclysm/WinDepend-lua.zip](http://dev.narc.ro/cataclysm/WinDepend-lua.zip), and extract it to `C:\Windows\System32` or somewhere else on your path.
|
||||
|
||||
Once you have it installed, go to the project directory, then go to `src/lua`, and run `lua53 generate_bindings.lua catabindings.cpp`. This will generate the `catabindings.cpp` file which is necessary for compilation.
|
||||
|
||||
### Building
|
||||
|
||||
Building Cataclysm with Visual Studio is very simple. Just build it like a normal Visual C++ project. The process may takes a long period of time, so you'd better prepare a cup of coffee and some books in front of your computer :)
|
||||
|
||||
If you need localization support, execute the bash script `lang/compile_mo.sh` inside Git Bash GUI just like on a UNIX-like system.
|
||||
|
||||
### Debugging
|
||||
|
||||
After building Cataclysm, you may discover that after pressing the debug button in Visual Studio, Cataclysm just exits after launch with return code 1. That is because of the wrong working directory. You need to configure the working directory to `$(ProjectDir)..`.
|
||||
|
||||
### Make a distribution
|
||||
|
||||
There is a batch script in `msvc-full-features` folder `distribute.bat`. It will create a sub folder `distribution` and copy all required files(eg. `data/`, `Cataclysm.exe` and dlls) into that folder. Then you can zip it and share the archive on the Internet.
|
||||
|
||||
## MinGW Guide
|
||||
To compile under windows MinGW you first need to download mingw. An automated GUI installer assistant called mingw-get-setup.exe will make everything a lot easier. I recommend installing it to `C:\MinGW`
|
||||
https://sourceforge.net/projects/mingw/files/latest/download
|
||||
|
||||
### MinGW setup
|
||||
once installed we need to get the right packages. In "Basic Setup", mark `mingw-developer-toolkit`, `mingw32-base` and `mingw32-gcc-g++`
|
||||
|
||||
Then install these components using `Installation -> Apply Changes`.
|
||||
|
||||
#### Localization
|
||||
If we want to compile with localization, we will need gettext and libintl. In "All Packages -> MinGW -> MinGW Autotools" ensure that `mingw32-gettext` and `mingw32-libintl` are installed.
|
||||
|
||||
### Required Tiles(SDL) Libraries
|
||||
If we want to compile with Tiles (SDL) we have to download a few libraries.
|
||||
* `SDL2` http://www.libsdl.org/download-2.0.php chose `SDL2-devel-2.0.X-mingw.tar.gz`.
|
||||
* `SDL_ttf` https://www.libsdl.org/projects/SDL_ttf/ chose `SDL2_ttf-devel-2.0.12-mingw.tar.gz`.
|
||||
* `SDL_image` https://www.libsdl.org/projects/SDL_image/ chose ` SDL2_image-devel-2.0.0-mingw.tar.gz`
|
||||
* `freetype` http://gnuwin32.sourceforge.net/packages/freetype.htm chose `Binaries` and `Developer files`
|
||||
|
||||
#### Bundled Libraries
|
||||
The following archives were pre-bundled for convenience and reduction of head-aches, simply download and extract directly to the root directory of the CDDA source:
|
||||
* `64-bit SDL \ Tiles \ Sound \ Lua \ Localization` http://dev.narc.ro/cataclysm/cdda-win64-codeblocks.7z
|
||||
|
||||
#### Installing Tiles(SDL) libraries.
|
||||
For the first 3 (`SDL2`, `SDL_ttf` and `SDL_image`) you want to extract the include and lib folders from the `i686-w64-mingw32` folders into your MinGW installation folder. (Recommended `C:\MinGW`). And the `SDL2_image.dll` and `SDL2_ttf.dll` into your cataclysm root folder.
|
||||
|
||||
For freetype you want to grab the include and lib folders from the `freetype-2.X.X-X-lib.zip` and move them into your your MinGW installation folder. Then you want to get the freetype6.dll from the `freetype-2.X.X-X-bin.zip` and move it into your cataclysm root folder.
|
||||
|
||||
#### ISSUE - "winapifamily.h" no such file or directoyr
|
||||
There seems to be at the moment of writing that a file in SDL is broken and needs to be replaced.
|
||||
https://hg.libsdl.org/SDL/raw-file/e217ed463f25/include/SDL_platform.h
|
||||
Replace SDL_platform.h in the MinGW/include/SDL2 folder and it should be fine.
|
||||
|
||||
### Makefile changes
|
||||
This probably not the best way to do it. But it seems that you need to remove a few dependencies from the makefile or it will not build.
|
||||
change the line `LDFLAGS += -lfreetype -lpng -lz -ljpeg -lbz2` to `LDFLAGS += -lfreetype`
|
||||
|
||||
### Compiling
|
||||
Navigate to `MinGW\msys\1.0` and run `msys.bat`. This will start a cmd-like shell where the following entries will be made.
|
||||
|
||||
Add the MinGW toolchain to your PATH with `export PATH=$PATH:/c/MinGW/bin`. Replace /c/MinGW/ with the directory into which you installed MinGW (/c/ stands for drive C:, so if it's in F:/foo/bar, you'd use /f/foo/bar).
|
||||
|
||||
Navigate to the CDDA source code directory.
|
||||
|
||||
Compile using `make TILES=1 NATIVE=win32 LOCALIZE=1` and unless there are problems, it should produce a CDDA binary for you.
|
||||
|
||||
If you dont want tiles you can change `TILES` to 0.
|
||||
|
||||
If you dont want localization you can change `LOCALIZE` to 0.
|
||||
|
||||
## Rough guide to building with only MSYS2
|
||||
|
||||
This is a tentative step-by-step guide to building your own CDDA with Tiles, Localization and Lua using only MSYS2. You may want to follow it if the MinGW guide above doesn't work for you or you just feel adventurous. Feedback is very much welcome in terms of issues and/or pull-requests.
|
||||
|
||||
This guide assumes you're building on a x86_64 build of Windows. If not adjust the invocations appropriately. It has been tested and proven to work on Windows XP, Windows 7 and Windows 10. Your mileage may vary.
|
||||
|
||||
#### 1. Go to https://msys2.github.io/ and download appropriate MSYS (top of the page).
|
||||
|
||||
#### 2. Install MSYS2 and leave the Run ticker on. You should end up with a MSYS2 terminal.
|
||||
|
||||
#### 3. In the open terminal:
|
||||
|
||||
```bash
|
||||
pacman --needed -Sy bash pacman pacman-mirrors msys2-runtime
|
||||
```
|
||||
|
||||
Note: You may close the terminal now and reopen it from the Start menu (MSYS2 Shell, just to be on the safe-er side).
|
||||
|
||||
Note: You may need to bash the close button repeatedly. Or use the task manager to kill it.
|
||||
|
||||
#### 4. Open an editor that preserves line-endings
|
||||
|
||||
Note: Wordpad should do. Or Notepad++.
|
||||
|
||||
#### 5. Open `C:\msys64\etc\pacman.conf` and change:
|
||||
|
||||
```bash
|
||||
# By default, pacman accepts packages signed by keys that its local keyring
|
||||
# trusts (see pacman-key and its man page), as well as unsigned packages.
|
||||
#SigLevel = Never
|
||||
SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
#RemoteFileSigLevel = Required
|
||||
```
|
||||
|
||||
To:
|
||||
|
||||
```bash
|
||||
# By default, pacman accepts packages signed by keys that its local keyring
|
||||
# trusts (see pacman-key and its man page), as well as unsigned packages.
|
||||
SigLevel = Never
|
||||
#SigLevel = Required DatabaseOptional
|
||||
LocalFileSigLevel = Optional
|
||||
#RemoteFileSigLevel = Required
|
||||
```
|
||||
|
||||
(Exchange the # on SigLevel). This disables signature checking as it is currently borked.
|
||||
|
||||
#### 6. Save the file
|
||||
|
||||
#### 7. Run in MSYS2 terminal:
|
||||
|
||||
```bash
|
||||
update-core
|
||||
pacman -Su
|
||||
pacman -S mingw-w64-x86_64-gcc
|
||||
pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_ttf
|
||||
pacman -S mingw-w64-x86_64-ncurses
|
||||
pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-libwebp
|
||||
pacman -S git make
|
||||
pacman -S mingw-w64-x86_64-lua
|
||||
```
|
||||
|
||||
#### 8. Close MSYS2 terminal and open MinGW-w64 Win64 Shell from Start menu and run:
|
||||
|
||||
Note: This will download whole CDDA repository. If you're just testing you should probably add `--depth=1`.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
cd Cataclysm-DDA
|
||||
```
|
||||
|
||||
#### 9. Compile your CDDA by running:
|
||||
|
||||
```bash
|
||||
make MSYS2=1 RELEASE=1 TILES=1 LOCALIZE=1 SOUND=1 LUA=1 NATIVE=win64
|
||||
```
|
||||
|
||||
Note: You cannot naively use `-jX` to speed up your building process with `LUA=1`. You must first run `cd src/lua/ && lua generate_bindings.lua && cd ../..` if you want to use `-jX`. X should be the number of threads/cores your processor has.
|
||||
|
||||
That's it. You should get a `cataclysm-tiles.exe` binary in the same folder you've found the `Makefile` in. The make flags are the same as the ones described above. For instance, if you do not want to build with sound support, you can remove `SOUND=1`.
|
||||
|
||||
# BSDs
|
||||
|
||||
There are reports of CDDA building fine on recent OpenBSD and FreeBSD machines (with appropriately recent compilers), and there is some work being done on making the `Makefile` "just work", however we're far from that and BSDs support is mostly based on user contributions. Your mileage may vary. So far essentially all testing has been on amd64, but there is no (known) reason that other architectures shouldn't work, in principle.
|
||||
|
||||
### Building on FreeBSD/amd64 10.1 with the system compiler
|
||||
|
||||
FreeBSD uses clang as the default compiler as of 10.0, and combines it with libc++ to provide C++11 support out of the box. You will however need gmake (examples for binary packages):
|
||||
|
||||
`pkg install gmake`
|
||||
|
||||
Tiles builds will also require SDL2:
|
||||
|
||||
`pkg install sdl2 sdl2_image sdl2_mixer sdl2_ttf`
|
||||
|
||||
Then you should be able to build with something like this (you can of course set CXXFLAGS and LDFLAGS in your .profile or something):
|
||||
|
||||
```
|
||||
export CXXFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"
|
||||
gmake # ncurses builds
|
||||
gmake TILES=1 # tiles builds
|
||||
```
|
||||
|
||||
The author has not tested tiles builds, as the build VM lacks X; they do at least compile/link successfully.
|
||||
|
||||
### Building ncurses version on FreeBSD/amd64 9.3 with GCC 4.8.4 from ports
|
||||
|
||||
For ncurses build add to `Makefile`, before `VERSION`:
|
||||
|
||||
```Makefile
|
||||
OTHERS += -D_GLIBCXX_USE_C99
|
||||
CXX = g++48
|
||||
CXXFLAGS += -I/usr/local/lib/gcc48/include
|
||||
LDFLAGS += -rpath=/usr/local/lib/gcc48
|
||||
```
|
||||
Note: or you can `setenv` the above (merging `OTHERS` into `CXXFLAGS`), but you knew that.
|
||||
|
||||
And then build with `gmake LOCALIZE=0 RELEASE=1`.
|
||||
|
||||
### Building on OpenBSD/amd64 5.8 with GCC 4.9.2 from ports/packages
|
||||
|
||||
First, install g++, gmake, and libexecinfo from packages (g++ 4.8 or 4.9 should work; 4.9 has been tested):
|
||||
|
||||
`pkg_add g++ gmake libexecinfo`
|
||||
|
||||
Then you should be able to build with something like:
|
||||
|
||||
`CXX=eg++ gmake`
|
||||
|
||||
Only an ncurses build is possible on 5.8-release, as SDL2 is broken. On recent -current or snapshots, however, you can install the SDL2 packages:
|
||||
|
||||
`pkg_add sdl2 sdl2-image sdl2-mixer sdl2-ttf`
|
||||
|
||||
and build with:
|
||||
|
||||
`CXX=eg++ gmake TILES=1`
|
||||
|
||||
### Building on NetBSD/amd64 7.0RC1 with the system compiler
|
||||
|
||||
NetBSD has (or will have) gcc 4.8.4 as of version 7.0, which is new enough to build cataclysm. You will need to install gmake and ncursesw:
|
||||
|
||||
`pkgin install gmake ncursesw`
|
||||
|
||||
Then you should be able to build with something like this (LDFLAGS for ncurses builds are taken care of by the ncurses configuration script; you can of course set CXXFLAGS/LDFLAGS in your .profile or something):
|
||||
|
||||
```
|
||||
export CXXFLAGS="-I/usr/pkg/include"
|
||||
gmake # ncurses builds
|
||||
LDFLAGS="-L/usr/pkg/lib" gmake TILES=1 # tiles builds
|
||||
```
|
||||
|
||||
SDL builds currently compile, but did not run in my testing - not only do they segfault, but gdb segfaults when reading the debug symbols! Perhaps your mileage will vary.
|
||||
@@ -8,22 +8,11 @@
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"RELEASE=1"
|
||||
"RELEASE=1",
|
||||
"LUA=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",
|
||||
"name": "make RELEASE LUA",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
@@ -33,10 +22,24 @@
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"LUA=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make LUA",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"LUA=1",
|
||||
"TILES=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make TILES",
|
||||
"name": "make TILES LUA",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
@@ -46,11 +49,12 @@
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"LUA=1",
|
||||
"TILES=1",
|
||||
"RELEASE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make RELEASE TILES",
|
||||
"name": "make RELEASE TILES LUA",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
}
|
||||
],
|
||||
|
||||
+108
-55
@@ -12,8 +12,7 @@
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
@@ -23,9 +22,8 @@
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
</Compiler>
|
||||
@@ -41,9 +39,9 @@
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
@@ -56,16 +54,38 @@
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (Lua)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLua/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLUA" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/lua5.1" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="liblua5.1.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c cd src/lua && lua5.1 -v || echo 'lua5.1' command not found!" />
|
||||
<Add before="cmd /c cd src/lua && lua5.1 generate_bindings.lua catabindings.cpp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
</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="-Os -O2" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
@@ -85,10 +105,10 @@
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
@@ -103,19 +123,21 @@
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Loc, Sound)">
|
||||
<Target title="Release (SDL, Loc, Lua, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalizedSoundSDL/" />
|
||||
<Option object_output="obj/ReleaseLocalizedLuaSoundSDL/" />
|
||||
<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="-Os -O2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add option="-DLUA" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/lua5.1" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
@@ -126,8 +148,14 @@
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add library="liblua5.1.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c cd src/lua && lua5.1 -v || echo 'lua5.1' command not found!" />
|
||||
<Add before="cmd /c cd src/lua && lua5.1 generate_bindings.lua catabindings.cpp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Debug">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
@@ -147,14 +175,12 @@
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add directory="WinDepend/include" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
@@ -167,14 +193,14 @@
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
@@ -182,6 +208,28 @@
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (Lua)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLua/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLUA" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/lua5.1" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="liblua5.1.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c cd src/lua && lua5.1 -v || echo 'lua5.1' command not found!" />
|
||||
<Add before="cmd /c cd src/lua && lua5.1 generate_bindings.lua catabindings.cpp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugSoundSDL/" />
|
||||
@@ -189,15 +237,15 @@
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DSDL_SOUND=1" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
@@ -213,15 +261,15 @@
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DTILES" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
@@ -231,23 +279,25 @@
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Loc, Sound)">
|
||||
<Target title="Debug (SDL, Loc, Lua, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalizedSoundSDL/" />
|
||||
<Option object_output="obj/DebugLocalizedLuaSoundSDL/" />
|
||||
<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 option="-pg -g" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add option="-DSDL_SOUND" />
|
||||
<Add option="-DLUA" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/lua5.1" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
@@ -255,19 +305,22 @@
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add library="liblua5.1.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c cd src/lua && lua5.1 -v || echo 'lua5.1' command not found!" />
|
||||
<Add before="cmd /c cd src/lua && lua5.1 generate_bindings.lua catabindings.cpp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-std=c++14" />
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-DCB_BUILD" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_MINGW" />
|
||||
<Add option="-D_WIN32" />
|
||||
<Add option="-D__MINGW__" />
|
||||
<Add option="-D_WINDOWS -D_MINGW -D_WIN32 -DWIN32 -D__MINGW__" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-Wl,-stack,12000000,-subsystem,windows" />
|
||||
|
||||
@@ -3,69 +3,38 @@
|
||||
There are a large number of files in `json/items/comestibles`, and this guide will help you decide where to put your new comestible!
|
||||
|
||||
## List of special comestibles:
|
||||
`med.json` -- comestible that has an addiction effect besides alcohol and caffeine, plus bandages and antiseptic type items.
|
||||
|
||||
`med.json` -- comestible that has an addiction effect besides alcohol and caffeine, plus bandages and disinfectant type items.
|
||||
`mre.json` -- items and comestibles related to MREs
|
||||
|
||||
`mutagen.json` -- comestible that has any mutagen effect
|
||||
|
||||
`carnivore.json` -- item that would normally be butchered from an animal or monster, and their cooked versions. examples: chunks of meat, tainted bones, boiled stomach
|
||||
|
||||
`protein.json` -- comestibles based on protein powder
|
||||
|
||||
`spice.json` -- comestibles that normally do not have nutrients, but are used to flavor a dish. examples: salt, thyme, black pepper
|
||||
|
||||
`frozen.json` -- comestibles best eaten frozen
|
||||
|
||||
`brewing.json` -- items used in the brewing process
|
||||
|
||||
## List of normal comestibles, in order of priority:
|
||||
When you have a comestible you want to add to the files, just go down this list, and the first filename you see in the list that matches the criteria is your choice!
|
||||
|
||||
### Liquid
|
||||
|
||||
`alcohol.json` -- "Drink" comestible with alcohol addiction
|
||||
|
||||
`soup.json` -- "Drink" comestible which is a soup. This is more of a "food" than a drink - you primarily want the calories from this
|
||||
|
||||
`drink.json` -- "Drink" comestible. This is your drink of choice when you're thirsty! examples: tea, juice, water
|
||||
|
||||
`drink_other.json` -- "Drink" comestible that does not fit any other criteria. example: vinegar, mustard
|
||||
|
||||
### Solid
|
||||
|
||||
`junkfood.json` -- comestible with the "junk" material. examples: cake, sugary cereal, nachos
|
||||
|
||||
`sandwich.json` -- a "sandwich" is generally two slices of "bread" with something in between. examples: BLT, PB&J sandwich, fish sandwich
|
||||
|
||||
`offal_dishes.json` -- comestible made of various offals. the offal types are: liver, brain, kidney, sweetbread, stomach. This must be the primary part of the dish.
|
||||
|
||||
`seed.json` -- seeds
|
||||
|
||||
`meat_dishes_human.json` -- comestible made of human flesh. examples: hobo helper, tio taco
|
||||
|
||||
`meat_dishes.json` -- comestible made with meat.
|
||||
|
||||
`raw_veggy.json` -- comestible that is a vegetable in its raw form.
|
||||
|
||||
`irradiated_veggy.json` -- comestible that is an irradiated vegetable. has an indefinite shelf life.
|
||||
|
||||
`raw_fruit.json` -- comestible that is a fruit in its raw form.
|
||||
|
||||
`irradiated_fruit.json` -- comestible that is an irradiated fruit. has an indefinite shelf life.
|
||||
|
||||
`veggy_dishes.json` -- comestible made of vegetables.
|
||||
|
||||
`bread.json` -- comestible that is either a bread starter, or a cooked bread.
|
||||
|
||||
`wheat.json` -- either raw wheat, or made of wheat
|
||||
|
||||
`egg.json` -- either an egg, or made of egg
|
||||
|
||||
`dairy.json` -- made of milk
|
||||
|
||||
`mushroom.json` -- a mushroom or made of mushrooms
|
||||
|
||||
`nuts.json` -- a nut or made of nuts
|
||||
|
||||
`other.json` -- if you made it here, your comestible doesn't fit any other category!
|
||||
@@ -44,11 +44,11 @@ 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.
|
||||
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` 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".
|
||||
We keep the development and direction of the game community-driven so placing a bounty *does not* necessarily mean that change will be incorporated into the main game. But it may be incorporated as a mod (or not). As such feel free to post bounties on what you like, but remember we don't do "bounty-driven" development. 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
|
||||
|
||||
|
||||
@@ -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.
|
||||
+3
-39
@@ -1,45 +1,9 @@
|
||||
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.
|
||||
The Square font (data/font/square.ttf) is copyright Wouter van Oortmerssen, licensed under Creative Commons Attribution 3.0 Unported License. See http://strlen.com/square for more information.
|
||||
|
||||
Terminus Font (data/font/terminus.ttf) is licensed under the SIL Open Font License (see LICENSE-OFL-Terminus-Font.txt).
|
||||
GNU Unifont (data/font/unitfont.ttf) is licensed under GNU General Public License v2+ with the GNU font embedding exception. Visit http://unifoundry.com/LICENSE.txt for details.
|
||||
|
||||
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).
|
||||
CATCH unit-test framework is licensed under the Boost Software License. Visit https://github.com/philsquared/Catch/blob/master/LICENSE.txt to read the license.
|
||||
|
||||
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.
|
||||
|
||||
@@ -1,59 +1,29 @@
|
||||
# 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>
|
||||
|
||||
[](https://travis-ci.org/CleverRaven/Cataclysm-DDA)
|
||||
[](https://coveralls.io/github/CleverRaven/Cataclysm-DDA?branch=master)
|
||||
[](https://lgtm.com/projects/g/CleverRaven/Cataclysm-DDA/context:cpp)
|
||||
[](https://www.codetriage.com/cleverraven/cataclysm-dda)
|
||||
[](https://github.com/CleverRaven/Cataclysm-DDA/graphs/contributors)
|
||||
[](https://github.com/XAMPPRocky/tokei)
|
||||
|
||||
## Downloads
|
||||
# Cataclysm: Dark Days Ahead
|
||||
|
||||
**Releases** - [Stable](https://cataclysmdda.org/releases/) | [Experimental](https://cataclysmdda.org/experimental/)
|
||||
Cataclysm: Dark Days Ahead is a roguelike 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, that want what you have...
|
||||
|
||||
**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
|
||||
## Download
|
||||
|
||||
#### Arch Linux
|
||||
Visit [our website](http://cataclysmdda.org) for download links to all stable and experimental releases.
|
||||
|
||||
Ncurses and tiles versions are available in the [community repo](https://www.archlinux.org/packages/?q=cataclysm-dda).
|
||||
The source can either be downloaded as [an archive](https://github.com/CleverRaven/Cataclysm-DDA/archive/master.zip), or you can clone it from [our GitHub repository](https://github.com/CleverRaven/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*)
|
||||
Please read [COMPILING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING.md) - it covers general information and more specific recipes for Linux, OS X, Windows and BSD. We also have an "unofficial" guide on building with `cmake` at [COMPILING-CMAKE.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING-CMAKE.md) and guide on building on Windows with `MSYS2` at [COMPILING-MSYS.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/COMPILING-MSYS.md). See [doc/COMPILER_SUPPORT.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/COMPILER_SUPPORT.md) for details on which compilers we support. And you can always dig for more information in `doc/`.
|
||||
|
||||
## 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.
|
||||
Cataclysm:Dark Days Ahead is the result of contributions from over 700 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)
|
||||
[](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.
|
||||
|
||||
@@ -63,7 +33,7 @@ Forums:
|
||||
https://discourse.cataclysmdda.org
|
||||
|
||||
Wiki:
|
||||
http://cddawiki.chezzo.com/cdda_wiki/index.php
|
||||
http://tools.cataclysmdda.com/wiki
|
||||
|
||||
GitHub repo:
|
||||
https://github.com/CleverRaven/Cataclysm-DDA
|
||||
@@ -72,9 +42,6 @@ IRC:
|
||||
`irc.freenode.net` ; `#CataclysmDDA`
|
||||
http://webchat.freenode.net/?channels=#CataclysmDDA
|
||||
|
||||
Official Discord:
|
||||
https://discord.gg/jFEc7Yp
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
#### Is there a tutorial?
|
||||
@@ -89,14 +56,6 @@ Press the `?` key, followed by the `1` key to see the full list of key commands.
|
||||
|
||||
**World** on the main menu will generate a fresh world for you. Select **Create World**.
|
||||
|
||||
#### I've found a bug. What should I do?
|
||||
#### I've found a bug / 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 [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:
|
||||
|
||||
[](https://feathub.com/CleverRaven/Cataclysm-DDA)
|
||||
Please submit an issue on [our GitHub page](https://github.com/CleverRaven/Cataclysm-DDA/issues/). If you're not able to, send an email to `kevin.granade@gmail.com`.
|
||||
|
||||
@@ -61,5 +61,3 @@ 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>
|
||||
|
||||
+10
-14
@@ -1,21 +1,17 @@
|
||||
!config/
|
||||
!deps*.zip
|
||||
*.iml
|
||||
.cxx
|
||||
.DS_Store
|
||||
.externalNativeBuild
|
||||
.gradle
|
||||
/.idea/libraries
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
!config/
|
||||
/app/jni/libintl-lite
|
||||
/app/jni/lua
|
||||
/app/jni/mpg-123
|
||||
/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
|
||||
|
||||
+80
-314
@@ -1,15 +1,11 @@
|
||||
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 {
|
||||
}
|
||||
else {
|
||||
apply plugin: 'com.android.library'
|
||||
}
|
||||
|
||||
@@ -21,300 +17,100 @@ if (localPropertiesFile.exists()) {
|
||||
}
|
||||
}
|
||||
|
||||
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 luaBinary = 'lua'
|
||||
if( localProperties.getProperty('luaBinary') != null ) {
|
||||
luaBinary = localProperties.getProperty('luaBinary')
|
||||
}
|
||||
|
||||
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 zipFile = new File('./deps.zip')
|
||||
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
|
||||
|
||||
switch(OperatingSystem.current()) {
|
||||
case OperatingSystem.LINUX:
|
||||
task makeLocalization(type: Exec) {
|
||||
workingDir './../..'
|
||||
commandLine 'make', 'localization', 'LANGUAGES=all'
|
||||
}
|
||||
|
||||
task makeLuaBindings(type: Exec) {
|
||||
workingDir './jni/src/lua'
|
||||
commandLine luaBinary, 'generate_bindings.lua'
|
||||
}
|
||||
|
||||
preBuild.dependsOn makeLocalization
|
||||
preBuild.dependsOn makeLuaBindings
|
||||
break
|
||||
case OperatingSystem.WINDOWS:
|
||||
task makeLocalization(type: Exec) {
|
||||
workingDir './../..'
|
||||
commandLine 'sh.exe', 'android/app/makelocalizations.sh'
|
||||
}
|
||||
|
||||
task makeLuaBindings(type: Exec) {
|
||||
workingDir './../../src/lua'
|
||||
commandLine luaBinary, 'generate_bindings.lua'
|
||||
}
|
||||
unzipDeps.dependsOn makeLocalization
|
||||
preBuild.dependsOn makeLuaBindings
|
||||
break
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion override_compileSdkVersion
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion "28.0.1"
|
||||
|
||||
|
||||
if(OperatingSystem.current().isLinux()) {
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'make', 'version'
|
||||
}
|
||||
}
|
||||
if(OperatingSystem.current().isWindows()) {
|
||||
exec {
|
||||
workingDir './../..'
|
||||
commandLine 'sh.exe', '-c', 'make version'
|
||||
}
|
||||
}
|
||||
|
||||
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]
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName new File('app/jni/src/version.h').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)"
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a"
|
||||
//abiFilters "x86" // use this for testing on emulators
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=android-16", "-j$njobs"
|
||||
}
|
||||
}
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
signingConfigs {
|
||||
if (keystoreProperties.getProperty('storeFile') != null) {
|
||||
if (file(keystoreProperties.getProperty('storeFile')).exists()) {
|
||||
if( localProperties.getProperty('storeFile') != null ) {
|
||||
if( file(localProperties.getProperty('storeFile')).exists() ) {
|
||||
release {
|
||||
storeFile file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword keystoreProperties.getProperty("storePassword")
|
||||
keyAlias keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword keystoreProperties.getProperty("keyPassword")
|
||||
storeFile file(localProperties.getProperty("storeFile"))
|
||||
storePassword localProperties.getProperty("storePassword")
|
||||
keyAlias localProperties.getProperty("keyAlias")
|
||||
keyPassword localProperties.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")
|
||||
throw new GradleException("Keystore file " + localProperties.getProperty("storeFile") + " was not found.\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,33 +118,25 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (signingConfigs.hasProperty("release")) {
|
||||
if( signingConfigs.hasProperty("release") ) {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
cFlags "-DNDEBUG", "-DRELEASE", "-Os", "-g"
|
||||
cFlags "-DNDEBUG", "-DRELEASE", "-Os"
|
||||
}
|
||||
}
|
||||
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')) {
|
||||
@@ -360,22 +148,18 @@ android {
|
||||
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";
|
||||
def fileName = "com.cleverraven.cataclysmdda.aar";
|
||||
output.outputFile = new File(outputFile.parent, fileName);
|
||||
}
|
||||
}
|
||||
@@ -383,24 +167,6 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
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.
@@ -2,7 +2,7 @@
|
||||
|
||||
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
|
||||
APP_STL := c++_shared
|
||||
APP_CPPFLAGS += -std=c++14
|
||||
APP_CPPFLAGS += -std=c++11
|
||||
ifneq ($(OS),Windows_NT)
|
||||
APP_LDFLAGS += -fuse-ld=gold
|
||||
endif
|
||||
|
||||
@@ -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)
|
||||
@@ -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_
|
||||
@@ -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_
|
||||
@@ -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
|
||||
@@ -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_
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../src
|
||||
@@ -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)
|
||||
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>
|
||||
@@ -8,6 +8,9 @@
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Android 4.0.1 -->
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" />
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
@@ -21,7 +24,7 @@
|
||||
|
||||
<!-- 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.
|
||||
|
||||
@@ -37,13 +40,13 @@
|
||||
<!-- 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"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@@ -55,7 +58,7 @@
|
||||
android:launchMode="singleInstance"
|
||||
android:keepScreenOn="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
|
||||
>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../../../lua
|
||||
@@ -57,8 +57,4 @@ public class CataclysmDDA extends SDLActivity {
|
||||
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,8 +1,6 @@
|
||||
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;
|
||||
@@ -16,13 +14,11 @@ 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;
|
||||
@@ -32,8 +28,8 @@ public class SplashScreen extends Activity {
|
||||
private static final int INSTALL_DIALOG_ID = 0;
|
||||
private ProgressDialog installDialog;
|
||||
|
||||
public CharSequence[] mSettingsNames;
|
||||
public boolean[] mSettingsValues = { false, false, true };
|
||||
public CharSequence[] mSettingsNames = { "Software rendering" };
|
||||
public boolean[] mSettingsValues = { true };
|
||||
|
||||
private String getVersionName() {
|
||||
try {
|
||||
@@ -46,49 +42,6 @@ public class SplashScreen extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
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()");
|
||||
@@ -96,17 +49,10 @@ public class SplashScreen extends Activity {
|
||||
|
||||
// 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);
|
||||
}
|
||||
startGameActivity(false);
|
||||
}
|
||||
else {
|
||||
new InstallProgramTask().execute();
|
||||
new InstallProgramTask().execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +63,7 @@ public class SplashScreen extends Activity {
|
||||
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.setTitle(getString(clean_install ? R.string.installing : R.string.upgrading));
|
||||
installDialog.setIndeterminate(true);
|
||||
installDialog.setCancelable(false);
|
||||
return installDialog;
|
||||
@@ -164,23 +110,23 @@ public class SplashScreen extends Activity {
|
||||
|
||||
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();
|
||||
.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, "lua") +
|
||||
countTotalAssets(assetManager, "lang");
|
||||
showDialog(INSTALL_DIALOG_ID);
|
||||
} catch(Exception e) {
|
||||
@@ -188,45 +134,21 @@ public class SplashScreen extends Activity {
|
||||
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))
|
||||
.setTitle("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() {
|
||||
.setPositiveButton("Start game", 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();
|
||||
for (int i = 0; i < mSettingsNames.length; ++i)
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean(SplashScreen.this.mSettingsNames[i].toString(), SplashScreen.this.mSettingsValues[i]).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();
|
||||
}
|
||||
|
||||
@@ -241,22 +163,24 @@ public class SplashScreen extends Activity {
|
||||
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"));
|
||||
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 + "/lua"));
|
||||
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");
|
||||
// Install the new data over the top
|
||||
copyAssetFolder(assetManager, "data", externalFilesDir + "/data");
|
||||
copyAssetFolder(assetManager, "gfx", externalFilesDir + "/gfx");
|
||||
copyAssetFolder(assetManager, "lua", externalFilesDir + "/lua");
|
||||
copyAssetFolder(assetManager, "lang", externalFilesDir + "/lang");
|
||||
} catch(Exception e) {
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
return false;
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember which version the installed data is
|
||||
// Remember which version the installed data is
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("installed", getVersionName()).commit();
|
||||
|
||||
publishProgress(++installedFiles);
|
||||
@@ -291,14 +215,14 @@ public class SplashScreen extends Activity {
|
||||
// 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, "");
|
||||
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
|
||||
return files.length > 0; // folder exists
|
||||
for (String file : files) {
|
||||
if (file.equalsIgnoreCase(assetName))
|
||||
return true; // file exists
|
||||
@@ -391,11 +315,11 @@ public class SplashScreen extends Activity {
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
removeDialog(INSTALL_DIALOG_ID);
|
||||
if(result) {
|
||||
if(result) {
|
||||
settingsAlert.show();
|
||||
} else {
|
||||
installationAlert.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
SDL library initialization
|
||||
*/
|
||||
@@ -35,50 +33,5 @@ public class SDL {
|
||||
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,7 +1,6 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.media.*;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
public class SDLAudioManager
|
||||
@@ -18,250 +17,41 @@ public class SDLAudioManager
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int audioOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
|
||||
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
|
||||
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
|
||||
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
|
||||
|
||||
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);
|
||||
Log.v(TAG, "SDL audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||
|
||||
// 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);
|
||||
desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + 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;
|
||||
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) {
|
||||
Log.e(TAG, "Failed during initialization of Audio Track");
|
||||
mAudioTrack = null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mAudioTrack.play();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Log.v(TAG, "SDL audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +63,7 @@ public class SDLAudioManager
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length;) {
|
||||
for (int i = 0; i < buffer.length; ) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
@@ -298,7 +88,7 @@ public class SDLAudioManager
|
||||
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) {
|
||||
@@ -319,33 +109,53 @@ public class SDLAudioManager
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
public static int captureOpen(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
|
||||
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
|
||||
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
|
||||
int frameSize = (isStereo ? 2 : 1) * (is16Bit ? 2 : 1);
|
||||
|
||||
/** 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);
|
||||
Log.v(TAG, "SDL capture: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + (sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||
|
||||
// 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
|
||||
desiredFrames = Math.max(desiredFrames, (AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);
|
||||
|
||||
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 -1;
|
||||
}
|
||||
|
||||
mAudioRecord.startRecording();
|
||||
}
|
||||
|
||||
Log.v(TAG, "SDL capture: got " + ((mAudioRecord.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioRecord.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + (mAudioRecord.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
|
||||
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
/** 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);
|
||||
}
|
||||
// !!! FIXME: this is available in API Level 23. Until then, we always block. :(
|
||||
//return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void audioClose() {
|
||||
if (mAudioTrack != null) {
|
||||
@@ -364,24 +174,5 @@ public class SDLAudioManager
|
||||
}
|
||||
}
|
||||
|
||||
/** 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();
|
||||
}
|
||||
|
||||
@@ -11,14 +11,13 @@ import android.view.*;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class SDLControllerManager
|
||||
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 is_accelerometer, int nbuttons,
|
||||
int naxes, int nhats, int nballs);
|
||||
public static native int nativeRemoveJoystick(int device_id);
|
||||
public static native int nativeAddHaptic(int device_id, String name);
|
||||
@@ -36,21 +35,21 @@ public class SDLControllerManager
|
||||
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();
|
||||
}
|
||||
}
|
||||
mJoystickHandler = null;
|
||||
mHapticHandler = null;
|
||||
|
||||
if (mHapticHandler == null) {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
mHapticHandler = new SDLHapticHandler_API26();
|
||||
} else {
|
||||
mHapticHandler = new SDLHapticHandler();
|
||||
}
|
||||
SDLControllerManager.setup();
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
if (Build.VERSION.SDK_INT >= 16) {
|
||||
mJoystickHandler = new SDLJoystickHandler_API16();
|
||||
} else if (Build.VERSION.SDK_INT >= 12) {
|
||||
mJoystickHandler = new SDLJoystickHandler_API12();
|
||||
} else {
|
||||
mJoystickHandler = new SDLJoystickHandler();
|
||||
}
|
||||
mHapticHandler = new SDLHapticHandler();
|
||||
}
|
||||
|
||||
// Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
|
||||
@@ -75,16 +74,8 @@ public class SDLControllerManager
|
||||
/**
|
||||
* 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);
|
||||
public static void hapticRun(int device_id, int length) {
|
||||
mHapticHandler.run(device_id, length);
|
||||
}
|
||||
|
||||
// Check if a given device is considered a possible SDL joystick
|
||||
@@ -99,8 +90,8 @@ public class SDLControllerManager
|
||||
|
||||
/* 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_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a joystick.");
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
|
||||
@@ -110,7 +101,7 @@ public class SDLControllerManager
|
||||
}
|
||||
**/
|
||||
|
||||
return ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ||
|
||||
return (((sources & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) ||
|
||||
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
|
||||
((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
);
|
||||
@@ -118,6 +109,7 @@ public class SDLControllerManager
|
||||
|
||||
}
|
||||
|
||||
/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
|
||||
class SDLJoystickHandler {
|
||||
|
||||
/**
|
||||
@@ -137,7 +129,7 @@ class SDLJoystickHandler {
|
||||
}
|
||||
|
||||
/* Actual joystick functionality available for API >= 12 devices */
|
||||
class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
class SDLJoystickHandler_API12 extends SDLJoystickHandler {
|
||||
|
||||
static class SDLJoystick {
|
||||
public int device_id;
|
||||
@@ -149,27 +141,13 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
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;
|
||||
return arg0.getAxis() - arg1.getAxis();
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<SDLJoystick> mJoysticks;
|
||||
|
||||
public SDLJoystickHandler_API16() {
|
||||
public SDLJoystickHandler_API12() {
|
||||
|
||||
mJoysticks = new ArrayList<SDLJoystick>();
|
||||
}
|
||||
@@ -177,7 +155,12 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
@Override
|
||||
public void pollInputDevices() {
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
for(int i=0; i < deviceIds.length; ++i) {
|
||||
// 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--) {
|
||||
SDLJoystick joystick = getJoystick(deviceIds[i]);
|
||||
if (joystick == null) {
|
||||
joystick = new SDLJoystick();
|
||||
@@ -204,7 +187,8 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
}
|
||||
|
||||
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);
|
||||
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, 0, -1,
|
||||
joystick.axes.size(), joystick.hats.size()/2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,6 +256,15 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getJoystickDescriptor(InputDevice joystickDevice) {
|
||||
return joystickDevice.getName();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SDLJoystickHandler_API16 extends SDLJoystickHandler_API12 {
|
||||
|
||||
@Override
|
||||
public String getJoystickDescriptor(InputDevice joystickDevice) {
|
||||
String desc = joystickDevice.getDescriptor();
|
||||
|
||||
@@ -279,154 +272,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
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);
|
||||
}
|
||||
}
|
||||
return super.getJoystickDescriptor(joystickDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,27 +285,20 @@ class SDLHapticHandler {
|
||||
}
|
||||
|
||||
private ArrayList<SDLHaptic> mHaptics;
|
||||
|
||||
|
||||
public SDLHapticHandler() {
|
||||
mHaptics = new ArrayList<SDLHaptic>();
|
||||
}
|
||||
|
||||
public void run(int device_id, float intensity, int length) {
|
||||
public void run(int device_id, 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();
|
||||
haptic.vib.vibrate (length);
|
||||
}
|
||||
}
|
||||
|
||||
public void pollHapticDevices() {
|
||||
|
||||
|
||||
final int deviceId_VIBRATOR_SERVICE = 999999;
|
||||
boolean hasVibratorService = false;
|
||||
|
||||
@@ -469,18 +308,21 @@ class SDLHapticHandler {
|
||||
// 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);
|
||||
if (Build.VERSION.SDK_INT >= 16)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -488,7 +330,11 @@ class SDLHapticHandler {
|
||||
/* Check VIBRATOR_SERVICE */
|
||||
Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vib != null) {
|
||||
hasVibratorService = vib.hasVibrator();
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
hasVibratorService = vib.hasVibrator();
|
||||
} else {
|
||||
hasVibratorService = true;
|
||||
}
|
||||
|
||||
if (hasVibratorService) {
|
||||
SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE);
|
||||
@@ -496,7 +342,7 @@ class SDLHapticHandler {
|
||||
haptic = new SDLHaptic();
|
||||
haptic.device_id = deviceId_VIBRATOR_SERVICE;
|
||||
haptic.name = "VIBRATOR_SERVICE";
|
||||
haptic.vib = vib;
|
||||
haptic.vib = vib;
|
||||
mHaptics.add(haptic);
|
||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||
}
|
||||
@@ -538,7 +384,7 @@ class SDLHapticHandler {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
@@ -555,19 +401,22 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
if (!SDLActivity.mSeparateMouseAndTouch) {
|
||||
break;
|
||||
}
|
||||
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);
|
||||
SDLActivity.onNativeMouse(0, action, x, y);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
SDLActivity.onNativeMouse(0, action, x, y);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -582,207 +431,5 @@ class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@
|
||||
android:src="@drawable/splash"/>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
||||
</layer-list>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Instalando información de juego…</string>
|
||||
<string name="upgradeTitle">Actualizando información de juego…</string>
|
||||
<string name="helpTitle">Ayuda y Controles</string>
|
||||
<string name="helpMessage">\"Deslizar\" para moverse (si tenés apretado aparece el joystick virtual). \"Click\" para confirmar la selección en el menú o Pausar un turno en el juego (mantené apretado para Pausar varios turnos). \"Doble click\" para cancelar o volver en el menú (funciona como la tecla Escape). \"Pellizcar\" para hacer zoom (en el juego). Usá el botón físico \"Volver\" para activar el teclado virtual (mantené apretado para los atajos de teclado).</string>
|
||||
<string name="softwareRendering">Render por software</string>
|
||||
<string name="forceFullscreen">Forzar pantalla completa</string>
|
||||
<string name="trapBackButton">Fijar botón Volver</string>
|
||||
<string name="settings">Configuración</string>
|
||||
<string name="startGame">Empezar juego</string>
|
||||
<string name="showHelp">Mostrar ayuda</string>
|
||||
<string name="crashAlert">El juego no fue cerrado correctamente la última vez</string>
|
||||
<string name="crashMessage">El registro del error localizado en ./config/crash.log puede ayudar a los desarrolladores a solucionar errores.</string>
|
||||
</resources>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Instalando los datos del juego...</string>
|
||||
<string name="upgradeTitle">Actualizando los datos del juego...</string>
|
||||
<string name="helpTitle">Ayuda & Controles</string>
|
||||
<string name="helpMessage">\"Deslizar\" para el movimiento direccional (mantenlo presionado para el joystick virtual). \"Toque\" para confirmar la selección en el menú o Pausar un turno en-juego (mantenlo presionado para varios turnos en-juego). \"Toque doble\" para cancelar o ir hacia atrás en los menús (funciona como la tecla Escape). \"Pellizcar\" para zoom dentro/fuera (en-juego). Usa el botón \"Atrás\" físico para mostrar/ocultar el teclado virtual (mantenlo pulsado para alternar los atajos de teclado).</string>
|
||||
<string name="softwareRendering">Render por software</string>
|
||||
<string name="forceFullscreen">Forzar pantalla completa</string>
|
||||
<string name="trapBackButton">Capturar Botón de atrás</string>
|
||||
<string name="settings">Opciones</string>
|
||||
<string name="startGame">Comenzar el juego</string>
|
||||
<string name="showHelp">Mostrar ayuda</string>
|
||||
<string name="crashAlert">El juego no finalizó correctamente la última vez</string>
|
||||
<string name="crashMessage">El informe de fallos que se encuentra en ./config/crash.log puede ayudar a los desarrolladores a solucionar los errores del programa. </string>
|
||||
</resources>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">ゲームデータをインストール中...</string>
|
||||
<string name="upgradeTitle">ゲームデータをアップグレード中...</string>
|
||||
<string name="helpTitle">ヘルプ & 操作</string>
|
||||
<string name="helpMessage">特定方向にスワイプ(仮想ジョイスティックの場合は長押し)で移動。タップで選択項目の決定と1ターンその場で静止(長押しで数ターン静止)。ダブルタップでキャンセルとメニューに戻る(Escキー機能)。ピンチでズームイン/アウト(ゲーム内画面)。戻るボタンで仮想キーボード切替(長押しでキーボードショートカット切替)。</string>
|
||||
<string name="softwareRendering">ソフトウェアレンダリング</string>
|
||||
<string name="forceFullscreen">強制フルスクリーン</string>
|
||||
<string name="trapBackButton">戻るボタン例外処理</string>
|
||||
<string name="settings">設定</string>
|
||||
<string name="startGame">ゲーム開始</string>
|
||||
<string name="showHelp">ヘルプ表示</string>
|
||||
<string name="crashAlert">前回のプレイ時にゲームが正常に終了しませんでした</string>
|
||||
<string name="crashMessage">configフォルダ内のcrash.logに記録されるクラッシュレポートは、開発者がプログラムエラーを解決する役に立つ場合があります。</string>
|
||||
</resources>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Instalowanie danych gry...</string>
|
||||
<string name="upgradeTitle">Aktualizowanie danych gry...</string>
|
||||
<string name="helpTitle">Pomoc & sterowanie</string>
|
||||
<string name="helpMessage">"Przesuń" by sterować w boku (przytrzymaj do wirtualnego joysticka). "Stuknij" by potwierdzić wybór w menu albo spauzować jedną turę w grze (trzymaj by spauzować kilka tur w grze). "Stuknij dwa razy" by anulować albo wrócić do menu (działa jak przycisk Escape). "Szczypnij" by zbliżyć/oddalić (w grze). Użyj fizycznego przycisku "wstecz" by włączyć wirtualną klawiaturę (przytrzymaj by przełączyć skróty klawiszowe).</string>
|
||||
<string name="softwareRendering">Renderowanie programowe</string>
|
||||
<string name="forceFullscreen">Wymuś pełny ekran</string>
|
||||
<string name="trapBackButton">Zablokuj przycisk wstecz</string>
|
||||
<string name="settings">Ustawienia</string>
|
||||
<string name="startGame">Zacznij grę</string>
|
||||
<string name="showHelp">Pokaż pomoc</string>
|
||||
<string name="crashAlert">Gra nie zamknęła się poprawnie ostatnim razem</string>
|
||||
<string name="crashMessage">Raport crashu zlokalizowany w ./config/crash.log może pomóc twórcom naprawić błędy programu.</string>
|
||||
</resources>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Установка игровых данных...</string>
|
||||
<string name="upgradeTitle">Обновление игровых данных...</string>
|
||||
<string name="helpTitle">Помощь и управление</string>
|
||||
<string name="helpMessage">Свайп для движения в выбранном направлении (зажать для показа виртуального джойстика). Одно нажатие для подтверждения выбора в меню или паузы на один ход (зажать для паузы на несколько ходов). Двойное нажатие для отмены или выхода из меню (работает как кнопка Escape). Растяните или сведите пальцы на экране для увеличения/уменьшения (в игре). Используйте кнопку \"Назад\" для показа виртуальной клавиатуры (зажмите для отображения «горячих клавиш»).</string>
|
||||
<string name="softwareRendering">Программный рендеринг</string>
|
||||
<string name="forceFullscreen">Полный экран</string>
|
||||
<string name="trapBackButton">Перехват функций кнопки «Назад»</string>
|
||||
<string name="settings">Настройки</string>
|
||||
<string name="startGame">Начать игру</string>
|
||||
<string name="showHelp">Показать подсказки</string>
|
||||
<string name="crashAlert">В прошлый раз игра завершилась некорректно</string>
|
||||
<string name="crashMessage">Отчёт об остановке приложения находится в папке ./config/crash.log. Он может помочь разработчикам устранить ошибки в игре.</string>
|
||||
</resources>
|
||||
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">正在解压游戏数据…</string>
|
||||
<string name="upgradeTitle">正在合并游戏数据…</string>
|
||||
<string name="helpTitle">游戏控制帮助</string>
|
||||
<string name="helpMessage">[屏幕上滑动]可定向移动([按住]可显示虚拟操纵杆,可在设置中选择关闭)。
|
||||
[轻触屏幕]可确认菜单中的选项\'或\'在游戏中等待一个回合([长按]可等待几个回合)。
|
||||
[双击屏幕]可取消当前操作\'或\'返回菜单(类似于Escape键)。
|
||||
游戏中[双指并拢手势]可放大/缩小视图当前分辨率(仅限开启贴图包状态下)。
|
||||
[点击系统后退键(手机上的小于号键,在菜单键旁边)]可切出虚拟键盘,按住直至弹窗出现可隐藏/显示下方快捷键栏。
|
||||
*设置中可绑定四个双指方向滑动快捷键;例双指向下滑动绑定键为\"i\",即可游戏内双指向下滑动打开物品栏。</string>
|
||||
<string name="softwareRendering">软件渲染
|
||||
(不可开启)</string>
|
||||
<string name="forceFullscreen">强制全屏
|
||||
(开启后不显示通知栏与虚拟键)</string>
|
||||
<string name="trapBackButton">限制返回
|
||||
(禁止返回按键退出APP)</string>
|
||||
<string name="settings">预设
|
||||
(进入游戏后请到 设置-图形 中修改终端宽高比)</string>
|
||||
<string name="startGame">载入游戏</string>
|
||||
<string name="showHelp">查看帮助</string>
|
||||
<string name="crashAlert">上一次游戏遇到错误异常退出</string>
|
||||
<string name="crashMessage">日志文件位于Android/data/CataclysmDDA/files/config/crash.log,可有助于开发者解决程序错误。</string>
|
||||
</resources>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">正在安裝遊戲資料...</string>
|
||||
<string name="upgradeTitle">正在更新遊戲資料...</string>
|
||||
<string name="helpTitle">幫助與控制</string>
|
||||
<string name="helpMessage">滑動屏幕移動遊戲角色或菜單選項。點擊屏幕確認選擇或在遊戲中休息一回合。雙擊屏幕取消菜單或回退。雙指縮放畫面遠近。點擊系統回退鍵打開虛擬鍵盤。</string>
|
||||
<string name="softwareRendering">軟件渲染</string>
|
||||
<string name="forceFullscreen">強制全屏</string>
|
||||
<string name="trapBackButton">捕捉返回鍵</string>
|
||||
<string name="settings">設定</string>
|
||||
<string name="startGame">開始遊戲</string>
|
||||
<string name="showHelp">顯示幫助</string>
|
||||
</resources>
|
||||
@@ -1,15 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="installTitle">Installing game data...</string>
|
||||
<string name="upgradeTitle">Upgrading game data...</string>
|
||||
<string name="helpTitle">Help & Controls</string>
|
||||
<string name="helpMessage">"Swipe" for directional movement (hold for virtual joystick). "Tap" to confirm selection in menu or Pause one turn in-game (hold to Pause several turns in-game). "Double tap" to cancel or go back in menus (works like Escape key). "Pinch" to zoom in/out (in-game). Use hardware "Back" button to toggle virtual keyboard (hold to toggle keyboard shortcuts).</string>
|
||||
<string name="softwareRendering">Software rendering</string>
|
||||
<string name="forceFullscreen">Force fullscreen</string>
|
||||
<string name="trapBackButton">Trap Back button</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="startGame">Start game</string>
|
||||
<string name="showHelp">Show help</string>
|
||||
<string name="crashAlert">The game did not quit properly last time</string>
|
||||
<string name="crashMessage">The crash report located in ./config/crash.log may help developers troubleshoot program errors.</string>
|
||||
<string name="app_name">Cataclysm DDA</string>
|
||||
<string name="installing">Installing game data...</string>
|
||||
<string name="upgrading">Upgrading game data...</string>
|
||||
</resources>
|
||||
|
||||
@@ -7,4 +7,4 @@
|
||||
<item name="android:colorBackground">@color/background_material_dark</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
</resources>
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||
classpath 'com.android.tools.build:gradle:3.1.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@@ -19,51 +19,3 @@ org.gradle.jvmargs=-Xmx1536m
|
||||
# This property controls the number of jobs sent by -j switch to ndk-build
|
||||
# You can override this from the command line by passing "-Pj=#"
|
||||
j=2
|
||||
|
||||
# This property controls whether build should be run with localization
|
||||
# You can override this from the command line by passing "-Plocalize=#"
|
||||
localize=true
|
||||
|
||||
# This property controls whether to build arm 32 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_arm_32=#"
|
||||
abi_arm_32=true
|
||||
|
||||
# This property controls whether to build arm 64 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_arm_64=#"
|
||||
abi_arm_64=true
|
||||
|
||||
# This property controls whether to build x86 32 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_x86_32=#"
|
||||
abi_x86_32=false
|
||||
|
||||
# This property controls whether to build x86 64 bit ABI
|
||||
# You can override this from the command line by passing "-Pabi_x86_64=#"
|
||||
abi_x86_64=false
|
||||
|
||||
# This property controls which dependencies file to use
|
||||
# You can override this from the command line by passing "-Pdeps=#"
|
||||
deps=./deps.zip
|
||||
|
||||
# This property controls which override version number to use
|
||||
# You can override this from the command line by passing "-Poverride_version=#"
|
||||
override_version=
|
||||
|
||||
# This property controls path where overridden version number header should be generated
|
||||
# You can override this from the command line by passing "-Pversion_header_path=#"
|
||||
version_header_path=./../src/version.h
|
||||
|
||||
# This property controls which compileSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_compileSdkVersion=#"
|
||||
override_compileSdkVersion=28
|
||||
|
||||
# This property controls which minSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_minSdkVersion=#"
|
||||
override_minSdkVersion=14
|
||||
|
||||
# This property controls which targetSdkVersion should be used
|
||||
# You can override this from the command line by passing "-Poverride_targetSdkVersion=#"
|
||||
override_targetSdkVersion=28
|
||||
|
||||
# This property controls which ndkBuildAppPlatform should be used
|
||||
# You can override this from the command line by passing "-Poverride_ndkBuildAppPlatform=#"
|
||||
override_ndkBuildAppPlatform=android-16
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
#Tue Aug 27 13:00:00 UTC 2019
|
||||
#Tue Aug 28 01:10:32 MDT 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
|
||||
Vendored
+90
-90
@@ -1,90 +1,90 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
src/advanced_inv.cpp
|
||||
src/character.cpp
|
||||
src/iexamine.cpp
|
||||
src/json.cpp
|
||||
src/npctalk.cpp
|
||||
src/player.cpp
|
||||
src/sdltiles.cpp
|
||||
src/ui.cpp
|
||||
src/veh_interact.cpp
|
||||
@@ -33,7 +33,7 @@ RUN apt-fast -qq install --no-install-recommends gettext
|
||||
RUN apt-fast -qq install --no-install-recommends libncurses5-dev libncursesw5-dev
|
||||
|
||||
# CDDA: libraries for tiles build
|
||||
RUN apt-fast -qq install --no-install-recommends libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev
|
||||
RUN apt-fast -qq install --no-install-recommends libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libfreetype6-dev lua5.2 liblua5.2-dev
|
||||
|
||||
# general packages for a much nicer time inside the container (we install psmisc for `killall`)
|
||||
RUN apt-fast -qq install --no-install-recommends tree watch tmux fish colormake vim emacs git silversearcher-ag lsof psmisc dstat
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user