← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/simplify_messagebox into lp:widelands

 

SirVer has proposed merging lp:~widelands-dev/widelands/simplify_messagebox into lp:widelands.

Commit message:
Remove unused parameters of message_box_objective.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/simplify_messagebox/+merge/313885
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/simplify_messagebox into lp:widelands.
=== modified file 'data/scripting/messages.lua'
--- data/scripting/messages.lua	2016-11-30 09:15:26 +0000
+++ data/scripting/messages.lua	2016-12-27 12:03:23 +0000
@@ -116,9 +116,6 @@
 --
 --    Besides the normal message arguments (see wl.Game.Player:message_box) the following ones can be used:
 --
---    :arg append_objective: If true, the objective text is appended to the message.body using new_objectives(). Default: False.
---       :arg obj_number: or :arg number: Used for the plural formatting in new_objectives. Default: 1.
---    :arg jump_to_field: If true, the view jumps to the message.field rather than scroll to it. Does nothing if the field is nil. Default: False, i.e. the view will scroll.
 --    :arg position: A string that indicates at which border of the screen the message box shall appear. Can be "top", "bottom", "right", "left" or a combination (e.g. "topright"). Overrides posx and posy. Default: Center. If only one direction is indicated, the other one stays central.
 --    :arg scroll_back: If true, the view scrolls/jumps back to where it came from. If false, the new location stays on the screen when the message box is closed. Default: False.
 --    :arg show_instantly: If true, the message box is shown immediately. If false, this function calls message_box(), which waits until the player leaves the roadbuilding mode. Use this with care because it can be very interruptive. Default: false.
@@ -127,27 +124,21 @@
 
 -- TODO(wl-zocker): This function should be used by all tutorials, campaigns and scenario maps
 function message_box_objective(player, message)
-   message.jump_to_field = message.jump_to_field or false
    message.show_instantly = message.show_instantly or false
    message.scroll_back = message.scroll_back or false
    message.append_objective = message.append_objective or false
    message.h = message.h or 400
    message.w = message.w or 450
 
-   local way, x, y
+   local way
 
    if message.field then
-      if message.jump_to_field then
-         x,y = wl.ui.MapView().viewpoint_x, wl.ui.MapView().viewpoint_y
-         -- player:message_box jumps, so nothing to do for us
-      else
       -- This is necessary. Otherwise, we would scroll and then wait until the road is finished.
       -- In this time, could user can scroll elsewhere, giving weird results.
-         if not message.show_instantly then
-            wait_for_roadbuilding()
-         end
-         way = scroll_smoothly_to(message.field)
+      if not message.show_instantly then
+         wait_for_roadbuilding()
       end
+      way = scroll_smoothly_to(message.field)
    end
 
    if message.position then
@@ -163,13 +154,6 @@
       end
    end
 
-   if (message.obj_name and message.append_objective) then
-      message.obj_number = message.obj_number or message.number or 1
-      -- because new_objectives needs a body
-      local obj = {body = objective_text(message.obj_title, message.obj_body), number = message.obj_number}
-      message.body = message.body .. new_objectives(obj)
-   end
-
    if message.show_instantly then
       -- message_box takes care of this, but player:message_box does not
       local user_input = wl.ui.get_user_input_allowed()
@@ -181,12 +165,7 @@
    end
 
    if (message.field and message.scroll_back) then
-      if message.jump_to_field then
-         wl.ui.MapView().viewpoint_x = x
-         wl.ui.MapView().viewpoint_y = y
-      else
-         timed_scroll(array_reverse(way))
-      end
+      timed_scroll(array_reverse(way))
    end
 
    if message.obj_name then


Follow ups