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

Add an ability to edit Rumors for maps #8823

Merged
merged 8 commits into from
Jun 17, 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
2 changes: 2 additions & 0 deletions VisualStudio/fheroes2/sources.props
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<ClCompile Include="src\fheroes2\editor\editor_castle_details_window.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_event_details_window.cpp" />
<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_sphinx_window.cpp" />
<ClCompile Include="src\fheroes2\editor\editor_ui_helper.cpp" />
Expand Down Expand Up @@ -330,6 +331,7 @@
<ClInclude Include="src\fheroes2\editor\editor_castle_details_window.h" />
<ClInclude Include="src\fheroes2\editor\editor_event_details_window.h" />
<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_sphinx_window.h" />
<ClInclude Include="src\fheroes2\editor\editor_ui_helper.h" />
Expand Down
17 changes: 16 additions & 1 deletion src/fheroes2/agg/agg_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ namespace
ICN::BUTTON_HSCORES_VERTICAL_EXIT,
ICN::BUTTON_HSCORES_VERTICAL_STANDARD,
ICN::DISMISS_HERO_DISABLED_BUTTON,
ICN::NEW_CAMPAIGN_DISABLED_BUTTON };
ICN::NEW_CAMPAIGN_DISABLED_BUTTON,
ICN::BUTTON_RUMORS_GOOD,
ICN::BUTTON_RUMORS_EVIL };

#ifndef NDEBUG
bool isLanguageDependentIcnId( const int id )
Expand Down Expand Up @@ -2105,6 +2107,17 @@ namespace fheroes2

break;
}
case ICN::BUTTON_RUMORS_GOOD:
case ICN::BUTTON_RUMORS_EVIL: {
_icnVsSprite[id].resize( 2 );

const bool isEvilInterface = ( id == ICN::BUTTON_RUMORS_EVIL );

getTextAdaptedButton( _icnVsSprite[id][0], _icnVsSprite[id][1], gettext_noop( "RUMORS" ),
isEvilInterface ? ICN::EMPTY_EVIL_BUTTON : ICN::EMPTY_GOOD_BUTTON, isEvilInterface ? ICN::STONEBAK_EVIL : ICN::STONEBAK );

break;
}
default:
// You're calling this function for non-specified ICN id. Check your logic!
// Did you add a new image for one language without generating a default
Expand Down Expand Up @@ -2765,6 +2778,8 @@ namespace fheroes2
case ICN::BUTTON_HSCORES_VERTICAL_CAMPAIGN:
case ICN::BUTTON_HSCORES_VERTICAL_EXIT:
case ICN::BUTTON_HSCORES_VERTICAL_STANDARD:
case ICN::BUTTON_RUMORS_GOOD:
case ICN::BUTTON_RUMORS_EVIL:
generateLanguageSpecificImages( id );
return true;
case ICN::PHOENIX:
Expand Down
3 changes: 3 additions & 0 deletions src/fheroes2/agg/icn.h
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,9 @@ namespace ICN
BUTTON_LOAD_MAP_EVIL,
BUTTON_LOAD_MAP_GOOD,

BUTTON_RUMORS_GOOD,
BUTTON_RUMORS_EVIL,

// IMPORTANT! Put any new entry just above this one.
LASTICN
};
Expand Down
22 changes: 20 additions & 2 deletions src/fheroes2/editor/editor_map_specs_window.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***************************************************************************
* fheroes2: https://github.com/ihhub/fheroes2 *
* Copyright (C) 2019 - 2024 *
* Copyright (C) 2024 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
Expand Down Expand Up @@ -34,6 +34,7 @@
#include "cursor.h"
#include "dialog.h"
#include "difficulty.h"
#include "editor_rumor_window.h"
#include "game_hotkeys.h"
#include "icn.h"
#include "image.h"
Expand Down Expand Up @@ -588,13 +589,19 @@ namespace Editor
background.renderButton( buttonOk, buttonOkIcn, 0, 1, { 20 + buttonCancelRoi.width + 10, 6 }, fheroes2::StandardWindow::Padding::BOTTOM_RIGHT );
const fheroes2::Rect buttonOkRoi( buttonOk.area() );

fheroes2::Button buttonRumors;
const int buttonRumorsIcn = isEvilInterface ? ICN::BUTTON_RUMORS_EVIL : ICN::BUTTON_RUMORS_GOOD;
background.renderButton( buttonRumors, buttonRumorsIcn, 0, 1, { 20, 6 }, fheroes2::StandardWindow::Padding::BOTTOM_LEFT );
const fheroes2::Rect buttonRumorsRoi( buttonRumors.area() );

LocalEvent & le = LocalEvent::Get();

display.render( background.totalArea() );

while ( le.HandleEvents() ) {
buttonOk.drawOnState( le.isMouseLeftButtonPressedInArea( buttonOkRoi ) );
buttonCancel.drawOnState( le.isMouseLeftButtonPressedInArea( buttonCancelRoi ) );
buttonRumors.drawOnState( le.isMouseLeftButtonPressedInArea( buttonRumorsRoi ) );
#ifndef HIDE_VICTORY_LOSS_CONDITIONS
victoryDroplistButton.drawOnState( le.isMouseLeftButtonPressedInArea( victoryDroplistButtonRoi ) );
lossDroplistButton.drawOnState( le.isMouseLeftButtonPressedInArea( lossDroplistButtonRoi ) );
Expand All @@ -608,7 +615,15 @@ namespace Editor
break;
}

if ( le.MouseClickLeft( mapNameRoi ) ) {
if ( le.MouseClickLeft( buttonRumorsRoi ) ) {
auto temp = mapFormat.rumors;
if ( openRumorWindow( temp ) ) {
mapFormat.rumors = std::move( temp );
}

display.render( background.totalArea() );
}
else if ( le.MouseClickLeft( mapNameRoi ) ) {
// TODO: Edit texts directly in this dialog.

std::string editableMapName = mapFormat.name;
Expand Down Expand Up @@ -679,6 +694,9 @@ namespace Editor
else if ( le.isMouseRightButtonPressedInArea( buttonOkRoi ) ) {
fheroes2::showStandardTextMessage( _( "Okay" ), _( "Click to accept the changes made." ), Dialog::ZERO );
}
else if ( le.isMouseRightButtonPressedInArea( buttonRumorsRoi ) ) {
fheroes2::showStandardTextMessage( _( "Rumors" ), _( "Click to edit custom rumors." ), Dialog::ZERO );
}
else if ( le.isMouseRightButtonPressedInArea( mapNameRoi ) ) {
fheroes2::showStandardTextMessage( _( "Map Name" ), _( "Click to change your map name." ), Dialog::ZERO );
}
Expand Down
Loading
Loading