614 Commits

Author SHA1 Message Date
JJ Marr
fe5296aefd Make every possible param a const reference
This is important for performance. If a parameter doesn't have to be
modified, it should be a constant reference to the original.
2024-12-01 23:19:53 -05:00
gfgtdf
3d589f8d0d use synced_context::run for move actions
With this, finally all actions run though synced context::run,
so that we not only have a central place that happens before/after
synced actions, we also guarantee that there is no difference between
the original and the replay codepath for all actions.

This should also make upcoming changed to the undo code easier.
2024-11-17 21:30:22 +01:00
gfgtdf
d0050dac8e remove undo_stack parameter from move_unit
it was only there for the ai code to skip undo which it no longer does
2024-11-17 21:30:22 +01:00
Yoruma
0c2b035cc5 Fix with a little tricky 2024-10-31 08:12:50 +05:30
Charles Dang
84c414c58b Make use of sdl::get_mouse_location() when possible 2024-10-25 02:41:59 -04:00
Charles Dang
5ab73a51fd Display: use point math for viewport position 2024-10-25 02:41:59 -04:00
Charles Dang
6d40872de0
Display: remove display_context wrapper functions (#9481)
This removes `get_teams()`, `get_units()`, and `get_map()` from the display class. These only served as one of the many, many ways to access this data held by the display_context, and that shouldn't be the first-class responsibility of display. Instead, we either access them through the display_context pointer that display holds (whose getter has been renamed to `context()`) or through other more convenient paths (such as play_controller). The editor_display function `map()` has now taken up the mantle of `get_map()`, mostly because both `display::get_map()` and `editor_display::map()` are used, and the former outnumbered the latter.
2024-10-19 21:38:18 -04:00
Charles Dang
f4fda31707 Map Location: convert direction to a scoped enum 2024-10-10 22:57:23 -04:00
Charles Dang
f1be5e4c83 Clean up scattered cases of viewing_team_index + 1 2024-09-02 12:37:41 -04:00
Charles Dang
ac9f0674d7 Display: refactor out [playing|viewing]_side
Now defined in terms of [playing|viewing]_team().side(). Much clearer. No more damn +1 math.
2024-09-02 12:37:41 -04:00
Charles Dang
0940b7451b Display: add back [viewing|playing]_team as actual team reference getters
Cleaned up redundant getters in other classes that served the same purpose.
2024-09-02 12:37:41 -04:00
Charles Dang
58472054fb Display: rename [viewing|playing]_team to [viewing|playing]_index 2024-09-02 12:37:41 -04:00
Marcus Örnås
d3b3c8c07a Add a "Teleport Unit (Debug!)" option to debug menu
Fixes #5649
2024-04-18 18:24:56 -05:00
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
pentarctagon
dcde7c541e Re-sets the standing animation before and after the temporary_unit_mover moves the unit
Fixes #6960
2024-01-26 16:18:45 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
zBugH1
d81a15ed33 Adaptive drag threshold
Changes the drag threshold from 14 to be based on window resolution. Scaling is performed so that a 1080p window has the original threshold of 14.
2023-12-01 15:29:50 +01:00
Daniel Santos
2578e9e2ef
Add lua mouse button event handler (#7952)
* Add lua mouse button event handler that can be consumed.
* Fix middle-mouse down/click not getting sent to lua

This is a flexible event handler mechanism to allow for more advanced
add-on features. It does not allow the add-on to consume the value
however, so there's no mechanism for the add-on to requrest the default
action not be executed.

We would normally deal separately with mouse down, up and click, with
the later being an event where the mouse has gone both down and up on
the same UI component. However, Wesnoth's code seems to allow a mouse up
on many UI components to serve as a click, so this implementation
follows that behavior.

This addresses issue #7949

The mouse handling code needs an overhaul, so this patch works with it
in it's current state in the best possible way. The revised code
attempts to restrict clicks to those events where a mouse went both down
and up on the same map tile. It is able to do this with the right mouse
button as well as X1 and X2, but must work as existing click events are
treated for now.

This means that "left click" is managed via the `left_click()` function
which occurrs at mouse down, "right click" via `right_mouse_up()` when
the right mouse button comes up, and the middle button's click behavior
is coded directly into mouse_handler_base::mouse_press() (so no function
is called) and "clicks" when the button comes down. The new
`on_mouse_button()` code will allow the mod developer to consume any
click event, preventing the default behavior, and also receive event
callbacks for up and down events, although the return value is ignored
for these calls and left and middle click occur on mouse down.
2023-10-17 00:08:00 -04:00
Iris Morelle
6a33ca6a7b ui: Fix untranslatable string
Closes #7761.
2023-07-02 17:58:39 -04:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Steve Cotton
ae4ecd17e4 Show units' max move ranges, unless it's the owner's turn
If it's another player's turn, then movement points will be reset in a refresh
phase and it's not useful to show current movement.

Partially reverts 978229c247 (af0968d9c3 on 1.16), using the old logic for
the movement range but the allies-based logic for goto_x,goto_y information.

Fixes #6716.
2022-09-03 14:26:09 +02:00
Tommy
6ace55e063 Remove << "\n"; from log lines 2022-07-20 15:20:57 +12:00
Tommy
7370ef62cb Disable other mouse motion events while scrolling via middle mouse
Fixes stuttering while scrolling, and also various other distracting
effects such as showing reach map of units when passed over.
2022-07-13 13:34:01 +12:00
Tommy
103dfc031c Replace sdl::point_in_location with new rect::contains 2022-07-02 12:30:58 +12:00
Tommy
ab10d4d219 Fix remaining input issues with scaled display.
There is a new sdl::get_mouse_state() function that should be used in place
of SDL_GetMouseState() in every case. It returns coordinates relative to
the drawing surface.

With this, the pixel scale option seems to be working without issue.
2022-04-18 17:25:06 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Steve Cotton
978229c247 Only show planned moves to self and allies
Fixes #6292, that the planned final destination from multi-turn moves and
interrupted moves was visible to enemies. There are three side-numbers involved
in this logic, listed below; the GUI code was checking whether the move should
be visible to the player whose turn it is, rather to the viewing team.

* un->side(), the owner of the unit
* mouse_handler::side_num_, the side whose turn it is
* viewing_team(), the side of the player whose computer this wesnoth-client is
  running on, thus which side's shroud and fog should be applied.

The plans are still hidden for units belonging to local AI sides, to hide any
goto_x,goto_y settings by campaign authors. The edge case in multiplayer of
allied network AI sides isn't tested here, but I think it's a trivial matter
whether or not those plans are shown.

(cherry picked from commit af0968d9c35325ce3b4bdbdb18c6112ea9ed137b)
2022-01-13 10:46:43 +01:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
2021-07-26 11:38:03 -05:00
Pentarctagon
8e2996661f
Prevents logging of duplicate deprecation messages and messages missing timestamps.
Fixes #5942
2021-07-24 18:51:42 -05:00
Charles Dang
d65d12e89d Big cleanup of get_adjacent_tiles usage
This adds a new overload of get_adjacent_tiles that returns the array instead of taking the address of
the first element (a C paradigm). This also converts the use of the result to range-for loops when possible,
which is enabled b the fact that we're using std::array here instead of C arrays.
2021-01-16 20:38:24 +11:00
Charles Dang
27a40a82ae Use play_controller accessors for units and map where possible 2021-01-04 07:33:17 +11:00
Charles Dang
49034e4629 Play Controller: droped _const suffixes from getters 2021-01-03 21:17:54 +11:00
Charles Dang
c2c45aa085 Game Board: removed mouse_handler and menu_handler as friends 2021-01-03 18:54:38 +11:00
Charles Dang
627bde781e Made more use of play_controller::get_teams
Looks like some of these (esp in mouse_handler) would not have worked before without the non-const overload of get_teams.
2021-01-03 18:43:47 +11:00
Pentarctagon
4c2b725ec0 Change all doxygen comments to the same format. 2020-12-31 23:59:28 -06:00
Charles Dang
7cedcb57ab Mouse Events: removed an override that only called the base method 2019-10-19 18:44:08 +11:00
Charles Dang
2470984af3 Prepend 'SDL2/' to all SDL includes
This was needed to get the build working with vcpkg's version of SDL, where all the SDL files are
in their own SDL folder. However, our cmake config also has a note saying it was a deliberate choice
to move our SDL files *out* of their SDL2 folder due to certain distros (FreeBSD is mentioned) not
putting the files in said folder in the first place.
2019-07-22 15:35:55 +11:00
Jyrki Vesterinen
386c19f0cf Mouse events: remove owning reference to the attacking unit
Follow-up to commit f8bd38b1. Fixes the halo remaining in the corner case
@newfrenchy83 linked in a comment.
2018-11-10 10:47:12 +02:00
Jyrki Vesterinen
f8bd38b13c Mouse events: don't keep around references to fighting units
Keeping references is bad if a unit dies and the dying unit has a halo
and a long-running listener for the "last breath" event, like in AtS E2
S10. In that case keeping the reference means that the halo will remain
as long as the event runs.

Closes #3673.
2018-11-02 22:44:50 +02:00
Victor Sergienko
12bd7d34b6 iOS: panning 2018-10-28 18:21:54 +02:00
Victor Sergienko
b4ef4c9b34 iOS: Touch-hex action added. 2018-10-28 18:21:54 +02:00
Victor Sergienko
aedc081b2e iOS: Touch interface implemented, and a RMB emulation of such on PC. 2018-10-28 18:21:53 +02:00
gfgtdf
b4196af8c0 refactor battle_context
this has multiple advantages:;
1) it fixes #3594, an assertion failue that happend when a unit with
only one attack attacked when that one attack was disabled.
2) It now creates each pair or battle_context_unit_stats only once for
each pauir of attacks, previsouly the coud would create multiple
temporary battle_context_unit_stats objects to for exampel check
"disabled"
3) It simplifies the code by removing special handling of some cases.
2018-10-16 12:29:17 +02:00
josteph
01867f9a2c GUI: Fix check for no usable weapons.
Fixes #3424.

(cherry-picked from commit f293c7cb3226bc7b28dbb968419ab54ff4e180da)
2018-10-07 03:24:00 +00:00
gfgtdf
e3b4e1d911 fix attacks beein wrongly disabled
as said in the comment, that get_special_bool might return the wrong value, as since 5f58cd7c6d the bc_vector no longer contains disabled attacks we can just remove this code.

fixes #3324

(cherry-picked from commit 44734570dd1824a098252d78dafc0f5a561c13cf)
2018-10-07 03:23:53 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
fcfd534d90 Used the return value of modal_dialog::show instead of an explicit retval check when possible
(cherry-picked from commit 637e69f27173fb55a396eefe98a2cbbc5c662257)
2018-10-07 03:23:30 +00:00
Charles Dang
965b5e1648 Unit Attack: fixed issues arising from displayed items potentially not equally available items
Since there were weapons included that weren't shown, it was possible for the best
weapon selection to be a hidden one (in which case, the initial selection would be
wrong, and it was possible for the returned index to point to a hidden, disabled
weapon.

This resolves both issues by excluding these disabled attacks from the weapon choices
list altogether. They aren't considered when calculating the best attack either.

mouse_handler::fill_weapon_choices is also used in mouse_handler::attack_enemy_, but
I don't foresee this change should cause any issues there, since you aren't supposed
to be able to actually attack with disabled weapons anyway.

(cherry-picked from commit 00e58f12f9a57b2e25dd4f67efb1255b177e173b)
2018-10-07 03:22:24 +00:00
Charles Dang
19e3afb463 Convert C-style casts to static_cast
(cherry-picked from commit 0dc5656c328cdd02eebb4dbd10dbab3eb4553b57)
2018-10-07 03:21:02 +00:00