GunChleoc has proposed merging
lp:~widelands-dev/widelands/toolbar-dropdown-scripting-review-only into
lp:widelands with lp:~widelands-dev/widelands/fix-dropdowns as a prerequisite.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/toolbar-dropdown-scripting-review-only/+merge/368228
DO NOT MERGE, THIS WILL BREAK THE TUTORIALS!
Split off tutorial and scripting changes from
https://code.launchpad.net/~widelands-dev/widelands/toolbar-dropdown-menus
for easier review.
Use this merge request for reviewing the scripting changes, and the other
branch's merge request for reviewing the C++ changes. When the review is done,
merge the other branch and delete this one.
--
Your team Widelands Developers is requested to review the proposed merge of
lp:~widelands-dev/widelands/toolbar-dropdown-scripting-review-only into
lp:widelands.
=== modified file 'data/campaigns/tutorial01_basic_control.wmf/elemental'
--- data/campaigns/tutorial01_basic_control.wmf/elemental 2014-10-28 09:24:36 +
+++ data/campaigns/tutorial01_basic_control.wmf/elemental 2019-06-01 15:39:16 +
@@ -6,5 +6,5 @@
map_h="64"
nr_players="1"
name=_"Basic Control"
-author="Winterwind,SirVer,Nasenbaer,wl-zocker"
+author="Winterwind,SirVer,Nasenbaer,wl-zocker,GunChleoc"
descr=_"In this tutorial, you will learn how to navigate in Widelands and how to build buildings and roads."
=== modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/helper_functions_demonstration.lua'
--- data/campaigns/tutorial01_basic_control.wmf/scripting/helper_functions_demonstration.lua 2016-12-28 22:11:45 +
+++ data/campaigns/tutorial01_basic_control.wmf/scripting/helper_functions_demonstration.lua 2019-06-01 15:39:16 +
@@ -68,6 +68,18 @@
blocker:lift_blocks()
end
+
+function select_item_from_dropdown(name, item)
+ local blocker = UserInputDisabler:new()
+
+ wl.ui.MapView().dropdowns[name]:highlight_item(item)
+ sleep(5000)
+ wl.ui.MapView().dropdowns[name]:select()
+ sleep(3000)
+
+ blocker:lift_blocks()
+end
+
-- Make sure the user is in road building mode starting from the given flag
function enter_road_building_mode(flag)
local mv = wl.ui.MapView()
=== modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua'
--- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2017-06-25 12:53:48 +
+++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2019-06-01 15:39:16 +
@@ -2,17 +2,61 @@
-- Mission thread
--
+local objective_to_explain_objectives = add_campaign_objective(obj_initial_close_objectives_window)
+
+local function wait_for_quarry_road_connection(field, cs, objective)
+ -- Wait till the construction site is connected to the headquarters
+ sleep(10 * wl.Game().desired_speed)
+ while not field.immovable or field.brn.immovable.debug_economy ~= sf.brn.immovable.debug_economy do
+ if not field.immovable then
+ campaign_message_box(quarry_illegally_destroyed)
+ scroll_to_field(field)
+ mouse_to_field(field)
+
+ cs = nil
+ immovable_is_legal = function(i)
+-- only allow quarry and flag at this position because the road building below relies on this
+if (i.fields[1] == field) or (i.fields[1] == field.brn) then
+ cs = allow_constructionsite(i, {"barbarians_quarry"})
+ return cs
+elseif(i.descr.type_name == "flag") or (i.descr.type_name == "road") then
+ register_immovable_as_allowed(i)
+ return true
+else return false end
+ end
+
+ -- Wait for a new constructionsite to be placed
+ while not cs do sleep(200) end
+ register_immovable_as_allowed(cs)
+ else
+ campaign_message_box(quarry_not_connected)
+ end
+ sleep(60*1000)
+ end
+ set_objective_done(objective, 0)
+ register_immovable_as_allowed(cs)
+end
+
function starting_infos()
+ -- So that the player cannot build anything here
+ map:place_immovable("debris00", second_quarry_field, "world")
reveal_concentric(plr, sf, 13, true, 80)
- map:place_immovable("debris00",second_quarry_field, "world")
- -- so that the player cannot build anything here
-
sleep(1000)
- message_box_objective(plr, initial_message_01)
+ -- Welcome and teach objectives
+ local o = campaign_message_with_objective(initial_message_01, obj_initial_close_story_window)
+ set_objective_done(o, 100)
+
+ wl.ui.MapView().buttons.objectives:click()
+ while not wl.ui.MapView().windows.objectives do sleep(100) end
+ while wl.ui.MapView().windows.objectives do sleep(100) end
sleep(500)
- local o = message_box_objective(plr, initial_message_02)
+