move WML [redraw] impl to lua
This commit is contained in:
parent
3b13ac21da
commit
96c35f6560
5 changed files with 58 additions and 45 deletions
38
.travis.yml
38
.travis.yml
|
@ -5,17 +5,17 @@ compiler:
|
|||
- clang
|
||||
|
||||
env:
|
||||
- BUILD="-O0"
|
||||
- BUILD="-O2"
|
||||
- BUILD="C++11 -O0"
|
||||
- BUILD="translations"
|
||||
- BUILD=1
|
||||
- BUILD=3
|
||||
- BUILD=4
|
||||
- BUILD=5
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
- compiler: gcc
|
||||
env: BUILD="-O2"
|
||||
env: BUILD=3
|
||||
- compiler: gcc
|
||||
env: BUILD="translations"
|
||||
env: BUILD=5
|
||||
|
||||
before_install:
|
||||
- export TARGETS="wesnoth wesnothd campaignd test"
|
||||
|
@ -30,21 +30,21 @@ before_install:
|
|||
- export NLS=false
|
||||
- export CXX11=false
|
||||
|
||||
- if [ "$BUILD" == "-O0" ]; then export STRICT_COMPILATION=false; fi
|
||||
- if [ "$BUILD" == "-O0" ]; then export EXTRA_FLAGS_RELEASE=""; fi
|
||||
- if [ "$BUILD" == "-O0" ]; then export WML_TEST_TIME=20; fi
|
||||
- if [ "$BUILD" == "-O0" ]; then export MP_TEST=true; fi
|
||||
- if [ "$BUILD" = 3 ]; then export STRICT_COMPILATION=false; fi
|
||||
- if [ "$BUILD" = 3 ]; then export EXTRA_FLAGS_RELEASE=""; fi
|
||||
- if [ "$BUILD" = 3 ]; then export WML_TEST_TIME=20; fi
|
||||
- if [ "$BUILD" = 3 ]; then export MP_TEST=true; fi
|
||||
|
||||
- if [ "$BUILD" == "C++11 -O0" ]; then export CXX11=true; fi
|
||||
- if [ "$BUILD" == "C++11 -O0" ]; then export EXTRA_FLAGS_RELEASE="-O0 -Wno-literal-suffix -Wno-deprecated-declarations"; fi
|
||||
- if [[ "$BUILD" == "C++11 -O0" ]] && [[ "$CXX" == "clang" ]]; then export EXTRA_FLAGS_RELEASE="-O0 -Wno-literal-suffix -Wno-deprecated-declarations -Wno-deprecated-register"; fi
|
||||
- if [ "$BUILD" == "C++11 -O0" ]; then export PLAY_TEST=false; fi
|
||||
- if [ "$BUILD" = 4 ]; then export CXX11=true; fi
|
||||
- if [ "$BUILD" = 4 ]; then export EXTRA_FLAGS_RELEASE="-O0 -Wno-literal-suffix -Wno-deprecated-declarations"; fi
|
||||
- if [[ "$BUILD" = 4 ]] && [[ "$CXX" == "clang++" ]]; then export EXTRA_FLAGS_RELEASE="-O0 -Wno-literal-suffix -Wno-deprecated-declarations -Wno-deprecated-register"; fi
|
||||
- if [ "$BUILD" = 4 ]; then export PLAY_TEST=false; fi
|
||||
|
||||
- if [ "$BUILD" == "translations" ]; then export NLS=true; fi
|
||||
- if [ "$BUILD" == "translations" ]; then export TARGETS="translations"; fi
|
||||
- if [ "$BUILD" == "translations" ]; then export WML_TESTS=false; fi
|
||||
- if [ "$BUILD" == "translations" ]; then export CPP_TESTS=false; fi
|
||||
- if [ "$BUILD" == "translations" ]; then export PLAY_TEST=false; fi
|
||||
- if [ "$BUILD" = 5 ]; then export NLS=true; fi
|
||||
- if [ "$BUILD" = 5 ]; then export TARGETS="translations"; fi
|
||||
- if [ "$BUILD" = 5 ]; then export WML_TESTS=false; fi
|
||||
- if [ "$BUILD" = 5 ]; then export CPP_TESTS=false; fi
|
||||
- if [ "$BUILD" = 5 ]; then export PLAY_TEST=false; fi
|
||||
|
||||
install:
|
||||
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ saucy main universe"
|
||||
|
|
|
@ -1354,3 +1354,14 @@ end
|
|||
function wml_actions.scroll(cfg)
|
||||
wesnoth.scroll(cfg)
|
||||
end
|
||||
|
||||
function wml_actions.redraw(cfg)
|
||||
local clear_shroud = cfg.clear_shroud
|
||||
|
||||
-- Backwards compat, the behavior of the tag was to clear shroud in case that side= is given.
|
||||
if cfg.clear_shroud == nil and cfg.side ~= nil then
|
||||
clear_shroud = true
|
||||
end
|
||||
|
||||
wesnoth.redraw(cfg, clear_shroud)
|
||||
end
|
||||
|
|
|
@ -1532,32 +1532,6 @@ WML_HANDLER_FUNCTION(recall, /*event_info*/, cfg)
|
|||
LOG_WML << "A [recall] tag with the following content failed:\n" << cfg.get_config().debug();
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(redraw, /*event_info*/, cfg)
|
||||
{
|
||||
game_display &screen = *resources::screen;
|
||||
|
||||
const config::attribute_value clear_shroud_av = cfg["clear_shroud"];
|
||||
const config::attribute_value side = cfg["side"];
|
||||
bool clear_shroud_bool = clear_shroud_av.to_bool(false);
|
||||
if(clear_shroud_av.blank() && !side.blank()) {
|
||||
//Backwards compat, behavior of the tag was to clear shroud in case that side= is given.
|
||||
clear_shroud_bool = true;
|
||||
}
|
||||
|
||||
if (clear_shroud_bool) {
|
||||
side_filter filter(cfg, resources::filter_con);
|
||||
BOOST_FOREACH(const int side, filter.get_teams()){
|
||||
actions::clear_shroud(side);
|
||||
}
|
||||
screen.recalculate_minimap();
|
||||
}
|
||||
bool result = screen.maybe_rebuild();
|
||||
if (!result) {
|
||||
screen.invalidate_all();
|
||||
}
|
||||
screen.draw(true,true);
|
||||
}
|
||||
|
||||
WML_HANDLER_FUNCTION(remove_sound_source, /*event_info*/, cfg)
|
||||
{
|
||||
resources::soundsources->remove(cfg["id"]);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "global.hpp"
|
||||
|
||||
#include "actions/attack.hpp" // for battle_context_unit_stats, etc
|
||||
#include "actions/vision.hpp" // for clear_shroud
|
||||
#include "ai/composite/ai.hpp" // for ai_composite
|
||||
#include "ai/composite/component.hpp" // for component, etc
|
||||
#include "ai/composite/contexts.hpp" // for ai_context
|
||||
|
@ -2738,6 +2739,31 @@ int game_lua_kernel::intf_delay(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int game_lua_kernel::intf_redraw(lua_State *L)
|
||||
{
|
||||
if (game_display_) {
|
||||
game_display & screen = *game_display_;
|
||||
|
||||
vconfig cfg(luaW_checkvconfig(L, 1));
|
||||
bool clear_shroud(lua_toboolean(L, 2));
|
||||
|
||||
if (clear_shroud) {
|
||||
side_filter filter(cfg, &game_state_);
|
||||
BOOST_FOREACH(const int side, filter.get_teams()){
|
||||
actions::clear_shroud(side);
|
||||
}
|
||||
screen.recalculate_minimap();
|
||||
}
|
||||
|
||||
bool result = screen.maybe_rebuild();
|
||||
if (!result) {
|
||||
screen.invalidate_all();
|
||||
}
|
||||
screen.draw(true,true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dimension of an image.
|
||||
* - Arg 1: string.
|
||||
|
@ -3201,6 +3227,7 @@ game_lua_kernel::game_lua_kernel(const config &cfg, CVideo * video, game_state &
|
|||
{ "place_shroud", boost::bind(&game_lua_kernel::intf_shroud_op, this, _1, true) },
|
||||
{ "put_recall_unit", boost::bind(&game_lua_kernel::intf_put_recall_unit, this, _1) },
|
||||
{ "put_unit", boost::bind(&game_lua_kernel::intf_put_unit, this, _1) },
|
||||
{ "redraw", boost::bind(&game_lua_kernel::intf_redraw, this, _1) },
|
||||
{ "remove_shroud", boost::bind(&game_lua_kernel::intf_shroud_op, this, _1, false) },
|
||||
{ "remove_tile_overlay", boost::bind(&game_lua_kernel::intf_remove_tile_overlay, this, _1) },
|
||||
{ "replace_schedule", boost::bind(&game_lua_kernel::intf_replace_schedule, this, _1) },
|
||||
|
|
|
@ -124,6 +124,7 @@ class game_lua_kernel : public lua_kernel_base
|
|||
int intf_add_tile_overlay(lua_State *L);
|
||||
int intf_remove_tile_overlay(lua_State *L);
|
||||
int intf_delay(lua_State *L);
|
||||
int intf_redraw(lua_State *L);
|
||||
int intf_replace_schedule(lua_State *l);
|
||||
int intf_scroll(lua_State *L);
|
||||
int intf_get_all_vars(lua_State *L);
|
||||
|
|
Loading…
Add table
Reference in a new issue