summaryrefslogtreecommitdiff
path: root/src/client.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-10-26Fixed FPS limit being enabled by defaultThorbjørn Lindeijer1-21/+6
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-08Do a single logic update each frameThorbjørn Lindeijer1-14/+4
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 Lindeijer1-47/+17
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-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-28Fixed choosing default world when using -D command-line parametercuoco1-6/+1
- Updated STATE_WORLD_SELECT case to automatically select the first world and proceed to update state when mOptions.chooseDefault is true. - This change ensures that the world selection window is bypassed for a smoother user experience when the default selection option is enabled. - Improved logic to handle cases with only one available world and directly proceed without showing the dialog.
2024-04-17macOS: Create an app bundleThorbjørn Lindeijer1-16/+2
Also enable using `cpack -G DragNDrop` to create a DMG to easily drag Mana into the Applications folder. The DMG is also available as a CI artifact. The minimum deployment target has been set to 10.15, as required due to usage of std::filesystem::create_directories.
2024-04-12CMake: Use GNUInstallDirsThorbjørn Lindeijer1-2/+1
This should make CMake options a little more standardized. The Windows part could potentially still be unified further. Absolute paths are now only used for the defines and not for values going to install() commands.
2024-04-08Set Windows-related DPI hints to per-monitor aware v2Thorbjørn Lindeijer1-0/+4
Set SDL_HINT_WINDOWS_DPI_AWARENESS to "permonitorv2", which tells Windows the application will handle all scaling. We don't currently adjust the window size when it changes monitors, but mainly use this hint to disable scaling by the system, since that blurs fonts and pixel art. Once we can properly handle fractional scaling (which is common on Windows), we can set SDL_HINT_WINDOWS_DPI_SCALING to "1" instead.
2024-04-08Windows: Modernize getSpecialFolderLocationThorbjørn Lindeijer1-3/+3
Ported from CSIDL to newer FOLDERID API and used wcstombs_s to convert the returned path to a multi-byte string. Fixes issues when the Windows username contains special characters.
2024-04-08Compile fixes for MSYS2 UCRT64Thorbjørn Lindeijer1-3/+4
Also added instructions for installing the dependencies on MSYS2. The selection of the default language is commented out for now. It will be fixed in another change.
2024-04-02General code cleanupsThorbjørn Lindeijer1-2/+2
* Removed some unused includes * Removed unused ListBox::mFont * Removed wrong cast to SDL_Scancode * Removed superfluous .c_str() * Removed superfluous explicit std::string construction * Removed unused variable * Use more emplace_back * Turned FindBeingFunctor into a lambda * Avoid needless pointer references for ambient layers and use a vector
2024-03-26Added support for HiDPI fontsThorbjørn Lindeijer1-4/+1
* TrueTypeFont class now takes into account the graphics scale, in order to render an appropriate higher-resolution texture. * Removed TrueTypeFont::fontCounter, since TTF_Init/TTF_Quit already keep a counter. * Avoid copying the rendered string needlessly, when it already exists in the cache. Avoid another copy, when inserting a new chunk into the cache.
2024-03-25Allow mouse focus click-throughThorbjørn Lindeijer1-0/+2
This is generally expected on Linux, where it feels annoying that the initial click just focuses the window. On macOS it's a little bit different, since applications can be specific about which elements are directly clickable and which aren't, but in general it feels better to me when the UI can be interacted with directly.
2024-03-22Added support for scaling the outputThorbjørn Lindeijer1-9/+16
* Added "Scale" user option, which can either by "Auto" or an explicit scaling factor. Its maximum value depends on the current resolution. The "Auto" factor is based on keeping the logical resolution on at least 800x600, wheres the maximum scale is based on keeping the logical resolution on at least 640x480. * Enabled support for High DPI. This means the rendering target can now have a different resolution than the window size, which can happen on macOS, Windows and Wayland. The resulting scale is multiplied by the above user-controlled scale. Currently, this looks ugly for non-integer scales, which are not used on macOS and can only be configured on some Wayland compositors. Has not been tested on Windows. * Simplified OpenGL initialization (moved out of _beginDraw). * Made sure _beginDraw/_endDraw sets a clip area also for SDLGraphics.
2024-03-12General code cleanupsThorbjørn Lindeijer1-7/+3
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
2024-03-08Removed SDL2_gfx dependencyThorbjørn Lindeijer1-20/+35
Since the upgrade to SDL2 it was only used for framerate limiting, which I've replicated in a small helper class. Also reduced the framerate limit while minimized from 100 to 10 FPS.
2024-03-06General code cleanupsThorbjørn Lindeijer1-13/+2
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
2024-03-02Exit with error when invalid server type is passed on CLIThorbjørn Lindeijer1-1/+1
Also made it exit with error when there is an unknown option or missing argument.
2024-03-02Changed server type to "enum class"Thorbjørn Lindeijer1-5/+5
2024-03-02Added support for -y / --server-type parameterThorbjørn Lindeijer1-10/+22
Usually this would be guessed correctly by the port, but now it is also possible to just specify the server type and the port will be derived from there, unless a default port is given in the branding file. Closes #56
2024-02-27Added VSync and windowed fullscreen optionsThorbjørn Lindeijer1-55/+34
The configuration and setup UI were adjusted to the new options. This also fixes issues in applying new video settings. Default resolution was changed from 800x600 to 1280x720. VSync is enabled by default while FPS limit was disabled. Display aspect ratio for the resolution options. I had to work around some macOS issues: * Don't change window size when it appears to be "maximized", since it just changes the rendering area while leaving the window maximized. * Unset fullscreen display mode temporarily to allow changing resolutions, otherwise the rendering area no longer matches the screen and mouse input is also off. * Removed SDL_WINDOW_ALLOW_HIGHDPI for now because it causes issues on macOS, since we're not actually handling the scaling factor. A Video class and an SDLGraphics subclass were split off from Graphics. This setup has Less duplication and leaves the OpenGLGraphics and SDLGraphics better separated. Fixes #57 Fixes #58
2024-02-22General code cleanupsThorbjørn Lindeijer1-4/+4
* Use default member initializers * Use range-based loops * Don't use 'else' after 'return' * Removed some unused includes * Construct empty strings with std::string() instead of "" * Clear strings with .clear() instead of assigning "" * Check whether strings are empty with .empty() instead of comparing to "" * Removed redundant initializations
2024-02-19Updated PhysicsFS API usageThorbjørn Lindeijer1-47/+9
Unfortunately, since we're making a difference between config and data, and also want to know where to write screenshots, we can't get rid of PHYSFS_getUserDir entirely. We'd need a replacement to get rid of the deprecation warnings. Also removed copying of old config file at "/.tmw/config.xml".
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-21/+21
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-26Disable "opengl" by default and remove unused "hwaccel" optionThorbjørn Lindeijer1-3/+2
Since we now use SDL2, OpenGL is used through the SDL2 API. This appears to work very well and handles resizing better (with less flicker). Our manual OpenGL rendering code is probably obsolete. The "hwaccel" option referred to hardware accelerations supported by SDL1 and is no longer relevant.
2024-01-25Minor includes cleanupThorbjørn Lindeijer1-5/+0
2024-01-25Ported to SDL2Thorbjørn Lindeijer1-59/+62
2024-01-24Fixed potential crash on exitThorbjørn Lindeijer1-2/+1
2013-05-22paths.xml content is now read from settings.xmlPrzemysław Grzywacz1-3/+0
2013-05-07items.xml can be used from settings.xmlPrzemysław Grzywacz1-16/+8
2013-05-04Client-side settings are now available from settings.xmlPrzemysław Grzywacz1-12/+8
2013-04-27Added support for charcreation.xml settingsThorbjørn Lindeijer1-0/+3
This file was introduced by ManaPlus as a way of configuring the character creation process. It defines the number of hair styles and colors, how stat points should be divided and what the starting equipment of the player is. The minimum and maximum hair color/style IDs are not supported at the moment. This is mostly a backport of ManaPlus commits 10cf52b5 and dcc18eba, with some style changes. Mantis-issue: 501 Reviewed-by: Ablu
2012-08-11Removed two unused variablesThorbjørn Lindeijer1-3/+0
Reviewed-by: Erik Schilling
2012-08-05Enable OpenGL by default on all platformsThorbjørn Lindeijer1-5/+1
Before it was only enabled by default for Mac. Reviewed-by: Erik Schilling
2012-02-18Added notification sound on receiving whisperThorbjørn Lindeijer1-1/+2
One of the sound channels is reserved for notification sounds, of which the volume can be configured separately. Currently, the only notification sound that is played is for receiving whispers. That can be extended later. The newmessage.ogg sound used currently is the one for receiving a message with the Psi instant messenger. Parts of this patch are based on the new message notification in ManaPlus. Reviewed-by: Erik Schilling
2012-02-09Allow changing fullscreen resolution without restartThorbjørn Lindeijer1-15/+22
Unified Graphics:setFullscreen and Graphics:resize into a single Graphics:changeVideoMode function that tries to restore the existing mode when changing to the new mode didn't work, and exists with an error when that also fails. Split up handling of SDL_VIDEORESIZE and the adapting to new resolution in the Client class, so that the second part could also be called when changing resolution fullscreen mode. The Video tab in the Setup window now also filters out any modes smaller than 640x480 since the game won't properly adapt to that resolution anyway. Reviewed-by: Yohann Ferreira
2012-02-04Removing password from memoryStefan Dombrowski1-1/+2
If the player switches login, then the password field in the login window should be empty. This was not the case after registering or password change. Reviewed-by: Ablu, Bertram
2012-02-03Changed the setup button at login stage to use the icon.Yohann Ferreira1-1/+3
I also made the button not readjust its size when deleted to avoid a crash. Reviewed-by: Erik Schilling
2012-02-02Fix to the hair colors and styles handling.Yohann Ferreira1-4/+4
- I made the charCreatedialog handle a possible max permitted color Id and a minimum hair style id for tA. - Added a foundation to later load the styles and colors from the same file, to handle the Mana-issue #224 for manaserv. - Support for non-contiguous hair color and style ids has also been added. - I also replaced the < and > arrow signs with images. Reviewed-by: Ben Longbons, Thorbjørn Lindeijer
2012-01-28Make command line choose character only work onceThorbjørn Lindeijer1-0/+4
Previously it was interfering with the 'switch character' functionality. Reviewed-by: Erik Schilling
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2012-01-26Remember the window size after resizingThorbjørn Lindeijer1-0/+5
Makes sure that the client starts up again in the same size. Reviewed-by: Erik Schilling
2012-01-24Stream music files directly from the archivesThorbjørn Lindeijer1-5/+6
Use Mix_LoadMUS_RW to stream music files directly from PhysFS. I kept around ResourceManager:copyFile for now, since it may have other uses. Also cleaned up some initialization of configuration defaults. Reviewed-by: Yohann Ferreira
2012-01-22Allow resizing of the game in windowed modeThorbjørn Lindeijer1-13/+40
Window positions are semi-smartly corrected as a result of the resize. Not supported when using OpenGL on Windows for now. Reviewed-by: Yohann Ferreira
2012-01-18ColorDB -> HairDB.Yohann Ferreira1-3/+3
This will ease the reading of the next patch about hair handling at character creation time in tAthena. As requested by bjorn. Reviewed-by: bjorn
2012-01-16Renamed some file names for consistency with the class namesThorbjørn Lindeijer1-3/+3
This was already done by ManaPlus. It's a good idea anyway and it makes comparing the code a little easier. Reviewed-by: Yohann Ferreira
2012-01-10player_node -> local_playerYohann Ferreira1-2/+2
Reviewed-by: Ablu
2012-01-09Made the client able to remove the port from update urls.Yohann Ferreira1-33/+21
Resolves: Mana-Mantis #381. Reviewed-by: Ablu.
2011-10-25Change the wrong, but mostly supported WIN32 macro to the correct _WIN32, ↵Bernd Wachter1-9/+9
enforced by -std=c++0x Reviewed-by: Thorbjørn Lindeijer
2011-06-02Arbitrary code cleanupsThorbjørn Lindeijer1-3/+3
Just some stuff that piles up while "looking" at the code, which eventually gets annoying to ignore while staging real changes. * Replaced a few NULL occurrences with 0 * Rely on default parameter for std::vector::resize. * Replaced a few "" with std::string() * Prefer .empty() to == "" * Removed a few comparisons with NULL * Don't check pointers before deleting them * Removed a bunch of redundant semicolons * Made some global variables static (local to their compilation unit) * Prefer prefix ++/-- operators to postfix versions when possible * Corrected location of a comment