Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make log window hidden by default, and show patch description in tooltip #33

Merged
merged 5 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/include/gui/DeltaPatcherDecodePanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class DeltaPatcherDecodePanel : public DecodePanel, public DeltaPatcherDropHandl
void OnDecodeOptionsClicked(wxCommandEvent& event);

virtual wxThread::ExitCode Entry();
void ShowPatchDescriptionToolTip(const wxString& patchDesc);
public:
/** Constructor */
DeltaPatcherDecodePanel( wxWindow* parent,Logger* logger );
Expand All @@ -60,7 +61,7 @@ class DeltaPatcherDecodePanel : public DecodePanel, public DeltaPatcherDropHandl
wxMenu* applyOptionsMenu;
wxMenuItem* keepOriginalCheck;
wxMenuItem* checksumCheck;

wxString threadOriginal;
wxString threadModified;
XDeltaPatch threadXDP;
Expand Down
38 changes: 32 additions & 6 deletions app/src/gui/DeltaPatcherDecodePanel.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include <gui/DeltaPatcherDropTarget.h>
#include <gui/icons/open.xpm>
#include <gui/icons/save.xpm>
#include <gui/icons/config.xpm>

#include <wx/filename.h>
#include <gui/DeltaPatcherDecodePanel.h>
#include <wx/filedlg.h>
#include <wx/generic/msgdlgg.h>

#include <gui/icons/open.xpm>
#include <gui/icons/save.xpm>
#include <gui/icons/config.xpm>
#include <wx/richtooltip.h>

DeltaPatcherDecodePanel::DeltaPatcherDecodePanel( wxWindow* parent,Logger* l )
:
Expand Down Expand Up @@ -126,6 +127,7 @@ void DeltaPatcherDecodePanel::SetPatchFile(const wxChar* patchPath)
}else
{
message<<wxString::Format(_(", description found:\n\n%s\n"),xdp.GetDescription());
ShowPatchDescriptionToolTip(xdp.GetDescription());
}

logger->Log(Logger::LOG_MESSAGE,message);
Expand Down Expand Up @@ -181,9 +183,26 @@ void DeltaPatcherDecodePanel::OnThreadUpdate(wxThreadEvent& evt)
int code = evt.GetInt();
wxString message = evt.GetString();

if(code!=0){
if(code!=0)
{
logger->Log(Logger::LOG_ERROR,message);
wxGenericMessageDialog(this,_("An error has occurred!\nSee log for more information."),_("Warning"),wxICON_EXCLAMATION).ShowModal();

if(message.Find("source file too short") != wxNOT_FOUND ||
message.Find("target window checksum mismatch") != wxNOT_FOUND)
{
wxGenericMessageDialog(
this,
_("The patch could not be applied:\n"
"The file you are trying to patch is not the right one."),
_("Error"),wxICON_ERROR).ShowModal();
}else
{
wxGenericMessageDialog(
this,
_("The patch could not be applied:\n"
"See log for more information."),
_("Error"),wxICON_ERROR).ShowModal();
}
}else{
if(!keepOriginalCheck->IsChecked()){ //we must not keep the original file
wxRemoveFile(threadOriginal);
Expand All @@ -194,6 +213,13 @@ void DeltaPatcherDecodePanel::OnThreadUpdate(wxThreadEvent& evt)
}
}

void DeltaPatcherDecodePanel::ShowPatchDescriptionToolTip(const wxString& patchDesc)
{
wxRichToolTip tip(_("Patch info"),patchDesc);
tip.SetIcon(wxICON_INFORMATION);
tip.ShowFor(patchButton);
}

wxThread::ExitCode DeltaPatcherDecodePanel::Entry()
{

Expand Down
2 changes: 1 addition & 1 deletion app/src/gui/DeltaPatcherEncodePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void DeltaPatcherEncodePanel::OnThreadUpdate(wxThreadEvent& evt)

if(code!=0){
logger->Log(Logger::LOG_ERROR,message);
wxGenericMessageDialog(this,_("An error has occurred!\nSee log for more information."),_("Warning"),wxICON_EXCLAMATION).ShowModal();
wxGenericMessageDialog(this,_("An error has occurred!\nSee log for more information."),_("Warning"),wxICON_ERROR).ShowModal();
}else{
logger->Log(Logger::LOG_MESSAGE,_("Patch successfully created!"));
wxGenericMessageDialog(this,_("Patch successfully created!"),_("Notice"),wxICON_INFORMATION).ShowModal();
Expand Down
2 changes: 2 additions & 0 deletions app/src/gui/DeltaPatcherMainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ MainDialog( parent ), decodeMode(true)
#endif

decodePanel->SwitchTo();
ShowHideLog();
this->Update();
this->Fit();

Expand Down Expand Up @@ -133,6 +134,7 @@ void DeltaPatcherMainDialog::Log(int type,const wxChar* msg)
message=wxString::Format(_("[%s] An error has occurred: %s\n"),strTime.GetData(),msg);

logCtrl->AppendText(message);
logCtrl->ShowPosition(logCtrl->GetLastPosition());
}


Expand Down
32 changes: 17 additions & 15 deletions app/src/gui/dpgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,32 @@ MainDialog::MainDialog( wxWindow* parent, wxWindowID id, const wxString& title,
aboutButton = new wxBitmapButton( this, wxID_ABOUT, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
aboutButton->SetToolTip( _("Shows information about this program.") );

bSizer22->Add( aboutButton, 0, wxALIGN_LEFT|wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bSizer22->Add( aboutButton, 0, wxALIGN_LEFT|wxBOTTOM|wxLEFT|wxRIGHT|wxEXPAND, 0 );


bSizer20->Add( bSizer22, 1, wxEXPAND, 5 );
bSizer20->Add( bSizer22, 1, wxEXPAND|wxLEFT, 5 );

wxBoxSizer* bSizer21;
bSizer21 = new wxBoxSizer( wxHORIZONTAL );

operationButton = new wxBitmapButton( this, wxID_OPERATION_BUTTON, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
operationButton->SetToolTip( _("Switches between patch creation and patch application modes.") );

bSizer21->Add( operationButton, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT, 5 );

bSizer21->Add( operationButton, 0, wxALIGN_RIGHT|wxBOTTOM|wxEXPAND, 0 );
bSizer21->AddSpacer(7);

showHideLog = new wxBitmapButton( this, wxID_SHOW_IDE_LOG, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
showHideLog->SetToolTip( _("Hides/Shows the log window.") );

bSizer21->Add( showHideLog, 0, wxALIGN_RIGHT|wxBOTTOM|wxLEFT|wxRIGHT, 5 );

bSizer21->Add( showHideLog, 0, wxALIGN_RIGHT|wxBOTTOM|wxEXPAND, 0 );

bSizer20->Add( bSizer21, 0, wxALIGN_RIGHT|wxEXPAND|wxRIGHT, 5 );


leftSizer->Add( bSizer20, 0, wxEXPAND, 5 );


mainSizer->Add( leftSizer, 0, wxBOTTOM|wxEXPAND|wxRIGHT, 5 );
mainSizer->Add( leftSizer, 0, wxBOTTOM|wxEXPAND, 5 );

logBox = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Log:") ), wxVERTICAL );

Expand Down Expand Up @@ -107,7 +107,7 @@ DecodePanel::DecodePanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
sbSizer1->Add( originalField, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 7 );

originalButton = new wxBitmapButton( this, wxID_DECODE_ORIGINAL_OPEN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
originalButton->SetToolTip( _("Choose the file to patched.") );
originalButton->SetToolTip( _("Choose the file to patch.") );

sbSizer1->Add( originalButton, 0, wxALL, 5 );

Expand Down Expand Up @@ -136,15 +136,16 @@ DecodePanel::DecodePanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
applyButton->SetDefault();
applyButton->SetToolTip( _("Applies the selected patch to the given file.") );

decodeBottomSizer->Add( applyButton, 1, wxALIGN_CENTER|wxALL|wxEXPAND, 6 );

decodeBottomSizer->Add( applyButton, 1, wxALIGN_CENTER|wxTOP|wxBOTTOM|wxEXPAND, 0 );
decodeBottomSizer->AddSpacer(7);

decodeOptionsButton = new wxBitmapButton( this, wxID_DECODE_OPTIONS_BUTTON, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
decodeOptionsButton->SetToolTip( _("Changes settings for patch application.") );

decodeBottomSizer->Add( decodeOptionsButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 );
decodeBottomSizer->Add( decodeOptionsButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP|wxEXPAND, 0 );


decodeMainSizer->Add( decodeBottomSizer, 0, wxEXPAND|wxTOP, 2 );
decodeMainSizer->Add( decodeBottomSizer, 0, wxEXPAND|wxTOP, 4 );


this->SetSizer( decodeMainSizer );
Expand Down Expand Up @@ -229,15 +230,16 @@ EncodePanel::EncodePanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, c
createButton->SetDefault();
createButton->SetToolTip( _("Creates a patch containing the differences between the original and the modified file.") );

bSizer4->Add( createButton, 1, wxALIGN_CENTER|wxALL|wxEXPAND, 6 );
bSizer4->Add( createButton, 1, wxALIGN_CENTER|wxTOP|wxBOTTOM|wxEXPAND, 0 );
bSizer4->AddSpacer(7);

encodeOptionsButton = new wxBitmapButton( this, wxID_ENCODE_OPTIONS_BUTTON, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
encodeOptionsButton->SetToolTip( _("Changes settings for patch creation.") );

bSizer4->Add( encodeOptionsButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxTOP, 5 );
bSizer4->Add( encodeOptionsButton, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxTOP|wxEXPAND, 0 );


bSizer1->Add( bSizer4, 0, wxEXPAND|wxTOP, 2 );
bSizer1->Add( bSizer4, 0, wxEXPAND|wxTOP, 4 );


this->SetSizer( bSizer1 );
Expand Down
10 changes: 9 additions & 1 deletion app/src/patcher/XDeltaPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ void XDeltaPatch::DecodeDescription()
std::string buf=base64_decode(strPart);

description=wxString::FromUTF8(buf.c_str(),buf.length());


//Uniform new lines to \n
description.Replace("\r\n","\n");
description.Replace("\r","\n");

//On Windows, use \r\n
#if defined(__WXMSW__)
description.Replace("\n","\r\n");
#endif
}

wxString XDeltaPatch::EncodeDescription()
Expand Down