Merge lp:~widelands-dev/widelands/toolbar-dropdown-menus into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9174
Proposed branch: lp:~widelands-dev/widelands/toolbar-dropdown-menus
Merge into: lp:widelands
Prerequisite: lp:~widelands-dev/widelands/toolbar-dropdown-scripting-review-only
Diff against target: 4562 lines (+1554/-1198)
82 files modified
data/images/wui/menus/CREDITS.txt (+1/-0)
data/tribes/atlanteans.lua (+21/-0)
regression_test.py (+3/-0)
src/editor/CMakeLists.txt (+0/-4)
src/editor/editorinteractive.cc (+330/-84)
src/editor/editorinteractive.h (+84/-24)
src/editor/ui_menus/main_menu.cc (+0/-110)
src/editor/ui_menus/main_menu.h (+0/-53)
src/editor/ui_menus/main_menu_load_map.cc (+2/-2)
src/editor/ui_menus/main_menu_load_map.h (+1/-1)
src/editor/ui_menus/main_menu_load_or_save_map.cc (+2/-2)
src/editor/ui_menus/main_menu_load_or_save_map.h (+3/-2)
src/editor/ui_menus/main_menu_map_options.cc (+8/-16)
src/editor/ui_menus/main_menu_map_options.h (+5/-4)
src/editor/ui_menus/main_menu_new_map.cc (+2/-2)
src/editor/ui_menus/main_menu_new_map.h (+3/-3)
src/editor/ui_menus/main_menu_random_map.cc (+2/-2)
src/editor/ui_menus/main_menu_random_map.h (+3/-3)
src/editor/ui_menus/main_menu_save_map.cc (+30/-22)
src/editor/ui_menus/main_menu_save_map.h (+9/-1)
src/editor/ui_menus/player_menu.cc (+2/-2)
src/editor/ui_menus/player_menu.h (+3/-2)
src/editor/ui_menus/tool_change_height_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_change_resources_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_menu.cc (+0/-193)
src/editor/ui_menus/tool_menu.h (+0/-37)
src/editor/ui_menus/tool_noise_height_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_options_menu.cc (+6/-6)
src/editor/ui_menus/tool_options_menu.h (+4/-2)
src/editor/ui_menus/tool_place_critter_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_place_immovable_options_menu.cc (+1/-1)
src/editor/ui_menus/tool_resize_options_menu.cc (+5/-4)
src/editor/ui_menus/tool_set_terrain_options_menu.cc (+1/-1)
src/graphic/CMakeLists.txt (+10/-0)
src/graphic/toolbar_imageset.cc (+38/-0)
src/graphic/toolbar_imageset.h (+43/-0)
src/logic/CMakeLists.txt (+1/-0)
src/logic/map.cc (+4/-0)
src/logic/map.h (+0/-1)
src/logic/map_objects/CMakeLists.txt (+1/-0)
src/logic/map_objects/tribes/tribe_descr.cc (+7/-0)
src/logic/map_objects/tribes/tribe_descr.h (+7/-0)
src/logic/note_map_options.h (+32/-0)
src/notifications/note_ids.h (+2/-1)
src/scripting/lua_game.cc (+12/-1)
src/scripting/lua_game.h (+1/-0)
src/scripting/lua_ui.cc (+18/-1)
src/scripting/lua_ui.h (+1/-0)
src/ui_basic/dropdown.cc (+0/-14)
src/ui_fsmenu/internet_lobby.cc (+2/-5)
src/ui_fsmenu/launch_mpg.cc (+1/-1)
src/wui/CMakeLists.txt (+1/-4)
src/wui/buildingwindow.cc (+1/-1)
src/wui/constructionsitewindow.cc (+1/-1)
src/wui/economy_options_window.cc (+3/-13)
src/wui/fieldaction.cc (+1/-42)
src/wui/game_chat_menu.cc (+3/-1)
src/wui/game_chat_menu.h (+2/-0)
src/wui/game_client_disconnected.cc (+1/-1)
src/wui/game_message_menu.cc (+3/-3)
src/wui/game_options_menu.cc (+0/-119)
src/wui/game_options_menu.h (+0/-49)
src/wui/game_statistics_menu.cc (+0/-98)
src/wui/game_statistics_menu.h (+0/-52)
src/wui/game_summary.cc (+1/-1)
src/wui/interactive_base.cc (+152/-54)
src/wui/interactive_base.h (+52/-12)
src/wui/interactive_gamebase.cc (+232/-6)
src/wui/interactive_gamebase.h (+76/-20)
src/wui/interactive_player.cc (+134/-45)
src/wui/interactive_player.h (+24/-2)
src/wui/interactive_spectator.cc (+12/-41)
src/wui/interactive_spectator.h (+0/-1)
src/wui/mapdetails.cc (+2/-0)
src/wui/mapdetails.h (+4/-0)
src/wui/mapview.cc (+19/-6)
src/wui/mapview.h (+7/-0)
src/wui/seafaring_statistics_menu.cc (+1/-1)
src/wui/watchwindow.cc (+2/-2)
test/maps/lua_testsuite.wmf/scripting/ui.lua (+18/-11)
test/maps/plain.wmf/scripting/test_ui.lua (+86/-0)
utils/buildcat.py (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/toolbar-dropdown-menus
Reviewer Review Type Date Requested Status
Klaus Halfmann comile, regression test Approve
Review via email: mp+368230@code.launchpad.net

Commit message

Convert toolbars to dropdowns
- All toolbar menus are converted to dropdowns
- Toolbar menus have tribe-dependent frame graphics
- Add entries to menus that were previously only accessible by hotkey
- Add minimal UI test
- Overhaul Tutorial 1 & 4
  - Adapt to UI changes
  - Make Tutorial 1 more robust against user not following instructions
  - Add pretty pictures to messages

Description of the change

I have filtered the tutorial changes away from view, because the diff got truncated.

Tutorial code can be reviewed via

https://code.launchpad.net/~widelands-dev/widelands/toolbar-dropdown-scripting-review-only/+merge/368228

To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5117. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/540142530.
Appveyor build 4899. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-4899.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Found 2 bugs:

- After using the toolbar menus, map navigation with arrow keys is broken
- Opening the ship statistics -> heap-use-after-free

9116. By GunChleoc

Merged trunk.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Looks ike playing te tutorial is the best test?
What are the names of Tutorial 1 & 4 ?

Revision history for this message
GunChleoc (gunchleoc) wrote :

Basic Control and Economy.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Not nice, you open the tool popup toheeter with the tool-size window.
The zoom Icons look a bit rough?
Via the Editor-Main-Menu one can open all windows at the same time,
this cries for all kinds of Errors.
Tutorial did not wait until I actually used te "Show Buiding Spaces" menu
Tutoral crashes with assert AND ASAN:
...
Clicking tab 'small'
Pressing button 'barbarians_lumberjacks_hut'
Clicking button 'barbarians_lumberjacks_hut'
Fatal exception: [../src/graphic/image_io.h:35] Image not found: images/wui/menus/menu_stock.png
FATAL ERROR - game crashed. Attempting emergency save.
Game: Writing Preload Data ... AddressSanitizer:DEADLYSIGNAL
=================================================================
==18043==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00010d04de4b bp 0x7ffee53a0910 sp 0x7ffee53a0460 T0)
==18043==The signal is caused by a READ memory access.
==18043==Hint: address points to the zero page.
    #0 0x10d04de4a in Widelands::GamePreloadPacket::write(FileSystem&, Widelands::Game&, Widelands::MapObjectSaver*) game_preload_packet.cc:114
    #1 0x10d052b08 in Widelands::GameSaver::save() game_saver.cc:51

Looks like the emergency save stumbeld over already corrupt data?

It think there is a lot to fix, aynthing more I can reasonably test?

review: Needs Fixing (play 1st tutorial)
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5247. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/550168297.
Appveyor build 5026. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-5026.

9117. By GunChleoc

Fixed image path.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for testing!

> Not nice, you open the tool popup toheeter with the tool-size window.

I do not understand what you mean here - please explain more.

> The zoom Icons look a bit rough?

The images are just placeholders, a graphic artist will need to make proper ones.

> Via the Editor-Main-Menu one can open all windows at the same time,
> this cries for all kinds of Errors.

This was also possible previously - you can open them all in trunk too. Certainly worth thinking about, but not in this branch.

> Tutorial did not wait until I actually used te "Show Buiding Spaces" menu

That bit is a bit different from trunk - the tutorial switched them on and off for you so that you can see how it's done, and then you have to do it yourself. In trunk, you have to do it yourself immediatel

How is the timing for you regarding the wait between opening the menu and clicking on the entry?

> Tutoral crashes with assert AND ASAN:
> ...
> Clicking tab 'small'
> Pressing button 'barbarians_lumberjacks_hut'
> Clicking button 'barbarians_lumberjacks_hut'
> Fatal exception: [../src/graphic/image_io.h:35] Image not found:
> images/wui/menus/menu_stock.png
> FATAL ERROR - game crashed. Attempting emergency save.
> Game: Writing Preload Data ... AddressSanitizer:DEADLYSIGNAL
> =================================================================
> ==18043==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc
> 0x00010d04de4b bp 0x7ffee53a0910 sp 0x7ffee53a0460 T0)
> ==18043==The signal is caused by a READ memory access.
> ==18043==Hint: address points to the zero page.
> #0 0x10d04de4a in Widelands::GamePreloadPacket::write(FileSystem&,
> Widelands::Game&, Widelands::MapObjectSaver*) game_preload_packet.cc:114
> #1 0x10d052b08 in Widelands::GameSaver::save() game_saver.cc:51
>
> Looks like the emergency save stumbeld over already corrupt data?

That's an image file that got moved, and then I merged in new code for the construction sites, which still pointed to the old image location. Fixed.

> It think there is a lot to fix, aynthing more I can reasonably test?

Testing needs to be done on the editor and the 2 tutorials, and maybe play a normal game too. And the dropdowns in the Options screen and the multiplayer setup should still be OK.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I played Turorail 2 for while and then saved it.
When trying to load I get:

lastserial: 677

Game data error
buildingdata: building 524547: not found

I will try this on trunk now, too

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Can we merge trunk? the savegameerro does not happen there?

review: Needs Fixing
9118. By GunChleoc

Merged trunk.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Done. I don't expect this branch to cause any troubles with savegames, but it's best to be sure.

Tuorial 2 should also be compatible between current trunk and this branch, because it doesn't to any scripting on the toolbar menus. It will not be compatible with Build 20 though - we made a commit that accidentally broke it, and I haven't had time to track down the commit that caused this yet.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5262. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/557234209.
Appveyor build 5039. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-5039.

9119. By GunChleoc

Merged trunk.

9120. By GunChleoc

Merged trunk.

9121. By GunChleoc

Remove opening of dropdown by keypress, because it messes up keyboard navigation for the map view.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have fixed the map keyboard navigation by no longer opening the dropdowns' lists with the Up/Down keys. I don't think this is being used anyway.

I have played tutorial 2 on this branch and then loaded all the automatically generated saves without any problems.

Issues to still look into:

- Opening the ship statistics -> heap-use-after-free

> Not nice, you open the tool popup toheeter with the tool-size window.

I still don't understand this comment

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

I always assumed all the windows in the editor are exclsuive.
But we can open all of them a the same time. Well this works
but just confused me. I assumed the different windows could
affect each other in a bad way, bt was not able to produce any
of this.

I woill check out again and give int another try.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Hmm, PAUSE as Menu daas not work for me (single Player Network game)

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5288. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/564618531.
Appveyor build 5063. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-5063.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Pause does not work in network games; the host has to use a chat command for that. Good catch - I'll remove pause game from the menu for multiplayer games.

We could always open multiple editor windows, so this is not new.

9122. By GunChleoc

Remove pause toggle for multiplayer games.

9123. By GunChleoc

Fix image path in ship statistics.

Revision history for this message
GunChleoc (gunchleoc) wrote :

All issues mentioned in this discussion should be fixed now, except for loading a Tutorial 2 game, which I cannot reproduce. I don't expect that it has anything to do with this branch though, since I get similar messages for Build 20 games in trunk.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

II creeated some Map now using this brnach and had no issues whatsover.
The tools wok ass designed, alas the User-Interaction is sometimes not clear.

Maybe we can play the nw mpa with this version and/or trunk.

review: Approve
9124. By GunChleoc

Merged trunk.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for testing again!

Shall we meet on the forum for discussing any improvements that can be made to the user interaction? https://www.widelands.org/forum/topic/2769/

@bunnybot merge

9125. By GunChleoc

Fix codecheck.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Perhpas I should create a video "howto create a widelands map".
To describe this in text is quite difficult.

It basically works but some sematics do not work like
in oter Painting Programs or such. It just works the "widelands way".

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5303. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/569957369.
Appveyor build 5076. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-5076.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.

Travis build 5303. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/569957369.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Mhh, some travis builds just time out,
The Realse Builds are all broekn with a testcase.

https://travis-ci.org/widelands/widelands/jobs/569957376

1383 Assertions checked. 405 Tests passed, 3 failed!
Trying to run: test/maps/lua_testsuite.wmf/scripting/test_lua_in_game.lua: done

this would indicate some asserts containing vital code which is now mssing
in the release build? I will try to do a release build but as I am on OSX
this should be ok. So we have an assertion with vital code that is still executed
on OSX, odd. So I will try a realse buid oon linux, too. That will take a little longer.

review: Needs Fixing
9126. By GunChleoc

Fix highlighting via Lua and test for debug builds.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Running tests locally I get (on OSX):

FAIL: test_buttons_property: [string "scripting/ui.lua"]:26: 'nil' not expected!

FAIL: test_name: [string "scripting/ui.lua"]:113: attempt to index a nil value (field 'b')
stack traceback:
 [string "scripting/ui.lua"]:113: in upvalue 'func'
 [string "scripting/lunit.lua"]:425: in function <[string "scripting/lunit.lua"]:425>
 [C]: in global 'xpcall'
 [string "scripting/lunit.lua"]:425: in upvalue 'call'
 [string "scripting/lunit.lua"]:450: in local 'run'
 [string "scripting/lunit.lua"]:476: in global 'lunit_run_testcase'
 [string "scripting/lunit.lua"]:382: in method 'run'
 [string "scripting/init.lua"]:70: in main chunk

FAIL: test_click: [string "scripting/ui.lua"]:116: attempt to index a nil value (field 'b')
stack traceback:
 [string "scripting/ui.lua"]:116: in upvalue 'func'
 [string "scripting/lunit.lua"]:425: in function <[string "scripting/lunit.lua"]:425>
 [C]: in global 'xpcall'
 [string "scripting/lunit.lua"]:425: in upvalue 'call'
 [string "scripting/lunit.lua"]:450: in local 'run'
 [string "scripting/lunit.lua"]:476: in global 'lunit_run_testcase'
 [string "scripting/lunit.lua"]:382: in method 'run'
 [string "scripting/init.lua"]:70: in main chunk

FAIL: test/maps/ship_transportation.wmf/scripting/test_rip_ship_before_picking_up_transporting_ware.lua

...

Fatal exception: [../src/io/filesystem/layered_filesystem.cc:216] LayeredFileSystem: unable to create sub filesystem for existing directory: /var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa/save/0_before_removing_ship.wgf
I have tried the following path(s):
    /var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa//var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa/save/0_before_removing_ship.wgf
    /Users/klaus/develop/widelands-repo/toolbar-dropdown-menus//var/folders/bx/q32c1w1965
FATAL ERROR - game crashed. Attempting emergency save.
lastserial: 0

Caught exception (of type '10WException') in outermost handler!
The exception said: [../src/io/filesystem/layered_filesystem.cc:216] LayeredFileSystem: unable to create sub filesystem for existing directory: /var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa/save/0_before_removing_ship.wgf
I have tried the following path(s):
    /var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa//var/folders/bx/q32c1w1965g5clyfbfdykcb40000gp/T/widelands_regression_testfmUxCa/save/0_before_removing_ship.wgf
    /Users/klaus/develop/widelands-repo/toolbar-dropdown-menus//var/folders/bx/q32c1w1965

This should not happen. Please file a bug report on version bzr9123[toolbar-dropdown-menus](Release).
and remember to specify your operating system.

----------------------------------------------------------------------
Ran 45 tests in 978.544s

FAILED (failures=2)

Gun: As you are "busy indexing nil values" you may have an idea what happend here ;-)

WIll it help if I:
a) Dig into the test and find what failed?
b) run these tests on linux?

I will no play a normala, single player game for a while and then try again with the debug build

9127. By GunChleoc

buildhelp is no longer a button, use help instead. Also, clean up nil asserts.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Ahh, now you confused me :-)

Just tried on Linux
> Linux iXubuntu 5.0.0-23-generic #24-Ubuntu SMP Mon Jul 29 15:36:44 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

and suprise: al Regreession tests pass on this branch and trunk with release and debug

OK Ill go back to OSX and try again

review: Approve (compile, regression test)
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Fine onn OSX now, too (release build)

> Ran 45 tests in 1128.847s
> OK

@bunnybot merge

review: Approve (comile, regression test)
Revision history for this message
GunChleoc (gunchleoc) wrote :

The reason that the test failed was because there is a UI test that depends on "buildhelp" to be a button, which is a menu entry now. I have changed it to use "help" instead, which is the button for opening the Encyclopedia.

The second failure was that in debug builds, the main menu has 1 additional entry on top (the Lua console). So, I am now counting he entries in the test to decide which is the correct item index.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5306. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/570176875.
Appveyor build 5079. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_toolbar_dropdown_menus-5079.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'data/images/wui/editor/menus'
2=== added file 'data/images/wui/editor/menus/load_map.png'
3Binary files data/images/wui/editor/menus/load_map.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/load_map.png 2019-08-10 10:01:32 +0000 differ
4=== added file 'data/images/wui/editor/menus/main_menu.png'
5Binary files data/images/wui/editor/menus/main_menu.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/main_menu.png 2019-08-10 10:01:32 +0000 differ
6=== added file 'data/images/wui/editor/menus/map_options.png'
7Binary files data/images/wui/editor/menus/map_options.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/map_options.png 2019-08-10 10:01:32 +0000 differ
8=== added file 'data/images/wui/editor/menus/new_map.png'
9Binary files data/images/wui/editor/menus/new_map.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/new_map.png 2019-08-10 10:01:32 +0000 differ
10=== added file 'data/images/wui/editor/menus/new_random_map.png'
11Binary files data/images/wui/editor/menus/new_random_map.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/new_random_map.png 2019-08-10 10:01:32 +0000 differ
12=== renamed file 'data/images/wui/editor/editor_redo.png' => 'data/images/wui/editor/menus/redo.png'
13=== added file 'data/images/wui/editor/menus/save_map.png'
14Binary files data/images/wui/editor/menus/save_map.png 1970-01-01 00:00:00 +0000 and data/images/wui/editor/menus/save_map.png 2019-08-10 10:01:32 +0000 differ
15=== renamed file 'data/images/wui/editor/editor_menu_toggle_tool_menu.png' => 'data/images/wui/editor/menus/tools.png'
16=== renamed file 'data/images/wui/editor/editor_menu_set_toolsize_menu.png' => 'data/images/wui/editor/menus/toolsize.png'
17=== renamed file 'data/images/wui/editor/editor_undo.png' => 'data/images/wui/editor/menus/undo.png'
18=== added directory 'data/images/wui/editor/tools'
19=== renamed file 'data/images/wui/editor/editor_menu_tool_place_bob.png' => 'data/images/wui/editor/tools/critters.png'
20=== renamed file 'data/images/wui/editor/editor_menu_tool_change_height.png' => 'data/images/wui/editor/tools/height.png'
21=== renamed file 'data/images/wui/editor/editor_menu_tool_place_immovable.png' => 'data/images/wui/editor/tools/immovables.png'
22=== renamed file 'data/images/wui/editor/editor_menu_tool_set_origin.png' => 'data/images/wui/editor/tools/map_origin.png'
23=== renamed file 'data/images/wui/editor/editor_menu_tool_noise_height.png' => 'data/images/wui/editor/tools/noise_height.png'
24=== renamed file 'data/images/wui/editor/editor_menu_player_menu.png' => 'data/images/wui/editor/tools/players.png'
25=== renamed file 'data/images/wui/editor/editor_menu_tool_set_port_space.png' => 'data/images/wui/editor/tools/port_spaces.png'
26=== renamed file 'data/images/wui/editor/editor_menu_tool_resize.png' => 'data/images/wui/editor/tools/resize_map.png'
27=== renamed file 'data/images/wui/editor/editor_menu_tool_change_resources.png' => 'data/images/wui/editor/tools/resources.png'
28=== renamed file 'data/images/wui/editor/editor_menu_tool_set_terrain.png' => 'data/images/wui/editor/tools/terrain.png'
29=== added file 'data/images/wui/menus/CREDITS.txt'
30--- data/images/wui/menus/CREDITS.txt 1970-01-01 00:00:00 +0000
31+++ data/images/wui/menus/CREDITS.txt 2019-08-10 10:01:32 +0000
32@@ -0,0 +1,1 @@
33+lua.png Copyright © 1998 Lua.org. Graphic design by Alexandre Nakonechnyj.
34
35=== renamed file 'data/images/wui/menus/menu_chat.png' => 'data/images/wui/menus/chat.png'
36=== renamed file 'data/images/wui/menus/menu_exit_game.png' => 'data/images/wui/menus/exit.png'
37=== added file 'data/images/wui/menus/gamespeed.png'
38Binary files data/images/wui/menus/gamespeed.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/gamespeed.png 2019-08-10 10:01:32 +0000 differ
39=== added file 'data/images/wui/menus/gamespeed_decrease.png'
40Binary files data/images/wui/menus/gamespeed_decrease.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/gamespeed_decrease.png 2019-08-10 10:01:32 +0000 differ
41=== added file 'data/images/wui/menus/gamespeed_increase.png'
42Binary files data/images/wui/menus/gamespeed_increase.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/gamespeed_increase.png 2019-08-10 10:01:32 +0000 differ
43=== added file 'data/images/wui/menus/gamespeed_pause.png'
44Binary files data/images/wui/menus/gamespeed_pause.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/gamespeed_pause.png 2019-08-10 10:01:32 +0000 differ
45=== added file 'data/images/wui/menus/gamespeed_resume.png'
46Binary files data/images/wui/menus/gamespeed_resume.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/gamespeed_resume.png 2019-08-10 10:01:32 +0000 differ
47=== renamed file 'data/images/wui/menus/menu_goto.png' => 'data/images/wui/menus/goto.png'
48=== added file 'data/images/wui/menus/lua.png'
49Binary files data/images/wui/menus/lua.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/lua.png 2019-08-10 10:01:32 +0000 differ
50=== renamed file 'data/images/wui/menus/menu_options_menu.png' => 'data/images/wui/menus/main_menu.png'
51=== modified file 'data/images/wui/menus/menu_toggle_grid.png'
52Binary files data/images/wui/menus/menu_toggle_grid.png 2019-03-14 10:30:55 +0000 and data/images/wui/menus/menu_toggle_grid.png 2019-08-10 10:01:32 +0000 differ
53=== renamed file 'data/images/wui/menus/menu_toggle_newmessage_menu.png' => 'data/images/wui/menus/message_new.png'
54=== renamed file 'data/images/wui/menus/menu_toggle_oldmessage_menu.png' => 'data/images/wui/menus/message_old.png'
55=== renamed file 'data/images/wui/menus/menu_objectives.png' => 'data/images/wui/menus/objectives.png'
56=== added file 'data/images/wui/menus/options.png'
57Binary files data/images/wui/menus/options.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/options.png 2019-08-10 10:01:32 +0000 differ
58=== renamed file 'data/images/wui/menus/menu_save_game.png' => 'data/images/wui/menus/save_game.png'
59=== renamed file 'data/images/wui/fieldaction/menu_show_workarea_overlap.png' => 'data/images/wui/menus/show_workarea_overlap.png'
60=== added file 'data/images/wui/menus/showhide.png'
61Binary files data/images/wui/menus/showhide.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/showhide.png 2019-08-10 10:01:32 +0000 differ
62=== renamed file 'data/images/wui/menus/menu_toggle_menu.png' => 'data/images/wui/menus/statistics.png'
63=== renamed file 'data/images/wui/menus/menu_building_stats.png' => 'data/images/wui/menus/statistics_buildings.png'
64=== renamed file 'data/images/wui/menus/menu_general_stats.png' => 'data/images/wui/menus/statistics_general.png'
65=== added file 'data/images/wui/menus/statistics_seafaring.png'
66Binary files data/images/wui/menus/statistics_seafaring.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/statistics_seafaring.png 2019-08-10 10:01:32 +0000 differ
67=== renamed file 'data/images/wui/menus/menu_stock.png' => 'data/images/wui/menus/statistics_stock.png'
68=== renamed file 'data/images/wui/menus/menu_ware_stats.png' => 'data/images/wui/menus/statistics_wares.png'
69=== renamed file 'data/images/wui/menus/menu_toggle_bobs.png' => 'data/images/wui/menus/toggle_bobs.png'
70=== renamed file 'data/images/wui/menus/menu_toggle_buildhelp.png' => 'data/images/wui/menus/toggle_buildhelp.png'
71=== renamed file 'data/images/wui/fieldaction/menu_show_census.png' => 'data/images/wui/menus/toggle_census.png'
72=== renamed file 'data/images/wui/menus/menu_toggle_immovables.png' => 'data/images/wui/menus/toggle_immovables.png'
73=== renamed file 'data/images/wui/menus/menu_toggle_minimap.png' => 'data/images/wui/menus/toggle_minimap.png'
74=== renamed file 'data/images/wui/menus/menu_toggle_resources.png' => 'data/images/wui/menus/toggle_resources.png'
75=== renamed file 'data/images/wui/fieldaction/menu_show_statistics.png' => 'data/images/wui/menus/toggle_statistics.png'
76=== renamed file 'data/images/wui/menus/menu_watch_follow.png' => 'data/images/wui/menus/watch_follow.png'
77=== added file 'data/images/wui/menus/zoom_decrease.png'
78Binary files data/images/wui/menus/zoom_decrease.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/zoom_decrease.png 2019-08-10 10:01:32 +0000 differ
79=== added file 'data/images/wui/menus/zoom_increase.png'
80Binary files data/images/wui/menus/zoom_increase.png 1970-01-01 00:00:00 +0000 and data/images/wui/menus/zoom_increase.png 2019-08-10 10:01:32 +0000 differ
81=== renamed file 'data/images/wui/menus/menu_reset_zoom.png' => 'data/images/wui/menus/zoom_reset.png'
82=== added directory 'data/images/wui/toolbar'
83=== added file 'data/images/wui/toolbar/center.png'
84Binary files data/images/wui/toolbar/center.png 1970-01-01 00:00:00 +0000 and data/images/wui/toolbar/center.png 2019-08-10 10:01:32 +0000 differ
85=== added file 'data/images/wui/toolbar/left.png'
86Binary files data/images/wui/toolbar/left.png 1970-01-01 00:00:00 +0000 and data/images/wui/toolbar/left.png 2019-08-10 10:01:32 +0000 differ
87=== added file 'data/images/wui/toolbar/left_corner.png'
88Binary files data/images/wui/toolbar/left_corner.png 1970-01-01 00:00:00 +0000 and data/images/wui/toolbar/left_corner.png 2019-08-10 10:01:32 +0000 differ
89=== added file 'data/images/wui/toolbar/right.png'
90Binary files data/images/wui/toolbar/right.png 1970-01-01 00:00:00 +0000 and data/images/wui/toolbar/right.png 2019-08-10 10:01:32 +0000 differ
91=== added file 'data/images/wui/toolbar/right_corner.png'
92Binary files data/images/wui/toolbar/right_corner.png 1970-01-01 00:00:00 +0000 and data/images/wui/toolbar/right_corner.png 2019-08-10 10:01:32 +0000 differ
93=== modified file 'data/tribes/atlanteans.lua'
94--- data/tribes/atlanteans.lua 2019-05-25 08:51:42 +0000
95+++ data/tribes/atlanteans.lua 2019-08-10 10:01:32 +0000
96@@ -44,6 +44,19 @@
97 -- **ship**: The internal name of the tribe's ship.
98 --
99 -- **port**: The internal name of the tribe's port building. This unit needs to be defined in the ``buildings`` table too.
100+--
101+-- **toolbar**: *Optional*. Replace the default toolbar images with these custom images. Example:
102+--
103+-- .. code-block:: lua
104+--
105+-- toolbar = {
106+-- left_corner = dirname .. "images/atlanteans/toolbar_left_corner.png",
107+-- left = dirname .. "images/atlanteans/toolbar_left.png", -- Will be tiled
108+-- center = dirname .. "images/atlanteans/toolbar_center.png",
109+-- right = dirname .. "images/atlanteans/toolbar_right.png", -- Will be tiled
110+-- right_corner = dirname .. "images/atlanteans/toolbar_right_corner.png"
111+-- }
112+--
113
114 image_dirname = path.dirname(__file__) .. "images/atlanteans/"
115
116@@ -370,4 +383,12 @@
117 rawlog = "log",
118 refinedlog = "planks",
119 granite = "granite",
120+
121+ toolbar = {
122+ left_corner = image_dirname .. "toolbar_left_corner.png",
123+ left = image_dirname .. "toolbar_left.png",
124+ center = image_dirname .. "toolbar_center.png",
125+ right = image_dirname .. "toolbar_right.png",
126+ right_corner = image_dirname .. "toolbar_right_corner.png"
127+ }
128 }
129
130=== added file 'data/tribes/images/atlanteans/toolbar_center.png'
131Binary files data/tribes/images/atlanteans/toolbar_center.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/toolbar_center.png 2019-08-10 10:01:32 +0000 differ
132=== added file 'data/tribes/images/atlanteans/toolbar_left.png'
133Binary files data/tribes/images/atlanteans/toolbar_left.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/toolbar_left.png 2019-08-10 10:01:32 +0000 differ
134=== added file 'data/tribes/images/atlanteans/toolbar_left_corner.png'
135Binary files data/tribes/images/atlanteans/toolbar_left_corner.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/toolbar_left_corner.png 2019-08-10 10:01:32 +0000 differ
136=== added file 'data/tribes/images/atlanteans/toolbar_right.png'
137Binary files data/tribes/images/atlanteans/toolbar_right.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/toolbar_right.png 2019-08-10 10:01:32 +0000 differ
138=== added file 'data/tribes/images/atlanteans/toolbar_right_corner.png'
139Binary files data/tribes/images/atlanteans/toolbar_right_corner.png 1970-01-01 00:00:00 +0000 and data/tribes/images/atlanteans/toolbar_right_corner.png 2019-08-10 10:01:32 +0000 differ
140=== modified file 'regression_test.py'
141--- regression_test.py 2019-03-15 19:37:37 +0000
142+++ regression_test.py 2019-08-10 10:01:32 +0000
143@@ -137,6 +137,9 @@
144 self.assertTrue("All Tests passed" in stdout,
145 "Not all tests pass. {}.".format(common_msg)
146 )
147+ self.assertFalse("lua_errors.cc" in stdout,
148+ "Not all tests pass. {}.".format(common_msg)
149+ )
150 out("done.\n")
151 if self.keep_output_around:
152 out(" stdout: {}\n".format(stdout_filename))
153
154=== modified file 'src/editor/CMakeLists.txt'
155--- src/editor/CMakeLists.txt 2019-06-01 08:18:58 +0000
156+++ src/editor/CMakeLists.txt 2019-08-10 10:01:32 +0000
157@@ -49,8 +49,6 @@
158 ui_menus/categorized_item_selection_menu.h
159 ui_menus/help.cc
160 ui_menus/help.h
161- ui_menus/main_menu.cc
162- ui_menus/main_menu.h
163 ui_menus/main_menu_load_map.cc
164 ui_menus/main_menu_load_map.h
165 ui_menus/main_menu_load_or_save_map.cc
166@@ -73,8 +71,6 @@
167 ui_menus/tool_change_height_options_menu.h
168 ui_menus/tool_change_resources_options_menu.cc
169 ui_menus/tool_change_resources_options_menu.h
170- ui_menus/tool_menu.cc
171- ui_menus/tool_menu.h
172 ui_menus/tool_noise_height_options_menu.cc
173 ui_menus/tool_noise_height_options_menu.h
174 ui_menus/tool_options_menu.cc
175
176=== modified file 'src/editor/editorinteractive.cc'
177--- src/editor/editorinteractive.cc 2019-04-26 05:52:49 +0000
178+++ src/editor/editorinteractive.cc 2019-08-10 10:01:32 +0000
179@@ -29,13 +29,29 @@
180 #include "base/i18n.h"
181 #include "base/scoped_timer.h"
182 #include "base/warning.h"
183-#include "editor/tools/delete_immovable_tool.h"
184+#include "editor/tools/decrease_height_tool.h"
185+#include "editor/tools/decrease_resources_tool.h"
186+#include "editor/tools/increase_height_tool.h"
187+#include "editor/tools/increase_resources_tool.h"
188+#include "editor/tools/noise_height_tool.h"
189+#include "editor/tools/place_critter_tool.h"
190+#include "editor/tools/place_immovable_tool.h"
191+#include "editor/tools/set_port_space_tool.h"
192+#include "editor/tools/set_terrain_tool.h"
193 #include "editor/ui_menus/help.h"
194-#include "editor/ui_menus/main_menu.h"
195 #include "editor/ui_menus/main_menu_load_map.h"
196+#include "editor/ui_menus/main_menu_map_options.h"
197+#include "editor/ui_menus/main_menu_new_map.h"
198+#include "editor/ui_menus/main_menu_random_map.h"
199 #include "editor/ui_menus/main_menu_save_map.h"
200 #include "editor/ui_menus/player_menu.h"
201-#include "editor/ui_menus/tool_menu.h"
202+#include "editor/ui_menus/tool_change_height_options_menu.h"
203+#include "editor/ui_menus/tool_change_resources_options_menu.h"
204+#include "editor/ui_menus/tool_noise_height_options_menu.h"
205+#include "editor/ui_menus/tool_place_critter_options_menu.h"
206+#include "editor/ui_menus/tool_place_immovable_options_menu.h"
207+#include "editor/ui_menus/tool_resize_options_menu.h"
208+#include "editor/ui_menus/tool_set_terrain_options_menu.h"
209 #include "editor/ui_menus/toolsize_menu.h"
210 #include "graphic/graphic.h"
211 #include "graphic/playercolor.h"
212@@ -70,66 +86,45 @@
213 need_save_(false),
214 realtime_(SDL_GetTicks()),
215 is_painting_(false),
216+ mainmenu_(
217+ toolbar(), "dropdown_menu_main", 0, 0, 34U, 10, 34U,
218+ /** TRANSLATORS: Title for the main menu button in the editor */
219+ as_tooltip_text_with_hotkey(_("Main Menu"), "h"),
220+ UI::DropdownType::kPictorialMenu,
221+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
222+ toolmenu_(
223+ toolbar(), "dropdown_menu_tools", 0, 0, 34U, 12, 34U,
224+ /** TRANSLATORS: Title for the tool menu button in the editor */
225+ as_tooltip_text_with_hotkey(_("Tools"), "t"),
226+ UI::DropdownType::kPictorialMenu,
227+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
228+ showhidemenu_(
229+ toolbar(), "dropdown_menu_showhide", 0, 0, 34U, 10, 34U,
230+ /** TRANSLATORS: Title for a menu button in the editor. This menu will show/hide building spaces, animals, immovables, resources */
231+ _("Show / Hide"),
232+ UI::DropdownType::kPictorialMenu,
233+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
234 undo_(nullptr),
235 redo_(nullptr),
236 tools_(new Tools(e.map())),
237 history_(nullptr) // history needs the undo/redo buttons
238 {
239- add_toolbar_button("wui/menus/menu_toggle_menu", "menu", _("Main menu"), &mainmenu_, true);
240- mainmenu_.open_window = [this] { new EditorMainMenu(*this, mainmenu_); };
241-
242- add_toolbar_button(
243- "wui/editor/editor_menu_toggle_tool_menu", "tools", _("Tools"), &toolmenu_, true);
244- toolmenu_.open_window = [this] { new EditorToolMenu(*this, toolmenu_); };
245-
246- add_toolbar_button(
247- "wui/editor/editor_menu_set_toolsize_menu", "toolsize", _("Tool size"), &toolsizemenu_, true);
248- toolsizemenu_.open_window = [this] { new EditorToolsizeMenu(*this, toolsizemenu_); };
249-
250- add_toolbar_button(
251- "wui/editor/editor_menu_player_menu", "players", _("Players"), &playermenu_, true);
252- playermenu_.open_window = [this] {
253- select_tool(tools_->set_starting_pos, EditorTool::First);
254- new EditorPlayerMenu(*this, playermenu_);
255- };
256-
257- toolbar()->add_space(15);
258-
259- toggle_buildhelp_ = add_toolbar_button(
260- "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
261- toggle_buildhelp_->sigclicked.connect(boost::bind(&EditorInteractive::toggle_buildhelp, this));
262- toggle_grid_ = add_toolbar_button("wui/menus/menu_toggle_grid", "grid", _("Show grid (on/off)"));
263- toggle_grid_->set_perm_pressed(true);
264- toggle_grid_->sigclicked.connect([this]() { toggle_grid(); });
265- toggle_immovables_ = add_toolbar_button(
266- "wui/menus/menu_toggle_immovables", "immovables", _("Show immovables (on/off)"));
267- toggle_immovables_->set_perm_pressed(true);
268- toggle_immovables_->sigclicked.connect([this]() { toggle_immovables(); });
269- toggle_bobs_ =
270- add_toolbar_button("wui/menus/menu_toggle_bobs", "animals", _("Show animals (on/off)"));
271- toggle_bobs_->set_perm_pressed(true);
272- toggle_bobs_->sigclicked.connect([this]() { toggle_bobs(); });
273- toggle_resources_ = add_toolbar_button(
274- "wui/menus/menu_toggle_resources", "resources", _("Show resources (on/off)"));
275- toggle_resources_->set_perm_pressed(true);
276- toggle_resources_->sigclicked.connect([this]() { toggle_resources(); });
277-
278- toolbar()->add_space(15);
279-
280- add_toolbar_button(
281- "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);
282- minimap_registry().open_window = [this] { toggle_minimap(); };
283-
284- auto zoom = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
285- zoom->sigclicked.connect([this] {
286- map_view()->zoom_around(
287- 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
288- });
289-
290- toolbar()->add_space(15);
291-
292- undo_ = add_toolbar_button("wui/editor/editor_undo", "undo", _("Undo"));
293- redo_ = add_toolbar_button("wui/editor/editor_redo", "redo", _("Redo"));
294+ add_main_menu();
295+ add_tool_menu();
296+
297+ add_toolbar_button(
298+ "wui/editor/menus/toolsize", "toolsize", _("Tool size"), &menu_windows_.toolsize, true);
299+ menu_windows_.toolsize.open_window = [this] { new EditorToolsizeMenu(*this, menu_windows_.toolsize); };
300+
301+ toolbar()->add_space(15);
302+
303+ add_mapview_menu(MiniMapType::kStaticMap);
304+ add_showhide_menu();
305+
306+ toolbar()->add_space(15);
307+
308+ undo_ = add_toolbar_button("wui/editor/menus/undo", "undo", _("Undo"));
309+ redo_ = add_toolbar_button("wui/editor/menus/redo", "redo", _("Redo"));
310
311 history_.reset(new EditorHistory(*undo_, *redo_));
312
313@@ -138,10 +133,10 @@
314
315 toolbar()->add_space(15);
316
317- add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &helpmenu_, true);
318- helpmenu_.open_window = [this] { new EditorHelp(*this, helpmenu_, &egbase().lua()); };
319+ add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &menu_windows_.help, true);
320+ menu_windows_.help.open_window = [this] { new EditorHelp(*this, menu_windows_.help, &egbase().lua()); };
321
322- adjust_toolbar_position();
323+ finalize_toolbar();
324
325 #ifndef NDEBUG
326 set_display_flag(InteractiveBase::dfDebug, true);
327@@ -152,8 +147,269 @@
328 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {
329 map_clicked(node_and_triangle, false);
330 });
331-
332- minimap_registry().minimap_type = MiniMapType::kStaticMap;
333+}
334+
335+
336+void EditorInteractive::add_main_menu() {
337+ mainmenu_.set_image(g_gr->images().get("images/wui/editor/menus/main_menu.png"));
338+
339+ menu_windows_.newmap.open_window = [this] {
340+ new MainMenuNewMap(*this, menu_windows_.newmap);
341+ };
342+ /** TRANSLATORS: An entry in the editor's main menu */
343+ mainmenu_.add(_("New Map"), MainMenuEntry::kNewMap,
344+ g_gr->images().get("images/wui/editor/menus/new_map.png"));
345+
346+ menu_windows_.newrandommap.open_window = [this] {
347+ new MainMenuNewRandomMap(*this, menu_windows_.newrandommap);
348+ };
349+ /** TRANSLATORS: An entry in the editor's main menu */
350+ mainmenu_.add(_("New Random Map"), MainMenuEntry::kNewRandomMap,
351+ g_gr->images().get("images/wui/editor/menus/new_random_map.png"));
352+
353+ menu_windows_.loadmap.open_window = [this] {
354+ new MainMenuLoadMap(*this, menu_windows_.loadmap);
355+ };
356+ /** TRANSLATORS: An entry in the editor's main menu */
357+ mainmenu_.add(_("Load Map"), MainMenuEntry::kLoadMap,
358+ g_gr->images().get("images/wui/editor/menus/load_map.png"),
359+ false, "", pgettext("hotkey", "Ctrl+l"));
360+
361+ menu_windows_.savemap.open_window = [this] {
362+ new MainMenuSaveMap(*this, menu_windows_.savemap, menu_windows_.mapoptions);
363+ };
364+ /** TRANSLATORS: An entry in the editor's main menu */
365+ mainmenu_.add(_("Save Map"), MainMenuEntry::kSaveMap,
366+ g_gr->images().get("images/wui/editor/menus/save_map.png"),
367+ false, "", pgettext("hotkey", "Ctrl+s"));
368+
369+ menu_windows_.mapoptions.open_window = [this] {
370+ new MainMenuMapOptions(*this, menu_windows_.mapoptions);
371+ };
372+ /** TRANSLATORS: An entry in the editor's main menu */
373+ mainmenu_.add(_("Map Options"), MainMenuEntry::kMapOptions,
374+ g_gr->images().get("images/wui/editor/menus/map_options.png"));
375+
376+ /** TRANSLATORS: An entry in the editor's main menu */
377+ mainmenu_.add(_("Exit Editor"), MainMenuEntry::kExitEditor,
378+ g_gr->images().get("images/wui/menus/exit.png"));
379+ mainmenu_.selected.connect([this] { main_menu_selected(mainmenu_.get_selected()); });
380+ toolbar()->add(&mainmenu_);
381+}
382+
383+void EditorInteractive::main_menu_selected(MainMenuEntry entry) {
384+ switch (entry) {
385+ case MainMenuEntry::kNewMap: {
386+ menu_windows_.newmap.toggle();
387+ } break;
388+ case MainMenuEntry::kNewRandomMap: {
389+ menu_windows_.newrandommap.toggle();
390+ } break;
391+ case MainMenuEntry::kLoadMap: {
392+ menu_windows_.loadmap.toggle();
393+ } break;
394+ case MainMenuEntry::kSaveMap: {
395+ menu_windows_.savemap.toggle();
396+ } break;
397+ case MainMenuEntry::kMapOptions: {
398+ menu_windows_.mapoptions.toggle();
399+ } break;
400+ case MainMenuEntry::kExitEditor: {
401+ exit();
402+ }
403+ }
404+}
405+
406+void EditorInteractive::add_tool_menu() {
407+ toolmenu_.set_image(g_gr->images().get("images/wui/editor/menus/tools.png"));
408+
409+ tool_windows_.height.open_window = [this] {
410+ new EditorToolChangeHeightOptionsMenu(*this, tools()->increase_height, tool_windows_.height);
411+ };
412+ /** TRANSLATORS: An entry in the editor's tool menu */
413+ toolmenu_.add(_("Change height"), ToolMenuEntry::kChangeHeight,
414+ g_gr->images().get("images/wui/editor/tools/height.png"), false,
415+ /** TRANSLATORS: Tooltip for the change height tool in the editor */
416+ _("Change the terrain height"));
417+
418+ tool_windows_.noiseheight.open_window = [this] {
419+ new EditorToolNoiseHeightOptionsMenu(*this, tools()->noise_height, tool_windows_.noiseheight);
420+ };
421+ /** TRANSLATORS: An entry in the editor's tool menu */
422+ toolmenu_.add(_("Random height"), ToolMenuEntry::kRandomHeight,
423+ g_gr->images().get("images/wui/editor/tools/noise_height.png"), false,
424+ /** TRANSLATORS: Tooltip for the random height tool in the editor */
425+ _("Set the terrain height to random values"));
426+
427+ tool_windows_.terrain.open_window = [this] {
428+ new EditorToolSetTerrainOptionsMenu(*this, tools()->set_terrain, tool_windows_.terrain);
429+ };
430+ /** TRANSLATORS: An entry in the editor's tool menu */
431+ toolmenu_.add(_("Terrain"), ToolMenuEntry::kTerrain,
432+ g_gr->images().get("images/wui/editor/tools/terrain.png"), false,
433+ /** TRANSLATORS: Tooltip for the terrain tool in the editor */
434+ _("Change the map’s terrain"));
435+
436+ tool_windows_.immovables.open_window = [this] {
437+ new EditorToolPlaceImmovableOptionsMenu(*this, tools()->place_immovable, tool_windows_.immovables);
438+ };
439+ /** TRANSLATORS: An entry in the editor's tool menu */
440+ toolmenu_.add(_("Immovables"), ToolMenuEntry::kImmovables,
441+ g_gr->images().get("images/wui/editor/tools/immovables.png"), false,
442+ /** TRANSLATORS: Tooltip for the immovables tool in the editor */
443+ _("Add or remove immovables"));
444+
445+ tool_windows_.critters.open_window = [this] {
446+ new EditorToolPlaceCritterOptionsMenu(*this, tools()->place_critter, tool_windows_.critters);
447+ };
448+ /** TRANSLATORS: An entry in the editor's tool menu */
449+ toolmenu_.add(_("Animals"), ToolMenuEntry::kAnimals,
450+ g_gr->images().get("images/wui/editor/tools/critters.png"), false,
451+ /** TRANSLATORS: Tooltip for the animals tool in the editor */
452+ _("Add or remove animals"));
453+
454+ tool_windows_.resources.open_window = [this] {
455+ new EditorToolChangeResourcesOptionsMenu(*this, tools()->increase_resources, tool_windows_.resources);
456+ };
457+ /** TRANSLATORS: An entry in the editor's tool menu */
458+ toolmenu_.add(_("Resources"), ToolMenuEntry::kResources,
459+ g_gr->images().get("images/wui/editor/tools/resources.png"), false,
460+ /** TRANSLATORS: Tooltip for the resources tool in the editor */
461+ _("Set or change resources"));
462+
463+ /** TRANSLATORS: An entry in the editor's tool menu */
464+ toolmenu_.add(_("Port spaces"), ToolMenuEntry::kPortSpace,
465+ g_gr->images().get("images/wui/editor/tools/port_spaces.png"), false,
466+ /** TRANSLATORS: Tooltip for the port spaces tool in the editor */
467+ _("Add or remove port spaces"));
468+
469+ tool_windows_.players.open_window = [this] {
470+ new EditorPlayerMenu(*this, tools()->set_starting_pos, tool_windows_.players);
471+ };
472+ /** TRANSLATORS: An entry in the editor's tool menu */
473+ toolmenu_.add(_("Players"), ToolMenuEntry::kPlayers,
474+ g_gr->images().get("images/wui/editor/tools/players.png"), false,
475+ /** TRANSLATORS: Tooltip for the map size tool in the editor */
476+ _("Set number of players and their names, tribes and starting positions"), "p");
477+
478+ /** TRANSLATORS: An entry in the editor's tool menu */
479+ toolmenu_.add(_("Map origin"), ToolMenuEntry::kMapOrigin,
480+ g_gr->images().get("images/wui/editor/tools/map_origin.png"), false,
481+ /** TRANSLATORS: Tooltip for the map origin tool in the editor */
482+ _("Set the position that will have the coordinates (0, 0). This will be the top-left corner of a generated minimap."));
483+
484+ tool_windows_.resizemap.open_window = [this] {
485+ new EditorToolResizeOptionsMenu(*this, tools()->resize, tool_windows_.resizemap);
486+ };
487+ /** TRANSLATORS: An entry in the editor's tool menu */
488+ toolmenu_.add(_("Map size"), ToolMenuEntry::kMapSize,
489+ g_gr->images().get("images/wui/editor/tools/resize_map.png"), false,
490+ /** TRANSLATORS: Tooltip for the map size tool in the editor */
491+ _("Change the map’s size"));
492+
493+ /** TRANSLATORS: An entry in the editor's tool menu */
494+ toolmenu_.add(_("Information"), ToolMenuEntry::kFieldInfo,
495+ g_gr->images().get("images/wui/editor/fsel_editor_info.png"), false,
496+ /** TRANSLATORS: Tooltip for the map information tool in the editor */
497+ _("Click on a field to show information about it"), "i");
498+ toolmenu_.selected.connect([this] { tool_menu_selected(toolmenu_.get_selected()); });
499+ toolbar()->add(&toolmenu_);
500+}
501+
502+void EditorInteractive::tool_menu_selected(ToolMenuEntry entry) {
503+ switch (entry) {
504+ case ToolMenuEntry::kChangeHeight:
505+ tool_windows_.height.toggle();
506+ break;
507+ case ToolMenuEntry::kRandomHeight:
508+ tool_windows_.noiseheight.toggle();
509+ break;
510+ case ToolMenuEntry::kTerrain:
511+ tool_windows_.terrain.toggle();
512+ break;
513+ case ToolMenuEntry::kImmovables:
514+ tool_windows_.immovables.toggle();
515+ break;
516+ case ToolMenuEntry::kAnimals:
517+ tool_windows_.critters.toggle();
518+ break;
519+ case ToolMenuEntry::kResources:
520+ tool_windows_.resources.toggle();
521+ break;
522+ case ToolMenuEntry::kPortSpace:
523+ select_tool(tools()->set_port_space, EditorTool::First);
524+ break;
525+ case ToolMenuEntry::kPlayers:
526+ tool_windows_.players.toggle();
527+ break;
528+ case ToolMenuEntry::kMapOrigin:
529+ select_tool(tools()->set_origin, EditorTool::First);
530+ break;
531+ case ToolMenuEntry::kMapSize:
532+ tool_windows_.resizemap.toggle();
533+ break;
534+ case ToolMenuEntry::kFieldInfo:
535+ select_tool(tools()->info, EditorTool::First);
536+ break;
537+ }
538+ toolmenu_.toggle();
539+}
540+
541+void EditorInteractive::add_showhide_menu() {
542+ showhidemenu_.set_image(g_gr->images().get("images/wui/menus/showhide.png"));
543+ toolbar()->add(&showhidemenu_);
544+
545+ rebuild_showhide_menu();
546+
547+ showhidemenu_.selected.connect([this] { showhide_menu_selected(showhidemenu_.get_selected()); });
548+}
549+
550+void EditorInteractive::rebuild_showhide_menu() {
551+ showhidemenu_.clear();
552+
553+ /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether building spaces are shown */
554+ showhidemenu_.add(buildhelp() ? _("Hide Building Spaces") : _("Show Building Spaces"),
555+ ShowHideEntry::kBuildingSpaces, g_gr->images().get("images/wui/menus/toggle_buildhelp.png"),
556+ false, "", pgettext("hotkey", "Space"));
557+
558+ /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether the map grid is shown */
559+ showhidemenu_.add(draw_grid_ ? _("Hide Grid") : _("Show Grid"),
560+ ShowHideEntry::kGrid, g_gr->images().get("images/wui/menus/menu_toggle_grid.png"),
561+ false, "", "G");
562+
563+ /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether immovables (trees, rocks etc.) are shown */
564+ showhidemenu_.add(draw_immovables_ ? _("Hide Immovables") : _("Show Immovables"), ShowHideEntry::kImmovables,
565+ g_gr->images().get("images/wui/menus/toggle_immovables.png"));
566+
567+ /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether animals are shown */
568+ showhidemenu_.add(draw_bobs_ ? _("Hide Animals") : _("Show Animals"), ShowHideEntry::kAnimals,
569+ g_gr->images().get("images/wui/menus/toggle_bobs.png"));
570+
571+ /** TRANSLATORS: An entry in the editor's show/hide menu to toggle whether resources are shown */
572+ showhidemenu_.add(draw_resources_ ? _("Hide Resources") : _("Show Resources"), ShowHideEntry::kResources,
573+ g_gr->images().get("images/wui/menus/toggle_resources.png"));
574+
575+}
576+
577+void EditorInteractive::showhide_menu_selected(ShowHideEntry entry) {
578+ switch (entry) {
579+ case ShowHideEntry::kBuildingSpaces: {
580+ toggle_buildhelp();
581+ } break;
582+ case ShowHideEntry::kGrid: {
583+ toggle_grid();
584+ } break;
585+ case ShowHideEntry::kImmovables: {
586+ toggle_immovables();
587+ } break;
588+ case ShowHideEntry::kAnimals: {
589+ toggle_bobs();
590+ } break;
591+ case ShowHideEntry::kResources: {
592+ toggle_resources();
593+ } break;
594+ }
595+ rebuild_showhide_menu();
596 }
597
598 void EditorInteractive::load(const std::string& filename) {
599@@ -399,7 +655,7 @@
600 set_sel_radius(0);
601 return;
602 }
603- if (UI::UniqueWindow* const w = toolsizemenu_.window) {
604+ if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
605 dynamic_cast<EditorToolsizeMenu&>(*w).update(val);
606 } else {
607 set_sel_radius(val);
608@@ -414,28 +670,20 @@
609 return true;
610 }
611
612-void EditorInteractive::on_buildhelp_changed(const bool value) {
613- toggle_buildhelp_->set_perm_pressed(value);
614-}
615-
616 void EditorInteractive::toggle_resources() {
617 draw_resources_ = !draw_resources_;
618- toggle_resources_->set_perm_pressed(draw_resources_);
619 }
620
621 void EditorInteractive::toggle_immovables() {
622 draw_immovables_ = !draw_immovables_;
623- toggle_immovables_->set_perm_pressed(draw_immovables_);
624 }
625
626 void EditorInteractive::toggle_bobs() {
627 draw_bobs_ = !draw_bobs_;
628- toggle_bobs_->set_perm_pressed(draw_bobs_);
629 }
630
631 void EditorInteractive::toggle_grid() {
632 draw_grid_ = !draw_grid_;
633- toggle_grid_->set_perm_pressed(draw_grid_);
634 }
635
636 bool EditorInteractive::handle_key(bool const down, SDL_Keysym const code) {
637@@ -530,21 +778,19 @@
638 return true;
639
640 case SDLK_l:
641- if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
642- new MainMenuLoadMap(*this);
643- return true;
644-
645- case SDLK_m:
646- minimap_registry().toggle();
647+ if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
648+ menu_windows_.loadmap.toggle();
649+ }
650 return true;
651
652 case SDLK_p:
653- playermenu_.toggle();
654+ tool_windows_.players.toggle();
655 return true;
656
657 case SDLK_s:
658- if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
659- new MainMenuSaveMap(*this);
660+ if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
661+ menu_windows_.savemap.toggle();
662+ }
663 return true;
664
665 case SDLK_t:
666@@ -564,7 +810,7 @@
667 return true;
668
669 case SDLK_F1:
670- helpmenu_.toggle();
671+ menu_windows_.help.toggle();
672 return true;
673
674 default:
675@@ -595,12 +841,12 @@
676 if (which == EditorTool::First && &primary != tools_->current_pointer) {
677 if (primary.has_size_one()) {
678 set_sel_radius(0);
679- if (UI::UniqueWindow* const w = toolsizemenu_.window) {
680+ if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
681 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
682 toolsize_menu.set_buttons_enabled(false);
683 }
684 } else {
685- if (UI::UniqueWindow* const w = toolsizemenu_.window) {
686+ if (UI::UniqueWindow* const w = menu_windows_.toolsize.window) {
687 EditorToolsizeMenu& toolsize_menu = dynamic_cast<EditorToolsizeMenu&>(*w);
688 toolsize_menu.update(toolsize_menu.value());
689 }
690
691=== modified file 'src/editor/editorinteractive.h'
692--- src/editor/editorinteractive.h 2019-04-24 16:59:23 +0000
693+++ src/editor/editorinteractive.h 2019-08-10 10:01:32 +0000
694@@ -37,10 +37,10 @@
695 #include "logic/map.h"
696 #include "notifications/notifications.h"
697 #include "ui_basic/button.h"
698+#include "ui_basic/dropdown.h"
699 #include "ui_basic/unique_window.h"
700 #include "wui/interactive_base.h"
701
702-class Editor;
703 class EditorTool;
704
705 /**
706@@ -138,16 +138,63 @@
707 // Access to the tools.
708 Tools* tools();
709
710- UI::UniqueWindow::Registry window_help;
711-
712 private:
713- friend struct EditorToolMenu;
714+ // For referencing the items in mainmenu_
715+ enum class MainMenuEntry {
716+ kNewMap,
717+ kNewRandomMap,
718+ kLoadMap,
719+ kSaveMap,
720+ kMapOptions,
721+ kExitEditor,
722+ };
723+
724+ // For referencing the items in toolmenu_
725+ enum class ToolMenuEntry {
726+ kChangeHeight,
727+ kRandomHeight,
728+ kTerrain,
729+ kImmovables,
730+ kAnimals,
731+ kResources,
732+ kPortSpace,
733+ kPlayers,
734+ kMapOrigin,
735+ kMapSize,
736+ kFieldInfo
737+ };
738+
739+ // For referencing the items in showhidemenu_
740+ enum class ShowHideEntry {
741+ kBuildingSpaces,
742+ kGrid,
743+ kAnimals,
744+ kImmovables,
745+ kResources
746+ };
747+
748+ // Adds the mainmenu_ to the toolbar
749+ void add_main_menu();
750+ // Takes the appropriate action when an item in the mainmenu_ is selected
751+ void main_menu_selected(MainMenuEntry entry);
752+ // Adds the toolmenu_ to the toolbar
753+ void add_tool_menu();
754+ // Takes the appropriate action when an item in the toolmenu_ is selected
755+ void tool_menu_selected(ToolMenuEntry entry);
756+
757+ // Adds the showhidemenu_ to the toolbar
758+ void add_showhide_menu();
759+ void rebuild_showhide_menu() override;
760+ // Takes the appropriate action when an item in the showhidemenu_ is selected
761+ void showhide_menu_selected(ShowHideEntry entry);
762
763 bool player_hears_field(const Widelands::Coords& coords) const override;
764- void on_buildhelp_changed(const bool value) override;
765
766+ // Show / hide the resources overlays in the mapview
767 void toggle_resources();
768+ // Show / hide the immovables in the mapview
769 void toggle_immovables();
770+ // Show / hide the bobs in the mapview
771 void toggle_bobs();
772 void toggle_grid();
773
774@@ -156,25 +203,38 @@
775 uint32_t realtime_;
776 bool is_painting_;
777
778- UI::UniqueWindow::Registry toolmenu_;
779-
780- UI::UniqueWindow::Registry toolsizemenu_;
781- UI::UniqueWindow::Registry playermenu_;
782- UI::UniqueWindow::Registry mainmenu_;
783- UI::UniqueWindow::Registry heightmenu_;
784- UI::UniqueWindow::Registry noise_heightmenu_;
785- UI::UniqueWindow::Registry terrainmenu_;
786- UI::UniqueWindow::Registry immovablemenu_;
787- UI::UniqueWindow::Registry crittermenu_;
788- UI::UniqueWindow::Registry resourcesmenu_;
789- UI::UniqueWindow::Registry resizemenu_;
790- UI::UniqueWindow::Registry helpmenu_;
791-
792- UI::Button* toggle_buildhelp_;
793- UI::Button* toggle_grid_;
794- UI::Button* toggle_resources_;
795- UI::Button* toggle_immovables_;
796- UI::Button* toggle_bobs_;
797+ // All unique menu windows
798+ struct EditorMenuWindows {
799+ UI::UniqueWindow::Registry newmap;
800+ UI::UniqueWindow::Registry newrandommap;
801+ UI::UniqueWindow::Registry savemap;
802+ UI::UniqueWindow::Registry loadmap;
803+ UI::UniqueWindow::Registry mapoptions;
804+
805+ UI::UniqueWindow::Registry toolsize;
806+
807+ UI::UniqueWindow::Registry help;
808+ } menu_windows_;
809+
810+ // All unique tool windows for those tools that have them
811+ struct EditorToolWindows {
812+ UI::UniqueWindow::Registry height;
813+ UI::UniqueWindow::Registry noiseheight;
814+ UI::UniqueWindow::Registry terrain;
815+ UI::UniqueWindow::Registry immovables;
816+ UI::UniqueWindow::Registry critters;
817+ UI::UniqueWindow::Registry resources;
818+ UI::UniqueWindow::Registry players;
819+ UI::UniqueWindow::Registry resizemap;
820+ } tool_windows_;
821+
822+ // Main menu on the toolbar
823+ UI::Dropdown<MainMenuEntry> mainmenu_;
824+ // Tools menu on the toolbar
825+ UI::Dropdown<ToolMenuEntry> toolmenu_;
826+ // Show / Hide menu on the toolbar
827+ UI::Dropdown<ShowHideEntry> showhidemenu_;
828+
829 UI::Button* undo_;
830 UI::Button* redo_;
831
832
833=== removed file 'src/editor/ui_menus/main_menu.cc'
834--- src/editor/ui_menus/main_menu.cc 2019-02-23 11:00:49 +0000
835+++ src/editor/ui_menus/main_menu.cc 1970-01-01 00:00:00 +0000
836@@ -1,110 +0,0 @@
837-/*
838- * Copyright (C) 2002-2019 by the Widelands Development Team
839- *
840- * This program is free software; you can redistribute it and/or
841- * modify it under the terms of the GNU General Public License
842- * as published by the Free Software Foundation; either version 2
843- * of the License, or (at your option) any later version.
844- *
845- * This program is distributed in the hope that it will be useful,
846- * but WITHOUT ANY WARRANTY; without even the implied warranty of
847- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
848- * GNU General Public License for more details.
849- *
850- * You should have received a copy of the GNU General Public License
851- * along with this program; if not, write to the Free Software
852- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
853- *
854- */
855-
856-#include "editor/ui_menus/main_menu.h"
857-
858-#include "base/i18n.h"
859-#include "editor/editorinteractive.h"
860-#include "editor/ui_menus/main_menu_load_map.h"
861-#include "editor/ui_menus/main_menu_map_options.h"
862-#include "editor/ui_menus/main_menu_new_map.h"
863-#include "editor/ui_menus/main_menu_random_map.h"
864-#include "editor/ui_menus/main_menu_save_map.h"
865-
866-// TODO(unknown): these should be defined globally for the whole UI
867-#define width 200
868-#define margin 15
869-#define vspacing 15
870-
871-inline EditorInteractive& EditorMainMenu::eia() {
872- return dynamic_cast<EditorInteractive&>(*get_parent());
873-}
874-
875-/**
876- * Create all the buttons etc...
877- */
878-EditorMainMenu::EditorMainMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
879- : UI::UniqueWindow(&parent, "main_menu", &registry, 2 * margin + width, 0, _("Main Menu")),
880- box_(this, margin, margin, UI::Box::Vertical, width, get_h() - 2 * margin, vspacing),
881- button_new_map_(
882- &box_, "new_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("New Map")),
883- button_new_random_map_(&box_,
884- "new_random_map",
885- 0,
886- 0,
887- width,
888- 0,
889- UI::ButtonStyle::kWuiSecondary,
890- _("New Random Map")),
891- button_load_map_(
892- &box_, "load_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Load Map")),
893- button_save_map_(
894- &box_, "save_map", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Save Map")),
895- button_map_options_(
896- &box_, "map_options", 0, 0, width, 0, UI::ButtonStyle::kWuiSecondary, _("Map Options")),
897- button_exit_editor_(
898- &box_, "exit", 0, 0, width, 0, UI::ButtonStyle::kWuiPrimary, _("Exit Editor")) {
899- box_.add(&button_new_map_);
900- box_.add(&button_new_random_map_);
901- box_.add(&button_load_map_);
902- box_.add(&button_save_map_);
903- box_.add(&button_map_options_);
904- box_.add(&button_exit_editor_);
905- box_.set_size(width, 6 * button_new_map_.get_h() + 5 * vspacing);
906- set_inner_size(get_inner_w(), box_.get_h() + 2 * margin);
907-
908- button_new_map_.sigclicked.connect(boost::bind(&EditorMainMenu::new_map_btn, this));
909- button_new_random_map_.sigclicked.connect(
910- boost::bind(&EditorMainMenu::new_random_map_btn, this));
911- button_load_map_.sigclicked.connect(boost::bind(&EditorMainMenu::load_btn, this));
912- button_save_map_.sigclicked.connect(boost::bind(&EditorMainMenu::save_btn, this));
913- button_map_options_.sigclicked.connect(boost::bind(&EditorMainMenu::map_options_btn, this));
914- button_exit_editor_.sigclicked.connect(boost::bind(&EditorMainMenu::exit_btn, this));
915-
916- // Put in the default position, if necessary
917- if (get_usedefaultpos())
918- center_to_parent();
919-}
920-
921-void EditorMainMenu::new_map_btn() {
922- new MainMenuNewMap(eia());
923- die();
924-}
925-
926-void EditorMainMenu::new_random_map_btn() {
927- new MainMenuNewRandomMap(eia());
928- die();
929-}
930-
931-void EditorMainMenu::load_btn() {
932- new MainMenuLoadMap(eia());
933- die();
934-}
935-
936-void EditorMainMenu::save_btn() {
937- new MainMenuSaveMap(eia());
938- die();
939-}
940-void EditorMainMenu::map_options_btn() {
941- new MainMenuMapOptions(eia());
942- die();
943-}
944-void EditorMainMenu::exit_btn() {
945- eia().exit();
946-}
947
948=== removed file 'src/editor/ui_menus/main_menu.h'
949--- src/editor/ui_menus/main_menu.h 2019-02-23 11:00:49 +0000
950+++ src/editor/ui_menus/main_menu.h 1970-01-01 00:00:00 +0000
951@@ -1,53 +0,0 @@
952-/*
953- * Copyright (C) 2002-2019 by the Widelands Development Team
954- *
955- * This program is free software; you can redistribute it and/or
956- * modify it under the terms of the GNU General Public License
957- * as published by the Free Software Foundation; either version 2
958- * of the License, or (at your option) any later version.
959- *
960- * This program is distributed in the hope that it will be useful,
961- * but WITHOUT ANY WARRANTY; without even the implied warranty of
962- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
963- * GNU General Public License for more details.
964- *
965- * You should have received a copy of the GNU General Public License
966- * along with this program; if not, write to the Free Software
967- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
968- *
969- */
970-
971-#ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_H
972-#define WL_EDITOR_UI_MENUS_MAIN_MENU_H
973-
974-#include "ui_basic/box.h"
975-#include "ui_basic/button.h"
976-#include "ui_basic/unique_window.h"
977-
978-class EditorInteractive;
979-
980-/**
981- * This represents the main menu
982- */
983-struct EditorMainMenu : public UI::UniqueWindow {
984- EditorMainMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
985-
986-private:
987- EditorInteractive& eia();
988- UI::Box box_;
989- UI::Button button_new_map_;
990- UI::Button button_new_random_map_;
991- UI::Button button_load_map_;
992- UI::Button button_save_map_;
993- UI::Button button_map_options_;
994- UI::Button button_exit_editor_;
995-
996- void exit_btn();
997- void load_btn();
998- void save_btn();
999- void new_map_btn();
1000- void new_random_map_btn();
1001- void map_options_btn();
1002-};
1003-
1004-#endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_H
1005
1006=== modified file 'src/editor/ui_menus/main_menu_load_map.cc'
1007--- src/editor/ui_menus/main_menu_load_map.cc 2019-02-23 11:00:49 +0000
1008+++ src/editor/ui_menus/main_menu_load_map.cc 2019-08-10 10:01:32 +0000
1009@@ -32,8 +32,8 @@
1010 /**
1011 * Create all the buttons etc...
1012 */
1013-MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent)
1014- : MainMenuLoadOrSaveMap(parent, 2, "load_map_menu", _("Load Map")) {
1015+MainMenuLoadMap::MainMenuLoadMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
1016+ : MainMenuLoadOrSaveMap(parent, registry, 2, "load_map_menu", _("Load Map")) {
1017 set_current_directory(curdir_);
1018
1019 table_.selected.connect(boost::bind(&MainMenuLoadMap::entry_selected, this));
1020
1021=== modified file 'src/editor/ui_menus/main_menu_load_map.h'
1022--- src/editor/ui_menus/main_menu_load_map.h 2019-02-23 11:00:49 +0000
1023+++ src/editor/ui_menus/main_menu_load_map.h 2019-08-10 10:01:32 +0000
1024@@ -29,7 +29,7 @@
1025 * Choose a filename and save your brand new created map
1026 */
1027 struct MainMenuLoadMap : public MainMenuLoadOrSaveMap {
1028- explicit MainMenuLoadMap(EditorInteractive& parent);
1029+ explicit MainMenuLoadMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry);
1030
1031 protected:
1032 void clicked_ok() override;
1033
1034=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.cc'
1035--- src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-04-19 05:13:02 +0000
1036+++ src/editor/ui_menus/main_menu_load_or_save_map.cc 2019-08-10 10:01:32 +0000
1037@@ -30,12 +30,12 @@
1038 #include "io/filesystem/layered_filesystem.h"
1039 #include "map_io/widelands_map_loader.h"
1040
1041-MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent,
1042+MainMenuLoadOrSaveMap::MainMenuLoadOrSaveMap(EditorInteractive& parent, Registry& registry,
1043 int no_of_bottom_rows,
1044 const std::string& name,
1045 const std::string& title,
1046 const std::string& basedir)
1047- : UI::Window(&parent, name, 0, 0, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title),
1048+ : UI::UniqueWindow(&parent, name, &registry, parent.get_inner_w() - 40, parent.get_inner_h() - 40, title),
1049
1050 // Values for alignment and size
1051 padding_(4),
1052
1053=== modified file 'src/editor/ui_menus/main_menu_load_or_save_map.h'
1054--- src/editor/ui_menus/main_menu_load_or_save_map.h 2019-02-23 11:00:49 +0000
1055+++ src/editor/ui_menus/main_menu_load_or_save_map.h 2019-08-10 10:01:32 +0000
1056@@ -27,15 +27,16 @@
1057 #include "ui_basic/button.h"
1058 #include "ui_basic/checkbox.h"
1059 #include "ui_basic/textarea.h"
1060-#include "ui_basic/window.h"
1061+#include "ui_basic/unique_window.h"
1062 #include "wui/mapdetails.h"
1063 #include "wui/maptable.h"
1064
1065 /**
1066 * Choose a filename and save your brand new created map
1067 */
1068-struct MainMenuLoadOrSaveMap : public UI::Window {
1069+struct MainMenuLoadOrSaveMap : public UI::UniqueWindow {
1070 MainMenuLoadOrSaveMap(EditorInteractive& parent,
1071+ UI::UniqueWindow::Registry& registry,
1072 int no_of_bottom_rows,
1073 const std::string& name,
1074 const std::string& title,
1075
1076=== modified file 'src/editor/ui_menus/main_menu_map_options.cc'
1077--- src/editor/ui_menus/main_menu_map_options.cc 2019-04-18 08:32:25 +0000
1078+++ src/editor/ui_menus/main_menu_map_options.cc 2019-08-10 10:01:32 +0000
1079@@ -42,8 +42,8 @@
1080 /**
1081 * Create all the buttons etc...
1082 */
1083-MainMenuMapOptions::MainMenuMapOptions(EditorInteractive& parent, bool modal)
1084- : UI::Window(&parent, "map_options", 0, 0, 350, parent.get_inner_h() - 80, _("Map Options")),
1085+MainMenuMapOptions::MainMenuMapOptions(EditorInteractive& parent, Registry& registry)
1086+ : UI::UniqueWindow(&parent, "map_options", &registry, 350, parent.get_inner_h() - 80, _("Map Options")),
1087 padding_(4),
1088 indent_(10),
1089 labelh_(text_height(UI::FontStyle::kLabel) + 4),
1090@@ -80,7 +80,7 @@
1091 teams_list_(
1092 &teams_box_, 0, 0, max_w_, 60, UI::PanelStyle::kWui, UI::ListselectLayout::kShowCheck),
1093
1094- modal_(modal) {
1095+ registry_(registry) {
1096
1097 tab_box_.set_size(max_w_, get_inner_h() - labelh_ - 2 * padding_);
1098 tabs_.set_size(max_w_, tab_box_.get_inner_h());
1099@@ -139,11 +139,11 @@
1100 teams_box_.add(new UI::Textarea(&teams_box_, 0, 0, max_w_, labelh_, players));
1101
1102 tab_box_.add(&tabs_, UI::Box::Resizing::kFullSize);
1103- tabs_.add("main_map_options", g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),
1104+ tabs_.add("main_map_options", g_gr->images().get("images/wui/menus/toggle_minimap.png"),
1105 &main_box_, _("Main Options"));
1106 tabs_.add("map_tags", g_gr->images().get("images/ui_basic/checkbox_checked.png"), &tags_box_,
1107 _("Tags"));
1108- tabs_.add("map_teams", g_gr->images().get("images/wui/editor/editor_menu_player_menu.png"),
1109+ tabs_.add("map_teams", g_gr->images().get("images/wui/editor/tools/players.png"),
1110 &teams_box_, _("Teams"));
1111
1112 name_.changed.connect(boost::bind(&MainMenuMapOptions::changed, this));
1113@@ -203,20 +203,12 @@
1114 eia().egbase().mutable_map()->add_tag(tag.first);
1115 }
1116 }
1117-
1118- if (modal_) {
1119- end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kOk);
1120- } else {
1121- die();
1122- }
1123+ Notifications::publish(NoteMapOptions());
1124+ registry_.destroy();
1125 }
1126
1127 void MainMenuMapOptions::clicked_cancel() {
1128- if (modal_) {
1129- end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
1130- } else {
1131- die();
1132- }
1133+ registry_.destroy();
1134 }
1135
1136 /*
1137
1138=== modified file 'src/editor/ui_menus/main_menu_map_options.h'
1139--- src/editor/ui_menus/main_menu_map_options.h 2019-02-23 11:00:49 +0000
1140+++ src/editor/ui_menus/main_menu_map_options.h 2019-08-10 10:01:32 +0000
1141@@ -20,6 +20,7 @@
1142 #ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
1143 #define WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
1144
1145+#include "logic/note_map_options.h"
1146 #include "ui_basic/box.h"
1147 #include "ui_basic/button.h"
1148 #include "ui_basic/checkbox.h"
1149@@ -28,7 +29,7 @@
1150 #include "ui_basic/multilineeditbox.h"
1151 #include "ui_basic/tabpanel.h"
1152 #include "ui_basic/textarea.h"
1153-#include "ui_basic/window.h"
1154+#include "ui_basic/unique_window.h"
1155
1156 class EditorInteractive;
1157
1158@@ -37,8 +38,8 @@
1159 * about the current map are displayed and you can change
1160 * author, name and description
1161 */
1162-struct MainMenuMapOptions : public UI::Window {
1163- MainMenuMapOptions(EditorInteractive&, bool modal = false);
1164+struct MainMenuMapOptions : public UI::UniqueWindow {
1165+ MainMenuMapOptions(EditorInteractive&, UI::UniqueWindow::Registry& registry);
1166
1167 private:
1168 EditorInteractive& eia();
1169@@ -66,7 +67,7 @@
1170
1171 // Tag, Checkbox
1172 std::map<std::string, UI::Checkbox*> tags_checkboxes_;
1173- bool modal_;
1174+ UI::UniqueWindow::Registry& registry_;
1175 };
1176
1177 #endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_MAP_OPTIONS_H
1178
1179=== modified file 'src/editor/ui_menus/main_menu_new_map.cc'
1180--- src/editor/ui_menus/main_menu_new_map.cc 2019-06-25 07:34:58 +0000
1181+++ src/editor/ui_menus/main_menu_new_map.cc 2019-08-10 10:01:32 +0000
1182@@ -41,8 +41,8 @@
1183 return dynamic_cast<EditorInteractive&>(*get_parent());
1184 }
1185
1186-MainMenuNewMap::MainMenuNewMap(EditorInteractive& parent)
1187- : UI::Window(&parent, "new_map_menu", 0, 0, 360, 150, _("New Map")),
1188+MainMenuNewMap::MainMenuNewMap(EditorInteractive& parent, Registry& registry)
1189+ : UI::UniqueWindow(&parent, "new_map_menu", &registry, 360, 150, _("New Map")),
1190 margin_(4),
1191 box_width_(get_inner_w() - 2 * margin_),
1192 box_(this, margin_, margin_, UI::Box::Vertical, 0, 0, margin_),
1193
1194=== modified file 'src/editor/ui_menus/main_menu_new_map.h'
1195--- src/editor/ui_menus/main_menu_new_map.h 2019-06-01 08:18:58 +0000
1196+++ src/editor/ui_menus/main_menu_new_map.h 2019-08-10 10:01:32 +0000
1197@@ -25,7 +25,7 @@
1198 #include "ui_basic/box.h"
1199 #include "ui_basic/button.h"
1200 #include "ui_basic/listselect.h"
1201-#include "ui_basic/window.h"
1202+#include "ui_basic/unique_window.h"
1203
1204 class EditorInteractive;
1205
1206@@ -34,8 +34,8 @@
1207 * the user to choose the new world and a few other
1208 * things like size, world ....
1209 */
1210-struct MainMenuNewMap : public UI::Window {
1211- explicit MainMenuNewMap(EditorInteractive&);
1212+struct MainMenuNewMap : public UI::UniqueWindow {
1213+ explicit MainMenuNewMap(EditorInteractive&, UI::UniqueWindow::Registry&);
1214
1215 private:
1216 EditorInteractive& eia();
1217
1218=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
1219--- src/editor/ui_menus/main_menu_random_map.cc 2019-06-25 07:34:58 +0000
1220+++ src/editor/ui_menus/main_menu_random_map.cc 2019-08-10 10:01:32 +0000
1221@@ -47,8 +47,8 @@
1222
1223 using namespace Widelands;
1224
1225-MainMenuNewRandomMap::MainMenuNewRandomMap(EditorInteractive& parent)
1226- : UI::Window(&parent, "random_map_menu", 0, 0, 400, 500, _("New Random Map")),
1227+MainMenuNewRandomMap::MainMenuNewRandomMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
1228+ : UI::UniqueWindow(&parent, "random_map_menu", &registry, 400, 500, _("New Random Map")),
1229 // UI elements
1230 margin_(4),
1231 box_width_(get_inner_w() - 2 * margin_),
1232
1233=== modified file 'src/editor/ui_menus/main_menu_random_map.h'
1234--- src/editor/ui_menus/main_menu_random_map.h 2019-06-01 08:18:58 +0000
1235+++ src/editor/ui_menus/main_menu_random_map.h 2019-08-10 10:01:32 +0000
1236@@ -30,7 +30,7 @@
1237 #include "ui_basic/editbox.h"
1238 #include "ui_basic/spinbox.h"
1239 #include "ui_basic/textarea.h"
1240-#include "ui_basic/window.h"
1241+#include "ui_basic/unique_window.h"
1242
1243 namespace Widelands {
1244 struct UniqueRandomMapInfo;
1245@@ -46,8 +46,8 @@
1246 * the user to choose the new world and a few other
1247 * things like size, world ....
1248 */
1249-struct MainMenuNewRandomMap : public UI::Window {
1250- explicit MainMenuNewRandomMap(EditorInteractive&);
1251+struct MainMenuNewRandomMap : public UI::UniqueWindow {
1252+ explicit MainMenuNewRandomMap(EditorInteractive&, UI::UniqueWindow::Registry&);
1253
1254 enum class ButtonId : uint8_t {
1255 kNone,
1256
1257=== modified file 'src/editor/ui_menus/main_menu_save_map.cc'
1258--- src/editor/ui_menus/main_menu_save_map.cc 2019-04-18 08:32:25 +0000
1259+++ src/editor/ui_menus/main_menu_save_map.cc 2019-08-10 10:01:32 +0000
1260@@ -31,7 +31,6 @@
1261 #include "base/macros.h"
1262 #include "base/wexception.h"
1263 #include "editor/editorinteractive.h"
1264-#include "editor/ui_menus/main_menu_map_options.h"
1265 #include "editor/ui_menus/main_menu_save_map_make_directory.h"
1266 #include "io/filesystem/filesystem.h"
1267 #include "io/filesystem/layered_filesystem.h"
1268@@ -49,9 +48,9 @@
1269 }
1270
1271 // TODO(GunChleoc): Arabic: Make directory dialog: buttons need more height for Arabic.
1272-MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent)
1273- : MainMenuLoadOrSaveMap(parent, 3, "save_map_menu", _("Save Map"), "maps/My_Maps"),
1274-
1275+MainMenuSaveMap::MainMenuSaveMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry, Registry& map_options_registry)
1276+ : MainMenuLoadOrSaveMap(parent, registry, 3, "save_map_menu", _("Save Map"), "maps/My_Maps"),
1277+ map_options_registry_(map_options_registry),
1278 make_directory_(this,
1279 "make_directory",
1280 right_column_x_,
1281@@ -114,6 +113,10 @@
1282 MapData mapdata(map, "", maptype, MapData::DisplayType::kMapnames);
1283
1284 map_details_.update(mapdata, false);
1285+
1286+ subscriber_ = Notifications::subscribe<NoteMapOptions>([this](const NoteMapOptions&) {
1287+ update_map_options();
1288+ });
1289 }
1290
1291 /**
1292@@ -196,24 +199,29 @@
1293 }
1294
1295 void MainMenuSaveMap::clicked_edit_options() {
1296- MainMenuMapOptions mo(eia(), true);
1297- if (mo.run<UI::Panel::Returncodes>() == UI::Panel::Returncodes::kOk) {
1298- const Widelands::Map& map = eia().egbase().map();
1299- MapData::MapType maptype;
1300-
1301- if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||
1302- map.scenario_types() & Widelands::Map::SP_SCENARIO) {
1303- maptype = MapData::MapType::kScenario;
1304- } else {
1305- maptype = MapData::MapType::kNormal;
1306- }
1307-
1308- MapData mapdata(map, editbox_->text(), maptype, MapData::DisplayType::kMapnames);
1309-
1310- map_details_.update(mapdata, false);
1311- }
1312-}
1313-
1314+ map_options_registry_.create();
1315+}
1316+
1317+void MainMenuSaveMap::update_map_options() {
1318+ const Widelands::Map& map = eia().egbase().map();
1319+ MapData::MapType maptype;
1320+
1321+ const std::string old_name = map_details_.name();
1322+
1323+ if (map.scenario_types() & Widelands::Map::MP_SCENARIO ||
1324+ map.scenario_types() & Widelands::Map::SP_SCENARIO) {
1325+ maptype = MapData::MapType::kScenario;
1326+ } else {
1327+ maptype = MapData::MapType::kNormal;
1328+ }
1329+
1330+ MapData mapdata(map, editbox_->text(), maptype, MapData::DisplayType::kMapnames);
1331+
1332+ map_details_.update(mapdata, false);
1333+ if (old_name == editbox_->text()) {
1334+ editbox_->set_text(map_details_.name());
1335+ }
1336+}
1337 /**
1338 * called when an item was selected
1339 */
1340
1341=== modified file 'src/editor/ui_menus/main_menu_save_map.h'
1342--- src/editor/ui_menus/main_menu_save_map.h 2019-02-23 11:00:49 +0000
1343+++ src/editor/ui_menus/main_menu_save_map.h 2019-08-10 10:01:32 +0000
1344@@ -20,10 +20,12 @@
1345 #ifndef WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
1346 #define WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
1347
1348+#include <memory>
1349 #include <string>
1350
1351 #include "editor/editorinteractive.h"
1352 #include "editor/ui_menus/main_menu_load_or_save_map.h"
1353+#include "editor/ui_menus/main_menu_map_options.h"
1354 #include "ui_basic/button.h"
1355 #include "ui_basic/editbox.h"
1356 #include "ui_basic/textarea.h"
1357@@ -32,7 +34,7 @@
1358 * Choose a filename and save your brand new created map
1359 */
1360 struct MainMenuSaveMap : public MainMenuLoadOrSaveMap {
1361- explicit MainMenuSaveMap(EditorInteractive& parent);
1362+ explicit MainMenuSaveMap(EditorInteractive& parent, UI::UniqueWindow::Registry& registry, UI::UniqueWindow::Registry& map_options_registry);
1363
1364 protected:
1365 // Sets the current dir and updates labels.
1366@@ -40,6 +42,8 @@
1367
1368 private:
1369 EditorInteractive& eia();
1370+ Registry& map_options_registry_;
1371+
1372 void clicked_ok() override;
1373 void clicked_make_directory();
1374 void clicked_edit_options();
1375@@ -49,6 +53,8 @@
1376 /// Resets the map's filename in the editbox. If mapname didn't change, die().
1377 void reset_editbox_or_die(const std::string& current_filename);
1378
1379+ void update_map_options();
1380+
1381 bool save_map(std::string, bool);
1382
1383 UI::Button make_directory_, edit_options_;
1384@@ -56,6 +62,8 @@
1385 UI::Textarea editbox_label_;
1386 UI::EditBox* editbox_;
1387 const std::string illegal_filename_tooltip_;
1388+
1389+ std::unique_ptr<Notifications::Subscriber<NoteMapOptions>> subscriber_;
1390 };
1391
1392 #endif // end of include guard: WL_EDITOR_UI_MENUS_MAIN_MENU_SAVE_MAP_H
1393
1394=== modified file 'src/editor/ui_menus/player_menu.cc'
1395--- src/editor/ui_menus/player_menu.cc 2019-06-25 07:34:58 +0000
1396+++ src/editor/ui_menus/player_menu.cc 2019-08-10 10:01:32 +0000
1397@@ -119,8 +119,8 @@
1398 return dynamic_cast<EditorInteractive&>(*get_parent());
1399 }
1400
1401-EditorPlayerMenu::EditorPlayerMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
1402- : UI::UniqueWindow(&parent, "players_menu", &registry, 100, 100, _("Player Options")),
1403+EditorPlayerMenu::EditorPlayerMenu(EditorInteractive& parent, EditorSetStartingPosTool& tool, UI::UniqueWindow::Registry& registry)
1404+ : EditorToolOptionsMenu(parent, registry, 0, 0, _("Player Options"), tool),
1405 box_(this, kMargin, kMargin, UI::Box::Vertical),
1406 no_of_players_(&box_,
1407 "dropdown_map_players",
1408
1409=== modified file 'src/editor/ui_menus/player_menu.h'
1410--- src/editor/ui_menus/player_menu.h 2019-02-27 19:00:36 +0000
1411+++ src/editor/ui_menus/player_menu.h 2019-08-10 10:01:32 +0000
1412@@ -24,6 +24,7 @@
1413 #include <string>
1414 #include <vector>
1415
1416+#include "editor/ui_menus/tool_options_menu.h"
1417 #include "ui_basic/box.h"
1418 #include "ui_basic/button.h"
1419 #include "ui_basic/dropdown.h"
1420@@ -32,9 +33,9 @@
1421
1422 class EditorInteractive;
1423
1424-class EditorPlayerMenu : public UI::UniqueWindow {
1425+class EditorPlayerMenu : public EditorToolOptionsMenu {
1426 public:
1427- EditorPlayerMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
1428+ EditorPlayerMenu(EditorInteractive&, EditorSetStartingPosTool& tool, UI::UniqueWindow::Registry&);
1429 ~EditorPlayerMenu() override {
1430 }
1431
1432
1433=== modified file 'src/editor/ui_menus/tool_change_height_options_menu.cc'
1434--- src/editor/ui_menus/tool_change_height_options_menu.cc 2019-02-23 11:00:49 +0000
1435+++ src/editor/ui_menus/tool_change_height_options_menu.cc 2019-08-10 10:01:32 +0000
1436@@ -32,7 +32,7 @@
1437 EditorInteractive& parent,
1438 EditorIncreaseHeightTool& increase_tool,
1439 UI::UniqueWindow::Registry& registry)
1440- : EditorToolOptionsMenu(parent, registry, 350, 100, _("Height Tools Options")),
1441+ : EditorToolOptionsMenu(parent, registry, 350, 100, _("Height Tools Options"), increase_tool),
1442 increase_tool_(increase_tool),
1443 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
1444 change_by_(&box_,
1445
1446=== modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc'
1447--- src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-05-12 07:45:59 +0000
1448+++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2019-08-10 10:01:32 +0000
1449@@ -45,7 +45,7 @@
1450 EditorInteractive& parent,
1451 EditorIncreaseResourcesTool& increase_tool,
1452 UI::UniqueWindow::Registry& registry)
1453- : EditorToolOptionsMenu(parent, registry, 370, 120, _("Resources")),
1454+ : EditorToolOptionsMenu(parent, registry, 370, 120, _("Resources"), increase_tool),
1455 increase_tool_(increase_tool),
1456 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
1457 change_by_(&box_,
1458
1459=== removed file 'src/editor/ui_menus/tool_menu.cc'
1460--- src/editor/ui_menus/tool_menu.cc 2019-04-24 07:09:29 +0000
1461+++ src/editor/ui_menus/tool_menu.cc 1970-01-01 00:00:00 +0000
1462@@ -1,193 +0,0 @@
1463-/*
1464- * Copyright (C) 2002-2019 by the Widelands Development Team
1465- *
1466- * This program is free software; you can redistribute it and/or
1467- * modify it under the terms of the GNU General Public License
1468- * as published by the Free Software Foundation; either version 2
1469- * of the License, or (at your option) any later version.
1470- *
1471- * This program is distributed in the hope that it will be useful,
1472- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1473- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1474- * GNU General Public License for more details.
1475- *
1476- * You should have received a copy of the GNU General Public License
1477- * along with this program; if not, write to the Free Software
1478- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1479- *
1480- */
1481-
1482-#include "editor/ui_menus/tool_menu.h"
1483-
1484-#include "base/i18n.h"
1485-#include "base/wexception.h"
1486-#include "editor/editorinteractive.h"
1487-#include "editor/tools/decrease_height_tool.h"
1488-#include "editor/tools/decrease_resources_tool.h"
1489-#include "editor/tools/increase_height_tool.h"
1490-#include "editor/tools/increase_resources_tool.h"
1491-#include "editor/tools/noise_height_tool.h"
1492-#include "editor/tools/place_critter_tool.h"
1493-#include "editor/tools/place_immovable_tool.h"
1494-#include "editor/tools/set_port_space_tool.h"
1495-#include "editor/tools/set_terrain_tool.h"
1496-#include "editor/ui_menus/tool_change_height_options_menu.h"
1497-#include "editor/ui_menus/tool_change_resources_options_menu.h"
1498-#include "editor/ui_menus/tool_noise_height_options_menu.h"
1499-#include "editor/ui_menus/tool_place_critter_options_menu.h"
1500-#include "editor/ui_menus/tool_place_immovable_options_menu.h"
1501-#include "editor/ui_menus/tool_resize_options_menu.h"
1502-#include "editor/ui_menus/tool_set_terrain_options_menu.h"
1503-#include "graphic/graphic.h"
1504-#include "ui_basic/radiobutton.h"
1505-#include "ui_basic/textarea.h"
1506-
1507-EditorToolMenu::EditorToolMenu(EditorInteractive& parent, UI::UniqueWindow::Registry& registry)
1508- : UI::UniqueWindow(&parent, "tool_menu", &registry, 350, 400, _("Tools")) {
1509-
1510-#define spacing 5
1511- Vector2i const offs(spacing, spacing);
1512- Vector2i pos = offs;
1513- int32_t const width = 34;
1514- int32_t const height = 34;
1515-
1516- int32_t const num_tools = 9;
1517-#define ADD_BUTTON(pic, tooltip) \
1518- radioselect_.add_button( \
1519- this, pos, g_gr->images().get("images/wui/editor/editor_menu_tool_" pic ".png"), tooltip); \
1520- pos.x += width + spacing;
1521-
1522- ADD_BUTTON("change_height", _("Change height"))
1523- ADD_BUTTON("noise_height", _("Random height"))
1524- ADD_BUTTON("set_terrain", _("Terrain"))
1525- ADD_BUTTON("place_immovable", _("Immovables"))
1526- ADD_BUTTON("place_bob", _("Animals"))
1527- ADD_BUTTON("change_resources", _("Resources"))
1528- ADD_BUTTON("set_port_space", _("Set port space"))
1529- ADD_BUTTON("set_origin", _("Set the position that will have the coordinates (0, 0). This will "
1530- "be the top-left corner of a generated minimap."));
1531- ADD_BUTTON("resize", _("Change the map’s size"));
1532-
1533- set_inner_size(offs.x + (width + spacing) * num_tools, offs.y + (height + spacing));
1534-
1535- {
1536- const EditorTool* current = &parent.tools()->current();
1537- radioselect_.set_state(current == &parent.tools()->noise_height ?
1538- 1 :
1539- current == &parent.tools()->set_terrain ?
1540- 2 :
1541- current == &parent.tools()->place_immovable ?
1542- 3 :
1543- current == &parent.tools()->place_critter ?
1544- 4 :
1545- current == &parent.tools()->increase_resources ?
1546- 5 :
1547- current == &parent.tools()->set_port_space ?
1548- 6 :
1549- current == &parent.tools()->set_origin ?
1550- 7 :
1551- current == &parent.tools()->resize ? 8 : 0);
1552- }
1553-
1554- radioselect_.changed.connect(boost::bind(&EditorToolMenu::changed_to, this));
1555- radioselect_.clicked.connect(boost::bind(&EditorToolMenu::changed_to, this));
1556-
1557- if (get_usedefaultpos())
1558- center_to_parent();
1559-}
1560-
1561-/**
1562- * Called when the radiogroup changes or is reclicked
1563- */
1564-void EditorToolMenu::changed_to() {
1565- const int32_t n = radioselect_.get_state();
1566-
1567- EditorInteractive& parent = dynamic_cast<EditorInteractive&>(*get_parent());
1568-
1569- EditorTool* current_tool_pointer = nullptr;
1570- UI::UniqueWindow::Registry* current_registry_pointer = nullptr;
1571- switch (n) {
1572- case 0:
1573- current_tool_pointer = &parent.tools()->increase_height;
1574- current_registry_pointer = &parent.heightmenu_;
1575- break;
1576- case 1:
1577- current_tool_pointer = &parent.tools()->noise_height;
1578- current_registry_pointer = &parent.noise_heightmenu_;
1579- break;
1580- case 2:
1581- current_tool_pointer = &parent.tools()->set_terrain;
1582- current_registry_pointer = &parent.terrainmenu_;
1583- break;
1584- case 3:
1585- current_tool_pointer = &parent.tools()->place_immovable;
1586- current_registry_pointer = &parent.immovablemenu_;
1587- break;
1588- case 4:
1589- current_tool_pointer = &parent.tools()->place_critter;
1590- current_registry_pointer = &parent.crittermenu_;
1591- break;
1592- case 5:
1593- current_tool_pointer = &parent.tools()->increase_resources;
1594- current_registry_pointer = &parent.resourcesmenu_;
1595- break;
1596- case 6:
1597- current_tool_pointer = &parent.tools()->set_port_space;
1598- current_registry_pointer = nullptr; // no need for a window
1599- break;
1600- case 7:
1601- current_tool_pointer = &parent.tools()->set_origin;
1602- current_registry_pointer = nullptr; // no need for a window
1603- break;
1604- case 8:
1605- current_tool_pointer = &parent.tools()->resize;
1606- current_registry_pointer = &parent.resizemenu_;
1607- break;
1608- default:
1609- NEVER_HERE();
1610- }
1611-
1612- parent.select_tool(*current_tool_pointer, EditorTool::First);
1613-
1614- if (current_registry_pointer) {
1615- if (UI::Window* const window = current_registry_pointer->window) {
1616- // There is already a window. If it is minimal, restore it.
1617- if (window->is_minimal())
1618- window->restore();
1619- else
1620- delete window;
1621- } else
1622- switch (n) { // create window
1623- case 0:
1624- new EditorToolChangeHeightOptionsMenu(
1625- parent, parent.tools()->increase_height, *current_registry_pointer);
1626- break;
1627- case 1:
1628- new EditorToolNoiseHeightOptionsMenu(
1629- parent, parent.tools()->noise_height, *current_registry_pointer);
1630- break;
1631- case 2:
1632- new EditorToolSetTerrainOptionsMenu(
1633- parent, parent.tools()->set_terrain, *current_registry_pointer);
1634- break;
1635- case 3:
1636- new EditorToolPlaceImmovableOptionsMenu(
1637- parent, parent.tools()->place_immovable, *current_registry_pointer);
1638- break;
1639- case 4:
1640- new EditorToolPlaceCritterOptionsMenu(
1641- parent, parent.tools()->place_critter, *current_registry_pointer);
1642- break;
1643- case 5:
1644- new EditorToolChangeResourcesOptionsMenu(
1645- parent, parent.tools()->increase_resources, *current_registry_pointer);
1646- break;
1647- case 8:
1648- new EditorToolResizeOptionsMenu(
1649- parent, parent.tools()->resize, *current_registry_pointer);
1650- break;
1651- default:
1652- NEVER_HERE();
1653- }
1654- }
1655-}
1656
1657=== removed file 'src/editor/ui_menus/tool_menu.h'
1658--- src/editor/ui_menus/tool_menu.h 2019-02-23 11:00:49 +0000
1659+++ src/editor/ui_menus/tool_menu.h 1970-01-01 00:00:00 +0000
1660@@ -1,37 +0,0 @@
1661-/*
1662- * Copyright (C) 2002-2019 by the Widelands Development Team
1663- *
1664- * This program is free software; you can redistribute it and/or
1665- * modify it under the terms of the GNU General Public License
1666- * as published by the Free Software Foundation; either version 2
1667- * of the License, or (at your option) any later version.
1668- *
1669- * This program is distributed in the hope that it will be useful,
1670- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1671- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1672- * GNU General Public License for more details.
1673- *
1674- * You should have received a copy of the GNU General Public License
1675- * along with this program; if not, write to the Free Software
1676- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1677- *
1678- */
1679-
1680-#ifndef WL_EDITOR_UI_MENUS_TOOL_MENU_H
1681-#define WL_EDITOR_UI_MENUS_TOOL_MENU_H
1682-
1683-#include "editor/editorinteractive.h"
1684-#include "ui_basic/radiobutton.h"
1685-#include "ui_basic/unique_window.h"
1686-
1687-/// The tool selection window/menu.
1688-struct EditorToolMenu : public UI::UniqueWindow {
1689- EditorToolMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
1690-
1691-private:
1692- UI::Radiogroup radioselect_;
1693-
1694- void changed_to();
1695-};
1696-
1697-#endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_MENU_H
1698
1699=== modified file 'src/editor/ui_menus/tool_noise_height_options_menu.cc'
1700--- src/editor/ui_menus/tool_noise_height_options_menu.cc 2019-02-23 11:00:49 +0000
1701+++ src/editor/ui_menus/tool_noise_height_options_menu.cc 2019-08-10 10:01:32 +0000
1702@@ -35,7 +35,7 @@
1703 EditorInteractive& parent,
1704 EditorNoiseHeightTool& noise_tool,
1705 UI::UniqueWindow::Registry& registry)
1706- : EditorToolOptionsMenu(parent, registry, 300, 120, _("Random Height Options")),
1707+ : EditorToolOptionsMenu(parent, registry, 300, 120, _("Random Height Options"), noise_tool),
1708 noise_tool_(noise_tool),
1709 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
1710 lower_(&box_,
1711
1712=== modified file 'src/editor/ui_menus/tool_options_menu.cc'
1713--- src/editor/ui_menus/tool_options_menu.cc 2019-02-23 11:00:49 +0000
1714+++ src/editor/ui_menus/tool_options_menu.cc 2019-08-10 10:01:32 +0000
1715@@ -23,14 +23,14 @@
1716 UI::UniqueWindow::Registry& registry,
1717 uint32_t const width,
1718 uint32_t const height,
1719- char const* const title)
1720+ const std::string& title, EditorTool& tool)
1721 : UI::UniqueWindow(&parent, "tool_options_menu", &registry, width, height, title),
1722- current_pointer_(parent.tools()->current_pointer) {
1723- if (get_usedefaultpos())
1724- center_to_parent();
1725+ parent_(parent),
1726+ current_tool_(tool) {
1727+ select_correct_tool();
1728+ clicked.connect([this] { select_correct_tool(); });
1729 }
1730
1731 void EditorToolOptionsMenu::select_correct_tool() {
1732- dynamic_cast<EditorInteractive&>(*get_parent())
1733- .select_tool(*current_pointer_, EditorTool::First);
1734+ parent_.select_tool(current_tool_, EditorTool::First);
1735 }
1736
1737=== modified file 'src/editor/ui_menus/tool_options_menu.h'
1738--- src/editor/ui_menus/tool_options_menu.h 2019-02-23 11:00:49 +0000
1739+++ src/editor/ui_menus/tool_options_menu.h 2019-08-10 10:01:32 +0000
1740@@ -28,7 +28,8 @@
1741 UI::UniqueWindow::Registry&,
1742 const uint32_t width,
1743 const uint32_t height,
1744- char const* title);
1745+ const std::string& title,
1746+ EditorTool& tool);
1747
1748 /**
1749 * Selects the correct tool from the parent.
1750@@ -53,7 +54,8 @@
1751 }
1752
1753 private:
1754- EditorTool* current_pointer_;
1755+ EditorInteractive& parent_;
1756+ EditorTool& current_tool_;
1757 };
1758
1759 #endif // end of include guard: WL_EDITOR_UI_MENUS_TOOL_OPTIONS_MENU_H
1760
1761=== modified file 'src/editor/ui_menus/tool_place_critter_options_menu.cc'
1762--- src/editor/ui_menus/tool_place_critter_options_menu.cc 2019-02-23 11:00:49 +0000
1763+++ src/editor/ui_menus/tool_place_critter_options_menu.cc 2019-08-10 10:01:32 +0000
1764@@ -47,7 +47,7 @@
1765
1766 EditorToolPlaceCritterOptionsMenu::EditorToolPlaceCritterOptionsMenu(
1767 EditorInteractive& parent, EditorPlaceCritterTool& tool, UI::UniqueWindow::Registry& registry)
1768- : EditorToolOptionsMenu(parent, registry, 0, 0, _("Animals")) {
1769+ : EditorToolOptionsMenu(parent, registry, 0, 0, _("Animals"), tool) {
1770 const Widelands::World& world = parent.egbase().world();
1771 multi_select_menu_.reset(
1772 new CategorizedItemSelectionMenu<Widelands::CritterDescr, EditorPlaceCritterTool>(
1773
1774=== modified file 'src/editor/ui_menus/tool_place_immovable_options_menu.cc'
1775--- src/editor/ui_menus/tool_place_immovable_options_menu.cc 2019-02-23 11:00:49 +0000
1776+++ src/editor/ui_menus/tool_place_immovable_options_menu.cc 2019-08-10 10:01:32 +0000
1777@@ -48,7 +48,7 @@
1778
1779 EditorToolPlaceImmovableOptionsMenu::EditorToolPlaceImmovableOptionsMenu(
1780 EditorInteractive& parent, EditorPlaceImmovableTool& tool, UI::UniqueWindow::Registry& registry)
1781- : EditorToolOptionsMenu(parent, registry, 0, 0, _("Immovables")) {
1782+ : EditorToolOptionsMenu(parent, registry, 0, 0, _("Immovables"), tool) {
1783 const Widelands::World& world = parent.egbase().world();
1784 multi_select_menu_.reset(
1785 new CategorizedItemSelectionMenu<Widelands::ImmovableDescr, EditorPlaceImmovableTool>(
1786
1787=== modified file 'src/editor/ui_menus/tool_resize_options_menu.cc'
1788--- src/editor/ui_menus/tool_resize_options_menu.cc 2019-06-25 07:34:58 +0000
1789+++ src/editor/ui_menus/tool_resize_options_menu.cc 2019-08-10 10:01:32 +0000
1790@@ -33,10 +33,11 @@
1791 return dynamic_cast<EditorInteractive&>(*get_parent());
1792 }
1793
1794-EditorToolResizeOptionsMenu::EditorToolResizeOptionsMenu(EditorInteractive& parent,
1795- EditorResizeTool& resize_tool,
1796- UI::UniqueWindow::Registry& registry)
1797- : EditorToolOptionsMenu(parent, registry, 260, 200, _("Resize")),
1798+EditorToolResizeOptionsMenu::EditorToolResizeOptionsMenu(
1799+ EditorInteractive& parent,
1800+ EditorResizeTool& resize_tool,
1801+ UI::UniqueWindow::Registry& registry)
1802+ : EditorToolOptionsMenu(parent, registry, 260, 200, _("Resize"), resize_tool),
1803 resize_tool_(resize_tool),
1804 box_(this, hmargin(), vmargin(), UI::Box::Vertical, 0, 0, vspacing()),
1805 map_size_box_(box_,
1806
1807=== modified file 'src/editor/ui_menus/tool_set_terrain_options_menu.cc'
1808--- src/editor/ui_menus/tool_set_terrain_options_menu.cc 2019-02-23 11:00:49 +0000
1809+++ src/editor/ui_menus/tool_set_terrain_options_menu.cc 2019-08-10 10:01:32 +0000
1810@@ -86,7 +86,7 @@
1811
1812 EditorToolSetTerrainOptionsMenu::EditorToolSetTerrainOptionsMenu(
1813 EditorInteractive& parent, EditorSetTerrainTool& tool, UI::UniqueWindow::Registry& registry)
1814- : EditorToolOptionsMenu(parent, registry, 0, 0, _("Terrain")) {
1815+ : EditorToolOptionsMenu(parent, registry, 0, 0, _("Terrain"), tool) {
1816 const Widelands::World& world = parent.egbase().world();
1817 multi_select_menu_.reset(
1818 new CategorizedItemSelectionMenu<Widelands::TerrainDescription, EditorSetTerrainTool>(
1819
1820=== modified file 'src/graphic/CMakeLists.txt'
1821--- src/graphic/CMakeLists.txt 2019-05-31 07:39:22 +0000
1822+++ src/graphic/CMakeLists.txt 2019-08-10 10:01:32 +0000
1823@@ -6,6 +6,16 @@
1824
1825 # Align and color
1826
1827+wl_library(graphic_toolbar_imageset
1828+ SRCS
1829+ toolbar_imageset.cc
1830+ toolbar_imageset.h
1831+ DEPENDS
1832+ graphic
1833+ graphic_surface
1834+ scripting_lua_table
1835+)
1836+
1837 wl_library(graphic_align
1838 SRCS
1839 align.h
1840
1841=== added file 'src/graphic/toolbar_imageset.cc'
1842--- src/graphic/toolbar_imageset.cc 1970-01-01 00:00:00 +0000
1843+++ src/graphic/toolbar_imageset.cc 2019-08-10 10:01:32 +0000
1844@@ -0,0 +1,38 @@
1845+/*
1846+ * Copyright (C) 2019 by the Widelands Development Team
1847+ *
1848+ * This program is free software; you can redistribute it and/or
1849+ * modify it under the terms of the GNU General Public License
1850+ * as published by the Free Software Foundation; either version 2
1851+ * of the License, or (at your option) any later version.
1852+ *
1853+ * This program is distributed in the hope that it will be useful,
1854+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1855+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1856+ * GNU General Public License for more details.
1857+ *
1858+ * You should have received a copy of the GNU General Public License
1859+ * along with this program; if not, write to the Free Software
1860+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1861+ *
1862+ */
1863+
1864+#include "graphic/toolbar_imageset.h"
1865+
1866+#include "graphic/graphic.h"
1867+
1868+ToolbarImageset::ToolbarImageset() :
1869+ left_corner(g_gr->images().get("images/wui/toolbar/left_corner.png")),
1870+ left(g_gr->images().get("images/wui/toolbar/left.png")),
1871+ center(g_gr->images().get("images/wui/toolbar/center.png")),
1872+ right(g_gr->images().get("images/wui/toolbar/right.png")),
1873+ right_corner(g_gr->images().get("images/wui/toolbar/right_corner.png")) {
1874+}
1875+
1876+ToolbarImageset::ToolbarImageset(const LuaTable& table) :
1877+ left_corner(g_gr->images().get(table.get_string("left_corner"))),
1878+ left(g_gr->images().get(table.get_string("left"))),
1879+ center(g_gr->images().get(table.get_string("center"))),
1880+ right(g_gr->images().get(table.get_string("right"))),
1881+ right_corner(g_gr->images().get(table.get_string("right_corner"))) {
1882+}
1883
1884=== added file 'src/graphic/toolbar_imageset.h'
1885--- src/graphic/toolbar_imageset.h 1970-01-01 00:00:00 +0000
1886+++ src/graphic/toolbar_imageset.h 2019-08-10 10:01:32 +0000
1887@@ -0,0 +1,43 @@
1888+/*
1889+ * Copyright (C) 2019 by the Widelands Development Team
1890+ *
1891+ * This program is free software; you can redistribute it and/or
1892+ * modify it under the terms of the GNU General Public License
1893+ * as published by the Free Software Foundation; either version 2
1894+ * of the License, or (at your option) any later version.
1895+ *
1896+ * This program is distributed in the hope that it will be useful,
1897+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1898+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1899+ * GNU General Public License for more details.
1900+ *
1901+ * You should have received a copy of the GNU General Public License
1902+ * along with this program; if not, write to the Free Software
1903+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1904+ *
1905+ */
1906+
1907+#ifndef WL_GRAPHIC_TOOLBAR_IMAGESET_H
1908+#define WL_GRAPHIC_TOOLBAR_IMAGESET_H
1909+
1910+#include "graphic/image.h"
1911+#include "scripting/lua_table.h"
1912+
1913+/// An imageset for a horizontal toolbar
1914+struct ToolbarImageset {
1915+ ToolbarImageset();
1916+ ToolbarImageset(const LuaTable& table);
1917+
1918+ /// Will be painted beyond the left corner of the toolbar
1919+ const Image* left_corner;
1920+ /// Will be repeated between the left corner and the center
1921+ const Image* left;
1922+ /// Will be painted at the center
1923+ const Image* center;
1924+ /// Will be repeated between the right corner and the center
1925+ const Image* right;
1926+ /// Will be painted beyond the right corner of the toolbar
1927+ const Image* right_corner;
1928+};
1929+
1930+#endif // end of include guard: WL_GRAPHIC_TOOLBAR_IMAGESET_H
1931
1932=== modified file 'src/logic/CMakeLists.txt'
1933--- src/logic/CMakeLists.txt 2019-05-26 01:58:59 +0000
1934+++ src/logic/CMakeLists.txt 2019-08-10 10:01:32 +0000
1935@@ -124,6 +124,7 @@
1936 maptriangleregion.cc
1937 maptriangleregion.h
1938 nodecaps.h
1939+ note_map_options.h
1940 path.cc
1941 path.h
1942 pathfield.cc
1943
1944=== modified file 'src/logic/map.cc'
1945--- src/logic/map.cc 2019-06-22 11:22:14 +0000
1946+++ src/logic/map.cc 2019-08-10 10:01:32 +0000
1947@@ -46,6 +46,7 @@
1948 #include "logic/mapfringeregion.h"
1949 #include "logic/maphollowregion.h"
1950 #include "logic/mapregion.h"
1951+#include "logic/note_map_options.h"
1952 #include "logic/objective.h"
1953 #include "logic/pathfield.h"
1954 #include "map_io/s2map.h"
1955@@ -2315,6 +2316,7 @@
1956 // There need to be at least 2 port spaces for seafaring to make sense
1957 if (get_port_spaces().size() < 2) {
1958 allows_seafaring_ = false;
1959+ Notifications::publish(NoteMapOptions());
1960 return;
1961 }
1962
1963@@ -2340,6 +2342,7 @@
1964 // Found one
1965 if (reachable_from_previous_ports.count(current_position) > 0) {
1966 allows_seafaring_ = true;
1967+ Notifications::publish(NoteMapOptions());
1968 return;
1969 }
1970
1971@@ -2362,6 +2365,7 @@
1972 }
1973 }
1974 allows_seafaring_ = false;
1975+ Notifications::publish(NoteMapOptions());
1976 }
1977
1978 void Map::cleanup_port_spaces(const World& world) {
1979
1980=== modified file 'src/logic/map.h'
1981--- src/logic/map.h 2019-06-23 10:30:26 +0000
1982+++ src/logic/map.h 2019-08-10 10:01:32 +0000
1983@@ -131,7 +131,6 @@
1984 */
1985 class Map : public ITransportCostCalculator {
1986 public:
1987- friend class Editor;
1988 friend class EditorGameBase;
1989 friend class MapLoader;
1990 friend class MapVersionPacket;
1991
1992=== modified file 'src/logic/map_objects/CMakeLists.txt'
1993--- src/logic/map_objects/CMakeLists.txt 2019-05-28 11:45:38 +0000
1994+++ src/logic/map_objects/CMakeLists.txt 2019-08-10 10:01:32 +0000
1995@@ -128,6 +128,7 @@
1996 graphic_image_io
1997 graphic_surface
1998 graphic_text_layout
1999+ graphic_toolbar_imageset
2000 helper
2001 io_fileread
2002 io_filesystem
2003
2004=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
2005--- src/logic/map_objects/tribes/tribe_descr.cc 2019-05-29 06:24:42 +0000
2006+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-08-10 10:01:32 +0000
2007@@ -203,6 +203,9 @@
2008 refinedlog_ = add_special_ware(table.get_string("refinedlog"));
2009 granite_ = add_special_ware(table.get_string("granite"));
2010
2011+ if (table.has_key<std::string>("toolbar")) {
2012+ toolbar_image_set_.reset(new ToolbarImageset(*table.get_table("toolbar")));
2013+ }
2014 } catch (const GameDataError& e) {
2015 throw GameDataError("tribe %s: %s", name_.c_str(), e.what());
2016 }
2017@@ -445,6 +448,10 @@
2018 }
2019 }
2020
2021+ToolbarImageset* TribeDescr::toolbar_image_set() const {
2022+ return toolbar_image_set_.get();
2023+}
2024+
2025 /**
2026 * Helper functions
2027 */
2028
2029=== modified file 'src/logic/map_objects/tribes/tribe_descr.h'
2030--- src/logic/map_objects/tribes/tribe_descr.h 2019-05-29 06:24:42 +0000
2031+++ src/logic/map_objects/tribes/tribe_descr.h 2019-08-10 10:01:32 +0000
2032@@ -26,6 +26,7 @@
2033
2034 #include "base/macros.h"
2035 #include "graphic/animation.h"
2036+#include "graphic/toolbar_imageset.h"
2037 #include "logic/map_objects/immovable.h"
2038 #include "logic/map_objects/tribes/building.h"
2039 #include "logic/map_objects/tribes/road_textures.h"
2040@@ -162,6 +163,9 @@
2041
2042 void add_building(const std::string& buildingname);
2043
2044+ // The custom toolbar imageset if any. Can be nullptr.
2045+ ToolbarImageset* toolbar_image_set() const;
2046+
2047 private:
2048 // Helper function for adding a special worker type (carriers etc.)
2049 DescriptionIndex add_special_worker(const std::string& workername);
2050@@ -206,6 +210,9 @@
2051 WaresOrder wares_order_;
2052 WaresOrder workers_order_;
2053
2054+ // An optional custom imageset for the in-game menu toolbar
2055+ std::unique_ptr<ToolbarImageset> toolbar_image_set_;
2056+
2057 std::vector<Widelands::TribeBasicInfo::Initialization> initializations_;
2058
2059 DISALLOW_COPY_AND_ASSIGN(TribeDescr);
2060
2061=== added file 'src/logic/note_map_options.h'
2062--- src/logic/note_map_options.h 1970-01-01 00:00:00 +0000
2063+++ src/logic/note_map_options.h 2019-08-10 10:01:32 +0000
2064@@ -0,0 +1,32 @@
2065+/*
2066+ * Copyright (C) 2019 by the Widelands Development Team
2067+ *
2068+ * This program is free software; you can redistribute it and/or
2069+ * modify it under the terms of the GNU General Public License
2070+ * as published by the Free Software Foundation; either version 2
2071+ * of the License, or (at your option) any later version.
2072+ *
2073+ * This program is distributed in the hope that it will be useful,
2074+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2075+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2076+ * GNU General Public License for more details.
2077+ *
2078+ * You should have received a copy of the GNU General Public License
2079+ * along with this program; if not, write to the Free Software
2080+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2081+ *
2082+ */
2083+
2084+#ifndef WL_LOGIC_NOTE_MAP_OPTIONS_H
2085+#define WL_LOGIC_NOTE_MAP_OPTIONS_H
2086+
2087+#include "notifications/note_ids.h"
2088+#include "notifications/notifications.h"
2089+
2090+struct NoteMapOptions {
2091+ CAN_BE_SENT_AS_NOTE(NoteId::MapOptions)
2092+
2093+ NoteMapOptions() = default;
2094+};
2095+
2096+#endif // end of include guard: WL_LOGIC_NOTE_MAP_OPTIONS_H
2097
2098=== modified file 'src/notifications/note_ids.h'
2099--- src/notifications/note_ids.h 2019-06-19 07:34:19 +0000
2100+++ src/notifications/note_ids.h 2019-08-10 10:01:32 +0000
2101@@ -42,7 +42,8 @@
2102 NoteExpeditionCanceled,
2103 Sound,
2104 Dropdown,
2105- GameSettings
2106+ GameSettings,
2107+ MapOptions
2108 };
2109
2110 #endif // end of include guard: WL_NOTIFICATIONS_NOTE_IDS_H
2111
2112=== modified file 'src/scripting/lua_game.cc'
2113--- src/scripting/lua_game.cc 2019-04-26 16:52:39 +0000
2114+++ src/scripting/lua_game.cc 2019-08-10 10:01:32 +0000
2115@@ -108,7 +108,7 @@
2116 PROP_RO(LuaPlayer, name), PROP_RO(LuaPlayer, allowed_buildings),
2117 PROP_RO(LuaPlayer, objectives), PROP_RO(LuaPlayer, defeated),
2118 PROP_RO(LuaPlayer, messages), PROP_RO(LuaPlayer, inbox),
2119- PROP_RW(LuaPlayer, team), PROP_RO(LuaPlayer, tribe),
2120+ PROP_RO(LuaPlayer, color), PROP_RW(LuaPlayer, team), PROP_RO(LuaPlayer, tribe),
2121 PROP_RW(LuaPlayer, see_all), {nullptr, nullptr, nullptr},
2122 };
2123
2124@@ -222,6 +222,17 @@
2125 }
2126
2127 /* RST
2128+ .. attribute:: color
2129+
2130+ (RO) The playercolor assigned to this player, in hex notation.
2131+*/
2132+int LuaPlayer::get_color(lua_State* L) {
2133+ const PlayerNumber pnumber = get(L, get_egbase(L)).player_number();
2134+ lua_pushstring(L, kPlayerColors[pnumber - 1].hex_value());
2135+ return 1;
2136+}
2137+
2138+/* RST
2139 .. attribute:: team
2140
2141 (RW) The team number of this player (0 means player is not in a team)
2142
2143=== modified file 'src/scripting/lua_game.h'
2144--- src/scripting/lua_game.h 2019-04-26 16:52:39 +0000
2145+++ src/scripting/lua_game.h 2019-08-10 10:01:32 +0000
2146@@ -71,6 +71,7 @@
2147 int get_defeated(lua_State* L);
2148 int get_messages(lua_State* L);
2149 int get_inbox(lua_State* L);
2150+ int get_color(lua_State* L);
2151 int get_team(lua_State* L);
2152 int get_tribe(lua_State* L);
2153 int set_team(lua_State* L);
2154
2155=== modified file 'src/scripting/lua_ui.cc'
2156--- src/scripting/lua_ui.cc 2019-06-25 07:34:58 +0000
2157+++ src/scripting/lua_ui.cc 2019-08-10 10:01:32 +0000
2158@@ -365,6 +365,7 @@
2159 };
2160 const PropertyType<LuaDropdown> LuaDropdown::Properties[] = {
2161 PROP_RO(LuaDropdown, name),
2162+ PROP_RO(LuaDropdown, no_of_items),
2163 {nullptr, nullptr, nullptr},
2164 };
2165
2166@@ -378,6 +379,16 @@
2167 return 1;
2168 }
2169
2170+/* RST
2171+ .. attribute:: no_of_items
2172+
2173+ (RO) The number of items his dropdown has.
2174+*/
2175+int LuaDropdown::get_no_of_items(lua_State* L) {
2176+ lua_pushinteger(L, get()->size());
2177+ return 1;
2178+}
2179+
2180 /*
2181 * Lua Functions
2182 */
2183@@ -411,8 +422,14 @@
2184 log("Highlighting item %d in dropdown '%s'\n", desired_item, get()->get_name().c_str());
2185 // Open the dropdown
2186 get()->set_list_visibility(true);
2187+
2188+ SDL_Keysym code;
2189+ // Ensure that we're at the top
2190+ code.sym = SDLK_UP;
2191+ for (size_t i = 1; i < get()->size(); ++i) {
2192+ get()->handle_key(true, code);
2193+ }
2194 // Press arrow down until the desired item is highlighted
2195- SDL_Keysym code;
2196 code.sym = SDLK_DOWN;
2197 for (size_t i = 1; i < desired_item; ++i) {
2198 get()->handle_key(true, code);
2199
2200=== modified file 'src/scripting/lua_ui.h'
2201--- src/scripting/lua_ui.h 2019-06-25 07:34:58 +0000
2202+++ src/scripting/lua_ui.h 2019-08-10 10:01:32 +0000
2203@@ -140,6 +140,7 @@
2204 * Properties
2205 */
2206 int get_name(lua_State* L);
2207+ int get_no_of_items(lua_State* L);
2208
2209 /*
2210 * Lua Methods
2211
2212=== modified file 'src/ui_basic/dropdown.cc'
2213--- src/ui_basic/dropdown.cc 2019-06-25 07:34:58 +0000
2214+++ src/ui_basic/dropdown.cc 2019-08-10 10:01:32 +0000
2215@@ -39,13 +39,6 @@
2216 std::max(button_dimension, text_height(g_gr->styles().table_style(style).enabled()) + 2);
2217 return result;
2218 }
2219-
2220-/*
2221-int BaseDropdown::base_height(int button_dimension) const {
2222- return std::max(button_dimension,
2223-text_height(g_gr->styles().table_style(UI::PanelStyle::kWui).enabled()) + 2);
2224-}
2225-*/
2226 } // namespace
2227
2228 namespace UI {
2229@@ -432,13 +425,6 @@
2230 return true;
2231 }
2232 break;
2233- case SDLK_DOWN:
2234- case SDLK_UP:
2235- if (!list_->is_visible() && !is_mouse_away()) {
2236- toggle_list();
2237- return true;
2238- }
2239- break;
2240 default:
2241 break; // not handled
2242 }
2243
2244=== modified file 'src/ui_fsmenu/internet_lobby.cc'
2245--- src/ui_fsmenu/internet_lobby.cc 2019-06-20 13:09:18 +0000
2246+++ src/ui_fsmenu/internet_lobby.cc 2019-08-10 10:01:32 +0000
2247@@ -241,17 +241,14 @@
2248
2249 if (games != nullptr) { // If no communication error occurred, fill the list.
2250 for (const InternetGame& game : *games) {
2251- const Image* pic;
2252 if (game.connectable == INTERNET_GAME_SETUP && game.build_id == localbuildid) {
2253 // only clients with the same build number are displayed
2254- pic = g_gr->images().get("images/ui_basic/continue.png");
2255- opengames_list_.add(game.name, game, pic, false, game.build_id);
2256+ opengames_list_.add(richtext_escape(game.name), game, g_gr->images().get("images/ui_basic/continue.png"), false, game.build_id);
2257 } else if (game.connectable == INTERNET_GAME_SETUP &&
2258 game.build_id.compare(0, 6, "build-") != 0 &&
2259 localbuildid.compare(0, 6, "build-") != 0) {
2260 // only development clients are allowed to see games openend by such
2261- pic = g_gr->images().get("images/ui_basic/different.png");
2262- opengames_list_.add(game.name, game, pic, false, game.build_id);
2263+ opengames_list_.add(richtext_escape(game.name), game, g_gr->images().get("images/ui_basic/different.png"), false, game.build_id);
2264 }
2265 }
2266 }
2267
2268=== modified file 'src/ui_fsmenu/launch_mpg.cc'
2269--- src/ui_fsmenu/launch_mpg.cc 2019-05-26 17:21:15 +0000
2270+++ src/ui_fsmenu/launch_mpg.cc 2019-08-10 10:01:32 +0000
2271@@ -113,7 +113,7 @@
2272 buth_,
2273 buth_,
2274 UI::ButtonStyle::kFsMenuSecondary,
2275- g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),
2276+ g_gr->images().get("images/wui/menus/toggle_minimap.png"),
2277 _("Change map or saved game")),
2278 help_button_(this,
2279 "help",
2280
2281=== modified file 'src/wui/CMakeLists.txt'
2282--- src/wui/CMakeLists.txt 2019-06-24 18:57:51 +0000
2283+++ src/wui/CMakeLists.txt 2019-08-10 10:01:32 +0000
2284@@ -200,16 +200,12 @@
2285 game_debug_ui.h
2286 game_exit_confirm_box.cc
2287 game_exit_confirm_box.h
2288- game_statistics_menu.cc
2289- game_statistics_menu.h
2290 game_main_menu_save_game.cc
2291 game_main_menu_save_game.h
2292 game_message_menu.cc
2293 game_message_menu.h
2294 game_objectives_menu.cc
2295 game_objectives_menu.h
2296- game_options_menu.cc
2297- game_options_menu.h
2298 game_options_sound_menu.cc
2299 game_options_sound_menu.h
2300 game_summary.cc
2301@@ -295,6 +291,7 @@
2302 graphic_surface
2303 graphic_text
2304 graphic_text_layout
2305+ graphic_toolbar_imageset
2306 io_fileread
2307 io_filesystem
2308 logic
2309
2310=== modified file 'src/wui/buildingwindow.cc'
2311--- src/wui/buildingwindow.cc 2019-05-28 11:45:38 +0000
2312+++ src/wui/buildingwindow.cc 2019-08-10 10:01:32 +0000
2313@@ -348,7 +348,7 @@
2314
2315 UI::Button* gotobtn = new UI::Button(
2316 capsbuttons, "goto", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
2317- g_gr->images().get("images/wui/menus/menu_goto.png"), _("Center view on this"));
2318+ g_gr->images().get("images/wui/menus/goto.png"), _("Center view on this"));
2319 gotobtn->sigclicked.connect(boost::bind(&BuildingWindow::clicked_goto, boost::ref(*this)));
2320 capsbuttons->add(gotobtn);
2321
2322
2323=== modified file 'src/wui/constructionsitewindow.cc'
2324--- src/wui/constructionsitewindow.cc 2019-06-25 08:13:54 +0000
2325+++ src/wui/constructionsitewindow.cc 2019-08-10 10:01:32 +0000
2326@@ -27,7 +27,7 @@
2327 #include "wui/interactive_player.h"
2328
2329 static const char pic_tab_wares[] = "images/wui/buildings/menu_tab_wares.png";
2330-static const char pic_tab_settings[] = "images/wui/menus/menu_stock.png";
2331+static const char pic_tab_settings[] = "images/wui/menus/statistics_stock.png";
2332 static const char pic_tab_settings_wares[] = "images/wui/stats/menu_tab_wares_warehouse.png";
2333 static const char pic_tab_settings_workers[] = "images/wui/stats/menu_tab_workers_warehouse.png";
2334 static const char pic_max_fill_indicator[] = "images/wui/buildings/max_fill_indicator.png";
2335
2336=== modified file 'src/wui/economy_options_window.cc'
2337--- src/wui/economy_options_window.cc 2019-06-25 07:34:58 +0000
2338+++ src/wui/economy_options_window.cc 2019-08-10 10:01:32 +0000
2339@@ -51,18 +51,8 @@
2340 worker_panel_(new EconomyOptionsPanel(
2341 &tabpanel_, this, serial_, player_, can_act, Widelands::wwWORKER, kDesiredWidth)),
2342 dropdown_box_(this, 0, 0, UI::Box::Horizontal),
2343- dropdown_(&dropdown_box_,
2344- "economy_profiles",
2345- 0,
2346- 0,
2347- 174,
2348- 10,
2349- 34,
2350- "",
2351- UI::DropdownType::kTextual,
2352- UI::PanelStyle::kWui,
2353- UI::ButtonStyle::kWuiSecondary), // NOCOM test if this is the correct button style.
2354- // heap-use-after-free somewhere too.
2355+ dropdown_(
2356+ &dropdown_box_, "economy_profiles", 0, 0, 174, 10, 34, "", UI::DropdownType::kTextual, UI::PanelStyle::kWui, UI::ButtonStyle::kWuiSecondary),
2357 time_last_thought_(0),
2358 save_profile_dialog_(nullptr) {
2359 set_center_panel(&main_box_);
2360@@ -105,7 +95,7 @@
2361 dropdown_.selected.connect([this] { reset_target(); });
2362
2363 b = new UI::Button(&dropdown_box_, "save_targets", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
2364- g_gr->images().get("images/wui/menus/menu_save_game.png"),
2365+ g_gr->images().get("images/wui/menus/save_game.png"),
2366 _("Save target settings"));
2367 b->sigclicked.connect([this] { create_target(); });
2368 dropdown_box_.add_space(8);
2369
2370=== modified file 'src/wui/fieldaction.cc'
2371--- src/wui/fieldaction.cc 2019-06-24 10:03:47 +0000
2372+++ src/wui/fieldaction.cc 2019-08-10 10:01:32 +0000
2373@@ -163,9 +163,6 @@
2374 void add_buttons_attack();
2375
2376 void act_watch();
2377- void act_show_census();
2378- void act_show_statistics();
2379- void act_show_workarea_overlap();
2380 void act_debug();
2381 void act_buildflag();
2382 void act_configure_economy();
2383@@ -232,10 +229,6 @@
2384 static const char* const pic_buildflag = "images/wui/fieldaction/menu_build_flag.png";
2385 static const char* const pic_ripflag = "images/wui/fieldaction/menu_rip_flag.png";
2386 static const char* const pic_watchfield = "images/wui/fieldaction/menu_watch_field.png";
2387-static const char* const pic_showcensus = "images/wui/fieldaction/menu_show_census.png";
2388-static const char* const pic_showstatistics = "images/wui/fieldaction/menu_show_statistics.png";
2389-static const char* const pic_showworkareaoverlap =
2390- "images/wui/fieldaction/menu_show_workarea_overlap.png";
2391 static const char* const pic_debug = "images/wui/fieldaction/menu_debug.png";
2392 static const char* const pic_abort = "images/wui/menu_abort.png";
2393 static const char* const pic_geologist = "images/wui/fieldaction/menu_geologist.png";
2394@@ -385,21 +378,10 @@
2395 node_, ibase().egbase().map().get_width())))
2396 add_buttons_attack();
2397
2398- // Watch actions, only when game (no use in editor) same for statistics.
2399- // census is ok
2400+ // Watch actions, only when in game (no use in editor).
2401 if (dynamic_cast<const Game*>(&ibase().egbase())) {
2402 add_button(&watchbox, "watch", pic_watchfield, &FieldActionWindow::act_watch,
2403 _("Watch field in a separate window"));
2404- add_button(&watchbox, "statistics", pic_showstatistics,
2405- &FieldActionWindow::act_show_statistics, _("Toggle building statistics display"));
2406- }
2407- add_button(&watchbox, "census", pic_showcensus, &FieldActionWindow::act_show_census,
2408- _("Toggle building label display"));
2409- if (is_a(InteractivePlayer, &ibase())) {
2410- add_button(
2411- &watchbox, "workarea_overlap", pic_showworkareaoverlap,
2412- &FieldActionWindow::act_show_workarea_overlap,
2413- _("Toggle whether overlapping workareas are indicated when placing a constructionsite"));
2414 }
2415
2416 if (ibase().get_display_flag(InteractiveBase::dfDebug))
2417@@ -584,29 +566,6 @@
2418
2419 /*
2420 ===============
2421-Toggle display of census and statistics for buildings, respectively.
2422-===============
2423-*/
2424-void FieldActionWindow::act_show_census() {
2425- ibase().set_display_flag(
2426- InteractiveBase::dfShowCensus, !ibase().get_display_flag(InteractiveBase::dfShowCensus));
2427- reset_mouse_and_die();
2428-}
2429-
2430-void FieldActionWindow::act_show_statistics() {
2431- ibase().set_display_flag(InteractiveBase::dfShowStatistics,
2432- !ibase().get_display_flag(InteractiveBase::dfShowStatistics));
2433- reset_mouse_and_die();
2434-}
2435-
2436-void FieldActionWindow::act_show_workarea_overlap() {
2437- ibase().set_display_flag(InteractiveBase::dfShowWorkareaOverlap,
2438- !ibase().get_display_flag(InteractiveBase::dfShowWorkareaOverlap));
2439- reset_mouse_and_die();
2440-}
2441-
2442-/*
2443-===============
2444 Show a debug widow for this field.
2445 ===============
2446 */
2447
2448=== modified file 'src/wui/game_chat_menu.cc'
2449--- src/wui/game_chat_menu.cc 2019-02-23 11:00:49 +0000
2450+++ src/wui/game_chat_menu.cc 2019-08-10 10:01:32 +0000
2451@@ -53,11 +53,13 @@
2452 return new GameChatMenu(parent, registry, chat, _("Chat"));
2453 }
2454
2455+#ifndef NDEBUG // only in debug builds
2456 GameChatMenu* GameChatMenu::create_script_console(UI::Panel* parent,
2457 UI::UniqueWindow::Registry& registry,
2458 ChatProvider& chat) {
2459- return new GameChatMenu(parent, registry, chat, _("Script console"));
2460+ return new GameChatMenu(parent, registry, chat, _("Script Console"));
2461 }
2462+#endif
2463
2464 bool GameChatMenu::enter_chat_message(bool close_on_send) {
2465 if (is_minimal()) {
2466
2467=== modified file 'src/wui/game_chat_menu.h'
2468--- src/wui/game_chat_menu.h 2019-02-23 11:00:49 +0000
2469+++ src/wui/game_chat_menu.h 2019-08-10 10:01:32 +0000
2470@@ -34,11 +34,13 @@
2471 */
2472 static GameChatMenu* create_chat_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);
2473
2474+#ifndef NDEBUG // only in debug builds
2475 /**
2476 * Creates a chat window only for scripting in debug mode
2477 */
2478 static GameChatMenu*
2479 create_script_console(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&);
2480+#endif
2481
2482 /**
2483 * Configure the menu so that it is useful for writing chat messages.
2484
2485=== modified file 'src/wui/game_client_disconnected.cc'
2486--- src/wui/game_client_disconnected.cc 2019-06-25 07:34:58 +0000
2487+++ src/wui/game_client_disconnected.cc 2019-08-10 10:01:32 +0000
2488@@ -93,7 +93,7 @@
2489 width,
2490 35,
2491 UI::ButtonStyle::kWuiMenu,
2492- g_gr->images().get("images/wui/menus/menu_exit_game.png"),
2493+ g_gr->images().get("images/wui/menus/exit.png"),
2494 /** TRANSLATORS: Button tooltip */
2495 _("Exit Game")) {
2496
2497
2498=== modified file 'src/wui/game_message_menu.cc'
2499--- src/wui/game_message_menu.cc 2019-06-25 07:34:58 +0000
2500+++ src/wui/game_message_menu.cc 2019-08-10 10:01:32 +0000
2501@@ -104,7 +104,7 @@
2502
2503 scenariobtn_ = new UI::Button(this, "filter_scenario_messages", 5 * kPadding + 4 * kButtonSize,
2504 kPadding, kButtonSize, kButtonSize, UI::ButtonStyle::kWuiSecondary,
2505- g_gr->images().get("images/wui/menus/menu_objectives.png"));
2506+ g_gr->images().get("images/wui/menus/objectives.png"));
2507 scenariobtn_->sigclicked.connect(
2508 boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kScenario));
2509
2510@@ -129,7 +129,7 @@
2511 centerviewbtn_ =
2512 new UI::Button(this, "center_main_mapview_on_location", kWindowWidth - kPadding - kButtonSize,
2513 archivebtn_->get_y(), kButtonSize, kButtonSize, UI::ButtonStyle::kWuiPrimary,
2514- g_gr->images().get("images/wui/menus/menu_goto.png"),
2515+ g_gr->images().get("images/wui/menus/goto.png"),
2516 as_tooltip_text_with_hotkey(
2517 /** TRANSLATORS: Tooltip in the messages window */
2518 _("Center main mapview on location"), "g"));
2519@@ -563,7 +563,7 @@
2520 case Widelands::Message::Type::kWarfare:
2521 return "images/wui/messages/messages_warfare.png";
2522 case Widelands::Message::Type::kScenario:
2523- return "images/wui/menus/menu_objectives.png";
2524+ return "images/wui/menus/objectives.png";
2525 case Widelands::Message::Type::kGameLogic:
2526 return "images/ui_basic/menu_help.png";
2527 case Widelands::Message::Type::kNoMessages:
2528
2529=== removed file 'src/wui/game_options_menu.cc'
2530--- src/wui/game_options_menu.cc 2019-03-18 07:11:02 +0000
2531+++ src/wui/game_options_menu.cc 1970-01-01 00:00:00 +0000
2532@@ -1,119 +0,0 @@
2533-/*
2534- * Copyright (C) 2002-2019 by the Widelands Development Team
2535- *
2536- * This program is free software; you can redistribute it and/or
2537- * modify it under the terms of the GNU General Public License
2538- * as published by the Free Software Foundation; either version 2
2539- * of the License, or (at your option) any later version.
2540- *
2541- * This program is distributed in the hope that it will be useful,
2542- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2543- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2544- * GNU General Public License for more details.
2545- *
2546- * You should have received a copy of the GNU General Public License
2547- * along with this program; if not, write to the Free Software
2548- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2549- *
2550- */
2551-
2552-#include "wui/game_options_menu.h"
2553-
2554-#include <boost/bind.hpp>
2555-#include <boost/lambda/bind.hpp>
2556-#include <boost/lambda/construct.hpp>
2557-#include <boost/type_traits.hpp>
2558-
2559-#include "base/i18n.h"
2560-#include "graphic/graphic.h"
2561-#include "wui/game_exit_confirm_box.h"
2562-#include "wui/game_main_menu_save_game.h"
2563-#include "wui/game_options_sound_menu.h"
2564-#include "wui/unique_window_handler.h"
2565-
2566-#define width 200
2567-#define margin 10
2568-#define vspacing 5
2569-#define vgap 3
2570-
2571-GameOptionsMenu::GameOptionsMenu(InteractiveGameBase& gb,
2572- UI::UniqueWindow::Registry& registry,
2573- InteractiveGameBase::GameMainMenuWindows& windows)
2574- : UI::UniqueWindow(&gb, "options", &registry, 2 * margin + width, 0, _("Main Menu")),
2575- igb_(gb),
2576- windows_(windows),
2577- box_(this, margin, margin, UI::Box::Vertical, width, get_h() - 2 * margin, vspacing),
2578- sound_(&box_,
2579- "sound_options",
2580- 0,
2581- 0,
2582- width,
2583- 0,
2584- UI::ButtonStyle::kWuiMenu,
2585- _("Sound Options"),
2586- /** TRANSLATORS: Button tooltip */
2587- _("Set sound effect and music options")),
2588- save_game_(&box_,
2589- "save_game",
2590- 0,
2591- 0,
2592- width,
2593- 35,
2594- UI::ButtonStyle::kWuiMenu,
2595- g_gr->images().get("images/wui/menus/menu_save_game.png"),
2596- /** TRANSLATORS: Button tooltip */
2597- _("Save Game")),
2598- exit_game_(&box_,
2599- "exit_game",
2600- 0,
2601- 0,
2602- width,
2603- 35,
2604- UI::ButtonStyle::kWuiMenu,
2605- g_gr->images().get("images/wui/menus/menu_exit_game.png"),
2606- /** TRANSLATORS: Button tooltip */
2607- _("Exit Game")) {
2608- box_.add(&sound_);
2609- box_.add_space(vgap);
2610- box_.add(&save_game_);
2611- box_.add(&exit_game_);
2612- box_.set_size(width, sound_.get_h() + 2 * save_game_.get_h() + vgap + 3 * vspacing);
2613- set_inner_size(get_inner_w(), box_.get_h() + 2 * margin);
2614-
2615- windows_.sound_options.open_window = [this] {
2616- new GameOptionsSoundMenu(igb_, windows_.sound_options);
2617- };
2618- sound_.sigclicked.connect(
2619- boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(windows_.sound_options)));
2620- save_game_.sigclicked.connect(
2621- boost::bind(&GameOptionsMenu::clicked_save_game, boost::ref(*this)));
2622- exit_game_.sigclicked.connect(
2623- boost::bind(&GameOptionsMenu::clicked_exit_game, boost::ref(*this)));
2624-
2625- if (windows_.sound_options.window) {
2626- sound_.set_perm_pressed(true);
2627- }
2628- windows_.sound_options.opened.connect(boost::bind(&UI::Button::set_perm_pressed, &sound_, true));
2629- windows_.sound_options.closed.connect(
2630- boost::bind(&UI::Button::set_perm_pressed, &sound_, false));
2631-
2632- if (get_usedefaultpos())
2633- center_to_parent();
2634-}
2635-
2636-GameOptionsMenu::~GameOptionsMenu() {
2637-}
2638-
2639-void GameOptionsMenu::clicked_save_game() {
2640- new GameMainMenuSaveGame(igb_, windows_.savegame);
2641- die();
2642-}
2643-
2644-void GameOptionsMenu::clicked_exit_game() {
2645- if (SDL_GetModState() & KMOD_CTRL) {
2646- igb_.end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
2647- } else {
2648- new GameExitConfirmBox(*get_parent(), igb_);
2649- die();
2650- }
2651-}
2652
2653=== removed file 'src/wui/game_options_menu.h'
2654--- src/wui/game_options_menu.h 2019-02-23 11:00:49 +0000
2655+++ src/wui/game_options_menu.h 1970-01-01 00:00:00 +0000
2656@@ -1,49 +0,0 @@
2657-/*
2658- * Copyright (C) 2002-2019 by the Widelands Development Team
2659- *
2660- * This program is free software; you can redistribute it and/or
2661- * modify it under the terms of the GNU General Public License
2662- * as published by the Free Software Foundation; either version 2
2663- * of the License, or (at your option) any later version.
2664- *
2665- * This program is distributed in the hope that it will be useful,
2666- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2667- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2668- * GNU General Public License for more details.
2669- *
2670- * You should have received a copy of the GNU General Public License
2671- * along with this program; if not, write to the Free Software
2672- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2673- *
2674- */
2675-
2676-#ifndef WL_WUI_GAME_OPTIONS_MENU_H
2677-#define WL_WUI_GAME_OPTIONS_MENU_H
2678-
2679-#include "ui_basic/box.h"
2680-#include "ui_basic/button.h"
2681-#include "ui_basic/messagebox.h"
2682-#include "ui_basic/textarea.h"
2683-#include "ui_basic/unique_window.h"
2684-#include "wui/interactive_gamebase.h"
2685-
2686-// The GameOptionsMenu is a rather dumb window with lots of buttons
2687-struct GameOptionsMenu : public UI::UniqueWindow {
2688- GameOptionsMenu(InteractiveGameBase&,
2689- UI::UniqueWindow::Registry&,
2690- InteractiveGameBase::GameMainMenuWindows&);
2691- ~GameOptionsMenu();
2692-
2693-private:
2694- InteractiveGameBase& igb_;
2695- InteractiveGameBase::GameMainMenuWindows& windows_;
2696- UI::Box box_;
2697- UI::Button sound_;
2698- UI::Button save_game_;
2699- UI::Button exit_game_;
2700-
2701- void clicked_save_game();
2702- void clicked_exit_game();
2703-};
2704-
2705-#endif // end of include guard: WL_WUI_GAME_OPTIONS_MENU_H
2706
2707=== removed file 'src/wui/game_statistics_menu.cc'
2708--- src/wui/game_statistics_menu.cc 2019-02-23 11:00:49 +0000
2709+++ src/wui/game_statistics_menu.cc 1970-01-01 00:00:00 +0000
2710@@ -1,98 +0,0 @@
2711-/*
2712- * Copyright (C) 2002-2019 by the Widelands Development Team
2713- *
2714- * This program is free software; you can redistribute it and/or
2715- * modify it under the terms of the GNU General Public License
2716- * as published by the Free Software Foundation; either version 2
2717- * of the License, or (at your option) any later version.
2718- *
2719- * This program is distributed in the hope that it will be useful,
2720- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2721- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2722- * GNU General Public License for more details.
2723- *
2724- * You should have received a copy of the GNU General Public License
2725- * along with this program; if not, write to the Free Software
2726- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2727- *
2728- */
2729-
2730-#include "wui/game_statistics_menu.h"
2731-
2732-#include <boost/bind.hpp>
2733-
2734-#include "base/i18n.h"
2735-#include "graphic/graphic.h"
2736-#include "ui_basic/unique_window.h"
2737-#include "wui/building_statistics_menu.h"
2738-#include "wui/general_statistics_menu.h"
2739-#include "wui/interactive_player.h"
2740-#include "wui/seafaring_statistics_menu.h"
2741-#include "wui/stock_menu.h"
2742-#include "wui/ware_statistics_menu.h"
2743-
2744-GameStatisticsMenu::GameStatisticsMenu(InteractivePlayer& plr,
2745- UI::UniqueWindow::Registry& registry,
2746- InteractivePlayer::GameMainMenuWindows& windows)
2747- : UI::UniqueWindow(&plr, "main_menu", &registry, 0, 0, _("Statistics Menu")),
2748- player_(plr),
2749- windows_(windows),
2750- box_(this, 0, 0, UI::Box::Horizontal, 0, 0, 5) {
2751- const bool is_seafaring = plr.egbase().mutable_map()->allows_seafaring();
2752- add_button("wui/menus/menu_general_stats", "general_stats", _("General statistics"),
2753- &windows_.general_stats);
2754- add_button(
2755- "wui/menus/menu_ware_stats", "ware_stats", _("Ware statistics"), &windows_.ware_stats);
2756- add_button("wui/menus/menu_building_stats", "building_stats", _("Building statistics"),
2757- &windows_.building_stats);
2758- add_button("wui/menus/menu_stock", "stock", _("Stock"), &windows_.stock);
2759- if (is_seafaring) {
2760- add_button("wui/buildings/start_expedition", "seafaring_stats", _("Seafaring Statistics"),
2761- &windows_.seafaring_stats);
2762- }
2763- box_.set_pos(Vector2i(10, 10));
2764- box_.set_size((34 + 5) * (is_seafaring ? 5 : 4), 34);
2765- set_inner_size(box_.get_w() + 20, box_.get_h() + 20);
2766-
2767- windows_.general_stats.open_window = [this] {
2768- new GeneralStatisticsMenu(player_, windows_.general_stats);
2769- };
2770- windows_.ware_stats.open_window = [this] {
2771- new WareStatisticsMenu(player_, windows_.ware_stats);
2772- };
2773- windows_.building_stats.open_window = [this] {
2774- new BuildingStatisticsMenu(player_, windows_.building_stats);
2775- };
2776- // The stock window is defined in InteractivePlayer because of the keyboard shortcut.
2777- if (is_seafaring) {
2778- windows_.seafaring_stats.open_window = [this] {
2779- new SeafaringStatisticsMenu(player_, windows_.seafaring_stats);
2780- };
2781- }
2782-
2783- if (get_usedefaultpos())
2784- center_to_parent();
2785-}
2786-
2787-UI::Button* GameStatisticsMenu::add_button(const std::string& image_basename,
2788- const std::string& name,
2789- const std::string& tooltip_text,
2790- UI::UniqueWindow::Registry* window) {
2791- UI::Button* button =
2792- new UI::Button(&box_, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiMenu,
2793- g_gr->images().get("images/" + image_basename + ".png"), tooltip_text);
2794- box_.add(button);
2795- if (window) {
2796- if (window->window) {
2797- button->set_perm_pressed(true);
2798- }
2799- window->opened.connect(boost::bind(&UI::Button::set_perm_pressed, button, true));
2800- window->closed.connect(boost::bind(&UI::Button::set_perm_pressed, button, false));
2801- button->sigclicked.connect(
2802- boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(*window)));
2803- }
2804- return button;
2805-}
2806-
2807-GameStatisticsMenu::~GameStatisticsMenu() {
2808-}
2809
2810=== removed file 'src/wui/game_statistics_menu.h'
2811--- src/wui/game_statistics_menu.h 2019-02-23 11:00:49 +0000
2812+++ src/wui/game_statistics_menu.h 1970-01-01 00:00:00 +0000
2813@@ -1,52 +0,0 @@
2814-/*
2815- * Copyright (C) 2002-2019 by the Widelands Development Team
2816- *
2817- * This program is free software; you can redistribute it and/or
2818- * modify it under the terms of the GNU General Public License
2819- * as published by the Free Software Foundation; either version 2
2820- * of the License, or (at your option) any later version.
2821- *
2822- * This program is distributed in the hope that it will be useful,
2823- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2824- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2825- * GNU General Public License for more details.
2826- *
2827- * You should have received a copy of the GNU General Public License
2828- * along with this program; if not, write to the Free Software
2829- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2830- *
2831- */
2832-
2833-#ifndef WL_WUI_GAME_STATISTICS_MENU_H
2834-#define WL_WUI_GAME_STATISTICS_MENU_H
2835-
2836-#include "ui_basic/box.h"
2837-#include "ui_basic/button.h"
2838-#include "wui/interactive_player.h"
2839-
2840-// The GameStatisticsMenu is a row of buttons that will toggle unique windows
2841-struct GameStatisticsMenu : public UI::UniqueWindow {
2842- GameStatisticsMenu(InteractivePlayer&,
2843- UI::UniqueWindow::Registry&,
2844- InteractivePlayer::GameMainMenuWindows&);
2845-
2846- ~GameStatisticsMenu();
2847-
2848-private:
2849- /// Adds a button to the menu that will toggle its window
2850- /// \param image_basename: File path for button image starting from 'images' and without
2851- /// file extension
2852- /// \param name: Internal name of the button
2853- /// \param tooltip_text: The button tooltip
2854- /// \param window: The window that's associated with this button.
2855- UI::Button* add_button(const std::string& image_basename,
2856- const std::string& name,
2857- const std::string& tooltip_text,
2858- UI::UniqueWindow::Registry* window);
2859-
2860- InteractivePlayer& player_;
2861- InteractivePlayer::GameMainMenuWindows& windows_;
2862- UI::Box box_;
2863-};
2864-
2865-#endif // end of include guard: WL_WUI_GAME_STATISTICS_MENU_H
2866
2867=== modified file 'src/wui/game_summary.cc'
2868--- src/wui/game_summary.cc 2019-05-26 17:21:15 +0000
2869+++ src/wui/game_summary.cc 2019-08-10 10:01:32 +0000
2870@@ -91,7 +91,7 @@
2871 bottom_box->add_space(PADDING);
2872 stop_button_ =
2873 new UI::Button(bottom_box, "stop_button", 0, 0, 35, 35, UI::ButtonStyle::kWuiMenu,
2874- g_gr->images().get("images/wui/menus/menu_exit_game.png"), _("Exit Game"));
2875+ g_gr->images().get("images/wui/menus/exit.png"), _("Exit Game"));
2876 bottom_box->add(stop_button_);
2877 bottom_box->add_space(PADDING);
2878
2879
2880=== modified file 'src/wui/interactive_base.cc'
2881--- src/wui/interactive_base.cc 2019-07-27 11:32:11 +0000
2882+++ src/wui/interactive_base.cc 2019-08-10 10:01:32 +0000
2883@@ -91,13 +91,82 @@
2884
2885 } // namespace
2886
2887+InteractiveBase::Toolbar::Toolbar(Panel* parent) : UI::Panel(parent, 0, 0, parent->get_inner_w(), parent->get_inner_h()), box(this, 0, 0, UI::Box::Horizontal),
2888+ repeat(0)
2889+{
2890+}
2891+
2892+void InteractiveBase::Toolbar::change_imageset(const ToolbarImageset& images) {
2893+ imageset = images;
2894+ finalize();
2895+}
2896+
2897+void InteractiveBase::Toolbar::finalize() {
2898+ // Set box size and get minimum height
2899+ int box_width, height;
2900+ box.get_desired_size(&box_width, &height);
2901+ box.set_size(box_width, height);
2902+
2903+ // Calculate repetition and width
2904+ repeat = 1;
2905+ int width = imageset.left->width() + imageset.center->width() + imageset.right->width();
2906+ while (width < box.get_w()) {
2907+ ++repeat;
2908+ width += imageset.left->width() + imageset.right->width();
2909+ }
2910+ width += imageset.left_corner->width() + imageset.right_corner->width();
2911+
2912+ // Find the highest image
2913+ height = std::max(height, imageset.left_corner->height());
2914+ height = std::max(height, imageset.left->height());
2915+ height = std::max(height, imageset.center->height());
2916+ height = std::max(height, imageset.right->height());
2917+ height = std::max(height, imageset.right_corner->height());
2918+
2919+ // Set size and position
2920+ set_size(width, height);
2921+ set_pos(Vector2i((get_parent()->get_inner_w() - width) >> 1, get_parent()->get_inner_h() - height));
2922+ box.set_pos(Vector2i((get_w() - box.get_w()) / 2, get_h() - box.get_h()));
2923+
2924+ // Notify dropdowns
2925+ box.position_changed();
2926+}
2927+
2928+void InteractiveBase::Toolbar::draw(RenderTarget& dst) {
2929+ int x = 0;
2930+ // Left corner
2931+ dst.blit(Vector2i(x, get_h() - imageset.left_corner->height()), imageset.left_corner);
2932+ x += imageset.left_corner->width();
2933+ // Repeat left
2934+ for (int i = 0; i < repeat; ++i) {
2935+ dst.blit(Vector2i(x, get_h() - imageset.left->height()), imageset.left);
2936+ x += imageset.left->width();
2937+ }
2938+ // Center
2939+ dst.blit(Vector2i(x, get_h() - imageset.center->height()), imageset.center);
2940+ x += imageset.center->width();
2941+ // Repeat right
2942+ for (int i = 0; i < repeat; ++i) {
2943+ dst.blit(Vector2i(x, get_h() - imageset.right->height()), imageset.right);
2944+ x += imageset.right->width();
2945+ }
2946+ // Right corner
2947+ dst.blit(Vector2i(x, get_h() - imageset.right_corner->height()), imageset.right_corner);
2948+}
2949+
2950 InteractiveBase::InteractiveBase(EditorGameBase& the_egbase, Section& global_s)
2951 : UI::Panel(nullptr, 0, 0, g_gr->get_xres(), g_gr->get_yres()),
2952 buildhelp_(false),
2953 map_view_(this, the_egbase.map(), 0, 0, g_gr->get_xres(), g_gr->get_yres()),
2954 // Initialize chatoveraly before the toolbar so it is below
2955 chat_overlay_(new ChatOverlay(this, 10, 25, get_w() / 2, get_h() - 25)),
2956- toolbar_(this, 0, 0, UI::Box::Horizontal),
2957+ toolbar_(this),
2958+ mapviewmenu_(
2959+ toolbar(), "dropdown_menu_mapview", 0, 0, 34U, 10, 34U,
2960+ /** TRANSLATORS: Title for the map view menu button in the game */
2961+ _("Map View"),
2962+ UI::DropdownType::kPictorialMenu,
2963+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
2964 quick_navigation_(&map_view_),
2965 workareas_cache_(nullptr),
2966 egbase_(the_egbase),
2967@@ -147,7 +216,7 @@
2968 set_size(message.width, message.height);
2969 map_view_.set_size(message.width, message.height);
2970 resize_chat_overlay();
2971- adjust_toolbar_position();
2972+ finalize_toolbar();
2973 });
2974 sound_subscriber_ = Notifications::subscribe<NoteSound>(
2975 [this](const NoteSound& note) { play_sound_effect(note); });
2976@@ -191,6 +260,68 @@
2977 }
2978 }
2979
2980+
2981+void InteractiveBase::add_mapview_menu(MiniMapType minimap_type) {
2982+ mapviewmenu_.set_image(g_gr->images().get("images/wui/menus/toggle_minimap.png"));
2983+ toolbar()->add(&mapviewmenu_);
2984+
2985+ minimap_registry_.open_window = [this] { toggle_minimap(); };
2986+ minimap_registry_.minimap_type = minimap_type;
2987+ minimap_registry_.closed.connect([this] { rebuild_mapview_menu(); });
2988+
2989+ rebuild_mapview_menu();
2990+ mapviewmenu_.selected.connect([this] { mapview_menu_selected(mapviewmenu_.get_selected()); });
2991+}
2992+
2993+void InteractiveBase::rebuild_mapview_menu() {
2994+ mapviewmenu_.clear();
2995+
2996+ /** TRANSLATORS: An entry in the game's map view menu */
2997+ mapviewmenu_.add(minimap_registry_.window != nullptr ? _("Hide Minimap") : _("Show Minimap"),
2998+ MapviewMenuEntry::kMinimap,
2999+ g_gr->images().get("images/wui/menus/toggle_minimap.png"),
3000+ false, "", "m");
3001+
3002+ /** TRANSLATORS: An entry in the game's map view menu */
3003+ mapviewmenu_.add(_("Zoom +"),
3004+ MapviewMenuEntry::kIncreaseZoom,
3005+ g_gr->images().get("images/wui/menus/zoom_increase.png"),
3006+ false, "", pgettext("hotkey", "Ctrl++"));
3007+
3008+ /** TRANSLATORS: An entry in the game's map view menu */
3009+ mapviewmenu_.add(_("Reset zoom"),
3010+ MapviewMenuEntry::kResetZoom,
3011+ g_gr->images().get("images/wui/menus/zoom_reset.png"),
3012+ false, "", pgettext("hotkey", "Ctrl+0"));
3013+
3014+ /** TRANSLATORS: An entry in the game's map view menu */
3015+ mapviewmenu_.add(_("Zoom -"),
3016+ MapviewMenuEntry::kDecreaseZoom,
3017+ g_gr->images().get("images/wui/menus/zoom_decrease.png"),
3018+ false, "", pgettext("hotkey", "Ctrl+-"));
3019+}
3020+
3021+void InteractiveBase::mapview_menu_selected(MapviewMenuEntry entry) {
3022+ switch (entry) {
3023+ case MapviewMenuEntry::kMinimap : {
3024+ toggle_minimap();
3025+ } break;
3026+ case MapviewMenuEntry::kDecreaseZoom : {
3027+ map_view()->decrease_zoom();
3028+ mapviewmenu_.toggle();
3029+ } break;
3030+ case MapviewMenuEntry::kIncreaseZoom : {
3031+ map_view()->increase_zoom();
3032+ mapviewmenu_.toggle();
3033+ } break;
3034+
3035+ case MapviewMenuEntry::kResetZoom : {
3036+ map_view()->reset_zoom();
3037+ mapviewmenu_.toggle();
3038+ } break;
3039+ }
3040+}
3041+
3042 const InteractiveBase::BuildhelpOverlay*
3043 InteractiveBase::get_buildhelp_overlay(const Widelands::NodeCaps caps) const {
3044 const int buildhelp_overlay_index = caps_to_buildhelp(caps);
3045@@ -222,6 +353,11 @@
3046 return false;
3047 }
3048
3049+
3050+void InteractiveBase::set_toolbar_imageset(const ToolbarImageset& imageset) {
3051+ toolbar_.change_imageset(imageset);
3052+}
3053+
3054 UniqueWindowHandler& InteractiveBase::unique_windows() {
3055 return *unique_window_handler_;
3056 }
3057@@ -230,6 +366,10 @@
3058 sel_.pos = center;
3059 }
3060
3061+void InteractiveBase::finalize_toolbar() {
3062+ toolbar_.finalize();
3063+}
3064+
3065 /*
3066 * Set the current sel selection radius.
3067 */
3068@@ -269,8 +409,11 @@
3069 }
3070
3071 void InteractiveBase::show_buildhelp(bool t) {
3072+ const bool old_value = buildhelp_;
3073 buildhelp_ = t;
3074- on_buildhelp_changed(t);
3075+ if (old_value != t) {
3076+ rebuild_showhide_menu();
3077+ }
3078 }
3079
3080 void InteractiveBase::toggle_buildhelp() {
3081@@ -283,9 +426,9 @@
3082 UI::UniqueWindow::Registry* window,
3083 bool bind_default_toggle) {
3084 UI::Button* button =
3085- new UI::Button(&toolbar_, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiPrimary,
3086+ new UI::Button(&toolbar_.box, name, 0, 0, 34U, 34U, UI::ButtonStyle::kWuiPrimary,
3087 g_gr->images().get("images/" + image_basename + ".png"), tooltip_text);
3088- toolbar_.add(button);
3089+ toolbar_.box.add(button);
3090 if (window) {
3091 window->opened.connect([button] { button->set_perm_pressed(true); });
3092 window->closed.connect([button] { button->set_perm_pressed(false); });
3093@@ -298,9 +441,6 @@
3094 return button;
3095 }
3096
3097-void InteractiveBase::on_buildhelp_changed(bool /* value */) {
3098-}
3099-
3100 bool InteractiveBase::has_expedition_port_space(const Widelands::Coords& coords) const {
3101 for (const auto& pair : expedition_port_spaces_) {
3102 if (pair.second == coords) {
3103@@ -638,6 +778,7 @@
3104 });
3105 mainview_move();
3106 }
3107+ rebuild_mapview_menu();
3108 }
3109
3110 const std::vector<QuickNavigation::Landmark>& InteractiveBase::landmarks() {
3111@@ -655,17 +796,6 @@
3112 minimap_registry_.destroy();
3113 }
3114
3115-/**
3116-===========
3117-InteractiveBase::minimap_registry()
3118-
3119-Exposes the Registry object of the minimap to derived classes
3120-===========
3121-*/
3122-MiniMap::Registry& InteractiveBase::minimap_registry() {
3123- return minimap_registry_;
3124-}
3125-
3126 /*
3127 ===============
3128 Return display flags (dfXXX) that modify the view of the map.
3129@@ -999,40 +1129,6 @@
3130
3131 if (down) {
3132 switch (code.sym) {
3133- case SDLK_KP_9:
3134- if (code.mod & KMOD_NUM) {
3135- break;
3136- }
3137- FALLS_THROUGH;
3138- case SDLK_PAGEUP:
3139- if (upcast(Game, game, &egbase_)) {
3140- if (GameController* const ctrl = game->game_controller()) {
3141- ctrl->set_desired_speed(ctrl->desired_speed() + 1000);
3142- }
3143- }
3144- return true;
3145-
3146- case SDLK_PAUSE:
3147- if (upcast(Game, game, &egbase_)) {
3148- if (GameController* const ctrl = game->game_controller()) {
3149- ctrl->toggle_paused();
3150- }
3151- }
3152- return true;
3153-
3154- case SDLK_KP_3:
3155- if (code.mod & KMOD_NUM) {
3156- break;
3157- }
3158- FALLS_THROUGH;
3159- case SDLK_PAGEDOWN:
3160- if (upcast(Widelands::Game, game, &egbase_)) {
3161- if (GameController* const ctrl = game->game_controller()) {
3162- uint32_t const speed = ctrl->desired_speed();
3163- ctrl->set_desired_speed(1000 < speed ? speed - 1000 : 0);
3164- }
3165- }
3166- return true;
3167 // Scroll the map
3168 case SDLK_KP_8:
3169 if (SDL_GetModState() & KMOD_NUM) {
3170@@ -1066,13 +1162,15 @@
3171 case SDLK_RIGHT:
3172 map_view_.pan_by(Vector2i(kScrollDistance, 0));
3173 return true;
3174-
3175 #ifndef NDEBUG // only in debug builds
3176 case SDLK_F6:
3177 GameChatMenu::create_script_console(
3178 this, debugconsole_, *DebugConsole::get_chat_provider());
3179 return true;
3180 #endif
3181+ case SDLK_m:
3182+ toggle_minimap();
3183+ return true;
3184 default:
3185 break;
3186 }
3187
3188=== modified file 'src/wui/interactive_base.h'
3189--- src/wui/interactive_base.h 2019-05-31 19:31:45 +0000
3190+++ src/wui/interactive_base.h 2019-08-10 10:01:32 +0000
3191@@ -25,12 +25,14 @@
3192
3193 #include <SDL_keycode.h>
3194
3195+#include "graphic/toolbar_imageset.h"
3196 #include "logic/editor_game_base.h"
3197 #include "logic/map.h"
3198 #include "notifications/notifications.h"
3199 #include "profile/profile.h"
3200 #include "sound/note_sound.h"
3201 #include "ui_basic/box.h"
3202+#include "ui_basic/dropdown.h"
3203 #include "ui_basic/textarea.h"
3204 #include "ui_basic/unique_window.h"
3205 #include "wui/chat_overlay.h"
3206@@ -116,7 +118,7 @@
3207 // Returns true if the buildhelp is currently displayed.
3208 bool buildhelp() const;
3209
3210- // Sets if the buildhelp should be displayed. Will also call on_buildhelp_changed().
3211+ // Sets if the buildhelp should be displayed and then calls rebuild_showhide_menu
3212 void show_buildhelp(bool t);
3213
3214 /**
3215@@ -171,6 +173,7 @@
3216 }
3217
3218 void toggle_minimap();
3219+ // Toggles the buildhelp and calls rebuild_showhide_menu
3220 void toggle_buildhelp();
3221
3222 // Returns the list of landmarks that have been mapped to the keys 0-9
3223@@ -184,6 +187,21 @@
3224 }
3225
3226 protected:
3227+ // For referencing the items in mapviewmenu_
3228+ enum class MapviewMenuEntry {
3229+ kMinimap,
3230+ kIncreaseZoom,
3231+ kDecreaseZoom,
3232+ kResetZoom
3233+ };
3234+
3235+ // Adds the mapviewmenu_ to the toolbar
3236+ void add_mapview_menu(MiniMapType minimap_type);
3237+ // Rebuilds the mapviewmenu_ according to current view settings
3238+ void rebuild_mapview_menu();
3239+ // Takes the appropriate action when an item in the mapviewmenu_ is selected
3240+ void mapview_menu_selected(MapviewMenuEntry entry);
3241+
3242 /// Adds a toolbar button to the toolbar
3243 /// \param image_basename: File path for button image starting from 'images' and without
3244 /// file extension
3245@@ -197,13 +215,8 @@
3246 UI::UniqueWindow::Registry* window = nullptr,
3247 bool bind_default_toggle = false);
3248
3249- // Will be called whenever the buildhelp is changed with the new 'value'.
3250- virtual void on_buildhelp_changed(bool value);
3251-
3252 void hide_minimap();
3253
3254- MiniMap::Registry& minimap_registry();
3255-
3256 void mainview_move();
3257
3258 void draw_overlay(RenderTarget&) override;
3259@@ -231,16 +244,16 @@
3260 const Image* get_sel_picture() {
3261 return sel_.pic;
3262 }
3263- void adjust_toolbar_position() {
3264- toolbar_.set_pos(Vector2i((get_inner_w() - toolbar_.get_w()) >> 1, get_inner_h() - 34));
3265- }
3266+
3267+ // Sets the toolbar's position to the bottom middle and configures its background images
3268+ void finalize_toolbar();
3269
3270 ChatOverlay* chat_overlay() {
3271 return chat_overlay_;
3272 }
3273
3274 UI::Box* toolbar() {
3275- return &toolbar_;
3276+ return &toolbar_.box;
3277 }
3278
3279 // Returns the information which overlay text should currently be drawn.
3280@@ -267,6 +280,12 @@
3281 /// Returns true if the current player is allowed to hear sounds from map objects on this field
3282 virtual bool player_hears_field(const Widelands::Coords& coords) const = 0;
3283
3284+ void set_toolbar_imageset(const ToolbarImageset& imageset);
3285+
3286+#ifndef NDEBUG // only in debug builds
3287+ UI::UniqueWindow::Registry debugconsole_;
3288+#endif
3289+
3290 private:
3291 void play_sound_effect(const NoteSound& note) const;
3292 void resize_chat_overlay();
3293@@ -275,6 +294,9 @@
3294 void cmd_map_object(const std::vector<std::string>& args);
3295 void cmd_lua(const std::vector<std::string>& args);
3296
3297+ // Rebuilds the subclass' showhidemenu_ according to current map settings
3298+ virtual void rebuild_showhide_menu() = 0;
3299+
3300 struct SelData {
3301 SelData(const bool Freeze = false,
3302 const bool Triangles = false,
3303@@ -297,7 +319,26 @@
3304 MapView map_view_;
3305 ChatOverlay* chat_overlay_;
3306
3307- UI::Box toolbar_;
3308+ /// A horizontal menu bar embellished with background graphics
3309+ struct Toolbar : UI::Panel {
3310+ Toolbar(UI::Panel* parent);
3311+
3312+ /// Sets the actual size and position of the toolbar
3313+ void finalize();
3314+ void draw(RenderTarget& dst) override;
3315+ void change_imageset(const ToolbarImageset& images);
3316+
3317+ /// A row of buttons and dropdown menus
3318+ UI::Box box;
3319+ private:
3320+ /// The set of background images
3321+ ToolbarImageset imageset;
3322+ /// How often the left and right images get repeated, calculated from the width of the box
3323+ int repeat;
3324+ } toolbar_;
3325+
3326+ // Map View menu on the toolbar
3327+ UI::Dropdown<MapviewMenuEntry> mapviewmenu_;
3328 // No unique_ptr on purpose: 'minimap_' is a UniqueWindow, its parent will
3329 // delete it.
3330 MiniMap* minimap_;
3331@@ -325,7 +366,6 @@
3332 Widelands::CoordPath* buildroad_; // path for the new road
3333 Widelands::PlayerNumber road_build_player_;
3334
3335- UI::UniqueWindow::Registry debugconsole_;
3336 std::unique_ptr<UniqueWindowHandler> unique_window_handler_;
3337 BuildhelpOverlay buildhelp_overlays_[Widelands::Field::Buildhelp_None];
3338 };
3339
3340=== modified file 'src/wui/interactive_gamebase.cc'
3341--- src/wui/interactive_gamebase.cc 2019-05-26 17:21:15 +0000
3342+++ src/wui/interactive_gamebase.cc 2019-08-10 10:01:32 +0000
3343@@ -37,7 +37,11 @@
3344 #include "profile/profile.h"
3345 #include "wui/constructionsitewindow.h"
3346 #include "wui/dismantlesitewindow.h"
3347+#include "wui/game_chat_menu.h"
3348 #include "wui/game_client_disconnected.h"
3349+#include "wui/game_exit_confirm_box.h"
3350+#include "wui/game_main_menu_save_game.h"
3351+#include "wui/game_options_sound_menu.h"
3352 #include "wui/game_summary.h"
3353 #include "wui/interactive_player.h"
3354 #include "wui/militarysitewindow.h"
3355@@ -65,7 +69,25 @@
3356 : InteractiveBase(g, global_s),
3357 chat_provider_(nullptr),
3358 multiplayer_(multiplayer),
3359- playertype_(pt) {
3360+ playertype_(pt),
3361+ showhidemenu_(
3362+ toolbar(), "dropdown_menu_showhide", 0, 0, 34U, 10, 34U,
3363+ /** TRANSLATORS: Title for a menu button in the game. This menu will show/hide building spaces, census, statistics */
3364+ _("Show / Hide"),
3365+ UI::DropdownType::kPictorialMenu,
3366+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
3367+ mainmenu_(
3368+ toolbar(), "dropdown_menu_main", 0, 0, 34U, 10, 34U,
3369+ /** TRANSLATORS: Title for the main menu button in the game */
3370+ _("Main Menu"),
3371+ UI::DropdownType::kPictorialMenu,
3372+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
3373+ gamespeedmenu_(
3374+ toolbar(), "dropdown_menu_gamespeed", 0, 0, 34U, 10, 34U,
3375+ /** TRANSLATORS: Title for a menu button in the game. This menu will show options o increase/decrease the gamespeed, and to pause the game */
3376+ _("Game Speed"),
3377+ UI::DropdownType::kPictorialMenu,
3378+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary) {
3379 buildingnotes_subscriber_ = Notifications::subscribe<Widelands::NoteBuilding>(
3380 [this](const Widelands::NoteBuilding& note) {
3381 switch (note.action) {
3382@@ -93,6 +115,215 @@
3383 });
3384 }
3385
3386+void InteractiveGameBase::add_main_menu() {
3387+ mainmenu_.set_image(g_gr->images().get("images/wui/menus/main_menu.png"));
3388+ toolbar()->add(&mainmenu_);
3389+
3390+#ifndef NDEBUG // only in debug builds
3391+ /** TRANSLATORS: An entry in the game's main menu */
3392+ mainmenu_.add(_("Script Console"), MainMenuEntry::kScriptConsole, g_gr->images().get("images/wui/menus/lua.png"), false,
3393+ /** TRANSLATORS: Tooltip for Script Console in the game's main menu */
3394+ "", pgettext("hotkey", "F6"));
3395+#endif
3396+
3397+ menu_windows_.sound_options.open_window = [this] {
3398+ new GameOptionsSoundMenu(*this, menu_windows_.sound_options);
3399+ };
3400+ /** TRANSLATORS: An entry in the game's main menu */
3401+ mainmenu_.add(_("Sound Options"), MainMenuEntry::kOptions, g_gr->images().get("images/wui/menus/options.png"), false,
3402+ /** TRANSLATORS: Tooltip for Sound Options in the game's main menu */
3403+ _("Set sound effect and music options"));
3404+
3405+ menu_windows_.savegame.open_window = [this] {
3406+ new GameMainMenuSaveGame(*this, menu_windows_.savegame);
3407+ };
3408+ /** TRANSLATORS: An entry in the game's main menu */
3409+ mainmenu_.add(_("Save Game"), MainMenuEntry::kSaveMap, g_gr->images().get("images/wui/menus/save_game.png"));
3410+
3411+ /** TRANSLATORS: An entry in the game's main menu */
3412+ mainmenu_.add(_("Exit Game"), MainMenuEntry::kExitGame, g_gr->images().get("images/wui/menus/exit.png"));
3413+
3414+ mainmenu_.selected.connect([this] { main_menu_selected(mainmenu_.get_selected()); });
3415+}
3416+
3417+void InteractiveGameBase::main_menu_selected(MainMenuEntry entry) {
3418+ switch (entry) {
3419+#ifndef NDEBUG // only in debug builds
3420+ case MainMenuEntry::kScriptConsole: {
3421+ GameChatMenu::create_script_console(
3422+ this, debugconsole_, *DebugConsole::get_chat_provider());
3423+ } break;
3424+#endif
3425+ case MainMenuEntry::kOptions: {
3426+ menu_windows_.sound_options.toggle();
3427+ } break;
3428+ case MainMenuEntry::kSaveMap: {
3429+ menu_windows_.savegame.toggle();
3430+ } break;
3431+ case MainMenuEntry::kExitGame: {
3432+ if (SDL_GetModState() & KMOD_CTRL) {
3433+ end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
3434+ } else {
3435+ new GameExitConfirmBox(*this, *this);
3436+ }
3437+ } break;
3438+ }
3439+}
3440+
3441+void InteractiveGameBase::add_showhide_menu() {
3442+ showhidemenu_.set_image(g_gr->images().get("images/wui/menus/showhide.png"));
3443+ toolbar()->add(&showhidemenu_);
3444+
3445+ rebuild_showhide_menu();
3446+ showhidemenu_.selected.connect([this] { showhide_menu_selected(showhidemenu_.get_selected()); });
3447+}
3448+
3449+void InteractiveGameBase::rebuild_showhide_menu() {
3450+ showhidemenu_.clear();
3451+
3452+ /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building spaces are shown */
3453+ showhidemenu_.add(buildhelp() ? _("Hide Building Spaces") : _("Show Building Spaces"),
3454+ ShowHideEntry::kBuildingSpaces, g_gr->images().get("images/wui/menus/toggle_buildhelp.png"),
3455+ false, "", pgettext("hotkey", "Space"));
3456+
3457+ /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building names are shown */
3458+ showhidemenu_.add(get_display_flag(dfShowCensus) ? _("Hide Census") : _("Show Census"),
3459+ ShowHideEntry::kCensus, g_gr->images().get("images/wui/menus/toggle_census.png"),
3460+ false, "", "c");
3461+
3462+ /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether building staristics are shown */
3463+ showhidemenu_.add(get_display_flag(dfShowStatistics) ? _("Hide Statistics") : _("Show Statistics"),
3464+ ShowHideEntry::kStatistics, g_gr->images().get("images/wui/menus/toggle_statistics.png"),
3465+ false, "", "s");
3466+}
3467+
3468+void InteractiveGameBase::showhide_menu_selected(ShowHideEntry entry) {
3469+ switch (entry) {
3470+ case ShowHideEntry::kBuildingSpaces: {
3471+ toggle_buildhelp();
3472+ } break;
3473+ case ShowHideEntry::kCensus: {
3474+ set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
3475+ } break;
3476+ case ShowHideEntry::kStatistics: {
3477+ set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
3478+ } break;
3479+ case ShowHideEntry::kWorkareaOverlap: {
3480+ set_display_flag(dfShowWorkareaOverlap, !get_display_flag(dfShowWorkareaOverlap));
3481+ } break;
3482+ }
3483+ rebuild_showhide_menu();
3484+}
3485+
3486+
3487+void InteractiveGameBase::add_gamespeed_menu() {
3488+ gamespeedmenu_.set_image(g_gr->images().get("images/wui/menus/gamespeed.png"));
3489+ toolbar()->add(&gamespeedmenu_);
3490+ rebuild_gamespeed_menu();
3491+ gamespeedmenu_.selected.connect([this] { gamespeed_menu_selected(gamespeedmenu_.get_selected()); });
3492+}
3493+
3494+
3495+void InteractiveGameBase::rebuild_gamespeed_menu() {
3496+ gamespeedmenu_.clear();
3497+
3498+ gamespeedmenu_.add(_("Speed +"), GameSpeedEntry::kIncrease, g_gr->images().get("images/wui/menus/gamespeed_increase.png"), false,
3499+ /** TRANSLATORS: Tooltip for Speed + in the game's game speed menu */
3500+ _("Increase the game speed"), pgettext("hotkey", "Page Up"));
3501+
3502+ gamespeedmenu_.add(_("Speed -"), GameSpeedEntry::kDecrease, g_gr->images().get("images/wui/menus/gamespeed_decrease.png"), false,
3503+ /** TRANSLATORS: Tooltip for Speed - in the game's game speed menu */
3504+ _("Decrease the game speed"), pgettext("hotkey", "Page Down"));
3505+
3506+ if (!is_multiplayer()) {
3507+ if (get_game()->game_controller() && get_game()->game_controller()->is_paused()) {
3508+ gamespeedmenu_.add(_("Resume"), GameSpeedEntry::kPause, g_gr->images().get("images/wui/menus/gamespeed_resume.png"), false,
3509+ /** TRANSLATORS: Tooltip for Pause in the game's game speed menu */
3510+ _("Resume the Game"), pgettext("hotkey", "Pause"));
3511+ } else {
3512+ gamespeedmenu_.add(_("Pause"), GameSpeedEntry::kPause, g_gr->images().get("images/wui/menus/gamespeed_pause.png"), false,
3513+ /** TRANSLATORS: Tooltip for Pause in the game's game speed menu */
3514+ _("Pause the Game"), pgettext("hotkey", "Pause"));
3515+ }
3516+ }
3517+}
3518+
3519+void InteractiveGameBase::gamespeed_menu_selected(GameSpeedEntry entry) {
3520+ switch (entry) {
3521+ case GameSpeedEntry::kIncrease: {
3522+ increase_gamespeed();
3523+ // Keep the window open so that the player can click this multiple times
3524+ gamespeedmenu_.toggle();
3525+ } break;
3526+ case GameSpeedEntry::kDecrease: {
3527+ decrease_gamespeed();
3528+ // Keep the window open so that the player can click this multiple times
3529+ gamespeedmenu_.toggle();
3530+ } break;
3531+ case GameSpeedEntry::kPause: {
3532+ if (!is_multiplayer()) {
3533+ toggle_game_paused();
3534+ }
3535+ } break;
3536+ }
3537+}
3538+
3539+void InteractiveGameBase::increase_gamespeed() {
3540+ if (GameController* const ctrl = get_game()->game_controller()) {
3541+ ctrl->set_desired_speed(ctrl->desired_speed() + 1000);
3542+ }
3543+}
3544+
3545+void InteractiveGameBase::decrease_gamespeed() {
3546+ if (GameController* const ctrl = get_game()->game_controller()) {
3547+ uint32_t const speed = ctrl->desired_speed();
3548+ ctrl->set_desired_speed(1000 < speed ? speed - 1000 : 0);
3549+ }
3550+}
3551+
3552+void InteractiveGameBase::toggle_game_paused() {
3553+ if (GameController* const ctrl = get_game()->game_controller()) {
3554+ ctrl->toggle_paused();
3555+ // Toggle Pause / Resume in the menu
3556+ rebuild_gamespeed_menu();
3557+ }
3558+}
3559+
3560+bool InteractiveGameBase::handle_key(bool down, SDL_Keysym code) {
3561+ if (InteractiveBase::handle_key(down, code)) {
3562+ return true;
3563+ }
3564+
3565+ if (down) {
3566+ switch (code.sym) {
3567+ case SDLK_KP_9:
3568+ if (code.mod & KMOD_NUM) {
3569+ break;
3570+ }
3571+ FALLS_THROUGH;
3572+ case SDLK_PAGEUP:
3573+ increase_gamespeed();
3574+ return true;
3575+
3576+ case SDLK_PAUSE:
3577+ toggle_game_paused();
3578+ return true;
3579+
3580+ case SDLK_KP_3:
3581+ if (code.mod & KMOD_NUM) {
3582+ break;
3583+ }
3584+ FALLS_THROUGH;
3585+ case SDLK_PAGEDOWN:
3586+ decrease_gamespeed();
3587+ return true;
3588+ default:
3589+ break;
3590+ }
3591+ }
3592+ return false;
3593+}
3594+
3595 /// \return a pointer to the running \ref Game instance.
3596 Widelands::Game* InteractiveGameBase::get_game() const {
3597 return dynamic_cast<Widelands::Game*>(&egbase());
3598@@ -180,7 +411,6 @@
3599 */
3600 void InteractiveGameBase::postload() {
3601 show_buildhelp(false);
3602- on_buildhelp_changed(buildhelp());
3603
3604 // Recalc whole map for changed owner stuff
3605 egbase().mutable_map()->recalc_whole_map(egbase().world());
3606@@ -210,10 +440,6 @@
3607 }
3608 }
3609
3610-void InteractiveGameBase::on_buildhelp_changed(const bool value) {
3611- toggle_buildhelp_->set_perm_pressed(value);
3612-}
3613-
3614 void InteractiveGameBase::add_wanted_building_window(const Widelands::Coords& coords,
3615 const Vector2i point,
3616 bool was_minimal) {
3617
3618=== modified file 'src/wui/interactive_gamebase.h'
3619--- src/wui/interactive_gamebase.h 2019-05-12 16:28:27 +0000
3620+++ src/wui/interactive_gamebase.h 2019-08-10 10:01:32 +0000
3621@@ -25,6 +25,7 @@
3622
3623 #include "logic/game.h"
3624 #include "profile/profile.h"
3625+#include "ui_basic/dropdown.h"
3626 #include "ui_basic/unique_window.h"
3627 #include "wui/general_statistics_menu.h"
3628 #include "wui/interactive_base.h"
3629@@ -35,22 +36,6 @@
3630
3631 class InteractiveGameBase : public InteractiveBase {
3632 public:
3633- struct GameMainMenuWindows {
3634- UI::UniqueWindow::Registry loadgame;
3635- UI::UniqueWindow::Registry savegame;
3636- UI::UniqueWindow::Registry readme;
3637- UI::UniqueWindow::Registry keys;
3638- UI::UniqueWindow::Registry help;
3639- UI::UniqueWindow::Registry license;
3640- UI::UniqueWindow::Registry sound_options;
3641-
3642- UI::UniqueWindow::Registry building_stats;
3643- GeneralStatisticsMenu::Registry general_stats;
3644- UI::UniqueWindow::Registry ware_stats;
3645- UI::UniqueWindow::Registry stock;
3646- UI::UniqueWindow::Registry seafaring_stats;
3647- };
3648-
3649 InteractiveGameBase(Widelands::Game&,
3650 Section& global_s,
3651 PlayerType pt = NONE,
3652@@ -104,20 +89,85 @@
3653 void start() override;
3654
3655 protected:
3656+ // For referencing the items in showhidemenu_
3657+ enum class ShowHideEntry {
3658+ kBuildingSpaces,
3659+ kCensus,
3660+ kStatistics,
3661+ kWorkareaOverlap
3662+ };
3663+
3664+ // Adds the mapviewmenu_ to the toolbar
3665+ void add_main_menu();
3666+ // Adds the showhidemenu_ to the toolbar
3667+ void add_showhide_menu();
3668+ void rebuild_showhide_menu() override;
3669+ // Adds the gamespeedmenu_ to the toolbar
3670+ void add_gamespeed_menu();
3671+
3672+ bool handle_key(bool down, SDL_Keysym code) override;
3673+
3674 void draw_overlay(RenderTarget&) override;
3675
3676- GameMainMenuWindows main_windows_;
3677+ // All unique menu windows
3678+ struct GameMenuWindows {
3679+ UI::UniqueWindow::Registry sound_options;
3680+ UI::UniqueWindow::Registry savegame;
3681+
3682+ GeneralStatisticsMenu::Registry stats_general;
3683+ UI::UniqueWindow::Registry stats_wares;
3684+ UI::UniqueWindow::Registry stats_stock;
3685+ UI::UniqueWindow::Registry stats_buildings;
3686+ UI::UniqueWindow::Registry stats_seafaring;
3687+
3688+ UI::UniqueWindow::Registry help;
3689+ } menu_windows_;
3690+
3691 ChatProvider* chat_provider_;
3692 bool multiplayer_;
3693 PlayerType playertype_;
3694+
3695+ // Show / Hide menu on the toolbar
3696+ UI::Dropdown<ShowHideEntry> showhidemenu_;
3697+
3698 UI::UniqueWindow::Registry fieldaction_;
3699 UI::UniqueWindow::Registry game_summary_;
3700 UI::UniqueWindow::Registry client_disconnected_;
3701- UI::Button* toggle_buildhelp_;
3702- UI::Button* reset_zoom_;
3703
3704 private:
3705- void on_buildhelp_changed(const bool value) override;
3706+ // For referencing the items in mainmenu_
3707+ enum class MainMenuEntry {
3708+#ifndef NDEBUG // only in debug builds
3709+ kScriptConsole,
3710+#endif
3711+ kOptions,
3712+ kSaveMap,
3713+ kExitGame
3714+ };
3715+
3716+ // For referencing the items in gamespeedmenu_
3717+ enum class GameSpeedEntry {
3718+ kIncrease,
3719+ kDecrease,
3720+ kPause
3721+ };
3722+
3723+ // Takes the appropriate action when an item in the mainmenu_ is selected
3724+ void main_menu_selected(MainMenuEntry entry);
3725+ // Takes the appropriate action when an item in the showhidemenu_ is selected
3726+ void showhide_menu_selected(ShowHideEntry entry);
3727+ // Takes the appropriate action when an item in the gamespeedmenu_ is selected
3728+ void gamespeed_menu_selected(GameSpeedEntry entry);
3729+ // Rebuilds the gamespeedmenu_ according to current game settings
3730+ void rebuild_gamespeed_menu();
3731+
3732+ // Increases the gamespeed
3733+ void increase_gamespeed();
3734+ // Decreases the gamespeed
3735+ void decrease_gamespeed();
3736+ // Pauses / Unpauses the game and calls rebuild_gamespeed_menu
3737+ void toggle_game_paused();
3738+
3739 struct WantedBuildingWindow {
3740 explicit WantedBuildingWindow(const Vector2i& pos,
3741 bool was_minimized,
3742@@ -128,6 +178,12 @@
3743 const bool minimize;
3744 const bool show_workarea;
3745 };
3746+
3747+ // Main menu on the toolbar
3748+ UI::Dropdown<MainMenuEntry> mainmenu_;
3749+ // Game speed menu on the toolbar
3750+ UI::Dropdown<GameSpeedEntry> gamespeedmenu_;
3751+
3752 // Building coordinates, window position, whether the window was minimized
3753 std::map<uint32_t, std::unique_ptr<const WantedBuildingWindow>> wanted_building_windows_;
3754 std::unique_ptr<Notifications::Subscriber<Widelands::NoteBuilding>> buildingnotes_subscriber_;
3755
3756=== modified file 'src/wui/interactive_player.cc'
3757--- src/wui/interactive_player.cc 2019-05-31 19:31:45 +0000
3758+++ src/wui/interactive_player.cc 2019-08-10 10:01:32 +0000
3759@@ -48,8 +48,6 @@
3760 #include "wui/game_main_menu_save_game.h"
3761 #include "wui/game_message_menu.h"
3762 #include "wui/game_objectives_menu.h"
3763-#include "wui/game_options_menu.h"
3764-#include "wui/game_statistics_menu.h"
3765 #include "wui/general_statistics_menu.h"
3766 #include "wui/seafaring_statistics_menu.h"
3767 #include "wui/stock_menu.h"
3768@@ -161,36 +159,26 @@
3769 : InteractiveGameBase(g, global_s, NONE, multiplayer),
3770 auto_roadbuild_mode_(global_s.get_bool("auto_roadbuild_mode", true)),
3771 flag_to_connect_(Widelands::Coords::null()),
3772- grid_marker_pic_(g_gr->images().get("images/wui/overlays/grid_marker.png")) {
3773- add_toolbar_button(
3774- "wui/menus/menu_options_menu", "options_menu", _("Main menu"), &options_, true);
3775- options_.open_window = [this] { new GameOptionsMenu(*this, options_, main_windows_); };
3776-
3777- add_toolbar_button(
3778- "wui/menus/menu_toggle_menu", "statistics_menu", _("Statistics"), &statisticsmenu_, true);
3779- statisticsmenu_.open_window = [this] {
3780- new GameStatisticsMenu(*this, statisticsmenu_, main_windows_);
3781- };
3782+ statisticsmenu_(
3783+ toolbar(), "dropdown_menu_statistics", 0, 0, 34U, 10, 34U,
3784+ /** TRANSLATORS: Title for the statistics menu button in the game */
3785+ _("Statistics"),
3786+ UI::DropdownType::kPictorialMenu,
3787+ UI::PanelStyle::kWui, UI::ButtonStyle::kWuiPrimary),
3788+ grid_marker_pic_(g_gr->images().get("images/wui/overlays/grid_marker.png")) {
3789+ add_main_menu();
3790
3791 set_display_flag(InteractiveBase::dfShowWorkareaOverlap, true); // enable by default
3792
3793 toolbar()->add_space(15);
3794
3795- add_toolbar_button(
3796- "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);
3797- minimap_registry().open_window = [this] { toggle_minimap(); };
3798+ add_mapview_menu(MiniMapType::kStaticViewWindow);
3799+ add_showhide_menu();
3800+ add_gamespeed_menu();
3801
3802- toggle_buildhelp_ = add_toolbar_button(
3803- "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
3804- toggle_buildhelp_->sigclicked.connect(boost::bind(&InteractiveBase::toggle_buildhelp, this));
3805- reset_zoom_ = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
3806- reset_zoom_->sigclicked.connect([this] {
3807- map_view()->zoom_around(
3808- 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
3809- });
3810 toolbar()->add_space(15);
3811 if (multiplayer) {
3812- toggle_chat_ = add_toolbar_button("wui/menus/menu_chat", "chat", _("Chat"), &chat_, true);
3813+ toggle_chat_ = add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
3814 chat_.open_window = [this] {
3815 if (chat_provider_) {
3816 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
3817@@ -199,14 +187,18 @@
3818 toolbar()->add_space(15);
3819 }
3820
3821+ add_statistics_menu();
3822+
3823 add_toolbar_button(
3824- "wui/menus/menu_objectives", "objectives", _("Objectives"), &objectives_, true);
3825+ "wui/menus/objectives", "objectives", _("Objectives"), &objectives_, true);
3826 objectives_.open_window = [this] { new GameObjectivesMenu(this, objectives_); };
3827
3828 toggle_message_menu_ = add_toolbar_button(
3829- "wui/menus/menu_toggle_oldmessage_menu", "messages", _("Messages"), &message_menu_, true);
3830+ "wui/menus/message_old", "messages", _("Messages"), &message_menu_, true);
3831 message_menu_.open_window = [this] { new GameMessageMenu(*this, message_menu_); };
3832
3833+ toolbar()->add_space(15);
3834+
3835 add_toolbar_button("ui_basic/menu_help", "help", _("Help"), &encyclopedia_, true);
3836 encyclopedia_.open_window = [this] {
3837 new TribalEncyclopedia(*this, encyclopedia_, &game().lua());
3838@@ -217,13 +209,106 @@
3839 node_action(node_and_triangle);
3840 });
3841
3842- adjust_toolbar_position();
3843-
3844- main_windows_.stock.open_window = [this] { new StockMenu(*this, main_windows_.stock); };
3845+ finalize_toolbar();
3846
3847 #ifndef NDEBUG // only in debug builds
3848 addCommand("switchplayer", boost::bind(&InteractivePlayer::cmdSwitchPlayer, this, _1));
3849 #endif
3850+
3851+ map_options_subscriber_ =
3852+ Notifications::subscribe<NoteMapOptions>([this](const NoteMapOptions&) {
3853+ rebuild_statistics_menu();
3854+ });
3855+}
3856+
3857+
3858+void InteractivePlayer::add_statistics_menu() {
3859+ statisticsmenu_.set_image(g_gr->images().get("images/wui/menus/statistics.png"));
3860+ toolbar()->add(&statisticsmenu_);
3861+
3862+ menu_windows_.stats_seafaring.open_window = [this] {
3863+ new SeafaringStatisticsMenu(*this, menu_windows_.stats_seafaring);
3864+ };
3865+
3866+ menu_windows_.stats_stock.open_window = [this] { new StockMenu(*this, menu_windows_.stats_stock); };
3867+
3868+ menu_windows_.stats_buildings.open_window = [this] {
3869+ new BuildingStatisticsMenu(*this, menu_windows_.stats_buildings);
3870+ };
3871+
3872+
3873+ menu_windows_.stats_wares.open_window = [this] {
3874+ new WareStatisticsMenu(*this, menu_windows_.stats_wares);
3875+ };
3876+
3877+ menu_windows_.stats_general.open_window = [this] {
3878+ new GeneralStatisticsMenu(*this, menu_windows_.stats_general);
3879+ };
3880+
3881+ // NoteMapOptions takes care of the rebuilding
3882+
3883+ statisticsmenu_.selected.connect([this] { statistics_menu_selected(statisticsmenu_.get_selected()); });
3884+}
3885+
3886+void InteractivePlayer::rebuild_statistics_menu() {
3887+ statisticsmenu_.clear();
3888+
3889+ if (egbase().map().allows_seafaring()) {
3890+ /** TRANSLATORS: An entry in the game's statistics menu */
3891+ statisticsmenu_.add(_("Seafaring"), StatisticsMenuEntry::kSeafaring,
3892+ g_gr->images().get("images/wui/menus/statistics_seafaring.png"),
3893+ false, "", "e");
3894+ }
3895+
3896+ /** TRANSLATORS: An entry in the game's statistics menu */
3897+ statisticsmenu_.add(_("Stock"), StatisticsMenuEntry::kStock,
3898+ g_gr->images().get("images/wui/menus/statistics_stock.png"),
3899+ false, "", "i");
3900+
3901+ /** TRANSLATORS: An entry in the game's statistics menu */
3902+ statisticsmenu_.add(_("Buildings"), StatisticsMenuEntry::kBuildings,
3903+ g_gr->images().get("images/wui/menus/statistics_buildings.png"),
3904+ false, "", "b");
3905+
3906+ /** TRANSLATORS: An entry in the game's statistics menu */
3907+ statisticsmenu_.add(_("Wares"), StatisticsMenuEntry::kWare, g_gr->images().get("images/wui/menus/statistics_wares.png"));
3908+
3909+
3910+ /** TRANSLATORS: An entry in the game's statistics menu */
3911+ statisticsmenu_.add(_("General"), StatisticsMenuEntry::kGeneral, g_gr->images().get("images/wui/menus/statistics_general.png"));
3912+}
3913+
3914+void InteractivePlayer::statistics_menu_selected(StatisticsMenuEntry entry) {
3915+ switch (entry) {
3916+ case StatisticsMenuEntry::kGeneral: {
3917+ menu_windows_.stats_general.toggle();
3918+ } break;
3919+ case StatisticsMenuEntry::kWare: {
3920+ menu_windows_.stats_wares.toggle();
3921+ } break;
3922+ case StatisticsMenuEntry::kBuildings: {
3923+ menu_windows_.stats_buildings.toggle();
3924+ } break;
3925+ case StatisticsMenuEntry::kStock: {
3926+ menu_windows_.stats_stock.toggle();
3927+ } break;
3928+ case StatisticsMenuEntry::kSeafaring: {
3929+ if (egbase().map().allows_seafaring()) {
3930+ menu_windows_.stats_seafaring.toggle();
3931+ }
3932+ } break;
3933+ }
3934+ statisticsmenu_.toggle();
3935+}
3936+
3937+void InteractivePlayer::rebuild_showhide_menu() {
3938+ InteractiveGameBase::rebuild_showhide_menu();
3939+
3940+ /** TRANSLATORS: An entry in the game's show/hide menu to toggle whether workarea overlaps are highlighted */
3941+ showhidemenu_.add(get_display_flag(dfShowWorkareaOverlap) ? _("Hide Workarea Overlaps") : _("Show Workarea Overlaps"),
3942+ ShowHideEntry::kWorkareaOverlap, g_gr->images().get("images/wui/menus/show_workarea_overlap.png"),
3943+ false, _("Toggle whether overlapping workareas are indicated when placing a constructionsite"),
3944+ "w");
3945 }
3946
3947 void InteractivePlayer::think() {
3948@@ -255,11 +340,11 @@
3949 toggle_chat_->set_enabled(chat_provider_);
3950 }
3951 {
3952- char const* msg_icon = "images/wui/menus/menu_toggle_oldmessage_menu.png";
3953+ char const* msg_icon = "images/wui/menus/message_old.png";
3954 std::string msg_tooltip = _("Messages");
3955 if (uint32_t const nr_new_messages =
3956 player().messages().nr_messages(Widelands::Message::Status::kNew)) {
3957- msg_icon = "images/wui/menus/menu_toggle_newmessage_menu.png";
3958+ msg_icon = "images/wui/menus/message_new.png";
3959 msg_tooltip =
3960 (boost::format(ngettext("%u new message", "%u new messages", nr_new_messages)) %
3961 nr_new_messages)
3962@@ -427,11 +512,7 @@
3963 return true;
3964
3965 case SDLK_i:
3966- main_windows_.stock.toggle();
3967- return true;
3968-
3969- case SDLK_m:
3970- minimap_registry().toggle();
3971+ menu_windows_.stats_stock.toggle();
3972 return true;
3973
3974 case SDLK_n:
3975@@ -451,26 +532,26 @@
3976 return true;
3977
3978 case SDLK_b:
3979- if (main_windows_.building_stats.window == nullptr) {
3980- new BuildingStatisticsMenu(*this, main_windows_.building_stats);
3981+ if (menu_windows_.stats_buildings.window == nullptr) {
3982+ new BuildingStatisticsMenu(*this, menu_windows_.stats_buildings);
3983 } else {
3984- main_windows_.building_stats.toggle();
3985+ menu_windows_.stats_buildings.toggle();
3986 }
3987 return true;
3988
3989 case SDLK_e:
3990 if (game().map().allows_seafaring()) {
3991- if (main_windows_.seafaring_stats.window == nullptr) {
3992- new SeafaringStatisticsMenu(*this, main_windows_.seafaring_stats);
3993+ if (menu_windows_.stats_seafaring.window == nullptr) {
3994+ new SeafaringStatisticsMenu(*this, menu_windows_.stats_seafaring);
3995 } else {
3996- main_windows_.seafaring_stats.toggle();
3997+ menu_windows_.stats_seafaring.toggle();
3998 }
3999 }
4000 return true;
4001
4002 case SDLK_s:
4003 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
4004- new GameMainMenuSaveGame(*this, main_windows_.savegame);
4005+ new GameMainMenuSaveGame(*this, menu_windows_.savegame);
4006 else
4007 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
4008 return true;
4009@@ -520,12 +601,20 @@
4010 void InteractivePlayer::cleanup_for_load() {
4011 }
4012
4013+void InteractivePlayer::postload() {
4014+ InteractiveGameBase::postload();
4015+
4016+ ToolbarImageset* imageset = player().tribe().toolbar_image_set();
4017+ if (imageset != nullptr) {
4018+ set_toolbar_imageset(*imageset);
4019+ }
4020+}
4021+
4022 bool InteractivePlayer::player_hears_field(const Widelands::Coords& coords) const {
4023 const Widelands::Player& plr = player();
4024 if (plr.see_all()) {
4025 return true;
4026 }
4027-
4028 const Widelands::Map& map = egbase().map();
4029 const Widelands::Player::Field& player_field =
4030 plr.fields()[map.get_index(coords, map.get_width())];
4031@@ -548,7 +637,7 @@
4032 str(boost::format("Switching from #%1% to #%2%.") % static_cast<int>(player_number_) % n));
4033 player_number_ = n;
4034
4035- if (UI::UniqueWindow* const building_statistics_window = main_windows_.building_stats.window) {
4036+ if (UI::UniqueWindow* const building_statistics_window = menu_windows_.stats_buildings.window) {
4037 dynamic_cast<BuildingStatisticsMenu&>(*building_statistics_window).update();
4038 }
4039 }
4040
4041=== modified file 'src/wui/interactive_player.h'
4042--- src/wui/interactive_player.h 2019-04-25 06:31:33 +0000
4043+++ src/wui/interactive_player.h 2019-08-10 10:01:32 +0000
4044@@ -20,11 +20,13 @@
4045 #ifndef WL_WUI_INTERACTIVE_PLAYER_H
4046 #define WL_WUI_INTERACTIVE_PLAYER_H
4047
4048+#include <memory>
4049 #include <vector>
4050
4051 #include <SDL_keyboard.h>
4052
4053 #include "logic/message_id.h"
4054+#include "logic/note_map_options.h"
4055 #include "profile/profile.h"
4056 #include "ui_basic/button.h"
4057 #include "wui/interactive_gamebase.h"
4058@@ -64,6 +66,7 @@
4059
4060 // For load
4061 void cleanup_for_load() override;
4062+ void postload() override;
4063 void think() override;
4064 void draw(RenderTarget& dst) override;
4065
4066@@ -74,6 +77,23 @@
4067 void popup_message(Widelands::MessageId, const Widelands::Message&);
4068
4069 private:
4070+ // For referencing the items in statisticsmenu_
4071+ enum class StatisticsMenuEntry {
4072+ kGeneral,
4073+ kWare,
4074+ kBuildings,
4075+ kStock,
4076+ kSeafaring
4077+ };
4078+
4079+ // Adds the statisticsmenu_ to the toolbar
4080+ void add_statistics_menu();
4081+ // Rebuilds the statisticsmenu_ according to current map settings
4082+ void rebuild_statistics_menu();
4083+ // Takes the appropriate action when an item in the statisticsmenu_ is selected
4084+ void statistics_menu_selected(StatisticsMenuEntry entry);
4085+ void rebuild_showhide_menu() override;
4086+
4087 bool player_hears_field(const Widelands::Coords& coords) const override;
4088
4089 void cmdSwitchPlayer(const std::vector<std::string>& args);
4090@@ -85,14 +105,16 @@
4091 UI::Button* toggle_chat_;
4092 UI::Button* toggle_message_menu_;
4093
4094+ // Statistics menu on the toolbar
4095+ UI::Dropdown<StatisticsMenuEntry> statisticsmenu_;
4096 UI::UniqueWindow::Registry chat_;
4097- UI::UniqueWindow::Registry options_;
4098- UI::UniqueWindow::Registry statisticsmenu_;
4099 UI::UniqueWindow::Registry objectives_;
4100 UI::UniqueWindow::Registry encyclopedia_;
4101 UI::UniqueWindow::Registry message_menu_;
4102
4103 const Image* grid_marker_pic_;
4104+
4105+ std::unique_ptr<Notifications::Subscriber<NoteMapOptions>> map_options_subscriber_;
4106 };
4107
4108 #endif // end of include guard: WL_WUI_INTERACTIVE_PLAYER_H
4109
4110=== modified file 'src/wui/interactive_spectator.cc'
4111--- src/wui/interactive_spectator.cc 2019-04-25 21:48:17 +0000
4112+++ src/wui/interactive_spectator.cc 2019-08-10 10:01:32 +0000
4113@@ -30,7 +30,6 @@
4114 #include "wui/fieldaction.h"
4115 #include "wui/game_chat_menu.h"
4116 #include "wui/game_main_menu_save_game.h"
4117-#include "wui/game_options_menu.h"
4118 #include "wui/general_statistics_menu.h"
4119
4120 /**
4121@@ -40,48 +39,24 @@
4122 Section& global_s,
4123 bool const multiplayer)
4124 : InteractiveGameBase(g, global_s, OBSERVER, multiplayer) {
4125- if (is_multiplayer()) {
4126- add_toolbar_button(
4127- "wui/menus/menu_options_menu", "options_menu", _("Main menu"), &options_, true);
4128- options_.open_window = [this] { new GameOptionsMenu(*this, options_, main_windows_); };
4129-
4130- } else {
4131- UI::Button* button =
4132- add_toolbar_button("wui/menus/menu_exit_game", "exit_replay", _("Exit replay"));
4133- button->sigclicked.connect(boost::bind(&InteractiveSpectator::exit_btn, this));
4134-
4135- add_toolbar_button(
4136- "wui/menus/menu_save_game", "save_game", _("Save game"), &main_windows_.savegame, true);
4137- main_windows_.savegame.open_window = [this] {
4138- new GameMainMenuSaveGame(*this, main_windows_.savegame);
4139- };
4140- }
4141- add_toolbar_button("wui/menus/menu_general_stats", "general_stats", _("Statistics"),
4142- &main_windows_.general_stats, true);
4143- main_windows_.general_stats.open_window = [this] {
4144- new GeneralStatisticsMenu(*this, main_windows_.general_stats);
4145+ add_main_menu();
4146+
4147+ add_toolbar_button("wui/menus/statistics_general", "general_stats", _("Statistics"),
4148+ &menu_windows_.stats_general, true);
4149+ menu_windows_.stats_general.open_window = [this] {
4150+ new GeneralStatisticsMenu(*this, menu_windows_.stats_general);
4151 };
4152
4153 toolbar()->add_space(15);
4154
4155- add_toolbar_button(
4156- "wui/menus/menu_toggle_minimap", "minimap", _("Minimap"), &minimap_registry(), true);
4157- minimap_registry().open_window = [this] { toggle_minimap(); };
4158-
4159- toggle_buildhelp_ = add_toolbar_button(
4160- "wui/menus/menu_toggle_buildhelp", "buildhelp", _("Show building spaces (on/off)"));
4161- toggle_buildhelp_->sigclicked.connect(boost::bind(&InteractiveBase::toggle_buildhelp, this));
4162-
4163- reset_zoom_ = add_toolbar_button("wui/menus/menu_reset_zoom", "reset_zoom", _("Reset zoom"));
4164- reset_zoom_->sigclicked.connect([this] {
4165- map_view()->zoom_around(
4166- 1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), MapView::Transition::Smooth);
4167- });
4168+ add_mapview_menu(MiniMapType::kStaticViewWindow);
4169+ add_showhide_menu();
4170+ add_gamespeed_menu();
4171
4172 toolbar()->add_space(15);
4173
4174 if (is_multiplayer()) {
4175- add_toolbar_button("wui/menus/menu_chat", "chat", _("Chat"), &chat_, true);
4176+ add_toolbar_button("wui/menus/chat", "chat", _("Chat"), &chat_, true);
4177 chat_.open_window = [this] {
4178 if (chat_provider_) {
4179 GameChatMenu::create_chat_console(this, chat_, *chat_provider_);
4180@@ -89,7 +64,7 @@
4181 };
4182 }
4183
4184- adjust_toolbar_position();
4185+ finalize_toolbar();
4186
4187 // Setup all screen elements
4188 map_view()->field_clicked.connect([this](const Widelands::NodeAndTriangle<>& node_and_triangle) {
4189@@ -222,17 +197,13 @@
4190 toggle_buildhelp();
4191 return true;
4192
4193- case SDLK_m:
4194- minimap_registry().toggle();
4195- return true;
4196-
4197 case SDLK_c:
4198 set_display_flag(dfShowCensus, !get_display_flag(dfShowCensus));
4199 return true;
4200
4201 case SDLK_s:
4202 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
4203- new GameMainMenuSaveGame(*this, main_windows_.savegame);
4204+ new GameMainMenuSaveGame(*this, menu_windows_.savegame);
4205 } else
4206 set_display_flag(dfShowStatistics, !get_display_flag(dfShowStatistics));
4207 return true;
4208
4209=== modified file 'src/wui/interactive_spectator.h'
4210--- src/wui/interactive_spectator.h 2019-03-14 23:06:02 +0000
4211+++ src/wui/interactive_spectator.h 2019-08-10 10:01:32 +0000
4212@@ -56,7 +56,6 @@
4213 void node_action(const Widelands::NodeAndTriangle<>& node_and_triangle) override;
4214
4215 UI::UniqueWindow::Registry chat_;
4216- UI::UniqueWindow::Registry options_;
4217 };
4218
4219 #endif // end of include guard: WL_WUI_INTERACTIVE_SPECTATOR_H
4220
4221=== modified file 'src/wui/mapdetails.cc'
4222--- src/wui/mapdetails.cc 2019-05-25 09:33:17 +0000
4223+++ src/wui/mapdetails.cc 2019-08-10 10:01:32 +0000
4224@@ -42,6 +42,7 @@
4225 style_(style),
4226 padding_(4),
4227 main_box_(this, 0, 0, UI::Box::Vertical, 0, 0, 0),
4228+ name_(""),
4229 name_label_(&main_box_,
4230 0,
4231 0,
4232@@ -86,6 +87,7 @@
4233
4234 void MapDetails::update(const MapData& mapdata, bool localize_mapname) {
4235 clear();
4236+ name_= mapdata.name;
4237 // Show directory information
4238 if (mapdata.maptype == MapData::MapType::kDirectory) {
4239 name_label_.set_text(
4240
4241=== modified file 'src/wui/mapdetails.h'
4242--- src/wui/mapdetails.h 2019-04-18 16:50:35 +0000
4243+++ src/wui/mapdetails.h 2019-08-10 10:01:32 +0000
4244@@ -36,6 +36,9 @@
4245
4246 void clear();
4247 void update(const MapData& mapdata, bool localize_mapname);
4248+ std::string name() {
4249+ return name_;
4250+ }
4251
4252 private:
4253 void layout() override;
4254@@ -43,6 +46,7 @@
4255 const int padding_;
4256
4257 UI::Box main_box_;
4258+ std::string name_;
4259 UI::MultilineTextarea name_label_;
4260 UI::MultilineTextarea descr_;
4261 UI::SuggestedTeamsBox* suggested_teams_box_;
4262
4263=== modified file 'src/wui/mapview.cc'
4264--- src/wui/mapview.cc 2019-04-25 06:31:33 +0000
4265+++ src/wui/mapview.cc 2019-08-10 10:01:32 +0000
4266@@ -40,6 +40,9 @@
4267 // value is used for automatic movements and for user controlled zoom.
4268 constexpr float kMaxZoom = 4.f;
4269
4270+// Step size for zooming by keypress or UI button
4271+constexpr float kZoomPercentPerKeyPress = 0.10f;
4272+
4273 // The time used for panning automated map movement only.
4274 constexpr float kShortAnimationMs = 500.f;
4275
4276@@ -556,6 +559,19 @@
4277 NEVER_HERE();
4278 }
4279
4280+
4281+void MapView::reset_zoom() {
4282+ zoom_around(1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4283+}
4284+void MapView::increase_zoom() {
4285+ zoom_around(animation_target_view().view.zoom - kZoomPercentPerKeyPress,
4286+ Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4287+}
4288+void MapView::decrease_zoom() {
4289+ zoom_around(animation_target_view().view.zoom + kZoomPercentPerKeyPress,
4290+ Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4291+}
4292+
4293 bool MapView::is_dragging() const {
4294 return dragging_;
4295 }
4296@@ -580,18 +596,15 @@
4297 return false;
4298 }
4299
4300- constexpr float kPercentPerKeyPress = 0.10f;
4301 switch (code.sym) {
4302 case SDLK_PLUS:
4303- zoom_around(animation_target_view().view.zoom - kPercentPerKeyPress,
4304- Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4305+ increase_zoom();
4306 return true;
4307 case SDLK_MINUS:
4308- zoom_around(animation_target_view().view.zoom + kPercentPerKeyPress,
4309- Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4310+ decrease_zoom();
4311 return true;
4312 case SDLK_0:
4313- zoom_around(1.f, Vector2f(get_w() / 2.f, get_h() / 2.f), Transition::Smooth);
4314+ reset_zoom();
4315 return true;
4316 default:
4317 return false;
4318
4319=== modified file 'src/wui/mapview.h'
4320--- src/wui/mapview.h 2019-04-25 06:31:33 +0000
4321+++ src/wui/mapview.h 2019-08-10 10:01:32 +0000
4322@@ -163,6 +163,13 @@
4323 // displayed at 'panel_pixel' unchanging, i.e. the center of the zoom.
4324 void zoom_around(float new_zoom, const Vector2f& panel_pixel, const Transition& transition);
4325
4326+ // Reset the zoom to 1.0f
4327+ void reset_zoom();
4328+ // Zoom in a bit
4329+ void increase_zoom();
4330+ // Zoom out a bit
4331+ void decrease_zoom();
4332+
4333 // True if the user is currently dragging the map.
4334 bool is_dragging() const;
4335
4336
4337=== modified file 'src/wui/seafaring_statistics_menu.cc'
4338--- src/wui/seafaring_statistics_menu.cc 2019-06-25 07:34:58 +0000
4339+++ src/wui/seafaring_statistics_menu.cc 2019-08-10 10:01:32 +0000
4340@@ -98,7 +98,7 @@
4341 kButtonSize,
4342 kButtonSize,
4343 UI::ButtonStyle::kWuiPrimary,
4344- g_gr->images().get("images/wui/menus/menu_watch_follow.png"),
4345+ g_gr->images().get("images/wui/menus/watch_follow.png"),
4346 /** TRANSLATORS: Tooltip in the seafaring statistics window */
4347 as_tooltip_text_with_hotkey(_("Watch the selected ship"), "w")),
4348 openwindowbtn_(&navigation_box_,
4349
4350=== modified file 'src/wui/watchwindow.cc'
4351--- src/wui/watchwindow.cc 2019-03-15 21:36:00 +0000
4352+++ src/wui/watchwindow.cc 2019-08-10 10:01:32 +0000
4353@@ -59,12 +59,12 @@
4354 cur_index_(0) {
4355 UI::Button* followbtn =
4356 new UI::Button(this, "follow", 0, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,
4357- g_gr->images().get("images/wui/menus/menu_watch_follow.png"), _("Follow"));
4358+ g_gr->images().get("images/wui/menus/watch_follow.png"), _("Follow"));
4359 followbtn->sigclicked.connect(boost::bind(&WatchWindow::do_follow, this));
4360
4361 UI::Button* gotobtn = new UI::Button(
4362 this, "center_mainview_here", 34, h - 34, 34, 34, UI::ButtonStyle::kWuiSecondary,
4363- g_gr->images().get("images/wui/menus/menu_goto.png"), _("Center the main view on this"));
4364+ g_gr->images().get("images/wui/menus/goto.png"), _("Center the main view on this"));
4365 gotobtn->sigclicked.connect(boost::bind(&WatchWindow::do_goto, this));
4366
4367 if (init_single_window) {
4368
4369=== modified file 'test/maps/lua_testsuite.wmf/scripting/ui.lua'
4370--- test/maps/lua_testsuite.wmf/scripting/ui.lua 2016-12-28 21:59:44 +0000
4371+++ test/maps/lua_testsuite.wmf/scripting/ui.lua 2019-08-10 10:01:32 +0000
4372@@ -23,7 +23,7 @@
4373 end
4374
4375 function ui_tests:test_buttons_property()
4376- assert_not_equal(nil, self.mv.buttons.buildhelp)
4377+ assert_not_nil(self.mv.buttons.help)
4378 end
4379
4380 function ui_tests:test_window_property()
4381@@ -33,7 +33,7 @@
4382 self.mv.buttons.messages:click()
4383 assert_equal(1, self:_cnt(self.mv.windows))
4384
4385- assert_not_equal(nil, self.mv.windows.messages)
4386+ assert_not_nil(self.mv.windows.messages)
4387 end
4388
4389 function ui_tests:test_window_property1()
4390@@ -42,8 +42,8 @@
4391 self.mv.buttons.objectives:click()
4392 assert_equal(1, self:_cnt(self.mv.windows))
4393
4394- assert_not_equal(nil, self.mv.windows.objectives)
4395- assert_equal(nil, self.mv.windows.messages)
4396+ assert_not_nil(self.mv.windows.objectives)
4397+ assert_nil(self.mv.windows.messages)
4398 end
4399
4400 function ui_tests:test_position_x()
4401@@ -78,7 +78,7 @@
4402 function ui_tests:test_descendant_position_not_child()
4403 self.mv.buttons.messages:click()
4404 local w = self.mv.windows.messages
4405- local b = self.mv.buttons.buildhelp
4406+ local b = self.mv.buttons.help
4407
4408 assert_error("Not a descendant!", function()
4409 w:get_descendant_position(b)
4410@@ -105,17 +105,17 @@
4411 -- ========
4412 button_tests = lunit.TestCase("Button tests")
4413 function button_tests:setup()
4414- self.b = wl.ui.MapView().buttons.buildhelp
4415- wl.ui.MapView().buildhelp = false
4416+ self.b = wl.ui.MapView().buttons.help
4417+ for n,w in pairs(wl.ui.MapView().windows) do w:close() end
4418 end
4419
4420 function button_tests:test_name()
4421- assert_equal("buildhelp", self.b.name)
4422+ assert_equal("help", self.b.name)
4423 end
4424 function button_tests:test_click()
4425 self.b:click()
4426
4427- assert_equal(true, wl.ui.MapView().buildhelp)
4428+ assert_not_nil(wl.ui.MapView().windows.encyclopedia)
4429 end
4430
4431 -- =========
4432@@ -159,13 +159,13 @@
4433 function mv_tests:setup()
4434 self.mv = wl.ui.MapView()
4435 self.mv.census = false
4436- self.mv.buildhelp = false
4437+ self.mv.statistics = false
4438 for n,w in pairs(self.mv.windows) do w:close() end
4439 end
4440
4441 function mv_tests:test_click()
4442 self.mv:click(map:get_field(10,10))
4443- assert_not_equal(nil, self.mv.windows.field_action)
4444+ assert_not_nil(self.mv.windows.field_action)
4445 end
4446
4447 function mv_tests:test_census()
4448@@ -179,3 +179,10 @@
4449 assert_equal(true, self.mv.statistics)
4450 assert_equal(false, self.mv.census)
4451 end
4452+
4453+
4454+-- =========
4455+-- Dropdowns
4456+-- =========
4457+
4458+--[[Dropdowns are tested in plain.wmf/test_ui.lua, because we need to call sleep()]]
4459
4460=== added file 'test/maps/plain.wmf/scripting/test_ui.lua'
4461--- test/maps/plain.wmf/scripting/test_ui.lua 1970-01-01 00:00:00 +0000
4462+++ test/maps/plain.wmf/scripting/test_ui.lua 2019-08-10 10:01:32 +0000
4463@@ -0,0 +1,86 @@
4464+-- There are more UI test in lua_testsuite.wmf/ui.lua
4465+
4466+local function open_and_close_sound_options(dropdown, is_debug_build)
4467+ sleep(100)
4468+
4469+ -- Test out-of-range selection in dropdown
4470+ assert_error("Highlighting item 0 should have been out of range", function()
4471+ dropdown:highlight_item(0)
4472+ end)
4473+ assert_error("Highlighting item 2000 should have been out of range", function()
4474+ dropdown:highlight_item(2000)
4475+ end)
4476+
4477+ -- Test selecting an item in the dropdown
4478+ if (is_debug_build) then
4479+ dropdown:highlight_item(2)
4480+ else
4481+ dropdown:highlight_item(1)
4482+ end
4483+ assert_nil(wl.ui.MapView().windows.sound_options_menu, "Sound options window should not have been there yet")
4484+
4485+ dropdown:select()
4486+ sleep(100)
4487+
4488+ window = wl.ui.MapView().windows.sound_options_menu
4489+ assert_not_nil(window, "Failed to open sound options window")
4490+ window:close()
4491+
4492+ sleep(100)
4493+ assert_nil(wl.ui.MapView().windows.sound_options_menu, "Failed to close sound options window")
4494+end
4495+
4496+run(function()
4497+ sleep(100)
4498+
4499+ -- Validate listing dropdowns
4500+ local dropdowns = wl.ui.MapView().dropdowns
4501+ for name,dropdown in pairs(dropdowns) do
4502+ assert_equal(name, dropdown.name)
4503+ end
4504+
4505+ -- Validate dropdown functions
4506+ local dropdown = dropdowns["dropdown_menu_main"]
4507+ assert_not_nil(dropdown, "Failed to find main menu dropdown")
4508+
4509+ local is_debug_build = dropdown.no_of_items == 4
4510+
4511+ -- Selecting from closed dropdown should fail silently
4512+ dropdown:select()
4513+
4514+ -- Validate selection without opening
4515+ open_and_close_sound_options(dropdown, is_debug_build);
4516+
4517+ -- Validate selection with opening
4518+ dropdown:open()
4519+ sleep(100)
4520+ open_and_close_sound_options(dropdown, is_debug_build);
4521+
4522+ -- Exit by dropdown
4523+ local dropdown = dropdowns["dropdown_menu_main"]
4524+ if (is_debug_build) then
4525+ dropdown:highlight_item(4)
4526+ else
4527+ dropdown:highlight_item(3)
4528+ end
4529+ dropdown:select()
4530+
4531+ local message_box = wl.ui.MapView().windows["message_box"]
4532+ assert_not_nil(message_box, "Failed to find exit confirm message box")
4533+ local ok_button = message_box.buttons["ok"]
4534+ assert_not_nil(ok_button, "Exit confirm message box has no 'ok' button")
4535+
4536+ -- We have to print this before closing the main view, otherwise the test suite
4537+ -- will fail this test, because printing to console won't work.
4538+ print("# All Tests passed.")
4539+
4540+ ok_button:click()
4541+
4542+ -- Give Widelands some time to close the map view
4543+ sleep(10000)
4544+ assert_nil(wl.ui.MapView(), "Exiting by main menu did not close the map view")
4545+
4546+ if (wl.ui.MapView() ~= nil) then
4547+ wl.ui.MapView():close()
4548+ end
4549+end)
4550
4551=== modified file 'utils/buildcat.py'
4552--- utils/buildcat.py 2019-01-12 09:44:33 +0000
4553+++ utils/buildcat.py 2019-08-10 10:01:32 +0000
4554@@ -110,7 +110,7 @@
4555 ['../../data/campaigns/%(name)s/extra_data',
4556 '../../data/campaigns/%(name)s/objective',
4557 '../../data/campaigns/%(name)s/scripting/*.lua',
4558- '../../data/scripting/format_scenario.lua'
4559+ '../../data/scripting/richtext_scenarios.lua'
4560 ]
4561 ),
4562 ('map_%(name)s/map_%(name)s', 'data/maps/',

Subscribers

People subscribed via source and target branches

to status/vote changes: