mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6164
6164: Automatically register ddnet:// url handler on macOS r=Robyt3 a=def- Should work automatically on first time running client. See https://hublog.hubmed.org/archives/001154 <!-- What is the motivation for the changes of this pull request? --> <!-- Note that builds and other checks will be run for your change. Don't feel intimidated by failures in some of the checks. If you can't resolve them yourself, experienced devs can also resolve them before merging your pull request. --> ## Checklist - [ ] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
commit
46209376ad
|
@ -18,6 +18,40 @@
|
|||
<string>${PROJECT_VERSION}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.DDNetClient.app</string>
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>DDNet server link</string>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>ddnet</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>DDNet demo</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>DDNet demo viewer</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>dyn.ah62d4rv4ge80k3prr6</string>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>DDNet map</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>DDNet map editor</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>dyn.ah62d4rv4ge8042pu</string>
|
||||
<string>public.data</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
<key>NSPrefersDisplaySafeAreaCompatibilityMode</key>
|
||||
|
|
|
@ -3175,6 +3175,18 @@ void CClient::Run()
|
|||
else
|
||||
SetState(IClient::STATE_QUITTING); // SDL_QUIT
|
||||
}
|
||||
|
||||
char aFile[IO_MAX_PATH_LENGTH];
|
||||
if(Input()->GetDropFile(aFile, sizeof(aFile)))
|
||||
{
|
||||
if(str_startswith(aFile, CONNECTLINK_NO_SLASH))
|
||||
HandleConnectLink(aFile);
|
||||
else if(str_endswith(aFile, ".demo"))
|
||||
HandleDemoPath(aFile);
|
||||
else if(str_endswith(aFile, ".map"))
|
||||
HandleMapPath(aFile);
|
||||
}
|
||||
|
||||
#if defined(CONF_AUTOUPDATE)
|
||||
Updater()->Update();
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,8 @@ CInput::CInput()
|
|||
m_NumTextInputInstances = 0;
|
||||
m_EditingTextLen = -1;
|
||||
m_aEditingText[0] = 0;
|
||||
|
||||
m_aDropFile[0] = 0;
|
||||
}
|
||||
|
||||
void CInput::Init()
|
||||
|
@ -751,6 +753,11 @@ int CInput::Update()
|
|||
// other messages
|
||||
case SDL_QUIT:
|
||||
return 1;
|
||||
|
||||
case SDL_DROPFILE:
|
||||
str_copy(m_aDropFile, Event.drop.file);
|
||||
SDL_free(Event.drop.file);
|
||||
break;
|
||||
}
|
||||
|
||||
if(Scancode > KEY_FIRST && Scancode < g_MaxKeys && !IgnoreKeys && (!SDL_IsTextInputActive() || m_EditingTextLen == -1))
|
||||
|
@ -777,6 +784,17 @@ int CInput::VideoRestartNeeded()
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool CInput::GetDropFile(char *aBuf, int Len)
|
||||
{
|
||||
if(m_aDropFile[0] != '\0')
|
||||
{
|
||||
str_copy(aBuf, m_aDropFile, Len);
|
||||
m_aDropFile[0] = '\0';
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IEngineInput *CreateEngineInput()
|
||||
{
|
||||
return new CInput;
|
||||
|
|
|
@ -94,6 +94,8 @@ private:
|
|||
void HandleJoystickAddedEvent(const SDL_JoyDeviceEvent &Event);
|
||||
void HandleJoystickRemovedEvent(const SDL_JoyDeviceEvent &Event);
|
||||
|
||||
char m_aDropFile[IO_MAX_PATH_LENGTH];
|
||||
|
||||
// IME support
|
||||
int m_NumTextInputInstances;
|
||||
char m_aEditingText[INPUT_TEXT_SIZE];
|
||||
|
@ -138,6 +140,8 @@ public:
|
|||
const char *GetIMEEditingText() override;
|
||||
int GetEditingCursor() override;
|
||||
void SetEditingPosition(float X, float Y) override;
|
||||
|
||||
bool GetDropFile(char *aBuf, int Len) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -114,6 +114,8 @@ public:
|
|||
virtual int GetEditingCursor() = 0;
|
||||
virtual void SetEditingPosition(float X, float Y) = 0;
|
||||
|
||||
virtual bool GetDropFile(char *aBuf, int Len) = 0;
|
||||
|
||||
ECursorType CursorRelative(float *pX, float *pY)
|
||||
{
|
||||
if(MouseRelative(pX, pY))
|
||||
|
|
Loading…
Reference in a new issue