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

Fix the mouse interaction in the Editor's spell selection and castle properties windows #9357

Merged
merged 7 commits into from
Dec 22, 2024
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
24 changes: 12 additions & 12 deletions src/fheroes2/editor/editor_castle_details_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace
{
LocalEvent & le = LocalEvent::Get();

if ( le.MouseClickLeft() ) {
if ( le.MouseClickLeft( _area ) ) {
if ( restrictionMode ) {
if ( _restrictedId <= -1 ) {
_restrictedId = _buildingVariants;
Expand All @@ -162,7 +162,7 @@ namespace
return true;
}

if ( le.isMouseRightButtonPressed() ) {
if ( le.isMouseRightButtonPressedInArea( _area ) ) {
const BuildingType building = _getBuildindTypeForRender();
std::string description = BuildingInfo::getBuildingDescription( _race, building );
const std::string requirement = fheroes2::getBuildingRequirementString( _race, building );
Expand Down Expand Up @@ -485,7 +485,7 @@ namespace Editor
message = _( "Click to change the Castle name. Right-click to reset to default." );

bool redrawName = false;
if ( le.MouseClickLeft() ) {
if ( le.MouseClickLeft( nameArea ) ) {
std::string res = castleMetadata.customName;

// TODO: use the provided language to set the castle's name.
Expand All @@ -497,7 +497,7 @@ namespace Editor
redrawName = true;
}
}
else if ( le.MouseClickRight() ) {
else if ( le.MouseClickRight( nameArea ) ) {
castleMetadata.customName.clear();
redrawName = true;
}
Expand All @@ -512,18 +512,18 @@ namespace Editor
else if ( isTown && le.isMouseCursorPosInArea( allowCastleArea ) ) {
message = _( "Allow to build a castle in this town." );

if ( le.MouseClickLeft() ) {
if ( le.MouseClickLeft( allowCastleArea ) ) {
allowCastleSign.isHidden() ? allowCastleSign.show() : allowCastleSign.hide();
display.render( allowCastleSign.getArea() );
}
else if ( le.isMouseRightButtonPressed() ) {
else if ( le.isMouseRightButtonPressedInArea( allowCastleArea ) ) {
fheroes2::showStandardTextMessage( _( "Allow Castle build" ), message, Dialog::ZERO );
}
}
else if ( le.isMouseCursorPosInArea( defaultBuildingsArea ) ) {
message = _( "Toggle the use of default buildings. Custom buildings will be reset!" );

if ( le.MouseClickLeft() ) {
if ( le.MouseClickLeft( defaultBuildingsArea ) ) {
if ( defaultBuildingsSign.isHidden() ) {
// Reset all buildings to their build and restrict default states.
for ( BuildingData & building : buildings ) {
Expand All @@ -544,23 +544,23 @@ namespace Editor
display.render( dialogRoi );
}
}
else if ( le.isMouseRightButtonPressed() ) {
else if ( le.isMouseRightButtonPressedInArea( defaultBuildingsArea ) ) {
fheroes2::showStandardTextMessage( _( "Default Buildings" ), message, Dialog::ZERO );
}
}

else if ( le.isMouseCursorPosInArea( buttonRestrictBuilding.area() ) ) {
message = _( "Toggle building construction restriction mode." );

if ( le.isMouseRightButtonPressed() ) {
if ( le.isMouseRightButtonPressedInArea( buttonRestrictBuilding.area() ) ) {
fheroes2::showStandardTextMessage( _( "Restrict Building Construction" ), message, Dialog::ZERO );
}
}

else if ( isNeutral && le.isMouseCursorPosInArea( defaultArmyArea ) ) {
message = _( "Use default defenders army." );

if ( le.MouseClickLeft() ) {
if ( le.MouseClickLeft( defaultArmyArea ) ) {
if ( defaultArmySign.isHidden() ) {
defaultArmySign.show();
castleArmy.Reset( false );
Expand All @@ -572,7 +572,7 @@ namespace Editor
display.render( defaultArmySign.getArea() );
}
}
else if ( le.isMouseRightButtonPressed() ) {
else if ( le.isMouseRightButtonPressedInArea( defaultArmyArea ) ) {
fheroes2::showStandardTextMessage( _( "Default Army" ), message, Dialog::ZERO );
}
}
Expand All @@ -591,7 +591,7 @@ namespace Editor
else if ( le.isMouseCursorPosInArea( buttonExit.area() ) ) {
message = _( "Exit Castle Options" );

if ( le.isMouseRightButtonPressed() ) {
if ( le.isMouseRightButtonPressedInArea( buttonExit.area() ) ) {
fheroes2::showStandardTextMessage( _( "Exit" ), message, Dialog::ZERO );
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/fheroes2/editor/editor_spell_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ namespace
return false;
}

if ( eventProcessor.MouseClickLeft() ) {
assert( static_cast<size_t>( spellIndex ) < _spellRoi.size() );
assert( static_cast<size_t>( spellIndex ) < _spellRoi.size() );

const fheroes2::Rect spellRoi = _spellRoi[spellIndex];
Districh-ru marked this conversation as resolved.
Show resolved Hide resolved

if ( eventProcessor.MouseClickLeft( spellRoi ) ) {
_spells[spellIndex].second = !_spells[spellIndex].second;

return true;
}

if ( eventProcessor.isMouseRightButtonPressed() ) {
if ( eventProcessor.isMouseRightButtonPressedInArea( spellRoi ) ) {
fheroes2::SpellDialogElement( _spells[spellIndex].first, nullptr ).showPopup( Dialog::ZERO );
}

Expand Down
Loading