diff --git a/src/fontcache.h b/src/fontcache.h index 92f22fe00a..13681fa6ff 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -229,7 +229,23 @@ public: ProviderManager::Unregister(*this); } + /** + * Try loading a font with this factory. + * @param fs Font size to load. + * @param fonttype Font type requested. + * @return FontCache of the font if loaded, or nullptr. + */ virtual std::unique_ptr LoadFont(FontSize fs, FontType fonttype) const = 0; + + /** + * We would like to have a fallback font as the current one + * doesn't contain all characters we need. + * This function must set all fonts of settings. + * @param settings The settings to overwrite the fontname of. + * @param language_isocode The language, e.g. en_GB. + * @param callback The function to call to check for missing glyphs. + * @return \c true if a font has been set, false otherwise. + */ virtual bool FindFallbackFont(struct FontCacheSettings *settings, const std::string &language_isocode, class MissingGlyphSearcher *callback) const = 0; }; diff --git a/src/fontcache/truetypefontcache.h b/src/fontcache/truetypefontcache.h index 19e7b0a2a1..61cc3a6f61 100644 --- a/src/fontcache/truetypefontcache.h +++ b/src/fontcache/truetypefontcache.h @@ -40,6 +40,12 @@ protected: GlyphEntry *GetGlyphPtr(GlyphID key); GlyphEntry &SetGlyphPtr(GlyphID key, GlyphEntry &&glyph); + /** + * Load the glyph as a sprite. + * @param key Unique ID of glyph to load. + * @param aa Whether to enable anti-aliasing. + * @return The loaded sprite. + */ virtual const Sprite *InternalGetGlyph(GlyphID key, bool aa) = 0; public: diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index fa2fffc598..6e5c22929a 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -823,9 +823,18 @@ public: this->UpdateStatistics(true); } + /** + * Update the statistics. + * @param initialize Initialize the data structure. + */ virtual void UpdateStatistics(bool initialize) = 0; - virtual std::optional GetDatasetIndex(int) { return std::nullopt; } + /** + * Get the dataset associated with a given Y-location within #WID_GRAPH_MATRIX. + * @param y The location along the Y-axis. + * @return The dataset index, or std::nullopt. + */ + virtual std::optional GetDatasetIndex([[maybe_unused]] int y) { return std::nullopt; } }; class BaseCompanyGraphWindow : public BaseGraphWindow { @@ -845,10 +854,6 @@ public: this->FinishInitNested(number); } - /** - * Update the statistics. - * @param initialize Initialize the data structure. - */ void UpdateStatistics(bool initialize) override { CompanyMask excluded_companies = _legend_excluded_companies; @@ -903,7 +908,13 @@ public: } } - virtual OverflowSafeInt64 GetGraphData(const Company *, int) = 0; + /** + * Get the data to show in the graph for a given company at a location along the X-axis. + * @param c The company. + * @param j The location along the X-axis. + * @return The value to show in the graph. + */ + virtual OverflowSafeInt64 GetGraphData(const Company *c, int j) = 0; }; @@ -1199,7 +1210,17 @@ struct BaseCargoGraphWindow : BaseGraphWindow { this->InvalidateData(); } + /** + * Get the CargoTypes to show in this window. + * @param number The unique identifier of the window. + * @return The cargo types to show. + */ virtual CargoTypes GetCargoTypes(WindowNumber number) const = 0; + + /** + * Get a reference to the cargo types that should not be shown. + * @return Reference to the cargo type mask to excluded from drawing. + */ virtual CargoTypes &GetExcludedCargoTypes() const = 0; std::optional GetDatasetIndex(int y) override diff --git a/src/script/script_scanner.hpp b/src/script/script_scanner.hpp index 1c2e0f5946..ff6f2148ed 100644 --- a/src/script/script_scanner.hpp +++ b/src/script/script_scanner.hpp @@ -21,6 +21,9 @@ public: ScriptScanner(); ~ScriptScanner() override; + /** + * Initialize the scanner by scanning for scripts and creating dummies if needed. + */ virtual void Initialize() = 0; /** diff --git a/src/sprite.h b/src/sprite.h index 7fbef6a49f..900da62989 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -56,6 +56,11 @@ struct DrawTileSprites { DrawTileSprites() = default; virtual ~DrawTileSprites() = default; + + /** + * The child sprites to draw. + * @return The span of child sprites. + */ virtual std::span GetSequence() const = 0; }; diff --git a/src/vehicle_base.h b/src/vehicle_base.h index d1ea57a5e9..520cc707f8 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -761,6 +761,10 @@ public: */ virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station) { return INVALID_TILE; } + /** + * Tile to use for economic calculations when moving cargo into or out of this vehicle. + * @return The cargo (un)load tile. + */ virtual TileIndex GetCargoTile() const { return this->tile; } /** @@ -770,6 +774,10 @@ public: */ virtual ClosestDepot FindClosestDepot() { return {}; } + /** + * Set the destination of this vehicle. + * @param tile The tile to go to. + */ virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; } CommandCost SendToDepot(DoCommandFlags flags, DepotCommandFlags command); diff --git a/src/video/cocoa/cocoa_ogl.mm b/src/video/cocoa/cocoa_ogl.mm index 8fd62478c2..01573edcf0 100644 --- a/src/video/cocoa/cocoa_ogl.mm +++ b/src/video/cocoa/cocoa_ogl.mm @@ -268,7 +268,6 @@ NSView *VideoDriver_CocoaOpenGL::AllocateDrawView() return [ [ OTTD_CGLLayerView alloc ] initWithFrame:this->cocoaview.bounds context:this->gl_context ]; } -/** Resize the window. */ void VideoDriver_CocoaOpenGL::AllocateBackingStore(bool force) { if (this->window == nil || this->setup) return; diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index 033446459b..a9a1997893 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -57,6 +57,10 @@ public: void MainLoopReal(); + /** + * Resize the window. + * @param force If true window resizing will be forced. + */ virtual void AllocateBackingStore(bool force = false) = 0; protected: @@ -77,9 +81,16 @@ protected: bool MakeWindow(int width, int height); + /** + * Allocate the view to show the game on. + * @return The allocated view. + */ virtual NSView *AllocateDrawView() = 0; - /** Get a pointer to the video buffer. */ + /** + * Get a pointer to the video buffer. + * @return The pointer. + */ virtual void *GetVideoPointer() = 0; /** Hand video buffer back to the drawing backend. */ virtual void ReleaseVideoPointer() {} diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 53fe6e6feb..ccf2819d1b 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -626,10 +626,6 @@ NSView *VideoDriver_CocoaQuartz::AllocateDrawView() return [ [ OTTD_QuartzView alloc ] initWithFrame:[ this->cocoaview bounds ] andDriver:this ]; } -/** - * Resize the window. - * @param force If true window resizing will be forced. - */ void VideoDriver_CocoaQuartz::AllocateBackingStore([[maybe_unused]] bool force) { if (this->window == nil || this->cocoaview == nil || this->setup) return; diff --git a/src/video/sdl2_v.h b/src/video/sdl2_v.h index 9bdf666e49..4f82fd5774 100644 --- a/src/video/sdl2_v.h +++ b/src/video/sdl2_v.h @@ -62,13 +62,31 @@ protected: /** Indicate to the driver the client-side might have changed. */ void ClientSizeChanged(int w, int h, bool force); - /** (Re-)create the backing store. */ + /** + * (Re-)create the backing store. + * @param w The width of the window. + * @param h The height of the window. + * @param force Whether to force full reallocation, instead of not reallocating when size did not change. + * @return Whether the backing store was (re-)created. + */ virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0; - /** Get a pointer to the video buffer. */ + + /** + * Get a pointer to the video buffer. + * @return The pointer. + */ virtual void *GetVideoPointer() = 0; + /** Hand video buffer back to the painting backend. */ virtual void ReleaseVideoPointer() = 0; - /** Create the main window. */ + + /** + * Create the main window. + * @param w The width of the window. + * @param h The height of the window. + * @param flags SDL specific flags for the window. + * @return Whether the window was created or already existed. + */ virtual bool CreateMainWindow(uint w, uint h, uint flags = 0); private: diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 2ce18b70f1..1869e21f9a 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -132,7 +132,10 @@ static uint MapWindowsKey(uint sym) return key; } -/** Colour depth to use for fullscreen display modes. */ +/** + * Colour depth to use for fullscreen display modes. + * @return The colour depth in bits per pixel. + */ uint8_t VideoDriver_Win32Base::GetFullscreenBpp() { /* Check modes for the relevant fullscreen bpp */ diff --git a/src/video/win32_v.h b/src/video/win32_v.h index d8b3a7886c..90c38c7d78 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -59,15 +59,30 @@ protected: bool MakeWindow(bool full_screen, bool resize = true); void ClientSizeChanged(int w, int h, bool force = false); - /** Get screen depth to use for fullscreen mode. */ virtual uint8_t GetFullscreenBpp(); - /** (Re-)create the backing store. */ + + /** + * (Re-)create the backing store. + * @param w The width of the window. + * @param h The height of the window. + * @param force Whether to force full reallocation, instead of not reallocating when size did not change. + * @return Whether the backing store was (re-)created. + */ virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0; - /** Get a pointer to the video buffer. */ + + /** + * Get a pointer to the video buffer. + * @return The pointer. + */ virtual void *GetVideoPointer() = 0; + /** Hand video buffer back to the painting backend. */ virtual void ReleaseVideoPointer() {} - /** Palette of the window has changed. */ + + /** + * Palette of the window has changed. + * @param hWnd The window handle of the changed window. + */ virtual void PaletteChanged(HWND hWnd) = 0; private: