Debian Codegraph @

CONTRIBUTING

raw
1 Contribution "instructions"
2 ===========================
3
4 All kinds of contributions are welcome: bug fixes, graphics, new tracks, translations..
5
6 E-mail: [email protected]
7
8 Getting the up-to-date source
9 -----------------------------
10
11 git clone https://github.com/juzzlin/DustRacing2D.git
12
13 - master branch has the currently released stuff and is stable.
14
15 Game / Editor
16 -------------
17
18 Make your changes against the master branch.
19
20 If you have fixed a bug or modified the game in some other acceptable way,
21 I most likely want to receive the changes as a GitHub pull request
22
23 OR
24
25 as a Git patch (make a commit of your changes in your working branch,
26 and then make a patch "git diff master > your_change.patch").
27
28 Please follow the existing coding style. Some examples and conventions below.
29
30 Adding/updating translations
31 ----------------------------
32
33 Qt's translation source files for the game are at:
34
35 src/game/translations/
36
37 Editor:
38
39 src/editor/translations/
40
41 You can just copy these files as a new locale and edit, but the recommended way is
42 to generate/update the file from source code to make sure that the source strings
43 are up-to-date:
44
45 $ lupdate src/game/*.cpp src/game/menu/*.cpp -ts src/game/translations/dustrac-game_fr.ts
46 $ lupdate src/editor/*.cpp -ts src/editor/translations/dustrac-editor_fr.ts
47
48 ..as an example for French.
49
50 The .ts-files can then be opened in Qt's translation GUI, linguist.
51
52 For Qt5, the Ubuntu package for these tools is qttools5-dev-tools.
53
54 A fallback character mapping is in src/game/graphicsfactory, as the texture font used in the
55 game doesn't support all accented characters, e.g. "รก" is mapped to "a". This map can also
56 be extended, if needed.
57
58 In the case of a new locale, src/game/CMakeLists.txt and src/editor/CMakeLists.txt
59 need to be modified so that the .ts files are compiled into corresponding .qm files.
60 The .qm files are binary files that are actually used by the application:
61
62 # Translation files in src/game/translations (without .ts)
63 set(TS dustrac-game_fi dustrac-game_it dustrac-game_cs)
64
65 Add your file to the list for both the game and the editor.
66
67 Remember to TEST the translations. The editor and the game can be forced to given lang:
68
69 $ ./dustrac-game --lang fr
70 $ ./dustrac-editor --lang fr
71
72 Coding style examples
73 ---------------------
74
75 Some conventions:
76
77 * Avoid useless comments and temp variables
78 * C++11 standard
79 * camelCase naming convention for members
80 * Indentation with 4 spaces
81 * No copy-paste code
82 * No public/protected member variables allowed, only private variables with getters/setters
83 * PascalCase naming convention for class names, namespaces, and enums
84 * Prefer references and smart pointers
85 * Typedef STL containers and smart pointers
86 * Use const always when possible
87
88 Class header example:
89
90 #ifndef MYFOOCLASS_HPP
91 #define MYFOOCLASS_HPP
92
93 class MyFooClass : public MyBase
94 {
95 public:
96
97 enum class MyEnum
98 {
99 This,
100 That
101 };
102
103 MyFooClass();
104
105 virtual ~MyFooClass();
106
107 bool someMember() const;
108
109 void setSomeMember(bool someMember);
110
111 protected:
112
113 void myMethod1();
114
115 private:
116
117 void myMethod2();
118
119 bool m_someMember;
120
121 int * m_somePointer;
122 };
123
124 typedef std::shared_ptr<MyFooClass> MyFooClassPtr;
125
126 #endif // MYFOOCLASS_HPP
127
128 Class source example:
129
130 #include "myfooclass.hpp"
131
132 namespace {
133 static const int MAX_CARS = 10;
134 }
135
136 MyFooClass::MyFooClass()
137 : m_someMember(false)
138 , m_somePointer(nullptr)
139 {
140 if (something())
141 {
142 for (int i = 0; i < MAX_CARS; i++)
143 {
144 doSomething(i);
145 }
146 }
147 }
148
149 bool MyFooClass::someMember() const
150 {
151 return m_someMember;
152 }
153
154 void setSomeMember(bool someMember)
155 {
156 m_someMember = someMember;
157 }
158
159 MyFooClass::~MyFooClass()
160 {
161 }
162
163 -- Jussi Lind <[email protected]>