Development: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 48: | Line 48: | ||
<!--T:14--> | <!--T:14--> | ||
< | <syntaxhighlight lang="bash"> | ||
sudo pacman -S --needed base-devel cmake curl ffmpeg freetype2 git glew glslang gmock libnotify libpng opusfile python rust sdl2 spirv-tools sqlite vulkan-headers vulkan-icd-loader wavpack x264 | |||
</syntaxhighlight> | |||
For Debian: | For Debian: | ||
< | <syntaxhighlight lang="bash"> | ||
sudo apt install build-essential cargo cmake git glslang-tools google-mock libavcodec-extra libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libcurl4-openssl-dev libfreetype6-dev libglew-dev libnotify-dev libogg-dev libopus-dev libopusfile-dev libpng-dev libsdl2-dev libsqlite3-dev libssl-dev libvulkan-dev libwavpack-dev libx264-dev python rustc spirv-tools4 | |||
</syntaxhighlight> | |||
== Compiling DDNet == <!--T:15--> | == Compiling DDNet == <!--T:15--> | ||
Line 238: | Line 242: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
See [https://cplusplus.com/reference/cstdio/printf/ printf documentation] for a list of all format specifiers. | |||
=== Iterating over all players === <!--T:63--> | === Iterating over all players === <!--T:63--> | ||
Line 257: | Line 261: | ||
Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "wikiprint", "Hello from the ddnet wiki!"); | Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "wikiprint", "Hello from the ddnet wiki!"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 267: | Line 272: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Translating text in the client === | |||
<code>Localize</code> can be used in the game client to get the translation for a specific string from the language file selected by the user.<syntaxhighlight lang="cpp"> | |||
DoButton(..., Localize("Connect"), ...); | |||
</syntaxhighlight>The string can also contain format specifiers. The translated string must contain the same format specifiers.<syntaxhighlight lang="cpp"> | |||
char aBuf[128]; | |||
str_format(aBuf, sizeof(aBuf), Localize("%d of %d servers"), NumServers, TotalServers); | |||
</syntaxhighlight>A script is used to scan the code for calls to <code>Localize</code> and collect the strings to update the translation files. For this reason, the call to <code>Localize</code> must not contain any other code, or the script cannot determine the text correctly.<syntaxhighlight lang="cpp"> | |||
// Do NOT do this: | |||
const char *pStr = Localize(Team == TEAM_RED ? "Red team" : "Blue team"); | |||
// Do this instead: | |||
const char *pStr = Team == TEAM_RED ? Localize("Red team") : Localize("Blue team"); | |||
</syntaxhighlight> | |||
== External resources == <!--T:69--> | == External resources == <!--T:69--> | ||
<!--T:70--> | <!--T:70--> | ||
* [https://edgarluque.com/blog/ui-code-ddnet/ UI Code in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] | |||
* [https://edgarluque.com/blog/intro-to-ddnet/ An intro to the DDraceNetwork game source code] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] | * [https://edgarluque.com/blog/intro-to-ddnet/ An intro to the DDraceNetwork game source code] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] | ||
* [https://edgarluque.com/blog/code-conventions-in-ddnet/ Code conventions in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] | * [https://edgarluque.com/blog/code-conventions-in-ddnet/ Code conventions in DDraceNetwork] by [[Special:MyLanguage/User:Ryozuki|Ryozuki]] |