mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
WX: HiDPI: NetPlay
Several refactors of GUI creation into separate functions where the function was too large or intermixed different concerns making it hard to modify.
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include <wx/gauge.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/stattext.h>
|
||||
|
||||
#include "Common/StringUtil.h"
|
||||
@ -17,43 +18,54 @@ MD5Dialog::MD5Dialog(wxWindow* parent, NetPlayServer* server, std::vector<const
|
||||
const std::string& game)
|
||||
: wxDialog(parent, wxID_ANY, _("MD5 Checksum")), m_netplay_server(server)
|
||||
{
|
||||
Bind(wxEVT_CLOSE_WINDOW, &MD5Dialog::OnClose, this);
|
||||
const int space5 = FromDIP(5);
|
||||
|
||||
wxBoxSizer* const main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
main_sizer->Add(new wxStaticText(this, wxID_ANY, _("Computing MD5 Checksum for:") + "\n" + game,
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL),
|
||||
0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
|
||||
main_sizer->AddSpacer(space5);
|
||||
main_sizer->Add(new wxStaticText(this, wxID_ANY,
|
||||
wxString::Format(_("Computing MD5 Checksum for:\n%s"), game),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxALIGN_CENTRE_HORIZONTAL | wxST_NO_AUTORESIZE),
|
||||
0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
||||
|
||||
for (const Player* player : players)
|
||||
{
|
||||
wxStaticBoxSizer* const player_szr = new wxStaticBoxSizer(
|
||||
wxVERTICAL, this, player->name + " (p" + std::to_string(player->pid) + ")");
|
||||
|
||||
wxGauge* gauge = new wxGauge(this, wxID_ANY, 100);
|
||||
wxGauge* gauge = new wxGauge(player_szr->GetStaticBox(), wxID_ANY, 100);
|
||||
m_progress_bars[player->pid] = gauge;
|
||||
player_szr->Add(gauge, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
m_result_labels[player->pid] =
|
||||
new wxStaticText(this, wxID_ANY, _("Computing..."), wxDefaultPosition, wxSize(250, 20),
|
||||
wxALIGN_CENTRE_HORIZONTAL);
|
||||
new wxStaticText(player_szr->GetStaticBox(), wxID_ANY, _("Computing..."));
|
||||
|
||||
m_result_labels[player->pid]->SetSize(250, 15);
|
||||
player_szr->Add(m_result_labels[player->pid], 0, wxALL, 5);
|
||||
player_szr->AddSpacer(space5);
|
||||
player_szr->Add(gauge, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
||||
player_szr->AddSpacer(space5);
|
||||
player_szr->Add(m_result_labels[player->pid], 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT,
|
||||
space5);
|
||||
player_szr->AddSpacer(space5);
|
||||
player_szr->SetMinSize(FromDIP(wxSize(250, -1)));
|
||||
|
||||
main_sizer->Add(player_szr, 0, wxEXPAND | wxALL, 5);
|
||||
main_sizer->AddSpacer(space5);
|
||||
main_sizer->Add(player_szr, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
||||
}
|
||||
|
||||
m_final_result_label =
|
||||
new wxStaticText(this, wxID_ANY,
|
||||
" ", // so it takes space
|
||||
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
|
||||
main_sizer->Add(m_final_result_label, 1, wxALL, 5);
|
||||
|
||||
wxButton* close_btn = new wxButton(this, wxID_ANY, _("Close"));
|
||||
close_btn->Bind(wxEVT_BUTTON, &MD5Dialog::OnCloseBtnPressed, this);
|
||||
main_sizer->Add(close_btn, 0, wxEXPAND | wxALL, 5);
|
||||
|
||||
main_sizer->AddSpacer(space5);
|
||||
main_sizer->Add(m_final_result_label, 1, wxLEFT | wxRIGHT, space5);
|
||||
main_sizer->AddSpacer(space5);
|
||||
main_sizer->Add(CreateStdDialogButtonSizer(wxCLOSE), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
|
||||
main_sizer->AddSpacer(space5);
|
||||
SetSizerAndFit(main_sizer);
|
||||
|
||||
Bind(wxEVT_BUTTON, &MD5Dialog::OnCloseBtnPressed, this, wxID_CLOSE);
|
||||
Bind(wxEVT_CLOSE_WINDOW, &MD5Dialog::OnClose, this);
|
||||
SetFocus();
|
||||
Center();
|
||||
}
|
||||
@ -65,6 +77,7 @@ void MD5Dialog::SetProgress(int pid, int progress)
|
||||
|
||||
m_progress_bars[pid]->SetValue(progress);
|
||||
m_result_labels[pid]->SetLabel(_("Computing: ") + std::to_string(progress) + "%");
|
||||
Layout();
|
||||
Update();
|
||||
}
|
||||
|
||||
@ -76,11 +89,12 @@ void MD5Dialog::SetResult(int pid, const std::string& result)
|
||||
m_result_labels[pid]->SetLabel(result);
|
||||
m_hashes.push_back(result);
|
||||
|
||||
if (m_hashes.size() <= 1)
|
||||
return;
|
||||
|
||||
wxString label = AllHashesMatch() ? _("Hashes match!") : _("Hashes do not match.");
|
||||
m_final_result_label->SetLabel(label);
|
||||
if (m_hashes.size() > 1)
|
||||
{
|
||||
wxString label = AllHashesMatch() ? _("Hashes match!") : _("Hashes do not match.");
|
||||
m_final_result_label->SetLabel(label);
|
||||
}
|
||||
Layout();
|
||||
}
|
||||
|
||||
bool MD5Dialog::AllHashesMatch() const
|
||||
@ -89,7 +103,7 @@ bool MD5Dialog::AllHashesMatch() const
|
||||
m_hashes.end();
|
||||
}
|
||||
|
||||
void MD5Dialog::OnClose(wxCloseEvent& event)
|
||||
void MD5Dialog::OnClose(wxCloseEvent&)
|
||||
{
|
||||
m_netplay_server->AbortMD5();
|
||||
}
|
||||
|
Reference in New Issue
Block a user