summaryrefslogtreecommitdiff
path: root/src/gui
AgeCommit message (Collapse)AuthorFilesLines
2024-06-25Fixed spaces getting added to chat every 50 charactersThorbjørn Lindeijer2-25/+2
This reverts part of 087babc2525ddb89e5b31f240a08739d9a3029a9. It's unclear to me why big words should be split (chat window force-wraps when necessary anyway) and it's causing issues by adding spaces in the middle of links, for example.
2024-06-25Show item links with empty item name.Andrei Karas1-0/+11
(cherry picked from commit 0192d44d46dcf948ab26371862753f4baf5aae4e)
2024-06-23Added support for text formatting and links to NPC dialogThorbjørn Lindeijer2-36/+27
Use BrowserBox in NpcDialog to enable the use of text formatting and links in NPC texts. This change is roughly based on ManaPlus commit 94f11a223e03c6845e7ce6e9fe67c0e9fa7061f4.
2024-06-22Added support for bold font markup to BrowserBoxThorbjørn Lindeijer2-39/+64
##B switches font to bold, ##b switches font to normal. Each line starts with the normal font. This change is roughly based on ManaPlus commit 6c4c6ca877c336e17c0378131a0a139792012a99.
2024-06-09Enable resizing windows from all sidesThorbjørn Lindeijer3-8/+25
Previously, the top edge of windows could not be dragged. Now you can also resize windows by their top edge, as well as the top-left and top-right corners.
2024-04-18Fixed being popup getting stuck under the mouseThorbjørn Lindeijer1-0/+2
Normally the popup follows the mouse, but when the mouse is moved down such that it is on top of the popup, the popup would seem to get stuck. When the BeingPopup is a mouse listener, the default behavior of Popup hiding the BeingPopup when the mouse moves over them kicks in. Hiding of the BeingPopup by Popup and Window when they are hovered in general is a workaround which might be necessary because there is currently no way for the Viewport to determine whether the mouse is above the map view or over a piece of UI.
2024-04-18Fixed mouse path debug when graphics are scaledThorbjørn Lindeijer1-3/+0
This SDL_GetMouseState call did not adjust the result to the graphics scale. Fortunately it could just be removed, since mMouseX and mMouseY are anyway updated each Viewport::logic.
2024-04-10Fixed the scaling of the custom cursorThorbjørn Lindeijer1-5/+6
It appears that either SDL or the system is already taking care of scaling the cursor to the display scale (observed on both macOS and Wayland). Hence, we should only scale the cursor by the user scale and not by both. Follow-up to 6eca1b485dba7355d827745284ed2f0072f9e370.
2024-04-08Added UI debug drawingThorbjørn Lindeijer7-4/+104
Shows outlines of visible widgets as well as highlighting modal focus, modal mouse focus and regular focus. Can currently only be toggled in the Debug window, so needs source code modification to be used during login sequence for now.
2024-04-08Use ResourceRef<Image> in more placesThorbjørn Lindeijer8-46/+29
Automatic reference counting of images is now used by Item, Icon, AnimatedSprite, ImageSprite, ParticleEmitter, Minimap, Desktop and Emote. Since ResourceManager::get automatically adds a reference, it needs to be explicitly subtracted when the resource is managed by ResourceRef. This is taken care of by the new ResourceManager::getImageRef. Also removed the apprently unused and duplicate "mDrawImage" from Item (which also didn't get decRef called on it). Fixes cleanup of emote ImageSet and ImageSprite instances, as well as particle images.
2024-04-08Compile fixes for MSYS2 UCRT64Thorbjørn Lindeijer2-5/+1
Also added instructions for installing the dependencies on MSYS2. The selection of the default language is commented out for now. It will be fixed in another change.
2024-04-02General code cleanupsThorbjørn Lindeijer14-47/+17
* Removed some unused includes * Removed unused ListBox::mFont * Removed wrong cast to SDL_Scancode * Removed superfluous .c_str() * Removed superfluous explicit std::string construction * Removed unused variable * Use more emplace_back * Turned FindBeingFunctor into a lambda * Avoid needless pointer references for ambient layers and use a vector
2024-04-02Fixed padding on mini-status windowThorbjørn Lindeijer1-0/+2
Broke in 474442f1a49d29d85de769c4fbb3aa8636877b49 due to changing the default padding on the Popup class.
2024-03-28Fixed size and child positions for various popupsThorbjørn Lindeijer10-91/+66
Most prominently, fixes the tooltips on the window buttons being clipped due to their position being slightly outside of the clipping children area. And fixes NPC tooltips from having a lot of empty space below the NPC name. Also reduced the space between texts in the item tooltip to match the padding rather than being an entire empty line.
2024-03-26Use SDL2 support for color and system mouse cursorsThorbjørn Lindeijer2-101/+161
This way the cursor is not limited by the framerate nor affected by input lag. Also, when custom cursor is disabled, a few different system cursors are now used instead. It also avoids an issue on Wayland, where hiding the cursor (as done to render our own one) would cause the cursor to get locked within the window. On macOS it fixes two cursors being visible when hovering the window while it is in the background. The cursor can unfortunately no longer gently fade away.
2024-03-26Added support for HiDPI fontsThorbjørn Lindeijer4-71/+105
* TrueTypeFont class now takes into account the graphics scale, in order to render an appropriate higher-resolution texture. * Removed TrueTypeFont::fontCounter, since TTF_Init/TTF_Quit already keep a counter. * Avoid copying the rendered string needlessly, when it already exists in the cache. Avoid another copy, when inserting a new chunk into the cache.
2024-03-26Added functions to draw images at sub-pixel positionsThorbjørn Lindeijer1-1/+1
This can be used for smoother mouse cursor movement when rendering our own mouse cursor (already changed in this commit) and is also necessary for implementing support for HiDPI font rendering. Also dropped some almost duplicated OpenGL code.
2024-03-25Avoid string allocations during text rendering and sizingThorbjørn Lindeijer1-4/+11
Now a text chunk has a maximum length of 4k characters, but that should be plenty of space since they're only single lines.
2024-03-22Added support for scaling the outputThorbjørn Lindeijer6-44/+135
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
2024-03-22Fixed the distribution of action events by DropDownThorbjørn Lindeijer1-1/+7
It did not distribute them when the value of the DropDown was changed by key events or mouse wheel.
2024-03-13Added SDL version check for SDL_OpenURLThorbjørn Lindeijer2-5/+20
Ubuntu 20.04 had SDL 2.0.10, and it is still supported. Also added error handling to the SDL_OpenURL call, just in case.
2024-03-12General code cleanupsThorbjørn Lindeijer34-184/+102
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
2024-03-11Implemented ability to open external links in news and chatThorbjørn Lindeijer8-18/+65
* Use ConfirmDialog to confirm the opening of the external link. * ConfirmDialog now centers on its parent window when provided. * Reset hovered link when mouse exits the BrowserBox.
2024-03-11Fixed settings being unavailable when updating was doneThorbjørn Lindeijer1-0/+1
The 'Play' button was continuously requesting focus once the updates had been downloaded.
2024-03-07Use the native TMX tile animation formatThorbjørn Lindeijer2-8/+7
Rewrote the tile animation loading code based on XML tags, replacing the code that loaded tile animations from tile properties. Also made a number of code simplifications and optimizations: * Replaced a number of pointer members with value members. * Pass around Animation and TileAnimation by value, using std::move to avoid allocating copies. * push -> emplace * push_front -> emplace_front * push_back -> emplace_back * Use range-based for loops * Use std::vector instead of std::list for storing affected tiles (less fragmentation) * Avoid string copies and allocations while parsing CSV layer data. * Replaced xmlNodeGetContent with directly accessing 'content'.
2024-03-06General code cleanupsThorbjørn Lindeijer5-36/+9
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
2024-03-04Fixed character displayThorbjørn Lindeijer3-24/+23
This change fixes hair style to take into account "race", which makes the faces visible again. Hair colors should also be fixed now, with partial support for itemcolors.xml added. The Mana client now also supports per-character gender, and it now hides the hair style and color buttons on character creation, when there are none to choose from. Closes #43
2024-03-04Added support for handling SMSG_NPC_COMMANDThorbjørn Lindeijer1-0/+10
This only adds support for the NPC_CLOSE_DIALOG and NPC_CLEAR_DIALOG sub-commands. Closes #47
2024-03-02Changed server type to "enum class"Thorbjørn Lindeijer10-22/+22
2024-03-02Added support for -y / --server-type parameterThorbjørn Lindeijer5-30/+16
Usually this would be guessed correctly by the port, but now it is also possible to just specify the server type and the port will be derived from there, unless a default port is given in the branding file. Closes #56
2024-03-02Added support for customizing NPC and Monster hover cursorThorbjørn Lindeijer1-7/+2
To match support for this in M+, since TMW uses this functionality on two of its NPCs.
2024-03-02Updated mouse cursors to latest versionThorbjørn Lindeijer5-66/+64
The new cursor types are not used yet for now.
2024-03-02General code cleanupsThorbjørn Lindeijer2-19/+0
* Don't needlessly store or return raw pointers in BeingInfo * Less copying, more moving * Less else after return * Make AddDEF a template instead of a macro * Removed some unused includes * Use range-based for loops
2024-02-29Re-download updates when their checksum no longer matchesThorbjørn Lindeijer1-19/+15
The Mana World currently likes to just update its "TMW.zip" file, whereas updates were always given unique names in the past. With this change, the client checks the Adler32 checksum to know when it should re-download an update file. This matches the behavior of ManaPlus commit 96150f1aeacf55d311c41ffe12d9e754b1cda001.
2024-02-28Use snprintf instead of sprintfThorbjørn Lindeijer1-5/+1
Using sprintf triggers a warning on macOS. The buffer should be large enough, but a little extra security doesn't hurt.
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer4-179/+185
The configuration and setup UI were adjusted to the new options. This also fixes issues in applying new video settings. Default resolution was changed from 800x600 to 1280x720. VSync is enabled by default while FPS limit was disabled. Display aspect ratio for the resolution options. I had to work around some macOS issues: * Don't change window size when it appears to be "maximized", since it just changes the rendering area while leaving the window maximized. * Unset fullscreen display mode temporarily to allow changing resolutions, otherwise the rendering area no longer matches the screen and mouse input is also off. * Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on macOS, since we're not actually handling the scaling factor. A Video class and an SDLGraphics subclass were split off from Graphics. This setup has Less duplication and leaves the OpenGLGraphics and SDLGraphics better separated. Fixes #57 Fixes #58
2024-02-22General code cleanupsThorbjørn Lindeijer28-60/+48
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
2024-02-15Fix handling of non-consecutive emote IDsThorbjørn Lindeijer5-97/+82
Previous code was assuming there would be no gaps in the emote IDs. Also cleaned up some confusion where the "emote ID" being passed around in the code was often offset by 1. Now it is only offset in communication with tmwAthena and when saving the shortcuts.
2024-02-13Removed no longer supported admin messagesThorbjørn Lindeijer1-5/+3
* Removed /announce command * Changed "Kick player" in player pop-up to kick by name Other messages, like CMSG_ADMIN_HIDE, CMSG_ADMIN_MUTE and CMSG_ADMIN_LOCAL_ANNOUNCE were already not used by the client. Also, none of this was implemented for Manaserv.
2024-02-13General code cleanupsThorbjørn Lindeijer64-293/+175
* Removing unused includes * Use member initialization * Use range-based for loops * Use nullptr * Removed no longer used aliases * Use override * Don't use else after return * Use '= delete' to remove implicit members * Use std::string::empty instead of comparing to ""
2024-02-09Optimized BrowserBoxThorbjørn Lindeijer9-351/+327
* Introduced a LayoutContext that conveniently allows for relayouting all rows, or just a single one when it is added. BrowserBox::addRow no longer relayouts all the rows. * BrowserLink and LinePart are now merged into a new TextRow struct, so they can be conveniently dropped when the row limit has been reached. * Removed "opaque" option, which was enabled by default but disabled for all BrowserBox instances. * Removed "always update" option, and instead start delaying relayouting automatically when there are a lot of rows (> 100 currently). * Update window now also has text wrapping enabled. Closes #50
2024-02-09Some cleanups in UpdaterWindow and BrowserBoxThorbjørn Lindeijer4-170/+79
Doing some cleanups before working towards optimizing this code. Removed needless additional wrapping code in BrowserBox::addRow, since the text will be relayouted anyway. Simplified layouting code a little. For example, there's no need to keep track of the number of wrapped lines. Use more optimal data structures, like an std::deque for the text rows and a plain std::vector for the line parts. Both have less fragmentation than an std::list.
2024-02-09C++11: Use default member initializersThorbjørn Lindeijer38-190/+113
This patch is not exhaustive.
2024-02-05Updated C++ standard to C++17Thorbjørn Lindeijer1-7/+1
C++17 should be universal enough by now. This raises the minimum CMake to 3.8, which should also pose no problem since Ubuntu 18.04 already shipped with CMake 3.10. C++17's 'if' initialization statement is now used in an efficient implementation of 'join' for vector<string>, found on StackOverflow.
2024-01-30Apply readability-delete-null-pointer fixitsThorbjørn Lindeijer2-8/+5
These checks are unnecessary as deleting a null pointer has no effect.
2024-01-29Removed unused SpecialEntry::mLevelLabelThorbjørn Lindeijer1-2/+0
2024-01-29Removed unused includes in various filesThorbjørn Lindeijer8-13/+0
2024-01-29Removed remnants of alpha cache in ResourceManagerThorbjørn Lindeijer1-3/+0
Continuation of 2c51c98625b225cecfb9628c30d62d4e30f7e3e1, which had already removed most of the alpha cache in Image.
2024-01-29Apply C++11 fixitsThorbjørn Lindeijer31-197/+145
modernize-loop-convert modernize-deprecated-headers
2024-01-29Fixed another crash due to incomplete SDL2 upgradeThorbjørn Lindeijer1-1/+1
SDL_GetKeyboardState array needs to be indexed by scan codes.