Skip to content

Commit

Permalink
#5662: Show the merge dialog once the map switches to merge mode
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 18, 2021
1 parent 190209d commit 5dacca8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
11 changes: 10 additions & 1 deletion radiant/ui/UserInterfaceModule.cpp
@@ -1,10 +1,13 @@
#include "UserInterfaceModule.h"

#include <sigc++/functors/ptr_fun.h>

#include "i18n.h"
#include "ilayer.h"
#include "ifilter.h"
#include "ientity.h"
#include "imru.h"
#include "imap.h"
#include "ibrush.h"
#include "ipatch.h"
#include "iorthocontextmenu.h"
Expand Down Expand Up @@ -100,7 +103,8 @@ const StringSet& UserInterfaceModule::getDependencies() const
MODULE_RADIANT_CORE,
MODULE_MRU_MANAGER,
MODULE_MAINFRAME,
MODULE_MOUSETOOLMANAGER
MODULE_MOUSETOOLMANAGER,
MODULE_MAP
};

return _dependencies;
Expand Down Expand Up @@ -218,6 +222,10 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
MouseToolRegistrationHelper::RegisterTools();

wxTheApp->Bind(DISPATCH_EVENT, &UserInterfaceModule::onDispatchEvent, this);

_mapEditModeChangedConn = GlobalMapModule().signal_editModeChanged().connect(
sigc::ptr_fun(&MergeControlDialog::OnMapEditModeChanged)
);
}

void UserInterfaceModule::shutdownModule()
Expand All @@ -230,6 +238,7 @@ void UserInterfaceModule::shutdownModule()

_coloursUpdatedConn.disconnect();
_entitySettingsConn.disconnect();
_mapEditModeChangedConn.disconnect();

_longOperationHandler.reset();
_mapFileProgressHandler.reset();
Expand Down
1 change: 1 addition & 0 deletions radiant/ui/UserInterfaceModule.h
Expand Up @@ -51,6 +51,7 @@ class UserInterfaceModule :

sigc::connection _entitySettingsConn;
sigc::connection _coloursUpdatedConn;
sigc::connection _mapEditModeChangedConn;

std::size_t _execFailedListener;
std::size_t _textureChangedListener;
Expand Down
20 changes: 13 additions & 7 deletions radiant/ui/merge/MergeControlDialog.cpp
Expand Up @@ -421,7 +421,6 @@ void MergeControlDialog::_preHide()
_undoHandler.disconnect();
_redoHandler.disconnect();
_mapEventHandler.disconnect();
_mapEditModeHandler.disconnect();

GlobalSelectionSystem().removeObserver(this);
}
Expand All @@ -439,10 +438,7 @@ void MergeControlDialog::_preShow()
_mapEventHandler = GlobalMapModule().signal_mapEvent().connect(
sigc::mem_fun(this, &MergeControlDialog::onMapEvent)
);
_mapEditModeHandler = GlobalMapModule().signal_editModeChanged().connect(
sigc::mem_fun(this, &MergeControlDialog::onMapEditModeChanged)
);


_undoHandler = GlobalUndoSystem().signal_postUndo().connect(
sigc::mem_fun(this, &MergeControlDialog::queueUpdate));
_redoHandler = GlobalUndoSystem().signal_postRedo().connect(
Expand Down Expand Up @@ -490,9 +486,19 @@ void MergeControlDialog::onMapEvent(IMap::MapEvent ev)
}
}

void MergeControlDialog::onMapEditModeChanged(IMap::EditMode newMode)
void MergeControlDialog::OnMapEditModeChanged(IMap::EditMode mode)
{
update();
// When switching to merge mode, make sure the dialog is shown

if (!InstancePtr() && mode == IMap::EditMode::Merge)
{
Instance().Show();
return;
}
else if (InstancePtr() && Instance().IsShown())
{
Instance().update();
}
}

void MergeControlDialog::updateSummary()
Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/merge/MergeControlDialog.h
Expand Up @@ -21,7 +21,6 @@ class MergeControlDialog final :
sigc::connection _undoHandler;
sigc::connection _redoHandler;
sigc::connection _mapEventHandler;
sigc::connection _mapEditModeHandler;

bool _updateNeeded;
std::size_t _numUnresolvedConflicts;
Expand All @@ -45,6 +44,8 @@ class MergeControlDialog final :
bool isInThreeWayMergeMode();
void setThreeWayMergeMode(bool enabled);

static void OnMapEditModeChanged(IMap::EditMode newMode);

protected:
void _preShow() override;
void _preHide() override;
Expand All @@ -67,7 +68,6 @@ class MergeControlDialog final :
void queueUpdate();
void onIdle(wxIdleEvent& ev);
void onMapEvent(IMap::MapEvent ev);
void onMapEditModeChanged(IMap::EditMode newMode);
void updateSummary();

void update();
Expand Down

0 comments on commit 5dacca8

Please sign in to comment.