Skip to content

Commit 0813131

Browse files
committed
Better communication of licensing status
1 parent b82d1d8 commit 0813131

File tree

7 files changed

+196
-22
lines changed

7 files changed

+196
-22
lines changed

source/activation.cpp

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#include "fmt/format.h"
44
#include <wx/process.h>
55
#include <wx/filedlg.h>
6+
#include <fstream>
7+
#include "output_dialog.hpp"
8+
9+
using namespace std;
610

711
wxBEGIN_EVENT_TABLE(PersonalActivationDlg, wxDialog)
812
EVT_BUTTON(PAD_CREATE, PersonalActivationDlg::OnCreateHit)
@@ -50,31 +54,54 @@ void PersonalActivationDlg::OnCreateHit(wxCommandEvent& evt)
5054
}
5155
}
5256

57+
void DisplayLicenseOutput(){
58+
std::filesystem::path logfile
59+
#ifdef __APPLE__
60+
= std::filesystem::path(wxGetHomeDir()) / "Library/Logs/Unity/Editor.log";
61+
#elif defined _WIN32
62+
= std::filesystem::path(wxGetHomeDir()) / "AppData"/"Local"/"Unity"/"Editor"/"Editor.log";
63+
#else
64+
= std::filesystem::path(wxGetHomeDir()) / ".config/unity3d/Editor.log";
65+
#endif
66+
ifstream in(logfile);
67+
std::string output;
68+
std::string line;
69+
while (getline(in, line)){
70+
auto cpy = line;
71+
transform(cpy.begin(), cpy.end(), cpy.begin(), ::tolower);
72+
// filter for license-related lines
73+
if (cpy.find("license") != decltype(line)::npos){
74+
output += line;
75+
}
76+
}
77+
auto dialog = new OutputDialog(nullptr, output, "Activation status");
78+
dialog->ShowModal();
79+
}
80+
5381
void PersonalActivationDlg::OnActivateHit(wxCommandEvent&)
5482
{
5583
wxFileDialog openFileDialog(this, _("Open License file"), "", "", "ULF files (*.ulf)|*.ulf", wxFD_OPEN | wxFD_FILE_MUST_EXIST);
5684
if (openFileDialog.ShowModal() == wxID_CANCEL) {}
5785
else {
5886
auto exe = the_editor.executablePath().string();
5987
auto cmd = fmt::format("{} -batchmode -manualLicenseFile \"{}\" -logfile",exe,openFileDialog.GetPath().ToStdString());
60-
//TODO: error check this?
88+
activateBtn->SetLabelText("Activating...");
6189
wxExecute(cmd, wxEXEC_SYNC);
62-
wxMessageBox("Activation complete", "Activation", wxOK | wxICON_INFORMATION);
90+
DisplayLicenseOutput();
6391
this->Close();
6492
}
6593
}
6694

6795
void PlusProActivationDlg::OnActivateHit(wxCommandEvent&)
6896
{
69-
std::string username = plusProActivUsernameCtrl->GetValue();
70-
std::string password = plusProActivPasswordCtrl->GetValue();
71-
std::string serial = plusProActivationSerialCtrl->GetValue();
97+
const std::string& username = plusProActivUsernameCtrl->GetValue();
98+
const std::string& password = plusProActivPasswordCtrl->GetValue();
99+
const std::string& serial = plusProActivationSerialCtrl->GetValue();
72100

73101
auto cmd = fmt::format("{} -batchmode -username {} -password {} -serial {} -quit",the_editor.executablePath().string(),username,password,serial);
74102

103+
activateBtn->SetLabelText("Activating...");
75104
wxExecute(cmd, wxEXEC_SYNC);
76-
77-
//TODO: error check this?
78-
wxMessageBox("Activation complete", "Activation", wxOK | wxICON_INFORMATION);
105+
DisplayLicenseOutput();
79106
this->Close();
80107
}

source/form.fbp

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,7 @@
23322332
<property name="minimize_button">0</property>
23332333
<property name="minimum_size"></property>
23342334
<property name="moveable">1</property>
2335-
<property name="name">m_button25</property>
2335+
<property name="name">activateBtn</property>
23362336
<property name="pane_border">1</property>
23372337
<property name="pane_position"></property>
23382338
<property name="pane_size"></property>
@@ -4136,7 +4136,7 @@
41364136
<property name="validator_style">wxFILTER_NONE</property>
41374137
<property name="validator_type">wxDefaultValidator</property>
41384138
<property name="validator_variable"></property>
4139-
<property name="value"></property>
4139+
<property name="value">SB-</property>
41404140
<property name="window_extra_style"></property>
41414141
<property name="window_name"></property>
41424142
<property name="window_style"></property>
@@ -4251,7 +4251,7 @@
42514251
<property name="minimize_button">0</property>
42524252
<property name="minimum_size"></property>
42534253
<property name="moveable">1</property>
4254-
<property name="name">m_button23</property>
4254+
<property name="name">activateBtn</property>
42554255
<property name="pane_border">1</property>
42564256
<property name="pane_position"></property>
42574257
<property name="pane_size"></property>
@@ -4278,5 +4278,103 @@
42784278
</object>
42794279
</object>
42804280
</object>
4281+
<object class="Dialog" expanded="1">
4282+
<property name="aui_managed">0</property>
4283+
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
4284+
<property name="bg"></property>
4285+
<property name="center">wxBOTH</property>
4286+
<property name="context_help"></property>
4287+
<property name="context_menu">1</property>
4288+
<property name="enabled">1</property>
4289+
<property name="event_handler">impl_virtual</property>
4290+
<property name="extra_style"></property>
4291+
<property name="fg"></property>
4292+
<property name="font"></property>
4293+
<property name="hidden">0</property>
4294+
<property name="id">wxID_ANY</property>
4295+
<property name="maximum_size"></property>
4296+
<property name="minimum_size"></property>
4297+
<property name="name">OutputDialogBase</property>
4298+
<property name="pos"></property>
4299+
<property name="size">388,256</property>
4300+
<property name="style">wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP</property>
4301+
<property name="subclass">; ; forward_declare</property>
4302+
<property name="title">Output</property>
4303+
<property name="tooltip"></property>
4304+
<property name="two_step_creation">0</property>
4305+
<property name="window_extra_style"></property>
4306+
<property name="window_name"></property>
4307+
<property name="window_style"></property>
4308+
<object class="wxBoxSizer" expanded="1">
4309+
<property name="minimum_size"></property>
4310+
<property name="name">bSizer9</property>
4311+
<property name="orient">wxVERTICAL</property>
4312+
<property name="permission">none</property>
4313+
<object class="sizeritem" expanded="1">
4314+
<property name="border">5</property>
4315+
<property name="flag">wxALL|wxEXPAND</property>
4316+
<property name="proportion">1</property>
4317+
<object class="wxTextCtrl" expanded="1">
4318+
<property name="BottomDockable">1</property>
4319+
<property name="LeftDockable">1</property>
4320+
<property name="RightDockable">1</property>
4321+
<property name="TopDockable">1</property>
4322+
<property name="aui_layer"></property>
4323+
<property name="aui_name"></property>
4324+
<property name="aui_position"></property>
4325+
<property name="aui_row"></property>
4326+
<property name="best_size"></property>
4327+
<property name="bg"></property>
4328+
<property name="caption"></property>
4329+
<property name="caption_visible">1</property>
4330+
<property name="center_pane">0</property>
4331+
<property name="close_button">1</property>
4332+
<property name="context_help"></property>
4333+
<property name="context_menu">1</property>
4334+
<property name="default_pane">0</property>
4335+
<property name="dock">Dock</property>
4336+
<property name="dock_fixed">0</property>
4337+
<property name="docking">Left</property>
4338+
<property name="enabled">1</property>
4339+
<property name="fg"></property>
4340+
<property name="floatable">1</property>
4341+
<property name="font"></property>
4342+
<property name="gripper">0</property>
4343+
<property name="hidden">0</property>
4344+
<property name="id">wxID_ANY</property>
4345+
<property name="max_size"></property>
4346+
<property name="maximize_button">0</property>
4347+
<property name="maximum_size"></property>
4348+
<property name="maxlength"></property>
4349+
<property name="min_size"></property>
4350+
<property name="minimize_button">0</property>
4351+
<property name="minimum_size"></property>
4352+
<property name="moveable">1</property>
4353+
<property name="name">contentText</property>
4354+
<property name="pane_border">1</property>
4355+
<property name="pane_position"></property>
4356+
<property name="pane_size"></property>
4357+
<property name="permission">protected</property>
4358+
<property name="pin_button">1</property>
4359+
<property name="pos"></property>
4360+
<property name="resize">Resizable</property>
4361+
<property name="show">1</property>
4362+
<property name="size"></property>
4363+
<property name="style">wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP</property>
4364+
<property name="subclass">; ; forward_declare</property>
4365+
<property name="toolbar_pane">0</property>
4366+
<property name="tooltip"></property>
4367+
<property name="validator_data_type"></property>
4368+
<property name="validator_style">wxFILTER_NONE</property>
4369+
<property name="validator_type">wxDefaultValidator</property>
4370+
<property name="validator_variable"></property>
4371+
<property name="value"></property>
4372+
<property name="window_extra_style"></property>
4373+
<property name="window_name"></property>
4374+
<property name="window_style"></property>
4375+
</object>
4376+
</object>
4377+
</object>
4378+
</object>
42814379
</object>
42824380
</wxFormBuilder_Project>

source/globals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ static const std::string AppVersion = "v1.5";
4141
#define pclose _pclose
4242
#define mkdir _mkdir
4343
#include <wx/wx.h>
44-
static const std::string homedir = getenv("HOMEPATH");
45-
static const std::filesystem::path datapath = std::filesystem::path(homedir) / std::filesystem::path("AppData\\Roaming\\UnityHubNative");
44+
static const std::filesystem::path homedir = getenv("HOMEPATH");
45+
static const std::filesystem::path datapath = homedir / std::filesystem::path("AppData\\Roaming\\UnityHubNative");
4646
static const char dirsep = '\\';
4747

4848
static const std::filesystem::path cachedir = std::filesystem::temp_directory_path();
@@ -202,4 +202,4 @@ struct editor {
202202
decltype(path) executablePath() const{
203203
return path / name / executable;
204204
}
205-
};
205+
};

source/interface.cpp

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ PersonalActivationDlgBase::PersonalActivationDlgBase( wxWindow* parent, wxWindow
249249
m_staticText20->Wrap( -1 );
250250
fgSizer2->Add( m_staticText20, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
251251

252-
m_button25 = new wxButton( this, PAD_ACTIVATE, wxT("Choose and Activate"), wxDefaultPosition, wxDefaultSize, 0 );
253-
fgSizer2->Add( m_button25, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
252+
activateBtn = new wxButton( this, PAD_ACTIVATE, wxT("Choose and Activate"), wxDefaultPosition, wxDefaultSize, 0 );
253+
fgSizer2->Add( activateBtn, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
254254

255255

256256
this->SetSizer( fgSizer2 );
@@ -463,15 +463,15 @@ PlusProActivationDlgBase::PlusProActivationDlgBase( wxWindow* parent, wxWindowID
463463
m_staticText11->Wrap( -1 );
464464
fgSizer1->Add( m_staticText11, 0, wxALL, 5 );
465465

466-
plusProActivationSerialCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
466+
plusProActivationSerialCtrl = new wxTextCtrl( this, wxID_ANY, wxT("SB-"), wxDefaultPosition, wxDefaultSize, 0 );
467467
fgSizer1->Add( plusProActivationSerialCtrl, 0, wxALL|wxEXPAND, 5 );
468468

469469
m_staticText13 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
470470
m_staticText13->Wrap( -1 );
471471
fgSizer1->Add( m_staticText13, 0, wxALL, 5 );
472472

473-
m_button23 = new wxButton( this, PPA_ACTIVATE, wxT("Activate"), wxDefaultPosition, wxDefaultSize, 0 );
474-
fgSizer1->Add( m_button23, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
473+
activateBtn = new wxButton( this, PPA_ACTIVATE, wxT("Activate"), wxDefaultPosition, wxDefaultSize, 0 );
474+
fgSizer1->Add( activateBtn, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
475475

476476

477477
this->SetSizer( fgSizer1 );
@@ -484,3 +484,24 @@ PlusProActivationDlgBase::PlusProActivationDlgBase( wxWindow* parent, wxWindowID
484484
PlusProActivationDlgBase::~PlusProActivationDlgBase()
485485
{
486486
}
487+
488+
OutputDialogBase::OutputDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
489+
{
490+
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
491+
492+
wxBoxSizer* bSizer9;
493+
bSizer9 = new wxBoxSizer( wxVERTICAL );
494+
495+
contentText = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_WORDWRAP );
496+
bSizer9->Add( contentText, 1, wxALL|wxEXPAND, 5 );
497+
498+
499+
this->SetSizer( bSizer9 );
500+
this->Layout();
501+
502+
this->Centre( wxBOTH );
503+
}
504+
505+
OutputDialogBase::~OutputDialogBase()
506+
{
507+
}

source/interface.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class PersonalActivationDlgBase : public wxDialog
9696
wxHyperlinkCtrl* m_hyperlink2;
9797
wxStaticText* m_staticText19;
9898
wxStaticText* m_staticText20;
99-
wxButton* m_button25;
99+
wxButton* activateBtn;
100100

101101
public:
102102

@@ -186,7 +186,7 @@ class PlusProActivationDlgBase : public wxDialog
186186
wxStaticText* m_staticText11;
187187
wxTextCtrl* plusProActivationSerialCtrl;
188188
wxStaticText* m_staticText13;
189-
wxButton* m_button23;
189+
wxButton* activateBtn;
190190

191191
public:
192192

@@ -196,3 +196,21 @@ class PlusProActivationDlgBase : public wxDialog
196196

197197
};
198198

199+
///////////////////////////////////////////////////////////////////////////////
200+
/// Class OutputDialogBase
201+
///////////////////////////////////////////////////////////////////////////////
202+
class OutputDialogBase : public wxDialog
203+
{
204+
private:
205+
206+
protected:
207+
wxTextCtrl* contentText;
208+
209+
public:
210+
211+
OutputDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Output"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 388,256 ), long style = wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER|wxSTAY_ON_TOP );
212+
213+
~OutputDialogBase();
214+
215+
};
216+

source/interface_derived.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void MainFrameDerived::LoadProjects(const std::string &filter){
155155
if (erroredProjects.size() > 0){
156156
//build string
157157
string str;
158-
for (string s : erroredProjects){
158+
for (const auto& s : erroredProjects){
159159
str += s + "\n";
160160
}
161161
//message box

source/output_dialog.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
#include "interface.h"
3+
4+
class OutputDialog : public OutputDialogBase{
5+
public:
6+
OutputDialog(wxWindow* parent, const std::string& data, const std::string& title) : OutputDialogBase(parent) {
7+
SetTitle(title);
8+
contentText->SetValue(data);
9+
}
10+
};

0 commit comments

Comments
 (0)