This adds highlighting color when hovering the main menu buttons (File, Tools, Settings), which was previously missing for these buttons. This also reduced duplicate code.
Extract font size for menu buttons into constant `MENU` in new namespace `EditorFontSizes`.
Use `DoButton_FontIcon` with `FONT_ICON_MINUS`/`FONT_ICON_PLUS` consistently instead of using `DoButton_ButtonDec/Inc` with text labels `+`/`-`.
For yes/no buttons, use `DoButton_Ex` and specify the button corners explicitly instead of using `DoButton_ButtonDec/Inc`.
Reset dragging operation when the dragged button has been unset and reset dragged button when operation has been reset, to prevent the editor from being stuck in either of two inconsistent states. This could be reproduced easily by clicking very quickly while moving the mouse up and down over the groups/layers list.
Do not call `CheckActiveItem` on a UI element (the dragged button) which might not be in view, as this prevents the UI from detecting the invalid active item, when groups/layers are dragged very far and quickly outside the scrollregion.
Closes#6855.
Immediately cancel new HTTP requests instead of enqueuing them when already shutting down `CHttp`. Otherwise, `CChooseMaster` may wait forever for HTTP requests to be completed while the client is shutting down, if `CHttp` was shutdown while `CChooseMaster` is not waiting for an existing HTTP request.
Not directly caused by #7962, but it made it more likely to happen.
Closes#7980.
The combined entities texture for all layers except the switch layer was only built when the gametype has a front, speedup, tele or tune layer, which is only the case for servers declaring DDNet or DDRace type in their gameinfo. Now this entities layer is always built, as the game layer is always present.
Expose UI element ID for the main map editor as member variable so the select layer by tile funtionality can correctly be enabled when the map editor is the hot item.
Add/update doxygen comments for all `shell_*`, `os_*`, `secure_*`, `cmdline_*`, `windows_*` and related functions.
Move `open_link` and `open_file` declarations to shell group, to the same relative position as their function definitions.
Instead of sending the message from the first client which is not ingame, choose the first client which is fully empty, to make it less likely that the message is sent from a currently connecting client.
Add a country "none" with tee flag (code `-1`) and a type "None" for all servers without community.
Previously, the country and type for these servers was unset and their handling special-cased, so any non-empty country/type filter would exclude servers without country/type information. Now individual countries/types can be excluded without also excluding all servers without community.
Closes#7961.
It was possible to create a community/country/type filter excluding all entries when the list only contains one entry and right-click is used to deselect it.
Shutdown `CHttp`, i.e. abort all HTTP requests, as early as possible when quitting/restarting the client, after the config has been saved but before shutting down the gameclient. Previously, this was delayed until the engine shutdown, so the requests would often finish entirely instead of being aborted by the callback.
Previously, HTTP requests being aborted due to `CHttp` shutting down were considered `EHttpState::ERROR`, which sometimes causes deadlocks during engine shutdown or destruction of `CHttp`. The state is now set to `ABORTED` by passing `CURLE_ABORTED_BY_CALLBACK` to `OnCompletionInternal`. The otherwise unused handling of internal errors is removed.
Previously, it was assumed `ResultJson` would return `nullptr` for HTTP requests which have been aborted or failed with an error, which would trigger the newly added assertion error "Request not done".
Directly use the bounding box which has already been calculated for the text containers, instead of calculating the text width again for every info message text.
Reduce duplicate code by moving screen remapping and validation of the info message into the `AddInfoMsg` function.
Check for valid kill message before creating text containers, so they are not created and deleted unnecessarily.
Assign info message type directly instead of passing it as a separate parameter.
Combine `CreateNamesIfNotCreated` and `CreateFinishTextContainersIfNotCreated` functions to `CreateTextContainersIfNotCreated` function to reduce duplicate code on usage.
Extract duplicate code for determining name color in info messages as lambda function.
For consistency between 0.6 and 0.7 clients, also show kill messages for 0.7 clients, now that DDNet client also supports finish messages.
Closes#5623.
Instead of preventing the client from quitting/restarting while a warning is shown in the menus, add warnings that should be shown after quitting/restarting (i.e. the warning when the config could not be saved) to a separate list and show these warnings using an OS message box after the client has been closed. Otherwise, the client is prevented from closing if a warning is shown without being automatically hidden, which causes the client to hang indefinitely in the CI.
The message boxes for warnings must be shown after the client has already been completely shutdown, otherwise the regular shutdown with the Vulkan backend crashes because showing the message box has already partially deinitialized the backend.
The quitting/restarting client state is now checked after updating the FIFO component, so quitting/restarting initiated via FIFO is effective immediately, although this should have little effect in practice.
For completeness, a log message is added also for the case that the config was saved successfully.
The GitHub CI seems to automatically confirm/disable OS message boxes, so they should not block workflows.
Add assertions to ensure that the HTTP request result data and SHA256 are available when getting them instead of returning `nullptr` and `SHA256_ZEROED` when they are not.
Rename `CHttpRequest::Sha256` function to `ResultSha256`.
Because of incorrect index/size math, two favorite communities were removed when exceeding the maximum number of three favorite communities instead of only one. The check can be simplified because the maximum number of favorite communities can never be exceeded, so at most the first element needs to be removed from the vector.
Closes#7935.
Avoid many writes to disk each time the DDNet info is downloaded, i.e. each time the refresh button is pressed in the server browser, by first loading the DDNet info into memory and only writing it to disk when it differs from the current DDNet info based on the SHA256 hash.
The SHA256 is now also used to track whether the DDNet info was modified for the community filters and icons instead of using the current time for this purpose.
Closes#3941.
Initialize the HTTP client (start the HTTP thread) after initializing the network client instead of during the client interface construction. This ensures that config variables have been loaded already and the log output level is set correctly. This also means all library initialization log messages appear together in one block when starting the client.
Show an error message box and stop launching when the HTTP client could not be initialized, instead of launching but not being able to perform any HTTP requests, which causes bug reports about the serverlist being empty.
Both console and chat commands are sent to clients dynamically with respective messages, so the static lists of commands were only used for servers not making use of these messages. Instead of assuming potentially incorrect console and chat commands on those servers, the lists will now be empty for those servers.
Move the command registration from the `ddracecommands.h` and `ddracechat.h` header files to the `CGameContext::RegisterDDRaceCommands` and `CGameContext::RegisterChatCommands` functions and delete the header files. The `CHAT_COMMAND` and `CONSOLE_COMMAND` macros are removed, because they only add unnecessary indirection now. The strings `CHAT_COMMAND` and `CONSOLE_COMMAND` are simply replaced with `Console()->Register` and semicolons are added at the end of the lines.
Closes#7665.
Support adding up to three communities as favorites in the server browser. Favorites can be changed with favorite buttons which are shown in the community filter on the Internet and Favorites tabs. The commands `add_favorite_community` and `remove_favorite_community` are added to change the favorite communities via the console and for saving the favorite communities to the config file. For the favorite communities, additional tabs using the communities' icons are shown in the server browser next to the Internet, LAN and Favorites tabs. Each community tab shows only the servers from the respective community, hence the community filters UI is not shown on the community tabs but only on the Internet and Favorites tabs. The country and type filters on community tabs cover only the countries and types from the respective community. Favorite communities are added from left to right. When more than three favorite communities are added, the oldest (leftmost) favorite community will be removed from the list.
When starting the client for the first time, i.e. with `cl_show_welcome 1`, the DDNet tab will be created as the only favorite community and selected initially. The community, country and type filters are unset when starting for the first time, so the Internet tab now shows all servers per default.
When starting with a `ui_page` for a favorite community that is not configured, the page is reset to the Internet tab. This also affects those who upgrade from versions with the old DDNet and KoG tabs. The server browser is now also correctly updated when changing `ui_page` via the console.
Track country and type filters for every community separately, to avoid filters resetting when switching between community tabs or changing the community filter. The commands `add_excluded_community`, `remove_excluded_community`, `add_excluded_country`, `remove_excluded_country`, `add_excluded_type` and `remove_excluded_type` are added to change the exclusion filters via the console and for saving the exclusion filters to the config file.
Render community filters above the toolbox (filter, info and friends) tabs when on the Internet and Favorites tab, so this setting is more visible and can be changed also when the other toolbox tabs are selected.
Add icon for the none community, based on the tee country flag color. This icon is hard-coded in the client, as the none community also is, so fetching the icon from the server would be inconvenient. Load community icons already when rendering the menu instead of only when rendering the server browser, so the icons are immediately available when using the start menu.
Find tutorial server by searching for community type "Tutorial" instead of searching for "(Tutorial)" in the server name.
Avoid cleaning favorite communities and filters when there are no communities, i.e. when the DDNet info failed to be loaded or does not contain any communities, to avoid losing all favorite communities and filters in this case.
Closes#7774.
When empty PNG files are loaded, the `std::vector` for the file contents is resized to size 0, which results in undefined behavior when it is accessed with `front`.
When `io_tell` fails, i.e. returns `-1`, this was incorrectly cast to an `unsigned` and therefore caused a very large allocation and potentially crashes due to lack of memory.
Add `CGameClient::RefreshSkins` function to refresh skins. This function reloads all skins by calling `CSkins::Refresh` and then notifies all gameclient components about the skins being refreshed by calling the new `CComponent::OnRefreshSkins` function, so the components can properly invalidate their current skin texture handles. The existing `RefindSkins` functions are changed to `OnRefreshSkins`.
Additionally, `OnRefreshSkins` is overridden in `CMenus` to set the flag so the skin list will be updated before it is rendered the next time, to fix the client crashing when changing skin related config variables via the console. Closes#7891.
Reduce height and empty space and make margins consistent. Slightly increase width for better round corner drawing and to support longer vote descriptions.
Auto-scale description and reason labels and show ellipsis if they don't fit.
Show circular progress indicator for remaining vote time.
The functionality to draw text on the voting bars is never used, so the parameter `Text` is always `false`.
Remove unused variable `PassArea`. The remaining area of the voting bars is unused.
Use error log level for error messages. Use info log level explicitly instead of using `dbg_msg`.
Log time taken for initialization in trace level message.
Use `IGraphics::CORNER_NONE` instead of `0`.
Use `nullptr` instead of `NULL`.
Remove arguments identical to defaults.
Use loops for tab bars with several tabs.
Add parameter to `shell_execute` to either start the process in the foreground or background on Windows. Previously, all processes were started in the background, because this is desired when starting the server from the client. However, this causes the graphics initialization to fail when restarting the client after updating or with the `restart` command when using Vulkan with windowed and windowed fullscreen mode.
Closes#6578.
Render an additional "Reset filter" button below the "No servers match your filter criteria" message to make it more obvious for new players how to restore the original view of servers, especially when the filter tab is not currently selected.
The `bool AllowResizing` parameter is only passed to other `SetWindowParams` functions but never used in the end, as whether or not resizing is allowed is separately determined based on the value of the `int FullscreenMode` parameter.
Instead of cleaning the countries/types filters based on all available communities' countries/types, only consider the countries/types of currently selected communities. Ensure countries/types are always cleaned when updating the server browser filter in the UI. This fixes that countries/types which are not available for the selected communities were still affecting the server filtering, causing no servers to be shown in some cases.
Closes#7847.
To simplify the usage of the demo recorder, parameters are added to the `IDemoRecorder::Stop` function to control whether the demo file is removed or renamed when stopping the recording.
Ensure demo files of the replay recorder are always removed (except on crashes). The temporary replay demos were previously not removed when being disconnected from a server.
Fix auto demos being stopped and restarted when enabling replays in the settings menu. Now only the replay recorder is stopped/started when necessary.
Fix replay recorder being restarted when setting `cl_replay` variable with console without changing the value.
Remove unnecessary `CClient::m_ButtonRender` variable. Demo rendering is already stopped correctly when reaching the end of the demo without this additional variable.
Remove unused `CDemoRecorder::m_pMapData` variable.
Instead of leaking the m_MoveRestrictions to all classes which needs to
adjust the Character velocity, add a setter which takes into account those
restrictions.
The shotgun bug replication requires an access to the Velocity without the
restrictions applied (so we have to have this dirty setter).
Expose only *const* CCharacterCore to force the setters usage and prevent
incorrect write.
Ensure that the `CHttpRequest::OnCompletion` function has finished before updating the state which is visible to other threads. Otherwise, threads may try to access the result of a completed HTTP request, before the result has been initialized/updated in the `OnCompletion` function.
Fixes warning due to invalid texture width/height being shown for downloaded skins, because the texture was loaded before the image data was initialized. Closes#7818.
Regression from #7683. Before this, the `OnCompletion` function could also modify the HTTP request's state, which was used to check if loading the skin PNG failed. Instead of doing this, a separate check is added for the skin download task to check that the PNG was loaded successfully.
Use [virtual terminal processing](https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for Windows console output when possible, using the existing async logger. Fallback to the old Windows logger when virtual terminal processing is not available. Do not set any logger when there is no console/file/pipe to output to.
This adds support for 24 bit RGB colors using ANSI escape codes (when Terminal emulator supports it) instead of only supporting 16 fixed colors.
Use the existing async logger also on Windows by converting the console standard output handle to an IOHANDLE. Avoid converting console output to UTF-16 by changing the console output codepage to UTF-8 and outputting that directly. Overall, this reduces the time until the loading screen first appears when launching the client from the console on Windows by around 70%, from 80-100ms down to 25ms.
Add support for `NO_COLOR` environment variable also on Windows.
Use the async logger also for writing output to files and pipes instead of using a Windows specific implementation for this, to reduce lags when redirecting the standard output.
Closes#3925. The client/server will not freeze anymore when entering selection mode in the console because we are using the async logger on Windows now.
Closes#1108. We were already using AIO on Windows to write the logfile, which was not causing any known issues. We are now also using AIO with the async loggers for console/files/pipes on Windows.
On Windows, the result of the `localtime` function is thread-local, hence our uses of this function are already thread-safe.
On non-Windows, the `localtime` function is potentially not thread-safe, so the reentrant `localtime_r` function is used instead with a thread-local buffer for the result.
Closes#7788.
When handling door and laser entities, all 8 adjacent tiles are checked for laser modifier tiles. When handling laser entities, the 8 tiles one further out are also checked for laser modifier tiles. If either of those 16 tiles is outside the map bounds, an error message was printed and the tiles are ignored. The error message is removed because it's unnecessary and misleading. Placing entities near or on the map border is not known to cause any issues.
Closes#7759.
Store X value (time) for all graph entries in addition to the Y value (FPS, prediction margin etc.). The `CGraph::Add` function adds values to the graph at the current time. The `CGraph::InsertAt` function allows specifying arbitrary X values, as long as the values are inserted in increasing order.
The entries are kept in a ringbuffer and old entries are recycled when it's full. The size of the ringbuffer is configurable for each graph, as the FPS graph needs significantly more buffer because values are added more often.
The scrolling speed of the graphs is fixed by specifying the maximum size of the window of values which should be displayed. For this purpose, a parameter is added to the `CGraph::Scale` function to specify the size of the window which should be rendered in the `CGraph::Render` function. For the FPS graph only the last second is rendered, so small spikes are still noticeable. For prediction and gametime margin graphs the last five seconds are rendered, which should result in a similar scrolling speed as before this change. The debug tuning graph is a special case, where the X values set manually and fixed to 0-127, same as before, instead of being based on the current time.
The graph rendering is made much more efficient by precalculating when the vertex colors need to be updated, to avoid all unnecessary calls to `SetColorVertex`. Additionally, line items are bundled together in an array to avoid calling `LinesDraw` for every individual line item.