[wesnoth-commits] [wesnoth/wesnoth] 0a9c3a: fix lua_push<string_view>

gfgtdf noreply at github.com
Thu Sep 3 20:09:12 UTC 2020


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 0a9c3a45eb658ff819d173a903b100c7c1b03a40
      https://github.com/wesnoth/wesnoth/commit/0a9c3a45eb658ff819d173a903b100c7c1b03a40
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M src/scripting/push_check.hpp

  Log Message:
  -----------
  fix lua_push<string_view>


  Commit: 90a5930f2111718d639e88c5cb66f1bbc9cd8229
      https://github.com/wesnoth/wesnoth/commit/90a5930f2111718d639e88c5cb66f1bbc9cd8229
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M data/lua/backwards-compatibility.lua
    M source_lists/wesnoth
    M src/gui/widgets/listbox.cpp
    M src/gui/widgets/multi_page.cpp
    M src/gui/widgets/widget.cpp
    M src/gui/widgets/widget.hpp
    M src/scripting/lua_gui2.cpp
    M src/scripting/lua_kernel_base.cpp
    A src/scripting/lua_ptr.hpp
    A src/scripting/lua_widget.cpp
    A src/scripting/lua_widget.hpp
    A src/scripting/lua_widget_attributes.cpp
    A src/scripting/lua_widget_attributes.hpp
    A src/scripting/lua_widget_methods.cpp
    A src/scripting/lua_widget_methods.hpp
    M src/scripting/push_check.hpp

  Log Message:
  -----------
  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.


  Commit: 522f301dd00f7611351ca2df109543c741958b06
      https://github.com/wesnoth/wesnoth/commit/522f301dd00f7611351ca2df109543c741958b06
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M src/scripting/lua_widget_attributes.cpp

  Log Message:
  -----------
  fix unused parameter warning


  Commit: ba1ea7a701fc7ea92913c4b63bf4d6e6e2e2f347
      https://github.com/wesnoth/wesnoth/commit/ba1ea7a701fc7ea92913c4b63bf4d6e6e2e2f347
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M data/campaigns/World_Conquest/lua/game_mechanics/wocopedia/help.lua
    M data/campaigns/World_Conquest/lua/game_mechanics/wocopedia/help_dialog.lua

  Log Message:
  -----------
  wc: use new widget lua userdata in help dialog


  Commit: 7b2ede62432485791580033cdf2e013fe8f2269f
      https://github.com/wesnoth/wesnoth/commit/7b2ede62432485791580033cdf2e013fe8f2269f
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M data/campaigns/Secrets_of_the_Ancients/utils/zombie-utils.cfg
    M data/campaigns/Secrets_of_the_Ancients/utils/zombie_recruit_dialog.lua

  Log Message:
  -----------
  SotA: use new gui2 widgets api in custom dialog


  Commit: 661fc1d8efb8c8ff89d9a771c2a68812c19499a4
      https://github.com/wesnoth/wesnoth/commit/661fc1d8efb8c8ff89d9a771c2a68812c19499a4
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M data/lua/backwards-compatibility.lua
    M src/scripting/lua_widget.cpp
    M src/scripting/lua_widget.hpp
    M src/scripting/lua_widget_methods.cpp

  Log Message:
  -----------
  refactoor lua gui2 callback code

this refactors the lua gui2 callback c++ implementation
Now the callback infrastructure also supports different
types of callbacks for a single widget. Furthermore
it also supports multiple open gui2 dialogs at the same time.

This now also makes the widget parameter of widget.find
manditory.


  Commit: ae2b7fc2dee517c1c10cea5771a84f9487d23923
      https://github.com/wesnoth/wesnoth/commit/ae2b7fc2dee517c1c10cea5771a84f9487d23923
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M src/scripting/lua_widget_methods.cpp

  Log Message:
  -----------
  add lua window:close() function


  Commit: a158eef0d04e768a6e5203849573e48a675c572a
      https://github.com/wesnoth/wesnoth/commit/a158eef0d04e768a6e5203849573e48a675c572a
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M src/scripting/lua_widget_attributes.cpp

  Log Message:
  -----------
  move widget attributes before children

This is mostly for perfromance reasons, sicne windget::find()
might search quite a while (relertively) in the wirst case


  Commit: 5a9c5bda1cc785ed435a41ba84bb0a71ea9f89da
      https://github.com/wesnoth/wesnoth/commit/5a9c5bda1cc785ed435a41ba84bb0a71ea9f89da
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-09-03 (Thu, 03 Sep 2020)

  Changed paths:
    M src/scripting/lua_widget_attributes.cpp

  Log Message:
  -----------
  add more lua widget callbacks

I'm not sure how mcuh of this api we should expose
in particular wrt to the fron/back_pre/postchild
parameter. The api is still no in its final state


Compare: https://github.com/wesnoth/wesnoth/compare/c48e176a1a0e...5a9c5bda1cc7



More information about the Commits mailing list