Compare commits
13 Commits
0.F
..
0.8-branch
| Author | SHA1 | Date | |
|---|---|---|---|
| 333065db37 | |||
| 4eea0aa985 | |||
| 243cae9967 | |||
| 6604c00938 | |||
| 01a093753c | |||
| 3699eabdb8 | |||
| a0a9e1883d | |||
| de6ede66a4 | |||
| 19de1a3405 | |||
| d6a1720e20 | |||
| b8d850486b | |||
| 3cc4ccc726 | |||
| 02c9e39fde |
@@ -1,28 +0,0 @@
|
||||
version: '{branch}.{build}'
|
||||
image: Visual Studio 2019
|
||||
configuration: Release
|
||||
platform: x86
|
||||
shallow_clone: true
|
||||
clone_folder: C:\Projects\Cataclysm-DDA
|
||||
cache:
|
||||
- c:\tools\vcpkg\installed
|
||||
- c:\Users\appveyor\AppData\Local\vcpkg\
|
||||
install:
|
||||
- cmd: cd c:\tools\vcpkg\
|
||||
- cmd: git pull
|
||||
- cmd: bootstrap-vcpkg.bat -disableMetrics
|
||||
- cmd: vcpkg --triplet %PLATFORM%-windows-static install sdl2 sdl2-image sdl2-mixer[dynamic-load,libflac,mpg123,libmodplug,libvorbis] sdl2-ttf gettext --recurse
|
||||
build:
|
||||
project: /msvc-full-features/Cataclysm-vcpkg-static.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
only_commits:
|
||||
files:
|
||||
- '.appveyor.yml'
|
||||
- 'msvc-full-features/**'
|
||||
- 'src/**'
|
||||
- 'tests/**'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# These options are mirrored in .astylerc and doc/CODE_STYLE.txt
|
||||
|
||||
# "One True Brace Style"
|
||||
--style=1tbs
|
||||
|
||||
# Attach brackets to class and struct inline function definitions.
|
||||
--attach-inlines
|
||||
|
||||
# 4 spaces per indentation level and per tab stop
|
||||
--indent=spaces=4
|
||||
|
||||
# 'char *foo' instead of 'char* foo'
|
||||
--align-pointer=name
|
||||
|
||||
# maximum length for a single unbroken line
|
||||
--max-code-length=100
|
||||
|
||||
# 'foo ||\nbar' instead of 'foo\n|| bar'
|
||||
--break-after-logical
|
||||
|
||||
# indent 'public:' 'protected:' 'private:' deeper than 'class' or 'struct'
|
||||
--indent-classes
|
||||
|
||||
# indent 'case' lines deeper than 'switch'
|
||||
--indent-switches
|
||||
|
||||
# indent later lines of multi-line preprocessor directives
|
||||
# to be deprecated by --indent-preproc-define
|
||||
--indent-preprocessor
|
||||
|
||||
# indent comments on column 1 to match the code block they are in
|
||||
--indent-col1-comments
|
||||
|
||||
# indent multi-line control block headers like 'if (foo\nbar)'
|
||||
--min-conditional-indent=0
|
||||
|
||||
# add space around operators with two operands
|
||||
--pad-oper
|
||||
|
||||
# add brackets to unbracketed one line conditional statements
|
||||
--add-brackets
|
||||
|
||||
# replaces tabs with spaces in non-indent sections, except in strings
|
||||
--convert-tabs
|
||||
|
||||
# remove extra space padding around parentheses
|
||||
--unpad-paren
|
||||
|
||||
# insert space padding around parentheses on the inside only
|
||||
--pad-paren-in
|
||||
|
||||
@@ -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,17 +0,0 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.json]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
@@ -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
|
||||
@@ -1,39 +0,0 @@
|
||||
# Automatically normalize line endings for all files
|
||||
# detected as text (Convert CRLF => LF).
|
||||
* text=auto
|
||||
|
||||
# Explicitly normalize files with these extensions in
|
||||
# case Git doesn't detect them as text for some reason.
|
||||
*.c text
|
||||
*.cbp text
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.json text
|
||||
*.md text
|
||||
*.py text
|
||||
*.rc text
|
||||
*.sh text
|
||||
*.txt text
|
||||
*.yml text
|
||||
|
||||
# Visual Studio project files, leave them alone.
|
||||
*.cmd -text
|
||||
*.filters -text
|
||||
*.sln -text
|
||||
*.user -text
|
||||
*.vcxproj -text
|
||||
|
||||
# Generated translation text, don't mess with them.
|
||||
*.mo -text
|
||||
*.po -text
|
||||
*.pot -text
|
||||
|
||||
# Treat images, archives, and font files as binary.
|
||||
# (binary is a macro for -text -diff)
|
||||
*.db binary
|
||||
*.fon binary
|
||||
*.gz binary
|
||||
*.ico binary
|
||||
*.png binary
|
||||
*.ttf binary
|
||||
|
||||
@@ -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
|
||||
@@ -1,325 +0,0 @@
|
||||
# Contribute
|
||||
|
||||
**Opening a new issue?** Please read [ISSUES.md](../ISSUES.md) first.
|
||||
|
||||
Contributing to Cataclysm: Dark Days Ahead is easy — simply fork the repository here on GitHub, make your changes, and then send us a pull request.
|
||||
|
||||
Cataclysm:Dark Days Ahead is released under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
|
||||
This means any contribution you make to the project will also be covered by the same license, and this license is irrevocable.
|
||||
|
||||
## Guidelines
|
||||
|
||||
There are a couple of guidelines we suggest sticking to:
|
||||
|
||||
* Add this repository as an `upstream` remote.
|
||||
* Keep your `master` branch clean. This means you can easily pull changes made to this repository into yours.
|
||||
* Create a new branch for each new feature or set of related bug fixes.
|
||||
* Never merge from your local branches into your `master` branch. Only update that by pulling from `upstream/master`.
|
||||
|
||||
## Code Style
|
||||
|
||||
Code style is enforced across the codebase by `astyle`.
|
||||
See [CODE_STYLE](../doc/CODE_STYLE.md) for details.
|
||||
|
||||
## Translations
|
||||
|
||||
The translation of Cataclysm: DDA is done using Transifex.
|
||||
Look at the [translation project](https://www.transifex.com/cataclysm-dda-translators/cataclysm-dda/) for an up-to-date list of supported languages.
|
||||
|
||||
See [TRANSLATING](../doc/TRANSLATING.md) for more information:
|
||||
|
||||
* [For translators](../doc/TRANSLATING.md#translators)
|
||||
* [For developers](../doc/TRANSLATING.md#developers)
|
||||
* [For maintainers](../doc/TRANSLATING.md#maintainers)
|
||||
|
||||
## Doxygen Comments
|
||||
|
||||
Extensive documentation of classes and class members will make the code more readable to new contributors. New doxygen comments for existing classes are a welcomed contribution.
|
||||
|
||||
Use the following template for commenting classes:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
*/
|
||||
class foo {
|
||||
```
|
||||
|
||||
Use the following template for commenting functions:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
* @param param1 Description of param1 (optional)
|
||||
* @return Description of return (optional)
|
||||
*/
|
||||
int foo(int param1);
|
||||
```
|
||||
|
||||
Use the following template for commenting member variables:
|
||||
```c++
|
||||
/** Brief description **/
|
||||
int foo;
|
||||
```
|
||||
|
||||
Helpful pages:
|
||||
* [Doxygen Manual - Special Commands](https://www.doxygen.nl/manual/commands.html)
|
||||
* [Doxygen Manual - Standard Markdown](https://www.doxygen.nl/manual/markdown.html#markdown_std)
|
||||
* [Doxygen Manual - Frequently Asked Questions](https://www.doxygen.nl/manual/faq.html)
|
||||
|
||||
### Guidelines for adding documentation
|
||||
* Doxygen comments should describe behavior towards the outside, not implementation, but since many classes in Cataclysm are intertwined, it's often necessary to describe implementation.
|
||||
* Describe things that aren't obvious to newcomers just from the name.
|
||||
* Don't describe redundantly: `/** Map **/; map* map;` is not a helpful comment.
|
||||
* When documenting X, describe how X interacts with other components, not just what X itself does.
|
||||
|
||||
### Building the documentation for viewing it locally
|
||||
* Install doxygen
|
||||
* `doxygen doxygen_doc/doxygen_conf.txt `
|
||||
* `firefox doxygen_doc/html/index.html` (replace firefox with your browser of choice)
|
||||
|
||||
## Example Workflow
|
||||
|
||||
#### Setup your environment
|
||||
|
||||
*(This only needs to be done once.)*
|
||||
|
||||
1. Fork this repository here on GitHub.
|
||||
|
||||
2. Clone your fork locally.
|
||||
|
||||
$ git clone https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
# Clones your fork of the repository into the current directory in terminal
|
||||
|
||||
3. Set commit message template.
|
||||
|
||||
$ git config --local commit.template .gitmessage
|
||||
|
||||
4. Add this repository as a remote.
|
||||
|
||||
$ cd Cataclysm-DDA
|
||||
# Changes the active directory in the prompt to the newly cloned "Cataclysm-DDA" directory
|
||||
$ git remote add -f upstream https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
# Assigns the original repository to a remote called "upstream"
|
||||
|
||||
For further details about commit message guidelines please visit:
|
||||
- [codeinthehole.com](https://codeinthehole.com/tips/a-useful-template-for-commit-messages/)
|
||||
- [chris.beams.io](https://chris.beams.io/posts/git-commit/)
|
||||
- [help.github.com](https://help.github.com/articles/closing-issues-using-keywords/)
|
||||
|
||||
#### Update your `master` branch
|
||||
|
||||
1. Make sure you have your `master` branch checked out.
|
||||
|
||||
$ git checkout master
|
||||
|
||||
2. Pull the changes from the `upstream/master` branch.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from "master" branch on the "upstream" remote
|
||||
|
||||
* Note: If this gives you an error, it means you have committed directly to your local `master` branch. [Click here for instructions on how to fix this issue](#why-does-git-pull---ff-only-result-in-an-error).
|
||||
|
||||
$ git push origin master
|
||||
# optionally, push the synced master state to your fork
|
||||
|
||||
#### Make your changes
|
||||
|
||||
0. Update your `master` branch, if you haven't already.
|
||||
|
||||
1. For each new feature or bug fix, create a new branch.
|
||||
|
||||
$ git branch new_feature
|
||||
# Creates a new branch called "new_feature"
|
||||
$ git checkout new_feature
|
||||
# Makes "new_feature" the active branch
|
||||
|
||||
2. Once you've committed some changes locally, you need to push them to your fork here on GitHub.
|
||||
|
||||
$ git push origin new_feature
|
||||
# origin was automatically set to point to your fork when you cloned it
|
||||
|
||||
3. Once you're finished working on your branch, and have committed and pushed all your changes, submit a pull request from your `new_feature` branch to this repository's `master` branch.
|
||||
|
||||
* Note: any new commits to the `new_feature` branch on GitHub will automatically be included in the pull request, so make sure to only commit related changes to the same branch.
|
||||
|
||||
## Drafts
|
||||
If you file a PR but you're still working on it, please make it a [Draft](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork).
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
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 categories to choose from are: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N.
|
||||
|
||||
Example:
|
||||
```
|
||||
#### Summary
|
||||
Content "Adds new mutation category 'Mouse'"
|
||||
```
|
||||
Or, if you want it treated as a minor tweak that doesn't appear in the changelog:
|
||||
```
|
||||
#### Summary
|
||||
None
|
||||
```
|
||||
|
||||
See [the Changelog Guidelines](../doc/CHANGELOG_GUIDELINES.md) for explanations of the categories.
|
||||
|
||||
### Closing issues using keywords
|
||||
|
||||
One more thing: when marking your PR as closing, fixing, or resolving issues, please include "XXXX #???" somewhere in the description, where XXX is on this list:
|
||||
* close
|
||||
* closes
|
||||
* closed
|
||||
* fix
|
||||
* fixes
|
||||
* fixed
|
||||
* resolve
|
||||
* resolves
|
||||
* resolved
|
||||
|
||||
The "???" is the issue number. This automatically closes the issue when the PR is pulled in, and allows merges to work slightly faster. To close multiple issues format it as "XXXX #???, XXXX#???".
|
||||
|
||||
See https://help.github.com/articles/closing-issues-using-keywords/ for more.
|
||||
|
||||
## Keep your PR description relevant
|
||||
|
||||
Make sure your PR description is still relevant every time you change your branch after discussion or additional thought.
|
||||
|
||||
## Tooling support
|
||||
|
||||
Various tools are available to help you keep your contributions conforming to the appropriate style. See [the relevant docs](../doc/DEVELOPER_TOOLING.md) for more details.
|
||||
|
||||
## Advanced Techniques
|
||||
|
||||
These guidelines aren't essential, but they can make keeping things in order much easier.
|
||||
|
||||
#### Using remote tracking branches
|
||||
|
||||
Remote tracking branches allow you to easily stay in touch with this repository's `master` branch, as they automatically know which remote branch to get changes from.
|
||||
|
||||
$ git branch -vv
|
||||
* master xxxx [origin/master] ....
|
||||
new_feature xxxx ....
|
||||
|
||||
Here you can see we have two branches; `master` which is tracking `origin/master`, and `new_feature` which isn't tracking any branch. In practice, what this means is that git won't know where to get changes from.
|
||||
|
||||
$ git checkout new_feature
|
||||
Switched to branch 'new_feature'
|
||||
$ git pull
|
||||
There is no tracking information for the current branch.
|
||||
Please specify which branch you want to merge with.
|
||||
|
||||
In order to easily pull changes from `upstream/master` into the `new_feature` branch, we can tell git which branch it should track. (You can even do this for your local master branch.)
|
||||
|
||||
$ git branch -u upstream/master new_feature
|
||||
Branch new_feature set up to track remote branch master from upstream.
|
||||
$ git pull
|
||||
Updating xxxx..xxxx
|
||||
....
|
||||
|
||||
You can also set the tracking information at the same time as creating the branch.
|
||||
|
||||
$ git branch new_feature_2 --track upstream/master
|
||||
Branch new_feature_2 set up to track remote branch master from upstream.
|
||||
|
||||
* Note: Although this makes it easier to pull from `upstream/master`, it doesn't change anything with regards to pushing. `git push` fails because you don't have permission to push to `upstream/master`.
|
||||
|
||||
$ git push
|
||||
error: The requested URL returned error: 403 while accessing https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
fatal: HTTP request failed
|
||||
$ git push origin
|
||||
....
|
||||
To https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
xxxx..xxxx new_feature -> new_feature
|
||||
|
||||
## Unit tests
|
||||
|
||||
There is a suite of tests built into the source tree at tests/
|
||||
You should run the test suite after ANY change to the game source.
|
||||
An ordinary invocation of `make` will build the test executable at tests/cata_test, and it can be invoked like any ordinary executable, or via `make check`.
|
||||
Running `test/cata_test` with no arguments will run the entire test suite; running it with `--help` will print a number of invocation options you can use to adjust its operation.
|
||||
|
||||
$ make
|
||||
... compilation details ...
|
||||
$ tests/cata_test
|
||||
Starting the actual test at Fri Nov 9 04:37:03 2018
|
||||
===============================================================================
|
||||
All tests passed (1324684 assertions in 94 test cases)
|
||||
Ended test at Fri Nov 9 04:37:45 2018
|
||||
The test took 41.772 seconds
|
||||
|
||||
I recommend habitually invoking make like ``make YOUR BUILD OPTIONS && make check``.
|
||||
|
||||
If you're working with Visual Studio (and don't have `make`), see [Visual Studio-specific advice](../doc/COMPILING/COMPILING-VS-VCPKG.md#running-unit-tests).
|
||||
|
||||
If you want/need to add a test, see [TESTING.md](../doc/TESTING.md)
|
||||
|
||||
## In-game testing, test environment and the debug menu
|
||||
|
||||
Whether you are implementing a new feature or whether you are fixing a bug, it is always a good practice to test your changes in-game. It can be a hard task to create the exact conditions by playing a normal game to be able to test your changes, which is why there is a debug menu. There is no default key to bring up the menu so you will need to assign one first.
|
||||
|
||||
Bring up the keybindings menu (press `Escape` then `1`), scroll down almost to the bottom and press `+` to add a new key binding. Press the letter that corresponds to the *Debug menu* item, then press the key you want to use to bring up the debug menu. To test your changes, create a new world with a new character. Once you are in that world, press the key you just assigned for the debug menu and you should see something like this:
|
||||
|
||||
```
|
||||
┌───────────────────────────────────────────────────────────────────────────┐
|
||||
│ Debug Functions - Using these will cheat not only the game, but yourself. │
|
||||
├───────────────────────────────────────────────────────────────────────────┤
|
||||
│ i Info │
|
||||
│ Q Quit to main menu │
|
||||
│ s Spawning… │
|
||||
│ p Player… │
|
||||
│ t Teleport… │
|
||||
│ m Map… │
|
||||
└───────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
With these commands, you should be able to recreate the proper conditions to test your changes. You can find some more information about the debug menu on [the official wiki](http://cddawiki.chezzo.com/cdda_wiki/index.php).
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
#### Why does `git pull --ff-only` result in an error?
|
||||
|
||||
If `git pull --ff-only` shows an error, it means that you've committed directly to your local `master` branch. To fix this, we create a new branch with these commits, find the point at which we diverged from `upstream/master`, and then reset `master` to that point.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
From https://github.com/CleverRaven/Cataclysm-DDA
|
||||
* branch master -> FETCH_HEAD
|
||||
fatal: Not possible to fast-forward, aborting.
|
||||
$ git branch new_branch master # mark the current commit with a tmp branch
|
||||
$ git merge-base master upstream/master
|
||||
cc31d0... # the last commit before we committed directly to master
|
||||
$ git reset --hard cc31d0....
|
||||
HEAD is now at cc31d0... ...
|
||||
|
||||
Now that `master` has been cleaned up, we can easily pull from `upstream/master`, and then continue working on `new_branch`.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from the "upstream" remote for the matching branch, in this case "master"
|
||||
$ git checkout new_branch
|
||||
|
||||
For more frequently asked questions, see the [developer FAQ](../doc/DEVELOPER_FAQ.md).
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
|
||||
---
|
||||
<!-- Please follow the template below -->
|
||||
|
||||
# Describe the bug
|
||||
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
|
||||
# Steps To Reproduce
|
||||
|
||||
<!-- Steps to reproduce the behavior:
|
||||
1. Make a player with a gun, magazine, and some ammo.
|
||||
2. Try to aim at a wall.
|
||||
3. There's no way to increase aim level. -->
|
||||
|
||||
|
||||
# Expected behavior
|
||||
|
||||
<!-- A clear and concise description of what you expected to happen.
|
||||
Ideally also describe *why* you expect it to happen. -->
|
||||
|
||||
|
||||
# Screenshots
|
||||
|
||||
<!-- **If applicable**, add screenshots to help explain your problem.
|
||||
|
||||
Do not take a screenshot of the crashing window. Please provide the crash logs in the "Additional context" -->
|
||||
|
||||
# Versions and configuration
|
||||
|
||||
<!-- Please complete the following information; you can now go to:
|
||||
- "Main menu (ESC) > Debug Menu > Info > Generate game report" to generate this report.
|
||||
- Please update your OS version with a more precise version.
|
||||
|
||||
- OS: [e.g. iOS 8 or Windows 10 or Ubuntu 18.04]
|
||||
- Game Version: [from the main menu, e.g. 0.C-29938-g90f5268437]
|
||||
- Graphics version: [Tiles or Terminal]
|
||||
- Ingame language: [Arabic or Bulgarian or Chinese (Simplified) or Chinese (Traditional) or Dutch or Esperanto or French or German or Italian (Italy) or Japanese or Korean or Polish or Portuguese (Brazil) or Russian or Serbian or Spanish (Argentina) or Spanish (Spain) or Turkish]
|
||||
- Mods loaded: [e.g.dda, boats, hacktheplanet, StatsThroughSkills]
|
||||
-->
|
||||
|
||||
# Additional context
|
||||
|
||||
<!-- Add any other context about the problem here.
|
||||
|
||||
Crash: if your problem refers to a crash, please add the following files to the "Additional Context" paragraph:
|
||||
- From the /config folder (you can zip them both together):
|
||||
- crash.log file.
|
||||
- debug.log file.
|
||||
- Your save file (zipped)
|
||||
|
||||
- note #1: you can drag and drop files in this issue post!
|
||||
- note #2: it is very important for us that you provide a save file in case of a crash. It really helps the developers
|
||||
to reproduce the bug and fix it. If possible, try to provide a save file that occurs in the right conditions, just
|
||||
before the crash happens. -->
|
||||
@@ -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.
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
|
||||
---
|
||||
|
||||
# Is your feature request related to a problem? Please describe.
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
# Describe the solution you'd like
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
# Describe alternatives you've considered
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
# Additional context
|
||||
Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature request here.
|
||||
@@ -1,33 +0,0 @@
|
||||
<!-- HOW TO USE: Under each "#### Heading" below, enter information relevant to your pull request.
|
||||
Leave the headings unless they don't apply to your PR, and remove the comment blocks (surrounded with <!–– and ––>) when you are done.
|
||||
NOTE: Please grant permission for repository maintainers to edit your PR. It is EXTREMELY common for PRs to be held up due to trivial changes being requested and the author being unavailable to make them. -->
|
||||
|
||||
#### Summary
|
||||
Category "Brief description"
|
||||
<!-- This section should consist of exactly one line, edit the one above.
|
||||
Category must be one of these: Features, Content, Interface, Mods, Balance, Bugfixes, Performance, Infrastructure, Build, I18N. Or replace the whole line with just the word None for no changelog entry.
|
||||
For more on the meaning of each category, see:
|
||||
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/CHANGELOG_GUIDELINES.md
|
||||
If approved and merged, your summary will be added to the project changelog:
|
||||
https://github.com/CleverRaven/Cataclysm-DDA/blob/master/data/changelog.txt -->
|
||||
|
||||
#### Purpose of change
|
||||
|
||||
<!-- With a few sentences, describe your reasons for making this change. If it relates to an existing issue, you can link it with a # followed by the GitHub issue number, like #1234. If your pull request *fully* resolves an issue, include the word "Fix" or "Fixes" before the issue number, like: Fixes #1234.
|
||||
If there is no related issue, explain here what issue, feature, or other concern you are addressing. If this is a bugfix, include steps to reproduce the original bug, so your fix can be verified. -->
|
||||
|
||||
#### Describe the solution
|
||||
|
||||
<!-- How does the feature work, or how does this fix a bug? The easier you make your solution to understand, the faster it can get merged. -->
|
||||
|
||||
#### Describe alternatives you've considered
|
||||
|
||||
<!-- Explain any alternative solutions, different approaches, or possibilities you've considered using to solve the same problem. -->
|
||||
|
||||
#### Testing
|
||||
|
||||
<!-- Describe what steps you took to test that this PR resolved the bug or added the feature, and what tests you performed to make sure it didn't cause any regressions. Also include testing suggestions for reviewers and maintainers. -->
|
||||
|
||||
#### Additional context
|
||||
|
||||
<!-- Add any other context (such as mock-ups, proof of concepts or screenshots) about the feature or bugfix here. -->
|
||||
@@ -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,63 +0,0 @@
|
||||
name: Clang Build Analyzer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '**.c'
|
||||
- '**/CMakeLists.txt'
|
||||
- '**/Makefile'
|
||||
- '**.hpp'
|
||||
- '**.cmake'
|
||||
- '.github/workflows/CBA.yml'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '**.cpp'
|
||||
- '**.h'
|
||||
- '**.c'
|
||||
- '**/CMakeLists.txt'
|
||||
- '**/Makefile'
|
||||
- '**.hpp'
|
||||
- '**.cmake'
|
||||
- '.github/workflows/CBA.yml'
|
||||
|
||||
|
||||
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++-10 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,70 +0,0 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, 0.8-branch, 0.9-branch, 0.A-branch, 0.B-branch, 0.C-branch, 0.D-branch, 0.E-branch, gh-pages ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '31 12 * * 6'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp', 'javascript', 'python' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
#- name: Autobuild
|
||||
# uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- run: |
|
||||
make RELEASE=1 RUNTESTS=0
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
@@ -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++-12
|
||||
os: ubuntu-latest
|
||||
cmake: 0
|
||||
tiles: 1
|
||||
sanitize: address,undefined
|
||||
native: linux64
|
||||
title: Clang 12, 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,247 +0,0 @@
|
||||
name: "Experimental Release"
|
||||
concurrency: release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
release:
|
||||
name: Create Release
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
timestamp: ${{ steps.get-timestamp.outputs.time }}
|
||||
release_already_exists: ${{ steps.tag_check.outputs.exists }}
|
||||
steps:
|
||||
- name: Get build timestamp
|
||||
id: get-timestamp
|
||||
uses: nanzm/get-time-action@v1.1
|
||||
with:
|
||||
timeZone: 0
|
||||
format: 'YYYY-MM-DD-HHmm'
|
||||
- name: Generate environmental variables
|
||||
id: generate_env_vars
|
||||
run: |
|
||||
echo "::set-output name=tag_name::cdda-experimental-${{ steps.get-timestamp.outputs.time }}"
|
||||
echo "::set-output name=release_name::Cataclysm-DDA experimental build ${{ steps.get-timestamp.outputs.time }}"
|
||||
- name: Check if there is existing git tag
|
||||
id: tag_check
|
||||
uses: mukunku/tag-exists-action@v1.0.0
|
||||
with:
|
||||
tag: ${{ steps.generate_env_vars.outputs.tag_name }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/checkout@v2
|
||||
- name: Push tag
|
||||
id: tag_version
|
||||
uses: mathieudutour/github-tag-action@v5.5
|
||||
if: ${{ steps.tag_check.outputs.exists == 'false' }}
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
custom_tag: ${{ steps.generate_env_vars.outputs.tag_name }}
|
||||
tag_prefix: ""
|
||||
- name: Create release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
if: ${{ steps.tag_check.outputs.exists == 'false' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.generate_env_vars.outputs.tag_name }}
|
||||
release_name: ${{ steps.generate_env_vars.outputs.release_name }}
|
||||
body: |
|
||||
These are the outputs for the experimental build of commit [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
|
||||
draft: false
|
||||
prerelease: true
|
||||
builds:
|
||||
needs: release
|
||||
if: ${{ needs.release.outputs.release_already_exists == 'false' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- name: Windows Tiles x64
|
||||
mxe: x86_64
|
||||
artifact: windows-tiles-x64
|
||||
os: ubuntu-latest
|
||||
ext: zip
|
||||
content: application/zip
|
||||
- name: Windows Tiles x32
|
||||
mxe: i686
|
||||
artifact: windows-tiles-x32
|
||||
os: ubuntu-latest
|
||||
ext: zip
|
||||
content: application/zip
|
||||
- name: Linux Tiles x64
|
||||
os: ubuntu-18.04
|
||||
mxe: none
|
||||
android: none
|
||||
tiles: 1
|
||||
artifact: linux-tiles-x64
|
||||
ext: tar.gz
|
||||
content: application/gzip
|
||||
- name: linux-curses-x64
|
||||
os: ubuntu-18.04
|
||||
mxe: none
|
||||
android: none
|
||||
tiles: 0
|
||||
artifact: linux-curses-x64
|
||||
ext: tar.gz
|
||||
content: application/gzip
|
||||
- name: osx-curses-x64
|
||||
os: macos-10.15
|
||||
mxe: none
|
||||
tiles: 0
|
||||
artifact: osx-curses-x64
|
||||
ext: dmg
|
||||
content: application/x-apple-diskimage
|
||||
- name: osx-tiles-x64
|
||||
os: macos-10.15
|
||||
mxe: none
|
||||
tiles: 1
|
||||
artifact: osx-tiles-x64
|
||||
ext: dmg
|
||||
content: application/x-apple-diskimage
|
||||
- name: Android x64
|
||||
os: ubuntu-latest
|
||||
mxe: none
|
||||
android: arm64
|
||||
artifact: android-x64
|
||||
ext: apk
|
||||
content: application/apk
|
||||
- name: Android x32
|
||||
os: ubuntu-latest
|
||||
mxe: none
|
||||
android: arm32
|
||||
artifact: android-x32
|
||||
ext: apk
|
||||
content: application/apk
|
||||
- name: Android Bundle
|
||||
os: ubuntu-latest
|
||||
mxe: none
|
||||
android: bundle
|
||||
artifact: android-bundle
|
||||
ext: aab
|
||||
content: application/aap
|
||||
name: ${{ matrix.name }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install dependencies (windows)
|
||||
if: matrix.mxe != 'none'
|
||||
run: |
|
||||
sudo apt install astyle autoconf automake autopoint bash bison bzip2 cmake flex gettext git g++ gperf intltool \
|
||||
libffi-dev libgdk-pixbuf2.0-dev libtool libltdl-dev libssl-dev libxml-parser-perl lzip make mingw-w64 openssl \
|
||||
p7zip-full patch perl pkg-config python ruby scons sed unzip wget xz-utils g++-multilib libc6-dev-i386 libtool-bin
|
||||
- name: Install MXE
|
||||
if: matrix.mxe != 'none'
|
||||
run: |
|
||||
sudo apt install software-properties-common lsb-release
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9
|
||||
sudo add-apt-repository "deb [arch=amd64] https://pkg.mxe.cc/repos/apt `lsb_release -sc` main"
|
||||
sudo apt update
|
||||
sudo apt install mxe-{i686,x86-64}-w64-mingw32.static-{sdl2,sdl2-ttf,sdl2-image,sdl2-mixer,gettext}
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux' && matrix.mxe == 'none' && matrix.android == 'none'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install libncursesw5-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev \
|
||||
libsdl2-mixer-dev libpulse-dev ccache gettext parallel
|
||||
- name: Install dependencies (mac)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
HOMEBREW_NO_AUTO_UPDATE=yes HOMEBREW_NO_INSTALL_CLEANUP=yes brew install sdl2 sdl2_image sdl2_ttf sdl2_mixer gettext ccache parallel
|
||||
pip3 install dmgbuild==1.4.2 biplist
|
||||
- name: Build CDDA (linux)
|
||||
if: runner.os == 'Linux' && matrix.mxe == 'none' && matrix.android == 'none'
|
||||
run: |
|
||||
cat >VERSION.txt <<EOL
|
||||
build type: ${{ matrix.artifact }}
|
||||
build number: ${{ needs.release.outputs.timestamp }}
|
||||
commit sha: ${{ github.sha }}
|
||||
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
|
||||
EOL
|
||||
make -j$((`nproc`+0)) TILES=${{ matrix.tiles }} SOUND=${{ matrix.tiles }} RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 bindist
|
||||
mv cataclysmdda-0.F.tar.gz cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.tar.gz
|
||||
- name: Build CDDA (windows)
|
||||
if: matrix.mxe != 'none'
|
||||
env:
|
||||
PLATFORM: /usr/lib/mxe/usr/bin/${{ matrix.mxe }}-w64-mingw32.static-
|
||||
run: |
|
||||
cat >VERSION.txt <<EOL
|
||||
build type: ${{ matrix.artifact }}
|
||||
build number: ${{ needs.release.outputs.timestamp }}
|
||||
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.F.zip cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.zip
|
||||
- name: Build CDDA (osx)
|
||||
if: runner.os == 'macOS'
|
||||
env:
|
||||
USE_HOME_DIR: 1
|
||||
run: |
|
||||
cat >VERSION.txt <<EOL
|
||||
build type: ${{ matrix.artifact }}
|
||||
build number: ${{ needs.release.outputs.timestamp }}
|
||||
commit sha: ${{ github.sha }}
|
||||
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
|
||||
EOL
|
||||
make -j3 TILES=${{ matrix.tiles }} SOUND=${{ matrix.tiles }} RELEASE=1 LOCALIZE=1 LANGUAGES=all BACKTRACE=0 PCH=0 dmgdist
|
||||
mv Cataclysm.dmg cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.dmg
|
||||
- name: Set up JDK 8 (android)
|
||||
if: runner.os == 'Linux' && matrix.android != 'none' && matrix.mxe == 'none'
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
- name: Setup Build and Dependencies (android)
|
||||
if: runner.os == 'Linux' && matrix.android != 'none' && matrix.mxe == 'none'
|
||||
run: |
|
||||
cat >VERSION.txt <<EOL
|
||||
build type: ${{ matrix.artifact }}
|
||||
build number: ${{ needs.release.outputs.timestamp }}
|
||||
commit sha: ${{ github.sha }}
|
||||
commit url: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
|
||||
EOL
|
||||
sudo apt-get update
|
||||
sudo apt-get install gettext
|
||||
- name: Build CDDA (android)
|
||||
if: runner.os == 'Linux' && matrix.android != 'none' && matrix.mxe == 'none'
|
||||
working-directory: ./android
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE }}" > release.keystore.asc
|
||||
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSWORD }}" --batch release.keystore.asc > app/release.keystore
|
||||
echo "${{ secrets.KEYSTORE_PROPERTIES }}" > keystore.properties.asc
|
||||
gpg -d --passphrase "${{ secrets.KEYSTORE_PASSWORD }}" --batch keystore.properties.asc > keystore.properties
|
||||
export UPSTREAM_BUILD_NUMBER="$((11581 + ${{ github.run_number }}))"
|
||||
chmod +x gradlew
|
||||
if [ ${{ matrix.android }} = arm64 ]
|
||||
then
|
||||
./gradlew -Pj=$((`nproc`+0)) -Pabi_arm_32=false assembleExperimentalRelease
|
||||
mv ./app/build/outputs/apk/experimental/release/*.apk ../cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.apk
|
||||
elif [ ${{ matrix.android }} = arm32 ]
|
||||
then
|
||||
./gradlew -Pj=$((`nproc`+0)) -Pabi_arm_64=false assembleExperimentalRelease
|
||||
mv ./app/build/outputs/apk/experimental/release/*.apk ../cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.apk
|
||||
elif [ ${{ matrix.android }} = bundle ]
|
||||
then
|
||||
./gradlew -Pj=$((`nproc`+0)) bundleExperimentalRelease
|
||||
mv ./app/build/outputs/bundle/experimentalRelease/*.aab ../cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.aab
|
||||
fi
|
||||
- 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 }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }}
|
||||
asset_name: cdda-${{ matrix.artifact }}-${{ needs.release.outputs.timestamp }}.${{ matrix.ext }}
|
||||
asset_content_type: ${{ matrix.content }}
|
||||
- name: Trigger GitHub pages rebuild
|
||||
run: |
|
||||
curl --fail --request POST \
|
||||
--url https://api.github.com/repos/${{ github.repository }}/pages/builds \
|
||||
--header "Authorization: Bearer ${{ secrets.USER_TOKEN }}" \
|
||||
--header "Accept: application/vnd.github.v3+json"
|
||||
@@ -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
|
||||
@@ -1,206 +1,39 @@
|
||||
!src/chkjson
|
||||
*.7z
|
||||
*.a
|
||||
*.d
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.tmp
|
||||
*.zip
|
||||
/WinDepend/
|
||||
/bindist/
|
||||
/build/
|
||||
/build-start-time
|
||||
/cmake-build-debug/
|
||||
/config/
|
||||
/data/*.template
|
||||
/data/mods/user-default-mods.json
|
||||
/dep/
|
||||
/doxygen_doc/html/*
|
||||
/doxygen_doc/latex/*
|
||||
/font/
|
||||
/graveyard/
|
||||
/memorial/
|
||||
/mods/
|
||||
/obj/
|
||||
/objwin/
|
||||
/save/
|
||||
/src/version.h
|
||||
/sound/
|
||||
/templates/
|
||||
/tools/format/json_formatter.cgi
|
||||
cataclysm
|
||||
cataclysm-tiles
|
||||
data/*.template
|
||||
save/
|
||||
graveyard/
|
||||
memorial/
|
||||
obj/
|
||||
debug.log
|
||||
logg.txt
|
||||
bindist/
|
||||
cataclysmdda-*
|
||||
objwin/
|
||||
version.h
|
||||
CataclysmWin.cscope_file_list
|
||||
CataclysmWin.depend
|
||||
CataclysmWin.layout
|
||||
cata_test
|
||||
cata_test-tiles
|
||||
cataclysm
|
||||
cataclysm-tiles
|
||||
cataclysm-vcpkg
|
||||
cataclysmdda-*
|
||||
chkjson*
|
||||
debug.log
|
||||
logg.txt
|
||||
json_formatter
|
||||
*.exe
|
||||
*.dll
|
||||
|
||||
# Visual Studio files
|
||||
*.code-workspace
|
||||
*.exp
|
||||
*.ilk
|
||||
*.opensdf
|
||||
*.pdb
|
||||
*.lib
|
||||
*.sdf
|
||||
*.suo
|
||||
*.user
|
||||
*.vcxproj.filters
|
||||
.vs/
|
||||
.vscode/
|
||||
Debug*/
|
||||
*.sdf
|
||||
*.pdb
|
||||
*.ilk
|
||||
Release*/
|
||||
|
||||
# Distribution script results
|
||||
/msvc-full-features/distribution
|
||||
|
||||
# Visual Studio 2015
|
||||
/msvc-full-features/*db
|
||||
/msvc-full-features/ipch
|
||||
lnk*.tmp
|
||||
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*
|
||||
Debug*/
|
||||
*.opensdf
|
||||
|
||||
# Temporary and backup files
|
||||
*.bak
|
||||
*.cbTemp
|
||||
*.sw?
|
||||
*~
|
||||
\#*
|
||||
*.bak
|
||||
*.cbTemp
|
||||
*.swp
|
||||
gmon.out
|
||||
|
||||
# System Files
|
||||
.DS_Store
|
||||
._.DS_Store
|
||||
Thumbs.db
|
||||
cscope.*
|
||||
tags
|
||||
|
||||
# Generated translation source
|
||||
/lang/po/cataclysm-dda.pot
|
||||
/lang/po/en.po
|
||||
|
||||
# Compiled binary translations
|
||||
/lang/mo/
|
||||
|
||||
# Directory for translatable strings
|
||||
/lang/json/*
|
||||
!/lang/json/README
|
||||
|
||||
# Netbeans IDE folders
|
||||
nbproject/
|
||||
|
||||
# Python runtime files
|
||||
*.pyc
|
||||
|
||||
# vim files
|
||||
*.vim
|
||||
*.session
|
||||
.ycm_extra_conf.py
|
||||
.vimrc
|
||||
|
||||
# taskwarrior files
|
||||
*.task*
|
||||
|
||||
# GitEye files
|
||||
*.project
|
||||
|
||||
# vimdiff backup
|
||||
*.orig
|
||||
|
||||
# OSX
|
||||
Cataclysm.app
|
||||
build-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
|
||||
monfactions.txt
|
||||
|
||||
# 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
|
||||
|
||||
# coredumps
|
||||
*.core
|
||||
|
||||
# sublime-text workspace
|
||||
*.sublime-workspace
|
||||
|
||||
# cppcheck
|
||||
*cppcheck.xml
|
||||
*.cppcheck
|
||||
|
||||
# clang tooling
|
||||
compile_commands.json
|
||||
.clangd
|
||||
|
||||
# IDA database
|
||||
Cataclysm.i64
|
||||
Cataclysm.id*
|
||||
Cataclysm.til
|
||||
Cataclysm.nam
|
||||
|
||||
# Snapcraft build directories
|
||||
prime
|
||||
snap
|
||||
stage
|
||||
|
||||
# Snapcraft build file
|
||||
*.snap
|
||||
|
||||
# Eclipse IDE
|
||||
.cproject
|
||||
.settings/
|
||||
|
||||
# Apple Xcode IDE
|
||||
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
|
||||
.DS_Store
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# If this commit is applied, it will ....
|
||||
# |<-- Using around 50, Maximum 72 Characters -->|
|
||||
|
||||
# Explain why this change is being made
|
||||
# |<---- Limit Each Line to a Maximum Of 72 Characters ---->|
|
||||
|
||||
# Provide links or keys to any relevant tickets, articles or other resources
|
||||
# Example: fixes #1234, closes #2345, resolves #3456, references #4567
|
||||
@@ -1,3 +0,0 @@
|
||||
# Disable FIXME query, in DDA it is as likely to be a future feature as a bug.
|
||||
queries:
|
||||
- exclude: cpp/fixme-comment
|
||||
@@ -1,233 +1,11 @@
|
||||
# this file is HEAVILY influenced by https://github.com/boostorg/hana/blob/master/.travis.yml
|
||||
language: cpp
|
||||
compiler:
|
||||
- gcc
|
||||
|
||||
dist: xenial
|
||||
language: c++
|
||||
|
||||
cache: ccache
|
||||
script: make
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
|
||||
addons:
|
||||
# these apt sources will be referenced later (by using *name)
|
||||
apt:
|
||||
sources: &apt_sources
|
||||
- ubuntu-toolchain-r-test
|
||||
config:
|
||||
retries: true
|
||||
|
||||
compiler: gcc
|
||||
os: linux
|
||||
|
||||
# We have branch builds disabled globally to prevent double-builds of PRs.
|
||||
# This re-enables just the master branch.
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- development
|
||||
|
||||
# Overall strategy for what sorts of builds to include:
|
||||
# We want a build for each compiler and each platform.
|
||||
# For PRs, we lessen the "each compiler" requirement to just covering the newest
|
||||
# and oldest relevant version of each compiler.
|
||||
# We also want to ensure that each of the following tweaks are covered in at
|
||||
# least one PR build:
|
||||
# - TILES=1
|
||||
# - SOUND=1
|
||||
# - RELEASE=1
|
||||
# - CMAKE=1
|
||||
# - LOCALIZE=0
|
||||
# - Tests with important mods enabled (Magiclysm)
|
||||
# We try to minimize the number of builds subject to those constraints.
|
||||
#
|
||||
# The following used to be here but became too slow to run on Travis and have
|
||||
# been moved to GitHub Actions:
|
||||
# - A clang-tidy run
|
||||
# - SANITIZE=address,undefined
|
||||
|
||||
# To see what toolchains are available, consult the following:
|
||||
# https://github.com/travis-ci/apt-source-safelist/blob/master/ubuntu.json
|
||||
# https://launchpad.net/%7Eubuntu-toolchain-r/+archive/ubuntu/test/+index
|
||||
|
||||
jobs:
|
||||
include:
|
||||
# Initial test stage, if this fails everything else is canceled.
|
||||
- stage: Test
|
||||
# Clang is consistently the fastest to build, so use it for the initial test.
|
||||
env: CLANG=clang++-3.8 TEST_STAGE=1 CXXFLAGS="-Wno-error=unused-command-line-argument -D__extern_always_inline='extern __always_inline'"
|
||||
name: "Clang 3.8 Make build with curses and style check"
|
||||
compiler: clang
|
||||
addons: &clang38
|
||||
apt:
|
||||
packages: ["clang-3.8"]
|
||||
sources: [*apt_sources]
|
||||
|
||||
# Then build different configurations and targets in parallel.
|
||||
- stage: "Main Compilers"
|
||||
env: COMPILER=g++ MODS=--mods=magiclysm LOCALIZE=0
|
||||
name: "GCC 5.3 Make build with curses, Magiclysm, and no Localization"
|
||||
compiler: gcc
|
||||
addons: &gcc53
|
||||
apt:
|
||||
packages: ["g++-5=5.3.1-14ubuntu2", "libstdc++-5-dev=5.3.1-14ubuntu2", "gcc-5=5.3.1-14ubuntu2", "gcc-5-base=5.3.1-14ubuntu2", "cpp-5=5.3.1-14ubuntu2", "libgcc-5-dev=5.3.1-14ubuntu2", "libasan2=5.3.1-14ubuntu2", "libmpx0=5.3.1-14ubuntu2"]
|
||||
sources: [*apt_sources]
|
||||
|
||||
- env: COMPILER=g++-8 CXXFLAGS="-Wno-implicit-fallthrough" TILES=1 SOUND=1
|
||||
name: "GCC 8 Make build with Tiles, Sound"
|
||||
dist: bionic
|
||||
compiler: gcc
|
||||
addons: &gcc8
|
||||
apt:
|
||||
packages: ["g++-8", "g++-8-multilib", "libc6-dbg", "libc6-dbg:i386", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: CLANG=clang++-10
|
||||
name: "Clang 10 Make build"
|
||||
compiler: clang
|
||||
dist: bionic
|
||||
addons: &clang10
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
- stage: "Platforms and Tidy"
|
||||
# MXE variant using alternate repository http://mirror.mxe.cc/repos/apt
|
||||
env: COMPILER=g++ LDFLAGS="-static-libgcc -static-libstdc++" MXE_TARGET="i686-w64-mingw32.static" WINE="wine" TILES=1 SOUND=1
|
||||
name: "Mingw-w64 Make cross-compile to Windows with Tiles and Sound"
|
||||
compiler: gcc
|
||||
addons: &gcc
|
||||
apt:
|
||||
packages: ["wine"]
|
||||
|
||||
- env: NATIVE=android COMPILER=gcc
|
||||
name: "Android build"
|
||||
language: android
|
||||
android:
|
||||
components:
|
||||
- build-tools-28.0.1
|
||||
cache:
|
||||
# The ccache feature in Travis doesn't work for language: android, so
|
||||
# do it ourselves.
|
||||
directories:
|
||||
- $HOME/.ccache
|
||||
|
||||
- env: CLANG=clang++ OSX_MIN=10.13 TILES=1 SOUND=1
|
||||
name: "Xcode 10.2 Make build with Tiles and sound (macOS)"
|
||||
os: osx
|
||||
osx_image: xcode10.2
|
||||
compiler: clang
|
||||
|
||||
# Finally check the compiler variants
|
||||
- stage: compilers
|
||||
# GCC 5.4 is default on Xenial
|
||||
env: COMPILER=g++
|
||||
name: "GCC 5.4 Make build with Curses"
|
||||
if: type != pull_request
|
||||
|
||||
- env: COMPILER=g++-6 CODE_COVERAGE=true
|
||||
name: "GCC 6 Make build with Curses and Code Coverage"
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc6
|
||||
apt:
|
||||
packages: ["g++-6", "g++-6-multilib", "libc6-dbg", "libc6-dbg:i386"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: COMPILER=g++-7 CXXFLAGS='-Wno-implicit-fallthrough -D_GLIBCXX_DEBUG'
|
||||
name: "GCC 7 Make build with Curses and GLIBCXX_DEBUG"
|
||||
if: type != pull_request
|
||||
compiler: gcc
|
||||
addons: &gcc7
|
||||
apt:
|
||||
packages: ["g++-7", "g++-7-multilib", "libc6-dbg", "libc6-dbg:i386", "lcov"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: CLANG=clang++-3.9 CXXFLAGS='-Wno-error=unused-command-line-argument -D__extern_always_inline="extern __always_inline"'
|
||||
name: "Clang 3.9 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang39
|
||||
apt:
|
||||
packages: ["clang-3.9"]
|
||||
sources: *apt_sources
|
||||
|
||||
- env: CLANG=clang++-4.0 CXXFLAGS=-Wno-error=unused-command-line-argument
|
||||
name: "Clang 4 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang40
|
||||
apt:
|
||||
packages: ["clang-4.0"]
|
||||
# Luckily the Trusty install Just Works on Xenial
|
||||
sources: [*apt_sources, llvm-toolchain-trusty-4.0]
|
||||
|
||||
- env: CLANG=clang++-5.0 CXXFLAGS=-Wno-error=unused-command-line-argument
|
||||
name: "Clang 5 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang50
|
||||
apt:
|
||||
packages: ["clang-5.0"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-5.0]
|
||||
|
||||
- env: CLANG=clang++-6.0 TILES=1 SOUND=1 CXXFLAGS=-Wno-error=unused-command-line-argument CMAKE=1 RELEASE=1
|
||||
name: "Clang 6 CMake build with tiles and sound"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang60
|
||||
apt:
|
||||
packages: ["clang-6.0", "libsdl2-dev", "libsdl2-ttf-dev", "libsdl2-image-dev", "libsdl2-mixer-dev"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-6.0]
|
||||
|
||||
- env: CLANG=clang++-7
|
||||
name: "Clang 7 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang7
|
||||
apt:
|
||||
packages: ["clang-7"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-7]
|
||||
|
||||
- env: CLANG=clang++-8
|
||||
name: "Clang 8 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
addons: &clang8
|
||||
apt:
|
||||
packages: ["clang-8"]
|
||||
sources: [*apt_sources, llvm-toolchain-xenial-8]
|
||||
|
||||
- env: CLANG=clang++-9
|
||||
name: "Clang 9 Make build with Curses"
|
||||
if: type != pull_request
|
||||
compiler: clang
|
||||
dist: bionic
|
||||
addons: &clang9
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
sources:
|
||||
- sourceline: "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main"
|
||||
key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
|
||||
before_install:
|
||||
- if [ "${NATIVE}" == "android" ]; then yes | sdkmanager "platforms;android-28"; fi
|
||||
|
||||
before_script:
|
||||
- if [ -n "${CLANG}" ]; then COMPILER="$CLANG"; fi
|
||||
- ${COMPILER} --version
|
||||
- CXX="$COMPILER"
|
||||
- source build-scripts/requirements.sh
|
||||
|
||||
script:
|
||||
- build-scripts/build.sh
|
||||
|
||||
after_success:
|
||||
- if [ -n "${CODE_COVERAGE}" ]; then coveralls -b . -i src -e tests --gcov /usr/bin/gcov-6; fi
|
||||
- if [ -n "${CODE_COVERAGE}" ]; then bash <(curl -s https://codecov.io/bash); fi
|
||||
irc: "irc.newnet.net#Cataclysm-DDA"
|
||||
irc: "irc.freenode.org#Cataclysm-DDA"
|
||||
use_notice: true
|
||||
skip_join: true
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[cataclysm-dda.master-cataclysm-dda]
|
||||
file_filter = lang/po/<lang>.po
|
||||
minimum_perc = 0
|
||||
source_file = lang/po/cataclysm-dda.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
@@ -1,391 +1,89 @@
|
||||
cmake_minimum_required(VERSION 3.1.4)
|
||||
# WARNING: Only linux is currently supported by this cmake build file.
|
||||
|
||||
project(CataclysmDDA)
|
||||
# This file is used to build cataclysm with CMake.
|
||||
#
|
||||
# To use it, install cmake, then:
|
||||
#
|
||||
# cd cataclysm
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake -G "Unix Makefiles" -DLOCALIZE=ON -DSDL=OFF ..
|
||||
# make
|
||||
#
|
||||
# This will build and install cataclysm into the build directory.
|
||||
#
|
||||
# "Unix Makefiles" is a generator, you can get a list of supported generators
|
||||
# on your system by running "cmake" without any arguments.
|
||||
#
|
||||
# -DOPTION_NAME=ON/OFF enables/disables OPTION_NAME
|
||||
|
||||
set(CMAKE_MODULE_PATH
|
||||
${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
|
||||
|
||||
set(CMAKE_TLS_VERIFY ON)
|
||||
PROJECT(CataclysmDDA)
|
||||
|
||||
# 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(LOCALIZE "Toggle gettext localization/translation." ON)
|
||||
OPTION(SDL "Use SDL curses emulation instead of terminal support." OFF)
|
||||
OPTION(TILES "Enable tileset support." OFF)
|
||||
|
||||
include(CTest)
|
||||
# Note: The CMake documentation says it's better to list the actual source
|
||||
# files here, as otherwise cmake won't know to rerun when a new file
|
||||
# is added. However, currently the Makefile also just scans for source
|
||||
# files, so this approach should be "good enough".
|
||||
FILE(GLOB CataclysmDDA_SRCS *.cpp)
|
||||
FILE(GLOB CataclysmDDA_HDRS *.h)
|
||||
|
||||
message(STATUS "${PROJECT} build environment --")
|
||||
message(STATUS "Build realm is: ${CMAKE_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||
ADD_EXECUTABLE(cataclysm ${CataclysmDDA_SRCS} ${CataclysmDDA_HDRS})
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif ()
|
||||
# Custom command that will be executed whenever the "cataclysm" target is built.
|
||||
# Copy all the relevant game data into the build directory.
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET cataclysm PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data $<TARGET_FILE_DIR:cataclysm>/data
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/LICENSE $<TARGET_FILE_DIR:cataclysm> # Don't forget the license :)
|
||||
)
|
||||
|
||||
add_definitions(-DCMAKE)
|
||||
IF(MINGW)
|
||||
add_definitions("-D_WINDOWS -D_MINGW -D_WIN32 -DWIN32 -D__MINGW__")
|
||||
ENDIF()
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
git_describe(GIT_VERSION --tags --always --match "[0-9A-Z]*.[0-9A-Z]*")
|
||||
if (NOT ${GIT_VERSION} MATCHES GIT-NOTFOUND)
|
||||
string(REPLACE "-NOTFOUND" "" GIT_VERSION ${GIT_VERSION})
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/src/version.h
|
||||
"// NOLINT(cata-header-guard)\n\#define VERSION \"${GIT_VERSION}\"\n")
|
||||
message(STATUS "${PROJECT_NAME} build version is: ${GIT_VERSION}")
|
||||
add_definitions(-DGIT_VERSION)
|
||||
endif ()
|
||||
|
||||
#OS Check Placeholders. Will be used for BINDIST
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
|
||||
set(_OS_LINUX_ 1)
|
||||
endif ()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
set(_OS_FREEBSD_ 1)
|
||||
endif ()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
|
||||
set(_OS_DARWIN_ 1)
|
||||
add_definitions(-DMACOSX)
|
||||
if (${TILES})
|
||||
add_definitions(-DOSX_SDL2_LIBS)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
#FIXME: Add dest build choice: m32 for 32 bit or m64 for 64 bit version
|
||||
#add_definitions("-m32")
|
||||
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
#SET(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -m32")
|
||||
#SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -m32")
|
||||
|
||||
if (NOT DYNAMIC_LINKING)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.dll.a")
|
||||
set(BUILD_SHARED_LIBRARIES OFF)
|
||||
check_cxx_compiler_flag (-static HAVE_STATIC_FLAG)
|
||||
if (HAVE_STATIC_FLAG)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
|
||||
endif ()
|
||||
# Workaround for cmake link library guesser
|
||||
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
|
||||
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
||||
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
|
||||
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
|
||||
else ()
|
||||
if (MINGW AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Avoid depending on MinGW runtime DLLs
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# System specific actions
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Linux OR ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
|
||||
if (NOT DATA_PREFIX)
|
||||
set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX}/share/cataclysm-dda)
|
||||
endif ()
|
||||
if (NOT LOCALE_DIR)
|
||||
set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX}/share/locale)
|
||||
endif ()
|
||||
if (NOT BIN_PREFIX)
|
||||
set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
endif ()
|
||||
if (NOT DESKTOP_ENTRY_PATH)
|
||||
set(DESKTOP_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/applications)
|
||||
endif ()
|
||||
if (NOT PIXMAPS_ENTRY_PATH)
|
||||
set(PIXMAPS_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor)
|
||||
endif ()
|
||||
if (NOT PIXMAPS_UNITY_ENTRY_PATH)
|
||||
set(PIXMAPS_UNITY_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/icons/ubuntu-mono-dark)
|
||||
endif ()
|
||||
if (NOT MANPAGE_ENTRY_PATH)
|
||||
set(MANPAGE_ENTRY_PATH ${CMAKE_INSTALL_PREFIX}/share/man)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
if (NOT DATA_PREFIX)
|
||||
set(DATA_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
endif ()
|
||||
if (NOT LOCALE_DIR)
|
||||
set(LOCALE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
endif ()
|
||||
if (NOT BIN_PREFIX)
|
||||
set(BIN_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
message(STATUS "${PROJECT_NAME} build options --")
|
||||
|
||||
# Preset variables
|
||||
if (NOT LANGUAGES)
|
||||
# English is included to workaround a libintl bug that affects performance
|
||||
# on MinGW targets. See lang/CMakeList.txt for more information.
|
||||
set(LANGUAGES en de es_AR es_ES fr it_IT ja ko pt_BR ru zh_CN zh_TW)
|
||||
endif ()
|
||||
|
||||
if (GIT_BINARY)
|
||||
set(GIT_EXECUTABLE ${GIT_BINARY})
|
||||
else ()
|
||||
find_package(Git)
|
||||
if (NOT GIT_FOUND)
|
||||
message(WARNING
|
||||
"Git binary not found. Build version will be set to NULL. \
|
||||
Install Git package or use -DGIT_BINARY to set path to git binary.")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (PREFIX)
|
||||
add_definitions(-DPREFIX=${PREFIX})
|
||||
endif ()
|
||||
|
||||
# Can't compile curses and tiles build's at same time
|
||||
if (TILES)
|
||||
set(CURSES OFF)
|
||||
endif ()
|
||||
|
||||
# Set build types and display info
|
||||
if (CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
message(STATUS "Build ${PROJECT} in development mode --")
|
||||
message(STATUS "Binaries will be located in: " ${CMAKE_SOURCE_DIR})
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
# Since CataclysmDDA does not respect PREFIX for development builds
|
||||
# and has funny path handlers, we should create resulting Binaries
|
||||
# in the source directory
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} CACHE PATH
|
||||
"Single Directory for all Executables.")
|
||||
set(BIN_PREFIX ${CMAKE_SOURCE_DIR})
|
||||
else ()
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS "BIN_PREFIX : ${BIN_PREFIX}")
|
||||
message(STATUS "DATA_PREFIX : ${DATA_PREFIX}")
|
||||
if (LOCALIZE)
|
||||
message(STATUS "LOCALE_PATH : ${LOCALE_DIR}")
|
||||
endif ()
|
||||
message(STATUS "DESKTOP_ENTRY_PATH : ${DESKTOP_ENTRY_PATH}")
|
||||
message(STATUS "PIXMAPS_ENTRY_PATH : ${PIXMAPS_ENTRY_PATH}")
|
||||
message(STATUS "PIXMAPS_UNITY_ENTRY_PATH : ${PIXMAPS_UNITY_ENTRY_PATH}")
|
||||
message(STATUS "MANPAGE_ENTRY_PATH : ${MANPAGE_ENTRY_PATH}")
|
||||
add_definitions(-DRELEASE)
|
||||
# Use PREFIX as storage of data,gfx, etc.. Useful only on *nix OS.
|
||||
if (PREFIX AND NOT WIN32)
|
||||
add_definitions(-DDATA_DIR_PREFIX)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
message(STATUS "GIT_BINARY : ${GIT_EXECUTABLE}")
|
||||
message(STATUS "DYNAMIC_LINKING : ${DYNAMIC_LINKING}")
|
||||
message(STATUS "TILES : ${TILES}")
|
||||
message(STATUS "CURSES : ${CURSES}")
|
||||
message(STATUS "SOUND : ${SOUND}")
|
||||
message(STATUS "BACKTRACE : ${BACKTRACE}")
|
||||
message(STATUS "LOCALIZE : ${LOCALIZE}")
|
||||
message(STATUS "USE_HOME_DIR : ${USE_HOME_DIR}")
|
||||
message(STATUS "LANGUAGES : ${LANGUAGES}")
|
||||
message(STATUS "See doc/COMPILING/COMPILING-CMAKE.md for details and more info --")
|
||||
|
||||
if (MSVC)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_AMD64_)
|
||||
else ()
|
||||
add_definitions(-D_X86_)
|
||||
endif ()
|
||||
else (MSVC)
|
||||
set(CATA_WARNINGS
|
||||
"-Werror -Wall -Wextra \
|
||||
-Wformat-signedness \
|
||||
-Wlogical-op \
|
||||
-Wmissing-declarations \
|
||||
-Wmissing-noreturn \
|
||||
-Wnon-virtual-dtor \
|
||||
-Wold-style-cast \
|
||||
-Woverloaded-virtual \
|
||||
-Wpedantic \
|
||||
-Wsuggest-override \
|
||||
-Wunused-macros \
|
||||
-Wzero-as-null-pointer-constant \
|
||||
-Wno-unknown-warning-option")
|
||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
|
||||
set(CATA_WARNINGS "${CATA_WARNINGS} -Wredundant-decls")
|
||||
endif ()
|
||||
set(CATA_OTHER_FLAGS "${CATA_OTHER_FLAGS} -fsigned-char")
|
||||
# Compact the whitespace in the warning string
|
||||
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS} ${CATA_OTHER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
# Force out-of-source build
|
||||
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(FATAL_ERROR
|
||||
"This project requires an out of source build. \
|
||||
Remove the file 'CMakeCache.txt' found in this directory before continuing; \
|
||||
create a separate build directory and run 'cmake [options] <srcs>' from there. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
|
||||
#set(THREADS_USE_PTHREADS_WIN32 True)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD True)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
# Check for build types and libraries
|
||||
if (TILES)
|
||||
# Find SDL, SDL_ttf & SDL_image for graphical install
|
||||
message(STATUS "Searching for SDL2 library --")
|
||||
find_package(SDL2)
|
||||
if (NOT SDL2_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"This project requires SDL2 to be installed to compile in graphical mode. \
|
||||
Please install the SDL2 development libraries, \
|
||||
or try compiling without -DTILES=1 for a text-only compilation. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
|
||||
if (NOT DYNAMIC_LINKING)
|
||||
# SDL, SDL_Image, SDL_ttf deps are required for static build
|
||||
message(STATUS "Searching for SDL deps libraries --")
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(BZip2 REQUIRED)
|
||||
endif ()
|
||||
|
||||
message(STATUS "Searching for SDL2_TTF library --")
|
||||
find_package(SDL2_ttf)
|
||||
if (NOT SDL2_TTF_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"This project requires SDL2_ttf to be installed to compile in graphical mode. \
|
||||
Please install the SDL2_ttf development libraries, \
|
||||
or try compiling without -DTILES=1 for a text-only compilation. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Searching for SDL2_image library --")
|
||||
find_package(SDL2_image)
|
||||
if (NOT SDL2_IMAGE_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"This project requires SDL2_image to be installed to compile in graphical mode. \
|
||||
Please install the SDL2_image development libraries, \
|
||||
or try compiling without -DTILES=1 for a text-only compilation. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
add_definitions(-DTILES)
|
||||
endif ()
|
||||
|
||||
if (CURSES)
|
||||
# Find the ncurses library for a text based compile
|
||||
message(STATUS "Searching for Curses library --")
|
||||
set(CURSES_NEED_NCURSES TRUE)
|
||||
set(CURSES_NEED_WIDE TRUE)
|
||||
find_package(Curses)
|
||||
if (NOT CURSES_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"This project requires ncurses to be installed to be compiled in text-only mode. \
|
||||
Please install the ncurses development libraries, \
|
||||
or try compiling with -DTILES=1 for a graphical compilation. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (SOUND)
|
||||
# You need TILES to be able to use SOUND
|
||||
if (NOT TILES)
|
||||
message(FATAL_ERROR
|
||||
"You must enable graphical support with -DTILES=1 \
|
||||
to be able to enable sound support. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
|
||||
# Sound requires SDL_mixer library
|
||||
message(STATUS "Searching for SDL2_mixer library --")
|
||||
find_package(SDL2_mixer)
|
||||
if (NOT SDL2_MIXER_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"You need the SDL2_mixer development library \
|
||||
to be able to compile with sound enabled. \
|
||||
See doc/COMPILING/COMPILING-CMAKE.md for details and more info.")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (BACKTRACE)
|
||||
add_definitions(-DBACKTRACE)
|
||||
if (LIBBACKTRACE)
|
||||
add_definitions(-DLIBBACKTRACE)
|
||||
endif (LIBBACKTRACE)
|
||||
endif (BACKTRACE)
|
||||
|
||||
# Ok. Now create build and install recipes
|
||||
if (LOCALIZE)
|
||||
if (NOT _OS_LINUX_) # on Linux with glibc, libintl is not required
|
||||
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 ()
|
||||
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 ()
|
||||
add_subdirectory(lang)
|
||||
IF(LOCALIZE)
|
||||
add_definitions(-DLOCALIZE)
|
||||
endif ()
|
||||
#TARGET_LINK_LIBRARIES(cataclysm
|
||||
# intl
|
||||
#)
|
||||
ENDIF()
|
||||
|
||||
if (USE_HOME_DIR)
|
||||
add_definitions(-DUSE_HOME_DIR)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(data)
|
||||
if (NOT MSVC)
|
||||
add_subdirectory(src/chkjson)
|
||||
endif()
|
||||
add_subdirectory(tests)
|
||||
if (JSON_FORMAT)
|
||||
add_subdirectory(tools/format)
|
||||
endif()
|
||||
if (CATA_CLANG_TIDY_PLUGIN)
|
||||
add_subdirectory(tools/clang-tidy-plugin)
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
"${CMAKE_COMMAND}"
|
||||
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if (CCACHE_FOUND AND CATA_CCACHE)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
|
||||
endif ()
|
||||
# TODO: windows rc stuff
|
||||
|
||||
IF(SDL OR TILES)
|
||||
# CMake ships with a few helpful include's to find common libraries
|
||||
# like SDL
|
||||
Include(FindSDL)
|
||||
Include(FindSDL_ttf)
|
||||
|
||||
Find_Package(SDL REQUIRED)
|
||||
Find_Package(SDL_ttf REQUIRED)
|
||||
|
||||
TARGET_LINK_LIBRARIES(cataclysm ${SDL_LIBRARY} ${SDLTTF_LIBRARY})
|
||||
|
||||
IF(TILES)
|
||||
# Install GFX directory
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET cataclysm PRE_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/gfx $<TARGET_FILE_DIR:cataclysm>/gfx
|
||||
)
|
||||
|
||||
Include(FindSDL_image)
|
||||
TARGET_LINK_LIBRARIES(cataclysm ${SDLIMAGE_LIBRARY})
|
||||
ADD_DEFINITIONS(-DSDLTILES)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DTILES)
|
||||
ENDIF()
|
||||
|
||||
ELSEIF(MSVC OR MINGW)
|
||||
# On windows our default isn't curses, but rather GDI
|
||||
TARGET_LINK_LIBRARIES(cataclysm gdi32 intl iconv winmm)
|
||||
add_definitions(-Wl,-stack,12000000,-subsystem,windows)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(cataclysm curses)
|
||||
ENDIF()
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
#.rst:
|
||||
# CMakeParseArguments
|
||||
# -------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords>
|
||||
# <multi_value_keywords> args...)
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions
|
||||
# for parsing the arguments given to that macro or function. It
|
||||
# processes the arguments and defines a set of variables which hold the
|
||||
# values of the respective options.
|
||||
#
|
||||
# The <options> argument contains all options for the respective macro,
|
||||
# i.e. keywords which can be used when calling the macro without any
|
||||
# value following, like e.g. the OPTIONAL keyword of the install()
|
||||
# command.
|
||||
#
|
||||
# The <one_value_keywords> argument contains all keywords for this macro
|
||||
# which are followed by one value, like e.g. DESTINATION keyword of the
|
||||
# install() command.
|
||||
#
|
||||
# The <multi_value_keywords> argument contains all keywords for this
|
||||
# macro which can be followed by more than one value, like e.g. the
|
||||
# TARGETS or FILES keywords of the install() command.
|
||||
#
|
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
|
||||
# keywords listed in <options>, <one_value_keywords> and
|
||||
# <multi_value_keywords> a variable composed of the given <prefix>
|
||||
# followed by "_" and the name of the respective keyword. These
|
||||
# variables will then hold the respective value from the argument list.
|
||||
# For the <options> keywords this will be TRUE or FALSE.
|
||||
#
|
||||
# All remaining arguments are collected in a variable
|
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see
|
||||
# whether your macro was called with unrecognized parameters.
|
||||
#
|
||||
# As an example here a my_install() macro, which takes similar arguments
|
||||
# as the real install() command:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# function(MY_INSTALL)
|
||||
# set(options OPTIONAL FAST)
|
||||
# set(oneValueArgs DESTINATION RENAME)
|
||||
# set(multiValueArgs TARGETS CONFIGURATIONS)
|
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
# ...
|
||||
#
|
||||
#
|
||||
#
|
||||
# Assume my_install() has been called like this:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
#
|
||||
#
|
||||
#
|
||||
# After the cmake_parse_arguments() call the macro will have set the
|
||||
# following variables:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# MY_INSTALL_OPTIONAL = TRUE
|
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
|
||||
# MY_INSTALL_DESTINATION = "bin"
|
||||
# MY_INSTALL_RENAME = "" (was not used)
|
||||
# MY_INSTALL_TARGETS = "foo;bar"
|
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
|
||||
#
|
||||
#
|
||||
#
|
||||
# You can then continue and process these variables.
|
||||
#
|
||||
# Keywords terminate lists of values, e.g. if directly after a
|
||||
# one_value_keyword another recognized keyword follows, this is
|
||||
# interpreted as the beginning of the new option. E.g.
|
||||
# my_install(TARGETS foo DESTINATION OPTIONAL) would result in
|
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION
|
||||
# would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
|
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
|
||||
# first set all result variables to empty/FALSE
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach()
|
||||
|
||||
foreach(option ${_optionNames})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach()
|
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(insideValues FALSE)
|
||||
set(currentArgName)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(currentArg ${ARGN})
|
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
|
||||
if(insideValues)
|
||||
if("${insideValues}" STREQUAL "SINGLE")
|
||||
set(${prefix}_${currentArgName} ${currentArg})
|
||||
set(insideValues FALSE)
|
||||
elseif("${insideValues}" STREQUAL "MULTI")
|
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg})
|
||||
endif()
|
||||
else()
|
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
|
||||
endif()
|
||||
else()
|
||||
if(NOT ${optionIndex} EQUAL -1)
|
||||
set(${prefix}_${currentArg} TRUE)
|
||||
set(insideValues FALSE)
|
||||
elseif(NOT ${singleArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "SINGLE")
|
||||
elseif(NOT ${multiArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "MULTI")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
|
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
|
||||
endforeach()
|
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
@@ -1,78 +0,0 @@
|
||||
#.rst:
|
||||
# CheckLibraryExists
|
||||
# ------------------
|
||||
#
|
||||
# Check if the function exists.
|
||||
#
|
||||
# CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE)
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# LIBRARY - the name of the library you are looking for
|
||||
# FUNCTION - the name of the function
|
||||
# LOCATION - location where the library should be found
|
||||
# VARIABLE - variable to store the result
|
||||
#
|
||||
#
|
||||
#
|
||||
# The following variables may be set before calling this macro to modify
|
||||
# the way the check is run:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2002-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
|
||||
macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
|
||||
if(${VARIABLE} MATCHES "^${VARIABLE}$")
|
||||
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
|
||||
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
|
||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
|
||||
if(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_LIBRARY_EXISTS_LIBRARIES
|
||||
${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
endif()
|
||||
try_compile(${VARIABLE}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_ROOT}/Modules/CheckFunctionExists.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}
|
||||
CMAKE_FLAGS
|
||||
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION}
|
||||
-DLINK_DIRECTORIES:STRING=${LOCATION}
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
if(${VARIABLE})
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
|
||||
set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"passed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
else()
|
||||
message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
|
||||
set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
|
||||
"failed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
@@ -1,198 +0,0 @@
|
||||
#.rst:
|
||||
# FindCurses
|
||||
# ----------
|
||||
#
|
||||
# Find the curses include file and library
|
||||
#
|
||||
#
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# CURSES_FOUND - system has Curses
|
||||
# CURSES_INCLUDE_DIR - the Curses include directory
|
||||
# CURSES_LIBRARIES - The libraries needed to use Curses
|
||||
# CURSES_HAVE_CURSES_H - true if curses.h is available
|
||||
# CURSES_HAVE_NCURSES_H - true if ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_NCURSES_H - true if ncurses/ncurses.h is available
|
||||
# CURSES_HAVE_NCURSES_CURSES_H - true if ncurses/curses.h is available
|
||||
# CURSES_LIBRARY - set for backwards compatibility with 2.4 CMake
|
||||
#
|
||||
#
|
||||
#
|
||||
# Set CURSES_NEED_NCURSES to TRUE before the find_package() command if
|
||||
# NCurses functionality is required.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2001-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_library(CURSES_CURSES_LIBRARY NAMES curses )
|
||||
|
||||
find_library(CURSES_NCURSES_LIBRARY NAMES ncurses )
|
||||
set(CURSES_USE_NCURSES FALSE)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND ((NOT CURSES_CURSES_LIBRARY) OR CURSES_NEED_NCURSES))
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html
|
||||
# cygwin ncurses stopped providing curses.h symlinks see above
|
||||
# message. Cygwin is an ncurses package, so force ncurses on
|
||||
# cygwin if the curses.h is missing
|
||||
if(CYGWIN)
|
||||
if(NOT EXISTS /usr/include/curses.h)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Not sure the logic is correct here.
|
||||
# If NCurses is required, use the function wsyncup() to check if the library
|
||||
# has NCurses functionality (at least this is where it breaks on NetBSD).
|
||||
# If wsyncup is in curses, use this one.
|
||||
# If not, try to find ncurses and check if this has the symbol.
|
||||
# Once the ncurses library is found, search the ncurses.h header first, but
|
||||
# some web pages also say that even with ncurses there is not always a ncurses.h:
|
||||
# http://osdir.com/ml/gnome.apps.mc.devel/2002-06/msg00029.html
|
||||
# So at first try ncurses.h, if not found, try to find curses.h under the same
|
||||
# prefix as the library was found, if still not found, try curses.h with the
|
||||
# default search paths.
|
||||
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
|
||||
|
||||
if(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP)
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
wsyncup "" CURSES_NCURSES_HAS_WSYNCUP)
|
||||
if( CURSES_NCURSES_HAS_WSYNCUP)
|
||||
set(CURSES_USE_NCURSES TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT CURSES_USE_NCURSES)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h )
|
||||
find_path(CURSES_CURSES_H_PATH curses.h )
|
||||
get_filename_component(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache with these variables set
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}"
|
||||
CACHE FILEPATH "The curses include path")
|
||||
set(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library")
|
||||
else()
|
||||
# we need to find ncurses
|
||||
get_filename_component(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH)
|
||||
get_filename_component(_cursesParentDir "${_cursesLibDir}" PATH)
|
||||
|
||||
find_file(CURSES_HAVE_NCURSES_H ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h)
|
||||
find_file(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h)
|
||||
find_file(CURSES_HAVE_CURSES_H curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h
|
||||
ncurses/curses.h)
|
||||
find_path(CURSES_NCURSES_INCLUDE_PATH curses.h
|
||||
HINTS "${_cursesParentDir}/include")
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload
|
||||
# however if the value of the variable has NOTFOUND in it, then
|
||||
# it is OK to force, and we need to force in order to have it work.
|
||||
# a cache with these variables set
|
||||
# only put ncurses include and library into
|
||||
# variables if they are found
|
||||
if(NOT CURSES_NCURSES_INCLUDE_PATH AND CURSES_HAVE_NCURSES_NCURSES_H)
|
||||
get_filename_component(CURSES_NCURSES_INCLUDE_PATH
|
||||
"${CURSES_HAVE_NCURSES_NCURSES_H}" PATH)
|
||||
endif()
|
||||
if(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY)
|
||||
set( FORCE_IT )
|
||||
if(CURSES_INCLUDE_PATH MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}"
|
||||
CACHE FILEPATH "The curses include path" ${FORCE_IT})
|
||||
set( FORCE_IT)
|
||||
if(CURSES_LIBRARY MATCHES NOTFOUND)
|
||||
set(FORCE_IT FORCE)
|
||||
endif()
|
||||
set(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}"
|
||||
CACHE FILEPATH "The curses library" ${FORCE_IT})
|
||||
endif()
|
||||
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}"
|
||||
cbreak "" CURSES_NCURSES_HAS_CBREAK)
|
||||
if(NOT CURSES_NCURSES_HAS_CBREAK)
|
||||
find_library(CURSES_EXTRA_LIBRARY tinfo HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY tinfo )
|
||||
CHECK_LIBRARY_EXISTS("${CURSES_EXTRA_LIBRARY}"
|
||||
cbreak "" CURSES_TINFO_HAS_CBREAK)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT CURSES_TINFO_HAS_CBREAK)
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_EXTRA_LIBRARY cur_colr )
|
||||
endif()
|
||||
|
||||
find_library(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}")
|
||||
find_library(CURSES_FORM_LIBRARY form )
|
||||
|
||||
# for compatibility with older FindCurses.cmake this has to be in the cache
|
||||
# FORCE must not be used since this would break builds which preload a cache
|
||||
# with these variables set
|
||||
set(FORM_LIBRARY "${CURSES_FORM_LIBRARY}"
|
||||
CACHE FILEPATH "The curses form library")
|
||||
|
||||
# Need to provide the *_LIBRARIES
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARY})
|
||||
|
||||
if(CURSES_EXTRA_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_EXTRA_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(CURSES_FORM_LIBRARY)
|
||||
set(CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_FORM_LIBRARY})
|
||||
endif()
|
||||
|
||||
# Proper name is *_INCLUDE_DIR
|
||||
set(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH})
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG
|
||||
CURSES_LIBRARY CURSES_INCLUDE_PATH)
|
||||
|
||||
mark_as_advanced(
|
||||
CURSES_INCLUDE_PATH
|
||||
CURSES_LIBRARY
|
||||
CURSES_CURSES_INCLUDE_PATH
|
||||
CURSES_CURSES_LIBRARY
|
||||
CURSES_NCURSES_INCLUDE_PATH
|
||||
CURSES_NCURSES_LIBRARY
|
||||
CURSES_EXTRA_LIBRARY
|
||||
FORM_LIBRARY
|
||||
CURSES_LIBRARIES
|
||||
CURSES_INCLUDE_DIR
|
||||
CURSES_CURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_WSYNCUP
|
||||
CURSES_NCURSES_HAS_CBREAK
|
||||
CURSES_TINFO_HAS_CBREAK
|
||||
)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# - Try to find Iconv
|
||||
# Once done this will define
|
||||
#
|
||||
# ICONV_FOUND - system has Iconv
|
||||
# ICONV_INCLUDE_DIR - the Iconv include directory
|
||||
# ICONV_LIBRARIES - Link these to use Iconv
|
||||
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
|
||||
#
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(ICONV_FIND_QUIETLY TRUE)
|
||||
ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
|
||||
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
|
||||
|
||||
FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
|
||||
|
||||
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
SET(ICONV_FOUND TRUE)
|
||||
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
|
||||
IF(ICONV_FOUND)
|
||||
check_cxx_source_compiles("
|
||||
#include <iconv.h>
|
||||
int main(){
|
||||
iconv_t conv = 0;
|
||||
const char* in = 0;
|
||||
size_t ilen = 0;
|
||||
char* out = 0;
|
||||
size_t olen = 0;
|
||||
iconv(conv, &in, &ilen, &out, &olen);
|
||||
return 0;
|
||||
}
|
||||
" ICONV_SECOND_ARGUMENT_IS_CONST )
|
||||
ENDIF(ICONV_FOUND)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Iconv DEFAULT_MSG
|
||||
ICONV_LIBRARIES ICONV_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
ICONV_INCLUDE_DIR
|
||||
ICONV_LIBRARIES
|
||||
ICONV_SECOND_ARGUMENT_IS_CONST
|
||||
)
|
||||
@@ -1,45 +0,0 @@
|
||||
# Try to find Libintl functionality
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBINTL_FOUND - system has Libintl
|
||||
# LIBINTL_INCLUDE_DIR - Libintl include directory
|
||||
# LIBINTL_LIBRARIES - Libraries needed to use Libintl
|
||||
#
|
||||
# TODO: This will enable translations only if Gettext functionality is
|
||||
# present in libc. Must have more robust system for release, where Gettext
|
||||
# functionality can also reside in standalone Gettext library, or the one
|
||||
# embedded within kdelibs (cf. gettext.m4 from Gettext source).
|
||||
|
||||
# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net>
|
||||
# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
|
||||
set(Libintl_FIND_QUIETLY TRUE)
|
||||
endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
|
||||
|
||||
find_path(LIBINTL_INCLUDE_DIR libintl.h)
|
||||
|
||||
set(LIBINTL_LIB_FOUND FALSE)
|
||||
|
||||
if(LIBINTL_INCLUDE_DIR)
|
||||
include(CheckFunctionExists)
|
||||
check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
|
||||
if (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
set(LIBINTL_LIBRARIES)
|
||||
set(LIBINTL_LIB_FOUND TRUE)
|
||||
else (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
find_library(LIBINTL_LIBRARIES intl libintl libintl-8)
|
||||
if(LIBINTL_LIBRARIES)
|
||||
set(LIBINTL_LIB_FOUND TRUE)
|
||||
endif(LIBINTL_LIBRARIES)
|
||||
endif (LIBINTL_LIBC_HAS_DGETTEXT)
|
||||
endif(LIBINTL_INCLUDE_DIR)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_LIBRARIES LIBINTL_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)
|
||||
@@ -1,351 +0,0 @@
|
||||
#.rst:
|
||||
# FindPackageHandleStandardArgs
|
||||
# -----------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
|
||||
#
|
||||
# This function is intended to be used in FindXXX.cmake modules files.
|
||||
# It handles the REQUIRED, QUIET and version-related arguments to
|
||||
# find_package(). It also sets the <packagename>_FOUND variable. The
|
||||
# package is considered found if all variables <var1>... listed contain
|
||||
# valid results, e.g. valid filepaths.
|
||||
#
|
||||
# There are two modes of this function. The first argument in both
|
||||
# modes is the name of the Find-module where it is called (in original
|
||||
# casing).
|
||||
#
|
||||
# The first simple mode looks like this:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
|
||||
#
|
||||
# If the variables <var1> to <varN> are all valid, then
|
||||
# <UPPERCASED_NAME>_FOUND will be set to TRUE. If DEFAULT_MSG is given
|
||||
# as second argument, then the function will generate itself useful
|
||||
# success and error messages. You can also supply a custom error
|
||||
# message for the failure case. This is not recommended.
|
||||
#
|
||||
# The second mode is more powerful and also supports version checking:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [FOUND_VAR <resultVar>]
|
||||
# [REQUIRED_VARS <var1>...<varN>]
|
||||
# [VERSION_VAR <versionvar>]
|
||||
# [HANDLE_COMPONENTS]
|
||||
# [CONFIG_MODE]
|
||||
# [FAIL_MESSAGE "Custom failure message"] )
|
||||
#
|
||||
#
|
||||
#
|
||||
# In this mode, the name of the result-variable can be set either to
|
||||
# either <UPPERCASED_NAME>_FOUND or <OriginalCase_Name>_FOUND using the
|
||||
# FOUND_VAR option. Other names for the result-variable are not
|
||||
# allowed. So for a Find-module named FindFooBar.cmake, the two
|
||||
# possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended
|
||||
# to use the original case version. If the FOUND_VAR option is not
|
||||
# used, the default is <UPPERCASED_NAME>_FOUND.
|
||||
#
|
||||
# As in the simple mode, if <var1> through <varN> are all valid,
|
||||
# <packagename>_FOUND will be set to TRUE. After REQUIRED_VARS the
|
||||
# variables which are required for this package are listed. Following
|
||||
# VERSION_VAR the name of the variable can be specified which holds the
|
||||
# version of the package which has been found. If this is done, this
|
||||
# version will be checked against the (potentially) specified required
|
||||
# version used in the find_package() call. The EXACT keyword is also
|
||||
# handled. The default messages include information about the required
|
||||
# version and the version which has been actually found, both if the
|
||||
# version is ok or not. If the package supports components, use the
|
||||
# HANDLE_COMPONENTS option to enable handling them. In this case,
|
||||
# find_package_handle_standard_args() will report which components have
|
||||
# been found and which are missing, and the <packagename>_FOUND variable
|
||||
# will be set to FALSE if any of the required components (i.e. not the
|
||||
# ones listed after OPTIONAL_COMPONENTS) are missing. Use the option
|
||||
# CONFIG_MODE if your FindXXX.cmake module is a wrapper for a
|
||||
# find_package(... NO_MODULE) call. In this case VERSION_VAR will be
|
||||
# set to <NAME>_VERSION and the macro will automatically check whether
|
||||
# the Config module was found. Via FAIL_MESSAGE a custom failure
|
||||
# message can be specified, if this is not used, the default message
|
||||
# will be displayed.
|
||||
#
|
||||
# Example for mode 1:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package_handle_standard_args(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
|
||||
#
|
||||
#
|
||||
#
|
||||
# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
|
||||
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to
|
||||
# TRUE. If it is not found and REQUIRED was used, it fails with
|
||||
# FATAL_ERROR, independent whether QUIET was used or not. If it is
|
||||
# found, success will be reported, including the content of <var1>. On
|
||||
# repeated Cmake runs, the same message won't be printed again.
|
||||
#
|
||||
# Example for mode 2:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package_handle_standard_args(LibXslt FOUND_VAR LibXslt_FOUND
|
||||
# REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS
|
||||
# VERSION_VAR LibXslt_VERSION_STRING)
|
||||
#
|
||||
# In this case, LibXslt is considered to be found if the variable(s)
|
||||
# listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and
|
||||
# LibXslt_INCLUDE_DIRS in this case. The result will then be stored in
|
||||
# LibXslt_FOUND . Also the version of LibXslt will be checked by using
|
||||
# the version contained in LibXslt_VERSION_STRING. Since no
|
||||
# FAIL_MESSAGE is given, the default messages will be printed.
|
||||
#
|
||||
# Another example for mode 2:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
|
||||
# find_package_handle_standard_args(Automoc4 CONFIG_MODE)
|
||||
#
|
||||
# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4
|
||||
# NO_MODULE) and adds an additional search directory for automoc4. Here
|
||||
# the result will be stored in AUTOMOC4_FOUND. The following
|
||||
# FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
|
||||
# success/error message.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake)
|
||||
|
||||
# internal helper macro
|
||||
macro(_FPHSA_FAILURE_MESSAGE _msg)
|
||||
if (${_NAME}_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "${_msg}")
|
||||
else ()
|
||||
if (NOT ${_NAME}_FIND_QUIETLY)
|
||||
message(STATUS "${_msg}")
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
|
||||
# internal helper macro to generate the failure message when used in CONFIG_MODE:
|
||||
macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
|
||||
# <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
|
||||
if(${_NAME}_CONFIG)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
|
||||
else()
|
||||
# If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
|
||||
# List them all in the error message:
|
||||
if(${_NAME}_CONSIDERED_CONFIGS)
|
||||
set(configsText "")
|
||||
list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
|
||||
math(EXPR configsCount "${configsCount} - 1")
|
||||
foreach(currentConfigIndex RANGE ${configsCount})
|
||||
list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
|
||||
list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
|
||||
set(configsText "${configsText} ${filename} (version ${version})\n")
|
||||
endforeach()
|
||||
if (${_NAME}_NOT_FOUND_MESSAGE)
|
||||
set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
|
||||
endif()
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
|
||||
|
||||
else()
|
||||
# Simple case: No Config-file was found at all:
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
||||
function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
|
||||
|
||||
# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
|
||||
# new extended or in the "old" mode:
|
||||
set(options CONFIG_MODE HANDLE_COMPONENTS)
|
||||
set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR)
|
||||
set(multiValueArgs REQUIRED_VARS)
|
||||
set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
|
||||
list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
|
||||
|
||||
if(${INDEX} EQUAL -1)
|
||||
set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
|
||||
set(FPHSA_REQUIRED_VARS ${ARGN})
|
||||
set(FPHSA_VERSION_VAR)
|
||||
else()
|
||||
|
||||
CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
|
||||
|
||||
if(FPHSA_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
|
||||
endif()
|
||||
|
||||
if(NOT FPHSA_FAIL_MESSAGE)
|
||||
set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# now that we collected all arguments, process them
|
||||
|
||||
if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
|
||||
set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
|
||||
endif()
|
||||
|
||||
# In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
|
||||
# when it successfully found the config-file, including version checking:
|
||||
if(FPHSA_CONFIG_MODE)
|
||||
list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
|
||||
list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
|
||||
set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
|
||||
endif()
|
||||
|
||||
if(NOT FPHSA_REQUIRED_VARS)
|
||||
message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
|
||||
endif()
|
||||
|
||||
list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
|
||||
|
||||
string(TOUPPER ${_NAME} _NAME_UPPER)
|
||||
string(TOLOWER ${_NAME} _NAME_LOWER)
|
||||
|
||||
if(FPHSA_FOUND_VAR)
|
||||
if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$")
|
||||
set(_FOUND_VAR ${FPHSA_FOUND_VAR})
|
||||
else()
|
||||
message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.")
|
||||
endif()
|
||||
else()
|
||||
set(_FOUND_VAR ${_NAME_UPPER}_FOUND)
|
||||
endif()
|
||||
|
||||
# collect all variables which were not found, so they can be printed, so the
|
||||
# user knows better what went wrong (#6375)
|
||||
set(MISSING_VARS "")
|
||||
set(DETAILS "")
|
||||
# check if all passed variables are valid
|
||||
unset(${_FOUND_VAR})
|
||||
foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
|
||||
if(NOT ${_CURRENT_VAR})
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
|
||||
else()
|
||||
set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE")
|
||||
set(${_FOUND_VAR} TRUE)
|
||||
endif()
|
||||
|
||||
# component handling
|
||||
unset(FOUND_COMPONENTS_MSG)
|
||||
unset(MISSING_COMPONENTS_MSG)
|
||||
|
||||
if(FPHSA_HANDLE_COMPONENTS)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(${_NAME}_${comp}_FOUND)
|
||||
|
||||
if(NOT DEFINED FOUND_COMPONENTS_MSG)
|
||||
set(FOUND_COMPONENTS_MSG "found components: ")
|
||||
endif()
|
||||
set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
else()
|
||||
|
||||
if(NOT DEFINED MISSING_COMPONENTS_MSG)
|
||||
set(MISSING_COMPONENTS_MSG "missing components: ")
|
||||
endif()
|
||||
set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
|
||||
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
set(MISSING_VARS "${MISSING_VARS} ${comp}")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
endforeach()
|
||||
set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
|
||||
set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
|
||||
endif()
|
||||
|
||||
# version handling:
|
||||
set(VERSION_MSG "")
|
||||
set(VERSION_OK TRUE)
|
||||
set(VERSION ${${FPHSA_VERSION_VAR}} )
|
||||
if (${_NAME}_FIND_VERSION)
|
||||
|
||||
if(VERSION)
|
||||
|
||||
if(${_NAME}_FIND_VERSION_EXACT) # exact version required
|
||||
if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
|
||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
|
||||
set(VERSION_OK FALSE)
|
||||
else ()
|
||||
set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
|
||||
endif ()
|
||||
|
||||
else() # minimum version specified:
|
||||
if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
|
||||
set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
|
||||
set(VERSION_OK FALSE)
|
||||
else ()
|
||||
set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
# if the package was not found, but a version was given, add that to the output:
|
||||
if(${_NAME}_FIND_VERSION_EXACT)
|
||||
set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
|
||||
else()
|
||||
set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
else ()
|
||||
if(VERSION)
|
||||
set(VERSION_MSG "(found version \"${VERSION}\")")
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if(VERSION_OK)
|
||||
set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
|
||||
else()
|
||||
set(${_FOUND_VAR} FALSE)
|
||||
endif()
|
||||
|
||||
|
||||
# print the result:
|
||||
if (${_FOUND_VAR})
|
||||
FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
|
||||
else ()
|
||||
|
||||
if(FPHSA_CONFIG_MODE)
|
||||
_FPHSA_HANDLE_FAILURE_CONFIG_MODE()
|
||||
else()
|
||||
if(NOT VERSION_OK)
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
|
||||
else()
|
||||
_FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif ()
|
||||
|
||||
set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE)
|
||||
|
||||
endfunction()
|
||||
@@ -1,57 +0,0 @@
|
||||
#.rst:
|
||||
# FindPackageMessage
|
||||
# ------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details")
|
||||
#
|
||||
# This macro is intended to be used in FindXXX.cmake modules files. It
|
||||
# will print a message once for each unique find result. This is useful
|
||||
# for telling the user where a package was found. The first argument
|
||||
# specifies the name (XXX) of the package. The second argument
|
||||
# specifies the message to display. The third argument lists details
|
||||
# about the find result so that if they change the message will be
|
||||
# displayed again. The macro also obeys the QUIET argument to the
|
||||
# find_package command.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# if(X11_FOUND)
|
||||
# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}"
|
||||
# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]")
|
||||
# else()
|
||||
# ...
|
||||
# endif()
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2008-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
function(FIND_PACKAGE_MESSAGE pkg msg details)
|
||||
# Avoid printing a message repeatedly for the same find result.
|
||||
if(NOT ${pkg}_FIND_QUIETLY)
|
||||
string(REGEX REPLACE "[\n]" "" details "${details}")
|
||||
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
|
||||
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
|
||||
# The message has not yet been printed.
|
||||
message(STATUS "${msg}")
|
||||
|
||||
# Save the find details in the cache to avoid printing the same
|
||||
# message again.
|
||||
set("${DETAILS_VAR}" "${details}"
|
||||
CACHE INTERNAL "Details about finding ${pkg}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -1,186 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2
|
||||
# -------
|
||||
#
|
||||
# Locate SDL2 library
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_LIBRARY, the name of the library to link against
|
||||
# SDL2_FOUND, if false, do not try to link to SDL
|
||||
# SDL2_INCLUDE_DIR, where to find SDL.h
|
||||
# SDL2_VERSION_STRING, human-readable string containing the version of SDL
|
||||
#
|
||||
#
|
||||
#
|
||||
# This module responds to the flag:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_BUILDING_LIBRARY
|
||||
# If this is defined, then no SDL2_main will be linked in because
|
||||
# only applications need main().
|
||||
# Otherwise, it is assumed you are building an application and this
|
||||
# module will attempt to locate and set the proper link flags
|
||||
# as part of the returned SDL2_LIBRARY variable.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Don't forget to include SDLmain.h and SDLmain.m your project for the
|
||||
# OS X framework based version. (Other versions link to -lSDLmain which
|
||||
# this module will try to find on your behalf.) Also for OS X, this
|
||||
# module will automatically add the -framework Cocoa on your behalf.
|
||||
#
|
||||
#
|
||||
#
|
||||
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your
|
||||
# configuration and no SDL2_LIBRARY, it means CMake did not find your SDL
|
||||
# library (SDL.dll, libsdl.so, SDL.framework, etc). Set
|
||||
# SDL2_LIBRARY_TEMP to point to your SDL library, and configure again.
|
||||
# Similarly, if you see an empty SDLMAIN_LIBRARY, you should set this
|
||||
# value as appropriate. These values are used to generate the final
|
||||
# SDL2_LIBRARY variable, but when these values are unset, SDL2_LIBRARY
|
||||
# does not get created.
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDLDIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
|
||||
#
|
||||
# Modified by Eric Wing. Added code to assist with automated building
|
||||
# by using environmental variables and providing a more
|
||||
# controlled/consistent search behavior. Added new modifications to
|
||||
# recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
|
||||
# Also corrected the header search path to follow "proper" SDL
|
||||
# guidelines. Added a search for SDLmain which is needed by some
|
||||
# platforms. Added a search for threads which is needed by some
|
||||
# platforms. Added needed compile switches for MinGW.
|
||||
#
|
||||
# On OSX, this will prefer the Framework version (if found) over others.
|
||||
# People will have to manually change the cache values of SDL2_LIBRARY to
|
||||
# override this selection or set the CMake environment
|
||||
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||
#
|
||||
# Note that the header path has changed from SDL/SDL.h to just SDL.h
|
||||
# This needed to change because "proper" SDL convention is #include
|
||||
# "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
|
||||
# because not all systems place things in SDL/ (see FreeBSD).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2003-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
find_path(SDL2_INCLUDE_DIR SDL.h
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDLDIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
find_library(SDL2_LIBRARY_TEMP
|
||||
NAMES SDL2
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
if(NOT SDL2_BUILDING_LIBRARY)
|
||||
if(NOT SDL2_INCLUDE_DIR MATCHES ".framework")
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDLmain for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
PATHS
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# SDL may require threads on your system.
|
||||
# The Apple build may not need an explicit flag because one of the
|
||||
# frameworks may already provide it.
|
||||
# But for non-OSX systems, I will use the CMake Threads package.
|
||||
if(NOT APPLE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
|
||||
# MinGW needs an additional library, mwindows
|
||||
# It's total link flags should look like -lmingw32 -lSDLmain -lSDL -lmwindows
|
||||
# (Actually on second look, I think it only needs one of the m* libraries.)
|
||||
if(MINGW)
|
||||
set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
|
||||
endif()
|
||||
|
||||
if(SDL2_LIBRARY_TEMP)
|
||||
# For SDLmain
|
||||
if(SDL2MAIN_LIBRARY AND NOT SDL2_BUILDING_LIBRARY)
|
||||
list(FIND SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" _SDL2_MAIN_INDEX)
|
||||
if(_SDL2_MAIN_INDEX EQUAL -1)
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2MAIN_LIBRARY}" ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
unset(_SDL2_MAIN_INDEX)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
# though it actually is there if I modify a pre-used variable.
|
||||
# I think it has something to do with the CACHE STRING.
|
||||
# So I use a temporary variable until the end so I can set the
|
||||
# "real" variable in one-shot.
|
||||
if(APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
# For threads, as mentioned Apple doesn't need this.
|
||||
# In fact, there seems to be a problem if I used the Threads package
|
||||
# and try using this line, so I'm just skipping it entirely for OS X.
|
||||
if(NOT APPLE)
|
||||
set(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# For MinGW library
|
||||
if(MINGW)
|
||||
set(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||
endif()
|
||||
|
||||
# Set the final string here so the GUI reflects the final state.
|
||||
set(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
|
||||
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
|
||||
set(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
|
||||
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
|
||||
VERSION_VAR SDL2_VERSION_STRING)
|
||||
@@ -1,97 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_image
|
||||
# -------------
|
||||
#
|
||||
# Locate SDL2_image library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_IMAGE_LIBRARIES, the name of the library to link against
|
||||
# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_IMAGE_FOUND, if false, do not try to link against
|
||||
# SDL2_IMAGE_VERSION_STRING - human-readable string containing the
|
||||
# version of SDL2_image
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2IMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES)
|
||||
# SDL2IMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS)
|
||||
# SDL2IMAGE_FOUND (same value as SDL2_IMAGE_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_IMAGE_INCLUDE_DIR AND SDL2IMAGE_INCLUDE_DIR)
|
||||
set(SDL2_IMAGE_INCLUDE_DIR ${SDL2IMAGE_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_IMAGE_LIBRARY AND SDL2IMAGE_LIBRARY)
|
||||
set(SDL2_IMAGE_LIBRARY ${SDL2IMAGE_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_IMAGE_LIBRARY
|
||||
NAMES SDL2_image
|
||||
HINTS
|
||||
ENV SDL2IMAGEDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY})
|
||||
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image
|
||||
REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_IMAGE_VERSION_STRING)
|
||||
|
||||
# for backward compatibility
|
||||
set(SDL2IMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES})
|
||||
set(SDL2IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
|
||||
set(SDL2IMAGE_FOUND ${SDL2_IMAGE_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR)
|
||||
@@ -1,97 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_mixer
|
||||
# -------------
|
||||
#
|
||||
# Locate SDL2_mixer library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_MIXER_LIBRARIES, the name of the library to link against
|
||||
# SDL2_MIXER_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_MIXER_FOUND, if false, do not try to link against
|
||||
# SDL2_MIXER_VERSION_STRING - human-readable string containing the
|
||||
# version of SDL2_mixer
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
|
||||
# SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
|
||||
# SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
|
||||
set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
|
||||
set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_MIXER_LIBRARY
|
||||
NAMES SDL2_mixer
|
||||
HINTS
|
||||
ENV SDL2MIXERDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
|
||||
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
|
||||
REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_MIXER_VERSION_STRING)
|
||||
|
||||
# for backward compatibility
|
||||
set(SDL2MIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
|
||||
set(SDL2MIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
|
||||
set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)
|
||||
@@ -1,96 +0,0 @@
|
||||
#.rst:
|
||||
# FindSDL2_ttf
|
||||
# -----------
|
||||
#
|
||||
# Locate SDL2_ttf library
|
||||
#
|
||||
# This module defines:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2_TTF_LIBRARIES, the name of the library to link against
|
||||
# SDL2_TTF_INCLUDE_DIRS, where to find the headers
|
||||
# SDL2_TTF_FOUND, if false, do not try to link against
|
||||
# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL2_ttf
|
||||
#
|
||||
#
|
||||
#
|
||||
# For backward compatibility the following variables are also set:
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# SDL2TTF_LIBRARY (same value as SDL2_TTF_LIBRARIES)
|
||||
# SDL2TTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS)
|
||||
# SDL2TTF_FOUND (same value as SDL2_TTF_FOUND)
|
||||
#
|
||||
#
|
||||
#
|
||||
# $SDL2DIR is an environment variable that would correspond to the
|
||||
# ./configure --prefix=$SDL2DIR used in building SDL2.
|
||||
#
|
||||
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
|
||||
# module, but with modifications to recognize OS X frameworks and
|
||||
# additional Unix paths (FreeBSD, etc).
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2012 Benjamin Eikel
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
if(NOT SDL2_TTF_INCLUDE_DIR AND SDL2TTF_INCLUDE_DIR)
|
||||
set(SDL2_TTF_INCLUDE_DIR ${SDL2TTF_INCLUDE_DIR} CACHE PATH "directory cache
|
||||
entry initialized from old variable name")
|
||||
endif()
|
||||
find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES SDL2
|
||||
# path suffixes to search inside ENV{SDL2DIR}
|
||||
include/SDL2 include
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(VC_LIB_PATH_SUFFIX lib/x64)
|
||||
else()
|
||||
set(VC_LIB_PATH_SUFFIX lib/x86)
|
||||
endif()
|
||||
|
||||
if(NOT SDL2_TTF_LIBRARY AND SDL2TTF_LIBRARY)
|
||||
set(SDL2_TTF_LIBRARY ${SDL2TTF_LIBRARY} CACHE FILEPATH "file cache entry
|
||||
initialized from old variable name")
|
||||
endif()
|
||||
find_library(SDL2_TTF_LIBRARY
|
||||
NAMES SDL2_ttf
|
||||
HINTS
|
||||
ENV SDL2TTFDIR
|
||||
ENV SDL2DIR
|
||||
${CMAKE_SOURCE_DIR}/dep/
|
||||
PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY})
|
||||
set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf
|
||||
REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS
|
||||
VERSION_VAR SDL2_TTF_VERSION_STRING)
|
||||
|
||||
# for backward compatibility
|
||||
set(SDL2TTF_LIBRARY ${SDL2_TTF_LIBRARIES})
|
||||
set(SDL2TTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS})
|
||||
set(SDL2TTF_FOUND ${SDL2_TTF_FOUND})
|
||||
|
||||
mark_as_advanced(SDL2_TTF_LIBRARY SDL2_TTF_INCLUDE_DIR)
|
||||
@@ -1,130 +0,0 @@
|
||||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake"
|
||||
@ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
@@ -1,41 +0,0 @@
|
||||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
@@ -1,25 +0,0 @@
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
1. Assume other participants are posting in good faith, even if you disagree with what they say.
|
||||
2. Make an effort to treat other participants with respect.
|
||||
1. Do not take a harsh tone towards other participants, and especially don't make personal attacks against them.
|
||||
2. Recognize that criticism of your statements is not a personal attack on you.
|
||||
3. Avoid statements about the presumed typical desires, capabilities or actions of some demographic group.
|
||||
3. Be especially kind to other contributors when saying they made a mistake.
|
||||
4. Don't argue unceasingly for your preferred course of action when a decision for some other course has already been made.
|
||||
5. If other participants complain about the way you express your ideas, please make an effort to cater to them.
|
||||
6. Don't raise unrelated political issues.
|
||||
7. If you feel these standards are being violated, please alert the project lead Kevin Granade at kevin.granade@gmail.com
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][CoC homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][CoC version] and the [GNU Kind Communications Guidelines][GKCG homepage].
|
||||
|
||||
|
||||
[CoC homepage]: http://contributor-covenant.org
|
||||
[CoC version]: http://contributor-covenant.org/version/1/4/
|
||||
[GKCG homepage]: https://www.gnu.org/philosophy/kind-communication.html
|
||||
@@ -0,0 +1,84 @@
|
||||
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
|
||||
* build essentials
|
||||
|
||||
```
|
||||
sudo apt-get install libncurses5-dev build-essential
|
||||
```
|
||||
|
||||
### Building ###
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
## Cross-compiling to linux 32-bit from linux 64-bit ##
|
||||
Dependencies:
|
||||
* 32-bit toolchain
|
||||
* 32-bit ncurses
|
||||
|
||||
```
|
||||
sudo apt-get install libc6-dev-i386 lib32stdc++-dev g++-multilib lib32ncurses5-dev
|
||||
```
|
||||
|
||||
### Building ###
|
||||
```
|
||||
make NATIVE=linux32
|
||||
```
|
||||
|
||||
## Cross-compile to Windows from Linux ##
|
||||
Dependencies:
|
||||
* [mxe](http://mxe.cc)
|
||||
|
||||
```
|
||||
sudo apt-get install autoconf bison flex cmake git automake intltool libtool scons yasm
|
||||
mkdir -p ~/src/mxe
|
||||
git clone -b stable https://github.com/mxe/mxe.git ~/src/mxe
|
||||
cd ~/src/mxe
|
||||
make gcc glib
|
||||
```
|
||||
|
||||
### Building ###
|
||||
```
|
||||
PATH="${PATH}:~/src/mxe/usr/bin"
|
||||
make CROSS=i686-pc-mingw32-
|
||||
```
|
||||
|
||||
## Linux (native) SDL builds ##
|
||||
Dependencies:
|
||||
* SDL
|
||||
* SDL_ttf
|
||||
* build essentials
|
||||
|
||||
```
|
||||
sudo apt-get install libsdl1.2-dev libsdl-ttf2.0-dev build-essential
|
||||
```
|
||||
|
||||
### Building ###
|
||||
```
|
||||
make TILES=1
|
||||
```
|
||||
|
||||
## Cross-compile to Windows SDL from Linux ##
|
||||
Dependencies:
|
||||
* [mxe](http://mxe.cc)
|
||||
|
||||
```
|
||||
sudo apt-get install autoconf bison flex cmake git automake intltool libtool scons yasm
|
||||
mkdir -p ~/src/mxe
|
||||
git clone -b stable https://github.com/mxe/mxe.git ~/src/mxe
|
||||
cd ~/src/mxe
|
||||
make sdl sdl_ttf
|
||||
```
|
||||
|
||||
### Building ###
|
||||
```
|
||||
PATH="${PATH}:~/src/mxe/usr/bin"
|
||||
make TILES=1 CROSS=i686-pc-mingw32-
|
||||
```
|
||||
@@ -0,0 +1,83 @@
|
||||
# Building Cataclysm-DDA on Mac OS X
|
||||
|
||||
Tested with OS X 10.8.4, Xcode 4.6.2.
|
||||
I haven't played it extensively but it builds and runs.
|
||||
|
||||
Not sure if it compiles with older OS/XCode versions.
|
||||
This worked for me, your mileage may vary.
|
||||
|
||||
### SDL
|
||||
|
||||
SDL, SDL\_image, and SDL\_ttf are needed for the tiles build.
|
||||
|
||||
[**SDL framework**](http://www.libsdl.org/download-1.2.php)
|
||||
http://www.libsdl.org/release/SDL-1.2.15.dmg
|
||||
|
||||
[**SDL\_image framework**](http://www.libsdl.org/projects/SDL_image/)
|
||||
http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.12.dmg
|
||||
|
||||
[**SDL\_ttf framework**](http://www.libsdl.org/projects/SDL_ttf/)
|
||||
http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-2.0.11.dmg
|
||||
|
||||
Copy `SDL.framework`, `SDL_image.framework`, and `SDL_ttf.framework`
|
||||
to `/Library/Frameworks` or `/Users/name/Library/Frameworks`.
|
||||
|
||||
Alternately, shared libraries (libsdl, libsdl\_image, libsdl\_ttf) can be used
|
||||
instead of frameworks. Install with a package manager (Fink, MacPorts,
|
||||
Homebrew, pkgsrc) or build and install from source.
|
||||
|
||||
### ncurses, gettext
|
||||
|
||||
ncurses and gettext are needed for localization.
|
||||
Install with a package manager, or build from source and install.
|
||||
|
||||
* ncurses needs wide character support enabled.
|
||||
|
||||
## Build
|
||||
|
||||
From the Cataclysm-DDA source folder:
|
||||
|
||||
The easiest way to try it out is the console version without localization:
|
||||
|
||||
$ make NATIVE=osx LOCALIZED=0 OSX_MIN=10.6
|
||||
|
||||
For localization support and/or to use libsdl (not frameworks):
|
||||
|
||||
$ export CXXFLAGS="-I/path/to/include" LDFLAGS="-L/path/to/lib"
|
||||
|
||||
This adds paths to find shared libraries outside of /usr and /usr/local.
|
||||
Multiple `-I/...` or `-L/...` paths can be specified.
|
||||
|
||||
### Example builds:
|
||||
|
||||
Build a release version with SDL graphical tiles:
|
||||
|
||||
$ make FRAMEWORK=1 NATIVE=osx OSX_MIN=10.6 RELEASE=1 TILES=1 LOCALIZE=0
|
||||
|
||||
Build a debug version with SDL ASCII:
|
||||
|
||||
$ make FRAMEWORK=1 NATIVE=osx OSX_MIN=10.6 SDL=1 LOCALIZE=0
|
||||
|
||||
## Run
|
||||
|
||||
$ ./cataclysm
|
||||
|
||||
or
|
||||
|
||||
$ ./cataclysm-tiles
|
||||
|
||||
### Make Options
|
||||
|
||||
`FRAMEWORK=1` use frameworks; omit to use libsdl, libsdl\_image, libsdl\_ttf.
|
||||
|
||||
`LOCALIZED=0` disable localization; enabled by default (requires gettext and ncurses with wide character support).
|
||||
|
||||
`NATIVE=osx` build for OS X.
|
||||
|
||||
`OSX_MIN=version` set `-mmacosx-version-min=` (for OS X > 10.5 set it to 10.6 or higher); omit for 10.5.
|
||||
|
||||
`RELEASE=1` build an optimized 'release' version.
|
||||
|
||||
`SDL=1` build the SDL version with ASCII characters.
|
||||
|
||||
`TILES=1` build the SDL version with graphical tiles.
|
||||
@@ -0,0 +1,197 @@
|
||||
# Contribute
|
||||
|
||||
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.
|
||||
|
||||
## Guidelines
|
||||
|
||||
There are a couple of guidelines we suggest sticking to:
|
||||
|
||||
* Add this repository as an `upstream` remote.
|
||||
* Keep your `master` branch clean. This means you can easily pull changes made to this repository into yours.
|
||||
* Create a new branch for each new feature or set of related bug fixes.
|
||||
* Never merge from your local branches into your `master` branch. Only update that by pulling from `upstream/master`.
|
||||
|
||||
## Code Style
|
||||
|
||||
Current policy is to only update code to the standard style when changing a substantial portion of it, but **please** do this in a seperate commit. Blocks of code can be passed through astyle
|
||||
to ensure that their formatting is correct:
|
||||
|
||||
astyle --style=1tbs --indent=spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-switches --indent-preprocessor --indent-col1-comments --min-conditional-indent=0 --pad-oper --add-brackets --convert-tabs
|
||||
|
||||
For example, from vi, set marks a and b around the block, then:
|
||||
|
||||
:'a,'b ! astyle --style=1tbs --indent-spaces=4 --align-pointer=name --max-code-length=100 --break-after-logical --indent-classes --indent-switches --indent-preprocessor --indent-col1-comments --min-conditional-indent=0 --pad-oper --add-brackets --convert-tabs
|
||||
|
||||
|
||||
## Doxygen Comments
|
||||
|
||||
Extensive documentation of classes and class members will make the code more readable to new contributors. New doxygen comments for existing classes are a welcomed contribution.
|
||||
|
||||
Use the following template for commenting classes:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
*/
|
||||
class foo {
|
||||
```
|
||||
|
||||
Use the following template for commenting functions:
|
||||
```c++
|
||||
/**
|
||||
* Brief description
|
||||
*
|
||||
* Lengthy description with many words. (optional)
|
||||
* @param param1 Description of param1 (optional)
|
||||
* @return Description of return (optional)
|
||||
*/
|
||||
int foo(int param1);
|
||||
```
|
||||
|
||||
Use the following template for commenting member variables:
|
||||
```c++
|
||||
/** Brief description **/
|
||||
int foo;
|
||||
```
|
||||
|
||||
Helpful pages:
|
||||
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.
|
||||
* Describe things that aren't obvious to newcomers just from the name.
|
||||
* Don't describe redundantly, `/** Map **/; map* map;` is not a helpful comment.
|
||||
* When documenting X, describe how X interacts with other components, not just what X itself does.
|
||||
|
||||
### Building the documentation for viewing it locally
|
||||
* Install doxygen
|
||||
* `doxygen doxygen_doc/doxygen_conf.txt `
|
||||
* `firefox doxygen_doc/html/index.html` (replace firefox with your browser of choice)
|
||||
|
||||
## Example Workflow
|
||||
|
||||
#### Setup your environment
|
||||
|
||||
*(This only needs to be done once.)*
|
||||
|
||||
1. Fork this repository here on GitHub.
|
||||
|
||||
2. Clone your fork locally.
|
||||
|
||||
$ git clone https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
# Clones your fork of the repository into the current directory in terminal
|
||||
|
||||
3. Add this repository as a remote.
|
||||
|
||||
$ cd Cataclysm-DDA
|
||||
# Changes the active directory in the prompt to the newly cloned "Cataclysm-DDA" directory
|
||||
$ git remote add -f upstream https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
# Assigns the original repository to a remote called "upstream"
|
||||
|
||||
#### Update your `master` branch
|
||||
|
||||
1. Make sure you have your `master` branch checked out.
|
||||
|
||||
$ git checkout master
|
||||
|
||||
2. Pull the changes from the `upstream/master` branch.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from "master" branch on the "upstream" remote
|
||||
|
||||
* Note: If this gives you an error, it means you have committed directly to your local `master` branch. [Click here for instructions on how to fix this issue](#why-does-git-pull---ff-only-result-in-an-error).
|
||||
|
||||
#### Make your changes
|
||||
|
||||
0. Update your `master` branch, if you haven't already.
|
||||
|
||||
1. For each new feature or bug fix, create a new branch.
|
||||
|
||||
$ git branch new_feature
|
||||
# Creates a new branch called "new_feature"
|
||||
$ git checkout new_feature
|
||||
# Makes "new_feature" the active branch
|
||||
|
||||
2. Once you've committed some changes locally, you need to push them to your fork here on GitHub.
|
||||
|
||||
$ git push origin new_feature
|
||||
# origin was automatically set to point to your fork when you cloned it
|
||||
|
||||
|
||||
3. Once you're finished working on your branch, and have committed and pushed all your changes, submit a pull request from your `new_feature` branch to this repository's `master` branch.
|
||||
|
||||
* Note: any new commits to the `new_feature` branch on GitHub will automatically be included in the pull request, so make sure to only commit related changes to the same branch.
|
||||
|
||||
## Pull Request Notes
|
||||
* Mark pull requests that are still being worked on with [WIP] at the end of the title
|
||||
* When a pull request is ready to be reviewed remove the [WIP]
|
||||
* Mark pull requests that need commenting/testing by others with [CR]
|
||||
|
||||
## Advanced Techniques
|
||||
|
||||
These guidelines aren't essential, but they can make keeping things in order much easier.
|
||||
|
||||
#### Using remote tracking branches
|
||||
|
||||
Remote tracking branches allow you to easily stay in touch with this repository's `master` branch, as they automatically know which remote branch to get changes from.
|
||||
|
||||
$ git branch -vv
|
||||
* master xxxx [origin/master] ....
|
||||
new_feature xxxx ....
|
||||
|
||||
Here you can see we have two branches; `master` which is tracking `origin/master`, and `new_feature` which isn't tracking any branch. In practice, what this means is that git won't know where to get changes from.
|
||||
|
||||
$ git checkout new_feature
|
||||
Switched to branch 'new_feature'
|
||||
$ git pull
|
||||
There is no tracking information for the current branch.
|
||||
Please specify which branch you want to merge with.
|
||||
|
||||
In order to easily pull changes from `upstream/master` into the `new_feature` branch, we can tell git which branch it should track. (You can even do this for your local master branch.)
|
||||
|
||||
$ git branch -u upstream/master new_feature
|
||||
Branch new_feature set up to track remote branch master from upstream.
|
||||
$ git pull
|
||||
Updating xxxx..xxxx
|
||||
....
|
||||
|
||||
You can also set the tracking information at the same time as creating the branch.
|
||||
|
||||
$ git branch new_feature_2 --track upstream/master
|
||||
Branch new_feature_2 set up to track remote branch master from upstream.
|
||||
|
||||
* Note: Although this makes it easier to pull from `upstream/master`, it doesn't change anything with regards to pushing. `git push` fails because you don't have permission to push to `upstream/master`.
|
||||
|
||||
$ git push
|
||||
error: The requested URL returned error: 403 while accessing https://github.com/CleverRaven/Cataclysm-DDA.git
|
||||
fatal: HTTP request failed
|
||||
$ git push origin
|
||||
....
|
||||
To https://github.com/YOUR_USERNAME/Cataclysm-DDA.git
|
||||
xxxx..xxxx new_feature -> new_feature
|
||||
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
####Why does `git pull --ff-only` result in an error?
|
||||
|
||||
If `git pull --ff-only` shows an error, it means that you've committed directly to your local `master` branch. To fix this, we create a new branch with these commits, find the point at which we diverged from `upstream/master`, and then reset `master` to that point.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
From https://github.com/CleverRaven/Cataclysm-DDA
|
||||
* branch master -> FETCH_HEAD
|
||||
fatal: Not possible to fast-forward, aborting.
|
||||
$ git branch new_branch master # mark the current commit with a tmp branch
|
||||
$ git merge-base master upstream/master
|
||||
cc31d0... # the last commit before we committed directly to master
|
||||
$ git reset --hard cc31d0....
|
||||
HEAD is now at cc31d0... ...
|
||||
|
||||
Now that `master` has been cleaned up, we can easily pull from `upstream/master`, and then continue working on `new_branch`.
|
||||
|
||||
$ git pull --ff-only upstream master
|
||||
# gets changes from the "upstream" remote for the matching branch, in this case "master"
|
||||
$ git checkout new_branch
|
||||
@@ -1,84 +0,0 @@
|
||||
{
|
||||
"build_systems":
|
||||
[
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"RELEASE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make RELEASE",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"TILES=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make TILES",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
},
|
||||
{
|
||||
"cmd":
|
||||
[
|
||||
"make",
|
||||
"USE_HOME_DIR=1",
|
||||
"CLANG=1",
|
||||
"CCACHE=1",
|
||||
"TILES=1",
|
||||
"RELEASE=1"
|
||||
],
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"name": "make RELEASE TILES",
|
||||
"working_dir": "${folder:${project_path:${file_path}}}"
|
||||
}
|
||||
],
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"folder_exclude_patterns":
|
||||
[
|
||||
"Cataclysm.app"
|
||||
],
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "~/.cataclysm-dda"
|
||||
},
|
||||
{
|
||||
"path": "~/Library/Application Support/Cataclysm"
|
||||
}
|
||||
],
|
||||
"settings":
|
||||
{
|
||||
"AStyleFormatter":
|
||||
{
|
||||
"options_c++":
|
||||
{
|
||||
"additional_options_file": ".astylerc",
|
||||
"use_only_additional_options": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,260 +14,112 @@
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release (Localized)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalized/" />
|
||||
<Target title="Release - Localized">
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
<Add library="intl" />
|
||||
<Add library="iconv" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseSDL/" />
|
||||
<Target title="Release -SDL">
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
<Add option="-DTILES" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
<Add library="libSDL.dll" />
|
||||
<Add library="SDL_ttf" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseSoundSDL/" />
|
||||
<Target title="Release -SDL -Localized">
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DSDL_SOUND=1" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
<Add option="-DTILES" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Localized)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalizedSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release (SDL, Loc, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/ReleaseLocalizedSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DSDL_SOUND=1" />
|
||||
<Add option="-DRELEASE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
<Add library="intl" />
|
||||
<Add library="iconv" />
|
||||
<Add library="libSDL.dll" />
|
||||
<Add library="SDL_ttf" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg -g" />
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg -lgmon" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (Localized)">
|
||||
<Option output="CataclysmWin" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalized/" />
|
||||
<Target title="Debug - Localized">
|
||||
<Option output="Cataclysm" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add option="-DLOCALIZE" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="intl" />
|
||||
<Add library="iconv" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL)">
|
||||
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugSDL/" />
|
||||
<Target title="Release - Tile Support">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/TilesRelease/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-Os" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
<Add option="-DSDLTILES" />
|
||||
<Add directory="3rdparty/include/SDL" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DSDL_SOUND=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Localized)">
|
||||
<Option output="CataclysmWin-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalizedSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug (SDL, Loc, Sound)">
|
||||
<Option output="Cataclysm-Tiles" prefix_auto="0" extension_auto="1" />
|
||||
<Option object_output="obj/DebugLocalizedSoundSDL/" />
|
||||
<Option type="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-pg" />
|
||||
<Add option="-g" />
|
||||
<Add option="-DLOCALIZE=1" />
|
||||
<Add option="-DTILES=1" />
|
||||
<Add option="-DSDL_SOUND=1" />
|
||||
<Add directory="WinDepend/include" />
|
||||
<Add directory="WinDepend/include/SDL2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-pg" />
|
||||
<Add option="-lgmon" />
|
||||
<Add library="libintl.dll.a" />
|
||||
<Add library="libiconv.dll.a" />
|
||||
<Add library="libSDL2.dll.a" />
|
||||
<Add library="libSDL2main.a" />
|
||||
<Add library="libSDL2_ttf.dll.a" />
|
||||
<Add library="libSDL2_image.dll.a" />
|
||||
<Add library="libSDL2_mixer.dll.a" />
|
||||
<Add directory="WinDepend/lib" />
|
||||
<Add option="-pg -lgmon" />
|
||||
<Add library="3rdparty\lib\libSDL.dll.a" />
|
||||
<Add library="3rdparty\lib\libSDLmain.a" />
|
||||
<Add library="3rdparty\lib\x86\SDL_image.lib" />
|
||||
<Add library="3rdparty\lib\x86\SDL_ttf.lib" />
|
||||
<Add directory="3rdparty/lib" />
|
||||
<Add directory="3rdparty/lib/x86" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-Wextra" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-std=c++14" />
|
||||
<Add option="-DCB_BUILD" />
|
||||
<Add option="-D_WINDOWS" />
|
||||
<Add option="-D_MINGW" />
|
||||
<Add option="-D_WIN32" />
|
||||
<Add option="-D__MINGW__" />
|
||||
<Add option="-Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-Wl,-stack,12000000,-subsystem,windows" />
|
||||
@@ -275,17 +127,214 @@
|
||||
<Add library="gdi32" />
|
||||
<Add library="winmm" />
|
||||
</Linker>
|
||||
<ExtraCommands>
|
||||
<Add before="cmd /c git --version || echo 'git' command not found!" />
|
||||
<Add before="cmd /c git describe --tags --always --dirty > version.tmp || echo no-git> version.tmp" />
|
||||
<Add before='cmd /c for /F "tokens=*" %%i in (version.tmp) do echo #define VERSION "%%i" > src/version.h' />
|
||||
<Add before="cmd /c del version.tmp" />
|
||||
<Mode after="always" />
|
||||
</ExtraCommands>
|
||||
<UnitsGlob directory="src" recursive="0" />
|
||||
<Unit filename="src/resource.rc">
|
||||
<Unit filename="SDLMain.h" />
|
||||
<Unit filename="action.cpp" />
|
||||
<Unit filename="action.h" />
|
||||
<Unit filename="addiction.cpp" />
|
||||
<Unit filename="addiction.h" />
|
||||
<Unit filename="advanced_inv.cpp" />
|
||||
<Unit filename="advanced_inv.h" />
|
||||
<Unit filename="animation_curses.cpp" />
|
||||
<Unit filename="animation_tiles.cpp" />
|
||||
<Unit filename="artifact.cpp" />
|
||||
<Unit filename="artifact.h" />
|
||||
<Unit filename="artifactdata.h" />
|
||||
<Unit filename="auto_pickup.cpp" />
|
||||
<Unit filename="auto_pickup.h" />
|
||||
<Unit filename="basecamp.cpp" />
|
||||
<Unit filename="basecamp.h" />
|
||||
<Unit filename="bionics.cpp" />
|
||||
<Unit filename="bionics.h" />
|
||||
<Unit filename="bodypart.cpp" />
|
||||
<Unit filename="bodypart.h" />
|
||||
<Unit filename="building_generation.cpp" />
|
||||
<Unit filename="building_generation.h" />
|
||||
<Unit filename="calendar.cpp" />
|
||||
<Unit filename="calendar.h" />
|
||||
<Unit filename="cata_tiles.cpp" />
|
||||
<Unit filename="cata_tiles.h" />
|
||||
<Unit filename="catacharset.cpp" />
|
||||
<Unit filename="catacharset.h" />
|
||||
<Unit filename="catacurse.h" />
|
||||
<Unit filename="catajson.cpp" />
|
||||
<Unit filename="catajson.h" />
|
||||
<Unit filename="color.cpp" />
|
||||
<Unit filename="color.h" />
|
||||
<Unit filename="computer.cpp" />
|
||||
<Unit filename="computer.h" />
|
||||
<Unit filename="construction.cpp" />
|
||||
<Unit filename="construction.h" />
|
||||
<Unit filename="crafting.cpp" />
|
||||
<Unit filename="crafting.h" />
|
||||
<Unit filename="cursesdef.h" />
|
||||
<Unit filename="cursesport.cpp" />
|
||||
<Unit filename="debug.cpp" />
|
||||
<Unit filename="debug.h" />
|
||||
<Unit filename="defense.cpp" />
|
||||
<Unit filename="dialogue.h" />
|
||||
<Unit filename="disease.cpp" />
|
||||
<Unit filename="disease.h" />
|
||||
<Unit filename="editmap.cpp" />
|
||||
<Unit filename="editmap.h" />
|
||||
<Unit filename="enums.h" />
|
||||
<Unit filename="event.cpp" />
|
||||
<Unit filename="event.h" />
|
||||
<Unit filename="faction.cpp" />
|
||||
<Unit filename="faction.h" />
|
||||
<Unit filename="field.cpp" />
|
||||
<Unit filename="field.h" />
|
||||
<Unit filename="game.cpp" />
|
||||
<Unit filename="game.h" />
|
||||
<Unit filename="gamemode.cpp" />
|
||||
<Unit filename="gamemode.h" />
|
||||
<Unit filename="gamesave.cpp" />
|
||||
<Unit filename="get_version.h" />
|
||||
<Unit filename="graffiti.cpp" />
|
||||
<Unit filename="graffiti.h" />
|
||||
<Unit filename="help.cpp" />
|
||||
<Unit filename="helper.cpp" />
|
||||
<Unit filename="helper.h" />
|
||||
<Unit filename="iexamine.cpp" />
|
||||
<Unit filename="iexamine.h" />
|
||||
<Unit filename="input.cpp" />
|
||||
<Unit filename="input.h" />
|
||||
<Unit filename="inventory.cpp" />
|
||||
<Unit filename="inventory.h" />
|
||||
<Unit filename="inventory_ui.cpp" />
|
||||
<Unit filename="item.cpp" />
|
||||
<Unit filename="item.h" />
|
||||
<Unit filename="item_factory.cpp" />
|
||||
<Unit filename="item_factory.h" />
|
||||
<Unit filename="item_group.cpp" />
|
||||
<Unit filename="item_group.h" />
|
||||
<Unit filename="itype.h" />
|
||||
<Unit filename="itypedef.cpp" />
|
||||
<Unit filename="iuse.cpp" />
|
||||
<Unit filename="iuse.h" />
|
||||
<Unit filename="iuse_software.cpp" />
|
||||
<Unit filename="iuse_software.h" />
|
||||
<Unit filename="iuse_software_kitten.cpp" />
|
||||
<Unit filename="iuse_software_kitten.h" />
|
||||
<Unit filename="iuse_software_snake.cpp" />
|
||||
<Unit filename="iuse_software_snake.h" />
|
||||
<Unit filename="iuse_software_sokoban.cpp" />
|
||||
<Unit filename="iuse_software_sokoban.h" />
|
||||
<Unit filename="keypress.cpp" />
|
||||
<Unit filename="keypress.h" />
|
||||
<Unit filename="lightmap.cpp" />
|
||||
<Unit filename="lightmap.h" />
|
||||
<Unit filename="line.cpp" />
|
||||
<Unit filename="line.h" />
|
||||
<Unit filename="main.cpp" />
|
||||
<Unit filename="main_menu.cpp" />
|
||||
<Unit filename="map.cpp" />
|
||||
<Unit filename="map.h" />
|
||||
<Unit filename="mapbuffer.cpp" />
|
||||
<Unit filename="mapbuffer.h" />
|
||||
<Unit filename="mapdata.cpp" />
|
||||
<Unit filename="mapdata.h" />
|
||||
<Unit filename="mapgen.cpp" />
|
||||
<Unit filename="mapgenformat.cpp" />
|
||||
<Unit filename="mapgenformat.h" />
|
||||
<Unit filename="mapitems.h" />
|
||||
<Unit filename="material.cpp" />
|
||||
<Unit filename="material.h" />
|
||||
<Unit filename="melee.cpp" />
|
||||
<Unit filename="mission.cpp" />
|
||||
<Unit filename="mission.h" />
|
||||
<Unit filename="mission_end.cpp" />
|
||||
<Unit filename="mission_fail.cpp" />
|
||||
<Unit filename="mission_place.cpp" />
|
||||
<Unit filename="mission_start.cpp" />
|
||||
<Unit filename="missiondef.cpp" />
|
||||
<Unit filename="monattack.cpp" />
|
||||
<Unit filename="monattack.h" />
|
||||
<Unit filename="mondeath.cpp" />
|
||||
<Unit filename="mondeath.h" />
|
||||
<Unit filename="mongroup.h" />
|
||||
<Unit filename="mongroupdef.cpp" />
|
||||
<Unit filename="monitemsdef.cpp" />
|
||||
<Unit filename="monmove.cpp" />
|
||||
<Unit filename="monster.cpp" />
|
||||
<Unit filename="monster.h" />
|
||||
<Unit filename="morale.h" />
|
||||
<Unit filename="moraledata.h" />
|
||||
<Unit filename="mtype.h" />
|
||||
<Unit filename="mtypedef.cpp" />
|
||||
<Unit filename="mutation.cpp" />
|
||||
<Unit filename="mutation.h" />
|
||||
<Unit filename="mutation_data.cpp" />
|
||||
<Unit filename="name.cpp" />
|
||||
<Unit filename="name.h" />
|
||||
<Unit filename="newcharacter.cpp" />
|
||||
<Unit filename="npc.cpp" />
|
||||
<Unit filename="npc.h" />
|
||||
<Unit filename="npcmove.cpp" />
|
||||
<Unit filename="npctalk.cpp" />
|
||||
<Unit filename="omdata.h" />
|
||||
<Unit filename="options.cpp" />
|
||||
<Unit filename="options.h" />
|
||||
<Unit filename="output.cpp" />
|
||||
<Unit filename="output.h" />
|
||||
<Unit filename="overmap.cpp" />
|
||||
<Unit filename="overmap.h" />
|
||||
<Unit filename="overmapbuffer.cpp" />
|
||||
<Unit filename="overmapbuffer.h" />
|
||||
<Unit filename="picofunc.cpp" />
|
||||
<Unit filename="picofunc.h" />
|
||||
<Unit filename="picojson.h" />
|
||||
<Unit filename="player.cpp" />
|
||||
<Unit filename="player.h" />
|
||||
<Unit filename="pldata.h" />
|
||||
<Unit filename="posix_time.cpp" />
|
||||
<Unit filename="posix_time.h" />
|
||||
<Unit filename="profession.cpp" />
|
||||
<Unit filename="profession.h" />
|
||||
<Unit filename="ranged.cpp" />
|
||||
<Unit filename="resource.rc">
|
||||
<Option compilerVar="WINDRES" />
|
||||
</Unit>
|
||||
<Unit filename="rng.cpp" />
|
||||
<Unit filename="rng.h" />
|
||||
<Unit filename="sdlcurse.cpp" />
|
||||
<Unit filename="sdltiles.cpp" />
|
||||
<Unit filename="settlement.cpp" />
|
||||
<Unit filename="settlement.h" />
|
||||
<Unit filename="setvector.cpp" />
|
||||
<Unit filename="setvector.h" />
|
||||
<Unit filename="skill.cpp" />
|
||||
<Unit filename="skill.h" />
|
||||
<Unit filename="text_snippets.cpp" />
|
||||
<Unit filename="text_snippets.h" />
|
||||
<Unit filename="tile_id_data.h" />
|
||||
<Unit filename="tileray.cpp" />
|
||||
<Unit filename="tileray.h" />
|
||||
<Unit filename="translations.h" />
|
||||
<Unit filename="trap.h" />
|
||||
<Unit filename="trapdef.cpp" />
|
||||
<Unit filename="trapfunc.cpp" />
|
||||
<Unit filename="tutorial.cpp" />
|
||||
<Unit filename="tutorial.h" />
|
||||
<Unit filename="ui.cpp" />
|
||||
<Unit filename="ui.h" />
|
||||
<Unit filename="uistate.h" />
|
||||
<Unit filename="veh_interact.cpp" />
|
||||
<Unit filename="veh_interact.h" />
|
||||
<Unit filename="veh_type.h" />
|
||||
<Unit filename="veh_typedef.cpp" />
|
||||
<Unit filename="vehicle.cpp" />
|
||||
<Unit filename="vehicle.h" />
|
||||
<Unit filename="version.cpp" />
|
||||
<Unit filename="version.h" />
|
||||
<Unit filename="wcwidth.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="wdirent.h" />
|
||||
<Unit filename="weather.cpp" />
|
||||
<Unit filename="weather.h" />
|
||||
<Unit filename="weather_data.cpp" />
|
||||
<Unit filename="wincurse.cpp" />
|
||||
<Unit filename="wish.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<debugger />
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# Issues
|
||||
|
||||
## How to create new issues properly
|
||||
|
||||
GitHub issues are used for everything from bug reporting to suggesting long-term ideas. You can make everything run much smoother by following some simple rules.
|
||||
|
||||
### Rule zero
|
||||
|
||||
Always give your issue a meaningful title as this is the first thing anyone will see.
|
||||
|
||||
Note: `[CR]` and `[WIP]` "tags" are meaningful only for PRs. All open issues by definition are request for comments and work in progress.
|
||||
|
||||
### Bug reports
|
||||
|
||||
Before you submit a bug always search the current list of issues to see if it has been reported already.
|
||||
|
||||
Your bug report has to include:
|
||||
|
||||
- On what OS did you experience the problem (Windows, Linux, OS X etc.)
|
||||
- What version were you playing:
|
||||
- Tiles or Curses (text-based)
|
||||
- Version string (preferably full version e.g. "0.C-4547-g3f1c109", or Jenkins build number e.g. 3245)
|
||||
- Description of the problem written in a way that enables anyone to try and recreate it
|
||||
|
||||
Your bug report may include:
|
||||
|
||||
- Screenshot(s) as some things are best explained visually
|
||||
- Save file (e.g. link to a dropbox upload)
|
||||
|
||||
Bonus points for:
|
||||
|
||||
- Checking if the bug exists under latest experimental build
|
||||
- Checking if it is OS specific
|
||||
|
||||
The OS and CDDA version are very important - with the pace of changes here it is possible the bug you have encountered has already been fixed. After that reproducibility is the key, so write your report with all the necessary details.
|
||||
|
||||
### Enhancements and addition ideas
|
||||
|
||||
We have hundreds of issues open - most of them are ideas and suggestions. If you have a general idea or anything that can't be easily described in terms of *current* code changes you'd be better off suggesting it in the appropriate section of [the forum](https://discourse.cataclysmdda.org/). You'll also get much broader exposure for your idea there. After developing a polished idea on the forum, it should be easy to make a GitHub issue for it.
|
||||
|
||||
Please first search if something like what you have on mind has been already proposed. If so, feel free to join the discussion! If your idea is related but sufficiently different, open a new issue and refer to the older discussion (use GitHub's `#issue_number` reference system).
|
||||
|
||||
Remember to take part in the discussion of your suggestions.
|
||||
|
||||
### Questions
|
||||
|
||||
You should direct your questions to the forum or ask on IRC. You should also read the included documentation and additional text files, e.g. [COMPILING.md](doc/COMPILING/COMPILING.md) if you have problems building.
|
||||
|
||||
## Bounties
|
||||
|
||||
Placing a bounty *does not* necessarily mean that change will be incorporated into the main game. Please coordinate in the issue you intend to place a bounty on to determine if it is a change the project will accept, and keep in mind that placing a bounty will not confer special status on the issue. A good way of thinking about bounties is as encouragement for contributors to work on a particular issue, and certainly not as "paying for features".
|
||||
|
||||
## Issue resolution
|
||||
|
||||
We do not assign people to issues. If you plan to work on a bug fix or a validated idea feel free to just comment about that. Actual PRs are of much greater value than any assignments. In general the first correct PR about something will be the PR that will get merged, but remember: we are using Git - you can collaborate with someone else easily by sending them patches or PRs against their PR branch.
|
||||
@@ -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.
|
||||
@@ -1,45 +1 @@
|
||||
Cataclysm is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
|
||||
|
||||
GNU Unifont (data/font/unifont.ttf) is licensed under GNU General Public License v2+ with the GNU font embedding exception. Visit http://unifoundry.com/LICENSE.txt for details.
|
||||
|
||||
Terminus Font (data/font/terminus.ttf) is licensed under the SIL Open Font License (see LICENSE-OFL-Terminus-Font.txt).
|
||||
|
||||
CATCH unit-test framework (tests/catch/catch.hpp) is licensed under the Boost Software License. Visit https://github.com/philsquared/Catch/blob/master/LICENSE.txt to read the license.
|
||||
|
||||
PLF List and PLF Colony (src/list.h, src/colony.h) are licensed under the zLib license (https://www.zlib.net/zlib_license.html).
|
||||
|
||||
getpost (tools/json_tools/format/getpost.h) is licensed under the MIT license, see file for text of license.
|
||||
|
||||
libintl-lite is licensed under Boost Software License 1.0. Visit https://www.boost.org/users/license.html to read the license.
|
||||
|
||||
libbacktrace is licensed under a BSD license (https://github.com/ianlancetaylor/libbacktrace/blob/master/LICENSE). The full license text is as follows:
|
||||
|
||||
# Copyright (C) 2012-2016 Free Software Foundation, Inc.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
|
||||
# (1) Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# (2) Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
|
||||
# (3) The name of the author may not be used to
|
||||
# endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -1,85 +1,30 @@
|
||||
# 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...
|
||||
Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world. While some have described it as a "zombie game", there's far more to Cataclysm than that. Struggle to survive in a harsh, persistent, procedurally generated world. Scavenge the remnants of a dead civilization for for food, equipment, or, if you're 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...
|
||||
|
||||
<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)
|
||||
## Download
|
||||
|
||||
## Downloads
|
||||
Visit [our website](http://en.cataclysmdda.com/) for download links to all stable and experimental releases
|
||||
|
||||
**Releases** - [Stable](https://cataclysmdda.org/releases/) | [Experimental](https://cataclysmdda.org/experimental/)
|
||||
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/).
|
||||
|
||||
**Source** - The source can be downloaded as a [.zip archive](https://github.com/CleverRaven/Cataclysm-DDA/archive/master.zip), or cloned from our [GitHub repo](https://github.com/CleverRaven/Cataclysm-DDA/).
|
||||
|
||||
### Packaging status
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
Ncurses and tiles versions are available in the [community repo](https://www.archlinux.org/packages/?q=cataclysm-dda).
|
||||
|
||||
`sudo pacman -S cataclysm-dda`
|
||||
|
||||
#### Fedora
|
||||
|
||||
Ncurses and tiles versions are available in the [official repos](https://src.fedoraproject.org/rpms/cataclysm-dda).
|
||||
|
||||
`sudo dnf install cataclysm-dda`
|
||||
|
||||
#### Debian / Ubuntu
|
||||
|
||||
Ncurses and tiles versions are available in the [official repos](https://tracker.debian.org/pkg/cataclysm-dda).
|
||||
|
||||
`sudo apt install cataclysm-dda-curses cataclysm-dda-sdl`
|
||||
|
||||
## Compile
|
||||
|
||||
Please read [COMPILING.md](doc/COMPILING/COMPILING.md) - it covers general information and more specific recipes for Linux, OS X, Windows and BSD. See [COMPILER_SUPPORT.md](doc/COMPILING/COMPILER_SUPPORT.md) for details on which compilers we support. And you can always dig for more information in [doc/](https://github.com/CleverRaven/Cataclysm-DDA/tree/master/doc).
|
||||
The latest instructions on how to compile can be found on [our wiki](http://www.wiki.cataclysmdda.com/index.php?title=How_to_compile).
|
||||
|
||||
We also have the following build guides:
|
||||
* Building on Windows with `MSYS2` at [COMPILING-MSYS.md](doc/COMPILING/COMPILING-MSYS.md)
|
||||
* Building on Windows with `vcpkg` at [COMPILING-VS-VCPKG.md](doc/COMPILING/COMPILING-VS-VCPKG.md)
|
||||
* Building with `cmake` at [COMPILING-CMAKE.md](doc/COMPILING/COMPILING-CMAKE.md) (*unofficial guide*)
|
||||
|
||||
## Contribute
|
||||
|
||||
Cataclysm: Dark Days Ahead is the result of contributions from over 1000 volunteers under the Creative Commons Attribution ShareAlike 3.0 license. The code and content of the game is free to use, modify, and redistribute for any purpose whatsoever. See http://creativecommons.org/licenses/by-sa/3.0/ for details.
|
||||
Some code distributed with the project is not part of the project and is released under different software licenses; the files covered by different software licenses have their own license notices.
|
||||
Please see [CONTRIBUTING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/CONTRIBUTING.md) for details.
|
||||
|
||||
[<img src="https://www.bountysource.com/badge/tracker?tracker_id=146201" alt="Bountysource" align="right">](https://www.bountysource.com/trackers/146201-clever-raven-cataclysm-dda?utm_source=146201&utm_medium=shield&utm_campaign=TRACKER_BADGE)
|
||||
|
||||
Please see [CONTRIBUTING.md](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/.github/CONTRIBUTING.md) for details.
|
||||
|
||||
## Community
|
||||
|
||||
Forums:
|
||||
https://discourse.cataclysmdda.org
|
||||
|
||||
Wiki:
|
||||
http://cddawiki.chezzo.com/cdda_wiki/index.php
|
||||
|
||||
GitHub repo:
|
||||
https://github.com/CleverRaven/Cataclysm-DDA
|
||||
|
||||
IRC:
|
||||
`irc.libera.chat` ; `#CataclysmDDA`
|
||||
https://kiwiirc.com/nextclient/irc.libera.chat#CataclysmDDA
|
||||
|
||||
Official Discord:
|
||||
https://discord.gg/jFEc7Yp
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
#### Is there a tutorial?
|
||||
|
||||
Yes, you can find the tutorial in the **Special** menu at the main menu (be aware that due to many code changes the tutorial may not function). You can also access documentation in-game via the `?` key.
|
||||
Yes, you can find the tutorial in the **Special** menu at the main menu. You can also access documentation in-game via the **?** key.
|
||||
|
||||
#### How can I change the key bindings?
|
||||
|
||||
@@ -87,16 +32,8 @@ Press the `?` key, followed by the `1` key to see the full list of key commands.
|
||||
|
||||
#### How can I start a new world?
|
||||
|
||||
**World** on the main menu will generate a fresh world for you. Select **Create World**.
|
||||
**Reset** on the main menu will generate a fresh world for you.
|
||||
|
||||
#### 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`.
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
Cataclysm: Dark Days Ahead
|
||||
|
||||
Cataclysm: Dark Days Ahead is a roguelike set in a post-apocalyptic world. While some have described
|
||||
it as a "zombie game", there's far more to Cataclysm than that. Struggle to survive in a harsh, persistent,
|
||||
procedurally generated world. Scavenge the remnants of a dead civilization for for food, equipment,
|
||||
or, if you're 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...
|
||||
|
||||
Download
|
||||
Visit http://en.cataclysmdda.com/ for download links to all stable and experimental releases
|
||||
|
||||
Compile
|
||||
The latest instructions on how to compile can be found on our wiki at http://www.wiki.cataclysmdda.com/index.php?title=How_to_compile.
|
||||
|
||||
Contribute
|
||||
Please see CONTRIBUTING.md for details.
|
||||
Contributing is much easier with an advanced text editor, for windows a good program is Notepad++, available at http://notepad-plus-plus.org/.
|
||||
|
||||
Frequently Asked Questions
|
||||
1)Is there a tutorial?
|
||||
Yes, you can find the tutorial in the Special menu at the main menu. You can also access
|
||||
documentation in-game via the ? key.
|
||||
|
||||
2)How can I change the key bindings?
|
||||
Press the `?` key, followed by the `1` key to see the full list of key commands. Press the `+` key
|
||||
to add a key binding, select which action with the corresponding letter key `a-w`, and then the key
|
||||
you wish to assign to that action.
|
||||
|
||||
3)How can I start a new world?
|
||||
Reset on the main menu will generate a fresh world for you.
|
||||
|
||||
4)I've found a bug / I would like to make a suggestion. What should I do?
|
||||
Please submit an issue on our GitHub page at https://github.com/CleverRaven/Cataclysm-DDA/issues/.
|
||||
If you're not able to, send an email to `kevin.granade@gmail.com`.
|
||||
@@ -0,0 +1,16 @@
|
||||
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#ifndef _SDLMain_h_
|
||||
#define _SDLMain_h_
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SDLMain : NSObject
|
||||
@end
|
||||
|
||||
#endif /* _SDLMain_h_ */
|
||||
@@ -0,0 +1,385 @@
|
||||
/* SDLMain.m - main entry point for our Cocoa-ized SDL app
|
||||
Initial Version: Darrell Walisser <dwaliss1@purdue.edu>
|
||||
Non-NIB-Code & other changes: Max Horn <max@quendi.de>
|
||||
|
||||
Feel free to customize this file to suit your needs
|
||||
*/
|
||||
|
||||
#if (defined OSX_SDL_FW)
|
||||
#include "SDL.h"
|
||||
#else
|
||||
#include "SDL/SDL.h"
|
||||
#endif
|
||||
#include "SDLMain.h"
|
||||
#include <sys/param.h> /* for MAXPATHLEN */
|
||||
#include <unistd.h>
|
||||
|
||||
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
|
||||
but the method still is there and works. To avoid warnings, we declare
|
||||
it ourselves here. */
|
||||
@interface NSApplication(SDL_Missing_Methods)
|
||||
- (void)setAppleMenu:(NSMenu *)menu;
|
||||
@end
|
||||
|
||||
/* Use this flag to determine whether we use SDLMain.nib or not */
|
||||
#define SDL_USE_NIB_FILE 0
|
||||
|
||||
/* Use this flag to determine whether we use CPS (docking) or not */
|
||||
#define SDL_USE_CPS 1
|
||||
#ifdef SDL_USE_CPS
|
||||
/* Portions of CPS.h */
|
||||
typedef struct CPSProcessSerNum
|
||||
{
|
||||
UInt32 lo;
|
||||
UInt32 hi;
|
||||
} CPSProcessSerNum;
|
||||
|
||||
extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
|
||||
extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
|
||||
extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
|
||||
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
static int gArgc;
|
||||
static char **gArgv;
|
||||
static BOOL gFinderLaunch;
|
||||
static BOOL gCalledAppMainline = FALSE;
|
||||
|
||||
static NSString *getApplicationName(void)
|
||||
{
|
||||
const NSDictionary *dict;
|
||||
NSString *appName = 0;
|
||||
|
||||
/* Determine the application name */
|
||||
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
|
||||
if (dict)
|
||||
appName = [dict objectForKey: @"CFBundleName"];
|
||||
|
||||
if (![appName length])
|
||||
appName = [[NSProcessInfo processInfo] processName];
|
||||
|
||||
return appName;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* A helper category for NSString */
|
||||
@interface NSString (ReplaceSubString)
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface NSApplication (SDLApplication)
|
||||
@end
|
||||
|
||||
@implementation NSApplication (SDLApplication)
|
||||
/* Invoked from the Quit menu item */
|
||||
- (void)terminate:(id)sender
|
||||
{
|
||||
/* Post a SDL_QUIT event */
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
@end
|
||||
|
||||
/* The main class of the application, the application's delegate */
|
||||
@implementation SDLMain
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
- (void) setupWorkingDirectory:(BOOL)shouldChdir
|
||||
{
|
||||
if (shouldChdir)
|
||||
{
|
||||
char parentdir[MAXPATHLEN];
|
||||
CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
|
||||
CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
|
||||
if (CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, MAXPATHLEN)) {
|
||||
chdir(parentdir); /* chdir to the binary app's parent */
|
||||
}
|
||||
CFRelease(url);
|
||||
CFRelease(url2);
|
||||
}
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
|
||||
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||
- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName
|
||||
{
|
||||
NSRange aRange;
|
||||
NSEnumerator *enumerator;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
|
||||
|
||||
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||
while ((menuItem = [enumerator nextObject]))
|
||||
{
|
||||
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||
if (aRange.length != 0)
|
||||
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]];
|
||||
if ([menuItem hasSubmenu])
|
||||
[self fixMenu:[menuItem submenu] withAppName:appName];
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void setApplicationMenu(void)
|
||||
{
|
||||
/* warning: this code is very odd */
|
||||
NSMenu *appleMenu;
|
||||
NSMenuItem *menuItem;
|
||||
NSString *title;
|
||||
NSString *appName;
|
||||
|
||||
appName = getApplicationName();
|
||||
appleMenu = [[NSMenu alloc] initWithTitle:@""];
|
||||
|
||||
/* Add menu items */
|
||||
title = [@"About " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Hide " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
|
||||
|
||||
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
|
||||
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
|
||||
|
||||
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
|
||||
|
||||
[appleMenu addItem:[NSMenuItem separatorItem]];
|
||||
|
||||
title = [@"Quit " stringByAppendingString:appName];
|
||||
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
|
||||
|
||||
|
||||
/* Put menu into the menubar */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
[menuItem setSubmenu:appleMenu];
|
||||
[[NSApp mainMenu] addItem:menuItem];
|
||||
|
||||
/* Tell the application object that this is now the application menu */
|
||||
[NSApp setAppleMenu:appleMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[appleMenu release];
|
||||
[menuItem release];
|
||||
}
|
||||
|
||||
/* Create a window menu */
|
||||
static void setupWindowMenu(void)
|
||||
{
|
||||
NSMenu *windowMenu;
|
||||
NSMenuItem *windowMenuItem;
|
||||
NSMenuItem *menuItem;
|
||||
|
||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||
|
||||
/* "Minimize" item */
|
||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||
[windowMenu addItem:menuItem];
|
||||
[menuItem release];
|
||||
|
||||
/* Put menu into the menubar */
|
||||
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||
[windowMenuItem setSubmenu:windowMenu];
|
||||
[[NSApp mainMenu] addItem:windowMenuItem];
|
||||
|
||||
/* Tell the application object that this is now the window menu */
|
||||
[NSApp setWindowsMenu:windowMenu];
|
||||
|
||||
/* Finally give up our references to the objects */
|
||||
[windowMenu release];
|
||||
[windowMenuItem release];
|
||||
}
|
||||
|
||||
/* Replacement for NSApplicationMain */
|
||||
static void CustomApplicationMain (int argc, char **argv)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
SDLMain *sdlMain;
|
||||
|
||||
/* Ensure the application object is initialised */
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
#ifdef SDL_USE_CPS
|
||||
{
|
||||
CPSProcessSerNum PSN;
|
||||
/* Tell the dock about us */
|
||||
if (!CPSGetCurrentProcess(&PSN))
|
||||
if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
|
||||
if (!CPSSetFrontProcess(&PSN))
|
||||
[NSApplication sharedApplication];
|
||||
}
|
||||
#endif /* SDL_USE_CPS */
|
||||
|
||||
/* Set up the menubar */
|
||||
[NSApp setMainMenu:[[NSMenu alloc] init]];
|
||||
setApplicationMenu();
|
||||
setupWindowMenu();
|
||||
|
||||
/* Create SDLMain and make it the app delegate */
|
||||
sdlMain = [[SDLMain alloc] init];
|
||||
[NSApp setDelegate:sdlMain];
|
||||
|
||||
/* Start the main event loop */
|
||||
[NSApp run];
|
||||
|
||||
[sdlMain release];
|
||||
[pool release];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Catch document open requests...this lets us notice files when the app
|
||||
* was launched by double-clicking a document, or when a document was
|
||||
* dragged/dropped on the app's icon. You need to have a
|
||||
* CFBundleDocumentsType section in your Info.plist to get this message,
|
||||
* apparently.
|
||||
*
|
||||
* Files are added to gArgv, so to the app, they'll look like command line
|
||||
* arguments. Previously, apps launched from the finder had nothing but
|
||||
* an argv[0].
|
||||
*
|
||||
* This message may be received multiple times to open several docs on launch.
|
||||
*
|
||||
* This message is ignored once the app's mainline has been called.
|
||||
*/
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
const char *temparg;
|
||||
size_t arglen;
|
||||
char *arg;
|
||||
char **newargv;
|
||||
|
||||
if (!gFinderLaunch) /* MacOS is passing command line args. */
|
||||
return FALSE;
|
||||
|
||||
if (gCalledAppMainline) /* app has started, ignore this document. */
|
||||
return FALSE;
|
||||
|
||||
temparg = [filename UTF8String];
|
||||
arglen = SDL_strlen(temparg) + 1;
|
||||
arg = (char *) SDL_malloc(arglen);
|
||||
if (arg == NULL)
|
||||
return FALSE;
|
||||
|
||||
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
|
||||
if (newargv == NULL)
|
||||
{
|
||||
SDL_free(arg);
|
||||
return FALSE;
|
||||
}
|
||||
gArgv = newargv;
|
||||
|
||||
SDL_strlcpy(arg, temparg, arglen);
|
||||
gArgv[gArgc++] = arg;
|
||||
gArgv[gArgc] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* Called when the internal event loop has just started running */
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) note
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Set the working directory to the .app's parent directory */
|
||||
[self setupWorkingDirectory:gFinderLaunch];
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
|
||||
#endif
|
||||
|
||||
/* Hand off to main application code */
|
||||
gCalledAppMainline = TRUE;
|
||||
status = SDL_main (gArgc, gArgv);
|
||||
|
||||
/* We're done, thank you for playing */
|
||||
exit(status);
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSString (ReplaceSubString)
|
||||
|
||||
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||
{
|
||||
unsigned int bufferSize;
|
||||
unsigned int selfLen = [self length];
|
||||
unsigned int aStringLen = [aString length];
|
||||
unichar *buffer;
|
||||
NSRange localRange;
|
||||
NSString *result;
|
||||
|
||||
bufferSize = selfLen + aStringLen - aRange.length;
|
||||
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||
|
||||
/* Get first part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aRange.location;
|
||||
[self getCharacters:buffer range:localRange];
|
||||
|
||||
/* Get middle part into buffer */
|
||||
localRange.location = 0;
|
||||
localRange.length = aStringLen;
|
||||
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||
|
||||
/* Get last part into buffer */
|
||||
localRange.location = aRange.location + aRange.length;
|
||||
localRange.length = selfLen - localRange.location;
|
||||
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||
|
||||
/* Build output string */
|
||||
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||
|
||||
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
#ifdef main
|
||||
# undef main
|
||||
#endif
|
||||
|
||||
|
||||
/* Main entry point to executable - should *not* be SDL_main! */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
/* Copy the arguments into a global variable */
|
||||
/* This is passed if we are launched by double-clicking */
|
||||
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * 2);
|
||||
gArgv[0] = argv[0];
|
||||
gArgv[1] = NULL;
|
||||
gArgc = 1;
|
||||
gFinderLaunch = YES;
|
||||
} else {
|
||||
int i;
|
||||
gArgc = argc;
|
||||
gArgv = (char **) SDL_malloc(sizeof (char *) * (argc+1));
|
||||
for (i = 0; i <= argc; i++)
|
||||
gArgv[i] = argv[i];
|
||||
gFinderLaunch = NO;
|
||||
}
|
||||
|
||||
#if SDL_USE_NIB_FILE
|
||||
NSApplicationMain (argc, argv);
|
||||
#else
|
||||
CustomApplicationMain (argc, argv);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,33 +33,3 @@ Angela Graves <Rivet.the.Zombie@gmail.com>
|
||||
Ian Strachan <ian_e_strachan@hotmail.com>
|
||||
Greg McNew <gmcnew@gmail.com>
|
||||
NaturesWitness <natureswitness@gmail.com>
|
||||
CodeHero <codehero@nerdpol.ch>
|
||||
tasetase "Tase" <tase on irc.freenode.net>
|
||||
Barry Peddycord III <ishara@isharacomix.org>
|
||||
Vidar Engh Skaugen <vidarsk@gmail.com>
|
||||
Brandon Bergren (Bdragon) <bdragon@rtk0.net> / <git@bdragon.rtk0.net>
|
||||
Henrik "Tivec" Bergvin <henrik@bergvin.com>
|
||||
FryCarson <frycarson@gmail.com>
|
||||
TranquilMarmot (Nate Moore) <nate272@gmail.com>
|
||||
Stéphane Travostino <stephane.travostino@gmail.com>
|
||||
Jeremy Osborne <jeremywosborne@gmail.com>
|
||||
David "Davek" Keaton <keaton.david@gmail.com>
|
||||
Piotr S. Staszewski (drbig) <p.staszewski@gmail.com>
|
||||
Donnie "Desrik" McNabb <koderkore@gmail.com>
|
||||
Christian R. Byrne <christianbyrne2012@gmail.com>
|
||||
Dmitry "illi-kun" Serov <D.E.Serov@gmail.com>
|
||||
Karl Parakenings (karlnp) <karl.parakenings@gmail.com>
|
||||
Rob Palkowski <dopeghoti@gmail.com>
|
||||
Zaweri Runewright <mrampuja@gmail.com>
|
||||
Cliffs Dover <cliffs@dancingbottle.com>
|
||||
Sven-Hendrik "svenstaro" Haase <svenstaro@gmail.com>
|
||||
Nick Owens <mischief@offblast.org>
|
||||
Brett Dong <brett.browning.dong@gmail.com>
|
||||
Barry Gackle <bdgackle@gmail.com>
|
||||
BorkBorkGoesTheCode <imreallytoolazy@protonmail.com>
|
||||
Patrik Stridvall <patrik@stridvall.se>
|
||||
Ryan Schneider (RadHazard) <rslego@gmail.com>
|
||||
Paul Bransford (draeath) <draeath@gmail.com>
|
||||
Mark Langsdorf (mlangsdorf) <mark.langsdorf@gmail.com> / <mlangsdo@redhat.com>
|
||||
Ratul Saha (sahaRatul) <ratul.saha@arrakis.in> / <50.ratulsaha@gmail.com>
|
||||
Davis Bray (Kaltag1925) <pdavisbray@gmail.com>
|
||||
|
||||
@@ -0,0 +1,471 @@
|
||||
#include "game.h"
|
||||
#include "keypress.h"
|
||||
#include "output.h"
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
void parse_keymap(std::istream &keymap_txt, std::map<char, action_id> &kmap);
|
||||
|
||||
void game::load_keyboard_settings()
|
||||
{
|
||||
// Load the default keymap
|
||||
std::istringstream sin;
|
||||
sin.str(default_keymap_txt());
|
||||
parse_keymap(sin, default_keymap);
|
||||
|
||||
// Load the player's actual keymap
|
||||
std::ifstream fin;
|
||||
fin.open("data/keymap.txt");
|
||||
if (!fin) { // It doesn't exist
|
||||
std::ofstream fout;
|
||||
fout.open("data/keymap.txt");
|
||||
fout << default_keymap_txt();
|
||||
fout.close();
|
||||
fin.open("data/keymap.txt");
|
||||
}
|
||||
if (!fin) { // Still can't open it--probably bad permissions
|
||||
debugmsg("Can't open data/keymap.txt. This may be a permissions issue.");
|
||||
keymap = default_keymap;
|
||||
return;
|
||||
} else {
|
||||
parse_keymap(fin, keymap);
|
||||
}
|
||||
|
||||
// Check for new defaults, and automatically bind them if possible
|
||||
std::map<char, action_id>::iterator d_it;
|
||||
bool found;
|
||||
for (d_it = default_keymap.begin(); d_it != default_keymap.end(); d_it++) {
|
||||
found = false;
|
||||
std::map<char, action_id>::iterator k_it;
|
||||
for (k_it = keymap.begin(); k_it != keymap.end(); k_it++) {
|
||||
if (d_it->second == k_it->second) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && !keymap.count(d_it->first)) {
|
||||
keymap[d_it->first] = d_it->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void parse_keymap(std::istream &keymap_txt, std::map<char, action_id> &kmap)
|
||||
{
|
||||
while (!keymap_txt.eof()) {
|
||||
std::string id;
|
||||
keymap_txt >> id;
|
||||
if (id == "")
|
||||
getline(keymap_txt, id); // Empty line, chomp it
|
||||
else if (id[0] != '#') {
|
||||
action_id act = look_up_action(id);
|
||||
if (act == ACTION_NULL)
|
||||
debugmsg("\
|
||||
Warning! data/keymap.txt contains an unknown action, \"%s\"\n\
|
||||
Fix data/keymap.txt at your next chance!", id.c_str());
|
||||
else {
|
||||
while (!keymap_txt.eof()) {
|
||||
char ch;
|
||||
keymap_txt >> std::noskipws >> ch >> std::skipws;
|
||||
if (ch == '\n') {
|
||||
break;
|
||||
} else if (ch != ' ' || keymap_txt.peek() == '\n') {
|
||||
if (kmap.find(ch) != kmap.end()) {
|
||||
debugmsg("\
|
||||
Warning! '%c' assigned twice in the keymap!\n\
|
||||
%s is being ignored.\n\
|
||||
Fix data/keymap.txt at your next chance!", ch, id.c_str());
|
||||
} else {
|
||||
kmap[ ch ] = act;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getline(keymap_txt, id); // Clear the whole line
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void game::save_keymap()
|
||||
{
|
||||
std::ofstream fout;
|
||||
fout.open("data/keymap.txt");
|
||||
if (!fout) { // It doesn't exist
|
||||
debugmsg("Can't open data/keymap.txt.");
|
||||
fout.close();
|
||||
return;
|
||||
}
|
||||
std::map<char, action_id>::iterator it;
|
||||
for (it = keymap.begin(); it != keymap.end(); it++)
|
||||
fout << action_ident( (*it).second ) << " " << (*it).first << std::endl;
|
||||
|
||||
fout.close();
|
||||
}
|
||||
|
||||
std::vector<char> game::keys_bound_to(action_id act)
|
||||
{
|
||||
std::vector<char> ret;
|
||||
std::map<char, action_id>::iterator it;
|
||||
for (it = keymap.begin(); it != keymap.end(); it++) {
|
||||
if ( (*it).second == act )
|
||||
ret.push_back( (*it).first );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void game::clear_bindings(action_id act)
|
||||
{
|
||||
std::map<char, action_id>::iterator it;
|
||||
for (it = keymap.begin(); it != keymap.end(); it++) {
|
||||
if ( (*it).second == act ) {
|
||||
keymap.erase(it);
|
||||
it = keymap.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string action_ident(action_id act)
|
||||
{
|
||||
switch (act) {
|
||||
case ACTION_PAUSE:
|
||||
return "pause";
|
||||
case ACTION_MOVE_N:
|
||||
return "move_n";
|
||||
case ACTION_MOVE_NE:
|
||||
return "move_ne";
|
||||
case ACTION_MOVE_E:
|
||||
return "move_e";
|
||||
case ACTION_MOVE_SE:
|
||||
return "move_se";
|
||||
case ACTION_MOVE_S:
|
||||
return "move_s";
|
||||
case ACTION_MOVE_SW:
|
||||
return "move_sw";
|
||||
case ACTION_MOVE_W:
|
||||
return "move_w";
|
||||
case ACTION_MOVE_NW:
|
||||
return "move_nw";
|
||||
case ACTION_MOVE_DOWN:
|
||||
return "move_down";
|
||||
case ACTION_MOVE_UP:
|
||||
return "move_up";
|
||||
case ACTION_CENTER:
|
||||
return "center";
|
||||
case ACTION_SHIFT_N:
|
||||
return "shift_n";
|
||||
case ACTION_SHIFT_NE:
|
||||
return "shift_ne";
|
||||
case ACTION_SHIFT_E:
|
||||
return "shift_e";
|
||||
case ACTION_SHIFT_SE:
|
||||
return "shift_se";
|
||||
case ACTION_SHIFT_S:
|
||||
return "shift_s";
|
||||
case ACTION_SHIFT_SW:
|
||||
return "shift_sw";
|
||||
case ACTION_SHIFT_W:
|
||||
return "shift_w";
|
||||
case ACTION_SHIFT_NW:
|
||||
return "shift_nw";
|
||||
case ACTION_OPEN:
|
||||
return "open";
|
||||
case ACTION_CLOSE:
|
||||
return "close";
|
||||
case ACTION_SMASH:
|
||||
return "smash";
|
||||
case ACTION_EXAMINE:
|
||||
return "examine";
|
||||
case ACTION_ADVANCEDINV:
|
||||
return "advinv";
|
||||
case ACTION_PICKUP:
|
||||
return "pickup";
|
||||
case ACTION_GRAB:
|
||||
return "grab";
|
||||
case ACTION_BUTCHER:
|
||||
return "butcher";
|
||||
case ACTION_CHAT:
|
||||
return "chat";
|
||||
case ACTION_LOOK:
|
||||
return "look";
|
||||
case ACTION_PEEK:
|
||||
return "peek";
|
||||
case ACTION_LIST_ITEMS:
|
||||
return "listitems";
|
||||
case ACTION_INVENTORY:
|
||||
return "inventory";
|
||||
case ACTION_COMPARE:
|
||||
return "compare";
|
||||
case ACTION_ORGANIZE:
|
||||
return "organize";
|
||||
case ACTION_USE:
|
||||
return "apply";
|
||||
case ACTION_USE_WIELDED:
|
||||
return "apply_wielded";
|
||||
case ACTION_WEAR:
|
||||
return "wear";
|
||||
case ACTION_TAKE_OFF:
|
||||
return "take_off";
|
||||
case ACTION_EAT:
|
||||
return "eat";
|
||||
case ACTION_READ:
|
||||
return "read";
|
||||
case ACTION_WIELD:
|
||||
return "wield";
|
||||
case ACTION_PICK_STYLE:
|
||||
return "pick_style";
|
||||
case ACTION_RELOAD:
|
||||
return "reload";
|
||||
case ACTION_UNLOAD:
|
||||
return "unload";
|
||||
case ACTION_THROW:
|
||||
return "throw";
|
||||
case ACTION_FIRE:
|
||||
return "fire";
|
||||
case ACTION_FIRE_BURST:
|
||||
return "fire_burst";
|
||||
case ACTION_SELECT_FIRE_MODE:
|
||||
return "select_fire_mode";
|
||||
case ACTION_DROP:
|
||||
return "drop";
|
||||
case ACTION_DIR_DROP:
|
||||
return "drop_adj";
|
||||
case ACTION_BIONICS:
|
||||
return "bionics";
|
||||
case ACTION_SORT_ARMOR:
|
||||
return "sort_armor";
|
||||
case ACTION_WAIT:
|
||||
return "wait";
|
||||
case ACTION_CRAFT:
|
||||
return "craft";
|
||||
case ACTION_RECRAFT:
|
||||
return "recraft";
|
||||
case ACTION_LONGCRAFT:
|
||||
return "long_craft";
|
||||
case ACTION_CONSTRUCT:
|
||||
return "construct";
|
||||
case ACTION_DISASSEMBLE:
|
||||
return "disassemble";
|
||||
case ACTION_SLEEP:
|
||||
return "sleep";
|
||||
case ACTION_CONTROL_VEHICLE:
|
||||
return "control_vehicle";
|
||||
case ACTION_TOGGLE_SAFEMODE:
|
||||
return "safemode";
|
||||
case ACTION_TOGGLE_AUTOSAFE:
|
||||
return "autosafe";
|
||||
case ACTION_IGNORE_ENEMY:
|
||||
return "ignore_enemy";
|
||||
case ACTION_SAVE:
|
||||
return "save";
|
||||
case ACTION_QUICKSAVE:
|
||||
return "quicksave";
|
||||
case ACTION_QUIT:
|
||||
return "quit";
|
||||
case ACTION_PL_INFO:
|
||||
return "player_data";
|
||||
case ACTION_MAP:
|
||||
return "map";
|
||||
case ACTION_MISSIONS:
|
||||
return "missions";
|
||||
case ACTION_FACTIONS:
|
||||
return "factions";
|
||||
case ACTION_KILLS:
|
||||
return "kills";
|
||||
case ACTION_MORALE:
|
||||
return "morale";
|
||||
case ACTION_MESSAGES:
|
||||
return "messages";
|
||||
case ACTION_HELP:
|
||||
return "help";
|
||||
case ACTION_DEBUG:
|
||||
return "debug";
|
||||
case ACTION_DISPLAY_SCENT:
|
||||
return "debug_scent";
|
||||
case ACTION_TOGGLE_DEBUGMON:
|
||||
return "debug_mode";
|
||||
case ACTION_NULL:
|
||||
return "null";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
action_id look_up_action(std::string ident)
|
||||
{
|
||||
for (int i = 0; i < NUM_ACTIONS; i++)
|
||||
{
|
||||
if (action_ident( action_id(i) ) == ident)
|
||||
{
|
||||
return action_id(i);
|
||||
}
|
||||
}
|
||||
return ACTION_NULL;
|
||||
}
|
||||
|
||||
std::string action_name(action_id act)
|
||||
{
|
||||
switch (act)
|
||||
{
|
||||
case ACTION_PAUSE:
|
||||
return _("Pause");
|
||||
case ACTION_MOVE_N:
|
||||
return _("Move North");
|
||||
case ACTION_MOVE_NE:
|
||||
return _("Move Northeast");
|
||||
case ACTION_MOVE_E:
|
||||
return _("Move East");
|
||||
case ACTION_MOVE_SE:
|
||||
return _("Move Southeast");
|
||||
case ACTION_MOVE_S:
|
||||
return _("Move South");
|
||||
case ACTION_MOVE_SW:
|
||||
return _("Move Southwest");
|
||||
case ACTION_MOVE_W:
|
||||
return _("Move West");
|
||||
case ACTION_MOVE_NW:
|
||||
return _("Move Northwest");
|
||||
case ACTION_MOVE_DOWN:
|
||||
return _("Descend Stairs");
|
||||
case ACTION_MOVE_UP:
|
||||
return _("Ascend Stairs");
|
||||
case ACTION_CENTER:
|
||||
return _("Center View");
|
||||
case ACTION_SHIFT_N:
|
||||
return _("Move View North");
|
||||
case ACTION_SHIFT_NE:
|
||||
return _("Move View Northeast");
|
||||
case ACTION_SHIFT_E:
|
||||
return _("Move View East");
|
||||
case ACTION_SHIFT_SE:
|
||||
return _("Move View Southeast");
|
||||
case ACTION_SHIFT_S:
|
||||
return _("Move View South");
|
||||
case ACTION_SHIFT_SW:
|
||||
return _("Move View Southwest");
|
||||
case ACTION_SHIFT_W:
|
||||
return _("Move View West");
|
||||
case ACTION_SHIFT_NW:
|
||||
return _("Move View Northwest");
|
||||
case ACTION_OPEN:
|
||||
return _("Open Door");
|
||||
case ACTION_CLOSE:
|
||||
return _("Close Door");
|
||||
case ACTION_SMASH:
|
||||
return _("Smash Nearby Terrain");
|
||||
case ACTION_EXAMINE:
|
||||
return _("Examine Nearby Terrain");
|
||||
case ACTION_PICKUP:
|
||||
return _("Pick Item(s) Up");
|
||||
case ACTION_GRAB:
|
||||
return _("Grab a nearby vehicle");
|
||||
case ACTION_BUTCHER:
|
||||
return _("Butcher");
|
||||
case ACTION_CHAT:
|
||||
return _("Chat with NPC");
|
||||
case ACTION_LOOK:
|
||||
return _("Look Around");
|
||||
case ACTION_PEEK:
|
||||
return _("Peek Around Corners");
|
||||
case ACTION_LIST_ITEMS:
|
||||
return _("List all items around the player");
|
||||
case ACTION_INVENTORY:
|
||||
return _("Open Inventory");
|
||||
case ACTION_ADVANCEDINV:
|
||||
return _("Advanced Inventory management");
|
||||
case ACTION_COMPARE:
|
||||
return _("Compare two Items");
|
||||
case ACTION_ORGANIZE:
|
||||
return _("Swap Inventory Letters");
|
||||
case ACTION_USE:
|
||||
return _("Apply or Use Item");
|
||||
case ACTION_USE_WIELDED:
|
||||
return _("Apply or Use Wielded Item");
|
||||
case ACTION_WEAR:
|
||||
return _("Wear Item");
|
||||
case ACTION_TAKE_OFF:
|
||||
return _("Take Off Worn Item");
|
||||
case ACTION_EAT:
|
||||
return _("Eat");
|
||||
case ACTION_READ:
|
||||
return _("Read");
|
||||
case ACTION_WIELD:
|
||||
return _("Wield");
|
||||
case ACTION_PICK_STYLE:
|
||||
return _("Select Unarmed Style");
|
||||
case ACTION_RELOAD:
|
||||
return _("Reload Wielded Item");
|
||||
case ACTION_UNLOAD:
|
||||
return _("Unload or Empty Wielded Item");
|
||||
case ACTION_THROW:
|
||||
return _("Throw Item");
|
||||
case ACTION_FIRE:
|
||||
return _("Fire Wielded Item");
|
||||
case ACTION_FIRE_BURST:
|
||||
return _("Burst-Fire Wielded Item");
|
||||
case ACTION_SELECT_FIRE_MODE:
|
||||
return _("Toggle attack mode of Wielded Item");
|
||||
case ACTION_DROP:
|
||||
return _("Drop Item");
|
||||
case ACTION_DIR_DROP:
|
||||
return _("Drop Item to Adjacent Tile");
|
||||
case ACTION_BIONICS:
|
||||
return _("View/Activate Bionics");
|
||||
case ACTION_SORT_ARMOR:
|
||||
return _("Re-layer armour/clothing");
|
||||
case ACTION_WAIT:
|
||||
return _("Wait for Several Minutes");
|
||||
case ACTION_CRAFT:
|
||||
return _("Craft Items");
|
||||
case ACTION_RECRAFT:
|
||||
return _("Recraft last recipe");
|
||||
case ACTION_LONGCRAFT:
|
||||
return _("Craft as long as possible");
|
||||
case ACTION_CONSTRUCT:
|
||||
return _("Construct Terrain");
|
||||
case ACTION_DISASSEMBLE:
|
||||
return _("Disassemble items");
|
||||
case ACTION_SLEEP:
|
||||
return _("Sleep");
|
||||
case ACTION_CONTROL_VEHICLE:
|
||||
return _("Control Vehicle");
|
||||
case ACTION_TOGGLE_SAFEMODE:
|
||||
return _("Toggle Safemode");
|
||||
case ACTION_TOGGLE_AUTOSAFE:
|
||||
return _("Toggle Auto-Safemode");
|
||||
case ACTION_IGNORE_ENEMY:
|
||||
return _("Ignore Nearby Enemy");
|
||||
case ACTION_SAVE:
|
||||
return _("Save and Quit");
|
||||
case ACTION_QUICKSAVE:
|
||||
return _("Quicksave");
|
||||
case ACTION_QUIT:
|
||||
return _("Commit Suicide");
|
||||
case ACTION_PL_INFO:
|
||||
return _("View Player Info");
|
||||
case ACTION_MAP:
|
||||
return _("View Map");
|
||||
case ACTION_MISSIONS:
|
||||
return _("View Missions");
|
||||
case ACTION_FACTIONS:
|
||||
return _("View Factions");
|
||||
case ACTION_KILLS:
|
||||
return _("View Kills");
|
||||
case ACTION_MORALE:
|
||||
return _("View Morale");
|
||||
case ACTION_MESSAGES:
|
||||
return _("View Message Log");
|
||||
case ACTION_HELP:
|
||||
return _("View Help");
|
||||
case ACTION_DEBUG:
|
||||
return _("Debug Menu");
|
||||
case ACTION_DISPLAY_SCENT:
|
||||
return _("View Scentmap");
|
||||
case ACTION_TOGGLE_DEBUGMON:
|
||||
return _("Toggle Debug Messages");
|
||||
case ACTION_NULL:
|
||||
return _("No Action");
|
||||
}
|
||||
return "Someone forgot to name an action.";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#ifndef _ACTION_H_
|
||||
#define _ACTION_H_
|
||||
|
||||
enum action_id {
|
||||
ACTION_NULL = 0,
|
||||
// Movement
|
||||
ACTION_PAUSE,
|
||||
ACTION_MOVE_N,
|
||||
ACTION_MOVE_NE,
|
||||
ACTION_MOVE_E,
|
||||
ACTION_MOVE_SE,
|
||||
ACTION_MOVE_S,
|
||||
ACTION_MOVE_SW,
|
||||
ACTION_MOVE_W,
|
||||
ACTION_MOVE_NW,
|
||||
ACTION_MOVE_DOWN,
|
||||
ACTION_MOVE_UP,
|
||||
// Shift view
|
||||
ACTION_CENTER,
|
||||
ACTION_SHIFT_N,
|
||||
ACTION_SHIFT_NE,
|
||||
ACTION_SHIFT_E,
|
||||
ACTION_SHIFT_SE,
|
||||
ACTION_SHIFT_S,
|
||||
ACTION_SHIFT_SW,
|
||||
ACTION_SHIFT_W,
|
||||
ACTION_SHIFT_NW,
|
||||
// Environment Interaction
|
||||
ACTION_OPEN,
|
||||
ACTION_CLOSE,
|
||||
ACTION_SMASH,
|
||||
ACTION_EXAMINE,
|
||||
ACTION_PICKUP,
|
||||
ACTION_GRAB,
|
||||
ACTION_BUTCHER,
|
||||
ACTION_CHAT,
|
||||
ACTION_LOOK,
|
||||
ACTION_PEEK,
|
||||
ACTION_LIST_ITEMS,
|
||||
// Inventory Interaction (including quasi-inventories like bionics)
|
||||
ACTION_INVENTORY,
|
||||
ACTION_ADVANCEDINV,
|
||||
ACTION_COMPARE,
|
||||
ACTION_ORGANIZE,
|
||||
ACTION_USE,
|
||||
ACTION_USE_WIELDED,
|
||||
ACTION_WEAR,
|
||||
ACTION_TAKE_OFF,
|
||||
ACTION_EAT,
|
||||
ACTION_READ,
|
||||
ACTION_WIELD,
|
||||
ACTION_PICK_STYLE,
|
||||
ACTION_RELOAD,
|
||||
ACTION_UNLOAD,
|
||||
ACTION_THROW,
|
||||
ACTION_FIRE,
|
||||
ACTION_FIRE_BURST,
|
||||
ACTION_SELECT_FIRE_MODE,
|
||||
ACTION_DROP,
|
||||
ACTION_DIR_DROP,
|
||||
ACTION_BIONICS,
|
||||
ACTION_SORT_ARMOR,
|
||||
// Long-term / special actions
|
||||
ACTION_WAIT,
|
||||
ACTION_CRAFT,
|
||||
ACTION_RECRAFT,
|
||||
ACTION_LONGCRAFT,
|
||||
ACTION_CONSTRUCT,
|
||||
ACTION_DISASSEMBLE,
|
||||
ACTION_SLEEP,
|
||||
ACTION_CONTROL_VEHICLE,
|
||||
ACTION_TOGGLE_SAFEMODE,
|
||||
ACTION_TOGGLE_AUTOSAFE,
|
||||
ACTION_IGNORE_ENEMY,
|
||||
ACTION_SAVE,
|
||||
ACTION_QUICKSAVE,
|
||||
ACTION_QUIT,
|
||||
// Info Screens
|
||||
ACTION_PL_INFO,
|
||||
ACTION_MAP,
|
||||
ACTION_MISSIONS,
|
||||
ACTION_KILLS,
|
||||
ACTION_FACTIONS,
|
||||
ACTION_MORALE,
|
||||
ACTION_MESSAGES,
|
||||
ACTION_HELP,
|
||||
// Debug Functions
|
||||
ACTION_DEBUG,
|
||||
ACTION_DISPLAY_SCENT,
|
||||
ACTION_TOGGLE_DEBUGMON,
|
||||
NUM_ACTIONS
|
||||
};
|
||||
|
||||
action_id look_up_action(std::string ident);
|
||||
std::string action_ident(action_id);
|
||||
std::string action_name(action_id);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,276 @@
|
||||
#include "addiction.h"
|
||||
|
||||
void addict_effect(game *g, addiction &add)
|
||||
{
|
||||
int in = add.intensity;
|
||||
|
||||
switch (add.type) {
|
||||
case ADD_CIG:
|
||||
if (in > 20 || one_in((500 - 20 * in))) {
|
||||
g->add_msg(rng(0, 6) < in ? _("You need a cigarette.") : _("You could use a cigarette."));
|
||||
g->cancel_activity_query(_("You have a nicotine craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_NICOTINE, -15, -50);
|
||||
if (one_in(800 - 50 * in)) {
|
||||
g->u.fatigue++;
|
||||
}
|
||||
if (g->u.stim > -50 && one_in(400 - 20 * in)) {
|
||||
g->u.stim--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_CAFFEINE:
|
||||
g->u.moves -= 2;
|
||||
if (in > 20 || one_in((500 - 20 * in))) {
|
||||
g->add_msg(_("You want some caffeine."));
|
||||
g->cancel_activity_query(_("You have a caffeine craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_CAFFEINE, -5, -30);
|
||||
if (g->u.stim > -150 && rng(0, 10) < in) {
|
||||
g->u.stim--;
|
||||
}
|
||||
if (rng(8, 400) < in) {
|
||||
g->add_msg(_("Your hands start shaking... you need it bad!"));
|
||||
g->u.add_disease("shakes", 20);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_ALCOHOL:
|
||||
g->u.per_cur--;
|
||||
g->u.int_cur--;
|
||||
if (rng(40, 1200) <= in * 10) {
|
||||
g->u.health--;
|
||||
}
|
||||
if (one_in(20) && rng(0, 20) < in) {
|
||||
g->add_msg(_("You could use a drink."));
|
||||
g->cancel_activity_query(_("You have an alcohol craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120);
|
||||
} else if (rng(8, 300) < in) {
|
||||
g->add_msg(_("Your hands start shaking... you need a drink bad!"));
|
||||
g->cancel_activity_query(_("You have an alcohol craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_ALCOHOL, -35, -120);
|
||||
g->u.add_disease("shakes", 50);
|
||||
} else if (!g->u.has_disease("hallu") && rng(10, 1600) < in) {
|
||||
g->u.add_disease("hallu", 3600);
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_SLEEP:
|
||||
// No effects here--just in player::can_sleep()
|
||||
// EXCEPT! Prolong this addiction longer than usual.
|
||||
if (one_in(2) && add.sated < 0) {
|
||||
add.sated++;
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_PKILLER:
|
||||
if ((in >= 25 || int(g->turn) % (100 - in * 4) == 0) && g->u.pkill > 0) {
|
||||
g->u.pkill--; // Tolerance increases!
|
||||
}
|
||||
if (g->u.pkill >= 35) { // No further effects if we're doped up.
|
||||
add.sated = 0;
|
||||
} else {
|
||||
g->u.str_cur -= 1 + int(in / 7);
|
||||
g->u.per_cur--;
|
||||
g->u.dex_cur--;
|
||||
if (g->u.pain < in * 3) {
|
||||
g->u.pain++;
|
||||
}
|
||||
if (in >= 40 || one_in((1200 - 30 * in))) {
|
||||
g->u.health--;
|
||||
}
|
||||
if (one_in(20) && dice(2, 20) < in) {
|
||||
g->add_msg(_("Your hands start shaking... you need some painkillers."));
|
||||
g->cancel_activity_query(_("You have an opiate craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_OPIATE, -40, -200);
|
||||
g->u.add_disease("shakes", 20 + in * 5);
|
||||
} else if (one_in(20) && dice(2, 30) < in) {
|
||||
g->add_msg(_("You feel anxious. You need your painkillers!"));
|
||||
g->u.add_morale(MORALE_CRAVING_OPIATE, -30, -200);
|
||||
g->cancel_activity_query(_("You have a craving."));
|
||||
} else if (one_in(50) && dice(3, 50) < in) {
|
||||
g->add_msg(_("You throw up heavily!"));
|
||||
g->cancel_activity_query(_("Throwing up."));
|
||||
g->u.vomit(g);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_SPEED: {
|
||||
int move_pen = in * 5;
|
||||
if (move_pen > 30) {
|
||||
move_pen = 30;
|
||||
}
|
||||
g->u.moves -= move_pen;
|
||||
g->u.int_cur--;
|
||||
g->u.str_cur--;
|
||||
if (g->u.stim > -100 && (in >= 20 || int(g->turn) % (100 - in * 5) == 0)) {
|
||||
g->u.stim--;
|
||||
}
|
||||
if (rng(0, 150) <= in) {
|
||||
g->u.health--;
|
||||
}
|
||||
if (dice(2, 100) < in) {
|
||||
g->add_msg(_("You feel depressed. Speed would help."));
|
||||
g->cancel_activity_query(_("You have a speed craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_SPEED, -25, -200);
|
||||
} else if (one_in(10) && dice(2, 80) < in) {
|
||||
g->add_msg(_("Your hands start shaking... you need a pick-me-up."));
|
||||
g->cancel_activity_query(_("You have a speed craving."));
|
||||
g->u.add_morale(MORALE_CRAVING_SPEED, -25, -200);
|
||||
g->u.add_disease("shakes", in * 20);
|
||||
} else if (one_in(50) && dice(2, 100) < in) {
|
||||
g->add_msg(_("You stop suddenly, feeling bewildered."));
|
||||
g->cancel_activity();
|
||||
g->u.moves -= 300;
|
||||
} else if (!g->u.has_disease("hallu") && one_in(20) && 8 + dice(2, 80) < in)
|
||||
g->u.add_disease("hallu", 3600);
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_COKE:
|
||||
g->u.int_cur--;
|
||||
g->u.per_cur--;
|
||||
if (in >= 30 || one_in((900 - 30 * in))) {
|
||||
g->add_msg(_("You feel like you need a bump."));
|
||||
g->cancel_activity_query(_("You have a craving for cocaine."));
|
||||
g->u.add_morale(MORALE_CRAVING_COCAINE, -20, -250);
|
||||
}
|
||||
if (dice(2, 80) <= in) {
|
||||
g->add_msg(_("You feel like you need a bump."));
|
||||
g->cancel_activity_query(_("You have a craving for cocaine."));
|
||||
g->u.add_morale(MORALE_CRAVING_COCAINE, -20, -250);
|
||||
if (g->u.stim > -150) {
|
||||
g->u.stim -= 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ADD_CRACK:
|
||||
g->u.int_cur--;
|
||||
g->u.per_cur--;
|
||||
if (in >= 30 || one_in((900 - 30 * in))) {
|
||||
g->add_msg(_("You're shivering, you need some crack."));
|
||||
g->cancel_activity_query(_("You have a craving for crack."));
|
||||
g->u.add_morale(MORALE_CRAVING_CRACK, -80, -250);
|
||||
}
|
||||
if (dice(2, 80) <= in) {
|
||||
g->add_msg(_("You're shivering, you need some crack."));
|
||||
g->cancel_activity_query(_("You have a craving for crack."));
|
||||
g->u.add_morale(MORALE_CRAVING_CRACK, -80, -250);
|
||||
if (g->u.stim > -150) {
|
||||
g->u.stim -= 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of an addiction. It should be able to finish the sentence
|
||||
* "Became addicted to ______".
|
||||
*/
|
||||
std::string addiction_type_name(add_type cur)
|
||||
{
|
||||
switch(cur) {
|
||||
case ADD_CIG: return _("nicotine");
|
||||
case ADD_CAFFEINE: return _("caffeine");
|
||||
case ADD_ALCOHOL: return _("alcohol");
|
||||
case ADD_SLEEP: return _("sleeping pills");
|
||||
case ADD_PKILLER: return _("opiates");
|
||||
case ADD_SPEED: return _("amphetamine");
|
||||
case ADD_COKE: return _("cocaine");
|
||||
case ADD_CRACK: return _("crack cocaine");
|
||||
default: return "bugs in addiction.cpp";
|
||||
}
|
||||
}
|
||||
|
||||
std::string addiction_name(addiction cur)
|
||||
{
|
||||
switch (cur.type) {
|
||||
case ADD_CIG: return _("Nicotine Withdrawal");
|
||||
case ADD_CAFFEINE: return _("Caffeine Withdrawal");
|
||||
case ADD_ALCOHOL: return _("Alcohol Withdrawal");
|
||||
case ADD_SLEEP: return _("Sleeping Pill Dependance");
|
||||
case ADD_PKILLER: return _("Opiate Withdrawal");
|
||||
case ADD_SPEED: return _("Amphetamine Withdrawal");
|
||||
case ADD_COKE: return _("Cocaine Withdrawal");
|
||||
case ADD_CRACK: return _("Crack Cocaine Withdrawal");
|
||||
default: return "Erroneous addiction";
|
||||
}
|
||||
}
|
||||
|
||||
morale_type addiction_craving(add_type cur)
|
||||
{
|
||||
switch (cur) {
|
||||
case ADD_CIG: return MORALE_CRAVING_NICOTINE;
|
||||
case ADD_CAFFEINE: return MORALE_CRAVING_CAFFEINE;
|
||||
case ADD_ALCOHOL: return MORALE_CRAVING_ALCOHOL;
|
||||
case ADD_PKILLER: return MORALE_CRAVING_OPIATE;
|
||||
case ADD_SPEED: return MORALE_CRAVING_SPEED;
|
||||
case ADD_COKE: return MORALE_CRAVING_COCAINE;
|
||||
case ADD_CRACK: return MORALE_CRAVING_CRACK;
|
||||
default: return MORALE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
add_type addiction_type(std::string name)
|
||||
{
|
||||
if (name == "nicotine")
|
||||
return ADD_CIG;
|
||||
else if (name == "caffeine")
|
||||
return ADD_CAFFEINE;
|
||||
else if (name == "alcohol")
|
||||
return ADD_ALCOHOL;
|
||||
else if (name == "sleeping pill")
|
||||
return ADD_SLEEP;
|
||||
else if (name == "opiate")
|
||||
return ADD_PKILLER;
|
||||
else if (name == "amphetamine")
|
||||
return ADD_SPEED;
|
||||
else if (name == "cocaine")
|
||||
return ADD_COKE;
|
||||
else if (name == "crack")
|
||||
return ADD_CRACK;
|
||||
else
|
||||
return ADD_NULL;
|
||||
}
|
||||
|
||||
std::string addiction_text(addiction cur)
|
||||
{
|
||||
int strpen = 1 + int(cur.intensity / 7);
|
||||
switch (cur.type) {
|
||||
case ADD_CIG:
|
||||
return _("Intelligence - 1; Occasional cravings");
|
||||
|
||||
case ADD_CAFFEINE:
|
||||
return _("Strength - 1; Slight sluggishness; Occasional cravings");
|
||||
|
||||
case ADD_ALCOHOL:
|
||||
return _("\
|
||||
Perception - 1; Intelligence - 1; Occasional Cravings;\n\
|
||||
Risk of delirium tremens");
|
||||
|
||||
case ADD_SLEEP:
|
||||
return _("You may find it difficult to sleep without medication.");
|
||||
|
||||
case ADD_PKILLER:
|
||||
{
|
||||
return string_format(_(
|
||||
"Strength - %d; Perception - 1; Dexterity - 1;\n"
|
||||
"Depression and physical pain to some degree. Frequent cravings. Vomiting."), strpen);
|
||||
}
|
||||
|
||||
case ADD_SPEED:
|
||||
return _("Strength - 1; Intelligence - 1;\n\
|
||||
Movement rate reduction. Depression. Weak immune system. Frequent cravings.");
|
||||
|
||||
case ADD_COKE:
|
||||
return _("Perception - 1; Intelligence - 1; Frequent cravings.");
|
||||
|
||||
case ADD_CRACK:
|
||||
return _("Perception - 2; Intelligence - 2; Frequent cravings.");
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _ADDICTION_H_
|
||||
#define _ADDICTION_H_
|
||||
|
||||
#include "rng.h"
|
||||
#include "game.h"
|
||||
#include "morale.h"
|
||||
#include <sstream>
|
||||
|
||||
#define MIN_ADDICTION_LEVEL 3 // Minimum intensity before effects are seen
|
||||
|
||||
void addict_effect(game *g, addiction &add);
|
||||
|
||||
std::string addiction_type_name(add_type cur);
|
||||
|
||||
std::string addiction_name(addiction cur);
|
||||
|
||||
morale_type addiction_craving(add_type cur);
|
||||
|
||||
add_type addiction_type(std::string name);
|
||||
|
||||
std::string addiction_text(addiction cur);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,124 @@
|
||||
#ifndef _ADVANCED_INV_H
|
||||
#define _ADVANCED_INV_H_
|
||||
#include "output.h"
|
||||
#include "game.h"
|
||||
#include <string>
|
||||
struct advanced_inv_area {
|
||||
int id;
|
||||
int hscreenx;
|
||||
int hscreeny;
|
||||
int offx;
|
||||
int offy;
|
||||
int x;
|
||||
int y;
|
||||
std::string name;
|
||||
std::string shortname;
|
||||
bool canputitems;
|
||||
vehicle *veh;
|
||||
int vstor;
|
||||
int size;
|
||||
std::string desc;
|
||||
int volume, weight;
|
||||
int max_size, max_volume;
|
||||
};
|
||||
|
||||
// for printing items in environment
|
||||
struct advanced_inv_listitem {
|
||||
int idx;
|
||||
int area;
|
||||
item *it;
|
||||
std::string name;
|
||||
bool autopickup;
|
||||
int stacks;
|
||||
int volume;
|
||||
int weight;
|
||||
int cat;
|
||||
};
|
||||
|
||||
class advanced_inventory_pane {
|
||||
public:
|
||||
int pos;
|
||||
int area, offx, offy, size, vstor; // quick lookup later
|
||||
int index, max_page, max_index, page;
|
||||
std::string area_string;
|
||||
int sortby;
|
||||
int issrc;
|
||||
vehicle *veh;
|
||||
WINDOW *window;
|
||||
std::vector<advanced_inv_listitem> items;
|
||||
int numcats;
|
||||
std::string filter;
|
||||
bool recalc;
|
||||
bool redraw;
|
||||
std::map<std::string, bool> filtercache;
|
||||
advanced_inventory_pane() {
|
||||
offx = 0; offy = 0; size = 0; vstor = -1;
|
||||
index = 0; max_page = 0; max_index = 0; page = 0;
|
||||
area_string = _("Initializing...");
|
||||
sortby = 1; issrc = 0; veh = NULL; window = NULL;
|
||||
items.clear();
|
||||
numcats = 0; filter="";
|
||||
filtercache.clear();
|
||||
}
|
||||
};
|
||||
|
||||
class advanced_inventory
|
||||
{
|
||||
public:
|
||||
game * g;
|
||||
player * p;
|
||||
|
||||
const int head_height;
|
||||
const int min_w_height;
|
||||
const int min_w_width;
|
||||
const int max_w_width;
|
||||
const int left;
|
||||
const int right;
|
||||
const int isinventory;
|
||||
const int isall;
|
||||
|
||||
bool checkshowmsg;
|
||||
bool showmsg;
|
||||
|
||||
int itemsPerPage;
|
||||
int w_height;
|
||||
int w_width;
|
||||
|
||||
int headstart;
|
||||
int colstart;
|
||||
|
||||
// itemsPerPage=getmaxy(left_window)-ADVINVOFS;
|
||||
// todo: awaiting ui::menu // last_tmpdest=-1;
|
||||
bool exit;// = false;
|
||||
bool redraw;// = true;
|
||||
bool recalc;// = true;
|
||||
int lastCh;// = 0;
|
||||
|
||||
int src;// = left; // the active screen , 0 for left , 1 for right.
|
||||
int dest;// = right;
|
||||
int max_inv;// = inv_chars.size() - u.worn.size() - ( u.is_armed() || u.weapon.is_style() ? 1 : 0 );
|
||||
bool examineScroll;// = false;
|
||||
bool filter_edit;
|
||||
|
||||
advanced_inventory_pane panes[2];
|
||||
advanced_inv_area squares[11];
|
||||
|
||||
advanced_inventory() :
|
||||
head_height(5),
|
||||
min_w_height(10),
|
||||
min_w_width(FULL_SCREEN_WIDTH),
|
||||
max_w_width(120),
|
||||
left(0),
|
||||
right(1),
|
||||
isinventory(0),
|
||||
isall(10) {
|
||||
}
|
||||
void display(game *gp, player *pp);
|
||||
void print_items(advanced_inventory_pane &pane, bool active);
|
||||
void recalc_pane(int i);
|
||||
void redraw_pane(int i);
|
||||
void init(game *gp, player *pp);
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
!config/
|
||||
!deps*.zip
|
||||
*.iml
|
||||
.cxx
|
||||
.DS_Store
|
||||
.externalNativeBuild
|
||||
.gradle
|
||||
/.idea/libraries
|
||||
/.idea/workspace.xml
|
||||
/app/jni/SDL2
|
||||
/app/jni/SDL2_image
|
||||
/app/jni/SDL2_mixer
|
||||
/app/jni/SDL2_ttf
|
||||
/app/jni/libhidapi
|
||||
/app/jni/lua
|
||||
/app/jni/mpg-123
|
||||
/app/build
|
||||
/app/src/main/assetsWinHost
|
||||
/build
|
||||
/captures
|
||||
/local.properties
|
||||
@@ -1,406 +0,0 @@
|
||||
import org.gradle.internal.os.OperatingSystem;
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
//options.compilerArgs << "-Xlint:deprecation"
|
||||
}
|
||||
|
||||
def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY');
|
||||
def buildAsApplication = !buildAsLibrary
|
||||
if (buildAsApplication) {
|
||||
apply plugin: 'com.android.application'
|
||||
} else {
|
||||
apply plugin: 'com.android.library'
|
||||
}
|
||||
|
||||
def localProperties = new Properties()
|
||||
def localPropertiesFile = rootProject.file('local.properties')
|
||||
if (localPropertiesFile.exists()) {
|
||||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||||
localProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def keystorePropertiesFilename = 'keystore.properties'
|
||||
if (localProperties.getProperty('keystorePropertiesFilename') != null) {
|
||||
keystorePropertiesFilename = localProperties.getProperty("keystorePropertiesFilename")
|
||||
}
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file(keystorePropertiesFilename)
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystorePropertiesFile.withReader('UTF-8') { reader ->
|
||||
keystoreProperties.load(reader)
|
||||
}
|
||||
}
|
||||
|
||||
def njobs = getProperty("j")
|
||||
if (localProperties.getProperty('j') != null) {
|
||||
njobs = localProperties.getProperty("j")
|
||||
}
|
||||
|
||||
def localize = getProperty("localize").toBoolean()
|
||||
if (localProperties.getProperty('localize') != null) {
|
||||
localize = localProperties.getProperty("localize").toBoolean()
|
||||
}
|
||||
|
||||
def abi_arm_32 = getProperty("abi_arm_32").toBoolean()
|
||||
if (localProperties.getProperty('abi_arm_32') != null) {
|
||||
abi_arm_32 = localProperties.getProperty("abi_arm_32").toBoolean()
|
||||
}
|
||||
|
||||
def abi_arm_64 = getProperty("abi_arm_64").toBoolean()
|
||||
if (localProperties.getProperty('abi_arm_64') != null) {
|
||||
abi_arm_64 = localProperties.getProperty("abi_arm_64").toBoolean()
|
||||
}
|
||||
|
||||
def abi_x86_32 = getProperty("abi_x86_32").toBoolean()
|
||||
if (localProperties.getProperty('abi_x86_32') != null) {
|
||||
abi_x86_32 = localProperties.getProperty("abi_x86_32").toBoolean()
|
||||
}
|
||||
|
||||
def abi_x86_64 = getProperty("abi_x86_64").toBoolean()
|
||||
if (localProperties.getProperty('abi_x86_64') != null) {
|
||||
abi_x86_64 = localProperties.getProperty("abi_x86_64").toBoolean()
|
||||
}
|
||||
|
||||
def deps = getProperty("deps")
|
||||
if (localProperties.getProperty('deps') != null) {
|
||||
deps = localProperties.getProperty("deps")
|
||||
}
|
||||
|
||||
def override_version = getProperty("override_version")
|
||||
if (localProperties.getProperty('override_version') != null) {
|
||||
override_version = localProperties.getProperty("override_version")
|
||||
}
|
||||
|
||||
def version_header_path = getProperty("version_header_path")
|
||||
if (localProperties.getProperty('version_header_path') != null) {
|
||||
version_header_path = localProperties.getProperty("version_header_path")
|
||||
}
|
||||
|
||||
def override_compileSdkVersion = getProperty("override_compileSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_compileSdkVersion') != null) {
|
||||
override_compileSdkVersion = localProperties.getProperty("override_compileSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_minSdkVersion = getProperty("override_minSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_minSdkVersion') != null) {
|
||||
override_minSdkVersion = localProperties.getProperty("override_minSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_targetSdkVersion = getProperty("override_targetSdkVersion").toInteger()
|
||||
if (localProperties.getProperty('override_targetSdkVersion') != null) {
|
||||
override_targetSdkVersion = localProperties.getProperty("override_targetSdkVersion").toInteger()
|
||||
}
|
||||
|
||||
def override_ndkBuildAppPlatform = getProperty("override_ndkBuildAppPlatform")
|
||||
if (localProperties.getProperty('override_ndkBuildAppPlatform') != null) {
|
||||
override_ndkBuildAppPlatform = localProperties.getProperty("override_ndkBuildAppPlatform")
|
||||
}
|
||||
|
||||
println("Using [ njobs]: $njobs")
|
||||
println("Using [ localize]: $localize")
|
||||
println("Using [ deps]: $deps")
|
||||
println("Using [ override_version]: $override_version")
|
||||
println("Using [version_header_path]: $version_header_path")
|
||||
println("Using [ compileSdkVersion]: $override_compileSdkVersion")
|
||||
println("Using [ minSdkVersion]: $override_minSdkVersion")
|
||||
println("Using [ targetSdkVersion]: $override_targetSdkVersion")
|
||||
println("Using [ndkBuildAppPlatform]: $override_ndkBuildAppPlatform")
|
||||
println("Using [ abi_arm_32]: $abi_arm_32")
|
||||
println("Using [ abi_arm_64]: $abi_arm_64")
|
||||
println("Using [ abi_x86_32]: $abi_x86_32")
|
||||
println("Using [ abi_x86_64]: $abi_x86_64")
|
||||
|
||||
if (!abi_arm_32 && !abi_arm_64 && !abi_x86_32 && !abi_x86_64) {
|
||||
throw new GradleException("All supported ABI properties are set to false!")
|
||||
}
|
||||
if (!file(deps).exists()) {
|
||||
throw new GradleException("Dependencies file does not exist:" + deps)
|
||||
}
|
||||
|
||||
if (!override_version.isEmpty()) {
|
||||
if (version_header_path.isEmpty()) {
|
||||
throw new GradleException("`version_header_path` cannot be empty when `override_version` is not empty")
|
||||
} else {
|
||||
println("Overriding version number to $override_version using path $version_header_path")
|
||||
}
|
||||
}
|
||||
|
||||
def projectRoot = './../..'
|
||||
def assetsDir = 'src/main/assets'
|
||||
def assetsDirWindows = 'src/main/assetsWinHost'
|
||||
|
||||
task unzipDeps(type: Copy) {
|
||||
println("Using dependencies file: $deps")
|
||||
def zipFile = new File("$deps")
|
||||
def outputDir = new File('.')
|
||||
from zipTree(zipFile)
|
||||
into outputDir
|
||||
}
|
||||
|
||||
task makeLocalization(type: Exec) {
|
||||
def args = []
|
||||
if (localize) {
|
||||
println("Building with localization")
|
||||
switch (OperatingSystem.current()) {
|
||||
case OperatingSystem.LINUX:
|
||||
args = ['make', 'localization', 'LANGUAGES=all']
|
||||
break
|
||||
case OperatingSystem.WINDOWS:
|
||||
args = ['sh.exe', 'lang/compile_mo.sh']
|
||||
break
|
||||
default:
|
||||
args = ['echo', 'Building without localization']
|
||||
break
|
||||
}
|
||||
} else {
|
||||
args = ['echo', 'Building without localization']
|
||||
if (OperatingSystem.current() == OperatingSystem.WINDOWS) {
|
||||
args = ['cmd.exe', '/k'] + args
|
||||
}
|
||||
}
|
||||
workingDir projectRoot
|
||||
commandLine args
|
||||
}
|
||||
|
||||
task generateVersionHeader() {
|
||||
// this taks imitates `make version` while respecting version_header_path
|
||||
if (override_version.isEmpty()) {
|
||||
println("Generating version number to $version_header_path")
|
||||
def output = new ByteArrayOutputStream()
|
||||
exec {
|
||||
workingDir projectRoot
|
||||
commandLine 'git', 'describe', '--tags', '--always', '--dirty', '--match', '"[0-9A-Z]*.[0-9A-Z]*"'
|
||||
standardOutput output
|
||||
}
|
||||
override_version = output.toString()
|
||||
override_version = override_version.split()[0] // strip whitespaces
|
||||
} else {
|
||||
println("Overriding version number to $override_version")
|
||||
}
|
||||
|
||||
def define = "// NOLINT(cata-header-guard)\n#define VERSION \"$override_version\"\n"
|
||||
def versionHeader = new File("$version_header_path")
|
||||
if (!versionHeader.exists() || versionHeader.text != define) {
|
||||
versionHeader.text = define
|
||||
}
|
||||
}
|
||||
|
||||
task createWindowsJunctionLinks() {
|
||||
onlyIf {
|
||||
OperatingSystem.current() == OperatingSystem.WINDOWS
|
||||
}
|
||||
|
||||
doLast {
|
||||
def mkJunction = { to, from ->
|
||||
def errOut = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'cmd', '/k', "mklink /J $to $from"
|
||||
errorOutput errOut
|
||||
standardOutput new ByteArrayOutputStream() // don't print the output
|
||||
}
|
||||
def errString = errOut.toString()
|
||||
if (!errString.isEmpty() && !errString.endsWith('already exists.\r\n')) {
|
||||
// we have an error that is not 'file already exists'
|
||||
errString = errString.substring(0, errString.size() - 2) // discard \r\n
|
||||
throw new GradleException("$errString")
|
||||
}
|
||||
}
|
||||
|
||||
println("Creating junctions for the assets")
|
||||
|
||||
mkdir assetsDirWindows
|
||||
mkdir "$assetsDirWindows/lang"
|
||||
|
||||
def rootDir = projectRoot.replace('/', '\\')
|
||||
def unixAssetsDir = assetsDir.replace('/', '\\')
|
||||
def winAssetsDir = assetsDirWindows.replace('/', '\\')
|
||||
|
||||
mkJunction("$winAssetsDir\\android", "$unixAssetsDir\\android")
|
||||
for (dir in ['data', 'gfx', 'lang\\mo']) {
|
||||
mkJunction("$winAssetsDir\\$dir", "$rootDir\\$dir")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preBuild.dependsOn unzipDeps
|
||||
preBuild.dependsOn makeLocalization
|
||||
preBuild.dependsOn generateVersionHeader
|
||||
preBuild.dependsOn createWindowsJunctionLinks
|
||||
createWindowsJunctionLinks.dependsOn makeLocalization
|
||||
|
||||
android {
|
||||
compileSdkVersion override_compileSdkVersion
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion override_minSdkVersion
|
||||
targetSdkVersion override_targetSdkVersion
|
||||
versionCode Integer.valueOf(System.env.UPSTREAM_BUILD_NUMBER ?: 1)
|
||||
versionName new File("$version_header_path").text.split('\"')[1]
|
||||
if (buildAsApplication) {
|
||||
applicationId "com.cleverraven.cataclysmdda"
|
||||
setProperty("archivesBaseName", "cataclysmdda-" + versionName)
|
||||
}
|
||||
resValue "string", "app_name", "Cataclysm DDA"
|
||||
|
||||
splits {
|
||||
// Configures multiple APKs based on ABI.
|
||||
abi {
|
||||
// Enables building multiple APKs per ABI.
|
||||
enable true
|
||||
// Resets the list of ABIs that Gradle should create APKs for to none.
|
||||
reset()
|
||||
// Specifies a list of ABIs that Gradle should create APKs for.
|
||||
if (abi_arm_32) {
|
||||
include "armeabi-v7a"
|
||||
}
|
||||
if (abi_arm_64) {
|
||||
include "arm64-v8a"
|
||||
}
|
||||
if (abi_x86_32) {
|
||||
include "x86"
|
||||
}
|
||||
if (abi_x86_64) {
|
||||
include "x86_64"
|
||||
}
|
||||
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
|
||||
universalApk false
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=$override_ndkBuildAppPlatform", "-j$njobs"
|
||||
}
|
||||
}
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
flavorDimensions "version"
|
||||
|
||||
productFlavors {
|
||||
stable {
|
||||
dimension "version"
|
||||
resValue "string", "app_name", "Cataclysm DDA"
|
||||
}
|
||||
experimental {
|
||||
dimension "version"
|
||||
applicationIdSuffix ".experimental"
|
||||
resValue "string", "app_name", "Cataclysm DDA (experimental)"
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystoreProperties.getProperty('storeFile') != null) {
|
||||
if (file(keystoreProperties.getProperty('storeFile')).exists()) {
|
||||
release {
|
||||
storeFile file(keystoreProperties.getProperty("storeFile"))
|
||||
storePassword keystoreProperties.getProperty("storePassword")
|
||||
keyAlias keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword keystoreProperties.getProperty("keyPassword")
|
||||
}
|
||||
} else {
|
||||
throw new GradleException("Keystore file " + keystoreProperties.getProperty("storeFile") + " was not found.\n")
|
||||
}
|
||||
}
|
||||
if (keystoreProperties.getProperty('debug_storeFile') != null) {
|
||||
if (file(keystoreProperties.getProperty('debug_storeFile')).exists()) {
|
||||
debug {
|
||||
storeFile file(keystoreProperties.getProperty("debug_storeFile"))
|
||||
storePassword keystoreProperties.getProperty("debug_storePassword")
|
||||
keyAlias keystoreProperties.getProperty("debug_keyAlias")
|
||||
keyPassword keystoreProperties.getProperty("debug_keyPassword")
|
||||
}
|
||||
} else {
|
||||
throw new GradleException("Keystore file " + keystoreProperties.getProperty("debug_storeFile") + " was not found.\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (signingConfigs.hasProperty("release")) {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
cFlags "-DNDEBUG", "-DRELEASE", "-Os", "-g"
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
debugSymbolLevel 'SYMBOL_TABLE'
|
||||
}
|
||||
}
|
||||
|
||||
debug {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
if (signingConfigs.hasProperty("debug")) {
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
cFlags "-g"
|
||||
}
|
||||
}
|
||||
ndk {
|
||||
debugSymbolLevel 'FULL'
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
|
||||
sourceSets.main {
|
||||
jniLibs.srcDir 'libs'
|
||||
}
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
path 'jni/Android.mk'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
if (OperatingSystem.current() == OperatingSystem.WINDOWS) {
|
||||
sourceSets.main.assets.srcDirs = ['src/main/assetsWinHost']
|
||||
}
|
||||
|
||||
if (buildAsLibrary) {
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith(".aar")) {
|
||||
def fileName = "$applicationId.aar";
|
||||
output.outputFile = new File(outputFile.parent, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs = ['src/main/java']
|
||||
}
|
||||
resources {
|
||||
srcDirs = ['src/main/res']
|
||||
}
|
||||
}
|
||||
stable {
|
||||
}
|
||||
experimental {
|
||||
resources {
|
||||
srcDirs = ['src/experimental/res']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api fileTree(include: ['*.jar'], dir: 'libs')
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Reference: https://developer.android.com/ndk/guides/android_mk.html
|
||||
|
||||
include $(call all-subdir-makefiles)
|
||||
@@ -1,17 +0,0 @@
|
||||
# Reference: https://developer.android.com/ndk/guides/application_mk.html
|
||||
|
||||
# See CPLUSPLUS-SUPPORT.html in the NDK documentation for more information
|
||||
APP_STL := c++_shared
|
||||
APP_CPPFLAGS += -std=c++14
|
||||
ifneq ($(OS),Windows_NT)
|
||||
APP_LDFLAGS += -fuse-ld=gold
|
||||
endif
|
||||
|
||||
# Do not specify APP_OPTIM here, it is done through ndk-build NDK_DEBUG=0/1 setting instead
|
||||
# See https://developer.android.com/ndk/guides/ndk-build.html#dvr
|
||||
#APP_OPTIM := debug
|
||||
#APP_OPTIM := release
|
||||
|
||||
# Min SDK level
|
||||
APP_PLATFORM=android-16
|
||||
|
||||
@@ -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_
|
||||
@@ -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)
|
||||
@@ -1,17 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in [sdk]/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
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>
|
||||
|
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>
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.cleverraven.cataclysmdda"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:allowBackup="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true"
|
||||
android:isGame="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
|
||||
-->
|
||||
|
||||
<activity android:name="SplashScreen"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleInstance"
|
||||
android:keepScreenOn="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="CataclysmDDA"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleInstance"
|
||||
android:keepScreenOn="true"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:configChanges="keyboardHidden|keyboard|orientation|screenSize|navigation"
|
||||
>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 8.5 KiB |
@@ -1 +0,0 @@
|
||||
../../../../../data
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../gfx
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../lang/mo
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.cleverraven.cataclysmdda;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
import android.os.Vibrator;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
public class CataclysmDDA extends SDLActivity {
|
||||
private static final String TAG = "CDDA";
|
||||
|
||||
public void vibrate(int duration) {
|
||||
try {
|
||||
Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
|
||||
v.vibrate(duration);
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void toast(final String message) {
|
||||
try {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHardwareKeyboardAvailable() {
|
||||
return getResources().getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY;
|
||||
}
|
||||
|
||||
private float getDisplayDensity() {
|
||||
return getResources().getDisplayMetrics().density;
|
||||
}
|
||||
|
||||
public void show_sdl_surface() {
|
||||
try {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
mLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} catch(Exception e) {
|
||||
System.err.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDefaultSetting(final String settingsName, boolean defaultValue) {
|
||||
return PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean(settingsName, defaultValue);
|
||||
}
|
||||
|
||||
public String getSystemLang() {
|
||||
return getResources().getConfiguration().locale.toLanguageTag().replace('-', '_');
|
||||
}
|
||||
}
|
||||
@@ -1,401 +0,0 @@
|
||||
package com.cleverraven.cataclysmdda;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.AssetManager;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
public class SplashScreen extends Activity {
|
||||
private static final String TAG = "Splash";
|
||||
private static final int INSTALL_DIALOG_ID = 0;
|
||||
private ProgressDialog installDialog;
|
||||
|
||||
public CharSequence[] mSettingsNames;
|
||||
public boolean[] mSettingsValues = { false, false, true };
|
||||
|
||||
private String getVersionName() {
|
||||
try {
|
||||
Context context = getApplicationContext();
|
||||
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||
return pInfo.versionName;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
|
||||
private void showCrashAlert() {
|
||||
String externalFilesDir = getExternalFilesDir(null).getPath();
|
||||
File crashAlertPrompt = new File(externalFilesDir + "/config/crash.log.prompt");
|
||||
try {
|
||||
crashAlertPrompt.delete();
|
||||
if(crashAlertPrompt.exists()) { // Sometimes .delete() doesn't really delete the file and I don't know why
|
||||
crashAlertPrompt.getCanonicalFile().delete();
|
||||
}
|
||||
} catch(IOException e) {
|
||||
return;
|
||||
}
|
||||
File crashLog = new File(externalFilesDir + "/config/crash.log");
|
||||
StringBuilder text = new StringBuilder();
|
||||
text.append(getString(R.string.crashMessage));
|
||||
text.append("\n\n");
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(crashLog));
|
||||
String line;
|
||||
while((line = br.readLine()) != null) {
|
||||
text.append(line);
|
||||
text.append("\n");
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
final String message = text.toString();
|
||||
this.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
AlertDialog errorAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle(getString(R.string.crashAlert))
|
||||
.setCancelable(false)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
SplashScreen.this.startGameActivity(false);
|
||||
}
|
||||
}).create();
|
||||
errorAlert.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Log.e(TAG, "onCreate()");
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Start the game if already installed, otherwise start installing...
|
||||
if (getVersionName().equals(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", ""))) {
|
||||
// Show an alert box if the game crashed last time
|
||||
String externalFilesDir = getExternalFilesDir(null).getPath();
|
||||
File crashAlertPrompt = new File(externalFilesDir + "/config/crash.log.prompt");
|
||||
if(crashAlertPrompt.exists()) {
|
||||
showCrashAlert();
|
||||
} else {
|
||||
startGameActivity(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
new InstallProgramTask().execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int id) {
|
||||
switch (id) {
|
||||
case INSTALL_DIALOG_ID:
|
||||
installDialog = new ProgressDialog(this);
|
||||
installDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
boolean clean_install = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("installed", "").isEmpty();
|
||||
installDialog.setTitle(getString(clean_install ? R.string.installTitle : R.string.upgradeTitle));
|
||||
installDialog.setIndeterminate(true);
|
||||
installDialog.setCancelable(false);
|
||||
return installDialog;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void startGameActivity(boolean delay) {
|
||||
if (!delay) {
|
||||
runOnUiThread(new StartGameRunnable());
|
||||
}
|
||||
else {
|
||||
// Wait 1.5 seconds, then start game
|
||||
Timer timer = new Timer();
|
||||
TimerTask gameStartTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
runOnUiThread(new StartGameRunnable());
|
||||
}
|
||||
};
|
||||
timer.schedule(gameStartTask, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
private final class StartGameRunnable implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
Intent intent = new Intent(SplashScreen.this, CataclysmDDA.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
overridePendingTransition(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private class InstallProgramTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
private final List<String> PRESERVE_SUBFOLDERS = Arrays.asList("sound", "mods", "gfx"); // don't delete custom subfolders under these folders
|
||||
private final List<String> PRESERVE_FOLDERS = Arrays.asList("font"); // don't delete this folder
|
||||
private final List<String> PRESERVE_FILES = Arrays.asList("user-default-mods.json"); // don't delete this file
|
||||
|
||||
private int totalFiles = 0;
|
||||
private int installedFiles = 0;
|
||||
|
||||
private AlertDialog installationAlert;
|
||||
private AlertDialog settingsAlert;
|
||||
private AlertDialog helpAlert;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
installationAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle("Installation Failed")
|
||||
.setCancelable(false)
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
SplashScreen.this.finish();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
AssetManager assetManager = getAssets();
|
||||
try {
|
||||
totalFiles = countTotalAssets(assetManager, "data") +
|
||||
countTotalAssets(assetManager, "gfx") +
|
||||
countTotalAssets(assetManager, "lang");
|
||||
showDialog(INSTALL_DIALOG_ID);
|
||||
} catch(Exception e) {
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
installationAlert.show();
|
||||
}
|
||||
|
||||
helpAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle(getString(R.string.helpTitle))
|
||||
.setCancelable(false)
|
||||
.setMessage(getString(R.string.helpMessage))
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
settingsAlert.show();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
|
||||
mSettingsNames = new CharSequence[] {
|
||||
getString(R.string.softwareRendering),
|
||||
getString(R.string.forceFullscreen),
|
||||
getString(R.string.trapBackButton)
|
||||
};
|
||||
|
||||
settingsAlert = new AlertDialog.Builder(SplashScreen.this)
|
||||
.setTitle(getString(R.string.settings))
|
||||
.setMultiChoiceItems(SplashScreen.this.mSettingsNames, SplashScreen.this.mSettingsValues, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
SplashScreen.this.mSettingsValues[which] = isChecked;
|
||||
}})
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(getString(R.string.startGame), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Software rendering", SplashScreen.this.mSettingsValues[0]).commit();
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Force fullscreen", SplashScreen.this.mSettingsValues[1]).commit();
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putBoolean("Trap Back button", SplashScreen.this.mSettingsValues[2]).commit();
|
||||
SplashScreen.this.startGameActivity(false);
|
||||
return;
|
||||
}
|
||||
})
|
||||
.setNeutralButton(getString(R.string.showHelp), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
helpAlert.show();
|
||||
return;
|
||||
}
|
||||
}).create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
if (installDialog != null) {
|
||||
installDialog.setIndeterminate(false);
|
||||
installDialog.setMax(totalFiles);
|
||||
}
|
||||
publishProgress(installedFiles);
|
||||
|
||||
AssetManager assetManager = getAssets();
|
||||
String externalFilesDir = getExternalFilesDir(null).getPath();
|
||||
|
||||
try {
|
||||
// Clear out the old data if it exists (but preserve custom folders + files)
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/data"));
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/gfx"));
|
||||
deleteRecursive(assetManager, externalFilesDir, new File(externalFilesDir + "/lang"));
|
||||
|
||||
// Install the new data over the top
|
||||
copyAssetFolder(assetManager, "data", externalFilesDir + "/data");
|
||||
copyAssetFolder(assetManager, "gfx", externalFilesDir + "/gfx");
|
||||
copyAssetFolder(assetManager, "lang", externalFilesDir + "/lang");
|
||||
} catch(Exception e) {
|
||||
installationAlert.setMessage(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember which version the installed data is
|
||||
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit().putString("installed", getVersionName()).commit();
|
||||
|
||||
publishProgress(++installedFiles);
|
||||
Log.d(TAG, "Total number of files copied: " + installedFiles);
|
||||
return true;
|
||||
}
|
||||
|
||||
void deleteRecursive(AssetManager assetManager, String externalFilesDir, File fileOrDirectory) {
|
||||
String parentFolder = fileOrDirectory.getParentFile().getName().toLowerCase();
|
||||
String fileOrDirectoryName = fileOrDirectory.getName().toLowerCase();
|
||||
if (fileOrDirectory.isDirectory()) {
|
||||
// Don't delete the folder if it is in the preserve folders list
|
||||
if (PRESERVE_FOLDERS.contains(fileOrDirectoryName))
|
||||
return;
|
||||
|
||||
// Don't delete the folder if its parent is in the preserve subfolders list, and it doesn't exist in the APK assets (so must be custom data)
|
||||
if (PRESERVE_SUBFOLDERS.contains(parentFolder) && !assetExists(assetManager, fileOrDirectory.getPath().substring(externalFilesDir.length()+1)))
|
||||
return;
|
||||
|
||||
for (File child : fileOrDirectory.listFiles())
|
||||
deleteRecursive(assetManager, externalFilesDir, child);
|
||||
}
|
||||
else {
|
||||
// Don't delete the file if it's in the preserve files list
|
||||
if (PRESERVE_FILES.contains(fileOrDirectoryName))
|
||||
return;
|
||||
}
|
||||
|
||||
fileOrDirectory.delete();
|
||||
}
|
||||
|
||||
// Returns true if an asset exists in the APK (either a directory or a file)
|
||||
// eg. assetExists("data/sound") or assetExists("data/font", "unifont.ttf") would both return true
|
||||
private boolean assetExists(AssetManager assetManager, String assetPath) {
|
||||
return assetExists(assetManager, assetPath, "");
|
||||
}
|
||||
|
||||
private boolean assetExists(AssetManager assetManager, String assetPath, String assetName) {
|
||||
try {
|
||||
String[] files = assetManager.list(assetPath);
|
||||
if (assetName.isEmpty())
|
||||
return files.length > 0; // folder exists
|
||||
for (String file : files) {
|
||||
if (file.equalsIgnoreCase(assetName))
|
||||
return true; // file exists
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int countTotalAssets(AssetManager assetManager, String assetPath) throws Exception {
|
||||
try {
|
||||
String[] files = assetManager.list(assetPath);
|
||||
int count = 0;
|
||||
for (String file : files)
|
||||
{
|
||||
String filePath = assetPath + "/" + file;
|
||||
String subdir_files[] = assetManager.list(filePath);
|
||||
if (subdir_files.length == 0) // file
|
||||
count++;
|
||||
else // folder
|
||||
count += countTotalAssets(assetManager, filePath);
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// Pinched from http://stackoverflow.com/questions/16983989/copy-directory-from-assets-to-data-folder
|
||||
private boolean copyAssetFolder(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
|
||||
try {
|
||||
String[] files = assetManager.list(fromAssetPath);
|
||||
new File(toPath).mkdirs();
|
||||
boolean res = true;
|
||||
for (String file : files)
|
||||
{
|
||||
String subdir_files[] = assetManager.list(fromAssetPath + "/" + file);
|
||||
if (subdir_files.length == 0) // file
|
||||
res &= copyAsset(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
|
||||
else // folder
|
||||
res &= copyAssetFolder(assetManager, fromAssetPath + "/" + file, toPath + "/" + file);
|
||||
}
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean copyAsset(AssetManager assetManager, String fromAssetPath, String toPath) throws Exception {
|
||||
publishProgress(++installedFiles, totalFiles);
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
in = assetManager.open(fromAssetPath);
|
||||
new File(toPath).createNewFile();
|
||||
out = new FileOutputStream(toPath);
|
||||
copyFile(in, out);
|
||||
in.close();
|
||||
in = null;
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void copyFile(InputStream in, OutputStream out) throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
int read;
|
||||
while((read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... values) {
|
||||
if (installDialog == null) {
|
||||
return;
|
||||
}
|
||||
installDialog.setProgress(values[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
removeDialog(INSTALL_DIALOG_ID);
|
||||
if(result) {
|
||||
settingsAlert.show();
|
||||
} else {
|
||||
installationAlert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.hardware.usb.UsbDevice;
|
||||
|
||||
interface HIDDevice
|
||||
{
|
||||
public int getId();
|
||||
public int getVendorId();
|
||||
public int getProductId();
|
||||
public String getSerialNumber();
|
||||
public int getVersion();
|
||||
public String getManufacturerName();
|
||||
public String getProductName();
|
||||
public UsbDevice getDevice();
|
||||
public boolean open();
|
||||
public int sendFeatureReport(byte[] report);
|
||||
public int sendOutputReport(byte[] report);
|
||||
public boolean getFeatureReport(byte[] report);
|
||||
public void setFrozen(boolean frozen);
|
||||
public void close();
|
||||
public void shutdown();
|
||||
}
|
||||
@@ -1,650 +0,0 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCallback;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattDescriptor;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.os.*;
|
||||
|
||||
//import com.android.internal.util.HexDump;
|
||||
|
||||
import java.lang.Runnable;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDevice {
|
||||
|
||||
private static final String TAG = "hidapi";
|
||||
private HIDDeviceManager mManager;
|
||||
private BluetoothDevice mDevice;
|
||||
private int mDeviceId;
|
||||
private BluetoothGatt mGatt;
|
||||
private boolean mIsRegistered = false;
|
||||
private boolean mIsConnected = false;
|
||||
private boolean mIsChromebook = false;
|
||||
private boolean mIsReconnecting = false;
|
||||
private boolean mFrozen = false;
|
||||
private LinkedList<GattOperation> mOperations;
|
||||
GattOperation mCurrentOperation = null;
|
||||
private Handler mHandler;
|
||||
|
||||
private static final int TRANSPORT_AUTO = 0;
|
||||
private static final int TRANSPORT_BREDR = 1;
|
||||
private static final int TRANSPORT_LE = 2;
|
||||
|
||||
private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000;
|
||||
|
||||
static public final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
|
||||
static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 };
|
||||
|
||||
static class GattOperation {
|
||||
private enum Operation {
|
||||
CHR_READ,
|
||||
CHR_WRITE,
|
||||
ENABLE_NOTIFICATION
|
||||
}
|
||||
|
||||
Operation mOp;
|
||||
UUID mUuid;
|
||||
byte[] mValue;
|
||||
BluetoothGatt mGatt;
|
||||
boolean mResult = true;
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
}
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// This is executed in main thread
|
||||
BluetoothGattCharacteristic chr;
|
||||
|
||||
switch (mOp) {
|
||||
case CHR_READ:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Reading characteristic " + chr.getUuid());
|
||||
if (!mGatt.readCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to read characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case CHR_WRITE:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing characteristic " + chr.getUuid() + " value=" + HexDump.toHexString(value));
|
||||
chr.setValue(mValue);
|
||||
if (!mGatt.writeCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to write characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case ENABLE_NOTIFICATION:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing descriptor of " + chr.getUuid());
|
||||
if (chr != null) {
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
int properties = chr.getProperties();
|
||||
byte[] value;
|
||||
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
|
||||
value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE;
|
||||
} else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
|
||||
value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE;
|
||||
} else {
|
||||
Log.e(TAG, "Unable to start notifications on input characteristic");
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mGatt.setCharacteristicNotification(chr, true);
|
||||
cccd.setValue(value);
|
||||
if (!mGatt.writeDescriptor(cccd)) {
|
||||
Log.e(TAG, "Unable to write descriptor " + mUuid.toString());
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
mResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean finish() {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
|
||||
BluetoothGattService valveService = mGatt.getService(steamControllerService);
|
||||
if (valveService == null)
|
||||
return null;
|
||||
return valveService.getCharacteristic(uuid);
|
||||
}
|
||||
|
||||
static public GattOperation readCharacteristic(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.CHR_READ, uuid);
|
||||
}
|
||||
|
||||
static public GattOperation writeCharacteristic(BluetoothGatt gatt, UUID uuid, byte[] value) {
|
||||
return new GattOperation(gatt, Operation.CHR_WRITE, uuid, value);
|
||||
}
|
||||
|
||||
static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
|
||||
mManager = manager;
|
||||
mDevice = device;
|
||||
mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
|
||||
mIsRegistered = false;
|
||||
mIsChromebook = mManager.getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
||||
mOperations = new LinkedList<GattOperation>();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mGatt = connectGatt();
|
||||
// final HIDDeviceBLESteamController finalThis = this;
|
||||
// mHandler.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// finalThis.checkConnectionForChromebookIssue();
|
||||
// }
|
||||
// }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return String.format("SteamController.%s", mDevice.getAddress());
|
||||
}
|
||||
|
||||
public BluetoothGatt getGatt() {
|
||||
return mGatt;
|
||||
}
|
||||
|
||||
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
|
||||
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
|
||||
private BluetoothGatt connectGatt(boolean managed) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
try {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
|
||||
} catch (Exception e) {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
} else {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
}
|
||||
|
||||
private BluetoothGatt connectGatt() {
|
||||
return connectGatt(false);
|
||||
}
|
||||
|
||||
protected int getConnectionState() {
|
||||
|
||||
Context context = mManager.getContext();
|
||||
if (context == null) {
|
||||
// We are lacking any context to get our Bluetooth information. We'll just assume disconnected.
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
BluetoothManager btManager = (BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
if (btManager == null) {
|
||||
// This device doesn't support Bluetooth. We should never be here, because how did
|
||||
// we instantiate a device to start with?
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
return btManager.getConnectionState(mDevice, BluetoothProfile.GATT);
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
|
||||
if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) {
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void checkConnectionForChromebookIssue() {
|
||||
if (!mIsChromebook) {
|
||||
// We only do this on Chromebooks, because otherwise it's really annoying to just attempt
|
||||
// over and over.
|
||||
return;
|
||||
}
|
||||
|
||||
int connectionState = getConnectionState();
|
||||
|
||||
switch (connectionState) {
|
||||
case BluetoothProfile.STATE_CONNECTED:
|
||||
if (!mIsConnected) {
|
||||
// We are in the Bad Chromebook Place. We can force a disconnect
|
||||
// to try to recover.
|
||||
Log.v(TAG, "Chromebook: We are in a very bad state; the controller shows as connected in the underlying Bluetooth layer, but we never received a callback. Forcing a reconnect.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
else if (!isRegistered()) {
|
||||
if (mGatt.getServices().size() > 0) {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never got our registration. Trying to recover.");
|
||||
probeService(this);
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never discovered services. Trying to recover.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected, and registered. Everything's good!");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_DISCONNECTED:
|
||||
Log.v(TAG, "Chromebook: We have either been disconnected, or the Chromebook BtGatt.ContextMap bug has bitten us. Attempting a disconnect/reconnect, but we may not be able to recover.");
|
||||
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_CONNECTING:
|
||||
Log.v(TAG, "Chromebook: We're still trying to connect. Waiting a bit longer.");
|
||||
break;
|
||||
}
|
||||
|
||||
final HIDDeviceBLESteamController finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.checkConnectionForChromebookIssue();
|
||||
}
|
||||
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
private boolean isRegistered() {
|
||||
return mIsRegistered;
|
||||
}
|
||||
|
||||
private void setRegistered() {
|
||||
mIsRegistered = true;
|
||||
}
|
||||
|
||||
private boolean probeService(HIDDeviceBLESteamController controller) {
|
||||
|
||||
if (isRegistered()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mIsConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.v(TAG, "probeService controller=" + controller);
|
||||
|
||||
for (BluetoothGattService service : mGatt.getServices()) {
|
||||
if (service.getUuid().equals(steamControllerService)) {
|
||||
Log.v(TAG, "Found Valve steam controller service " + service.getUuid());
|
||||
|
||||
for (BluetoothGattCharacteristic chr : service.getCharacteristics()) {
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
Log.v(TAG, "Found input characteristic");
|
||||
// Start notifications
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
enableNotification(chr.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mGatt.getServices().size() == 0) && mIsChromebook && !mIsReconnecting) {
|
||||
Log.e(TAG, "Chromebook: Discovered services were empty; this almost certainly means the BtGatt.ContextMap bug has bitten us.");
|
||||
mIsConnected = false;
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void finishCurrentGattOperation() {
|
||||
GattOperation op = null;
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null) {
|
||||
op = mCurrentOperation;
|
||||
mCurrentOperation = null;
|
||||
}
|
||||
}
|
||||
if (op != null) {
|
||||
boolean result = op.finish(); // TODO: Maybe in main thread as well?
|
||||
|
||||
// Our operation failed, let's add it back to the beginning of our queue.
|
||||
if (!result) {
|
||||
mOperations.addFirst(op);
|
||||
}
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void executeNextGattOperation() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null)
|
||||
return;
|
||||
|
||||
if (mOperations.isEmpty())
|
||||
return;
|
||||
|
||||
mCurrentOperation = mOperations.removeFirst();
|
||||
}
|
||||
|
||||
// Run in main thread
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation == null) {
|
||||
Log.e(TAG, "Current operation null in executor?");
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentOperation.run();
|
||||
// now wait for the GATT callback and when it comes, finish this operation
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queueGattOperation(GattOperation op) {
|
||||
synchronized (mOperations) {
|
||||
mOperations.add(op);
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void enableNotification(UUID chrUuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void writeCharacteristic(UUID uuid, byte[] value) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void readCharacteristic(UUID uuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////// BluetoothGattCallback overridden methods
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onConnectionStateChange(BluetoothGatt g, int status, int newState) {
|
||||
//Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState);
|
||||
mIsReconnecting = false;
|
||||
if (newState == 2) {
|
||||
mIsConnected = true;
|
||||
// Run directly, without GattOperation
|
||||
if (!isRegistered()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGatt.discoverServices();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (newState == 0) {
|
||||
mIsConnected = false;
|
||||
}
|
||||
|
||||
// Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent.
|
||||
}
|
||||
|
||||
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onServicesDiscovered status=" + status);
|
||||
if (status == 0) {
|
||||
if (gatt.getServices().size() == 0) {
|
||||
Log.v(TAG, "onServicesDiscovered returned zero services; something has gone horribly wrong down in Android's Bluetooth stack.");
|
||||
mIsReconnecting = true;
|
||||
mIsConnected = false;
|
||||
gatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
else {
|
||||
probeService(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceFeatureReport(getId(), characteristic.getValue());
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic)) {
|
||||
// Only register controller with the native side once it has been fully configured
|
||||
if (!isRegistered()) {
|
||||
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
|
||||
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0);
|
||||
setRegistered();
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
// Enable this for verbose logging of controller input reports
|
||||
//Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue()));
|
||||
|
||||
if (characteristic.getUuid().equals(inputCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceInputReport(getId(), characteristic.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
//Log.v(TAG, "onDescriptorRead status=" + status);
|
||||
}
|
||||
|
||||
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
BluetoothGattCharacteristic chr = descriptor.getCharacteristic();
|
||||
//Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid());
|
||||
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
boolean hasWrittenInputDescriptor = true;
|
||||
BluetoothGattCharacteristic reportChr = chr.getService().getCharacteristic(reportCharacteristic);
|
||||
if (reportChr != null) {
|
||||
Log.v(TAG, "Writing report characteristic to enter valve mode");
|
||||
reportChr.setValue(enterValveMode);
|
||||
gatt.writeCharacteristic(reportChr);
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onReliableWriteCompleted status=" + status);
|
||||
}
|
||||
|
||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
|
||||
//Log.v(TAG, "onReadRemoteRssi status=" + status);
|
||||
}
|
||||
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
//Log.v(TAG, "onMtuChanged status=" + status);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////// Public API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId() {
|
||||
// Valve Corporation
|
||||
final int VALVE_USB_VID = 0x28DE;
|
||||
return VALVE_USB_VID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProductId() {
|
||||
// We don't have an easy way to query from the Bluetooth device, but we know what it is
|
||||
final int D0G_BLE2_PID = 0x1106;
|
||||
return D0G_BLE2_PID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerialNumber() {
|
||||
// This will be read later via feature report by Steam
|
||||
return "12345";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturerName() {
|
||||
return "Valve Corporation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName() {
|
||||
return "Steam Controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsbDevice getDevice() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We need to skip the first byte, as that doesn't go over the air
|
||||
byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(actual_report));
|
||||
writeCharacteristic(reportCharacteristic, actual_report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendOutputReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendOutputReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(report));
|
||||
writeCharacteristic(reportCharacteristic, report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted getFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "getFeatureReport");
|
||||
readCharacteristic(reportCharacteristic);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrozen(boolean frozen) {
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
close();
|
||||
|
||||
BluetoothGatt g = mGatt;
|
||||
if (g != null) {
|
||||
g.disconnect();
|
||||
g.close();
|
||||
mGatt = null;
|
||||
}
|
||||
mManager = null;
|
||||
mIsRegistered = false;
|
||||
mIsConnected = false;
|
||||
mOperations.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||