summaryrefslogtreecommitdiff
path: root/src/gui
AgeCommit message (Collapse)AuthorFilesLines
2025-03-11Implemented replacement of key names in NPC dialogThorbjørn Lindeijer3-0/+43
Now when NPCs text includes "###MoveUp;", it will get replaced by "Up", or whatever key is currently bound to that action. For compatibility reasons the key name can optionally have a "key" prefix, for example "###keyMoveUp;". Closes #73
2025-03-07Reuse gcn::ScrollArea::drawThorbjørn Lindeijer2-27/+7
Code appeared duplicated just because we don't draw the background, but this could be done by overriding drawBackground instead.
2025-03-07Removed the functionality to split item stacksThorbjørn Lindeijer5-143/+30
No longer supported by manaserv and not supported by tmwAthena.
2025-03-07General code cleanupsThorbjørn Lindeijer1-11/+0
2025-03-07Introduced spriteOffsetY setting to replace half tile hackThorbjørn Lindeijer1-3/+2
For historical reasons, sprites get a 16 pixel offset by default, which is used to position them correctly on their tile. When pixel-based movement was added, actors are now positioned on the middle of a tile and the built-in offset was removed. Servers that use sprites that do not rely on this offset can now set the spriteOffsetY option to 0.
2025-03-07Updated manaserv protocol to version 9Thorbjørn Lindeijer2-2/+2
This extends the messages regarding abilities, replacing the specific "attack" messages. It also unifies attribute handling, with a generic system replacing specific variables for attributes like level, xp and skills. The inventory and equipment handling was adjusted such that equipped items stay in the inventory. Support for quest states was added. Added: * GPMSG_ABILITY_REMOVED (mana/manaserv@e3fcc1a47db312933a0f5b7e725c5779a1a45722) * GPMSG_ABILITY_COOLDOWN (mana/manaserv@c2f00b2f3ba920cb25333d19a1d37d251342caf8) * GPMSG_BEING_ABILITY_POINT * GPMSG_BEING_ABILITY_BEING (mana/manaserv@2f2393b6d190deb8958fcb806b58418508d25e28) * GPMSG_ATTRIBUTE_POINTS_STATUS (mana/manaserv@1e5a15c0a5e24fb4b358fff75a7082d65496e1f9) * PGMSG_USE_ABILITY_ON_DIRECTION (mana/manaserv@05fc955a3f8a03539088fa7569395434e29d90e8) * GPMSG_BEING_ABILITY_DIRECTION (mana/manaserv@54389afd7ba9fecf0761333185145e968e2453ae) * GPMSG_QUESTLOG_STATUS (mana/manaserv@66a98a3a0df795761328d62ef2ad07f81e383f9e) Removed: * PGMSG_ATTACK * GPMSG_BEING_ATTACK (mana/manaserv@f31277b327df701361391b1d4b8bd6f89f4e3109) * GPMSG_PLAYER_EXP_CHANGE * GPMSG_LEVELUP * GPMSG_LEVEL_PROGRESS (mana/manaserv@44ee071d7ece5a2023f79307f36e8a244c9e7b3a) Changed: * GPMSG_ABILITY_STATUS (mana/manaserv@ba573fcc38580a01985172b9bc864c97ce855af3) * GPMSG_BEING_LOOKS_CHANGE (mana/manaserv@8ddda85d923a528c7497a628d2fe10fc40b80a1f) * APMSG_CHAR_INFO (mana/manaserv@4f5053f463fd8da0de1615ca6b0f212f02f3d653) * APMSG_CHAR_CREATE_RESPONSE (mana/manaserv@1263c729d85df649c7ab59726bddad7c8cd7ae81) * GPMSG_NPC_BUYSELL_RESPONSE (mana/manaserv@336ce321a9b996e56a61a5364bb32124efa84dd9) Equipment changes (mana/manaserv@f712d68495dd8e040c32da3b1c85bcb7845543ec): * Changed GPMSG_INVENTORY_FULL, GPMSG_EQUIP * Removed PGMSG_MOVE_ITEM * Added GPMSG_EQUIP_RESPONSE, GPMSG_UNEQUIP_RESPONSE, GPMSG_UNEQUIP While this change deals with some of the protocol changes, there's still many changes required in the UI regarding using of abilities (including attacking), showing of certain attributes and quest log.
2025-03-07Renamed specials to abilitiesThorbjørn Lindeijer3-57/+58
To match mana/manaserv@9ff69160ea1c3c64ea7012cd70a3b50ff4373264.
2025-03-01Further Download related cleanupsThorbjørn Lindeijer4-457/+266
* Moved the memory buffer and mutex handling into the Download class to simplify the code updating the UI in ServerDialog and UpdaterWindow. * Replaced the "DownloadUpdate" callback function with simply polling Download::getState, since in the end polling was happening anyway. This changes also fixes handling of the Enter key while downloading updates, which no longer cancels the update process. Also, when pressing Escape while things are being downloaded, the first press cancels and only the second press goes back to login. Introduced a ThreadSafe template class, which wraps any type and makes it only accessible by calling lock(). This ensures the data is never accessed without locking the relevant mutex.
2025-02-28Fixed unresponsive UI when switching server/char with Away dialog openThorbjørn Lindeijer2-7/+8
The UI became unresponsive as a result of not actually deleting the OkDialog. The dialog is now managed by the AwayListener, which now schedules Away dialog for deletion when necessary, using a DeathListener to clear the reference to the dialog. The WindowContainer now uses an std::set instead of std::list to keep track of widgets scheduled for deletion, to avoid crashing when a widget is scheduled for deletion multiple times.
2025-02-26Plugged a few more memory leaksThorbjørn Lindeijer8-50/+50
* DebugWindow and SkillDialog were not deleting their tabs nor their tab widgets. * TabbedArea was not deleting its arrow buttons. * Button was deleting its TextPopup on deletion of the last Button instance, which was wrong because it was also being deleted by the WindowContainer. Also removed some misplaced event forwarding to the TextPopup. TabbedArea is tricky because it does not automatically delete added tabs or their widgets. Tab instances are only deleted when they were added by name. Issues found by Valgrind memory analyzer.
2025-02-26Plugged various memory leaksThorbjørn Lindeijer5-76/+73
* ActorSpriteManager failed to delete its AutoCompleteLister instances. * CharCreateDialog was relying on ~Window to delete its child widgets, but it wasn't always adding all its widgets, so some failed to get deleted. Now it only creates the widgets it needs. * SkillDialog didn't delete its SkillModels. * PlayerList didn't delete its player Avatar instances. * Fixed deletion of the EffectManager. Leaks located using AddressSanitizer.
2025-02-26Use ResourceRef for all resource typesThorbjørn Lindeijer36-194/+137
All ResourceManager functions that load resources now return respective ResourceRef values, which helps to make sure resources are properly cleaned up. The Sound class was cleaned up and now also allows SoundEffect resources to be unloaded. The Animation class now keeps its ImageSet loaded only as long as necessary. Previously, SimpleAnimation and ParticleEmitter would keep the ImageSet loaded indefinitely by never decreasing its reference count. Reduced duplicated animation loading code between SimpleAnimation and ParticleEmitter.
2025-02-26Avoid %z type character in string formatThorbjørn Lindeijer1-2/+4
It triggers the following warning on MinGW: warning: unknown conversion type character 'z' in format [-Wformat=] Since we don't expect the number of online players to go beyond UINT_MAX, we can simply do a cast and use %u instead of %zu.
2025-02-26Cleanup Download code, fixing SDL_Thread leakingThorbjørn Lindeijer4-86/+55
The download thread was setting itself to nullptr (d->mThread = nullptr) in a number of locations. This caused a later call to SDL_WaitThread to be unable to perform cleanup. This reverts most of 1eb02f83a5d3895e4e18db30ea10d88da94ba4c0 (including making Download::cancel no longer blocking), but keeps the necessary waiting for the thread to finish before freeing the memory buffer in ~UpdaterWindow(), which might have been the bug fixed by that change. Fixed removal of downloaded .part file when its checksum failed. It trying to remove the file without .part appended instead. Fixed download progress indication in ServerDialog to not be reversed, though this is rarely visible due to the server list being so small. Fixed reporting of curl error.
2025-02-25Added tooltips to status effect iconsThorbjørn Lindeijer3-101/+115
Based on the name attributes in the status-effect XML elements. Also cleanup the code a little. Since the MiniStatusWindow now adjust its size to respect the status icons, those icons no longer have to be drawn from the Viewport.
2025-02-25Fixed status effect icon positionsThorbjørn Lindeijer1-4/+14
The status effect icons are implemented as sprites. Traditionally, since sprites were rendered on the map, they were by default centered horizontally on a tile and aligned to the bottom of the tile. The necessary offsets were part of the animation frames. This was changed in ae4aea451d6e2c44b273c963026c4fd697568f79 and 0248b2f58c783f21b7e68a20deadc0a3f942c869, which moved this offset to be applied at a later stage. At that point, client data was changed to remove this offset from the status effect icons, where it wasn't meaningful. Unfortunately, those client data changes were later reverted because the M+ fork of the client still applies the above offsets to the animation frames. Hence, to fix the status icon sprite positions, Mana client now applies the same offsets when rendering the status icons. Closes https://git.themanaworld.org/mana/mana/-/issues/95
2025-02-25Added support for option, opt1, opt2, opt3 status effect fieldsThorbjørn Lindeijer1-9/+10
Supporting these fields is necessary to correctly identify status effects sent by tmwAthena. This is a manual port of ac4e40a1408ad4d6fbcfce9d2bc6a0bc187ea5a4, 542d2ba78d84e0fa051e0620ccab5fb3a0c711e3 and 8800940bb4b94f6dab7dcf80bf0abc3e3b09e35f from M+.
2025-02-25Some code cleanups related to status iconsThorbjørn Lindeijer3-19/+16
Fixed leaking of Sprite instances.
2025-02-21Merged AnimatedSprite into SpriteThorbjørn Lindeijer2-6/+6
With AnimatedSprite being the only implementation of the Sprite interface, there was no longer a point in separating these.
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...