summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2 daysUse a consistent naming style for enum class valuesHEADmasterThorbjørn Lindeijer47-223/+224
Sometimes I've used CamelCase and sometimes SNAKE_CASE for these values. Since "enum class" values are always prefixed with the enum name, which uses CamelCase, I find it more fitting to use it for the values as well. Also fixes compilation on Windows where 'ERROR' was conflicting with a define.
2 daysGeneral code cleanupsThorbjørn Lindeijer16-171/+80
* Removed some unused includes and forward declarations. * Use std::unique_ptr to automate cleanup. * Use TextRenderer::renderText in BrowserBox to avoid code duplication. * Removed unused STATE_NORMAL from StateFlags. * Small layout fix in ServerDialog. * Reduced rewrapping delay in BrowserBox to 33ms and disabled it entirely when there are no more than 1000 lines to rewrap. The rewrapping is usually fast enough.
2 daysFixed minimum width of the Social windowThorbjørn Lindeijer3-10/+25
Needs to allow space for all three buttons, especially since they are no longer clipped to the window.
3 daysFixed crash on exit when CharCreateDialog is openThorbjørn Lindeijer4-10/+34
* Displayed Being was deleting its SpeechBubble after the WindowContainer had already deleted it. Resolved by registering a DeathListener. * On dialog deletion, the CharHandler had become a roaming pointer but was still accessed.
3 daysGUI: Made CheckBox, RadioButton and Slider more customizableThorbjørn Lindeijer14-72/+89
Added handling of padding and text format and added new "spacing" skin variable which is used for the space between the label and the control in case of CheckBox and RadioButton. Small tweaks to UI layout in various places.
4 daysUse color modulation to render text in different colorsThorbjørn Lindeijer2-21/+43
No need to cache the image in different colors since color modulation is cheap these days.
4 daysGUI: Support customizing widget text format through themeThorbjørn Lindeijer9-124/+291
The following widgets now support setting the font, text color, outline color and shadow color through the theme: * Button * Tab * Window (title) * ProgressBar The text format can be specified differently per skin state.
4 daysGUI: De-hardcode the window title offsetsThorbjørn Lindeijer4-9/+18
4 daysGUI: Apply clipping only where necessaryThorbjørn Lindeijer13-106/+123
Clipping has been disabled globally by taking it out of Graphics::pushClipArea. Now its name is a little confusing, but it can't just be changed since it is part of Guichan. Widgets that do need to clip their children use the new Graphics::pushClipRect, which pushes a clipping rectangle without affecting the local coordinates. These are: * ScrollArea * TextField * TabbedArea (scrolling tabs) * MiniMap While it might count as a small optimization, I'm actually disabling clipping because it is not always desired. For example it gets in the way of rendering the complete ResizeGrip in the Jewelry theme because that's a child widget.
11 daysAdded fill mode parameter to ImageRectThorbjørn Lindeijer3-37/+113
ImageRect now stretches the sides and center images by default because this is more efficient these days. FilMode::Repeat can be specified when repetition is desired. Added 'fill' attribute to allow the fill mode to be specified for the GUI theme images.
11 daysExpanded GUI theming capabilitiesThorbjørn Lindeijer38-416/+609
* Moved previously hardcoded values for frame size, padding and title bar height to the Skin. * Added support for rendering colored rectangles (used for scroll bar background). * Scroll bar width is now determined by its skin. * Added separate skins for horizontal and vertical scroll bars and horizontal and vertical scroll markers and added a skin for the shortcut box. * Added support for hovered state on window close button.
11 daysDefine the GUI theme in XMLThorbjørn Lindeijer23-894/+649
Now all images used by the various UI widgets are defined in a `theme.xml`, removing hardcoded requirements on the size of images, borders and sub-images and their locations. The `colors.xml` file was merged into this new file as well. The `<img>` element defines either a plain image, or a 9-scale that is automatically rendered at the size of the widget when any of the `left`, `right`, `top` or `bottom` attributes are given. The `x`, `y`, `width` and `height` attributes determine the sub-rectangle within the image referenced by `src`. `x` and `y` default to 0 and `width` and `height` default to the imge size. The `<state>` element defines in which state its images are used by setting its `selected`, `disabled`, `hovered` or `focused` attributes to either `true` or `false`. Only the first matching state is rendered. The `Text` and `SpeechBubble` classes now use the same skin to draw the bubble, as well as using a newly introduced `BUBBLE_TEXT` color from the theme palette.
2025-03-17Fixed small issue in SDLGraphics::drawRescaledImagePatternThorbjørn Lindeijer1-1/+2
It wasn't setting the size of the srcRect correctly when the last drawn images were partially cut off and the image wasn't being rendered at 1:1 scale. This issue might have affected ambient layers with mKeepRatio set to true.
2025-03-17Have ImageRect automatically initialize and clean upThorbjørn Lindeijer7-37/+36
2025-03-17Don't call static ResourceManager methods through instanceThorbjørn Lindeijer2-15/+10
2025-03-14Moved widget drawing code into ThemeThorbjørn Lindeijer39-1428/+839
This is cleaner overall since now each widget type no longer needs to keep track of its own instances and updating of the GUI alpha. It also introduces a single point from where the GUI theme support can be enhanced. Theme is no longer a singleton, though for now there is a single instance owned by the Gui singleton. Widgets adjusted to delegate their painting to the Theme: * Button * Tab * TextField * CheckBox * RadioButton * Slider * DropDown * ProgressBar * ScrollArea * ResizeGrip * PlayerBox (by subclassing ScrollArea) The Window and Popup widgets already use the theme through the Skin class. They can actually use a different skin per instance, though this feature is only used by the SpeechBubble.
2025-03-13Removed needless case-insensitive string comparisonsThorbjørn Lindeijer7-54/+13
These are not necessary since we can instead make sure the referenced values match case, like we do for everything else. This affects server types in the server list and colors referenced in theme files. The server version was also compared case-insensitively for some reason.
2025-03-11Implemented replacement of key names in NPC dialogThorbjørn Lindeijer5-13/+66
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 Lindeijer13-164/+30
No longer supported by manaserv and not supported by tmwAthena.
2025-03-07Fixed CompoundSprite::getWidth/getHeightThorbjørn Lindeijer2-14/+10
The getWidth and getHeight functions need to make sure the mWidth and mHeight members have been initialized, by calling redraw() when still necessary. Removed the unused getOffsetX/Y getters.
2025-03-07General code cleanupsThorbjørn Lindeijer12-78/+42
2025-03-07Fixed GeneralHandler deletion when switching server typesThorbjørn Lindeijer11-54/+33
When switching between tmwAthena and Manaserv the GeneralHandler was not getting deleted, resulting in crashes later on when the still around instance (or one of its child handlers) would try to respond to events it was listening to.
2025-03-07Introduced spriteOffsetY setting to replace half tile hackThorbjørn Lindeijer4-25/+12
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-07Fixed handling of equipmentThorbjørn Lindeijer4-18/+37
* Fixed ManaServ::EquipBackend removing all slots in response to GPMSG_INVENTORY_FULL, rather than resetting them to empty. * Fixed updating of buttons in InventoryWindow as relevant from the ManaServ::InventoryHandler. * Updated handling of equipment sprites in messages related to character appearance (Manaserv now always sends all relevant equipment and as such does not send removals).
2025-03-07Support triggering attacks and play use ability animationsThorbjørn Lindeijer7-50/+96
For now, PlayerHandler::attack just tries to trigger the "Strike" ability. Adjusted the AbilityDB to the removal of ability categories and the addition of the useaction attribute (mana/manaserv@81f126ae001b1446dc0be37341f133dca5ab2923)
2025-03-07Updated manaserv protocol to version 9Thorbjørn Lindeijer20-425/+373
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-07Ability related network message adjustmentsThorbjørn Lindeijer4-7/+14
* Handle GPMSG_ABILITY_REMOVED for removal of abilities (mana/manaserv@e3fcc1a47db312933a0f5b7e725c5779a1a45722) * Adjust GPMSG_ABILITY_STATUS now that it only sends abilities that have changed state, so it should no longer clear all abilities. (mana/manaserv@3598685c0fcbb9b5fdbcdbbaee258e2b55d5c98a)
2025-03-07Renamed ability set to ability categoryThorbjørn Lindeijer3-20/+9
To match mana/manaserv@9c4b8e24487843f0b52108ba99c8c01f03bfae81.
2025-03-07Renamed specials to abilitiesThorbjørn Lindeijer24-205/+195
To match mana/manaserv@9ff69160ea1c3c64ea7012cd70a3b50ff4373264.
2025-03-01Further Download related cleanupsThorbjørn Lindeijer8-532/+422
* 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-03-01Fixed leaking of resources referenced by resourcesThorbjørn Lindeijer1-6/+8
While cleaning up resources on shutdown, the resources they in turn referenced (like an Image referenced by an ImageSet) ended up in mOrphanedResources. Since the orphaned resources were only taken into account once, a lot of remaining orphans never got deleted. Technically a non-issue because it leaked on shutdown only, but it resulted in many faulty log entries about resources still being referenced as well as much noise from memory leak detectors.
2025-02-28Fixed unresponsive UI when switching server/char with Away dialog openThorbjørn Lindeijer5-49/+84
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-28Replaced buffered SDL_RWops wrapper with PHYSFS_setBufferThorbjørn Lindeijer4-225/+13
This removes the buffered SDL_RWops functionality that was just added in 51b0c3239265ddee2d1bf445f873299cc8193ab9. We just call PHYSFS_setBuffer instead. Using the PhysicsFS buffer is a little bit slower, likely because it operates at a lower level, but it is fast enough for our purposes. Uncompressed music files loaded from ZIP files can start playing in about 1-2 ms. I've also landed a fix for the problem in SDL_mixer, which works even better in any case: https://github.com/libsdl-org/SDL_mixer/pull/671
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 Lindeijer12-87/+85
* 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 Lindeijer69-726/+450
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 Lindeijer6-245/+179
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-26Fix unable to switch to another character after -D (chooseDefault) is used.Fedja Beader1-0/+1
Addendum to !108. Cherry-picked from M+ commit 78430c4bd86412a4b011632135c4eca71a435a1d.
2025-02-25Added tooltips to status effect iconsThorbjørn Lindeijer5-101/+118
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-25Some code cleanups in EffectManagerThorbjørn Lindeijer2-43/+43
Use a std::map to ease the lookup of triggered effects.
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 disabled "follow-parent" propertyThorbjørn Lindeijer1-1/+1
Normally one was expected to just leave out this property to disable it, but on TMW some of the particle effects have a value="0" attribute.
2025-02-25Replaced ParticleContainer with a ParticleHandleThorbjørn Lindeijer10-360/+96
The main feature of the ParticleContainer seemed to be to provide persistent access to particles, even though they are generally owned by their parent particle. This allowed particles to be moved along with the ActorSprite and to be killed explicitly when they were no longer wanted. The ParticleHandle now takes care of disabling automatic deletion and of killing the particle along with the handle. It allows the particle references to be stored in whatever container is suitable, like a vector for general ActorSprite particle effects, separate vectors for equipment based particles and finally a map for status effect particles. Moving the particles along with the ActorSprite does need to happen more explicitly now, but overall it's a nice cleanup.
2025-02-25Added support for option, opt1, opt2, opt3 status effect fieldsThorbjørn Lindeijer13-343/+320
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 Lindeijer6-33/+23
Fixed leaking of Sprite instances.
2025-02-22Fix incorrect reset animation.Andrei Karas1-3/+4
Cherry-picked from M+ commit 6b92b52308211bc61320e3c8062c59e7b4e81f65.
2025-02-21Merged AnimatedSprite into SpriteThorbjørn Lindeijer11-147/+85
With AnimatedSprite being the only implementation of the Sprite interface, there was no longer a point in separating these.
2025-02-21Removed ImageSpriteThorbjørn Lindeijer7-136/+44
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.