summaryrefslogtreecommitdiff
path: root/src/gui
AgeCommit message (Collapse)AuthorFilesLines
2025-02-21Removed ImageSpriteThorbjørn Lindeijer1-2/+0
The only use of ImageSprite was for FloorItem instances, which now just draw the item icon in FloorItem::draw. This leaves only one Sprite subclass, AnimatedSprite, which means we can remove the entire virtual Sprite interface.
2025-02-21Replaced ImageSprite in Emote by plain ImageThorbjørn Lindeijer2-11/+20
Emotes just need an image to be represented in the UI, so we don't need to use ImageSprite.
2025-02-21Fixed too fast animations for MiniStatusWindow iconsThorbjørn Lindeijer1-1/+1
AnimatedSprite works with delta time since 7de0b165f196cb0c1f983b6d2a. Adjusted some parameter names for clarity. Closes https://git.themanaworld.org/mana/mana/-/issues/94
2025-02-17Further ResourceManager and PhysFS cleanupsThorbjørn Lindeijer5-27/+48
* Wrapped remaining PhysFS API calls and set PHYSFS_DEPRECATED to suppress deprecation warnings for PHYSFS_getUserDir, since no alternative is available for now. * Removed support for decompressing .gz files, since it has been unused for years and doesn't seem useful when updates are anyway served in an archive. * Use SDL_LoadFile and SDL_LoadFile_RW convenience functions (raises minimum SDL version to 2.0.10). * Removed ResourceManager::copyFile, since it was unused and will likely stay unused. * Removed ResourceManager::loadTextFile. Instead, split up the string in BrowserBox::addRows without making additional copies.
2025-02-17Wrapped PhysFS usage in a convenience APIThorbjørn Lindeijer1-1/+2
* Most direct PhysFS calls now contained within a single header file. * File class that automatically closes. * Files class allows iterating files with range-based for. * Use std::optional to force error handling where applicable.
2025-02-14Fixed handling of update URLs which mention a portThorbjørn Lindeijer1-1/+1
This appears to have been a regression in f405849b49614254f42eb3ee6147434458978623, which for some reason erased the port (and any trailing parts) from not just the update directory but also from the update URL. Unfortunately we can't access Mana-Mantis #381 at the moment, but presumably the port was removed due to the colon being a problematic character. Instead, now the colon (and other special characters) are replaced by _ when determining the update directory. Closes https://git.themanaworld.org/mana/mana/-/issues/80
2025-01-21Replaced include guards with #pragma onceThorbjørn Lindeijer104-418/+104
Thanks to https://github.com/cgmb/guardonce and a follow-up replace to remove duplicated newlines at end of file: find src -type f -name '*.h' -exec \ sed --in-place -e :a -e '/^\n*$/{$d;N;};/\n$/ba' {} \; Source: https://unix.stackexchange.com/questions/81685/how-to-remove-multiple-newlines-at-eof Fixes compile on macOS, which appears to have been due to the EVENT_H include guard.
2025-01-21Update names as soon as the "Show gender" option is changedThorbjørn Lindeijer2-9/+12
No need to wait for Apply for this option. Using `ConfigOptionChanged` event rather than direct call into `ActorSpriteManager::updatePlayerNames`.
2025-01-21Fixed ConfigOptionChanged eventsThorbjørn Lindeijer4-10/+10
With the statically typed config we no longer get an event for each changed config value. Where relevant, this is now done through `setConfigValue`. The `Event` now uses a `std::any`, which for `ConfigOptionChanged` events is set to the changed `Config` member. This allows for a type-safe check on which config value was changed.
2025-01-20Made client config statically typedThorbjørn Lindeijer46-433/+281
This makes accessing the config values much faster, since it no longer needs to do a lookup nor string conversion, which means we could remove some needless copying of the values. Overall it makes it easier to find out where settings are used and it puts the defaults along with the declaration. Options with default values are no longer saved to the config file. This does not include unrecognized options, which are kept around to provide some compatibility with older clients. While most basic options have kept the same name, more complicated settings like window geometry, shortcuts, outfits, etc. now have their own XML elements. Older clients will ignore these and erase them when saving the configuration.
2025-01-20Wrapped xmlNodePtr access with a Node classThorbjørn Lindeijer3-43/+39
Slightly more ergonomic and this eliminates direct libxml2 usage from many places.
2024-10-29Turned the PlayerRelation struct into an enum classThorbjørn Lindeijer2-14/+14
Less code to achieve the same thing (strong type and namespaced values). The permissions related values have been moved to a PlayerPermissions struct, which is also a bit less confusing.
2024-10-29Optimise PlayerRelationsManager::clearThorbjørn Lindeijer3-19/+11
Previous implementation was O(n^2), doing lots of work (saving file and updating UI) for each removed player.
2024-10-29Avoid some needless pointer indirectionThorbjørn Lindeijer1-17/+12
* Don't use `PlayerRelation*` in `mRelations`, but just store the value. * Pass `std::vector<PlayerIgnoreStrategy *>` by reference instead of pointer. * Return player list in `PlayerRelationsManager::getPlayers` by value instead of pointer. Overall these changes simplify the code, making it less prone to errors.
2024-10-26Fixed FPS limit being enabled by defaultThorbjørn Lindeijer3-7/+7
There were some inconsistencies between the values set up in `Client::initConfiguration` and those in `getConfigDefaults`. These duplicates have now been removed. For some of these settings the code getting the values had to be adjusted to use getBoolValue, to actually rely on the provided default instead of one provided as a parameter.
2024-10-23Changed SERVER_NOTICE macro to inline functionThorbjørn Lindeijer4-39/+39
Seems to be no point in using a macro here.
2024-10-23Various small fixes to translatable stringsThorbjørn Lindeijer4-7/+6
Mostly adjustments based on feedback from the Finnish translator.
2024-10-18Added small grabbable margin to Shortcuts windowThorbjørn Lindeijer5-81/+32
The Shortcuts window could no longer be moved since adding support for resizing windows at the top edge. Now there is again a bit of space where the window can be grabbed. Included some related cleanups.
2024-10-18Avoid accessing static members through instancesThorbjørn Lindeijer3-8/+8
Fixed with clang-tidy `readability-static-accessed-through-instance` check.
2024-10-18General code cleanupsThorbjørn Lindeijer1-3/+2
2024-10-08Small cleanup in OutfitWindow::loadThorbjørn Lindeijer2-19/+7
Based on MV commit db452921bafb2dd322b52c1e5d03e5e713849dd0.
2024-10-08Restore the screen shake effectThorbjørn Lindeijer2-30/+32
Now the experience mightes better with what it was before the logic update change (59a7d5c58f8b3af21b3e19d4e78f5653bf011bfb). The per-frame effect is reduced and less constant, based on a sine wave. The effect is no longer applied directly to the mPixelViewX/Y values, but is rather only taken into account when rendering the view.
2024-10-08Smoother being movementThorbjørn Lindeijer1-13/+11
There was a slight stutter in being movement, since each time a being reached the next position along its path, it would only continue to the following position with the next logic tick. Now the logic has been adjusted to keep moving until all the time for the current frame was used up, or the path was exhausted. A slight stutter remains for keyboard movement, as well as broken walk animation playback, since it will only set a new path once the current one is finished (see e554d9b2be1ec2fcb15065ae70151302adeef602). Also simplified some logic in Viewport::draw and removed some obsolete code in LocalPlayer::startWalking.
2024-10-08Do a single logic update each frameThorbjørn Lindeijer1-1/+1
The logic update now uses Time::deltaTimeMs() where needed to make it framerate-independent. This means there will no longer be multiple logic calls per frame (as was usually the case with logic ticking at 100 fps whereas the game would generally run at 60 fps). At the same time, the game can be more precise at higher framerates and should now run smoother at 144 Hz, for example. Previously the game would sometimes skip logic ticks at that rate. This change affects: * Updating of animations * Being movement speed * More moving of manual time variables to Timer Notoriously, the particle system still does 100 ticks/second.
2024-10-08Added convenient and efficient Timer classThorbjørn Lindeijer11-154/+145
The Timer is efficient because it does not depend on incrementing a counter to keep track of time, nor does it call SDL_GetTicks every time its state is checked (this happens once per frame instead). Along with global functions Time::absoluteTimeMs() and Time::deltaTimeMs(), this replaces previous globals tick_time, cur_time and get_elapsed_time(). For now, there is still a fixed 100 times per second logic call rate, but the new Time::deltaTimeMs() function should allow getting rid of this.
2024-10-04Removed useless LocalPlayer::mUpdateNameThorbjørn Lindeijer4-21/+3
Maybe it once had a use, but a change in the "Show own name" setting is already handled by LocalPlayer::event.
2024-09-28Replaced all "xmlChildrenNode" with "children"Thorbjørn Lindeijer1-2/+2
Because "xmlChildrenNode" is a macro defined for compatibility with libxml1, which we don't support.
2024-09-28Removed getter/setter cruft from ItemInfoThorbjørn Lindeijer7-28/+25
Made the class and the code in general more readable by removing all the needless getters and setters.
2024-09-27Replaced for_each_xml_child_node macro with helper classThorbjørn Lindeijer3-5/+5
The new XML::Children class enables using a C++11 range-based for loop to iterate over the children of an xmlNodePtr.
2024-09-02Added a hand mouse cursor, used when hovering linksThorbjørn Lindeijer4-14/+24
InputEvent::mIsConsumed is used to tell the Window it should not change the mouse cursor as well. This change also adds a closed hand mouse cursor, though this is unused for now (might be useful when dragging stuff around). The new cursors are by meway.
2024-08-31Apply a margin to the text in the help windowThorbjørn Lindeijer1-7/+3
And removed the manual space character at the start of each line...
2024-08-31Display "Mana" as part of the version in Setup windowThorbjørn Lindeijer1-1/+1
This was already done in the log, when responding to the --version parameter and for the label on the Desktop widget, but not in the Setup window. Now it is consistently part of the FULL_VERSION define.
2024-08-31BrowserBox: Make sure to start each line with the default colorThorbjørn Lindeijer1-1/+4
This was already the case for each newly added line, but when the entire layout was redone previous selected colors would spill over to the next line.
2024-08-31Some margin and indentation tweaks in news and NPC dialogsThorbjørn Lindeijer6-40/+41
* Apply indentation after wrapping only in NPC dialogs and chat window, since we don't want this in the updater window / news. * Added some margin around the text in the updater window and NPC dialogs, using gcn::Widget::setFrameSize. * Cosmetic changes to BrowserBox implementation.
2024-08-28Fixed handling of consecutive text formatting markersThorbjørn Lindeijer1-11/+7
If a text contained for example "##3##B", expected behavior was to switch to blue color and bold font. Instead, due to there being no actual text in between the markers, the layouting code was aborting prematurely here: if (mMode == AUTO_WRAP && partWidth == 0) break; As far as I could judge, this check is actually not necessary anyway, but I've kept it for now since the wrapping code looks so problematic. Instead, a while loop now makes sure we process all consecutive formatting markers. Closes #75
2024-08-26Limit shop's Max button to available carry weightFedja Beader1-1/+13
(cherry picked from M+ commit 13b9ff5baf1f6d31cc6bfa5bd30bacd45b80539c)
2024-08-25Fixed initialization of equipment backendThorbjørn Lindeijer2-68/+62
For new characters (and in general, when logging in with a character that had nothing equipped), the equipment backend wasn't being initialized. This resulted in the equipment not being visible in the Equipment window. Fixes #83
2024-08-15Fixed resize border width on bottom and right sidesThorbjørn Lindeijer1-4/+4
2024-08-04Removed a bunch of unused NPC related eventsThorbjørn Lindeijer2-30/+11
Nobody cared for the events that were emitted when NPC related network messages had been sent.
2024-08-04Small code simplification in Button::initThorbjørn Lindeijer1-10/+7
2024-08-04Reuse Window::ensureOnScreenThorbjørn Lindeijer1-17/+7
Less code duplication.
2024-06-25Added online player list to Social windowDavid Athay4-23/+105
The online list refreshes every 18 seconds, which matches ManaVerse behavior. It's not ideal, but to improve this would mean diving into TMWA. The client version was bumped to 8 to get a SMSG_ONLINE_LIST reply. Further changes needed related to the client version are tracked by #71. This also changes the TabbedArea to take into account the frame size for its tab widgets, to make sure those frames are not clipped by the TabbedArea widget (as happened in the Social window). The horizontal scroll bar is now disabled in all social tabs, with the vertical one appearing only when necessary. Closes #61
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.