Commit graph

1624 commits

Author SHA1 Message Date
Robert Müller 4df4fa237e Add ingame touch controls
Add new client component `CTouchControls` for playing the game with touch inputs. The touch controls can be enabled/disabled with the config variable `cl_touch_controls`, which defaults to `1` on Android and `0` on other platforms. The touch controls consist of various on-screen touch buttons. The different buttons are only shown when they are usable depending on the context. The touch button configuration is stored in `touch_controls.json`.

Default touch button configuration
----------------------------------

Movement buttons for left, right and jump actions are arranged in a `⊥`-pattern similar to WASD controls.

For the fire and hook action, two modes are implemented:

1. Direct touch input: the mouse is moved exactly where the player touches on the screen.
2. Virtual joystick: a button is used to emulate a joystick, which moves the mouse relative to the center of the screen.

In either mode, a button is used to switch between the active actions (fire and hook). While the virtual joystick is being held down, this button uses the other action directly instead of switching it.

The direct touch input mode can be enabled/disabled separately for ingame/spectating, to prevent accidental direct touch input when using a joystick.

When spectating, direct touch input is used to allow panning the map directly like in an image/map viewer. Virtual joysticks can also be used to pan the map while spectating.

Two separate buttons are shown to switch to the previous and next weapons.

A hamburger menu button `☰` is used to toggle the visibility of lesser used touch buttons. This includes buttons for showing the scoreboard, showing the emoticon selector, showing the spectator menu, opening team and team chat, voting yes/no, and zooming. Long pressing the hamburger menu button will open the regular menu.

When the dummy is connected, a button for swapping between main and dummy is shown.

The emoticon selector and spectator menu are activated with the respective touch buttons and can be deactivated by touching outside of them or by using the back-button, as toggling them while the ingame touch button is pressed down is currently not feasible and also inconvenient at least for using the spectator menu.

Touch button configuration format
---------------------------------

The default button layout described above is loaded from `data/touch_controls.json`. This layout can be overridden by creating `touch_controls.json` in the user directory. The following button properties are adjustable:

- Position and size (attributes `x`, `y`, `w`, `h`): the X/Y position and width/height are integers on a 1,000,000² grid. The unit grid values are converted to screen grid values at runtime in relation to the aspect ratio of the screen. This means buttons may appear stretched if the resolution is changed, but it allows us to provide a reasonable default for slightly different aspect ratios. If we save the absolute position instead, we would have the problem of buttons appearing outside the screen or not being aligned on different aspect ratios.
- Shape (attribute `shape`): determines the shape of the button being rendered.
    - `"rect"`: rectangle shape.
    - `"circle"`: circle shape. The button size will automatically be adjusted so that width and height are identical.
- Visibility (attribute `visibilities`): an array of predefined visibility classes can be selected and the button is only shown if all conditions are satisfied. An empty array means that the button is always shown. The following visibility classes are defined:
    - `"ingame"`: player is ingame, i.e. not spectating.
    - `"extra-menu"`: the extra menu is activated.
    - `"zoom-allowed"`: zoom is allowed on the this server.
    - `"vote-active"`: a vote is currently active.
    - `"dummy-allowed"`: dummy is allowed on this server.
    - `"dummy-connected"`: dummy is currently connected.
    - `"rcon-authed"`: player is currently authed in rcon.
    - All visibility classes can be inverted by prefixing them with `-`, e.g. `"-ingame"` is satisfied when the player is not ingame, i.e. spectating.
- Behavior (attribute `behavior`): an object which describes the behavior of this touch button when it is activated/deactivated as well as its label. The attribute `type` is used to differentiate which type of behavior is used. The behavior is either predefined (hard-coded) or a generic console command (bind). Predefined behavior is only used where necessary, all other buttons are represented as generic binds.
    - Predefined behavior (attribute `type` set to `"predefined"`): The attribute `id` is set to a fixed string value which determines the specific predefined behavior. The following predefined behaviors exist:
        - `"extra-menu"`: The extra menu button which toggles visibility of buttons with `"extra-menu"` visibility. Also opens the normal menu on long press.
        - `"emoticon"`: Opens the emoticon selector (this does not work with binds).
        - `"spectate"`: Opens the spectator menu (this does not work with binds).
        - `"swap-action"`: Swaps the active action (fire and hook) for direct touch input and virtual joysticks.
        - `"use-action"`: Uses the active action with the current aiming position.
        - `"joystick-action"`: Virtual joystick which uses the active action.
        - `"joystick-fire"`: Virtual joystick which always uses fire.
        - `"joystick-hook"`: Virtual joystick which always uses hook.
    - Bind behavior (attribute `type` set to `"bind"`). Buttons with this behavior work like regular key binds.
        - The attribute `"label"` specifies as a string the label of the button.
        - The attribute `"label-type"` specifies as a string the type of the label of the button, i.e. how the attribute `"label"` is interpreted:
            - `"plain"`: Label is used as is.
            - `"localized"`: Label is localized. Only usable for the default buttons for which there are translations available.
            - `"icon"`: Icon font is used for the label. Icons must be encoded using `\uXXXX`, e.g. `\uf3ce` for the mobile phone icon.
        - The attribute `"command"` specifies as a string the command to execute in the console like a bind when this button is used.

Ingame menu buttons
-------------------

In addition to the separate on-screen touch controls, a second row is added to the main page of the ingame menu when `cl_touch_controls` is enabled for less frequently used functions which are otherwise not usable without a keyboard:

- Buttons to open the local and remote consoles. Opening the local console without the touch controls is useful because error messages would be shown there if the touch controls configuration could not be loaded.
- Button to close the menu, which is more convenient than using the virtual back button if it's not always shown.
- Checkbox for toggling the touch controls editor UI (see below).

Ingame touch controls editor
----------------------------

The user interface to adjust the touch controls is rendered over the main screen of the ingame menu when enabled. For now, the implementation of the touch controls editor is limited to basic configuration management functions.

- Saving the configuration to the `touch_controls.json` file in config directory.
- Discarding the current changes by reloading the `touch_controls.json` file from config directory.
- Restoring the default configuration by reloading the `touch_controls.json` file from data directory.
- Displaying whether there are unsaved changes.
- Importing and exporting the configuration from and to the clipboard. This is the only way to edit the configuration on newer Android versions, as editing files within apps' storage is not possible anymore.

Furthermore, the global touch controls settings can be adjusted in this UI:

- Direct touch input can be enabled/disabled separately while ingame and while spectating.

While the touch controls editor is active, all buttons are shown regardless of their visibility, to better support arranging the buttons.

Future tasks
------------

- Implement more usable UI for adjusting the button layout.
- Add `color` property to touch buttons to adjust the default background color?
- Support multiple independent extra menu visibilities and buttons with separate states, which would also add support for nesting buttons in menus.
- Support zooming gesture.
- Optimize touch button rendering using text and quad containers.
2024-08-25 15:41:57 +02:00
furo 10376fa4ff Fix language files that failed validation 2024-08-25 00:40:42 +02:00
Pavukoplov 7ee735a274 Update belarusian translation for 18.4 2024-08-24 00:03:29 +03:00
lolipodass a3c8949d40
Update russian.txt to match wiki
fix names like in https://wiki.ddnet.org/wiki/Dummy/ru
and https://wiki.ddnet.org/wiki/Common_Terminology/ru#Тии
2024-08-22 20:55:40 +03:00
Souly 4fb3027bd7
fix 0.7 feet offset
fix 0.7 feet offset
2024-08-19 15:34:44 +02:00
Dennis Felsing 96e946d504
Merge pull request #8751 from ChillerDragon/pr_grass_main_07_vanilla
Restore grass_main_0.7.png vanilla compability
2024-08-18 08:18:31 +00:00
ChillerDragon 6121be1bf1 Rename grass_main_0.7 to ddnet_grass
ddnet did extend the tileset so it is no longer matching the 0.7 grass_main
renaming the file makes that clear and allows for further extensions of
the file without breaking teeworlds 0.7 compability.

Also it frees the filename grass_main_0.7.png to be used by the ddnet
0.7 client mode so it can display the correct mapres on 0.7 connections.
2024-08-18 10:32:33 +08:00
ChillerDragon 31cc4c24bf Restore grass_main_0.7.png vanilla compability
Reset to the current teeworlds version. Removing the ddnet specific
extension from 2015.

929919d44b (diff-d3cf443ce462f6e0cf9543319e40497f2c93505528a40cb7d923781643094f99)

Closed #8747

```
$ wget https://raw.githubusercontent.com/teeworlds/teeworlds/a1911c8f7d8458fb4076ef8e7651e8ef5e91ab3e/datasrc/mapres/grass_main.png -O grass_main_0.7.png
$ dilate grass_main_0.7.png
```
2024-08-17 00:36:14 +08:00
heinrich5991 871cec9778
Merge pull request #8502 from BlaiZephyr/upd-teamlock
new lock indicator
2024-08-13 10:10:24 +00:00
ChillerDragon 093a78464a Add custom ddnet 0.7 skin greensward
https://github.com/teeworlds/teeworlds/pull/2152
2024-08-10 14:50:43 +02:00
Alexander Akulich fe99a346dd Improve 0.7 skins
skins7: Extract the skins dir to a macro
skins7: Look for the skins at 'skins7' dir
Data: Add 0.7 skins (diliated)
CMenus::RenderSkinSelection7: Fix the skins number (use 0.7 getter)
CSkins7::GetColorV3: Fix missing UnclampLighting
CRenderTools: Use stronger type for 0.7 colors
CSkins7::RandomizeSkin: Use enum value instead of hardcode+comment
CMenus::RenderSettingsTee7: Enable team skins validation
system: Add str_utf8_copy_num()
GameClient: Extract ApplySkin7InfoFromGameMsg()
GameClient: Add skin7 to CClientData (also process and validate it)
2024-08-10 14:50:43 +02:00
ChillerDragon bae37ab7df Add 0.7 client support
While keeping 0.6 fully working and untouched
This adds the option to connect via 0.7

0.7 servers are now mixed into the server browser list.
And users can also manually connect via 0.7
using a connection url like so:

    ./DDNet "connect tw-0.7+udp://127.0.0.1:8303"

This also adds a "Tee 0.7" section in the menu to pick a 0.7 skin.
The config variables are prefixed with player7_ like for example
player7_color_body
2024-08-10 14:50:42 +02:00
noKetchup 38773e39a8
Update spanish.txt 2024-07-28 00:29:15 -04:00
Dennis Felsing 3297aa336a
Merge pull request #8626 from By622/patch-18
Update traditional_chinese.txt
2024-07-21 13:18:09 +00:00
Dennis Felsing d0492e61dc
Update data/languages/traditional_chinese.txt
Co-authored-by: furo <furo@posteo.net>
2024-07-21 14:58:31 +02:00
By e20f43479b Update simplified_chinese.txt 2024-07-21 14:56:55 +02:00
By b24a377b13
Update traditional_chinese.txt 2024-07-21 16:52:37 +08:00
Dennis Felsing 36d8803302 Update Estonian translations (by Cammo) 2024-07-19 00:37:59 +02:00
Dennis Felsing 9b9005b77d
Merge pull request #8612 from furo321/swedish-18.4
Update Swedish translations for 18.4
2024-07-17 22:41:04 +00:00
gerdoe 7a6c40fb5d Update russian.txt 2024-07-17 22:29:36 +03:00
furo 816c5f2991 Update Swedish translations for 18.4 2024-07-17 21:21:55 +02:00
Dennis Felsing 17f8b59400
Merge pull request #8608 from EGYT5453/ua-18.4
Update Ukrainian l10n (18.4)
2024-07-17 15:24:11 +00:00
Rafael Fontenelle baedadc1ef
Update brazilian_portuguese.txt 2024-07-17 12:05:10 -03:00
Andriy 17d102f9b8
Update Ukrainian l10n (18.4) 2024-07-17 18:01:30 +03:00
Dennis Felsing 6e31f2cb43
Merge pull request #8604 from GokturkTalha/patch-9
Update Azerbaijanese translations
2024-07-17 07:18:33 +00:00
Talha Aygün 91202eb4ed
Update Azerbaijanese translations 2024-07-17 02:24:38 +03:00
Talha Aygün 2a66f8cdd4
Update Turkish translations 2024-07-17 02:24:13 +03:00
Dennis Felsing 22afa1770b Update German translations 2024-07-16 18:31:37 +02:00
Dennis Felsing 95eb509c93 Update translations for upcoming 18.4 2024-07-16 18:30:08 +02:00
Dennis Felsing 4ee5dfdbe6 Dilate new images 2024-07-09 17:47:55 +02:00
meloƞ 2c6eb73ed7 new lock indic. partially closes ddnet#8467
Co-Authored-by: catseyenebulous
2024-07-09 17:32:06 +02:00
fokkonaut 3e3017f557 Update F-DDrace entities 2024-07-09 16:27:12 +02:00
Dennis Felsing 83abf98c9a
Merge pull request #8546 from ChillerDragon/pr_07_winter
Add winter_main_0.7 mapres
2024-07-02 10:11:39 +00:00
ChillerDragon 22b051ce22 Add winter_main_0.7 mapres
```
$ wget https://raw.githubusercontent.com/teeworlds/teeworlds/a1911c8f7d8458fb4076ef8e7651e8ef5e91ab3e/datasrc/mapres/winter_main.png -O winter_main_0.7.png
$ dilate winter_main_0.7.png
```

https://github.com/ChillerDragon/ddnet/issues/8
2024-07-02 10:40:10 +08:00
Yacinello-droid 313f44ffbd
Update russian.txt 2024-06-26 02:42:29 +05:00
Dennis Felsing 248a24845e
Merge pull request #8513 from MilkeeyCat/pr_ddnet_fix_da_translations
Add context to translations & add removed translations
2024-06-23 18:32:01 +00:00
MilkeeyCat 635f91be12 fix: add context to translations & add removed translations 2024-06-23 17:54:18 +03:00
Dennis Felsing e7bd56544b Fix indentation 2024-06-20 13:10:51 +08:00
Sedonya_ 6153a8dc76
Update russian.txt 2024-06-20 03:19:23 +05:00
noKetchup ede5fe55d6
Update spanish.txt 2024-06-15 15:09:59 -04:00
Rafael Fontenelle fd4e34fd1e
Update brazilian_portuguese.txt 2024-06-11 22:43:59 -03:00
Dennis Felsing 0f35e576b4
Merge pull request #8477 from By622/patch-13
Update simplified_chinese.txt
2024-06-10 09:45:13 +00:00
By cbf11fcd34
Update traditional_chinese.txt 2024-06-10 16:57:32 +08:00
By 3184ea12d8
Update simplified_chinese.txt 2024-06-10 16:57:24 +08:00
dobrykafe bb378a5f2d update slovak translations for 18.3 2024-06-09 23:36:10 +02:00
dobrykafe 72f98c5d66 update czech translations for 18.3 2024-06-09 23:34:43 +02:00
Dennis Felsing e80d1ab4bd
Merge pull request #8473 from GokturkTalha/patch-7
Update Azerbaijanese translation
2024-06-09 16:21:33 +00:00
Dennis Felsing 7383d74a48
Merge pull request #8472 from GokturkTalha/patch-6
Update Turkish translations
2024-06-09 16:11:15 +00:00
Talha Aygün a0125f7df5
Update Azerbaijanese translation 2024-06-09 18:50:43 +03:00
Talha Aygün e993434163
Update Turkish translations 2024-06-09 18:49:06 +03:00