Commit graph

120 commits

Author SHA1 Message Date
P. J. McDermott
b5d073a2ad Rename src/lua/*.h to src/lua/wrapper_*.h
These will be changed to conditionally include system Lua headers,
e.g. "lua.h", instead of submodule Lua headers, e.g. "module/lua/lua.h".
If a header named "lua.h" includes "lua.h", the build will fail due to
recursion.

This can't be solved using angle brackets to include system headers,
because macos builds won't find them:

    In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/registry.cpp:30:
    In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/composite/aspect.hpp:24:
    In file included from /Users/runner/work/wesnoth/wesnoth/src/ai/lua/lua_object.hpp:25:
    /Users/runner/work/wesnoth/wesnoth/src/lua/lua.h:4:14: error: 'lua.h' file not found with <angled> include; use "quotes" instead
        #include <lua.h>
                 ^~~~~~~
                 "lua.h"

Renamed with (requires GNU sed):

    $ for f in src/lua/*.h; do
    >     git mv "${f}" "src/lua/wrapper_${f#src/lua/}";
    > done
    $ git grep -El -- '#[ \t]*include[ \t]+"lua/[^"]+[.]h"' src | \
    > xargs sed -Ei -- '
    > s|(#[ \t]*include[ \t]+"lua/)(lua[.]h")(            )?|\1wrapper_\2|;
    > s|(#[ \t]*include[ \t]+"lua/)(lualib[.]h")(         )?|\1wrapper_\2|;
    > s|(#[ \t]*include[ \t]+"lua/)(lauxlib[.]h")(        )?|\1wrapper_\2|;
    > '
2024-02-11 23:21:15 -06:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Severin Glöckner
932dca3982 show_narration: use label column if only given a string
This matches behaviour in 1.14
2024-01-07 00:00:00 +01:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05: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
1a3498cbf3 Rename nowarn/ to lua/
Also cleanup the includes.
2022-03-09 15:01:37 -06:00
Pentarctagon
dd947db289 Avoid lua build warning without altering source code. 2022-03-09 15:01:37 -06:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Steve Cotton
4ad2760cd8
For a [message] with options, zero-initialise the default selection int (#6221)
I can't reproduce the issue (it selects the first option by default for me even
without this), but this probably fixes #6038 "When you have a long list of
[message][option], it will default to highlighting the 3rd entry for some
reason."

(this is the equivalent of 1.16's commit 219f2c8f02)
2021-10-25 14:12:36 +02: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
Celtic Minstrel
e555e0681d Fix a bunch of compiler warnings
- Some implicit conversions
- Loop variable is always copied
- Missing prototypes
- Unused lambda captures
- Comma operators
2021-07-01 01:33:28 -04:00
Steve Cotton
b6225e354d Make callers of help::show_help not need a help_manager
Most of the places that created a help_manager did so just to call show_help on
the next line. Move knowledge of the internals out of those callers and into
help.cpp.

This leaves editor_controller and play_controller with knowledge of help_manager,
however both of those classes handle ownership of the game_config too.
2021-05-14 11:38:35 +02:00
Celtic Minstrel
7b2ceb863c Move open_help to the gui module (as show_help)
This also exposes it in kernels besides the game kernel.
2021-05-11 14:52:18 -04:00
Charles Dang
4d54b2a7fd Used std::optional directly since we support C++17 now 2021-01-17 11:48:14 +11:00
Charles Dang
6e2f3e099e Removed utils/functional.hpp 2020-12-04 15:30:46 +11:00
Charles Dang
30c7a747ab Explicitly specify std::placeholders namespace for all bind placeholders
Apparently, even on Boost 1.73 without Boost placeholders specialized as is_placeholder, they were somehow
getting used in the global namespace. Would explain all the "Boost placeholders in the global namespace is
deprecated" warnings I was getting after 23d1db043f.

When testing with BOOST_BIND_NO_PLACEHOLDERS, even though I had `using namespace std::placeholders` in utils/functional.hpp,
compilation still failed in places. This confirms even more that Boost global placeholders were being used. Honestly,
it was simplest just to specify std::placeholders for everything. This also means we can remove the hack in utils/functional.hpp
designed to allow Boost placeholders to work with `std::bind`.
2020-12-04 15:28:15 +11:00
Charles Dang
cb537f781b
Converted uses of boost::optional to utils::optional (#5329) 2020-12-02 08:16:05 +11:00
Celtic Minstrel
251e6c3f7a Apply the deprecation standard to the new GUI2 API
This also removes backwards-compatibility.lua altogether.
It's no longer correct in the general case to add backwards compatibility code to this file, so removing it entirely avoids situations where compatibility code is incorrectly added there.

In the C++, this removes the commented-out old GUI2 API entries, and
adds show_dialog to the gui module directly instead of moving it in core.lua
2020-09-27 16:44:28 -04:00
gfgtdf
90a5930f21 new lua gui2 widget userdata
lua now has a widget userdata that can be used
to set/get widgets properties as one would
expect, a lot of the set/get_dialog_xy function
were converted into modifiable properties of
the widget userdata. This in particular allows
us to get rid of the strange 'path to widget'
type of arguments of gui2 functions.

It currently generates lot of compiler wanrings,
I will fix this in a later commit.

One of the main advantage is that it makes it
much easier to add new api, previously a lot
of functions where overused, probably because
that was just easier than creatign a new
function. For example set_dialog_value returned
multiple value of listbox objects. (the
compatibility path doesn't support this
particular feature yet but i don't think it is
important, it probably wasn't even used at all,
since it also wasn't documented).

This also adds some new features, like an 'add_item'
function to add an item to a listbox, a 'type'
property of widgets to query the type of a
widget and a 'item_count' property to count the
number of children in an item.

Im still not 100% sure about the
property /function names, in particular:

1) i might rename 'items' to 'elements' or
   'children' in some functions. Not sure yet
2) I might rename the 'value' property to
   'value_compat' to make clear that its only
   supposed to be used by the
   backwards_compat.lua code.

A next step in improving this api might be
to introduce a (reusable!) 'window' userdata
so that the implementaion of wesnoth.show_dialog
would become:
```
function wesnoth.show_dialog(wml, preshow, postshow)
  local dialog = gui.create_dialog(wml)
  preshow(dialog)
  local res = dialog:show()
  postshow(dialog)
  return res
end
```

However this is currently not really possble
since the pure existance of a gui2::window
object blocks the gui1 code (the main game view)
from receiving events. So we clearly cannot luas
gc take ownership of gui2::window objects.
2020-09-03 22:08:53 +02:00
Celtic Minstrel
1323e75ee2 Split out the main core modules of Wesnoth (wml, gui, stringx) into separate C++ source files
And load them with lua_requiref because we can.
2019-12-09 21:54:28 -05:00
Charles Dang
c15cb0696e GUI2: added display and execute wrappers for a bunch more dialogs
Made use of them where applicable. There are a whole bunch of cases where the dialog
object only exists to check its return value, but I'll update those separately.
2019-10-19 18:44:05 +11:00
Charles Dang
2adac53461 GUI2/Tree View: use NOTIFY_MODIFIED events instead of manual callbacks
Unlike other widgets where `this` is the event target, the tree nodes fire the event
with the tree widget itself as the target.

I had added a fire-event call in f97dc8ae12, but with
the target as the node. I don't think there was any way that would have worked...
changed.
2019-10-19 17:52:14 +11:00
Celtic Minstrel
7c07cc71c0 Remove support for legacy menu markup 2019-09-18 22:48:53 -04:00
Jyrki Vesterinen
d8bbcc6b1e Fix #3794: dialog callback can be called immediately
When a dialog registered a new callback in the callback handler, the new
callback was called as a result of the same event that fired the original
handler.

The solution is to simply stop processing of the event after executing the
original handler.
2018-12-22 07:09:02 +02:00
gfgtdf
ed49d27511 add wesnoth.set_dialog_tooltip fixes #3692 2018-11-11 02:16:46 +01:00
gfgtdf
cc8a9e8128 don't call invalidate_layout() unless needed
commit 8000a868 added an invalidate layout() call to fix issues arisiong from widgets that change its site when their 'value' is changes.
But with this, some dialogs, in particular the custom help dialgog in the addon "world conquest 2", reacted much slower to user input because invalidate_layout() causes the dialogs to recaclulate all its siszes which is very slow. Since most of the widgets, in particular 'multi_page' don't change their size when the value is changed, this commit fixes the mentioned custom help dialog by not calling invalidate_layout() when cahnging the value of those widgets.
(cherry picked from commit 808bd59dae)
2018-10-28 02:53:12 +00:00
Charles Dang
00a1edd149 Convert a bunch more C-style casts I missed in 0dc5656 to static_cast
(cherry picked from commit cb43d8b35f)
2018-10-28 02:53:11 +00:00
josteph
cd7052a4cb Lua: Invalidate layout in set_dialog_value()
Needed when the new value is longer than the old one.

Fixes #3572.

(cherry picked from commit 8000a86828)
2018-10-28 02:53:10 +00:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0
(cherry-picked from commit bc4d22dc72)
2018-10-07 03:23:36 +00:00
Charles Dang
c6e9efde9c GUI2: removed 2010 experimental listbox
This was never finished, is not maintained, suffers from a lack of features the "old" listbox
class now has, and seems (according to the logs) to be have been superceded by the pane widget.
At the very least, the pane widget seems to be what mordante was working with in his early
prototype of a new addon manager, and not this 2010 list class.

(cherry-picked from commit 458dd284b8)
2018-10-07 03:23:07 +00:00
Celtic Minstrel
d6052862df Fix two of the dialog functions not accepting translatable strings
(cherry-picked from commit 0327085d99)
2018-10-07 03:19:18 +00:00
Charles Dang
45f871067f Use std::size_t everywhere instead of plain size_t
Excludes:
* spirit_po/
* xBRZ/

(cherry-picked from commit fc2a58f693)
2018-10-07 03:17:59 +00:00
Celtic Minstrel
709ecedad7 Lua show_menu: allow specifying markup but not initial selection 2018-03-17 18:11:34 -04:00
Gregory A Lundberg
2d6392adc3
Fix variable hides variable 2018-03-13 19:11:06 -05:00
Charles Dang
26e8c148b1 GUI2: split default return value enum into its own file
This avoid having to include gui/widgets/window.hpp every time you just want to
check a dialog's return value.
2018-03-12 12:03:48 +11:00
Celtic Minstrel
ab354737ef Fix wesnoth.show_message_box ignoring user-specified case for button label 2018-03-11 13:50:53 -04:00
Celtic Minstrel
5fc9d8d173 Use new deprecated_message() function wherever possible (C++)
This also covers handling of legacy DescriptionWML for [set_menu_item],
and tweaks its handling in the other cases (mainly [multiplayer_side]).

I added the next_dev_version constant intending to use it, but then
decided not to do so; however I left it in in case someone finds it useful.
2018-03-04 21:21:33 -05:00
Celtic Minstrel
0e9935593d Lua GUI2: Support sliders in set_dialog_callback 2018-02-13 10:44:23 +11:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Charles Dang
6759f41b1e GUI2: cleaned up and restructured initialization process
This mostly has to do with moving various components into more logical locations instead of
all mushed together in gui/widgets/settings.*pp. To that end, the following changes have been
made:

* The gui2::init function has been moved to its own file in the gui/ toplevel.
* load_settings() has been merged into init().
* All functions and code relating to gui theme definitions have been moved to their own file.
* All code relating to widgets or window static init have been moved to their own file.
* window::update_screen_size has been moved out of the window class and into settings.cpp.
* The unimplemented free-stadnding version of load_widget_definitions has been removed.
* gui_definition::read and gui_defintion::load have been merged into the gui_definition ctor
  and greatly simplified.
* Some functions relating to builder_widgets have been renamed for clarity.
* add/remove_single_widget_defintion now access the current gui theme instead of the default.
  This looks like it was a mistake made in the original code.
* Since the static registry is now externally linked, the unit tests accessor for window types
  has been removed.
* Documentation has been updated. The wikidoc comment for gui_definition has been removed. It
  was rather out-of-date and needed to be reworked anyway.
* widget_builder_func_t's signature is now to take a config reference and not a copy, though
  REGISRER_WIDGET had already passed register_builder_widget a lambda that took a reference.
* Various other misc cleanups and improvements.
2017-12-11 14:49:58 +11:00
Charles Dang
c67f5c352a Cleaned up more unnecessary CVideo function arguments and class members
* Dropped unused CVideo class member references.
* Replaced the lone usecase of the CVideo member in loadgame with the singleton and removed said member.
* Removed CVideo references from a bunch of addon management functions.
* Cleaned up a *lot* of now-unnecessary forward CVideo declarations.
2017-11-21 03:07:23 +11:00
Charles Dang
f2b31ba082 Massive cleanup of GUI2 display/show and execute functions implementations and related CVideo arguments
This a two part commit. First:
----------------------------------------------------------------------------------------------------
Added and deployed two new helper macros for the standard implementations of the static execute
and display functions. I also made use of a variadic template in order greatly simplify code
maintenance. Now, even if the dialog's ctor parameters change, no one has to worry about updating
the associated execute/display functions (though of course, this only applies if the helper macros
are used). \o/

I did not deploy the macro in cases where there were multiple overloads or the functions did more
than just show their dialogs. I might add an additional __VA_ARGS_ parameter to the macros later.
Do note for the end_credits dialog I moved the default empty-string parameter from the display
function to the ctor.

Second:
----------------------------------------------------------------------------------------------------
Another change is that modal_dialog::show and modeless_dialog::show no longer take CVideo arguments.
Since the video argument couldn't be included in the parameter pack (maintaining the argument would
have meant making it the first one, which would be just as much work), and using CVideo::get_singleton
in the macros would require adding video.hpp includes in a whole bunch of files, I simply removed the
argument. I had been intending to do this for a while anyway.

This therefor also removes the CVideo argument from:
* All dialog display/execute functions.
* modal_dialog::show
* modal_dialog::build_window
* modeless_dialog::show
* modeless_dialog::build_window
* wml_exception::show
* gui2::show_message
* gui2::show_error_message
* gui2::show_transient_message
* gui2::show_transient_error_message
* gui2::show_wml_message
* gui2::build
* gui2:🪟:window
* gui2::dialogs::tip::show
* Various GUI2-related Lua functions. The video_dispatch helper was also removed.
* Any functions that took a CVideo argument for the sole purpose of passing it to one of the above.

Ya know, all these damn CVideo arguments didn't actually do anything, besides an occasional check to
CVideo::faked. At the end of the pipeline, they just got assigned to the video_ member of gui2::window.
Huge code bloat for nothing.
2017-11-20 19:24:41 +11:00
Charles Dang
19bbfedb32 Deployed unique_ptrs in a bunch more places
The changes from stack::push to stack::emplace in ai::handler are since the unique_ptrs make the copy
ctor malformed.
2017-09-04 03:18:21 +11:00
Charles Dang
2a1c1a81fc GUI2: convert uses of 'state changed' callbacks to NOTIFY_MODIFIED signal handlers 2017-08-26 10:49:06 +11:00
Charles Dang
e58bbd7a20 GUI2: use signal handlers for listbox event handling
This affects uses of both set_callback_item_change and set_callback_value_change.
Finally we get rid of most of the conditional GUI2_EXPERIMENTAL_LISTBOX handler setups. \o/

[ci skip]
2017-08-26 10:49:06 +11:00
Celtic Minstrel
e6fce88d21 Minor fixups to [story] 2017-06-04 12:26:02 -04:00
Charles Dang
cdc9ce1fea Fixup cef3e0d 2017-05-05 12:00:02 +11:00
Celtic Minstrel
cef3e0d266 Add wesnoth.show_message_box function 2017-05-04 20:09:52 -04:00
Celtic Minstrel
efb0fe05e9 Accept [story] as ActionWML 2017-05-02 20:49:10 -04:00