summaryrefslogtreecommitdiff
path: root/src/resources
AgeCommit message (Collapse)AuthorFilesLines
6 daysGUI: Added Desktop skinHEADmasterThorbjørn Lindeijer3-0/+3
Replaces the default login wallpaper. The wallpaper can still be set either through branding or in the client data. This also fixes the scaling of the Manasource logo when using the Mana theme. Closes #99
6 daysWork around player invisibility caused by "unspecified" genderThorbjørn Lindeijer1-2/+2
The "Unspecified" gender was causing some older players to be invisible since no sprites were displayed at all. I think this is a bug in TMWA, which should never send SEX::UNSPECIFIED for player characters, but while this bug exists we can make sure to map this to Gender::Neutral (renamed from "Hidden"). The Gender::Unspecified value was removed entirely because it never makes sense for beings. One "neutral" value should be enough.
14 daysFixed issues related to wrong alpha mod set on texturesThorbjørn Lindeijer1-12/+3
Due to the use of SubImage, there can be multiple images pointing to the same SDL_Texture with different alpha values. However, since the alpha mod set on the texture was only set from Image::setAlpha, images were not always rendered with the correct alpha value. Now the alpha mod is always set right before rendering each image. Most of the time the alpha will remain the same, but I don't expect this to become a performance issue so I've not added extra variables and checks to suppress such calls when they aren't needed. On the upside, this simplifies the "use color" option, which previously had to restore the previously set alpha mod. Closes #117
2025-07-15Render font outlines using TTF_SetFontOutlineThorbjørn Lindeijer1-8/+6
Rather than rendering the same texture 4 additional times, render a specific outline version of the text. While reducing the number of times the text is drawn, it does increase font texture use. Result is a generally prettier outline due to rendering it properly at sharp corners of the characters. The shadow for outlined text is now also thicker, as appropriate. As part of this change, the `TextRenderer` class was merged into the `Graphics` and `TrueTypeFont` classes. There seemed to be little point in having a separate function for this, apart from needing more static casts to `Graphics*`. Also fixed an issue where the font style was not being restored after adjusting the font scale, when using an older SDL_ttf than 2.0.18. Closes #87
2025-07-15Theme: Introduced HIGHLIGHT_TEXT colorThorbjørn Lindeijer2-0/+2
For customizing the text color used with HIGHLIGHT color as background.
2025-07-14Fix quests window destruction and add QuestDB::initThorbjørn Lindeijer4-4/+10
The init call makes sure there are no quests loaded, which is necessary because `SettingsManager::unload` is only called on exit and not when switching servers. Closes #112
2025-07-12Typo fixes (based on reports by meway)Thorbjørn Lindeijer1-1/+1
2025-07-11Cleaned up ImageRect a littleThorbjørn Lindeijer1-1/+1
* Use `std::unique_ptr`, so we can get rid of the custom move constructor and destructor. * Move and rename the `ImagePosition` enum to `WindowAlignment`, which fits better with what this enum is actually used for.
2025-07-06Add support for custom text colors for progress bars in GUI themeAndrew Hall2-13/+32
Since there was already specific support for theming different progress bars with a custom color gradient, it was relatively straight-forward to extend this to support custom text formats. Thanks to @Meway for having an initial go at this feature! Closes #111
2025-07-04Added logging priorities and use SDLs logging facilitiesThorbjørn Lindeijer23-170/+167
By using SDL logging, we can rely on SDL to filter the log messages by their priority before they get sent to our custom output function. For example, we now no longer get entries for created and destroyed Window instances by default, since these have only "debug" priority whereas the default priority for the "app" category is "info". We can also get log messages raised by SDL itself in our log now. Log levels can be controlled per category through the "SDL_LOGGING" environment variable. Many existing log messages have been assigned a category based on their existing prefix.
2025-07-02Implemented effects for new and completed questsThorbjørn Lindeijer2-0/+51
2025-07-02Added Quests windowThorbjørn Lindeijer2-7/+63
This window gives an overview over completed and currently active quests. A persistent checkbox toggles whether completed quests are shown. Item links are supported in quest texts. New window icon by meway. Completed quest icon for Mana theme copied from ManaPlus. The Quests window has no shortcut for now.
2025-06-23Apply quest effects to NPCsThorbjørn Lindeijer2-5/+75
The `TmwAthena::PlayerHandler` now handles the quest variables and applies the active quest effects to NPCs. They are updated when variables change or the map changes.
2025-06-17Add quest database support and parsing utilitiesThorbjørn Lindeijer3-0/+194
- Introduce QuestDB with quest/effect structures and XML parsing - Register questdb in CMake and settings manager - Add fromString overload for std::vector<int> parsing
2025-05-01Fixed crash on Windows related to choosing wrong log overloadThorbjørn Lindeijer1-1/+1
When compiled with MinGW, the va_list overload of Logger::log was chosen where a char* was passed, causing a crash at runtime. Resolved by renaming the va_list version to Logger::vlog.
2025-04-29Dye: Cast to SDL_Color rather than shifting bits aroundThorbjørn Lindeijer3-32/+35
When we use SDL_PIXELFORMAT_RGBA32, which is actually the same as SDL_PIXELFORMAT_ABGR8888 on little-endian systems, we can cast the pixel data directly to SDL_Color* for easy access to the components. This may also make applying dye more efficient on big-endian systems, though I have no such system to test with. Follow-up to d8b871727c363892b14f2eadfad8f6058ec6ab72.
2025-04-28GUI: Added skin for the emote slots in the EmotePopupThorbjørn Lindeijer2-0/+2
Allows more flexible customization as needed by Jewelry theme.
2025-04-26GUI: Added support for explicit outline color per palette entryThorbjørn Lindeijer2-24/+26
This enables customized outlines for each text color as well as adding outlines for specific palettes, as done by the Jewelry theme. Merged PARTY_CHAT_TAB and PARTY_SOCIAL_TAB into just PARTY_TAB since we should probably be using the same color there anyway. Split off WHISPER_TAB as separate color from WHISPER.
2025-04-25GUI: Added support for multiple color palettes to ThemeThorbjørn Lindeijer2-39/+133
Each Skin can point to a different palette, which can be used to tweak text colors where necessary. For now there is no generic solution for this, instead a number of locations have been adjusted to take the palette into account: * ChatWindow sets its palette on the BrowserBox used in its tabs. * Popup sets its palette on child widgets when they are added (covering BrowserBox, Label and TextBox). * ItemPopup now uses its palette when looking up colors. The BrowserBox now retrieves its numbered text colors from the theme. Also added OLDCHAT, AWAYCHAT and GLOBAL theme colors, with ##g, ##o and ##a to choose these colors respectively. Fixed ImageRect move constructor. TextPreview class was cleaned up from unused functionality. Being name colors are no longer different between the name shown on the being and the name shown in the SpeechDialog.
2025-04-25Introduced theme dropdown in interface setupThorbjørn Lindeijer2-60/+120
* Added Theme dropdown to Interface setup * Added CARET theme color * Fixed issue with logging errors in `check` function in `theme.cpp` * Fixed XML::Children::Iterator to iterate only element nodes * Changed default theme to "jewelry" Changing the theme (or font size) shows a dialog that points out a restart is required to apply these changes. This is necessary at the moment because many things, like default or minimum window sizes, are only calculated once.
2025-04-25GUI: Added support for hiding the scroll area buttonsThorbjørn Lindeijer2-0/+2
And made the Jewelry theme hide those buttons.
2025-04-25Simplified ImageRect handlingThorbjørn Lindeijer1-20/+9
We don't need to keep an array of SubImage instances, but can just remember the top, left, right and bottom margins and use those when rendering the scaled ImageRect. Graphics::drawRescaledImagePattern had to be extended to allow specifying the source rectangle.
2025-04-25GUI: Added support for defining named icons to the themeThorbjørn Lindeijer2-1/+58
Now we can define icon names for each equipment box and then look up the icon image through the theme, enabling some shared control over equipment slot icons between the game data and GUI theme. The icon for an equipment slot is also no longer rendered when the slot has an item in it. Removed the needless storing of equipment box positions and images in the EquipmentWindow, because this information is readily available from the InventoryHandler and the images are already loaded by the Theme.
2025-04-25GUI: Allow theme to skin item slots and equipment boxesThorbjørn Lindeijer2-18/+24
* Added EquipmentBox and ItemSlot skin types. * Allowed rectangles drawn by the theme to be not filled. * Added width/height attributes to skin element since we needed a way to specify the size of the item slots and equipment boxes.
2025-04-25GUI: Allow customizing the SkinType used by a WindowThorbjørn Lindeijer2-0/+2
Now different windows can use different skin types. This also introduces a new ToolWindow skin type, which is generally a window without title bar nor close button. Customized windows are: * Chat -> Popup skin * MiniMap -> Popup skin * ShortcutWindow (items and emotes) -> ToolWindow skin Even though the MiniMap now appears as a Popup, it does have a title, so appropriate attributes have been added to this skin type.
2025-04-05Avoid pixel format conversions when applying dyeThorbjørn Lindeijer1-19/+22
The images returned by IMG_Load_RW appear to usually be in the format SDL_PIXELFORMAT_ABGR8888. As such, adjust the code performing the dye to operate on this format rather than always converting the surfaces to SDL_PIXELFORMAT_RGBA8888. This appears to make the loading of dyed images about 30% faster.
2025-04-02Use a consistent naming style for enum class valuesThorbjørn Lindeijer6-31/+31
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.
2025-04-02General code cleanupsThorbjørn Lindeijer1-5/+4
* 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.
2025-04-01GUI: Made CheckBox, RadioButton and Slider more customizableThorbjørn Lindeijer2-0/+2
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.
2025-03-31GUI: Support customizing widget text format through themeThorbjørn Lindeijer2-59/+83
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.
2025-03-31GUI: De-hardcode the window title offsetsThorbjørn Lindeijer2-0/+4
2025-03-24Added fill mode parameter to ImageRectThorbjørn Lindeijer1-0/+11
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.
2025-03-24Expanded GUI theming capabilitiesThorbjørn Lindeijer2-100/+130
* 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.
2025-03-24Define the GUI theme in XMLThorbjørn Lindeijer2-671/+423
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-17Have ImageRect automatically initialize and clean upThorbjørn Lindeijer2-32/+7
2025-03-14Moved widget drawing code into ThemeThorbjørn Lindeijer2-146/+636
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 Lindeijer1-15/+7
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-07General code cleanupsThorbjørn Lindeijer1-17/+17
2025-03-07Support triggering attacks and play use ability animationsThorbjørn Lindeijer3-39/+45
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-07Renamed ability set to ability categoryThorbjørn Lindeijer3-20/+9
To match mana/manaserv@9c4b8e24487843f0b52108ba99c8c01f03bfae81.
2025-03-07Renamed specials to abilitiesThorbjørn Lindeijer4-55/+46
To match mana/manaserv@9ff69160ea1c3c64ea7012cd70a3b50ff4373264.
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-26Plugged various memory leaksThorbjørn Lindeijer1-1/+0
* 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 Lindeijer15-177/+201
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-25Added tooltips to status effect iconsThorbjørn Lindeijer1-0/+2
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-25Added support for option, opt1, opt2, opt3 status effect fieldsThorbjørn Lindeijer3-10/+173
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-21Replaced ImageSprite in Emote by plain ImageThorbjørn Lindeijer2-16/+9
Emotes just need an image to be represented in the UI, so we don't need to use ImageSprite.
2025-02-20Fixed stutter when new music starts playingThorbjørn Lindeijer1-1/+10
This is a workaround for a performance issue when SDL_mixer is using stb_vorbis. Since stb_vorbis will request the file one byte at a time, the overhead of using SDL_RWops to call PHYSFS_readBytes is too high. Solved by introducing a buffered SDL_RWops wrapper with a fixed 2048 byte buffer. This is a more optimal solution than loading the entire OGG file in memory. Now starting a new song takes less than 1ms, when the OGG file isn't compressed (almost down to 0.2ms when SDL_mixer uses libvorbisfile). See https://github.com/libsdl-org/SDL_mixer/issues/670 Closes https://git.themanaworld.org/mana/mana/-/issues/93
2025-02-17Further ResourceManager and PhysFS cleanupsThorbjørn Lindeijer3-186/+9
* 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 Lindeijer4-119/+80
* 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.