|
OpenTTD Source 20260129-master-g2bb01bd0e4
|
Code related to OS interface for the cocoa video driver. More...
#include "../../stdafx.h"#include "../../os/macosx/macos.h"#include "../../os/macosx/macos_objective_c.h"#include "../../openttd.h"#include "../../debug.h"#include "cocoa_v.h"#include "cocoa_wnd.h"#include "../../settings_type.h"#include "../../string_func.h"#include "../../gfx_func.h"#include "../../window_func.h"#include "../../window_gui.h"#include "../../spritecache.h"#include "../../textbuf_type.h"#include "../../toolbar_gui.h"#include "../../core/utf8.hpp"#include "../../table/sprites.h"#include "cocoa_keys.h"Go to the source code of this file.
Data Structures | |
| struct | TouchBarButton |
| Structure to store information about single touch bar button. More... | |
| class | OTTDMain |
| The main class of the application, the application's delegate. More... | |
Functions | |
| static NSUInteger | CountUtf16Units (std::string_view str) |
| Count the number of UTF-16 code points in a range of an UTF-8 string. | |
| static size_t | Utf8AdvanceByUtf16Units (std::string_view str, NSUInteger count) |
| Advance an UTF-8 string by a number of equivalent UTF-16 code points. | |
| static std::vector< char32_t > | NSStringToUTF32 (NSString *s) |
| Convert a NSString to an UTF-32 encoded string. | |
| static void | CGDataFreeCallback (void *, const void *data, size_t) |
| Free memory where data was stored. | |
| static NSImage * | NSImageFromSprite (SpriteID sprite_id, ZoomLevel zoom) |
| Render an OTTD sprite to a Cocoa image. | |
| static void | setApplicationMenu () |
| Initialize the application menu shown in top bar. | |
| static void | setupWindowMenu () |
| Create a window menu. | |
| bool | CocoaSetupApplication () |
| Startup the application. | |
| void | CocoaExitApplication () |
| Deregister app delegate. | |
| void | CocoaDialog (std::string_view title, std::string_view message, std::string_view buttonLabel) |
| Catch asserts prior to initialization of the videodriver. | |
Variables | |
| static const std::array< TouchBarButton, 9 > | _touchbar_buttons |
| Storage of defined touch bar buttons. | |
| bool | _allow_hidpi_window = true |
| Storage for allow_hidpi setting. If true renders OTTD in native resolution. | |
| NSString * | OTTDMainLaunchGameEngine = @"@"ottdmain_launch_game_engine" |
| Name of notification observer used to restart the game loop if necessary. | |
| bool | _tab_is_down |
| Is tab button pressed. | |
| static bool | _cocoa_video_dialog = false |
| True iff inside the scope of CocoaDialog method. | |
| static OTTDMain * | _ottd_main |
| App delegate instance of OTTDMain. | |
| bool | touchbar_created |
| Whether the touchbar exists. | |
| NSUInteger | _current_mods |
| Currently applied modifier flags. | |
| bool | _emulated_down |
| Whether the mouse button is emulated or real. | |
| bool | _use_hidpi |
| Render content in native resolution? | |
Code related to OS interface for the cocoa video driver.
Definition in file cocoa_wnd.mm.
|
static |
Free memory where data was stored.
| data | Pointer to memory that will be freed. |
Definition at line 143 of file cocoa_wnd.mm.
Referenced by NSImageFromSprite().
| void CocoaDialog | ( | std::string_view | title, |
| std::string_view | message, | ||
| std::string_view | buttonLabel | ||
| ) |
Catch asserts prior to initialization of the videodriver.
Definition at line 379 of file cocoa_wnd.mm.
References _cocoa_video_dialog, _cocoa_video_started, CocoaSetupApplication(), VideoDriver::GetInstance(), and Driver::Stop().
Referenced by ShowMacDialog().
| void CocoaExitApplication | ( | ) |
Deregister app delegate.
Definition at line 364 of file cocoa_wnd.mm.
Referenced by VideoDriver_Cocoa::Stop().
| bool CocoaSetupApplication | ( | ) |
Startup the application.
Definition at line 328 of file cocoa_wnd.mm.
References _ottd_main, Debug, setApplicationMenu(), and setupWindowMenu().
Referenced by CocoaDialog(), and VideoDriver_Cocoa::Initialize().
|
static |
Count the number of UTF-16 code points in a range of an UTF-8 string.
| str | The view in range of the string. |
Definition at line 88 of file cocoa_wnd.mm.
Render an OTTD sprite to a Cocoa image.
| sprite_id | Sprite to make a NSImage from. |
| zoom | Zoom level to render the sprite in. |
Definition at line 154 of file cocoa_wnd.mm.
References CGDataFreeCallback(), DrawSpriteToRgbaBuffer(), and GetSpriteSize().
|
static |
Convert a NSString to an UTF-32 encoded string.
| s | String to convert. |
Definition at line 119 of file cocoa_wnd.mm.
References Utf16DecodeSurrogate(), Utf16IsLeadSurrogate(), and Utf16IsTrailSurrogate().
|
static |
Initialize the application menu shown in top bar.
Definition at line 257 of file cocoa_wnd.mm.
Referenced by CocoaSetupApplication().
|
static |
Create a window menu.
Definition at line 301 of file cocoa_wnd.mm.
Referenced by CocoaSetupApplication().
|
static |
Advance an UTF-8 string by a number of equivalent UTF-16 code points.
| str | UTF-8 string. |
| count | Number of UTF-16 code points to advance the string by. |
Definition at line 103 of file cocoa_wnd.mm.
| bool _allow_hidpi_window = true |
Storage for allow_hidpi setting. If true renders OTTD in native resolution.
Definition at line 69 of file cocoa_wnd.mm.
|
static |
True iff inside the scope of CocoaDialog method.
Definition at line 79 of file cocoa_wnd.mm.
Referenced by CocoaDialog().
| NSUInteger _current_mods |
Currently applied modifier flags.
Definition at line 541 of file cocoa_wnd.mm.
| bool _emulated_down |
Whether the mouse button is emulated or real.
Definition at line 542 of file cocoa_wnd.mm.
|
static |
App delegate instance of OTTDMain.
Definition at line 80 of file cocoa_wnd.mm.
Referenced by CocoaSetupApplication().
| bool _tab_is_down |
Is tab button pressed.
Definition at line 77 of file cocoa_wnd.mm.
Referenced by VideoDriver_Cocoa::InputLoop().
|
static |
Storage of defined touch bar buttons.
Definition at line 57 of file cocoa_wnd.mm.
| bool _use_hidpi |
Render content in native resolution?
Definition at line 543 of file cocoa_wnd.mm.
| NSString* OTTDMainLaunchGameEngine = @"@"ottdmain_launch_game_engine" |
Name of notification observer used to restart the game loop if necessary.
Definition at line 75 of file cocoa_wnd.mm.
Referenced by VideoDriver_Cocoa::MainLoop().
| bool touchbar_created |
Whether the touchbar exists.
Definition at line 432 of file cocoa_wnd.mm.