Merge lp:~widelands-dev/widelands/bug-1395322-tool3 into lp:widelands
- bug-1395322-tool3
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7946 |
Proposed branch: | lp:~widelands-dev/widelands/bug-1395322-tool3 |
Merge into: | lp:widelands |
Diff against target: |
1161 lines (+301/-605) 11 files modified
data/scripting/editor/editor_controls.lua (+16/-9) src/editor/editorinteractive.cc (+6/-0) src/editor/tools/set_port_space_tool.cc (+1/-1) src/editor/ui_menus/tool_change_height_options_menu.cc (+56/-159) src/editor/ui_menus/tool_change_height_options_menu.h (+7/-13) src/editor/ui_menus/tool_change_resources_options_menu.cc (+89/-173) src/editor/ui_menus/tool_change_resources_options_menu.h (+12/-15) src/editor/ui_menus/tool_noise_height_options_menu.cc (+99/-221) src/editor/ui_menus/tool_noise_height_options_menu.h (+10/-14) src/ui_basic/spinbox.cc (+1/-0) src/ui_basic/spinbox.h (+4/-0) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1395322-tool3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
kaputtnik (community) | testing | Approve | |
GunChleoc | Needs Resubmitting | ||
Review via email: mp+290829@code.launchpad.net |
Commit message
Added CTRL as selection key for the 2nd alternative tool and updated help text. Redesigned the Height, Noise and Resources tools to use proper SpinBoxes and Boxes.
Description of the change
Left ALT is causing problems in some OS, so I added the CTRL keys for the 2nd alternative tool. I left the ALT keys in though in order not to frustrate map designers who are used to the Alt key.
bunnybot (widelandsofficial) wrote : | # |
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 968. State: failed. Details: https:/
Appveyor build 801. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 969. State: errored. Details: https:/
Appveyor build 802. State: success. Details: https:/
Miroslav Remák (miroslavr256) wrote : | # |
If we're going to be so specific, we should also mention that Shift or Ctrl + Click removes map elements for Immovables, Animals and Port Space tools. Except Ctrl + Click with the Port Space tool does placement instead of removal for some reason. Perhaps we could fix this inconsistency? That would be an easy one-line change in EditorSetPortSp
Also, see diff comments.
GunChleoc (gunchleoc) wrote : | # |
Yes, I think we should fix the inconsistency. Thanks for flagging it up!
I think the help is getting a bit crowded, too much for the user to remember. So, I'd suggest explaining the general trends in the help function and adding specific help to each tool as a tooltip.
kaputtnik (franku) wrote : | # |
I don't know the reason why Ctrl is used to remove objects at all. In my opinion there should be only one key for removing objects and use this key for all objects. So for all objects:
Click: Place Objects or Increase (meaning 'add something')
Shift + Click: Remove Objects or Decrease (meaning 'remove something')
This should be consistent for all objects, imho. And the Ctrl key should only work for special things (like "Set Value").
Miroslav Remák (miroslavr256) wrote : | # |
It's used as a fallback to the first alternative version of the tool if the second one is not available. It makes sense to me, but I'm not against changing this behavior.
GunChleoc (gunchleoc) wrote : | # |
I don't think that we should go to the trouble to remove the fallbacks - it would only add code. We document the intended keys, and if additional keys work too, I don't see a problem. Basically, if there is no third option, the behavour of the Ctrl key is undefined, so it doesn't matter if it switches to the 1st or 2nd tool.
kaputtnik (franku) wrote : | # |
Ok, then it would be fine if the CTRL + Click for Portdocks get changed in this branch :-)
And removing the shift key from:
"Shift or Ctrl + Click : Set height to the value selected by ‘Set Value’"
Miroslav Remák (miroslavr256) wrote : | # |
Sounds good.
GunChleoc (gunchleoc) wrote : | # |
And another scope creep... since the tooltips wouldn't take, I redesigned the Heigh, Noise and Resources tools to use proper SpinBoxes and Boxes.
kaputtnik (franku) wrote : | # |
Removing the additional headers for "Height and Resources tool" and "Noise height tool" in the help doesn't fit my taste. A general help should be driven by "Information as clear as it could be", not "Information as short it could be". But if you think it's good, lets leave it. The Tooltips make such help nearly superfluous :-)
The only thing i am wondering is the tooltip for "Noise height -> Set Value" which says "Use Shift + Click or Ctrl + Click ...". I think only "Ctrl + Click" should be shown here?
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 975. State: passed. Details: https:/
Appveyor build 808. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
> The Tooltips make such help nearly superfluous :-)
Exactly my point - it's there with the tooltips, and the less the user has to read and memorize, the better IMO.
> The only thing i am wondering is the tooltip for "Noise height -> Set Value"
> which says "Use Shift + Click or Ctrl + Click ...". I think only "Ctrl +
> Click" should be shown here?
+1 - will do :)
kaputtnik (franku) wrote : | # |
I think it's good to go now :-)
Miroslav Remák (miroslavr256) wrote : | # |
See diff comments, otherwise LGTM.
GunChleoc (gunchleoc) wrote : | # |
Thanks for testing & review :)
@bunnybot merge
Preview Diff
1 | === modified file 'data/scripting/editor/editor_controls.lua' | |||
2 | --- data/scripting/editor/editor_controls.lua 2016-04-02 08:09:19 +0000 | |||
3 | +++ data/scripting/editor/editor_controls.lua 2016-04-07 14:03:59 +0000 | |||
4 | @@ -4,16 +4,17 @@ | |||
5 | 4 | include "txts/help/common_helptexts.lua" | 4 | include "txts/help/common_helptexts.lua" |
6 | 5 | 5 | ||
7 | 6 | return { | 6 | return { |
9 | 7 | title = _"Keyboard Shortcuts", | 7 | title = _"Controls", |
10 | 8 | text = | 8 | text = |
11 | 9 | rt( | 9 | rt( |
12 | 10 | h2(_"Keyboard Shortcuts") .. | ||
13 | 10 | p( | 11 | p( |
14 | 12 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
15 | 13 | dl(help_format_hotkey("F1"), _"Help") .. | ||
16 | 11 | -- TRANSLATORS: This is an access key combination. | 14 | -- TRANSLATORS: This is an access key combination. |
17 | 12 | dl(help_format_hotkey("H"), _"Toggle main menu") .. | 15 | dl(help_format_hotkey("H"), _"Toggle main menu") .. |
18 | 13 | -- TRANSLATORS: This is an access key combination. The hotkey is 't' | 16 | -- TRANSLATORS: This is an access key combination. The hotkey is 't' |
19 | 14 | dl(help_format_hotkey("T"), _"Toggle tools menu") .. | 17 | dl(help_format_hotkey("T"), _"Toggle tools menu") .. |
20 | 15 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
21 | 16 | dl(help_format_hotkey(pgettext("hotkey", "1-0")), _"Change tool size") .. | ||
22 | 17 | help_toggle_minimap_hotkey() .. | 18 | help_toggle_minimap_hotkey() .. |
23 | 18 | help_toggle_building_spaces_hotkey() .. | 19 | help_toggle_building_spaces_hotkey() .. |
24 | 19 | -- TRANSLATORS: This is an access key combination. The hotkey is 'p' | 20 | -- TRANSLATORS: This is an access key combination. The hotkey is 'p' |
25 | @@ -22,12 +23,6 @@ | |||
26 | 22 | dl(help_format_hotkey("Ctrl + Z"), _"Undo") .. | 23 | dl(help_format_hotkey("Ctrl + Z"), _"Undo") .. |
27 | 23 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | 24 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
28 | 24 | dl(help_format_hotkey("Ctrl + Y"), _"Redo") .. | 25 | dl(help_format_hotkey("Ctrl + Y"), _"Redo") .. |
29 | 25 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
30 | 26 | dl(help_format_hotkey("F1"), _"Help") .. | ||
31 | 27 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
32 | 28 | dl(help_format_hotkey(pgettext("hotkey", "Shift (Hold)")), _"First alternative tool while pressed") .. | ||
33 | 29 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
34 | 30 | dl(help_format_hotkey(pgettext("hotkey", "Alt (Hold)")), _"Second alternative tool while pressed") .. | ||
35 | 31 | -- TRANSLATORS: This is an access key combination. The hotkey is 'i' | 26 | -- TRANSLATORS: This is an access key combination. The hotkey is 'i' |
36 | 32 | dl(help_format_hotkey("I"), _"Activate information tool") .. | 27 | dl(help_format_hotkey("I"), _"Activate information tool") .. |
37 | 33 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | 28 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
38 | @@ -35,6 +30,18 @@ | |||
39 | 35 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | 30 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. |
40 | 36 | dl(help_format_hotkey(pgettext("hotkey", "Ctrl + S")), _"Save map") .. | 31 | dl(help_format_hotkey(pgettext("hotkey", "Ctrl + S")), _"Save map") .. |
41 | 37 | help_toggle_fullscreen_hotkey() | 32 | help_toggle_fullscreen_hotkey() |
42 | 33 | ) .. | ||
43 | 34 | |||
44 | 35 | h2(_"Tools") .. | ||
45 | 36 | p( | ||
46 | 37 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
47 | 38 | dl(help_format_hotkey(pgettext("hotkey", "1-0")), _"Change tool size") .. | ||
48 | 39 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
49 | 40 | dl(help_format_hotkey(pgettext("hotkey", "Click")), _"Place new elements on the map, or increase map elements by the value selected by ‘Increase/Decrease value’") .. | ||
50 | 41 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
51 | 42 | dl(help_format_hotkey(pgettext("hotkey", "Shift + Click")), _"Remove elements from the map, or decrease map elements by the value selected by ‘Increase/Decrease value’") .. | ||
52 | 43 | -- TRANSLATORS: This is an access key combination. Localize, but do not change the key. | ||
53 | 44 | dl(help_format_hotkey(pgettext("hotkey", "Ctrl + Click")), _"Set map elements to the value selected by ‘Set Value’") | ||
54 | 38 | ) | 45 | ) |
55 | 39 | ) | 46 | ) |
56 | 40 | } | 47 | } |
57 | 41 | 48 | ||
58 | === modified file 'src/editor/editorinteractive.cc' | |||
59 | --- src/editor/editorinteractive.cc 2016-04-06 09:23:04 +0000 | |||
60 | +++ src/editor/editorinteractive.cc 2016-04-07 14:03:59 +0000 | |||
61 | @@ -441,6 +441,9 @@ | |||
62 | 441 | handled = true; | 441 | handled = true; |
63 | 442 | break; | 442 | break; |
64 | 443 | 443 | ||
65 | 444 | case SDLK_LCTRL: | ||
66 | 445 | case SDLK_RCTRL: | ||
67 | 446 | // TODO(GunChleoc): Keeping ALT and MODE to make the transition easier. Remove for Build 20. | ||
68 | 444 | case SDLK_LALT: | 447 | case SDLK_LALT: |
69 | 445 | case SDLK_RALT: | 448 | case SDLK_RALT: |
70 | 446 | case SDLK_MODE: | 449 | case SDLK_MODE: |
71 | @@ -525,6 +528,9 @@ | |||
72 | 525 | switch (code.sym) { | 528 | switch (code.sym) { |
73 | 526 | case SDLK_LSHIFT: | 529 | case SDLK_LSHIFT: |
74 | 527 | case SDLK_RSHIFT: | 530 | case SDLK_RSHIFT: |
75 | 531 | case SDLK_LCTRL: | ||
76 | 532 | case SDLK_RCTRL: | ||
77 | 533 | // TODO(GunChleoc): Keeping ALT and MODE to make the transition easier. Remove for Build 20. | ||
78 | 528 | case SDLK_LALT: | 534 | case SDLK_LALT: |
79 | 529 | case SDLK_RALT: | 535 | case SDLK_RALT: |
80 | 530 | case SDLK_MODE: | 536 | case SDLK_MODE: |
81 | 531 | 537 | ||
82 | === modified file 'src/editor/tools/set_port_space_tool.cc' | |||
83 | --- src/editor/tools/set_port_space_tool.cc 2016-04-06 09:23:04 +0000 | |||
84 | +++ src/editor/tools/set_port_space_tool.cc 2016-04-07 14:03:59 +0000 | |||
85 | @@ -45,7 +45,7 @@ | |||
86 | 45 | EditorSetPortSpaceTool::EditorSetPortSpaceTool | 45 | EditorSetPortSpaceTool::EditorSetPortSpaceTool |
87 | 46 | (EditorUnsetPortSpaceTool & the_unset_tool) | 46 | (EditorUnsetPortSpaceTool & the_unset_tool) |
88 | 47 | : | 47 | : |
90 | 48 | EditorTool(the_unset_tool, *this) | 48 | EditorTool(the_unset_tool, the_unset_tool) |
91 | 49 | {} | 49 | {} |
92 | 50 | 50 | ||
93 | 51 | 51 | ||
94 | 52 | 52 | ||
95 | === modified file 'src/editor/ui_menus/tool_change_height_options_menu.cc' | |||
96 | --- src/editor/ui_menus/tool_change_height_options_menu.cc 2016-04-06 09:23:04 +0000 | |||
97 | +++ src/editor/ui_menus/tool_change_height_options_menu.cc 2016-04-07 14:03:59 +0000 | |||
98 | @@ -22,177 +22,74 @@ | |||
99 | 22 | #include <cstdio> | 22 | #include <cstdio> |
100 | 23 | #include <string> | 23 | #include <string> |
101 | 24 | 24 | ||
102 | 25 | #include <boost/format.hpp> | ||
103 | 26 | |||
104 | 25 | #include "base/i18n.h" | 27 | #include "base/i18n.h" |
105 | 26 | #include "editor/editorinteractive.h" | 28 | #include "editor/editorinteractive.h" |
106 | 27 | #include "editor/tools/increase_height_tool.h" | 29 | #include "editor/tools/increase_height_tool.h" |
107 | 28 | #include "editor/tools/set_height_tool.h" | 30 | #include "editor/tools/set_height_tool.h" |
108 | 29 | #include "graphic/graphic.h" | 31 | #include "graphic/graphic.h" |
109 | 30 | #include "logic/widelands_geometry.h" | 32 | #include "logic/widelands_geometry.h" |
110 | 31 | #include "ui_basic/button.h" | ||
111 | 32 | 33 | ||
112 | 33 | #define width 20 | ||
113 | 34 | #define height 20 | ||
114 | 35 | EditorToolChangeHeightOptionsMenu::EditorToolChangeHeightOptionsMenu | 34 | EditorToolChangeHeightOptionsMenu::EditorToolChangeHeightOptionsMenu |
115 | 36 | (EditorInteractive & parent, | 35 | (EditorInteractive & parent, |
116 | 37 | EditorIncreaseHeightTool & increase_tool, | 36 | EditorIncreaseHeightTool & increase_tool, |
117 | 38 | UI::UniqueWindow::Registry & registry) | 37 | UI::UniqueWindow::Registry & registry) |
118 | 39 | : | 38 | : |
121 | 40 | EditorToolOptionsMenu | 39 | EditorToolOptionsMenu(parent, registry, 350, 100, _("Height Tools Options")), |
120 | 41 | (parent, registry, 250, 135, _("Height Tools Options")), | ||
122 | 42 | increase_tool_(increase_tool), | 40 | increase_tool_(increase_tool), |
186 | 43 | change_by_label_ | 41 | box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()), |
187 | 44 | (this, | 42 | change_by_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
188 | 45 | hmargin(), vmargin(), get_inner_w() - 2 * hmargin(), height, | 43 | increase_tool_.get_change_by(), 1, MAX_FIELD_HEIGHT_DIFF, |
189 | 46 | _("Increase/Decrease Value"), UI::Align::kBottomCenter), | 44 | _("Increase/Decrease Value:"), UI::SpinBox::Units::kNone, |
190 | 47 | change_by_increase_ | 45 | g_gr->images().get("images/ui_basic/but1.png"), |
191 | 48 | (this, "incr_change_by", | 46 | UI::SpinBox::Type::kSmall), |
192 | 49 | get_inner_w() - hmargin() - width, | 47 | set_to_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
193 | 50 | change_by_label_.get_y() + change_by_label_.get_h() + spacing(), | 48 | increase_tool_.set_tool().get_interval().min, 0, MAX_FIELD_HEIGHT, |
194 | 51 | width, height, | 49 | _("Set Value:"), UI::SpinBox::Units::kNone, |
195 | 52 | g_gr->images().get("images/ui_basic/but1.png"), | 50 | g_gr->images().get("images/ui_basic/but1.png"), |
196 | 53 | g_gr->images().get("images/ui_basic/scrollbar_up.png"), | 51 | UI::SpinBox::Type::kSmall) |
134 | 54 | std::string(), | ||
135 | 55 | increase_tool.get_change_by() < MAX_FIELD_HEIGHT_DIFF), | ||
136 | 56 | change_by_decrease_ | ||
137 | 57 | (this, "decr_change_by", | ||
138 | 58 | hmargin(), | ||
139 | 59 | change_by_increase_.get_y(), | ||
140 | 60 | width, height, | ||
141 | 61 | g_gr->images().get("images/ui_basic/but1.png"), | ||
142 | 62 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), | ||
143 | 63 | std::string(), | ||
144 | 64 | 1 < increase_tool.get_change_by()), | ||
145 | 65 | change_by_value_ | ||
146 | 66 | (this, | ||
147 | 67 | change_by_increase_.get_x() + change_by_increase_.get_w() + | ||
148 | 68 | hspacing(), | ||
149 | 69 | change_by_increase_.get_y(), | ||
150 | 70 | change_by_decrease_.get_x() - hspacing() | ||
151 | 71 | - | ||
152 | 72 | (change_by_increase_.get_x() + change_by_increase_.get_w() + | ||
153 | 73 | hspacing()), | ||
154 | 74 | height, | ||
155 | 75 | UI::Align::kBottomCenter), | ||
156 | 76 | set_to_label_ | ||
157 | 77 | (this, | ||
158 | 78 | vmargin(), | ||
159 | 79 | change_by_increase_.get_y() + change_by_increase_.get_h() + | ||
160 | 80 | vspacing(), | ||
161 | 81 | get_inner_w() - 2 * hmargin(), height, | ||
162 | 82 | _("Set Value"), UI::Align::kBottomCenter), | ||
163 | 83 | set_to_increase_ | ||
164 | 84 | (this, "incr_set_to", | ||
165 | 85 | change_by_increase_.get_x(), | ||
166 | 86 | set_to_label_.get_y() + set_to_label_.get_h() + vspacing(), | ||
167 | 87 | width, height, | ||
168 | 88 | g_gr->images().get("images/ui_basic/but1.png"), | ||
169 | 89 | g_gr->images().get("images/ui_basic/scrollbar_up.png"), | ||
170 | 90 | std::string(), | ||
171 | 91 | increase_tool.set_tool().get_interval().min < MAX_FIELD_HEIGHT), | ||
172 | 92 | set_to_decrease_ | ||
173 | 93 | (this, "decr_set_to", | ||
174 | 94 | hmargin(), | ||
175 | 95 | set_to_increase_.get_y(), | ||
176 | 96 | width, height, | ||
177 | 97 | g_gr->images().get("images/ui_basic/but1.png"), | ||
178 | 98 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), | ||
179 | 99 | std::string(), | ||
180 | 100 | 0 < increase_tool.set_tool().get_interval().min), | ||
181 | 101 | set_to_value_ | ||
182 | 102 | (this, | ||
183 | 103 | change_by_value_.get_x(), set_to_increase_.get_y(), | ||
184 | 104 | change_by_value_.get_w(), height, | ||
185 | 105 | UI::Align::kBottomCenter) | ||
197 | 106 | { | 52 | { |
289 | 107 | change_by_increase_.sigclicked.connect | 53 | change_by_.set_tooltip( |
290 | 108 | (boost::bind | 54 | /** TRANSLATORS: Editor change height access keys. **/ |
291 | 109 | (&EditorToolChangeHeightOptionsMenu::clicked_change_by_increment, boost::ref(*this))); | 55 | (boost::format(_("Use %s to increase, %s to decrease")) |
292 | 110 | change_by_decrease_.sigclicked.connect | 56 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
293 | 111 | (boost::bind | 57 | % _("Click") |
294 | 112 | (&EditorToolChangeHeightOptionsMenu::clicked_change_by_decrement, boost::ref(*this))); | 58 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
295 | 113 | set_to_increase_.sigclicked.connect | 59 | % _("Shift + Click")).str()); |
296 | 114 | (boost::bind(&EditorToolChangeHeightOptionsMenu::clicked_setto_increment, boost::ref(*this))); | 60 | set_to_.set_tooltip( |
297 | 115 | set_to_decrease_.sigclicked.connect | 61 | /** TRANSLATORS: Editor set height access key. **/ |
298 | 116 | (boost::bind(&EditorToolChangeHeightOptionsMenu::clicked_setto_decrement, boost::ref(*this))); | 62 | (boost::format(_("Use %s to set to this value")) |
299 | 117 | 63 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ | |
300 | 118 | change_by_increase_.set_repeating(true); | 64 | % _("Ctrl + Click")).str()); |
301 | 119 | change_by_decrease_.set_repeating(true); | 65 | |
302 | 120 | set_to_increase_ .set_repeating(true); | 66 | change_by_.changed.connect |
303 | 121 | set_to_decrease_ .set_repeating(true); | 67 | (boost::bind |
304 | 122 | update(); | 68 | (&EditorToolChangeHeightOptionsMenu::update_change_by, boost::ref(*this))); |
305 | 123 | } | 69 | set_to_.changed.connect |
306 | 124 | 70 | (boost::bind | |
307 | 125 | 71 | (&EditorToolChangeHeightOptionsMenu::update_set_to, boost::ref(*this))); | |
308 | 126 | void EditorToolChangeHeightOptionsMenu::clicked_change_by_decrement() { | 72 | |
309 | 127 | int32_t change_by = increase_tool_.get_change_by(); | 73 | box_.add(&change_by_, UI::Align::kLeft); |
310 | 128 | assert(change_by == increase_tool_.decrease_tool().get_change_by()); | 74 | box_.add(&set_to_, UI::Align::kLeft); |
311 | 129 | assert(1 < change_by); | 75 | box_.set_size(get_inner_w() - 2 * hmargin(), change_by_.get_h() + set_to_.get_h() + vspacing()); |
312 | 130 | 76 | set_inner_size(box_.get_w() + 2 * hmargin(), box_.get_h() + 2 * vspacing()); | |
313 | 131 | --change_by; | 77 | } |
314 | 132 | 78 | ||
315 | 133 | increase_tool_ .set_change_by(change_by); | 79 | void EditorToolChangeHeightOptionsMenu::update_change_by() { |
316 | 134 | increase_tool_.decrease_tool().set_change_by(change_by); | 80 | int32_t change_by = change_by_.get_value(); |
317 | 135 | change_by_decrease_.set_enabled(1 < change_by); | 81 | assert(change_by > 0); |
318 | 136 | change_by_increase_.set_enabled(true); | 82 | assert(change_by <= MAX_FIELD_HEIGHT_DIFF); |
319 | 137 | select_correct_tool(); | 83 | |
320 | 138 | update(); | 84 | increase_tool_ .set_change_by(change_by); |
321 | 139 | } | 85 | increase_tool_.decrease_tool().set_change_by(change_by); |
322 | 140 | 86 | select_correct_tool(); | |
323 | 141 | 87 | } | |
324 | 142 | void EditorToolChangeHeightOptionsMenu::clicked_change_by_increment() { | 88 | |
325 | 143 | int32_t change_by = increase_tool_.get_change_by(); | 89 | void EditorToolChangeHeightOptionsMenu::update_set_to() { |
326 | 144 | assert(change_by == increase_tool_.decrease_tool().get_change_by()); | 90 | int32_t set_to = set_to_.get_value(); |
327 | 145 | assert(change_by < MAX_FIELD_HEIGHT_DIFF); | 91 | assert(set_to >= 0); |
328 | 146 | 92 | assert(set_to <= MAX_FIELD_HEIGHT); | |
329 | 147 | ++change_by; | 93 | increase_tool_.set_tool().set_interval(Widelands::HeightInterval(set_to, set_to)); |
330 | 148 | 94 | select_correct_tool(); | |
240 | 149 | increase_tool_ .set_change_by(change_by); | ||
241 | 150 | increase_tool_.decrease_tool().set_change_by(change_by); | ||
242 | 151 | change_by_decrease_.set_enabled(true); | ||
243 | 152 | change_by_increase_.set_enabled(change_by < MAX_FIELD_HEIGHT_DIFF); | ||
244 | 153 | select_correct_tool(); | ||
245 | 154 | update(); | ||
246 | 155 | } | ||
247 | 156 | |||
248 | 157 | |||
249 | 158 | void EditorToolChangeHeightOptionsMenu::clicked_setto_decrement() { | ||
250 | 159 | Widelands::Field::Height setto = | ||
251 | 160 | increase_tool_.set_tool().get_interval().min; | ||
252 | 161 | assert(setto == increase_tool_.set_tool().get_interval().max); | ||
253 | 162 | assert(0 < setto); | ||
254 | 163 | |||
255 | 164 | --setto; | ||
256 | 165 | |||
257 | 166 | increase_tool_.set_tool().set_interval | ||
258 | 167 | (Widelands::HeightInterval(setto, setto)); | ||
259 | 168 | set_to_decrease_.set_enabled(0 < setto); | ||
260 | 169 | set_to_increase_.set_enabled(true); | ||
261 | 170 | select_correct_tool(); | ||
262 | 171 | update(); | ||
263 | 172 | } | ||
264 | 173 | |||
265 | 174 | |||
266 | 175 | void EditorToolChangeHeightOptionsMenu::clicked_setto_increment() { | ||
267 | 176 | Widelands::Field::Height setto = | ||
268 | 177 | increase_tool_.set_tool().get_interval().min; | ||
269 | 178 | assert(setto == increase_tool_.set_tool().get_interval().max); | ||
270 | 179 | assert(setto < MAX_FIELD_HEIGHT); | ||
271 | 180 | |||
272 | 181 | ++setto; | ||
273 | 182 | |||
274 | 183 | increase_tool_.set_tool().set_interval | ||
275 | 184 | (Widelands::HeightInterval(setto, setto)); | ||
276 | 185 | set_to_decrease_.set_enabled(true); | ||
277 | 186 | set_to_increase_.set_enabled(setto < MAX_FIELD_HEIGHT); | ||
278 | 187 | select_correct_tool(); | ||
279 | 188 | update(); | ||
280 | 189 | } | ||
281 | 190 | |||
282 | 191 | |||
283 | 192 | /// Update all the textareas, so that they represent the correct values. | ||
284 | 193 | void EditorToolChangeHeightOptionsMenu::update() { | ||
285 | 194 | change_by_value_.set_text(std::to_string(increase_tool_.get_change_by())); | ||
286 | 195 | |||
287 | 196 | set_to_value_.set_text(std::to_string( | ||
288 | 197 | static_cast<unsigned int>(increase_tool_.set_tool().get_interval().min))); | ||
331 | 198 | } | 95 | } |
332 | 199 | 96 | ||
333 | === modified file 'src/editor/ui_menus/tool_change_height_options_menu.h' | |||
334 | --- src/editor/ui_menus/tool_change_height_options_menu.h 2016-04-06 09:23:04 +0000 | |||
335 | +++ src/editor/ui_menus/tool_change_height_options_menu.h 2016-04-07 14:03:59 +0000 | |||
336 | @@ -21,8 +21,8 @@ | |||
337 | 21 | #define WL_EDITOR_UI_MENUS_TOOL_CHANGE_HEIGHT_OPTIONS_MENU_H | 21 | #define WL_EDITOR_UI_MENUS_TOOL_CHANGE_HEIGHT_OPTIONS_MENU_H |
338 | 22 | 22 | ||
339 | 23 | #include "editor/ui_menus/tool_options_menu.h" | 23 | #include "editor/ui_menus/tool_options_menu.h" |
342 | 24 | #include "ui_basic/button.h" | 24 | #include "ui_basic/box.h" |
343 | 25 | #include "ui_basic/textarea.h" | 25 | #include "ui_basic/spinbox.h" |
344 | 26 | 26 | ||
345 | 27 | class EditorInteractive; | 27 | class EditorInteractive; |
346 | 28 | struct EditorIncreaseHeightTool; | 28 | struct EditorIncreaseHeightTool; |
347 | @@ -37,18 +37,12 @@ | |||
348 | 37 | 37 | ||
349 | 38 | private: | 38 | private: |
350 | 39 | EditorIncreaseHeightTool& increase_tool_; | 39 | EditorIncreaseHeightTool& increase_tool_; |
357 | 40 | UI::Textarea change_by_label_; | 40 | UI::Box box_; |
358 | 41 | UI::Button change_by_increase_, change_by_decrease_; | 41 | UI::SpinBox change_by_; |
359 | 42 | UI::Textarea change_by_value_; | 42 | UI::SpinBox set_to_; |
354 | 43 | UI::Textarea set_to_label_; | ||
355 | 44 | UI::Button set_to_increase_, set_to_decrease_; | ||
356 | 45 | UI::Textarea set_to_value_; | ||
360 | 46 | 43 | ||
366 | 47 | void clicked_change_by_decrement(); | 44 | void update_change_by(); |
367 | 48 | void clicked_change_by_increment(); | 45 | void update_set_to(); |
363 | 49 | void clicked_setto_decrement (); | ||
364 | 50 | void clicked_setto_increment (); | ||
365 | 51 | void update(); | ||
368 | 52 | }; | 46 | }; |
369 | 53 | 47 | ||
370 | 54 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_CHANGE_HEIGHT_OPTIONS_MENU_H | 48 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_CHANGE_HEIGHT_OPTIONS_MENU_H |
371 | 55 | 49 | ||
372 | === modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc' | |||
373 | --- src/editor/ui_menus/tool_change_resources_options_menu.cc 2016-04-06 09:23:04 +0000 | |||
374 | +++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2016-04-07 14:03:59 +0000 | |||
375 | @@ -22,6 +22,8 @@ | |||
376 | 22 | #include <cstdio> | 22 | #include <cstdio> |
377 | 23 | #include <string> | 23 | #include <string> |
378 | 24 | 24 | ||
379 | 25 | #include <boost/format.hpp> | ||
380 | 26 | |||
381 | 25 | #include "base/i18n.h" | 27 | #include "base/i18n.h" |
382 | 26 | #include "base/wexception.h" | 28 | #include "base/wexception.h" |
383 | 27 | #include "editor/editorinteractive.h" | 29 | #include "editor/editorinteractive.h" |
384 | @@ -33,11 +35,9 @@ | |||
385 | 33 | #include "logic/map_objects/world/world.h" | 35 | #include "logic/map_objects/world/world.h" |
386 | 34 | #include "logic/widelands.h" | 36 | #include "logic/widelands.h" |
387 | 35 | #include "logic/widelands_geometry.h" | 37 | #include "logic/widelands_geometry.h" |
388 | 36 | #include "ui_basic/button.h" | ||
389 | 37 | #include "wui/field_overlay_manager.h" | 38 | #include "wui/field_overlay_manager.h" |
390 | 38 | 39 | ||
393 | 39 | const static int BUTTON_WIDTH = 20; | 40 | constexpr int kMaxValue = 63; |
392 | 40 | const static int BUTTON_HEIGHT = 20; | ||
394 | 41 | 41 | ||
395 | 42 | inline EditorInteractive & EditorToolChangeResourcesOptionsMenu::eia() { | 42 | inline EditorInteractive & EditorToolChangeResourcesOptionsMenu::eia() { |
396 | 43 | return dynamic_cast<EditorInteractive&>(*get_parent()); | 43 | return dynamic_cast<EditorInteractive&>(*get_parent()); |
397 | @@ -50,178 +50,114 @@ | |||
398 | 50 | EditorIncreaseResourcesTool & increase_tool, | 50 | EditorIncreaseResourcesTool & increase_tool, |
399 | 51 | UI::UniqueWindow::Registry & registry) | 51 | UI::UniqueWindow::Registry & registry) |
400 | 52 | : | 52 | : |
458 | 53 | EditorToolOptionsMenu | 53 | EditorToolOptionsMenu(parent, registry, 350, 120, _("Resources")), |
459 | 54 | (parent, registry, 250, 120, _("Resources")), | 54 | increase_tool_(increase_tool), |
460 | 55 | change_by_label_ | 55 | box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()), |
461 | 56 | (this, | 56 | change_by_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
462 | 57 | hmargin(), vmargin(), get_inner_w() - 2 * hmargin(), BUTTON_HEIGHT, | 57 | increase_tool_.get_change_by(), 1, kMaxValue, |
463 | 58 | _("Increase/Decrease Value"), UI::Align::kBottomCenter), | 58 | _("Increase/Decrease Value:"), UI::SpinBox::Units::kNone, |
464 | 59 | change_by_increase_ | 59 | g_gr->images().get("images/ui_basic/but1.png"), |
465 | 60 | (this, "incr_change_by", | 60 | UI::SpinBox::Type::kSmall), |
466 | 61 | get_inner_w() - hmargin() - BUTTON_WIDTH, | 61 | set_to_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
467 | 62 | change_by_label_.get_y() + change_by_label_.get_h() + spacing(), | 62 | increase_tool_.set_tool().get_set_to(), 0, kMaxValue, |
468 | 63 | BUTTON_WIDTH, BUTTON_HEIGHT, | 63 | _("Set Value:"), UI::SpinBox::Units::kNone, |
469 | 64 | g_gr->images().get("images/ui_basic/but1.png"), | 64 | g_gr->images().get("images/ui_basic/but1.png"), |
470 | 65 | g_gr->images().get("images/ui_basic/scrollbar_up.png")), | 65 | UI::SpinBox::Type::kSmall), |
471 | 66 | change_by_decrease_ | 66 | resources_box_(&box_, 0, 0, UI::Box::Horizontal, 0, 0, 1), |
472 | 67 | (this, "decr_change_by", | 67 | cur_selection_(&box_, 0, 0, "", UI::Align::kCenter) |
416 | 68 | hmargin(), | ||
417 | 69 | change_by_increase_.get_y(), | ||
418 | 70 | BUTTON_WIDTH, BUTTON_HEIGHT, | ||
419 | 71 | g_gr->images().get("images/ui_basic/but1.png"), | ||
420 | 72 | g_gr->images().get("images/ui_basic/scrollbar_down.png")), | ||
421 | 73 | change_by_value_ | ||
422 | 74 | (this, | ||
423 | 75 | change_by_increase_.get_x() + change_by_increase_.get_w() + | ||
424 | 76 | hspacing(), | ||
425 | 77 | change_by_increase_.get_y(), | ||
426 | 78 | change_by_decrease_.get_x() - hspacing() | ||
427 | 79 | - | ||
428 | 80 | (change_by_increase_.get_x() + change_by_increase_.get_w() + | ||
429 | 81 | hspacing()), | ||
430 | 82 | BUTTON_HEIGHT, | ||
431 | 83 | UI::Align::kBottomCenter), | ||
432 | 84 | set_to_label_ | ||
433 | 85 | (this, | ||
434 | 86 | vmargin(), | ||
435 | 87 | change_by_increase_.get_y() + change_by_increase_.get_h() + vspacing(), | ||
436 | 88 | get_inner_w() - 2 * hmargin(), BUTTON_HEIGHT, | ||
437 | 89 | _("Set Value"), UI::Align::kBottomCenter), | ||
438 | 90 | set_to_increase_ | ||
439 | 91 | (this, "incr_set_to", | ||
440 | 92 | change_by_increase_.get_x(), | ||
441 | 93 | set_to_label_.get_y() + set_to_label_.get_h() + vspacing(), | ||
442 | 94 | BUTTON_WIDTH, BUTTON_HEIGHT, | ||
443 | 95 | g_gr->images().get("images/ui_basic/but1.png"), | ||
444 | 96 | g_gr->images().get("images/ui_basic/scrollbar_up.png")), | ||
445 | 97 | set_to_decrease_ | ||
446 | 98 | (this, "decr_set_to", | ||
447 | 99 | hmargin(), | ||
448 | 100 | set_to_increase_.get_y(), BUTTON_WIDTH, BUTTON_HEIGHT, | ||
449 | 101 | g_gr->images().get("images/ui_basic/but1.png"), | ||
450 | 102 | g_gr->images().get("images/ui_basic/scrollbar_down.png")), | ||
451 | 103 | set_to_value_ | ||
452 | 104 | (this, | ||
453 | 105 | change_by_value_.get_x(), set_to_increase_.get_y(), | ||
454 | 106 | change_by_value_.get_w(), BUTTON_HEIGHT, | ||
455 | 107 | UI::Align::kBottomCenter), | ||
456 | 108 | cur_selection_(this, 0, 0, _("Current Selection"), UI::Align::kBottomCenter), | ||
457 | 109 | increase_tool_(increase_tool) | ||
473 | 110 | { | 68 | { |
504 | 111 | change_by_increase_.sigclicked.connect | 69 | // Configure spin boxes |
505 | 112 | (boost::bind | 70 | change_by_.set_tooltip( |
506 | 113 | (&EditorToolChangeResourcesOptionsMenu::clicked_button, | 71 | /** TRANSLATORS: Editor change resources access keys. **/ |
507 | 114 | boost::ref(*this), | 72 | (boost::format(_("Use %s to increase, %s to decrease")) |
508 | 115 | Change_By_Increase)); | 73 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
509 | 116 | change_by_decrease_.sigclicked.connect | 74 | % _("Click") |
510 | 117 | (boost::bind | 75 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
511 | 118 | (&EditorToolChangeResourcesOptionsMenu::clicked_button, | 76 | % _("Shift + Click")).str()); |
512 | 119 | boost::ref(*this), | 77 | set_to_.set_tooltip( |
513 | 120 | Change_By_Decrease)); | 78 | /** TRANSLATORS: Editor set resources access key. **/ |
514 | 121 | set_to_increase_.sigclicked.connect | 79 | (boost::format(_("Use %s to set to this value")) |
515 | 122 | (boost::bind | 80 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
516 | 123 | (&EditorToolChangeResourcesOptionsMenu::clicked_button, | 81 | % _("Ctrl + Click")).str()); |
517 | 124 | boost::ref(*this), | 82 | |
518 | 125 | Set_To_Increase)); | 83 | change_by_.changed.connect |
519 | 126 | set_to_decrease_.sigclicked.connect | 84 | (boost::bind |
520 | 127 | (boost::bind | 85 | (&EditorToolChangeResourcesOptionsMenu::update_change_by, boost::ref(*this))); |
521 | 128 | (&EditorToolChangeResourcesOptionsMenu::clicked_button, | 86 | set_to_.changed.connect |
522 | 129 | boost::ref(*this), | 87 | (boost::bind |
523 | 130 | Set_To_Decrease)); | 88 | (&EditorToolChangeResourcesOptionsMenu::update_set_to, boost::ref(*this))); |
524 | 131 | 89 | ||
525 | 132 | change_by_increase_.set_repeating(true); | 90 | box_.add(&change_by_, UI::Align::kLeft); |
526 | 133 | change_by_decrease_.set_repeating(true); | 91 | box_.add(&set_to_, UI::Align::kLeft); |
527 | 134 | set_to_increase_ .set_repeating(true); | 92 | box_.set_size(get_inner_w() - 2 * hmargin(), change_by_.get_h() + set_to_.get_h() + vspacing()); |
528 | 135 | set_to_decrease_ .set_repeating(true); | 93 | |
529 | 136 | const Widelands::World & world = parent.egbase().world(); | 94 | // Add resource buttons |
530 | 137 | Widelands::DescriptionIndex const nr_resources = world.get_nr_resources(); | 95 | const Widelands::World& world = parent.egbase().world(); |
531 | 138 | 96 | const Widelands::DescriptionIndex nr_resources = world.get_nr_resources(); | |
532 | 139 | // Find the maximal width and height for the resource pictures. | 97 | |
503 | 140 | int resource_pic_max_width = 0, resource_pic_max_height = 0; | ||
533 | 141 | for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) { | 98 | for (Widelands::DescriptionIndex i = 0; i < nr_resources; ++i) { |
537 | 142 | const Image* pic = g_gr->images().get(world.get_resource(i)->representative_image()); | 99 | const Widelands::ResourceDescription& resource = *world.get_resource(i); |
538 | 143 | resource_pic_max_width = std::max(resource_pic_max_width, pic->width()); | 100 | radiogroup_.add_button |
539 | 144 | resource_pic_max_height = std::max(resource_pic_max_height, pic->height()); | 101 | (&resources_box_, |
540 | 102 | Point(0, 0), | ||
541 | 103 | g_gr->images().get(resource.representative_image()), | ||
542 | 104 | resource.descname()); | ||
543 | 105 | resources_box_.add(radiogroup_.get_first_button(), UI::Align::kLeft, false, true); | ||
544 | 145 | } | 106 | } |
545 | 146 | 107 | ||
550 | 147 | const uint16_t resources_in_row = | 108 | box_.add_space(vspacing()); |
551 | 148 | (get_inner_w() - 2 * hmargin() + spacing()) | 109 | box_.add(&resources_box_, UI::Align::kLeft, true); |
552 | 149 | / | 110 | box_.set_size(box_.get_w(), box_.get_h() + 4 * vspacing() + resources_box_.get_h()); |
553 | 150 | (resource_pic_max_width + spacing()); | 111 | |
554 | 112 | radiogroup_.set_state(increase_tool_.get_cur_res()); | ||
555 | 151 | 113 | ||
556 | 152 | radiogroup_.changed.connect | 114 | radiogroup_.changed.connect |
558 | 153 | (boost::bind(&EditorToolChangeResourcesOptionsMenu::selected, this)); | 115 | (boost::bind(&EditorToolChangeResourcesOptionsMenu::change_resource, this)); |
559 | 154 | radiogroup_.clicked.connect | 116 | radiogroup_.clicked.connect |
587 | 155 | (boost::bind(&EditorToolChangeResourcesOptionsMenu::selected, this)); | 117 | (boost::bind(&EditorToolChangeResourcesOptionsMenu::change_resource, this)); |
588 | 156 | 118 | ||
589 | 157 | uint16_t cur_x = 0; | 119 | // Add label |
590 | 158 | Point pos | 120 | cur_selection_.set_fixed_width(box_.get_inner_w()); |
591 | 159 | (hmargin(), set_to_value_.get_y() + set_to_value_.get_h() + vspacing()); | 121 | box_.add(&cur_selection_, UI::Align::kLeft); |
592 | 160 | for | 122 | |
593 | 161 | (Widelands::DescriptionIndex i = 0; | 123 | box_.set_size(box_.get_w(), box_.get_h() + vspacing() + cur_selection_.get_h()); |
594 | 162 | i < nr_resources; | 124 | set_inner_size(get_inner_w(), box_.get_h() + 1 * vmargin()); |
568 | 163 | pos.x += resource_pic_max_width + hspacing(), ++cur_x, ++i) | ||
569 | 164 | { | ||
570 | 165 | if (cur_x == resources_in_row) { | ||
571 | 166 | cur_x = 0; | ||
572 | 167 | pos.x = hmargin(); | ||
573 | 168 | pos.y += resource_pic_max_height + vspacing(); | ||
574 | 169 | } | ||
575 | 170 | radiogroup_.add_button | ||
576 | 171 | (this, | ||
577 | 172 | pos, | ||
578 | 173 | g_gr->images().get(world.get_resource(i)->representative_image())); | ||
579 | 174 | } | ||
580 | 175 | pos.y += resource_pic_max_height + vspacing(); | ||
581 | 176 | |||
582 | 177 | set_inner_size(get_inner_w(), pos.y + cur_selection_.get_h() + vmargin()); | ||
583 | 178 | cur_selection_.set_pos(Point(get_inner_w() / 2, pos.y + hspacing())); | ||
584 | 179 | |||
585 | 180 | radiogroup_.set_state(increase_tool_.get_cur_res()); | ||
586 | 181 | |||
595 | 182 | update(); | 125 | update(); |
596 | 183 | } | 126 | } |
597 | 184 | 127 | ||
615 | 185 | 128 | void EditorToolChangeResourcesOptionsMenu::update_change_by() { | |
616 | 186 | void EditorToolChangeResourcesOptionsMenu::clicked_button(Button const n) | 129 | int32_t change_by = change_by_.get_value(); |
617 | 187 | { | 130 | assert(change_by > 0); |
618 | 188 | assert | 131 | assert(change_by <= kMaxValue); |
602 | 189 | (increase_tool_.get_change_by() | ||
603 | 190 | == | ||
604 | 191 | increase_tool_.decrease_tool().get_change_by()); | ||
605 | 192 | |||
606 | 193 | int32_t change_by = increase_tool_.get_change_by(); | ||
607 | 194 | int32_t set_to = increase_tool_.set_tool().get_set_to(); | ||
608 | 195 | |||
609 | 196 | switch (n) { | ||
610 | 197 | case Change_By_Increase: change_by += change_by < 63; break; | ||
611 | 198 | case Change_By_Decrease: change_by -= 1 < change_by; break; | ||
612 | 199 | case Set_To_Increase: set_to += set_to < 63; break; | ||
613 | 200 | case Set_To_Decrease: set_to -= 0 < set_to; | ||
614 | 201 | } | ||
619 | 202 | increase_tool_.set_change_by(change_by); | 132 | increase_tool_.set_change_by(change_by); |
620 | 203 | increase_tool_.decrease_tool().set_change_by(change_by); | 133 | increase_tool_.decrease_tool().set_change_by(change_by); |
621 | 134 | select_correct_tool(); | ||
622 | 135 | } | ||
623 | 136 | |||
624 | 137 | void EditorToolChangeResourcesOptionsMenu::update_set_to() { | ||
625 | 138 | int32_t set_to = set_to_.get_value(); | ||
626 | 139 | assert(set_to >= 0); | ||
627 | 140 | assert(set_to <= kMaxValue); | ||
628 | 204 | increase_tool_.set_tool().set_set_to(set_to); | 141 | increase_tool_.set_tool().set_set_to(set_to); |
629 | 205 | |||
630 | 206 | select_correct_tool(); | 142 | select_correct_tool(); |
631 | 207 | update(); | ||
632 | 208 | } | 143 | } |
633 | 209 | 144 | ||
634 | 145 | |||
635 | 210 | /** | 146 | /** |
636 | 211 | * called when a resource has been selected | 147 | * called when a resource has been selected |
637 | 212 | */ | 148 | */ |
640 | 213 | void EditorToolChangeResourcesOptionsMenu::selected() { | 149 | void EditorToolChangeResourcesOptionsMenu::change_resource() { |
641 | 214 | const int32_t resIx = radiogroup_.get_state(); | 150 | const int32_t resource_index = radiogroup_.get_state(); |
642 | 215 | 151 | ||
646 | 216 | increase_tool_.set_tool().set_cur_res(resIx); | 152 | increase_tool_.set_tool().set_cur_res(resource_index); |
647 | 217 | increase_tool_.set_cur_res(resIx); | 153 | increase_tool_.set_cur_res(resource_index); |
648 | 218 | increase_tool_.decrease_tool().set_cur_res(resIx); | 154 | increase_tool_.decrease_tool().set_cur_res(resource_index); |
649 | 219 | 155 | ||
650 | 220 | Widelands::EditorGameBase& egbase = eia().egbase(); | 156 | Widelands::EditorGameBase& egbase = eia().egbase(); |
651 | 221 | Widelands::Map & map = egbase.map(); | 157 | Widelands::Map & map = egbase.map(); |
652 | 222 | eia().mutable_field_overlay_manager()->register_overlay_callback_function( | 158 | eia().mutable_field_overlay_manager()->register_overlay_callback_function( |
655 | 223 | [resIx, &map, &egbase](const Widelands::TCoords<Widelands::FCoords>& coords) -> uint32_t { | 159 | [resource_index, &map, &egbase](const Widelands::TCoords<Widelands::FCoords>& coords) -> uint32_t { |
656 | 224 | if (map.is_resource_valid(egbase.world(), coords, resIx)) { | 160 | if (map.is_resource_valid(egbase.world(), coords, resource_index)) { |
657 | 225 | return coords.field->nodecaps(); | 161 | return coords.field->nodecaps(); |
658 | 226 | } | 162 | } |
659 | 227 | return 0; | 163 | return 0; |
660 | @@ -229,7 +165,6 @@ | |||
661 | 229 | 165 | ||
662 | 230 | map.recalc_whole_map(egbase.world()); | 166 | map.recalc_whole_map(egbase.world()); |
663 | 231 | select_correct_tool(); | 167 | select_correct_tool(); |
664 | 232 | |||
665 | 233 | update(); | 168 | update(); |
666 | 234 | } | 169 | } |
667 | 235 | 170 | ||
668 | @@ -237,26 +172,7 @@ | |||
669 | 237 | * Update all the textareas, so that they represent the correct values | 172 | * Update all the textareas, so that they represent the correct values |
670 | 238 | */ | 173 | */ |
671 | 239 | void EditorToolChangeResourcesOptionsMenu::update() { | 174 | void EditorToolChangeResourcesOptionsMenu::update() { |
672 | 240 | |||
673 | 241 | change_by_value_.set_text(std::to_string(increase_tool_.get_change_by())); | ||
674 | 242 | |||
675 | 243 | set_to_value_.set_text(std::to_string( | ||
676 | 244 | static_cast<unsigned int>(increase_tool_.set_tool().get_set_to()))); | ||
677 | 245 | |||
678 | 246 | cur_selection_.set_text | 175 | cur_selection_.set_text |
694 | 247 | (eia().egbase().world().get_resource(increase_tool_.set_tool().get_cur_res())->descname()); | 176 | ((boost::format(_("Current: %s")) |
695 | 248 | cur_selection_.set_pos | 177 | % eia().egbase().world().get_resource(increase_tool_.set_tool().get_cur_res())->descname()).str()); |
681 | 249 | (Point | ||
682 | 250 | ((get_inner_w() - cur_selection_.get_w()) / 2, get_inner_h() - 20)); | ||
683 | 251 | |||
684 | 252 | { | ||
685 | 253 | int32_t const change_by = increase_tool_.get_change_by(); | ||
686 | 254 | change_by_decrease_.set_enabled(1 < change_by); | ||
687 | 255 | change_by_increase_.set_enabled (change_by < 63); | ||
688 | 256 | } | ||
689 | 257 | { | ||
690 | 258 | int32_t const set_to = increase_tool_.set_tool().get_set_to(); | ||
691 | 259 | set_to_decrease_ .set_enabled(0 < set_to); | ||
692 | 260 | set_to_increase_ .set_enabled (set_to < 63); | ||
693 | 261 | } | ||
696 | 262 | } | 178 | } |
697 | 263 | 179 | ||
698 | === modified file 'src/editor/ui_menus/tool_change_resources_options_menu.h' | |||
699 | --- src/editor/ui_menus/tool_change_resources_options_menu.h 2016-04-06 09:23:04 +0000 | |||
700 | +++ src/editor/ui_menus/tool_change_resources_options_menu.h 2016-04-07 14:03:59 +0000 | |||
701 | @@ -21,8 +21,9 @@ | |||
702 | 21 | #define WL_EDITOR_UI_MENUS_TOOL_CHANGE_RESOURCES_OPTIONS_MENU_H | 21 | #define WL_EDITOR_UI_MENUS_TOOL_CHANGE_RESOURCES_OPTIONS_MENU_H |
703 | 22 | 22 | ||
704 | 23 | #include "editor/ui_menus/tool_options_menu.h" | 23 | #include "editor/ui_menus/tool_options_menu.h" |
706 | 24 | #include "ui_basic/button.h" | 24 | #include "ui_basic/box.h" |
707 | 25 | #include "ui_basic/radiobutton.h" | 25 | #include "ui_basic/radiobutton.h" |
708 | 26 | #include "ui_basic/spinbox.h" | ||
709 | 26 | #include "ui_basic/textarea.h" | 27 | #include "ui_basic/textarea.h" |
710 | 27 | 28 | ||
711 | 28 | class EditorInteractive; | 29 | class EditorInteractive; |
712 | @@ -38,22 +39,18 @@ | |||
713 | 38 | 39 | ||
714 | 39 | private: | 40 | private: |
715 | 40 | EditorInteractive & eia(); | 41 | EditorInteractive & eia(); |
722 | 41 | void selected(); | 42 | void change_resource(); |
723 | 42 | enum Button { | 43 | void update_change_by(); |
724 | 43 | Change_By_Increase, Change_By_Decrease, | 44 | void update_set_to(); |
719 | 44 | Set_To_Increase, Set_To_Decrease | ||
720 | 45 | }; | ||
721 | 46 | void clicked_button(Button); | ||
725 | 47 | void update(); | 45 | void update(); |
732 | 48 | UI::Textarea change_by_label_; | 46 | |
733 | 49 | UI::Button change_by_increase_, change_by_decrease_; | 47 | EditorIncreaseResourcesTool& increase_tool_; |
734 | 50 | UI::Textarea change_by_value_; | 48 | UI::Box box_; |
735 | 51 | UI::Textarea set_to_label_; | 49 | UI::SpinBox change_by_; |
736 | 52 | UI::Button set_to_increase_, set_to_decrease_; | 50 | UI::SpinBox set_to_; |
737 | 53 | UI::Textarea set_to_value_; | 51 | UI::Box resources_box_; |
738 | 52 | UI::Radiogroup radiogroup_; | ||
739 | 54 | UI::Textarea cur_selection_; | 53 | UI::Textarea cur_selection_; |
740 | 55 | UI::Radiogroup radiogroup_; | ||
741 | 56 | EditorIncreaseResourcesTool& increase_tool_; | ||
742 | 57 | }; | 54 | }; |
743 | 58 | 55 | ||
744 | 59 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_CHANGE_RESOURCES_OPTIONS_MENU_H | 56 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_CHANGE_RESOURCES_OPTIONS_MENU_H |
745 | 60 | 57 | ||
746 | === modified file 'src/editor/ui_menus/tool_noise_height_options_menu.cc' | |||
747 | --- src/editor/ui_menus/tool_noise_height_options_menu.cc 2016-04-06 09:23:04 +0000 | |||
748 | +++ src/editor/ui_menus/tool_noise_height_options_menu.cc 2016-04-07 14:03:59 +0000 | |||
749 | @@ -30,236 +30,114 @@ | |||
750 | 30 | #include "editor/tools/noise_height_tool.h" | 30 | #include "editor/tools/noise_height_tool.h" |
751 | 31 | #include "graphic/graphic.h" | 31 | #include "graphic/graphic.h" |
752 | 32 | #include "logic/widelands_geometry.h" | 32 | #include "logic/widelands_geometry.h" |
753 | 33 | #include "ui_basic/textarea.h" | ||
754 | 33 | 34 | ||
755 | 34 | 35 | ||
756 | 35 | using Widelands::Field; | 36 | using Widelands::Field; |
757 | 36 | 37 | ||
758 | 37 | #define width 20 | ||
759 | 38 | #define height 20 | ||
760 | 39 | EditorToolNoiseHeightOptionsMenu::EditorToolNoiseHeightOptionsMenu | 38 | EditorToolNoiseHeightOptionsMenu::EditorToolNoiseHeightOptionsMenu |
761 | 40 | (EditorInteractive & parent, | 39 | (EditorInteractive & parent, |
762 | 41 | EditorNoiseHeightTool & noise_tool, | 40 | EditorNoiseHeightTool & noise_tool, |
763 | 42 | UI::UniqueWindow::Registry & registry) | 41 | UI::UniqueWindow::Registry & registry) |
764 | 43 | : | 42 | : |
767 | 44 | EditorToolOptionsMenu | 43 | EditorToolOptionsMenu(parent, registry, 300, 120, _("Noise Height Options")), |
766 | 45 | (parent, registry, 250, 3 * height + 4 * vspacing() + 2 * vmargin(), _("Noise Height Options")), | ||
768 | 46 | noise_tool_(noise_tool), | 44 | noise_tool_(noise_tool), |
841 | 47 | lower_label_ | 45 | box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()), |
842 | 48 | (this, | 46 | lower_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
843 | 49 | hmargin(), | 47 | noise_tool_.get_interval().min, 1, MAX_FIELD_HEIGHT, |
844 | 50 | vmargin(), | 48 | _("Minimum Height:"), UI::SpinBox::Units::kNone, |
845 | 51 | width, height, | 49 | g_gr->images().get("images/ui_basic/but1.png"), |
846 | 52 | UI::Align::kLeft), | 50 | UI::SpinBox::Type::kSmall), |
847 | 53 | upper_label_ | 51 | upper_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
848 | 54 | (this, | 52 | noise_tool_.get_interval().max, 0, MAX_FIELD_HEIGHT, |
849 | 55 | hmargin(), | 53 | _("Maximum Height:"), UI::SpinBox::Units::kNone, |
850 | 56 | lower_label_.get_y() + lower_label_.get_h() + 2 * vspacing(), | 54 | g_gr->images().get("images/ui_basic/but1.png"), |
851 | 57 | width, height, | 55 | UI::SpinBox::Type::kSmall), |
852 | 58 | UI::Align::kLeft), | 56 | set_to_(&box_, 0, 0, get_inner_w() - 2 * hmargin(), 80, |
853 | 59 | lower_decrease_ | 57 | noise_tool_.set_tool().get_interval().min, 0, MAX_FIELD_HEIGHT, |
854 | 60 | (this, "decr_lower", | 58 | _("Set Value:"), UI::SpinBox::Units::kNone, |
855 | 61 | get_inner_w() - 2 * width - hspacing(), | 59 | g_gr->images().get("images/ui_basic/but1.png"), |
856 | 62 | lower_label_.get_y(), | 60 | UI::SpinBox::Type::kSmall) |
785 | 63 | width, height, | ||
786 | 64 | g_gr->images().get("images/ui_basic/but0.png"), | ||
787 | 65 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), | ||
788 | 66 | std::string(), | ||
789 | 67 | 0 < noise_tool.get_interval().min), | ||
790 | 68 | lower_increase_ | ||
791 | 69 | (this, "incr_lower", | ||
792 | 70 | get_inner_w() - width - hspacing(), | ||
793 | 71 | lower_label_.get_y(), | ||
794 | 72 | width, height, | ||
795 | 73 | g_gr->images().get("images/ui_basic/but0.png"), | ||
796 | 74 | g_gr->images().get("images/ui_basic/scrollbar_up.png"), | ||
797 | 75 | std::string(), | ||
798 | 76 | noise_tool.get_interval().min < MAX_FIELD_HEIGHT), | ||
799 | 77 | upper_decrease_ | ||
800 | 78 | (this, "decr_upper", | ||
801 | 79 | get_inner_w() - 2 * width - hspacing(), | ||
802 | 80 | upper_label_.get_y(), | ||
803 | 81 | width, height, | ||
804 | 82 | g_gr->images().get("images/ui_basic/but0.png"), | ||
805 | 83 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), | ||
806 | 84 | std::string(), | ||
807 | 85 | 0 < noise_tool.get_interval().max), | ||
808 | 86 | upper_increase_ | ||
809 | 87 | (this, "incr_upper", | ||
810 | 88 | get_inner_w() - width - hspacing(), | ||
811 | 89 | upper_label_.get_y(), | ||
812 | 90 | width, height, | ||
813 | 91 | g_gr->images().get("images/ui_basic/but0.png"), | ||
814 | 92 | g_gr->images().get("images/ui_basic/scrollbar_up.png"), | ||
815 | 93 | std::string(), | ||
816 | 94 | noise_tool.get_interval().max < MAX_FIELD_HEIGHT), | ||
817 | 95 | set_label_ | ||
818 | 96 | (this, | ||
819 | 97 | hmargin(), | ||
820 | 98 | upper_label_.get_y() + upper_label_.get_h() + 2 * vspacing(), | ||
821 | 99 | width, height, | ||
822 | 100 | UI::Align::kLeft), | ||
823 | 101 | setto_decrease_ | ||
824 | 102 | (this, "decr_set_to", | ||
825 | 103 | get_inner_w() - 2 * width - hspacing(), | ||
826 | 104 | set_label_.get_y(), | ||
827 | 105 | width, height, | ||
828 | 106 | g_gr->images().get("images/ui_basic/but1.png"), | ||
829 | 107 | g_gr->images().get("images/ui_basic/scrollbar_down.png"), | ||
830 | 108 | std::string(), | ||
831 | 109 | 0 < noise_tool.set_tool().get_interval().min), | ||
832 | 110 | setto_increase_ | ||
833 | 111 | (this, "incr_set_to", | ||
834 | 112 | get_inner_w() - width - hspacing(), | ||
835 | 113 | set_label_.get_y(), | ||
836 | 114 | width, height, | ||
837 | 115 | g_gr->images().get("images/ui_basic/but1.png"), | ||
838 | 116 | g_gr->images().get("images/ui_basic/scrollbar_up.png"), | ||
839 | 117 | std::string(), | ||
840 | 118 | noise_tool.set_tool().get_interval().max < MAX_FIELD_HEIGHT) | ||
857 | 119 | { | 61 | { |
1003 | 120 | lower_increase_.sigclicked.connect | 62 | lower_.set_tooltip( |
1004 | 121 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_lower_increase, boost::ref(*this))); | 63 | /** TRANSLATORS: Editor noise height access keys. **/ |
1005 | 122 | lower_decrease_.sigclicked.connect | 64 | _("Click to set the height to a random value within the specified range")); |
1006 | 123 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_lower_decrease, boost::ref(*this))); | 65 | upper_.set_tooltip( |
1007 | 124 | upper_increase_.sigclicked.connect | 66 | /** TRANSLATORS: Editor noise height access keys. **/ |
1008 | 125 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_upper_increase, boost::ref(*this))); | 67 | _("Click to set the height to a random value within the specified range")); |
1009 | 126 | upper_decrease_.sigclicked.connect | 68 | set_to_.set_tooltip( |
1010 | 127 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_upper_decrease, boost::ref(*this))); | 69 | /** TRANSLATORS: Editor set hoise height access keys. **/ |
1011 | 128 | setto_increase_.sigclicked.connect | 70 | (boost::format(_("Use %s to set to this value")) |
1012 | 129 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_setto_increase, boost::ref(*this))); | 71 | /** TRANSLATORS: This is an access key combination. Localize, but do not change the key. **/ |
1013 | 130 | setto_decrease_.sigclicked.connect | 72 | % _("Ctrl + Click")).str()); |
1014 | 131 | (boost::bind(&EditorToolNoiseHeightOptionsMenu::clicked_setto_decrease, boost::ref(*this))); | 73 | |
1015 | 132 | 74 | lower_.changed.connect | |
1016 | 133 | lower_increase_.set_repeating(true); | 75 | (boost::bind |
1017 | 134 | lower_decrease_.set_repeating(true); | 76 | (&EditorToolNoiseHeightOptionsMenu::update_lower, boost::ref(*this))); |
1018 | 135 | upper_increase_.set_repeating(true); | 77 | upper_.changed.connect |
1019 | 136 | upper_decrease_.set_repeating(true); | 78 | (boost::bind |
1020 | 137 | setto_increase_.set_repeating(true); | 79 | (&EditorToolNoiseHeightOptionsMenu::update_upper, boost::ref(*this))); |
1021 | 138 | setto_decrease_.set_repeating(true); | 80 | set_to_.changed.connect |
1022 | 139 | update(); | 81 | (boost::bind |
1023 | 140 | } | 82 | (&EditorToolNoiseHeightOptionsMenu::update_set_to, boost::ref(*this))); |
1024 | 141 | 83 | ||
1025 | 142 | /** | 84 | UI::Textarea* label = new UI::Textarea(&box_, 0, 0, 0, 0, _("Random Height"), UI::Align::kCenter); |
1026 | 143 | * Update all textareas | 85 | label->set_fixed_width(get_inner_w() - 2 * hmargin()); |
1027 | 144 | */ | 86 | box_.add(label, UI::Align::kLeft); |
1028 | 145 | void EditorToolNoiseHeightOptionsMenu::update() { | 87 | box_.add(&upper_, UI::Align::kLeft); |
1029 | 146 | const Widelands::HeightInterval height_interval = noise_tool_.get_interval(); | 88 | box_.add(&lower_, UI::Align::kLeft); |
1030 | 147 | 89 | ||
1031 | 148 | lower_label_.set_text((boost::format(_("Minimum: %u")) | 90 | box_.add_space(2 * vspacing()); |
1032 | 149 | % static_cast<unsigned int>(height_interval.min)).str()); | 91 | label = new UI::Textarea(&box_, 0, 0, 0, 0, _("Fixed Height"), UI::Align::kCenter); |
1033 | 150 | 92 | label->set_fixed_width(get_inner_w() - 2 * hmargin()); | |
1034 | 151 | upper_label_.set_text((boost::format(_("Maximum: %u")) | 93 | box_.add(label, UI::Align::kLeft); |
1035 | 152 | % static_cast<unsigned int>(height_interval.max)).str()); | 94 | box_.add(&set_to_, UI::Align::kLeft); |
1036 | 153 | 95 | ||
1037 | 154 | set_label_.set_text((boost::format(_("Set value: %u")) | 96 | box_.set_size(get_inner_w() - 2 * hmargin(), |
1038 | 155 | % static_cast<unsigned int>(noise_tool_.set_tool().get_interval().min)).str()); | 97 | upper_.get_h() + lower_.get_h() + set_to_.get_h() + 2 * label->get_h() + 7 * vspacing()); |
1039 | 156 | 98 | ||
1040 | 157 | select_correct_tool(); | 99 | set_inner_size(box_.get_w() + 2 * hmargin(), box_.get_h() + 2 * vspacing()); |
1041 | 158 | } | 100 | } |
1042 | 159 | 101 | ||
1043 | 160 | 102 | ||
1044 | 161 | void EditorToolNoiseHeightOptionsMenu::clicked_lower_decrease() { | 103 | void EditorToolNoiseHeightOptionsMenu::update_lower() { |
1045 | 162 | Widelands::HeightInterval height_interval = noise_tool_.get_interval(); | 104 | int32_t upper = upper_.get_value(); |
1046 | 163 | 105 | int32_t lower = lower_.get_value(); | |
1047 | 164 | assert(height_interval.valid()); | 106 | // Make sure that upper increases if necessary |
1048 | 165 | assert(0 < height_interval.min); | 107 | upper = std::max(lower, upper); |
1049 | 166 | 108 | lower = std::min(lower, upper); | |
1050 | 167 | --height_interval.min; | 109 | update_interval(lower, upper); |
1051 | 168 | 110 | } | |
1052 | 169 | assert(height_interval.valid()); | 111 | |
1053 | 170 | 112 | ||
1054 | 171 | noise_tool_.set_interval(height_interval); | 113 | void EditorToolNoiseHeightOptionsMenu::update_upper() { |
1055 | 172 | lower_decrease_.set_enabled(0 < height_interval.min); | 114 | int32_t upper = upper_.get_value(); |
1056 | 173 | lower_increase_.set_enabled(true); | 115 | int32_t lower = lower_.get_value(); |
1057 | 174 | update(); | 116 | // Make sure that lower decreases if necessary |
1058 | 175 | } | 117 | lower = std::min(lower, upper); |
1059 | 176 | 118 | upper = std::max(lower, upper); | |
1060 | 177 | 119 | update_interval(lower, upper); | |
1061 | 178 | void EditorToolNoiseHeightOptionsMenu::clicked_lower_increase() { | 120 | } |
1062 | 179 | Widelands::HeightInterval height_interval = noise_tool_.get_interval(); | 121 | |
1063 | 180 | 122 | void EditorToolNoiseHeightOptionsMenu::update_interval(int32_t lower, int32_t upper) { | |
1064 | 181 | assert(height_interval.valid()); | 123 | assert(lower >= 0); |
1065 | 182 | assert(height_interval.min < MAX_FIELD_HEIGHT); | 124 | assert(lower <= MAX_FIELD_HEIGHT); |
1066 | 183 | 125 | assert(upper >= 0); | |
1067 | 184 | ++height_interval.min; | 126 | assert(upper <= MAX_FIELD_HEIGHT); |
1068 | 185 | height_interval.max = std::max(height_interval.min, height_interval.max); | 127 | |
1069 | 186 | 128 | Widelands::HeightInterval height_interval(lower, upper); | |
1070 | 187 | assert(height_interval.valid()); | 129 | assert(height_interval.valid()); |
1071 | 188 | 130 | ||
1072 | 189 | noise_tool_.set_interval(height_interval); | 131 | lower_.set_value(height_interval.min); |
1073 | 190 | lower_decrease_.set_enabled(true); | 132 | upper_.set_value(height_interval.max); |
1074 | 191 | lower_increase_.set_enabled(height_interval.min < MAX_FIELD_HEIGHT); | 133 | noise_tool_.set_interval(height_interval); |
1075 | 192 | upper_decrease_.set_enabled(true); | 134 | select_correct_tool(); |
1076 | 193 | upper_increase_.set_enabled(height_interval.max < MAX_FIELD_HEIGHT); | 135 | } |
1077 | 194 | 136 | ||
1078 | 195 | update(); | 137 | void EditorToolNoiseHeightOptionsMenu::update_set_to() { |
1079 | 196 | } | 138 | int32_t set_to = set_to_.get_value(); |
1080 | 197 | 139 | assert(set_to >= 0); | |
1081 | 198 | 140 | assert(set_to <= MAX_FIELD_HEIGHT); | |
1082 | 199 | void EditorToolNoiseHeightOptionsMenu::clicked_upper_decrease() { | 141 | noise_tool_.set_tool().set_interval(Widelands::HeightInterval(set_to, set_to)); |
1083 | 200 | Widelands::HeightInterval height_interval = noise_tool_.get_interval(); | 142 | select_correct_tool(); |
939 | 201 | |||
940 | 202 | assert(height_interval.valid()); | ||
941 | 203 | assert(0 < noise_tool_.get_interval().max); | ||
942 | 204 | |||
943 | 205 | --height_interval.max; | ||
944 | 206 | height_interval.min = std::min(height_interval.min, height_interval.max); | ||
945 | 207 | |||
946 | 208 | assert(height_interval.valid()); | ||
947 | 209 | |||
948 | 210 | noise_tool_.set_interval(height_interval); | ||
949 | 211 | lower_decrease_.set_enabled(0 < height_interval.min); | ||
950 | 212 | lower_increase_.set_enabled(true); | ||
951 | 213 | upper_decrease_.set_enabled(0 < height_interval.max); | ||
952 | 214 | upper_increase_.set_enabled(true); | ||
953 | 215 | update(); | ||
954 | 216 | } | ||
955 | 217 | |||
956 | 218 | |||
957 | 219 | void EditorToolNoiseHeightOptionsMenu::clicked_upper_increase() { | ||
958 | 220 | Widelands::HeightInterval height_interval = noise_tool_.get_interval(); | ||
959 | 221 | |||
960 | 222 | assert(noise_tool_.get_interval().valid()); | ||
961 | 223 | assert(noise_tool_.get_interval().max < MAX_FIELD_HEIGHT); | ||
962 | 224 | |||
963 | 225 | ++height_interval.max; | ||
964 | 226 | |||
965 | 227 | assert(noise_tool_.get_interval().valid()); | ||
966 | 228 | |||
967 | 229 | noise_tool_.set_interval(height_interval); | ||
968 | 230 | upper_decrease_.set_enabled(true); | ||
969 | 231 | upper_increase_.set_enabled(height_interval.max < MAX_FIELD_HEIGHT); | ||
970 | 232 | update(); | ||
971 | 233 | } | ||
972 | 234 | |||
973 | 235 | |||
974 | 236 | void EditorToolNoiseHeightOptionsMenu::clicked_setto_decrease() { | ||
975 | 237 | EditorSetHeightTool & set_tool = noise_tool_.set_tool(); | ||
976 | 238 | Field::Height h = set_tool.get_interval().min; | ||
977 | 239 | |||
978 | 240 | assert(h == set_tool.get_interval().max); | ||
979 | 241 | assert(0 < h); | ||
980 | 242 | |||
981 | 243 | --h; | ||
982 | 244 | |||
983 | 245 | set_tool.set_interval(Widelands::HeightInterval(h, h)); | ||
984 | 246 | setto_decrease_.set_enabled(0 < h); | ||
985 | 247 | setto_increase_.set_enabled(true); | ||
986 | 248 | update(); | ||
987 | 249 | } | ||
988 | 250 | |||
989 | 251 | |||
990 | 252 | void EditorToolNoiseHeightOptionsMenu::clicked_setto_increase() { | ||
991 | 253 | EditorSetHeightTool & set_tool = noise_tool_.set_tool(); | ||
992 | 254 | Field::Height h = set_tool.get_interval().min; | ||
993 | 255 | |||
994 | 256 | assert(h == set_tool.get_interval().max); | ||
995 | 257 | assert(h < MAX_FIELD_HEIGHT); | ||
996 | 258 | |||
997 | 259 | ++h; | ||
998 | 260 | |||
999 | 261 | set_tool.set_interval(Widelands::HeightInterval(h, h)); | ||
1000 | 262 | setto_decrease_.set_enabled(true); | ||
1001 | 263 | setto_increase_.set_enabled(h < MAX_FIELD_HEIGHT); | ||
1002 | 264 | update(); | ||
1084 | 265 | } | 143 | } |
1085 | 266 | 144 | ||
1086 | === modified file 'src/editor/ui_menus/tool_noise_height_options_menu.h' | |||
1087 | --- src/editor/ui_menus/tool_noise_height_options_menu.h 2016-04-06 09:23:04 +0000 | |||
1088 | +++ src/editor/ui_menus/tool_noise_height_options_menu.h 2016-04-07 14:03:59 +0000 | |||
1089 | @@ -21,8 +21,8 @@ | |||
1090 | 21 | #define WL_EDITOR_UI_MENUS_TOOL_NOISE_HEIGHT_OPTIONS_MENU_H | 21 | #define WL_EDITOR_UI_MENUS_TOOL_NOISE_HEIGHT_OPTIONS_MENU_H |
1091 | 22 | 22 | ||
1092 | 23 | #include "editor/ui_menus/tool_options_menu.h" | 23 | #include "editor/ui_menus/tool_options_menu.h" |
1095 | 24 | #include "ui_basic/button.h" | 24 | #include "ui_basic/box.h" |
1096 | 25 | #include "ui_basic/textarea.h" | 25 | #include "ui_basic/spinbox.h" |
1097 | 26 | 26 | ||
1098 | 27 | class EditorInteractive; | 27 | class EditorInteractive; |
1099 | 28 | struct EditorNoiseHeightTool; | 28 | struct EditorNoiseHeightTool; |
1100 | @@ -34,19 +34,15 @@ | |||
1101 | 34 | UI::UniqueWindow::Registry &); | 34 | UI::UniqueWindow::Registry &); |
1102 | 35 | 35 | ||
1103 | 36 | private: | 36 | private: |
1104 | 37 | void update_interval(int32_t lower, int32_t upper); | ||
1105 | 38 | void update_upper(); | ||
1106 | 39 | void update_lower(); | ||
1107 | 40 | void update_set_to(); | ||
1108 | 41 | |||
1109 | 37 | EditorNoiseHeightTool& noise_tool_; | 42 | EditorNoiseHeightTool& noise_tool_; |
1122 | 38 | UI::Textarea lower_label_, upper_label_; | 43 | UI::Box box_; |
1123 | 39 | UI::Button lower_decrease_, lower_increase_, upper_decrease_, upper_increase_; | 44 | UI::SpinBox lower_, upper_; |
1124 | 40 | UI::Textarea set_label_; | 45 | UI::SpinBox set_to_; |
1113 | 41 | UI::Button setto_decrease_, setto_increase_; | ||
1114 | 42 | |||
1115 | 43 | void clicked_lower_decrease(); | ||
1116 | 44 | void clicked_lower_increase(); | ||
1117 | 45 | void clicked_upper_decrease(); | ||
1118 | 46 | void clicked_upper_increase(); | ||
1119 | 47 | void clicked_setto_decrease(); | ||
1120 | 48 | void clicked_setto_increase(); | ||
1121 | 49 | void update(); | ||
1125 | 50 | }; | 46 | }; |
1126 | 51 | 47 | ||
1127 | 52 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_NOISE_HEIGHT_OPTIONS_MENU_H | 48 | #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_NOISE_HEIGHT_OPTIONS_MENU_H |
1128 | 53 | 49 | ||
1129 | === modified file 'src/ui_basic/spinbox.cc' | |||
1130 | --- src/ui_basic/spinbox.cc 2016-04-01 12:22:09 +0000 | |||
1131 | +++ src/ui_basic/spinbox.cc 2016-04-07 14:03:59 +0000 | |||
1132 | @@ -254,6 +254,7 @@ | |||
1133 | 254 | void SpinBox::change_value(int32_t const value) | 254 | void SpinBox::change_value(int32_t const value) |
1134 | 255 | { | 255 | { |
1135 | 256 | set_value(value + sbi_->value); | 256 | set_value(value + sbi_->value); |
1136 | 257 | changed(); | ||
1137 | 257 | } | 258 | } |
1138 | 258 | 259 | ||
1139 | 259 | 260 | ||
1140 | 260 | 261 | ||
1141 | === modified file 'src/ui_basic/spinbox.h' | |||
1142 | --- src/ui_basic/spinbox.h 2016-03-26 18:57:47 +0000 | |||
1143 | +++ src/ui_basic/spinbox.h 2016-04-07 14:03:59 +0000 | |||
1144 | @@ -23,6 +23,8 @@ | |||
1145 | 23 | #include <cstring> | 23 | #include <cstring> |
1146 | 24 | #include <list> | 24 | #include <list> |
1147 | 25 | 25 | ||
1148 | 26 | #include <boost/signals2.hpp> | ||
1149 | 27 | |||
1150 | 26 | #include "graphic/align.h" | 28 | #include "graphic/align.h" |
1151 | 27 | #include "ui_basic/box.h" | 29 | #include "ui_basic/box.h" |
1152 | 28 | #include "ui_basic/button.h" | 30 | #include "ui_basic/button.h" |
1153 | @@ -63,6 +65,8 @@ | |||
1154 | 63 | int32_t step_size = 1, int32_t big_step_size = 10); | 65 | int32_t step_size = 1, int32_t big_step_size = 10); |
1155 | 64 | ~SpinBox(); | 66 | ~SpinBox(); |
1156 | 65 | 67 | ||
1157 | 68 | boost::signals2::signal<void ()> changed; | ||
1158 | 69 | |||
1159 | 66 | void set_value(int32_t); | 70 | void set_value(int32_t); |
1160 | 67 | // For spinboxes of type kValueList. The vector needs to be sorted in ascending order, | 71 | // For spinboxes of type kValueList. The vector needs to be sorted in ascending order, |
1161 | 68 | // otherwise you will confuse the user. | 72 | // otherwise you will confuse the user. |
Continuous integration builds have changed state:
Travis build 951. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 120451312. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ bug_1395322_ tool3-784.
Appveyor build 784. State: success. Details: https:/