Skip to content

Commit

Permalink
Merge branch 'master' into Autosave
Browse files Browse the repository at this point in the history
* master:
  Update issue templates
  Add ability to setup Secondary Skills in Witch's Hut inside the Editor (ihhub#9351)
  Fix the mouse interaction in the Editor's spell selection and castle properties windows (ihhub#9357)
  • Loading branch information
BlackBred committed Dec 22, 2024
2 parents 9456331 + cc46e58 commit 9d5a30b
Show file tree
Hide file tree
Showing 17 changed files with 547 additions and 138 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 2 additions & 0 deletions VisualStudio/fheroes2/sources.props
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<ClCompile Include="src\fheroes2\editor\editor_options.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_rumor_window.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_save_map_window.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_secondary_skill_selection.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_spell_selection.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_sphinx_window.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_ui_helper.cpp" />
Expand Down Expand Up @@ -328,6 +329,7 @@
<ClInclude Include="src\fheroes2\editor\editor_options.h" />
<ClInclude Include="src\fheroes2\editor\editor_rumor_window.h" />
<ClInclude Include="src\fheroes2\editor\editor_save_map_window.h" />
<ClInclude Include="src\fheroes2\editor\editor_secondary_skill_selection.h" />
<ClInclude Include="src\fheroes2\editor\editor_spell_selection.h" />
<ClInclude Include="src\fheroes2\editor\editor_sphinx_window.h" />
<ClInclude Include="src\fheroes2\editor\editor_ui_helper.h" />
Expand Down
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
45 changes: 32 additions & 13 deletions src/fheroes2/editor/editor_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "editor_map_specs_window.h"
#include "editor_object_popup_window.h"
#include "editor_save_map_window.h"
#include "editor_secondary_skill_selection.h"
#include "editor_spell_selection.h"
#include "editor_sphinx_window.h"
#include "game.h"
Expand Down Expand Up @@ -352,7 +353,7 @@ namespace
mapFormat.adventureMapEventMetadata.erase( objectIter->id );
break;
case MP2::OBJ_PYRAMID:
mapFormat.spellObjectMetadata.erase( objectIter->id );
mapFormat.selectionObjectMetadata.erase( objectIter->id );
break;
case MP2::OBJ_SIGN:
assert( mapFormat.signMetadata.find( objectIter->id ) != mapFormat.signMetadata.end() );
Expand All @@ -362,6 +363,9 @@ namespace
assert( mapFormat.sphinxMetadata.find( objectIter->id ) != mapFormat.sphinxMetadata.end() );
mapFormat.sphinxMetadata.erase( objectIter->id );
break;
case MP2::OBJ_WITCHS_HUT:
mapFormat.selectionObjectMetadata.erase( objectIter->id );
break;
default:
break;
}
Expand Down Expand Up @@ -424,7 +428,7 @@ namespace
case MP2::OBJ_SHRINE_SECOND_CIRCLE:
case MP2::OBJ_SHRINE_THIRD_CIRCLE:
// We cannot assert non-existing metadata as these objects could have been created by an older Editor version.
mapFormat.spellObjectMetadata.erase( objectIter->id );
mapFormat.selectionObjectMetadata.erase( objectIter->id );
break;
default:
break;
Expand Down Expand Up @@ -1410,11 +1414,11 @@ namespace Interface
}
}
else if ( objectType == MP2::OBJ_SHRINE_FIRST_CIRCLE || objectType == MP2::OBJ_SHRINE_SECOND_CIRCLE || objectType == MP2::OBJ_SHRINE_THIRD_CIRCLE ) {
if ( _mapFormat.spellObjectMetadata.find( object.id ) == _mapFormat.spellObjectMetadata.end() ) {
_mapFormat.spellObjectMetadata[object.id] = {};
if ( _mapFormat.selectionObjectMetadata.find( object.id ) == _mapFormat.selectionObjectMetadata.end() ) {
_mapFormat.selectionObjectMetadata[object.id] = {};
}

auto & originalMetadata = _mapFormat.spellObjectMetadata[object.id];
auto & originalMetadata = _mapFormat.selectionObjectMetadata[object.id];
auto newMetadata = originalMetadata;

int spellLevel = 0;
Expand All @@ -1432,23 +1436,38 @@ namespace Interface
spellLevel = 1;
}

if ( Editor::openSpellSelectionWindow( MP2::StringObject( objectType ), spellLevel, newMetadata.allowedSpells )
&& originalMetadata.allowedSpells != newMetadata.allowedSpells ) {
if ( Editor::openSpellSelectionWindow( MP2::StringObject( objectType ), spellLevel, newMetadata.selectedItems )
&& originalMetadata.selectedItems != newMetadata.selectedItems ) {
fheroes2::ActionCreator action( _historyManager, _mapFormat );
originalMetadata = std::move( newMetadata );
action.commit();
}
}
else if ( objectType == MP2::OBJ_WITCHS_HUT ) {
if ( _mapFormat.selectionObjectMetadata.find( object.id ) == _mapFormat.selectionObjectMetadata.end() ) {
_mapFormat.selectionObjectMetadata[object.id] = {};
}

auto & originalMetadata = _mapFormat.selectionObjectMetadata[object.id];
auto newMetadata = originalMetadata;

if ( Editor::openSecondarySkillSelectionWindow( MP2::StringObject( objectType ), 1, newMetadata.selectedItems )
&& originalMetadata.selectedItems != newMetadata.selectedItems ) {
fheroes2::ActionCreator action( _historyManager, _mapFormat );
originalMetadata = std::move( newMetadata );
action.commit();
}
}
else if ( objectType == MP2::OBJ_PYRAMID ) {
if ( _mapFormat.spellObjectMetadata.find( object.id ) == _mapFormat.spellObjectMetadata.end() ) {
_mapFormat.spellObjectMetadata[object.id] = {};
if ( _mapFormat.selectionObjectMetadata.find( object.id ) == _mapFormat.selectionObjectMetadata.end() ) {
_mapFormat.selectionObjectMetadata[object.id] = {};
}

auto & originalMetadata = _mapFormat.spellObjectMetadata[object.id];
auto & originalMetadata = _mapFormat.selectionObjectMetadata[object.id];
auto newMetadata = originalMetadata;

if ( Editor::openSpellSelectionWindow( MP2::StringObject( objectType ), 5, newMetadata.allowedSpells )
&& originalMetadata.allowedSpells != newMetadata.allowedSpells ) {
if ( Editor::openSpellSelectionWindow( MP2::StringObject( objectType ), 5, newMetadata.selectedItems )
&& originalMetadata.selectedItems != newMetadata.selectedItems ) {
fheroes2::ActionCreator action( _historyManager, _mapFormat );
originalMetadata = std::move( newMetadata );
action.commit();
Expand Down Expand Up @@ -2135,7 +2154,7 @@ namespace Interface
++objectsReplaced;
}

if ( replaceKey( _mapFormat.spellObjectMetadata, object.id, newObjectUID ) ) {
if ( replaceKey( _mapFormat.selectionObjectMetadata, object.id, newObjectUID ) ) {
++objectsReplaced;
}

Expand Down
Loading

0 comments on commit 9d5a30b

Please sign in to comment.