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 dialog to choose between Auto Combat and Quick Combat #9180

Merged
merged 61 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b2e88a8
Initial dialog with empty buttons
zenseii Mar 18, 2024
07c1d5a
Fix missing declaration name change
zenseii Mar 19, 2024
82a88e1
Add returns
zenseii Mar 19, 2024
c82d307
code style
zenseii Mar 19, 2024
38fb591
Add To-dos
zenseii Mar 22, 2024
8cca571
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Mar 22, 2024
0f173ce
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Oct 9, 2024
d5099d1
Generate text-adapted buttons
zenseii Oct 9, 2024
cd9ba4b
Const and else ifs
zenseii Oct 10, 2024
cfbff98
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Oct 21, 2024
d237bd6
Merge branch 'master' into auto-resolve
ihhub Dec 5, 2024
4837053
Merge branch 'auto-resolve' of https://github.com/zenseii/fheroes2 in…
zenseii Jan 3, 2025
a59d786
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Jan 3, 2025
0bb5241
Generate buttons in agg_image.cpp
zenseii Jan 3, 2025
0be0ca9
Add header and title, move button generation,
zenseii Jan 3, 2025
ef6b34f
style nit
zenseii Jan 3, 2025
7125508
remove dash
zenseii Jan 3, 2025
b91bb9c
Add right click infos
zenseii Jan 3, 2025
58c0325
style nit
zenseii Jan 3, 2025
bccdfc9
Copyright years
zenseii Jan 3, 2025
71709a9
Code style
zenseii Jan 3, 2025
3fb0fa8
cache texts
zenseii Jan 3, 2025
c06ccb8
it -> this
zenseii Jan 3, 2025
8b97660
Account for multi-lined texts
zenseii Jan 3, 2025
fa73da6
Separate the text body blocks
zenseii Jan 10, 2025
9d5645f
separate auto resolve info text blocks
zenseii Jan 10, 2025
b59ddba
Remove duplicated todo
zenseii Jan 10, 2025
bd7d77f
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Jan 10, 2025
6e23a1f
Add button shine
zenseii Jan 10, 2025
0c75e6a
Paraphrase auto resolve text
zenseii Jan 10, 2025
1f11f7f
Change to stone background
zenseii Jan 12, 2025
48154ed
Dymanic background width, paraphrasing
zenseii Jan 13, 2025
794f05e
Merge remote-tracking branch 'upstream/master' into auto-resolve
zenseii Jan 13, 2025
744f9fc
Paraphrasing, dialog dynamic size
zenseii Jan 13, 2025
2b5c1b9
Make normal buttons have extra margin
zenseii Jan 13, 2025
560c352
else if to if
zenseii Jan 13, 2025
4bc6e70
Add hotkeys, expand description
zenseii Jan 13, 2025
8b9112c
Code style
zenseii Jan 13, 2025
9c7f070
Rename the symbols and hotkeys related to auto combat and instant combat
oleg-derevenetz Jan 14, 2025
3120a9f
Apply the IWYU suggestions
oleg-derevenetz Jan 14, 2025
d1218f9
Auto Resolve -> Quick Combat
zenseii Jan 16, 2025
4606405
Address comments from #9094
zenseii Jan 16, 2025
493b7d3
Code style
zenseii Jan 16, 2025
44e12cc
Address @ihhub comments
zenseii Jan 16, 2025
e2dd498
Change auto resolve button ICN to quick combat
zenseii Jan 16, 2025
8f01bd8
Change settings names
zenseii Jan 16, 2025
1d36d61
Copyright year
zenseii Jan 16, 2025
67e9998
change references from instant to quick
zenseii Jan 16, 2025
0511cc5
Fix fheroes2.key replacement
zenseii Jan 16, 2025
8a9955f
last missing "resolve" references
zenseii Jan 16, 2025
74f365f
Last paraphrasing
zenseii Jan 16, 2025
a77b5a8
small consistency correction
zenseii Jan 16, 2025
e4cc7cc
paraphrasing
zenseii Jan 16, 2025
8ac4396
change to agreed phrasings
zenseii Jan 17, 2025
31b1dad
Simplify the logic
oleg-derevenetz Jan 17, 2025
6afad31
Merge branch 'master' into auto-resolve
oleg-derevenetz Jan 17, 2025
2a1196b
Remove extra else
oleg-derevenetz Jan 17, 2025
247ec2d
Rework the logic a bit
oleg-derevenetz Jan 17, 2025
a0c22a8
Revert the wording
oleg-derevenetz Jan 17, 2025
7ccae8f
Set cursor with yellow outline
zenseii Jan 17, 2025
32366c4
Add an empty line :)
oleg-derevenetz Jan 17, 2025
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
52 changes: 51 additions & 1 deletion src/fheroes2/battle/battle_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3217,14 +3217,64 @@ void Battle::Interface::EventAutoFinish( Actions & actions )
humanturn_exit = true;
}

void Battle::Interface::OpenAutoModeDialog( const Unit & unit, Actions & actions )
{
LocalEvent & le = LocalEvent::Get();

fheroes2::Display & display = fheroes2::Display::instance();

Dialog::FrameBox box( 100, true );
zenseii marked this conversation as resolved.
Show resolved Hide resolved
const fheroes2::Rect roiArea = box.GetArea();
fheroes2::Button cancel( roiArea.x + roiArea.width / 2 - fheroes2::AGG::GetICN( ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0 ).width() / 2, roiArea.y + roiArea.height - 20,
ICN::UNIFORM_GOOD_CANCEL_BUTTON, 0, 1 );

fheroes2::Sprite releasedCombatButton;
fheroes2::Sprite pressedCombatButton;
fheroes2::Sprite releasedResolveButton;
fheroes2::Sprite pressedResolveButton;

fheroes2::getTextAdaptedButton( releasedCombatButton, pressedCombatButton, _( "AUTO-\nCOMBAT" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD );
fheroes2::getTextAdaptedButton( releasedResolveButton, pressedResolveButton, _( "AUTO-\nRESOLVE" ), ICN::EMPTY_GOOD_BUTTON, ICN::UNIFORMBAK_GOOD );

fheroes2::ButtonSprite autoCombat( roiArea.x, roiArea.y + 40, releasedCombatButton, pressedCombatButton );
fheroes2::ButtonSprite autoResolve( roiArea.x + roiArea.width - releasedCombatButton.width(), roiArea.y + 40, releasedResolveButton, pressedResolveButton );

// To-do: add a title and a header to the dialog. "Automatic Battle Modes" and Choose an automatic battle mode:

cancel.draw();
autoResolve.draw();
autoCombat.draw();
display.render();
while ( le.HandleEvents() ) {
le.isMouseLeftButtonPressedInArea( cancel.area() ) ? cancel.drawOnPress() : cancel.drawOnRelease();
le.isMouseLeftButtonPressedInArea( autoResolve.area() ) ? autoResolve.drawOnPress() : autoResolve.drawOnRelease();
le.isMouseLeftButtonPressedInArea( autoCombat.area() ) ? autoCombat.drawOnPress() : autoCombat.drawOnRelease();

// To-do: add right-click infos for the buttons.

if ( le.MouseClickLeft( cancel.area() ) || Game::HotKeyPressEvent( Game::HotKeyEvent::DEFAULT_CANCEL ) ) {
return;
}
else if ( le.MouseClickLeft( autoResolve.area() ) ) {
zenseii marked this conversation as resolved.
Show resolved Hide resolved
EventAutoFinish( actions );
return;
}
else if ( le.MouseClickLeft( autoCombat.area() ) ) {
EventStartAutoBattle( unit, actions );
return;
zenseii marked this conversation as resolved.
Show resolved Hide resolved
}
display.render( roiArea );
}
}

void Battle::Interface::ButtonAutoAction( const Unit & unit, Actions & actions )
{
LocalEvent & le = LocalEvent::Get();

le.isMouseLeftButtonPressedInArea( btn_auto.area() ) ? btn_auto.drawOnPress() : btn_auto.drawOnRelease();

if ( le.MouseClickLeft( btn_auto.area() ) ) {
EventStartAutoBattle( unit, actions );
OpenAutoModeDialog( unit, actions );
}
}

Expand Down
1 change: 1 addition & 0 deletions src/fheroes2/battle/battle_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ namespace Battle
void _openBattleSettingsDialog();
void EventStartAutoBattle( const Unit & unit, Actions & actions );
void EventAutoFinish( Actions & actions );
void OpenAutoModeDialog( const Unit & unit, Actions & actions );
void EventShowOptions();
void ButtonAutoAction( const Unit & unit, Actions & actions );
void ButtonSettingsAction();
Expand Down
Loading