Skip to content

Commit

Permalink
Updated XShowConnectUI
Browse files Browse the repository at this point in the history
  • Loading branch information
theTwister authored and theTwister committed Dec 22, 2022
1 parent b944a12 commit 57b6859
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
11 changes: 9 additions & 2 deletions game/source/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ void __cdecl direct_connect(transport_address address, s_transport_session_descr

void show_direct_connect_dialog()
{
bool dialog_succeeded = false;

c_static_wchar_string<16> insecure_ip;
c_static_wchar_string<16> port;
c_static_wchar_string<128> secure_ip;
c_static_wchar_string<128> session_id;
{
Expand All @@ -115,6 +118,9 @@ void show_direct_connect_dialog()
secure_ip.print(L"%hs", _secure_ip.get_string());

session_id.print(L"%hs", _session_id);

REFERENCE_DECLARE(0x01860454, word, game_port);
port.print(L"%hd", game_port);
}

transport_address address{};
Expand All @@ -124,7 +130,7 @@ void show_direct_connect_dialog()
wchar_t result_port_text[128]{};
wchar_t result_id_text[128]{};
wchar_t result_address_text[128]{};
XShowConnectUI(insecure_ip.get_string(), L"11774", session_id.get_string(), secure_ip.get_string(), result_ip_text, result_port_text, result_id_text, result_address_text, get_donkey_module());
XShowConnectUI(insecure_ip.get_string(), port.get_string(), session_id.get_string(), secure_ip.get_string(), result_ip_text, result_port_text, result_id_text, result_address_text, get_donkey_module(), &dialog_succeeded);

c_static_wchar_string<32> ip_port_str;
ip_port_str.print(L"%s:%s", result_ip_text, result_port_text);
Expand All @@ -134,7 +140,8 @@ void show_direct_connect_dialog()
transport_secure_address_from_string(result_address_text, description.address);
}

direct_connect(address, description);
if (dialog_succeeded)
direct_connect(address, description);
}

void __cdecl main_loop_body_begin()
Expand Down
10 changes: 8 additions & 2 deletions game/source/xbox/xbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ struct XShowConnectUI_struct
wchar_t* result_id_text; // buffer must be 128 characters in size
wchar_t* result_address_text; // buffer must be 128 characters in size

bool* dialog_succeeded;

void dialog_initialize_handler(HWND dialog_handle)
{
SetWindowText(dialog_handle, L"Direct Connect");
Expand All @@ -124,9 +126,11 @@ struct XShowConnectUI_struct
SendMessage(GetDlgItem(dialog_handle, ID_SESSION_ID_TEXT), WM_GETTEXT, (WPARAM)128, (LPARAM)result_id_text);
SendMessage(GetDlgItem(dialog_handle, ID_SESSION_ADDRESS_TEXT), WM_GETTEXT, (WPARAM)128, (LPARAM)result_address_text);
EndDialog(dialog_handle, IDCONNECT);
*dialog_succeeded = true;
break;
case IDCANCEL:
EndDialog(dialog_handle, IDCANCEL);
*dialog_succeeded = false;
break;
}
}
Expand Down Expand Up @@ -166,7 +170,8 @@ long XShowConnectUI(
wchar_t* result_port_text,
wchar_t* result_id_text,
wchar_t* result_address_text,
void* platform_handle
void* platform_handle,
bool* dialog_succeeded
)
{
XShowConnectUI_struct params
Expand All @@ -178,7 +183,8 @@ long XShowConnectUI(
result_ip_text,
result_port_text,
result_id_text,
result_address_text
result_address_text,
dialog_succeeded
};
DialogBoxParam((HINSTANCE)platform_handle, MAKEINTRESOURCE(IDD_CONNECT_DIALOG), g_game_window_handle, &XShowConnectUI_proc, (LPARAM)&params);

Expand Down
3 changes: 2 additions & 1 deletion game/source/xbox/xbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern long XShowConnectUI(
wchar_t* result_port_text,
wchar_t* result_id_text,
wchar_t* result_address_text,
void* platform_handle
void* platform_handle,
bool* should_connect
);

0 comments on commit 57b6859

Please sign in to comment.