summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2025-05-25Fixed tooltip visibility logic for shortcut and inventory windowsHEADmasterThorbjørn Lindeijer6-31/+44
* When hovering an empty box in the shortcut window, the tooltip of a previously hovered non-empty box would stay visible. * When hovering to the right of a row of inventory items, the tooltip for the left-most item on the next row would be displayed. Also added some padding to shift the text and item icon a little in the shortcut window when using the Jewelry theme.
2025-05-21macOS: Use system Guichan by defaultThorbjørn Lindeijer1-1/+1
Guichan 0.8.3 was released and can now be installed through Homebrew, we don't need to rely on the Guichan submodule on macOS anymore.
2025-05-12TMWA: Added debug logging of sent messagesThorbjørn Lindeijer3-2/+16
2025-05-12Fixed handling of "close2" script commandThorbjørn Lindeijer3-30/+11
When adding support for SMSG_NPC_COMMAND in d5ebad4e74da011777f9ba1a13f, I mistakenly assumed the "close dialog" (5) command should just close the NPC dialog. However, the client is expected to send CMSG_NPC_CLOSE as well. Closes #91 Closes #107 Closes #108
2025-05-01Fixed loading of servers saved in client configThorbjørn Lindeijer2-7/+3
This was broken by 79e4325192f3260ed4ded264e43da8429650bf72 due to there being a case difference between the serverTypeToString and parseType functions, causing loaded servers to be invalid due to unknown server type. Closes #105
2025-05-01Fixed crash on Windows related to choosing wrong log overloadThorbjørn Lindeijer3-4/+4
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-29Made the Setup window key work during login sequenceThorbjørn Lindeijer2-2/+14
Closes #100
2025-04-29Changed removeColors to work in-placeThorbjørn Lindeijer6-44/+28
Can avoid some memory allocations. Also simplified its implementation a little. Also made ChatLogger::getDateString use the full year.
2025-04-29Reduced excessive use of getters in LocalPlayer::getNextWalkPositionThorbjørn Lindeijer2-60/+63
getWalkMask() and getCollisionRadius() are not going to return different values each time, so assign them to a local variable. Also marked LocalPlayer::getNextWalkPosition const.
2025-04-29Some Inventory and TradeWindow cleanupsThorbjørn Lindeijer5-81/+56
Mainly using std::vector<std::unique_ptr<Item>> to automate memory management.
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-29Fixed compile with ENABLE_MANASERV=OFFThorbjørn Lindeijer2-3/+3
2025-04-28GUI: Removed fixed width for ItemAmountWindowThorbjørn Lindeijer1-1/+1
The window needs to be slightly larger on Jewelry theme. By not specifying a width, the layout will take care of this.
2025-04-28GUI: Added skin for the emote slots in the EmotePopupThorbjørn Lindeijer4-29/+28
Allows more flexible customization as needed by Jewelry theme.
2025-04-28GUI: Use theme icons for offline/online player indicatorsThorbjørn Lindeijer2-34/+24
Instead of loading images directly, which is less flexible. In Jewelry theme, these icons are embedded in the window.png image.
2025-04-26GUI: Added support for explicit outline color per palette entryThorbjørn Lindeijer14-81/+180
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 Lindeijer33-384/+432
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 Lindeijer14-121/+257
* 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 Lindeijer4-9/+140
And made the Jewelry theme hide those buttons.
2025-04-25GUI: Added support for fixed-size scrollarea markersThorbjørn Lindeijer2-7/+338
Due to getVerticalMarkerDimension and getHorizontalMarkerDimension not being virtual, this unfortunately required copying a lot of code from Guichan to make sure it calls our versions of these functions. Also addressed a small issue where gcn::ScrollArea::checkPolicies was not taking the frame size of the content into account.
2025-04-25Simplified ImageRect handlingThorbjørn Lindeijer7-227/+173
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-25Jewelry: Fixed sticky button positionThorbjørn Lindeijer1-18/+18
Used "spacing" to store the additional space between the sticky button and the edge of the window (or the close button). Adjusted Popup and ToolWindow skins by one pixel to make the sticky button align the same way as for the Window skin.
2025-04-25GUI: Added support for defining named icons to the themeThorbjørn Lindeijer10-108/+126
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 Lindeijer11-107/+105
* 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 Lindeijer7-13/+34
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 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.
2025-04-02General 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.
2025-04-02Fixed 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.
2025-04-01Fixed 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.
2025-04-01GUI: 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.
2025-03-31Use 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.
2025-03-31GUI: 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.
2025-03-31GUI: De-hardcode the window title offsetsThorbjørn Lindeijer4-9/+18
2025-03-31GUI: 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.
2025-03-24Added 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.
2025-03-24Expanded 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.
2025-03-24Define 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.