Revert the entire new messages stuff.
The main reason for reverting are: The stuff has hampered my development for almost a month now, including forcing me to delay things I need to/want to work on. The recruit dialog looks very ugly on 1024x768 since it doesn't fit entirely on the screen. It's still usable, but lowering the height of the main window makes the dialog unusable. The code includes several new wml errors: "Invalid WML found: Window builder: parsing resolution tip with empty 'id' field. Will become mandatory in 1.9.7. (4)" The unit tests are broken, and instead of being fixed properly their code is being `fixed' by disabling tests. 2011-03-05T20:39:56Z!fabianmueller5@gmx.de indicates it should fix the unit tests, but it doesn't so the code seems untested. Which means I still can't use the tests for other code I want to commit. In 2011-03-05T09:12:02Z!fabianmueller5@gmx.de fendrin commits not working code with the goal to force me to help him, which I consider bad practice, show the code in a pastebin if you want help. I want to work on things when _I_ choose to, and not being coerced to by committing bad code. Commit 2011-03-05T12:04:13Z!fabianmueller5@gmx.de throws private _GUI* macros in a global header, which might break other code in unexpected ways. The file modified even contains the documentation regarding how to use GUI* and _GUI* macros. And another remark that I should look at fixing the issue. So I had enough of this stuff; it's incomplete, buggy and hampers the work of at least one other developer for several weeks now. Reverts fendrin's commits: 2011-02-11T19:01:16Z!fabianmueller5@gmx.de 2011-02-12T06:25:47Z!fabianmueller5@gmx.de 2011-02-12T16:43:20Z!fabianmueller5@gmx.de 2011-02-12T17:37:40Z!fabianmueller5@gmx.de 2011-02-12T18:36:30Z!fabianmueller5@gmx.de 2011-02-12T19:59:34Z!fabianmueller5@gmx.de 2011-02-12T20:47:43Z!fabianmueller5@gmx.de 2011-02-12T21:41:35Z!fabianmueller5@gmx.de 2011-02-12T22:35:15Z!fabianmueller5@gmx.de 2011-02-14T19:24:40Z!fabianmueller5@gmx.de 2011-02-14T20:55:55Z!fabianmueller5@gmx.de, 2011-03-02T18:59:59Z!fabianmueller5@gmx.de 2011-03-03T13:34:48Z!fabianmueller5@gmx.de 2011-03-03T13:56:10Z!fabianmueller5@gmx.de 2011-03-03T17:32:49Z!fabianmueller5@gmx.de 2011-03-04T00:52:26Z!fabianmueller5@gmx.de 2011-03-04T11:27:39Z!fabianmueller5@gmx.de 2011-03-04T11:28:48Z!fabianmueller5@gmx.de 2011-03-05T09:12:02Z!fabianmueller5@gmx.de 2011-03-05T11:16:09Z!fabianmueller5@gmx.de 2011-03-05T11:19:37Z!fabianmueller5@gmx.de 2011-03-05T11:21:19Z!fabianmueller5@gmx.de 2011-03-05T11:32:25Z!fabianmueller5@gmx.de 2011-03-05T11:47:30Z!fabianmueller5@gmx.de 2011-03-05T12:00:39Z!fabianmueller5@gmx.de 2011-03-05T12:01:22Z!fabianmueller5@gmx.de 2011-03-05T12:02:03Z!fabianmueller5@gmx.de 2011-03-05T12:02:46Z!fabianmueller5@gmx.de 2011-03-05T12:04:13Z!fabianmueller5@gmx.de 2011-03-05T12:05:02Z!fabianmueller5@gmx.de 2011-03-05T12:20:25Z!fabianmueller5@gmx.de 2011-03-05T12:24:39Z!fabianmueller5@gmx.de 2011-03-05T13:56:43Z!fabianmueller5@gmx.de, 2011-03-05T16:32:38Z!fabianmueller5@gmx.de 2011-03-05T16:34:34Z!fabianmueller5@gmx.de 2011-03-05T16:35:17Z!fabianmueller5@gmx.de 2011-03-05T20:39:56Z!fabianmueller5@gmx.de 2011-03-05T22:17:03Z!fabianmueller5@gmx.de 2011-03-05T22:29:29Z!fabianmueller5@gmx.de. Also reverts a build system change that is no longer needed: 2011-03-05T16:35:04Z!anonymissimus@arcor.de
This commit is contained in:
parent
9a6855f78c
commit
360ade6068
24 changed files with 441 additions and 2906 deletions
|
@ -278,143 +278,3 @@
|
|||
18
|
||||
#enddef
|
||||
|
||||
#TODO change comments a little
|
||||
###
|
||||
### The in game portrait dialogs.
|
||||
### Due to the excessive amount of dialogs it's not possible to split off the
|
||||
### window definitions. So this unit is a bit larger as wanted.
|
||||
###
|
||||
|
||||
# These might become global have to evaluate later.
|
||||
#define _GUI_HEIGHT_OFFSET
|
||||
25#enddef
|
||||
|
||||
# helper convert the scale factor, since we use it in two places define it as
|
||||
# helper value. (Two the not working and working version, but want to avoid
|
||||
# surprises when the not working version is fixed).
|
||||
#define __GUI_SIZE_FACTOR
|
||||
3#enddef
|
||||
|
||||
### The formula language doesn't support variables so macros are used to
|
||||
### emulate them. This makes the code what harder to read, so the algorithm for
|
||||
### __GUI_IMAGE_WIDTH is described here:
|
||||
###
|
||||
### if gamemap_width <= TEXT_WIDTH_SATURATION
|
||||
### __GUI_IMAGE_WIDTH = gamemap_width / 3
|
||||
### else
|
||||
### # Text reached it maximum width, take all space.
|
||||
### __GUI_IMAGE_WIDTH = gamemap_width - MAX_TEXT_WIDTH
|
||||
### fi
|
||||
###
|
||||
### if __GUI_IMAGE_WIDTH < 250
|
||||
### __GUI_IMAGE_WIDTH = 250
|
||||
### fi
|
||||
###
|
||||
### if __GUI_IMAGE_WIDTH > 500
|
||||
### __GUI_IMAGE_WIDTH = 500
|
||||
### fi
|
||||
|
||||
#define __GUI_MAX_HEIGHT
|
||||
(gamemap_height - 4)
|
||||
#enddef
|
||||
|
||||
# The maximum width of the text
|
||||
#define MAX_TEXT_WIDTH
|
||||
675
|
||||
#enddef
|
||||
|
||||
# gamemap_width width needed to reach the MAX_TEXT_WIDTH
|
||||
#define TEXT_WIDTH_SATURATION
|
||||
((3 * {_GUI_HEIGHT_OFFSET}) / 2)
|
||||
#enddef
|
||||
|
||||
#define BEST_WIDTH
|
||||
(if(gamemap_width > {TEXT_WIDTH_SATURATION}, gamemap_width - {MAX_TEXT_WIDTH}, (gamemap_width / {__GUI_SIZE_FACTOR})))
|
||||
#enddef
|
||||
|
||||
#define __GUI_BEST_SIZE
|
||||
(if({BEST_WIDTH} > {__GUI_MAX_HEIGHT}, {__GUI_MAX_HEIGHT}, {BEST_WIDTH}))
|
||||
#enddef
|
||||
|
||||
#define ___GUI_IMAGE_WIDTH
|
||||
if({__GUI_BEST_SIZE} < 250, 250,
|
||||
if({__GUI_BEST_SIZE} > 500, 500, {__GUI_BEST_SIZE})
|
||||
)
|
||||
#enddef
|
||||
|
||||
# This is the version with debug info
|
||||
#define __GUI_IMAGE_WIDTH
|
||||
([[
|
||||
debug_print('screen_width ', screen_width),
|
||||
debug_print('screen_height ', screen_height),
|
||||
debug_print('gamemap_width ', gamemap_width),
|
||||
debug_print('gamemap_height ', gamemap_height),
|
||||
debug_print('__GUI_MAX_HEIGHT ', {__GUI_MAX_HEIGHT}),
|
||||
debug_print('BEST_WIDTH ', {BEST_WIDTH}),
|
||||
debug_print('__GUI_BEST_SIZE ', {__GUI_BEST_SIZE})
|
||||
],
|
||||
{___GUI_IMAGE_WIDTH}
|
||||
][1]
|
||||
)
|
||||
#enddef
|
||||
|
||||
#undef __GUI_IMAGE_WIDTH
|
||||
# This is the version without debug info
|
||||
#define __GUI_IMAGE_WIDTH
|
||||
({___GUI_IMAGE_WIDTH})#enddef
|
||||
|
||||
|
||||
# This is the macro for the image width which is can be used as string
|
||||
# parameter.
|
||||
#define _GUI_IMAGE_WIDTH
|
||||
"{__GUI_IMAGE_WIDTH}"#enddef
|
||||
|
||||
# the value the image needs to be scaled by, this version can be used as string
|
||||
# parameter.
|
||||
#define _GUI_IMAGE_SCALE_FACTOR
|
||||
(
|
||||
{__GUI_IMAGE_WIDTH} / 500
|
||||
)#enddef
|
||||
|
||||
|
||||
# The formula to set the widthe of the real image width depending on the
|
||||
# image real size
|
||||
#define __GUI_IMAGE_DISPLAYED_WIDTH
|
||||
(
|
||||
if((image_original_width < 300) and (image_original_height < 300),
|
||||
image_original_width,
|
||||
((image_original_width * {__GUI_IMAGE_WIDTH}) / 500))
|
||||
)#enddef
|
||||
|
||||
# The formula to set the heighte of the real image height depending on the
|
||||
# image real size
|
||||
#define __GUI_IMAGE_DISPLAYED_HEIGHT
|
||||
(
|
||||
if((image_original_width < 300) and (image_original_height < 300),
|
||||
image_original_height,
|
||||
((image_original_height * {__GUI_IMAGE_WIDTH}) / 500))
|
||||
)#enddef
|
||||
|
||||
# The X location of the image to display, only tested on the left side.
|
||||
#define __GUI_IMAGE_DISPLAYED_X X
|
||||
(
|
||||
if(image_original_width > 100,
|
||||
{X},
|
||||
({__GUI_IMAGE_WIDTH} - image_width) / 2)
|
||||
|
||||
)#enddef
|
||||
|
||||
# The Y location of the image to display, only tested on the left side.
|
||||
# Note since we don't know the exact height of the text we can't centre
|
||||
# the image. Instead we use the centre of the reserved image space.
|
||||
#
|
||||
# TODO the Y can't be determined properly since we don't know the height
|
||||
# of the panel. Disabled the centring for now.
|
||||
#
|
||||
#define __GUI_IMAGE_DISPLAYED_Y
|
||||
(
|
||||
if(image_original_height > 0,
|
||||
(height - image_height),
|
||||
height - (({__GUI_IMAGE_WIDTH} - image_height) / 2))
|
||||
|
||||
)#enddef
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### Definition of an image.
|
||||
###
|
||||
{gui/default/macros/_initial.cfg}
|
||||
[image_definition]
|
||||
id = "scaled"
|
||||
description = "an image, scaled depending on resolution."
|
||||
|
||||
[resolution]
|
||||
|
||||
vertical_placement=bottom
|
||||
#min_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
#min_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
|
||||
#w=250
|
||||
#h=250
|
||||
|
||||
# default_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
# default_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
|
||||
# max_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
# max_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
|
||||
[state_enabled]
|
||||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
w="{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
h="{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
vertical_placement=bottom
|
||||
#w=250
|
||||
#h=250
|
||||
#x=(500 - image_original_width)
|
||||
#50
|
||||
y=(500 - image_original_height)
|
||||
name = "(text)"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/state_enabled]
|
||||
|
||||
[/resolution]
|
||||
|
||||
[/image_definition]
|
||||
|
|
@ -1,278 +0,0 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### The recruit dialog.
|
||||
###
|
||||
{gui/default/macros/_initial.cfg}
|
||||
#define _GUI_RECRUIT_WINDOW SIDE
|
||||
[window]
|
||||
id=recruit_message_{SIDE}
|
||||
description="Recruit Dialog Window"
|
||||
[resolution]
|
||||
|
||||
[linked_group]
|
||||
id = "cost"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
click_dismiss=false
|
||||
|
||||
definition= "default"
|
||||
|
||||
automatic_placement= "false"
|
||||
#vertical_placement= "center"
|
||||
#horizontal_placement= "right"
|
||||
maximum_width=800
|
||||
maximum_height=600
|
||||
width=800
|
||||
height=600
|
||||
#x=50
|
||||
x=(gamemap_width - ( 800 - 5) )
|
||||
y=200
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
vertical_alignment=top
|
||||
[label]
|
||||
id = "title"
|
||||
definition = "title"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment=left
|
||||
vertical_alignment=bottom
|
||||
[grid]
|
||||
[row]
|
||||
|
||||
|
||||
[column]
|
||||
vertical_alignment=bottom
|
||||
#min_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
#min_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
|
||||
#w=250
|
||||
#h=250
|
||||
|
||||
#default_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
#default_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
vertical_placement=bottom
|
||||
#max_width = 250 #"{__GUI_IMAGE_DISPLAYED_WIDTH}"
|
||||
#max_height = 250 #"{__GUI_IMAGE_DISPLAYED_HEIGHT}"
|
||||
#{GUI_FORCE_WIDGET_MINIMUM_SIZE
|
||||
#{__GUI_IMAGE_DISPLAYED_WIDTH} {__GUI_IMAGE_DISPLAYED_HEIGHT} (
|
||||
{GUI_FORCE_WIDGET_MINIMUM_SIZE 500 500 (
|
||||
[image]
|
||||
vertical_alignment=bottom
|
||||
definition=scaled
|
||||
id=unit_portrait
|
||||
[/image])}
|
||||
[/column]
|
||||
|
||||
|
||||
[column]
|
||||
horizontal_alignment=right
|
||||
vertical_alignment=top
|
||||
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
#horizontal_grow = "true"
|
||||
vertical_alignment=top
|
||||
horizontal_alignment=left
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[scroll_label]
|
||||
id = "message"
|
||||
#definition = "wml_message"
|
||||
[/scroll_label]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
vertical_grow=false
|
||||
#horizontal_grow=false
|
||||
vertical_alignment=top
|
||||
horizontal_alignment=right
|
||||
[listbox]
|
||||
id = "recruit_list"
|
||||
[list_definition]
|
||||
[row]
|
||||
[column]
|
||||
|
||||
#horizontal_grow=true
|
||||
horizontal_alignment=right
|
||||
[toggle_panel]
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
[image]
|
||||
id="icon"
|
||||
[/image]
|
||||
[/column]
|
||||
[column]
|
||||
{GUI_FORCE_WIDGET_MINIMUM_SIZE 175 0 (
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment="left"
|
||||
[label]
|
||||
id="type"
|
||||
linked_group="cost"
|
||||
definition="default"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
#grow_factor=1
|
||||
#horizontal_grow="true"
|
||||
|
||||
border="all"
|
||||
border_size=5
|
||||
|
||||
[label]
|
||||
id= "cost"
|
||||
definition="default"
|
||||
linked_group="cost"
|
||||
[/label]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
) }
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/toggle_panel]
|
||||
[/column]
|
||||
[/row]
|
||||
[/list_definition]
|
||||
[/listbox]
|
||||
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
#button row
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment=left
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
horizontal_alignment=left
|
||||
border="all"
|
||||
border_size=5
|
||||
#horizontal_alignment=left
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border="all"
|
||||
border_size=5
|
||||
horizontal_alignment=left
|
||||
[button]
|
||||
id=profile
|
||||
label= _ "Profile"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
border="all"
|
||||
border_size=5
|
||||
horizontal_alignment=left
|
||||
[button]
|
||||
id=help
|
||||
label= _ "Help"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[column]
|
||||
[spacer]
|
||||
width=250
|
||||
#height=0
|
||||
|
||||
|
||||
[/spacer]
|
||||
[/column]
|
||||
[column]
|
||||
border="all"
|
||||
border_size=5
|
||||
#horizontal_alignment=left
|
||||
horizontal_alignment=right
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
border="all"
|
||||
border_size=5
|
||||
horizontal_alignment=left
|
||||
|
||||
[button]
|
||||
id=ok
|
||||
label= _ "Okay"
|
||||
[/button]
|
||||
[/column]
|
||||
[column]
|
||||
|
||||
border="all"
|
||||
border_size=5
|
||||
horizontal_alignment=left
|
||||
[button]
|
||||
id=cancel
|
||||
label= _ "Cancel"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
#/button row
|
||||
[/grid]
|
||||
[/resolution]
|
||||
[/window]
|
||||
#enddef
|
||||
|
||||
{_GUI_RECRUIT_WINDOW left}
|
||||
{_GUI_RECRUIT_WINDOW right}
|
||||
|
||||
|
||||
|
||||
# local dialog = {
|
||||
# T.grid { T.row {
|
||||
# T.column { T.grid {
|
||||
# T.row { T.column { horizontal_grow = true, T.listbox { id = "the_list",
|
||||
# T.list_definition { T.row { T.column { horizontal_grow = true,
|
||||
# T.toggle_panel { T.grid { T.row {
|
||||
# T.column { horizontal_alignment = "left", T.label { id = "the_label" } },
|
||||
# T.column { T.image { id = "the_icon" } }
|
||||
# } } }
|
||||
# } } }
|
||||
# } } },
|
||||
# T.row { T.column { T.grid { T.row {
|
||||
# T.column { T.button { id = "ok", label = _"OK" } },
|
||||
# T.column { T.button { id = "cancel", label = _"Cancel" } }
|
||||
# } } } },
|
||||
# T.row { T.column {
|
||||
# T.toggle_button { id = "flip", label = "Flip" }
|
||||
# } }
|
||||
# } },
|
||||
# T.column { T.image { id = "the_image" } }
|
||||
# } }
|
||||
# }
|
|
@ -139,9 +139,8 @@
|
|||
|
||||
)#enddef
|
||||
|
||||
#define IMAGE_MESSAGE ID
|
||||
[window_definition]
|
||||
id = "{ID}_left"
|
||||
id = "wml_message_left"
|
||||
description = "bar"
|
||||
|
||||
[resolution]
|
||||
|
@ -176,7 +175,7 @@
|
|||
[/window_definition]
|
||||
|
||||
[window_definition]
|
||||
id = "{ID}_right"
|
||||
id = "wml_message_right"
|
||||
description = "bar"
|
||||
|
||||
[resolution]
|
||||
|
@ -209,68 +208,10 @@
|
|||
[/resolution]
|
||||
|
||||
[/window_definition]
|
||||
#enddef
|
||||
|
||||
{IMAGE_MESSAGE image_message}
|
||||
{IMAGE_MESSAGE input_message}
|
||||
{IMAGE_MESSAGE option_message}
|
||||
|
||||
|
||||
#define _GUI_INPUT
|
||||
[row]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "input_caption"
|
||||
definition = "default"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[text_box]
|
||||
id = "input"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
[/row]
|
||||
#enddef
|
||||
|
||||
#define _GUI_OPTION_LIST
|
||||
|
||||
[row]
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
|
||||
|
||||
#define _GUI_INPUT_LIST
|
||||
[listbox]
|
||||
id = "option_list"
|
||||
id = "input_list"
|
||||
definition = "wml_message"
|
||||
[list_definition]
|
||||
|
||||
|
@ -346,276 +287,17 @@
|
|||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
#
|
||||
# #{_GUI_RECRUIT_LIST}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
#enddef
|
||||
|
||||
#define _GUI_UNIT_LIST
|
||||
[listbox]
|
||||
id = "unit_list"
|
||||
definition = "unit_message"
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
definition = "unit_message"
|
||||
|
||||
return_value_id = "ok"
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "type"
|
||||
definition = "default"
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "name"
|
||||
definition = "default"
|
||||
linked_group = "name"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "level"
|
||||
definition = "default"
|
||||
linked_group = "level"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "xp"
|
||||
definition = "default"
|
||||
linked_group = "xp"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "traits"
|
||||
definition = "default"
|
||||
linked_group = "traits"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "label"
|
||||
definition = "default"
|
||||
linked_group = "label"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "description"
|
||||
definition = "default"
|
||||
linked_group = "description"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
#enddef
|
||||
|
||||
#define _GUI_RECRUIT_LIST
|
||||
[listbox]
|
||||
id = "recruit_list"
|
||||
definition = "recruit_message"
|
||||
[list_definition]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
definition = "recruit_message"
|
||||
|
||||
return_value_id = "ok"
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "type"
|
||||
definition = "default"
|
||||
linked_group = "type"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
horizontal_alignment = "left"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[image]
|
||||
id = "gold"
|
||||
definition = "default"
|
||||
#linked_group = "icon"
|
||||
[/image]
|
||||
|
||||
[/column]
|
||||
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "cost"
|
||||
definition = "default"
|
||||
linked_group = "cost"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/toggle_panel]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/list_definition]
|
||||
|
||||
[/listbox]
|
||||
#enddef
|
||||
|
||||
|
||||
#define IMAGE_MESSAGE_WINDOW ID GUI_ELEMENT
|
||||
[window]
|
||||
id = "{ID}_left"
|
||||
id = "wml_message_left"
|
||||
description = "Dialog showing a unit portrait on the left side"
|
||||
|
||||
[resolution]
|
||||
window_width = 0
|
||||
window_height = 0
|
||||
|
||||
definition = "{ID}_left"
|
||||
definition = "wml_message_left"
|
||||
|
||||
automatic_placement = "false"
|
||||
|
||||
|
@ -641,50 +323,6 @@
|
|||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "traits"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "xp"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "type"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "cost"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "level"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "name"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "usage"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip_large"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "tooltip_large"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
@ -752,13 +390,56 @@
|
|||
|
||||
[scroll_label]
|
||||
id = "message"
|
||||
definition = "{ID}"
|
||||
definition = "wml_message"
|
||||
[/scroll_label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "input_caption"
|
||||
definition = "default"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[text_box]
|
||||
id = "input"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
@ -766,99 +447,31 @@
|
|||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
{_GUI_RECRUIT_LIST}
|
||||
{_GUI_INPUT_LIST}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
{GUI_ELEMENT}
|
||||
#[row]
|
||||
|
||||
# [column]
|
||||
# border = "all"
|
||||
## border_size = 5
|
||||
# horizontal_grow = "true"
|
||||
|
||||
#
|
||||
# #{_GUI_RECRUIT_LIST}
|
||||
|
||||
# [/column]
|
||||
|
||||
#[/row]
|
||||
|
||||
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_alignment = "center"
|
||||
#
|
||||
# [button]
|
||||
# # This button will be shown or hidden depending on the
|
||||
# # whether or not a sellection may be avoided
|
||||
# id = "help"
|
||||
# definition = "transparent"
|
||||
# label = _ "Help"
|
||||
# [/button]
|
||||
# [/column]
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_alignment = "center"
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
|
||||
# [button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a sellection may be avoided
|
||||
# id = "profile"
|
||||
# definition = "transparent"
|
||||
#
|
||||
# label = _ "Profile"
|
||||
# [/button]
|
||||
# [/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "center"
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "ok"
|
||||
definition = "transparent"
|
||||
|
||||
[button]
|
||||
# This button will be shown or hidden depending on the
|
||||
# whether or not a scrollbar is needed to show the
|
||||
# text.
|
||||
id = "ok"
|
||||
definition = "transparent"
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
label = _ "OK"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_alignment = "center"
|
||||
#
|
||||
# [button]
|
||||
# # This button will be shown or hidden depending on the
|
||||
# # whether or not a scrollbar is needed to show the
|
||||
# # text.
|
||||
# id = "cancel"
|
||||
# definition = "transparent"
|
||||
#
|
||||
# label = _ "Cancel"
|
||||
# [/button]
|
||||
# [/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
@ -901,14 +514,14 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
|
|||
[/window]
|
||||
|
||||
[window]
|
||||
id = "{ID}_right"
|
||||
id = "wml_message_right"
|
||||
description = "Dialog showing a unit portrait on the right side"
|
||||
|
||||
[resolution]
|
||||
window_width = 0
|
||||
window_height = 0
|
||||
|
||||
definition = "{ID}_right"
|
||||
definition = "wml_message_right"
|
||||
|
||||
automatic_placement = "false"
|
||||
|
||||
|
@ -934,14 +547,6 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
|
|||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip_large"
|
||||
[/tooltip]
|
||||
|
||||
[helptip]
|
||||
id = "tooltip_large"
|
||||
[/helptip]
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
@ -1013,35 +618,61 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
|
|||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
{GUI_ELEMENT}
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
# [row]
|
||||
#
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_grow = "true"
|
||||
#
|
||||
# {_GUI_OPTION_LIST}
|
||||
#
|
||||
# [/column]
|
||||
#
|
||||
# [/row]
|
||||
|
||||
# [row]
|
||||
#
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_grow = "true"
|
||||
#
|
||||
# {_GUI_UNIT_LIST}
|
||||
#
|
||||
# [/column]
|
||||
#
|
||||
# [/row]
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "input_caption"
|
||||
definition = "default"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[text_box]
|
||||
id = "input"
|
||||
definition = "default"
|
||||
[/text_box]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_grow = "true"
|
||||
|
||||
{_GUI_INPUT_LIST}
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
|
@ -1061,27 +692,8 @@ if(gamemap_width - ({__GUI_IMAGE_WIDTH}) > {MAX_TEXT_WIDTH}
|
|||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
# [row]
|
||||
# [column]
|
||||
# border = "all"
|
||||
# border_size = 5
|
||||
# horizontal_alignment = "center"
|
||||
#
|
||||
# [button]
|
||||
# # This button will be shown or hidden depending on the
|
||||
# # whether or not a scrollbar is needed to show the
|
||||
# # text.
|
||||
# id = "canel"
|
||||
# definition = "transparent"
|
||||
#
|
||||
# label = _ "Cancel"
|
||||
# [/button]
|
||||
#
|
||||
# [/column]
|
||||
#
|
||||
#
|
||||
# [/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
|
@ -1134,15 +746,8 @@ if(gamemap_width - (10 + ({__GUI_IMAGE_WIDTH})) > {MAX_TEXT_WIDTH}
|
|||
[/resolution]
|
||||
|
||||
[/window]
|
||||
#enddef
|
||||
|
||||
{IMAGE_MESSAGE_WINDOW image_message ()}
|
||||
{IMAGE_MESSAGE_WINDOW input_message ({_GUI_INPUT}) }
|
||||
{IMAGE_MESSAGE_WINDOW option_message ({_GUI_OPTION_LIST}) }
|
||||
|
||||
#undef _GUI_INPUT
|
||||
#undef _GUI_OPTION_LIST
|
||||
#undef _GUI_UNIT_LIST
|
||||
#undef _GUI_INPUT_LIST
|
||||
|
||||
#undef __GUI_IMAGE_DISPLAYED_Y
|
||||
#undef __GUI_IMAGE_DISPLAYED_X
|
|
@ -416,14 +416,6 @@
|
|||
<Unit filename="..\..\src\gui\dialogs\gamestate_inspector.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\gamestate_inspector.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\helper.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\image_message.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\image_message.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\input_message.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\input_message.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\option_message.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\option_message.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\recruit_message.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\image_message\recruit_message.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\language_selection.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\language_selection.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\lobby\lobby_data.cpp" />
|
||||
|
@ -460,6 +452,8 @@
|
|||
<Unit filename="..\..\src\gui\dialogs\unit_attack.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\unit_create.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\unit_create.hpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\wml_message.cpp" />
|
||||
<Unit filename="..\..\src\gui\dialogs\wml_message.hpp" />
|
||||
<Unit filename="..\..\src\gui\widgets\button.cpp" />
|
||||
<Unit filename="..\..\src\gui\widgets\button.hpp" />
|
||||
<Unit filename="..\..\src\gui\widgets\clickable.hpp" />
|
||||
|
|
|
@ -2706,6 +2706,34 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\wml_message.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug (fast)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Lobby"
|
||||
>
|
||||
|
@ -2785,54 +2813,6 @@
|
|||
<Filter
|
||||
Name="Image_Message"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\image_message.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\Image_Message\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\input_message.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\Image_Message\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\option_message.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\Image_Message\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\recruit_message.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Gui\Dialogs\Image_Message\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -7525,6 +7505,10 @@
|
|||
RelativePath="..\..\src\gui\dialogs\unit_attack.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\wml_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="Lobby"
|
||||
>
|
||||
|
@ -7548,22 +7532,6 @@
|
|||
<Filter
|
||||
Name="Image_Message"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\image_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\input_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\option_message.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\gui\dialogs\image_message\recruit_message.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
|
|
@ -175,7 +175,6 @@ if(MSVC)
|
|||
SOURCE_GROUP("src gui auxiliary window_builder" REGULAR_EXPRESSION "gui/auxiliary/window_builder/.*")
|
||||
SOURCE_GROUP("src gui dialogs" REGULAR_EXPRESSION "gui/dialogs/.*")
|
||||
SOURCE_GROUP("src gui dialogs lobby" REGULAR_EXPRESSION "gui/dialogs/lobby/.*")
|
||||
SOURCE_GROUP("src gui dialogs lobby" REGULAR_EXPRESSION "gui/dialogs/image_message/.*")
|
||||
SOURCE_GROUP("src lua" REGULAR_EXPRESSION "lua/.*")
|
||||
SOURCE_GROUP("src widgets" REGULAR_EXPRESSION "widgets/.*")
|
||||
SOURCE_GROUP("src gui widgets" REGULAR_EXPRESSION "gui/widgets/.*")
|
||||
|
@ -453,10 +452,7 @@ set(wesnoth-main_SRC
|
|||
gui/dialogs/transient_message.cpp
|
||||
gui/dialogs/unit_attack.cpp
|
||||
gui/dialogs/unit_create.cpp
|
||||
gui/dialogs/image_message/image_message.cpp
|
||||
gui/dialogs/image_message/input_message.cpp
|
||||
gui/dialogs/image_message/option_message.cpp
|
||||
gui/dialogs/image_message/recruit_message.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/button.cpp
|
||||
gui/widgets/container.cpp
|
||||
gui/widgets/control.cpp
|
||||
|
|
|
@ -300,10 +300,6 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/game_load.cpp
|
||||
gui/dialogs/game_save.cpp
|
||||
gui/dialogs/gamestate_inspector.cpp
|
||||
gui/dialogs/image_message/image_message.cpp
|
||||
gui/dialogs/image_message/input_message.cpp
|
||||
gui/dialogs/image_message/option_message.cpp
|
||||
gui/dialogs/image_message/recruit_message.cpp
|
||||
gui/dialogs/language_selection.cpp
|
||||
gui/dialogs/lobby/lobby_data.cpp
|
||||
gui/dialogs/lobby/lobby_info.cpp
|
||||
|
@ -322,6 +318,7 @@ wesnoth_sources = Split("""
|
|||
gui/dialogs/transient_message.cpp
|
||||
gui/dialogs/unit_attack.cpp
|
||||
gui/dialogs/unit_create.cpp
|
||||
gui/dialogs/wml_message.cpp
|
||||
gui/widgets/button.cpp
|
||||
gui/widgets/container.cpp
|
||||
gui/widgets/control.cpp
|
||||
|
|
|
@ -30,10 +30,7 @@
|
|||
#include "gettext.hpp"
|
||||
#include "gui/dialogs/gamestate_inspector.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
// include "gui/dialogs/wml_message.hpp"
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
#include "gui/dialogs/image_message/input_message.hpp"
|
||||
#include "gui/dialogs/image_message/option_message.hpp"
|
||||
#include "gui/dialogs/wml_message.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "help.hpp"
|
||||
#include "log.hpp"
|
||||
|
@ -2456,14 +2453,12 @@ struct message_user_choice : mp_sync::user_choice
|
|||
unit_map::iterator speaker;
|
||||
vconfig text_input_element;
|
||||
bool has_text_input;
|
||||
vconfig unit_input_element;
|
||||
bool has_unit_input;
|
||||
const std::vector<std::string> &options;
|
||||
|
||||
message_user_choice(const vconfig &c, const unit_map::iterator &s,
|
||||
const vconfig &t, bool ht, const vconfig &u, bool hu, const std::vector<std::string> &o)
|
||||
const vconfig &t, bool ht, const std::vector<std::string> &o)
|
||||
: cfg(c), speaker(s), text_input_element(t)
|
||||
, has_text_input(ht), unit_input_element(u), has_unit_input(hu), options(o)
|
||||
, has_text_input(ht), options(o)
|
||||
{}
|
||||
|
||||
virtual config query_user() const
|
||||
|
@ -2477,63 +2472,22 @@ struct message_user_choice : mp_sync::user_choice
|
|||
image.erase(right_offset);
|
||||
}
|
||||
|
||||
std::string unit_input_content;
|
||||
std::string unit_input_types = unit_input_element["types"];
|
||||
|
||||
std::vector<unit> unit_list;
|
||||
|
||||
if (has_unit_input) {
|
||||
vconfig filter = unit_input_element.child("filter");
|
||||
if(filter.null()) {
|
||||
//TODO handle the missing filter
|
||||
lg::wml_error << "[unit_input] missing required [filter] tag\n";
|
||||
}
|
||||
|
||||
for(unit_map::iterator i = resources::units->begin(); i != resources::units->end(); i++) {
|
||||
if(game_events::unit_matches_filter(*i,filter) == true) {
|
||||
unit_list.push_back(*i);
|
||||
}
|
||||
}
|
||||
unit_input_content = unit_list.front().id();
|
||||
//TODO call the unit_message dialog
|
||||
}
|
||||
|
||||
int counter = 0;
|
||||
if (has_text_input) counter++;
|
||||
if (has_unit_input) counter++;
|
||||
if (!options.empty()) counter++;
|
||||
|
||||
if (counter > 1) {
|
||||
lg::wml_error << "option, input and unit_input conflict with each other!";
|
||||
}
|
||||
|
||||
int dlg_result = 0;
|
||||
if (!has_text_input && !has_unit_input && options.empty()) {
|
||||
dlg_result = gui2::show_image_message(left_side, resources::screen->video(),
|
||||
caption, cfg["message"], image, false);
|
||||
}
|
||||
|
||||
// Parse input text, if not available all fields are empty
|
||||
std::string text_input_label = text_input_element["label"];
|
||||
std::string text_input_content = text_input_element["text"];
|
||||
if (has_text_input) {
|
||||
// Parse input text, if not available all fields are empty
|
||||
std::string text_input_label = text_input_element["label"];
|
||||
unsigned input_max_size = text_input_element["max_length"].to_int(256);
|
||||
if (input_max_size > 1024 || input_max_size < 1) {
|
||||
lg::wml_error << "invalid maximum size for input "
|
||||
<< input_max_size << '\n';
|
||||
input_max_size = 256;
|
||||
}
|
||||
dlg_result = gui2::show_input_message(left_side, resources::screen->video(),
|
||||
caption, cfg["message"], image, false,
|
||||
text_input_label, &text_input_content, input_max_size);
|
||||
unsigned input_max_size = text_input_element["max_length"].to_int(256);
|
||||
if (input_max_size > 1024 || input_max_size < 1) {
|
||||
lg::wml_error << "invalid maximum size for input "
|
||||
<< input_max_size << '\n';
|
||||
input_max_size = 256;
|
||||
}
|
||||
|
||||
int option_chosen = 0;
|
||||
if (!options.empty()) {
|
||||
dlg_result = gui2::show_option_message(left_side, resources::screen->video(),
|
||||
caption, cfg["message"], image, false,
|
||||
options, &option_chosen);
|
||||
}
|
||||
int option_chosen;
|
||||
int dlg_result = gui2::show_wml_message(left_side,
|
||||
resources::screen->video(), caption, cfg["message"],
|
||||
image, false, has_text_input, text_input_label,
|
||||
&text_input_content, input_max_size, options,
|
||||
&option_chosen);
|
||||
|
||||
/* Since gui2::show_wml_message needs to do undrawing the
|
||||
chatlines can get garbled and look dirty on screen. Force a
|
||||
|
@ -2549,7 +2503,6 @@ struct message_user_choice : mp_sync::user_choice
|
|||
config cfg;
|
||||
if (!options.empty()) cfg["value"] = option_chosen;
|
||||
if (has_text_input) cfg["text"] = text_input_content;
|
||||
if (has_unit_input) cfg["unit"] = unit_input_content;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
@ -2564,12 +2517,11 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
|
|||
{
|
||||
// Check if there is any input to be made, if not the message may be skipped
|
||||
const vconfig::child_list menu_items = cfg.get_children("option");
|
||||
const vconfig::child_list unit_input_elements = cfg.get_children("unit_input");
|
||||
|
||||
const vconfig::child_list text_input_elements = cfg.get_children("text_input");
|
||||
const bool has_text_input = (text_input_elements.size() == 1);
|
||||
const bool has_unit_input = (unit_input_elements.size() == 1);
|
||||
|
||||
const bool has_input = (has_text_input || has_unit_input || !menu_items.empty() );
|
||||
bool has_input= (has_text_input || !menu_items.empty() );
|
||||
|
||||
// skip messages during quick replay
|
||||
play_controller *controller = resources::controller;
|
||||
|
@ -2639,8 +2591,7 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
|
|||
}
|
||||
}
|
||||
|
||||
//TODO I think that redeclaration of has_input is obsolete and dangerous
|
||||
//has_input = !options.empty() || has_text_input;
|
||||
has_input = !options.empty() || has_text_input;
|
||||
if (!has_input && get_replay_source().is_skipping()) {
|
||||
// No input to get and the user is not interested either.
|
||||
return;
|
||||
|
@ -2654,23 +2605,15 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
|
|||
lg::wml_error << "too many text_input tags, only one accepted\n";
|
||||
}
|
||||
|
||||
if(unit_input_elements.size()>1) {
|
||||
lg::wml_error << "too many unit_input tags, only one accepted\n";
|
||||
}
|
||||
|
||||
const vconfig text_input_element = has_text_input ?
|
||||
text_input_elements.front() : vconfig::empty_vconfig();
|
||||
|
||||
const vconfig unit_input_element = has_unit_input ?
|
||||
unit_input_elements.front() : vconfig::empty_vconfig();
|
||||
|
||||
int option_chosen = 0;
|
||||
std::string unit_input_result;
|
||||
std::string text_input_result;
|
||||
|
||||
DBG_DP << "showing dialog...\n";
|
||||
|
||||
message_user_choice msg(cfg, speaker, text_input_element, has_text_input, unit_input_element, has_unit_input,
|
||||
message_user_choice msg(cfg, speaker, text_input_element, has_text_input,
|
||||
options);
|
||||
if (!has_input)
|
||||
{
|
||||
|
@ -2682,7 +2625,6 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
|
|||
{
|
||||
config choice = mp_sync::get_user_choice("input", msg, 0, true);
|
||||
option_chosen = choice["value"];
|
||||
unit_input_result = choice["unit"].str();
|
||||
text_input_result = choice["text"].str();
|
||||
}
|
||||
|
||||
|
@ -2707,12 +2649,6 @@ WML_HANDLER_FUNCTION(message, event_info, cfg)
|
|||
variable_name="input";
|
||||
resources::state_of_game->set_variable(variable_name, text_input_result);
|
||||
}
|
||||
if(has_unit_input) {
|
||||
std::string variable_name=unit_input_element["variable"];
|
||||
if(variable_name.empty())
|
||||
variable_name="unit_input";
|
||||
resources::state_of_game->set_variable(variable_name, unit_input_result);
|
||||
}
|
||||
}
|
||||
|
||||
// Adding/removing new time_areas dynamically with Standard Location Filters.
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
//#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
//#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
//#include "gui/widgets/list.hpp"
|
||||
//#else
|
||||
//#include "gui/widgets/listbox.hpp"
|
||||
//#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
//#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void timage_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
window.canvas(1).set_variable("portrait_image", variant(portrait_));
|
||||
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
|
||||
|
||||
// Set the markup
|
||||
tlabel& title = find_widget<tlabel>(&window, "title", false);
|
||||
title.set_label(title_);
|
||||
title.set_use_markup(true);
|
||||
title.set_can_wrap(true);
|
||||
|
||||
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
|
||||
message.set_label(message_);
|
||||
message.set_use_markup(true);
|
||||
// The message label might not always be a scroll_label but the capturing
|
||||
// shouldn't hurt.
|
||||
window.keyboard_capture(&message);
|
||||
|
||||
window.set_click_dismiss(true);
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(image_message_left)
|
||||
|
||||
REGISTER_DIALOG(image_message_right)
|
||||
|
||||
int show_image_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror)
|
||||
{
|
||||
std::auto_ptr<timage_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new timage_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new timage_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_IMAGE_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_IMAGE_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* Base class for all messages with a transparent image or portrait displayed.
|
||||
*
|
||||
* We have a separate sub class for left and right images.
|
||||
*/
|
||||
class timage_message_
|
||||
: public tdialog
|
||||
{
|
||||
public:
|
||||
timage_message_(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: title_(title)
|
||||
, image_("")
|
||||
, message_(message)
|
||||
, portrait_(portrait)
|
||||
, mirror_(mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** The title for the dialog. */
|
||||
std::string title_;
|
||||
|
||||
/**
|
||||
* The image which is shown in the dialog.
|
||||
*
|
||||
* This image can be an icon or portrait or any other image.
|
||||
*/
|
||||
std::string image_;
|
||||
|
||||
/** The message to show to the user. */
|
||||
std::string message_;
|
||||
/** Filename of the portrait. */
|
||||
std::string portrait_;
|
||||
|
||||
/** Mirror the portrait? */
|
||||
bool mirror_;
|
||||
|
||||
protected:
|
||||
/** Inherited from tdialog. */
|
||||
virtual void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the left side. */
|
||||
class timage_message_left : public timage_message_
|
||||
{
|
||||
public:
|
||||
timage_message_left(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: timage_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the right side. */
|
||||
class timage_message_right : public timage_message_
|
||||
{
|
||||
public:
|
||||
timage_message_right(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: timage_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to show a portrait.
|
||||
*
|
||||
* @param left_side If true the portrait is shown on the left,
|
||||
* on the right side otherwise.
|
||||
* @param video The display variable.
|
||||
* @param title The title of the dialog.
|
||||
* @param message The message to show.
|
||||
* @param portrait Filename of the portrait.
|
||||
* @param mirror Does the portrait need to be mirrored?
|
||||
*/
|
||||
|
||||
int show_image_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror);
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/image_message/input_message.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
//#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void tinput_message_::pre_show(CVideo& video, twindow& window)
|
||||
{
|
||||
timage_message_::pre_show(video, window);
|
||||
// Find the input box related fields.
|
||||
tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
|
||||
ttext_box& input = find_widget<ttext_box>(&window, "input", true);
|
||||
|
||||
caption.set_label(input_caption_);
|
||||
caption.set_use_markup(true);
|
||||
input.set_value(*input_text_);
|
||||
input.set_maximum_length(input_maximum_lenght_);
|
||||
window.keyboard_capture(&input);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
// click_dismiss has been disabled due to the input.
|
||||
}
|
||||
|
||||
void tinput_message_::post_show(twindow& window)
|
||||
{
|
||||
*input_text_ =
|
||||
find_widget<ttext_box>(&window, "input", true).get_value();
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(input_message_left)
|
||||
|
||||
REGISTER_DIALOG(input_message_right)
|
||||
|
||||
int show_input_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const std::string& input_caption
|
||||
, std::string* input_text
|
||||
, const unsigned maximum_length)
|
||||
{
|
||||
std::auto_ptr<tinput_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new tinput_message_left(
|
||||
title, message, portrait, mirror, input_caption, input_text, maximum_length));
|
||||
} else {
|
||||
dlg.reset(new tinput_message_right(
|
||||
title, message, portrait, mirror, input_caption, input_text, maximum_length));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_INPUT_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_INPUT_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* image messages offering a text input dialog.
|
||||
*
|
||||
* We have a separate sub class for left and right images.
|
||||
*/
|
||||
class tinput_message_
|
||||
: public timage_message_
|
||||
{
|
||||
public:
|
||||
tinput_message_(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror,
|
||||
const std::string& caption, std::string* text, const unsigned maximum_length)
|
||||
: timage_message_(title, message, portrait, mirror)
|
||||
, input_caption_(caption)
|
||||
, input_text_(text)
|
||||
, input_maximum_lenght_(maximum_length)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** The caption to show for the input text. */
|
||||
std::string input_caption_;
|
||||
|
||||
/** The text input. */
|
||||
std::string* input_text_;
|
||||
|
||||
/** The maximum length of the input text. */
|
||||
unsigned input_maximum_lenght_;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the left side. */
|
||||
class tinput_message_left : public tinput_message_
|
||||
{
|
||||
public:
|
||||
tinput_message_left(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror,
|
||||
const std::string& caption, std::string* text, const unsigned maximum_length)
|
||||
: tinput_message_(title, message, portrait, mirror, caption, text, maximum_length)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the right side. */
|
||||
class tinput_message_right : public tinput_message_
|
||||
{
|
||||
public:
|
||||
tinput_message_right(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror,
|
||||
const std::string& caption, std::string* text, const unsigned maximum_length)
|
||||
: tinput_message_(title, message, portrait, mirror, caption, text, maximum_length)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to show a portrait.
|
||||
*
|
||||
* @param left_side If true the portrait is shown on the left,
|
||||
* on the right side otherwise.
|
||||
* @param video The display variable.
|
||||
* @param title The title of the dialog.
|
||||
* @param message The message to show.
|
||||
* @param portrait Filename of the portrait.
|
||||
* @param mirror Does the portrait need to be mirrored?
|
||||
*
|
||||
* @param input_caption The caption for the optional input text
|
||||
* box. If this value != "" there is an input
|
||||
* and the input text parameter is mandatory.
|
||||
* @param input_text Pointer to the initial text value will be
|
||||
* set to the result.
|
||||
* @param maximum_length The maximum length of the text.
|
||||
*/
|
||||
int show_input_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const std::string& input_caption
|
||||
, std::string* input_text
|
||||
, const unsigned maximum_length);
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -1,129 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/image_message/option_message.hpp"
|
||||
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
void toption_message_::set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option)
|
||||
{
|
||||
assert(!option_list.empty());
|
||||
assert(chosen_option);
|
||||
|
||||
option_list_ = option_list;
|
||||
chosen_option_ = chosen_option;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void toption_message_::pre_show(CVideo& video, twindow& window)
|
||||
{
|
||||
timage_message_::pre_show(video, window);
|
||||
|
||||
// Find the option list related fields.
|
||||
tlistbox& options = find_widget<tlistbox>(&window, "option_list", true);
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < option_list_.size(); ++i) {
|
||||
/**
|
||||
* @todo This syntax looks like a bad hack, it would be nice to write
|
||||
* a new syntax which doesn't use those hacks (also avoids the problem
|
||||
* with special meanings for certain characters.
|
||||
*/
|
||||
tlegacy_menu_item item(option_list_[i]);
|
||||
|
||||
if(item.is_default()) {
|
||||
// Number of items hasn't been increased yet so i is ok.
|
||||
*chosen_option_ = i;
|
||||
}
|
||||
|
||||
// Add the data.
|
||||
data["icon"]["label"] = item.icon();
|
||||
data["label"]["label"] = item.label();
|
||||
data["label"]["use_markup"] = "true";
|
||||
data["description"]["label"] = item.description();
|
||||
data["description"]["use_markup"] = "true";
|
||||
options.add_row(data);
|
||||
}
|
||||
|
||||
// Avoid negetive and 0 since item 0 is already selected.
|
||||
if(*chosen_option_ > 0
|
||||
&& static_cast<size_t>(*chosen_option_)
|
||||
< option_list_.size()) {
|
||||
|
||||
options.select_row(*chosen_option_);
|
||||
}
|
||||
|
||||
window.keyboard_capture(&options);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
|
||||
window.add_to_keyboard_chain(&options);
|
||||
//options.set_visible(twidget::INVISIBLE);
|
||||
|
||||
}
|
||||
|
||||
void toption_message_::post_show(twindow& window)
|
||||
{
|
||||
*chosen_option_ =
|
||||
find_widget<tlistbox>(&window, "option_list", true).get_selected_row();
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(option_message_left)
|
||||
REGISTER_DIALOG(option_message_right)
|
||||
|
||||
int show_option_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const std::vector<std::string>& option_list
|
||||
, int* chosen_option)
|
||||
{
|
||||
std::auto_ptr<toption_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new toption_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new toption_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
dlg->set_option_list(option_list, chosen_option);
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_OPTION_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_OPTION_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* Class for displaying a wml message with option list.
|
||||
*
|
||||
* We have a separate sub class for left and right images.
|
||||
*/
|
||||
class toption_message_
|
||||
: public timage_message_
|
||||
{
|
||||
public:
|
||||
toption_message_(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: timage_message_(title, message, portrait, mirror)
|
||||
//, image_("")
|
||||
, option_list_()
|
||||
, chosen_option_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the option list.
|
||||
*
|
||||
* @param option_list Vector of options to choice from.
|
||||
* @param chosen_option Number of the option that was chosen.
|
||||
*/
|
||||
void set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option);
|
||||
|
||||
private:
|
||||
|
||||
/** The list of options the player can choose. */
|
||||
std::vector<std::string> option_list_;
|
||||
|
||||
/** The chosen option. */
|
||||
int *chosen_option_;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the left side. */
|
||||
class toption_message_left : public toption_message_
|
||||
{
|
||||
public:
|
||||
toption_message_left(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: toption_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the right side. */
|
||||
class toption_message_right : public toption_message_
|
||||
{
|
||||
public:
|
||||
toption_message_right(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: toption_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to show a portrait.
|
||||
*
|
||||
* @param left_side If true the portrait is shown on the left,
|
||||
* on the right side otherwise.
|
||||
* @param video The display variable.
|
||||
* @param title The title of the dialog.
|
||||
* @param message The message to show.
|
||||
* @param portrait Filename of the portrait.
|
||||
* @param mirror Does the portrait need to be mirrored?
|
||||
* @param option_list A list of options to select in the dialog.
|
||||
* @param chosen_option Pointer to the initially chosen option.
|
||||
* Will be set to the chosen_option when the
|
||||
* dialog closes.
|
||||
*/
|
||||
int show_option_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const std::vector<std::string>& option_list
|
||||
, int* chosen_option);
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -1,269 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/image_message/recruit_message.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/widgets/image.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
//TODO let's see if we need all of those
|
||||
#include "resources.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "map.hpp"
|
||||
#include "help.hpp"
|
||||
#include "gettext.hpp" //could be done in menu_events
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
//should be active in every dialog that involves units.
|
||||
void trecruit_message_::profile_pressed() {
|
||||
assert(chosen_unit_);
|
||||
const unit_type& t = *chosen_unit_->type();
|
||||
help::show_unit_help(*resources::screen, t.id(), t.hide_help());
|
||||
}
|
||||
|
||||
//TODO this is very specific, might need to go into another class
|
||||
void trecruit_message_::help_pressed() {
|
||||
help::show_help(*resources::screen,"recruit_and_recall");
|
||||
}
|
||||
|
||||
void trecruit_message_::update_unit_list(twindow& window) {
|
||||
tlistbox& unit_listbox = find_widget<tlistbox> (&window, "recruit_list", false);
|
||||
|
||||
chosen_unit_ = &unit_list_[unit_listbox.get_selected_row()];
|
||||
|
||||
const map_location& loc = chosen_unit_->get_location();
|
||||
|
||||
if (resources::game_map->on_board(loc)) {
|
||||
resources::screen->highlight_hex(loc);
|
||||
//TODO is false better?
|
||||
resources::screen->scroll_to_tile(loc,
|
||||
game_display::SCROLL, true);
|
||||
} else {
|
||||
chosen_unit_->draw_report();
|
||||
}
|
||||
|
||||
timage& unit_portrait = find_widget<timage> (&window, "unit_portrait", true);
|
||||
unit_portrait.set_image(chosen_unit_->big_profile());
|
||||
// unit_portrait.set_dirty();
|
||||
window.set_dirty();
|
||||
}
|
||||
|
||||
void trecruit_message_::set_unit_list(
|
||||
const std::vector<unit>& unit_list, std::string* unit_id)
|
||||
{
|
||||
assert(unit_id);
|
||||
assert(!unit_list.empty());
|
||||
|
||||
unit_id_ = unit_id;
|
||||
unit_list_ = unit_list;
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
void trecruit_message_::set_type_list(
|
||||
std::vector<const unit_type*> type_list, std::string* type_id, int side_num, int gold)
|
||||
{
|
||||
assert(!type_list.empty());
|
||||
assert(type_id);
|
||||
|
||||
gold_ = gold;
|
||||
unit_id_ = type_id;
|
||||
|
||||
std::vector<const unit_type*>::const_iterator it;
|
||||
it = type_list.begin();
|
||||
|
||||
for (it = type_list.begin(); it != type_list.end(); it++)
|
||||
{
|
||||
unit new_unit(*it, side_num, false);
|
||||
unit_list_.push_back(new_unit);
|
||||
}
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void trecruit_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
window.canvas(1).set_variable("portrait_image", variant(portrait_));
|
||||
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
|
||||
|
||||
// Set the markup
|
||||
tlabel& title = find_widget<tlabel>(&window, "title", false);
|
||||
title.set_label(title_);
|
||||
title.set_use_markup(true);
|
||||
title.set_can_wrap(true);
|
||||
|
||||
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
|
||||
message.set_label(message_);
|
||||
message.set_use_markup(true);
|
||||
// The message label might not always be a scroll_label but the capturing
|
||||
// shouldn't hurt.
|
||||
window.keyboard_capture(&message);
|
||||
|
||||
// Find the unit list related fields:
|
||||
tlistbox& units = find_widget<tlistbox>(&window, "recruit_list", true);
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
units.set_callback_value_change(dialog_callback<trecruit_message_,
|
||||
&trecruit_message_::update_unit_list> );
|
||||
#else
|
||||
connect_signal_notify_modified(units, boost::bind(
|
||||
&trecruit_message_::update_unit_list
|
||||
, this
|
||||
, boost::ref(window)));
|
||||
#endif
|
||||
if(!unit_list_.empty()) {
|
||||
|
||||
window.canvas(0).set_variable("portrait_image", variant(
|
||||
chosen_unit_->big_profile()));
|
||||
window.set_dirty();
|
||||
|
||||
timage& unit_portrait = find_widget<timage> (&window, "unit_portrait", true);
|
||||
unit_portrait.set_image(chosen_unit_->big_profile());
|
||||
|
||||
chosen_unit_->draw_report();
|
||||
|
||||
//TODO make it optional
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "help", true)
|
||||
, boost::bind(
|
||||
&trecruit_message_::help_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "profile", true)
|
||||
, boost::bind(
|
||||
&trecruit_message_::profile_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < unit_list_.size(); ++i) {
|
||||
|
||||
unit& unit = unit_list_[i];
|
||||
|
||||
bool affordable = unit.cost() <= gold_ ;
|
||||
|
||||
std::string unit_mod = affordable ? unit.image_mods() : "~GS()" ;
|
||||
std::string icon = (unit.absolute_image() + unit_mod);
|
||||
std::string type = unit.type_name();
|
||||
std::string name = unit.name();
|
||||
|
||||
//TODO handle traits in another way
|
||||
//std::string traits = unit.trait_descriptions();
|
||||
std::ostringstream level;
|
||||
std::ostringstream xp;
|
||||
xp << unit.experience() << "/" << unit.max_experience();
|
||||
|
||||
// Show units of level (0=gray, 1 normal, 2 bold, 2+ bold&wbright)
|
||||
const int level_number = unit.level();
|
||||
//TODO enable the switch construct after replacing the font::NORMAL_TEXT etc.
|
||||
// switch(level_number)
|
||||
// {
|
||||
// case 0: level << "<150,150,150>";
|
||||
// break;
|
||||
// case 1: level << font::NORMAL_TEXT;
|
||||
// break;
|
||||
// case 2: level << font::BOLD_TEXT;
|
||||
// break;
|
||||
// default: level << font::BOLD_TEXT << "<255,255,255>";
|
||||
// }
|
||||
level << level_number;
|
||||
|
||||
std::string gold_color;
|
||||
|
||||
gold_color = affordable ? "green" : "red" ;
|
||||
|
||||
std::ostringstream cost;
|
||||
cost << "<span color=\"" << gold_color << "\">" << unit.cost() << " " << "Gold" << "</span>" ;
|
||||
|
||||
// Add the data.
|
||||
data["cost"]["label"] = cost.str();
|
||||
data["cost"]["use_markup"] = "true";
|
||||
data["gold"]["label"] = "items/gold-coins-small.png";
|
||||
data["usage"]["label"] = unit.usage();
|
||||
data["icon"]["label"] = icon;
|
||||
data["icon"]["use_markup"] = "true";
|
||||
data["name"]["label"] = name;
|
||||
data["type"]["label"] = type;
|
||||
data["label"]["use_markup"] = "true";
|
||||
data["level"]["label"] = level.str();
|
||||
data["xp"]["label"] = xp.str();
|
||||
//TODO traits handling changed through the versions
|
||||
//data["traits"]["label"] = unit.traits_description();
|
||||
units.add_row(data);
|
||||
}
|
||||
}
|
||||
|
||||
window.set_click_dismiss(false);
|
||||
}
|
||||
|
||||
void trecruit_message_::post_show(twindow& /*window*/)
|
||||
{
|
||||
if(!unit_list_.empty()) {
|
||||
*unit_id_ = chosen_unit_->type_id();
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(recruit_message_left)
|
||||
|
||||
REGISTER_DIALOG(recruit_message_right)
|
||||
|
||||
int show_recruit_message(const bool left_side
|
||||
, CVideo& video
|
||||
, std::vector<const unit_type*> type_list
|
||||
, std::string* type_id
|
||||
, int side_num
|
||||
, int gold)
|
||||
{
|
||||
const std::string title = _("Recruit");
|
||||
const std::string message = _("Select unit:");
|
||||
const std::string portrait = "";
|
||||
const bool mirror = false;
|
||||
std::auto_ptr<trecruit_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new trecruit_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new trecruit_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
dlg->set_type_list(type_list, type_id, side_num, gold);
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
@ -1,243 +0,0 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_RECRUIT_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_RECRUIT_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
//TODO get rid of this here
|
||||
#include "unit.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* Base class for the wml generated messages.
|
||||
*
|
||||
* We have a separate sub class for left and right images.
|
||||
*/
|
||||
class trecruit_message_
|
||||
: public tdialog
|
||||
{
|
||||
public:
|
||||
trecruit_message_(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: title_(title)
|
||||
, image_("")
|
||||
, message_(message)
|
||||
, portrait_(portrait)
|
||||
, mirror_(mirror)
|
||||
, has_input_(false)
|
||||
, input_caption_("")
|
||||
, input_text_(NULL)
|
||||
, input_maximum_lenght_(0)
|
||||
, option_list_()
|
||||
, chosen_option_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the input text variables.
|
||||
*
|
||||
* @param caption The caption for the label.
|
||||
* @param text The initial text, after showing the final
|
||||
* text.
|
||||
* @param maximum_length The maximum length of the text.
|
||||
*/
|
||||
void set_input(const std::string& caption,
|
||||
std::string* text, const unsigned maximum_length);
|
||||
|
||||
/**
|
||||
* Sets the option list.
|
||||
*
|
||||
* @param option_list Vector of options to choice from.
|
||||
* @param chosen_option Number of the option that was chosen.
|
||||
*/
|
||||
void set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option);
|
||||
|
||||
/**
|
||||
* Sets the unit list.
|
||||
*
|
||||
* @param unit_list TODO
|
||||
* @param chosen_unit TODO
|
||||
*/
|
||||
void set_unit_list(
|
||||
const std::vector<unit>& unit_list, std::string* chosen_unit);
|
||||
|
||||
/**
|
||||
* Sets the type list
|
||||
*
|
||||
* @param type_list TODO
|
||||
* @param type_id TODO
|
||||
* @param side_num TODO
|
||||
* @param gold TODO
|
||||
*/
|
||||
void set_type_list(
|
||||
std::vector<const unit_type*> type_list, std::string* type_id, int side_num, int gold);
|
||||
private:
|
||||
|
||||
|
||||
/** Handler for changed unit selection. */
|
||||
void update_unit_list(twindow& window);
|
||||
|
||||
/** Handler for the profile button event. */
|
||||
void profile_pressed();
|
||||
|
||||
/** Handler for the help button event */
|
||||
void help_pressed();
|
||||
|
||||
/** The title for the dialog. */
|
||||
std::string title_;
|
||||
|
||||
/**
|
||||
* The image which is shown in the dialog.
|
||||
*
|
||||
* This image can be an icon or portrait or any other image.
|
||||
*/
|
||||
std::string image_;
|
||||
|
||||
/** The message to show to the user. */
|
||||
std::string message_;
|
||||
/** Filename of the portrait. */
|
||||
std::string portrait_;
|
||||
|
||||
/** Mirror the portrait? */
|
||||
bool mirror_;
|
||||
|
||||
/** Do we need to show an input box? */
|
||||
bool has_input_;
|
||||
|
||||
/** The caption to show for the input text. */
|
||||
std::string input_caption_;
|
||||
|
||||
/** The text input. */
|
||||
std::string* input_text_;
|
||||
|
||||
/** The maximum length of the input text. */
|
||||
unsigned input_maximum_lenght_;
|
||||
|
||||
/** The unit id. */
|
||||
std::string* unit_id_;
|
||||
|
||||
/** The list of units the player can choose. */
|
||||
std::vector<unit> unit_list_;
|
||||
|
||||
/** The list of unit_types the player can choose. */
|
||||
//std::vector<const unit_type*> type_list_;
|
||||
|
||||
/** The list of options the player can choose. */
|
||||
std::vector<std::string> option_list_;
|
||||
|
||||
/** The chosen option. */
|
||||
int *chosen_option_;
|
||||
|
||||
/** The chosen unit. */
|
||||
unit *chosen_unit_;
|
||||
|
||||
/** Gold */
|
||||
int gold_;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void post_show(twindow& window);
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the left side. */
|
||||
class trecruit_message_left : public trecruit_message_
|
||||
{
|
||||
public:
|
||||
trecruit_message_left(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: trecruit_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
/** Shows a dialog with the portrait on the right side. */
|
||||
class trecruit_message_right : public trecruit_message_
|
||||
{
|
||||
public:
|
||||
trecruit_message_right(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: trecruit_message_(title, message, portrait, mirror)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to show a portrait.
|
||||
*
|
||||
* @param left_side If true the portrait is shown on the left,
|
||||
* on the right side otherwise.
|
||||
* @param video The display variable.
|
||||
* @param title The title of the dialog.
|
||||
* @param message The message to show.
|
||||
* @param portrait Filename of the portrait.
|
||||
* @param mirror Does the portrait need to be mirrored?
|
||||
*
|
||||
* @param has_input Do we need to show the input box.
|
||||
* @param input_caption The caption for the optional input text
|
||||
* box. If this value != "" there is an input
|
||||
* and the input text parameter is mandatory.
|
||||
* @param input_text Pointer to the initial text value will be
|
||||
* set to the result.
|
||||
* @param maximum_length The maximum length of the text.
|
||||
*
|
||||
* @param option_list A list of options to select in the dialog.
|
||||
* @param chosen_option Pointer to the initially chosen option.
|
||||
* Will be set to the chosen_option when the
|
||||
* dialog closes.
|
||||
*/
|
||||
int show_recruit_message(const bool left_side
|
||||
, CVideo& video
|
||||
, std::vector<const unit_type*> type_list
|
||||
, std::string* type_id
|
||||
, int side_num
|
||||
, int gold);
|
||||
|
||||
//int show_wml_message(const bool left_side
|
||||
// , CVideo& video
|
||||
// , const std::string& title
|
||||
// , const std::string& message
|
||||
// , const std::string& portrait
|
||||
// , const bool mirror
|
||||
// , const bool has_input
|
||||
// , const std::string& input_caption
|
||||
// , std::string* input_text
|
||||
// , const unsigned maximum_length
|
||||
// , const bool has_unit
|
||||
// , std::string* unit_id
|
||||
// , const std::vector<unit>& unit_list
|
||||
// , const std::vector<std::string>& option_list
|
||||
// , int* chosen_option);
|
||||
|
||||
|
||||
} // namespace gui2
|
||||
|
||||
#endif
|
||||
|
|
@ -1,408 +0,0 @@
|
|||
/* $Id: unit_message.cpp -1 $ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/wml_message.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "gui/dialogs/helper.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
//TODO let's see if we need all of those
|
||||
#include "resources.hpp"
|
||||
#include "game_display.hpp"
|
||||
#include "map.hpp"
|
||||
#include "help.hpp"
|
||||
#include "gettext.hpp" //could be done in menu_events
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
//should be active in every dialog that involves units.
|
||||
void twml_message_::profile_pressed() {
|
||||
assert(chosen_unit_);
|
||||
const unit_type& t = *chosen_unit_->type();
|
||||
help::show_unit_help(*resources::screen, t.id(), t.hide_help());
|
||||
}
|
||||
|
||||
//TODO this is very specific, might need to go into another class
|
||||
void twml_message_::help_pressed() {
|
||||
help::show_help(*resources::screen,"recruit_and_recall");
|
||||
}
|
||||
|
||||
void twml_message_::update_unit_list(twindow& window) {
|
||||
tlistbox& unit_listbox = find_widget<tlistbox> (&window, "recruit_list", false);
|
||||
|
||||
//TODO this hack does not respect the sorting of the list.
|
||||
chosen_unit_ = &unit_list_[unit_listbox.get_selected_row()];
|
||||
|
||||
const map_location& loc = chosen_unit_->get_location();
|
||||
|
||||
if (resources::game_map->on_board(loc)) {
|
||||
resources::screen->highlight_hex(loc);
|
||||
//TODO is false better?
|
||||
resources::screen->scroll_to_tile(loc,
|
||||
game_display::SCROLL, true);
|
||||
} else {
|
||||
chosen_unit_->draw_report();
|
||||
}
|
||||
|
||||
window.canvas(1).set_variable("portrait_image", variant(
|
||||
chosen_unit_->big_profile()));
|
||||
window.set_dirty();
|
||||
}
|
||||
|
||||
void twml_message_::set_input(const std::string& caption,
|
||||
std::string* text, const unsigned maximum_length)
|
||||
{
|
||||
assert(text);
|
||||
|
||||
has_input_ = true;
|
||||
input_caption_ = caption;
|
||||
input_text_ = text;
|
||||
input_maximum_lenght_ = maximum_length;
|
||||
}
|
||||
|
||||
void twml_message_::set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option)
|
||||
{
|
||||
assert(!option_list.empty());
|
||||
assert(chosen_option);
|
||||
|
||||
option_list_ = option_list;
|
||||
chosen_option_ = chosen_option;
|
||||
}
|
||||
|
||||
void twml_message_::set_unit_list(
|
||||
const std::vector<unit>& unit_list, std::string* unit_id)
|
||||
{
|
||||
assert(unit_id);
|
||||
assert(!unit_list.empty());
|
||||
|
||||
unit_id_ = unit_id;
|
||||
unit_list_ = unit_list;
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
void twml_message_::set_type_list(
|
||||
std::vector<const unit_type*> type_list, std::string* type_id, int side_num, int gold)
|
||||
{
|
||||
assert(!type_list.empty());
|
||||
assert(type_id);
|
||||
|
||||
gold_ = gold;
|
||||
unit_id_ = type_id;
|
||||
|
||||
std::vector<const unit_type*>::const_iterator it;
|
||||
it = type_list.begin();
|
||||
|
||||
for (it = type_list.begin(); it != type_list.end(); it++)
|
||||
{
|
||||
unit new_unit(*it, side_num, false);
|
||||
unit_list_.push_back(new_unit);
|
||||
}
|
||||
chosen_unit_ = &unit_list_[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
window.canvas(1).set_variable("portrait_image", variant(portrait_));
|
||||
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
|
||||
|
||||
// Set the markup
|
||||
tlabel& title = find_widget<tlabel>(&window, "title", false);
|
||||
title.set_label(title_);
|
||||
title.set_use_markup(true);
|
||||
title.set_can_wrap(true);
|
||||
|
||||
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
|
||||
message.set_label(message_);
|
||||
message.set_use_markup(true);
|
||||
// The message label might not always be a scroll_label but the capturing
|
||||
// shouldn't hurt.
|
||||
window.keyboard_capture(&message);
|
||||
|
||||
// Find the input box related fields.
|
||||
tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
|
||||
ttext_box& input = find_widget<ttext_box>(&window, "input", true);
|
||||
|
||||
if(has_input_) {
|
||||
caption.set_label(input_caption_);
|
||||
caption.set_use_markup(true);
|
||||
input.set_value(*input_text_);
|
||||
input.set_maximum_length(input_maximum_lenght_);
|
||||
window.keyboard_capture(&input);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
} else {
|
||||
caption.set_visible(twidget::INVISIBLE);
|
||||
input.set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
|
||||
// Find the unit list related fields:
|
||||
// tlistbox& units = find_widget<tlistbox>(&window, "unit_list", true);
|
||||
tlistbox& units = find_widget<tlistbox>(&window, "recruit_list", true);
|
||||
#ifndef GUI2_EXPERIMENTAL_LISTBOX
|
||||
units.set_callback_value_change(dialog_callback<twml_message_,
|
||||
&twml_message_::update_unit_list> );
|
||||
#endif
|
||||
if(!unit_list_.empty()) {
|
||||
|
||||
window.canvas(1).set_variable("portrait_image", variant(
|
||||
chosen_unit_->big_profile()));
|
||||
window.set_dirty();
|
||||
|
||||
chosen_unit_->draw_report();
|
||||
|
||||
//TODO make it optional
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "help", true)
|
||||
, boost::bind(
|
||||
&twml_message_::help_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "profile", true)
|
||||
, boost::bind(
|
||||
&twml_message_::profile_pressed
|
||||
, this
|
||||
));
|
||||
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < unit_list_.size(); ++i) {
|
||||
|
||||
unit& unit = unit_list_[i];
|
||||
|
||||
bool affordable = unit.cost() <= gold_ ;
|
||||
|
||||
std::string unit_mod = affordable ? unit.image_mods() : "~GS()" ;
|
||||
std::string icon = (unit.absolute_image() + unit_mod);
|
||||
std::string type = unit.type_name();
|
||||
std::string name = unit.name();
|
||||
|
||||
//TODO handle traits in another way
|
||||
//std::string traits = unit.trait_descriptions();
|
||||
std::ostringstream level;
|
||||
std::ostringstream xp;
|
||||
xp << unit.experience() << "/" << unit.max_experience();
|
||||
|
||||
// Show units of level (0=gray, 1 normal, 2 bold, 2+ bold&wbright)
|
||||
const int level_number = unit.level();
|
||||
//TODO enable the switch construct after replacing the font::NORMAL_TEXT etc.
|
||||
// switch(level_number)
|
||||
// {
|
||||
// case 0: level << "<150,150,150>";
|
||||
// break;
|
||||
// case 1: level << font::NORMAL_TEXT;
|
||||
// break;
|
||||
// case 2: level << font::BOLD_TEXT;
|
||||
// break;
|
||||
// default: level << font::BOLD_TEXT << "<255,255,255>";
|
||||
// }
|
||||
level << level_number;
|
||||
|
||||
std::string gold_color;
|
||||
|
||||
gold_color = affordable ? "green" : "red" ;
|
||||
|
||||
std::ostringstream cost;
|
||||
cost << "<span color=\"" << gold_color << "\">" << unit.cost() << " " << "Gold" << "</span>" ;
|
||||
|
||||
// Add the data.
|
||||
data["cost"]["label"] = cost.str();
|
||||
data["cost"]["use_markup"] = "true";
|
||||
data["gold"]["label"] = "items/gold-coins-small.png";
|
||||
data["usage"]["label"] = unit.usage();
|
||||
data["icon"]["label"] = icon;
|
||||
data["icon"]["use_markup"] = "true";
|
||||
data["name"]["label"] = name;
|
||||
data["type"]["label"] = type;
|
||||
data["label"]["use_markup"] = "true";
|
||||
data["level"]["label"] = level.str();
|
||||
data["xp"]["label"] = xp.str();
|
||||
//TODO traits handling changed through the versions
|
||||
//data["traits"]["label"] = unit.traits_description();
|
||||
units.add_row(data);
|
||||
}
|
||||
} else {
|
||||
tbutton* profile_button = find_widget<tbutton> (&window, "profile", false,
|
||||
false);
|
||||
profile_button->set_visible(twidget::INVISIBLE);
|
||||
units.set_visible(twidget::INVISIBLE);
|
||||
|
||||
tbutton* help_button = find_widget<tbutton> (&window, "help", false,
|
||||
false);
|
||||
help_button->set_visible(twidget::INVISIBLE);
|
||||
|
||||
tbutton* cancel_button = find_widget<tbutton> (&window, "cancel", false,
|
||||
false);
|
||||
cancel_button->set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
|
||||
// Find the option list related fields.
|
||||
tlistbox& options = find_widget<tlistbox>(&window, "input_list", true);
|
||||
|
||||
if(!option_list_.empty()) {
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < option_list_.size(); ++i) {
|
||||
/**
|
||||
* @todo This syntax looks like a bad hack, it would be nice to write
|
||||
* a new syntax which doesn't use those hacks (also avoids the problem
|
||||
* with special meanings for certain characters.
|
||||
*/
|
||||
tlegacy_menu_item item(option_list_[i]);
|
||||
|
||||
if(item.is_default()) {
|
||||
// Number of items hasn't been increased yet so i is ok.
|
||||
*chosen_option_ = i;
|
||||
}
|
||||
|
||||
// Add the data.
|
||||
data["icon"]["label"] = item.icon();
|
||||
data["label"]["label"] = item.label();
|
||||
data["label"]["use_markup"] = "true";
|
||||
data["description"]["label"] = item.description();
|
||||
data["description"]["use_markup"] = "true";
|
||||
options.add_row(data);
|
||||
}
|
||||
|
||||
// Avoid negetive and 0 since item 0 is already selected.
|
||||
if(*chosen_option_ > 0
|
||||
&& static_cast<size_t>(*chosen_option_)
|
||||
< option_list_.size()) {
|
||||
|
||||
options.select_row(*chosen_option_);
|
||||
}
|
||||
|
||||
if(!has_input_) {
|
||||
window.keyboard_capture(&options);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
} else {
|
||||
window.add_to_keyboard_chain(&options);
|
||||
// click_dismiss has been disabled due to the input.
|
||||
}
|
||||
} else {
|
||||
options.set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
window.set_click_dismiss(!has_input_ && option_list_.empty() && unit_list_.empty());
|
||||
}
|
||||
|
||||
void twml_message_::post_show(twindow& window)
|
||||
{
|
||||
if(has_input_) {
|
||||
*input_text_ =
|
||||
find_widget<ttext_box>(&window, "input", true).get_value();
|
||||
}
|
||||
|
||||
if(!option_list_.empty()) {
|
||||
*chosen_option_ =
|
||||
find_widget<tlistbox>(&window, "input_list", true).get_selected_row();
|
||||
}
|
||||
|
||||
if(!unit_list_.empty()) {
|
||||
*unit_id_ = chosen_unit_->type_id();
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(wml_message_left)
|
||||
|
||||
REGISTER_DIALOG(wml_message_right)
|
||||
|
||||
int show_recruit_message(const bool left_side
|
||||
, CVideo& video
|
||||
, std::vector<const unit_type*> type_list
|
||||
, std::string* type_id
|
||||
, int side_num
|
||||
, int gold)
|
||||
{
|
||||
const std::string title = _("Recruit");
|
||||
const std::string message = _("Select unit:");
|
||||
const std::string portrait = "";
|
||||
const bool mirror = false;
|
||||
std::auto_ptr<twml_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new twml_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new twml_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
dlg->set_type_list(type_list, type_id, side_num, gold);
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
int show_wml_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const bool has_input
|
||||
, const std::string& input_caption
|
||||
, std::string* input_text
|
||||
, const unsigned maximum_length
|
||||
, const bool has_unit
|
||||
, std::string* unit_id
|
||||
, const std::vector<unit>& unit_list
|
||||
, const std::vector<std::string>& option_list
|
||||
, int* chosen_option)
|
||||
{
|
||||
std::auto_ptr<twml_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new twml_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new twml_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
if(has_input) {
|
||||
dlg->set_input(input_caption, input_text, maximum_length);
|
||||
}
|
||||
|
||||
if(has_unit) {
|
||||
dlg->set_unit_list(unit_list, unit_id);
|
||||
}
|
||||
|
||||
if(!option_list.empty()) {
|
||||
dlg->set_option_list(option_list, chosen_option);
|
||||
}
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
197
src/gui/dialogs/wml_message.cpp
Normal file
197
src/gui/dialogs/wml_message.cpp
Normal file
|
@ -0,0 +1,197 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||
|
||||
#include "gui/dialogs/wml_message.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "gui/auxiliary/old_markup.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
#include "gui/widgets/list.hpp"
|
||||
#else
|
||||
#include "gui/widgets/listbox.hpp"
|
||||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
void twml_message_::set_input(const std::string& caption,
|
||||
std::string* text, const unsigned maximum_length)
|
||||
{
|
||||
assert(text);
|
||||
|
||||
has_input_ = true;
|
||||
input_caption_ = caption;
|
||||
input_text_ = text;
|
||||
input_maximum_lenght_ = maximum_length;
|
||||
}
|
||||
|
||||
void twml_message_::set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option)
|
||||
{
|
||||
assert(!option_list.empty());
|
||||
assert(chosen_option);
|
||||
|
||||
option_list_ = option_list;
|
||||
chosen_option_ = chosen_option;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo This function enables the wml markup for all items, but the interface
|
||||
* is a bit hacky. Especially the fiddling in the internals of the listbox is
|
||||
* ugly. There needs to be a clean interface to set whether a widget has a
|
||||
* markup and what kind of markup. These fixes will be post 1.6.
|
||||
*/
|
||||
void twml_message_::pre_show(CVideo& /*video*/, twindow& window)
|
||||
{
|
||||
window.canvas(1).set_variable("portrait_image", variant(portrait_));
|
||||
window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
|
||||
|
||||
// Set the markup
|
||||
tlabel& title = find_widget<tlabel>(&window, "title", false);
|
||||
title.set_label(title_);
|
||||
title.set_use_markup(true);
|
||||
title.set_can_wrap(true);
|
||||
|
||||
tcontrol& message = find_widget<tcontrol>(&window, "message", false);
|
||||
message.set_label(message_);
|
||||
message.set_use_markup(true);
|
||||
// The message label might not always be a scroll_label but the capturing
|
||||
// shouldn't hurt.
|
||||
window.keyboard_capture(&message);
|
||||
|
||||
// Find the input box related fields.
|
||||
tlabel& caption = find_widget<tlabel>(&window, "input_caption", false);
|
||||
ttext_box& input = find_widget<ttext_box>(&window, "input", true);
|
||||
|
||||
if(has_input_) {
|
||||
caption.set_label(input_caption_);
|
||||
caption.set_use_markup(true);
|
||||
input.set_value(*input_text_);
|
||||
input.set_maximum_length(input_maximum_lenght_);
|
||||
window.keyboard_capture(&input);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
} else {
|
||||
caption.set_visible(twidget::INVISIBLE);
|
||||
input.set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
|
||||
// Find the option list related fields.
|
||||
tlistbox& options = find_widget<tlistbox>(&window, "input_list", true);
|
||||
|
||||
if(!option_list_.empty()) {
|
||||
std::map<std::string, string_map> data;
|
||||
for(size_t i = 0; i < option_list_.size(); ++i) {
|
||||
/**
|
||||
* @todo This syntax looks like a bad hack, it would be nice to write
|
||||
* a new syntax which doesn't use those hacks (also avoids the problem
|
||||
* with special meanings for certain characters.
|
||||
*/
|
||||
tlegacy_menu_item item(option_list_[i]);
|
||||
|
||||
if(item.is_default()) {
|
||||
// Number of items hasn't been increased yet so i is ok.
|
||||
*chosen_option_ = i;
|
||||
}
|
||||
|
||||
// Add the data.
|
||||
data["icon"]["label"] = item.icon();
|
||||
data["label"]["label"] = item.label();
|
||||
data["label"]["use_markup"] = "true";
|
||||
data["description"]["label"] = item.description();
|
||||
data["description"]["use_markup"] = "true";
|
||||
options.add_row(data);
|
||||
}
|
||||
|
||||
// Avoid negetive and 0 since item 0 is already selected.
|
||||
if(*chosen_option_ > 0
|
||||
&& static_cast<size_t>(*chosen_option_)
|
||||
< option_list_.size()) {
|
||||
|
||||
options.select_row(*chosen_option_);
|
||||
}
|
||||
|
||||
if(!has_input_) {
|
||||
window.keyboard_capture(&options);
|
||||
window.set_click_dismiss(false);
|
||||
window.set_escape_disabled(true);
|
||||
} else {
|
||||
window.add_to_keyboard_chain(&options);
|
||||
// click_dismiss has been disabled due to the input.
|
||||
}
|
||||
} else {
|
||||
options.set_visible(twidget::INVISIBLE);
|
||||
}
|
||||
window.set_click_dismiss(!has_input_ && option_list_.empty());
|
||||
}
|
||||
|
||||
void twml_message_::post_show(twindow& window)
|
||||
{
|
||||
if(has_input_) {
|
||||
*input_text_ =
|
||||
find_widget<ttext_box>(&window, "input", true).get_value();
|
||||
}
|
||||
|
||||
if(!option_list_.empty()) {
|
||||
*chosen_option_ = find_widget<tlistbox>(
|
||||
&window, "input_list", true).get_selected_row();
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_DIALOG(wml_message_left)
|
||||
|
||||
REGISTER_DIALOG(wml_message_right)
|
||||
|
||||
int show_wml_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
, const std::string& message
|
||||
, const std::string& portrait
|
||||
, const bool mirror
|
||||
, const bool has_input
|
||||
, const std::string& input_caption
|
||||
, std::string* input_text
|
||||
, const unsigned maximum_length
|
||||
, const std::vector<std::string>& option_list
|
||||
, int* chosen_option)
|
||||
{
|
||||
std::auto_ptr<twml_message_> dlg;
|
||||
if(left_side) {
|
||||
dlg.reset(new twml_message_left(title, message, portrait, mirror));
|
||||
} else {
|
||||
dlg.reset(new twml_message_right(title, message, portrait, mirror));
|
||||
}
|
||||
assert(dlg.get());
|
||||
|
||||
if(has_input) {
|
||||
dlg->set_input(input_caption, input_text, maximum_length);
|
||||
}
|
||||
|
||||
if(!option_list.empty()) {
|
||||
dlg->set_option_list(option_list, chosen_option);
|
||||
}
|
||||
|
||||
dlg->show(video);
|
||||
return dlg->get_retval();
|
||||
}
|
||||
|
||||
} // namespace gui2
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: unit_message.hpp -1 $ */
|
||||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 - 2011 by Mark de Wever <koraq@xs4all.nl>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
@ -13,53 +13,54 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef GUI_DIALOGS_UNIT_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_UNIT_MESSAGE_HPP_INCLUDED
|
||||
#ifndef GUI_DIALOGS_WML_MESSAGE_HPP_INCLUDED
|
||||
#define GUI_DIALOGS_WML_MESSAGE_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
#include "unit.hpp"
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
/**
|
||||
* Base class for the unit option messages.
|
||||
* Base class for the wml generated messages.
|
||||
*
|
||||
* We have a separate sub class for left and right images.
|
||||
*/
|
||||
class tunit_message_
|
||||
: public timage_message_
|
||||
class twml_message_
|
||||
: public tdialog
|
||||
{
|
||||
public:
|
||||
tunit_message_(const std::string& title, const std::string& message,
|
||||
twml_message_(const std::string& title, const std::string& message,
|
||||
const std::string& portrait, const bool mirror)
|
||||
: title_(title)
|
||||
, image_("")
|
||||
, message_(message)
|
||||
, portrait_(portrait)
|
||||
, mirror_(mirror)
|
||||
, has_input_(false)
|
||||
, input_caption_("")
|
||||
, input_text_(NULL)
|
||||
, input_maximum_lenght_(0)
|
||||
, option_list_()
|
||||
, chosen_option_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the unit list.
|
||||
* Sets the input text variables.
|
||||
*
|
||||
* @param unit_list TODO
|
||||
* @param chosen_unit TODO
|
||||
* @param caption The caption for the label.
|
||||
* @param text The initial text, after showing the final
|
||||
* text.
|
||||
* @param maximum_length The maximum length of the text.
|
||||
*/
|
||||
void set_unit_list(
|
||||
const std::vector<unit>& unit_list, std::string* chosen_unit);
|
||||
void set_input(const std::string& caption,
|
||||
std::string* text, const unsigned maximum_length);
|
||||
|
||||
void set_option_list(
|
||||
const std::vector<std::string>& option_list, int* chosen_option);
|
||||
|
||||
private:
|
||||
|
||||
/** Handler for changed unit selection. */
|
||||
void update_unit_list(twindow& window);
|
||||
|
||||
/** Handler for the profile button event. */
|
||||
void profile_pressed();
|
||||
|
||||
/** Handler for the help button event */
|
||||
void help_pressed();
|
||||
|
||||
/** The title for the dialog. */
|
||||
std::string title_;
|
||||
|
||||
|
@ -78,20 +79,23 @@ private:
|
|||
/** Mirror the portrait? */
|
||||
bool mirror_;
|
||||
|
||||
/** The unit id. */
|
||||
std::string* unit_id_;
|
||||
/** Do we need to show an input box? */
|
||||
bool has_input_;
|
||||
|
||||
/** The list of units the player can choose. */
|
||||
std::vector<unit> unit_list_;
|
||||
/** The caption to show for the input text. */
|
||||
std::string input_caption_;
|
||||
|
||||
/** The list of unit_types the player can choose. */
|
||||
//std::vector<const unit_type*> type_list_;
|
||||
/** The text input. */
|
||||
std::string* input_text_;
|
||||
|
||||
/** The chosen unit. */
|
||||
unit *chosen_unit_;
|
||||
/** The maximum length of the input text. */
|
||||
unsigned input_maximum_lenght_;
|
||||
|
||||
/** Gold */
|
||||
int gold_;
|
||||
/** The list of options the user can choose. */
|
||||
std::vector<std::string> option_list_;
|
||||
|
||||
/** The chosen option. */
|
||||
int *chosen_option_;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
@ -157,13 +161,6 @@ private:
|
|||
* Will be set to the chosen_option when the
|
||||
* dialog closes.
|
||||
*/
|
||||
int show_recruit_message(const bool left_side
|
||||
, CVideo& video
|
||||
, std::vector<const unit_type*> type_list
|
||||
, std::string* type_id
|
||||
, int side_num
|
||||
, int gold);
|
||||
|
||||
int show_wml_message(const bool left_side
|
||||
, CVideo& video
|
||||
, const std::string& title
|
||||
|
@ -174,9 +171,6 @@ int show_wml_message(const bool left_side
|
|||
, const std::string& input_caption
|
||||
, std::string* input_text
|
||||
, const unsigned maximum_length
|
||||
, const bool has_unit
|
||||
, std::string* unit_id
|
||||
, const std::vector<unit>& unit_list
|
||||
, const std::vector<std::string>& option_list
|
||||
, int* chosen_option);
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
#include "gui/dialogs/edit_label.hpp"
|
||||
#include "gui/dialogs/message.hpp"
|
||||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/dialogs/image_message/recruit_message.hpp"
|
||||
#include "gui/dialogs/wml_message.hpp"
|
||||
#include "gui/dialogs/gamestate_inspector.hpp"
|
||||
#include "gui/dialogs/data_manage.hpp"
|
||||
#include "gui/dialogs/simple_item_selector.hpp"
|
||||
|
@ -712,20 +712,30 @@ void menu_handler::recruit(int side_num, const map_location &last_hex)
|
|||
}
|
||||
|
||||
int recruit_res = 0;
|
||||
bool left_side = true;
|
||||
int gold = current_team.gold();
|
||||
std::string unit_type = "Elvish Fighter";
|
||||
recruit_res = gui2::show_recruit_message(left_side, gui_->video(),
|
||||
sample_units, &unit_type, side_num, gold);
|
||||
|
||||
//TODO fix the dialog and enable again
|
||||
// if(recruit_res != -1) {
|
||||
if(recruit_res == -1) {
|
||||
do_recruit(unit_type, side_num, last_hex);
|
||||
{
|
||||
dialogs::unit_types_preview_pane unit_preview(
|
||||
sample_units, NULL, side_num);
|
||||
std::vector<gui::preview_pane*> preview_panes;
|
||||
preview_panes.push_back(&unit_preview);
|
||||
|
||||
gui::dialog rmenu(*gui_, _("Recruit") + get_title_suffix(side_num),
|
||||
_("Select unit:") + std::string("\n"),
|
||||
gui::OK_CANCEL,
|
||||
gui::dialog::default_style);
|
||||
rmenu.add_button(new help::help_button(*gui_,"recruit_and_recall"),
|
||||
gui::dialog::BUTTON_HELP);
|
||||
rmenu.set_menu(items);
|
||||
rmenu.set_panes(preview_panes);
|
||||
recruit_res = rmenu.show();
|
||||
}
|
||||
|
||||
if(recruit_res != -1) {
|
||||
do_recruit(item_keys[recruit_res], side_num, last_hex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void menu_handler::repeat_recruit(int side_num, const map_location &last_hex)
|
||||
{
|
||||
if(last_recruit_.empty() == false)
|
||||
|
|
|
@ -52,11 +52,7 @@
|
|||
#include "gui/dialogs/transient_message.hpp"
|
||||
#include "gui/dialogs/unit_attack.hpp"
|
||||
#include "gui/dialogs/unit_create.hpp"
|
||||
#include "gui/dialogs/image_message/image_message.hpp"
|
||||
//TODO enable when safe
|
||||
//#include "gui/dialogs/image_message/input_message.hpp"
|
||||
//#include "gui/dialogs/image_message/option_message.hpp"
|
||||
//#include "gui/dialogs/image_message/unit_message.hpp"
|
||||
#include "gui/dialogs/wml_message.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "language.hpp"
|
||||
#include "map_create.hpp"
|
||||
|
@ -233,15 +229,8 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
test<gui2::ttransient_message>();
|
||||
// test<gui2::tunit_attack>(); /** @todo ENABLE */
|
||||
test<gui2::tunit_create>();
|
||||
test<gui2::timage_message_left>();
|
||||
test<gui2::timage_message_right>();
|
||||
//TODO enable when safe
|
||||
// test<gui2::tinput_message_left>();
|
||||
// test<gui2::tinput_message_right>();
|
||||
// test<gui2::toption_message_left>();
|
||||
// test<gui2::toption_message_right>();
|
||||
// test<gui2::tunit_message_left>();
|
||||
// test<gui2::tunit_message_right>();
|
||||
test<gui2::twml_message_left>();
|
||||
test<gui2::twml_message_right>();
|
||||
|
||||
std::vector<std::string>& list = gui2::unit_test_registered_window_list();
|
||||
|
||||
|
@ -251,36 +240,6 @@ BOOST_AUTO_TEST_CASE(test_gui2)
|
|||
* This list marks some dialogs as tested that are not tested.
|
||||
* This list should be removed so all dialogs are properly tested.
|
||||
*/
|
||||
// list.erase(
|
||||
// std::remove(list.begin(), list.end(), "timage_message_left")
|
||||
// , list.end());
|
||||
// list.erase(
|
||||
// std::remove(list.begin(), list.end(), "timage_message_right")
|
||||
// , list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "toption_message_left")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "toption_message_right")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "tinput_message_left")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "tinput_message_right")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "tunit_message_left")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "tunit_message_right")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "trecruit_message_left")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "trecruit_message_right")
|
||||
, list.end());
|
||||
list.erase(
|
||||
std::remove(list.begin(), list.end(), "debug_clock")
|
||||
, list.end());
|
||||
|
@ -551,61 +510,23 @@ struct twrapper<gui2::ttransient_message>
|
|||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::timage_message_left>
|
||||
struct twrapper<gui2::twml_message_left>
|
||||
{
|
||||
static gui2::timage_message_left* create()
|
||||
static gui2::twml_message_left* create()
|
||||
{
|
||||
return new gui2::timage_message_left("Title", "Message", "", false);
|
||||
return new gui2::twml_message_left("Title", "Message", "", false);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct twrapper<gui2::timage_message_right>
|
||||
struct twrapper<gui2::twml_message_right>
|
||||
{
|
||||
static gui2::timage_message_right* create()
|
||||
static gui2::twml_message_right* create()
|
||||
{
|
||||
return new gui2::timage_message_right("Title", "Message", "", false);
|
||||
return new gui2::twml_message_right("Title", "Message", "", false);
|
||||
}
|
||||
};
|
||||
|
||||
//TODO enable again when safe
|
||||
//template<>
|
||||
//struct twrapper<gui2::tinput_message_left>
|
||||
//{
|
||||
// static gui2::tinput_message_left* create()
|
||||
// {
|
||||
// return new gui2::tinput_message_left("Title", "Message", "", false);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//template<>
|
||||
//struct twrapper<gui2::tinput_message_right>
|
||||
//{
|
||||
// static gui2::tinput_message_right* create()
|
||||
// {
|
||||
// return new gui2::tinput_message_right("Title", "Message", "", false);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//template<>
|
||||
//struct twrapper<gui2::option_message_left>
|
||||
//{
|
||||
// static gui2::toption_message_left* create()
|
||||
// {
|
||||
// return new gui2::toption_message_left("Title", "Message", "", false);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//template<>
|
||||
//struct twrapper<gui2::toption_message_right>
|
||||
//{
|
||||
// static gui2::toption_message_right* create()
|
||||
// {
|
||||
// return new gui2::toption_message_right("Title", "Message", "", false);
|
||||
// }
|
||||
//};
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace editor {
|
||||
|
|
12
src/unit.cpp
12
src/unit.cpp
|
@ -50,9 +50,6 @@ static lg::log_domain log_config("config");
|
|||
#define WRN_CF LOG_STREAM(warn, log_config)
|
||||
#define ERR_CONFIG LOG_STREAM(err, log_config)
|
||||
|
||||
//TODO this works here but is ugly
|
||||
unit* unit::selected_unit_ = NULL;
|
||||
|
||||
namespace {
|
||||
const std::string ModificationTypes[] = { "advance", "trait", "object" };
|
||||
const size_t NumModificationTypes = sizeof(ModificationTypes)/
|
||||
|
@ -2802,20 +2799,12 @@ unit_map::iterator find_visible_unit(const map_location &loc,
|
|||
unit *get_visible_unit(const map_location &loc,
|
||||
const team ¤t_team, bool see_all)
|
||||
{
|
||||
if (unit::selected_unit_ != NULL) return unit::selected_unit_;
|
||||
unit_map::iterator ui = find_visible_unit(loc,
|
||||
current_team, see_all);
|
||||
if (ui == resources::units->end()) return NULL;
|
||||
return &*ui;
|
||||
}
|
||||
|
||||
void unit::draw_report() {
|
||||
selected_unit_ = this;
|
||||
resources::screen->invalidate_unit();
|
||||
resources::screen->draw(false, false);
|
||||
selected_unit_ = NULL;
|
||||
}
|
||||
|
||||
void unit::refresh()
|
||||
{
|
||||
if (state_ == STATE_FORGET && anim_ && anim_->animation_finished_potential())
|
||||
|
@ -2923,6 +2912,7 @@ void unit::remove_attacks_ai()
|
|||
set_attacks(0);
|
||||
}
|
||||
|
||||
|
||||
void unit::remove_movement_ai()
|
||||
{
|
||||
if (movement_left() == total_movement()) {
|
||||
|
|
|
@ -185,8 +185,6 @@ public:
|
|||
|
||||
/** draw a unit. */
|
||||
void redraw_unit();
|
||||
/** draw the unit's report. Used to display units that are offmap */
|
||||
void draw_report();
|
||||
/** Clear unit_halo_ */
|
||||
void clear_haloes();
|
||||
|
||||
|
@ -332,12 +330,7 @@ public:
|
|||
const tportrait* portrait(
|
||||
const unsigned size, const tportrait::tside side) const;
|
||||
|
||||
//TODO move to the right place
|
||||
static unit* selected_unit_;// = NULL;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void advance_to(const config &old_cfg, const unit_type *t,
|
||||
bool use_traits, game_state *state);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue